diff --git a/CHANGELOG.md b/CHANGELOG.md index 35bd60e5d..d62d2e240 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,8 @@ All notable changes to Bambuddy will be documented in this file. - **Per-printer Maintenance Mode toggle (#1476, requested by @IndividualGhost1905 / Ferdi SEVER)** — Operator-flipped "out of service" state per printer, surfaced as a wrench icon + amber pill on the card and a checkbox in the Edit Printer dialog. Requested for three real-world scenarios that all share the same shape: (1) parallel Bambuddy installs (dev + prod, primary + warm spare) where the printer rejects concurrent MQTT clients except one, leaving the others in a flicker-online state burning CPU and network; (2) printers under repair / awaiting spare parts that shouldn't accept queue jobs but should remain visible on the dashboard so they aren't forgotten; (3) temporary suspension during maintenance work. **What was already there, what was missing.** The backend field `Printer.is_active: bool` has shipped since the initial Bambuddy release — toggling it via `PATCH /printers/{id}` already disconnects MQTT (`printer_manager.disconnect_printer` at `printers.py:366`), stops the printer from being eligible for queue dispatch (`print_scheduler.py:520, 1588`, `print_queue.py:383`), excludes it from model-based filament lookups (`printers.py:197`), excludes it from metrics + diagnostic snapshots + scheduled-backup runs (`metrics.py:105`, `diagnostic_snapshot.py:126`, `github_backup.py:333`, `maintenance.py:457`), and is already honoured by PrinterSelector (filtered with a "show inactive" override, greyed + "(inactive)" label when shown). All three of Ferdi's use cases were structurally supported by `is_active` from day one. **The missing piece was UI exposure.** `grep is_active` on `PrintersPage.tsx` returned zero hits — no menu item, no edit field, no toggle. The only way to flip it was a direct API call. This change adds the surfaces that should have been there all along. **Card UI — replacement, not addition.** Per Ferdi-conversation feedback, the maintenance state replaces the print-status / cover-image container rather than stacking above it, so card heights stay identical across the grid: in expanded mode the same `` header renders an amber panel (wrench icon + "In Maintenance" + subtitle + Exit button) where the cover + progress would normally be; in compact mode a single amber pill replaces the progress bar. The header connection pill is also swapped — instead of the red "Offline" pill (which would be misleading because the disconnect is deliberate) the card shows an amber "Maintenance" pill, and the "Run Diagnostic" CTA is suppressed (that's reserved for involuntary offline triage). HMS / Queue / Firmware status pills are still gated by `status?.connected` so they fall away naturally with the MQTT disconnect. **Three entry points.** (1) Printer card three-dot overflow menu — `Enter maintenance mode` / `Exit maintenance mode` with a wrench icon, adjacent to the Edit and Reconnect actions. (2) Exit button inside the in-card amber panel, so a user noticing the card from across the room can flip back without opening the menu. (3) Checkbox in the EditPrinterModal — `Maintenance mode` with the same subtitle as the help line, so the toggle is discoverable from the edit dialog too (the checkbox is the inverse of `is_active` because the user-facing concept is "is this in maintenance" not "is it active"). **Mid-print safety prompt.** Entering maintenance mode on a printer in `RUNNING` / `PAUSE` state triggers a confirmation dialog before the toggle fires — disconnecting MQTT mid-print stops progress tracking + completion notifications for the in-flight job, which is usually NOT what the operator wants (they probably meant "after this print finishes"). Idle / FINISH / FAILED states skip the dialog and toggle directly. **What this does NOT change.** No backend change (`is_active` was already wired everywhere); no new permission (uses existing `printers:update`); no behaviour change for any other consumer (queue dispatch, scheduler, metrics, picker, backup — all already honoured `is_active`). The card stays visible on the Printers page (greyed temps/controls/fans below the amber banner) so the printer doesn't disappear from the operator's mental map — Ferdi explicitly wanted to remember it's there. Doesn't auto-pause Smart Plug logic or notification providers (would be a sensible follow-up if Ferdi asks; out of scope here to keep the diff bounded to "expose the existing gate"). The scheduled-maintenance dashboard at `/maintenance` (interval-tracked rod-cleaning / lube / belt tasks via the existing `MaintenanceHistory` and `PrinterMaintenance` models) is conceptually adjacent but operationally distinct — the dashboard tracks "this printer is due for cleaning"; Maintenance Mode tracks "this printer is currently out of service." A future "perform maintenance task → optionally enter maintenance mode while you do it" link is the natural connection but isn't wired here. **i18n.** Twelve new keys under `printers.maintenance.*` (title / subtitle / pillLabel / exitButton / menuEnter / menuExit / toastEntered / toastExited / confirmMidPrintTitle / confirmMidPrintMessage / editFieldLabel / editFieldHelp) — real translations in all 11 locales (de / en / es / fr / it / ja / ko / pt-BR / tr / zh-CN / zh-TW), parity 5228 leaves per locale, no English fallback. **Tests.** 4 new cases in `PrintersPage.test.tsx::'maintenance mode (#1476)'`: amber status panel renders with Exit button (and the regular "No active job" / "Ready to print" copy is absent — confirms the swap, not a stacked render); header pill swaps to amber Maintenance and the diagnostic CTA is suppressed; clicking Exit issues a `PATCH /printers/{id}` with `is_active: true`; active printers never show the maintenance panel. Existing test fixture (`mockPrinters`) got an explicit `is_active: true` to keep the existing 56 tests green on the new render path. **Type:** `PrinterCreate.is_active?: boolean` added to the TypeScript surface so the field flows cleanly through the existing `api.updatePrinter` helper. **Build + checks.** Full PrintersPage vitest 60/60 green; `npm run build` clean; ESLint clean; i18n parity 5228 × 11 locales green. ### Fixed +- **Forecasting now groups spools by colour + Forecast UI rework (#1814, by @Keybored02)** — The Forecast tab previously grouped spools by `(material, subtype, brand)` only, so a farm running Bambu PLA Basic in Jade White, Bambu Green, and Sunrise Orange saw all three pooled under one "Bambu PLA Basic" row — usage rate, reorder point, and lead-time override all averaged across colours the user actually buys and tracks separately. **Grouping key.** `skuKey(material, subtype, brand)` becomes `skuKey(material, subtype, brand, color_name)` everywhere the forecast surface fans out: row keys, settings map, alert banner labels, usage chart series, add-to-cart payloads, shopping-list lookups, CSV export, label rendering. **Pre-upgrade settings preserved via a NULL-colour fallback.** When a colour-keyed group has no own settings row, the panel falls back to the legacy `color_name IS NULL` row at `ForecastPanel.tsx:241-244` so users keep their lead-time / safety-margin customisations from before the migration. Upserts write a NEW colour-specific row — the legacy NULL row stays in place as the implicit "any-colour default" for as-yet-unconfigured colours of the same `(material, subtype, brand)`. **History-rate algorithm rewrite.** `computeHistoryRate` aggregates usage events by UTC calendar day (`r.created_at.slice(0, 10)`) before computing inter-day g/day rates. Fixes two problems: (a) concurrent multi-spool prints on the same day no longer produced near-zero inter-event gaps that inflated per-interval rates (the previous 0.5d floor only partially masked it — multiple spools printing within seconds of each other still cleared 0.5d after rounding); (b) the oldest event's weight is no longer silently dropped — it contributes to its day bucket. Same exponential 30-day half-life weighting (`λ = ln(2)/30`); rate is null when fewer than 2 distinct days of history exist (the existing delta-rate fallback covers the gap). **Reset-spool history filter.** Pre-reset events on a spool that's had "Reset usage" applied (#1390) have no anchor weight and would inflate the post-reset rate; the history pool now skips any spool with `weight_used_baseline > 0` entirely. Conservative: a group whose every spool has been reset gets coarser projection via delta-rate, but never wrong projection from a phantom pre-reset baseline. **UI rework.** New compact table layout: dedicated **Spools** column (was a subtitle line under SKU); full-row stock progress bar with gram value inline; filter chips for **Material** and **Brand** alongside the chart-days toggle (using existing `inventory.material` / `inventory.brand` keys — no new locale work); expanded row collapses the previous two-grid layout into one 4-column compact strip (effective lead time + reorder point + SKU lead-time override + safety margin). Chart tooltip rewritten — date header + one row per series with colour dot and gram value, replaces the per-series-item format that obscured cross-series comparison. Shopping-cart purchase / receive icons resized + opacity tuned for visibility (existing `text-bambu-gray` blended into the surrounding row). **Shopping list carries colour through.** New `color_name` column on `filament_shopping_list`; the modal pre-populates it from the forecast group; CSV export gains a Colour column between Subtype and Weight; labels everywhere render `[brand, material, subtype, colour].filter(Boolean).join(' ')`. CSV header strings switched from hardcoded `'Brand'` / `'Subtype'` to `t('inventory.brand')` / `t('inventory.subtype')` / `t('inventory.color')` (existing depth-1 keys present in all 11 locales). **"SKU Lead Time Override" → "Lead Time Override".** The "SKU" prefix in the expanded row was redundant given the surrounding settings panel context. English label only; other locales keep their existing translations of the prior phrasing — the i18n key is unchanged. **DB migration.** New `color_name VARCHAR(100)` nullable column on `filament_sku_settings` and `filament_shopping_list`. UNIQUE constraint on `filament_sku_settings` widened from `(material, subtype, brand)` to `(material, subtype, brand, color_name)` so the same `(material, subtype, brand)` triple can carry one settings row per colour. **SQLite path** rebuilds the table when the legacy 3-column unique index is detected via `PRAGMA index_list` introspection — idempotent across restarts; once the rebuild has run, the check exits early. **Postgres path** drops and re-adds the named constraint `uq_filament_sku` so the model declaration stays in sync. The drop/re-add is gated on a `pg_constraint` lookup — without the gate, every backend startup would issue both `ALTER TABLE`s, each acquiring an ACCESS EXCLUSIVE lock briefly, churning the constraint for no reason. SQLite + Postgres parity verified per [[feedback_sqlite_and_postgres_upfront]]. **Verification.** `ForecastPanelPermissions` 7/7 green on the merged code. Backend `ruff check backend/` clean across the four touched files (`core/database.py`, `api/routes/inventory.py`, `models/filament_sku_settings.py`, `models/shopping_list.py`). Frontend `npm run build` clean. No new permission. No change to ForecastPanel's existing read/write permission gating. + - **False-positive "Print Stopped" notification on reprint after MQTT reconnect (#1807, reported by @volodymyr-doba)** — Reporter's P1S with a heavily-queued workload sporadically fired a "Print Stopped" push notification while the print was still actively running (screenshots showed 48% progress + a "50% Complete" notification 10 minutes after the spurious stop). Caught in a support bundle: `[RECONCILE] Printer 1: synthesising missed PRINT COMPLETE for archive 31 — subtask_id changed ('1844213296' → '2103771517')` at 10:26:08, immediately after the MQTT reconnect signature (`Requesting firmware version info` + `Sending K-profile priming request`) and immediately followed by `gcode_state: RUNNING` on the same wire — proof the print never actually stopped. **Root cause.** `bambu_mqtt.py:3647` mints a fresh `submission_id` (`int(time.time() * 1000) % 2_147_483_647 or 1`) per dispatch, so the queue-reprinting flow sends a NEW `subtask_id` to the printer each time. `main.py:2564` and `main.py:2773` set `archive.subtask_id` only when the stored value was empty (`not archive.subtask_id`) — so on reprint the row kept the FIRST run's id. When MQTT reconnects mid-print (network blip, printer reboot, Bambuddy restart), `reconcile_stale_active_prints` from #1542 runs against every `status="printing"` archive; `_is_active_archive_stale` at `main.py:3722` compared the stale stored id against the printer's live id, returned `(True, "subtask_id changed (…)")`, and the synthesizer fired a `status="aborted"` payload through `on_print_complete` — which is the exact code path the "Print Stopped" notification listens to. Collateral: the in-progress queue item was marked `cancelled` because the synthesized complete killed Bambuddy's tracking state. **Fix.** Two places in `main.py` — the expected-print promotion branch (line 2564) and the duplicate-printing-archive branch (line 2773) — now update `archive.subtask_id` whenever the new effective id **differs** from the stored one, not only when the stored one is empty. The comparison-based gate preserves the noop-on-stable-push behaviour the original `not archive.subtask_id` guard provided (the same id from a repeat push doesn't trigger a rewrite) while picking up reprint dispatches that mint a fresh id. The path is already inside expected-print promotion — meaning Bambuddy itself dispatched this print in-process — so the live id genuinely belongs to this archive; the write is safe. **Why the second notification ("Nozzle/Extruder Error") in the screenshot is unrelated.** That's a separate HMS event at 10:26:25, likely a stored error code the printer flushed on reconnect. The queue scheduler correctly observed `state=RUNNING, awaiting_plate_clear=True` at 10:26:08 and did NOT try to dispatch the next queue item, so the HMS "Device is busy" reason is NOT a side-effect of the bogus reconcile — both notifications fired in the same minute because they share a common trigger (the MQTT reconnect). **Tests.** 3 new cases in `test_reprint_updates_subtask_id.py` exercising the actual `on_print_start` expected-archive path: stale stored id gets rewritten on reprint (the #1807 scenario, asserts `archive.subtask_id == "2103771517"`); first-run still sets the id on an archive with `subtask_id=None`; stable repeat-push with the same id leaves the field untouched. Mocks the full session / printer / notification / WS / smart-plug / MQTT-relay surface that `on_print_start` touches so the test stays unit-fast. Full backend `pytest -n 8`: 552/552 in 17 s on the print-lifecycle suite. Ruff clean. **Scope.** Two-line guard rewrite; no DB migration, no schema change, no notification surface change, no frontend change. The reconciler itself (the consumer of `archive.subtask_id`) stays unchanged — it was doing the right thing given the data it had. - **SpoolBuddy "Assign to AMS" pushed Generic instead of the user's custom slicer preset (#1815, reported by @Bgabor997)** — On P1S, assigning a spool with a Bambu Cloud user preset (PFUS-prefix `slicer_filament`) via SpoolBuddy left Bambu Studio's Device tab showing "Generic " instead of the actual custom preset (e.g. "Jayo PETG HF (Custom)"). Manual "Configure" from Bambuddy's AMS card with the same preset worked correctly — reporter triple-checked the preset existed in their slicer and that Bambuddy's inventory showed the right name. **Root cause** in `slicer_filament_resolver.py:197-203`: the defensive filter that catches PFUS / PFCN cloud-preset IDs leaking into `tray_info_idx` (the printer's calibration table can't key on cloud-preset hashes) cleared `setting_id` alongside `tray_info_idx`. `setting_id` is what the slicer uses to find the actual preset, and PFUS / PFCN are VALID values there — they're only invalid as `tray_info_idx`. When the Bambu Cloud detail lookup didn't return a `filament_id` (cloud-unauth on the `on_ams_change` replay path, transient cloud failure, or older custom presets whose detail JSON omits `filament_id`), the resolver fell through to `normalize_slicer_filament` which round-tripped the PFUS as `tray_info_idx`, the defensive filter fired, BOTH fields were cleared, and the caller's generic-material fallback at `inventory.py:157-165` filled `tray_info_idx=GFG99` AND `setting_id=GFSG99` — Bambu Studio resolved the slot to Generic PETG. The manual Configure modal works because the frontend at `ConfigureAmsSlotModal.tsx:503-512` calls the cloud detail API itself, sets `trayInfoIdx` to the resolved `filament_id`, and **preserves** the `PFUS` as `setting_id` in the request — so the backend's MQTT push lands both correct fields. **Fix.** The defensive filter still clears `tray_info_idx` for PFUS / PFCN / material-name leaks, but now preserves `setting_id` when it's a valid slicer reference (`PFUS` / `PFCN` cloud user/shared preset, or `GFS` Bambu official preset). Material-name leaks (e.g. `setting_id="PETG"`) are still cleared — those are never valid slicer references. Post-fix MQTT push carries `tray_info_idx=GFG99` (generic — firmware-acceptable for HMS / drying / colour matching) AND `setting_id=PFUS` (slicer uses this to load the user's actual custom preset). **What stays the same.** Bambuddy's own AMS card still reads `tray_info_idx` from `raw_data` and displays the generic material on cloud-unauth paths — same fundamental limitation as today, because without cloud resolution the backend has no way to know the real `P*` filament_id. This is the secondary symptom the reporter mentioned ("Bambuddy configure modal also shows Generic as default"); fixing it requires a deeper layered fallback (look up `LocalPreset` by name, or query the printer's live `kprofiles`, or cache the resolved cloud detail) and is out of scope for this drop. The slicer-side fix is the user's explicit ask. **Tests.** 5 new cases in `test_slicer_filament_resolver.py`: PFUS cloud-unavailable preserves setting_id (reporter's scenario); PFCN cloud-unavailable preserves setting_id (#1648 partner-preset shape); PFUS cloud-resolved still works as before (regression guard); GFS cloud-unavailable resolves via `normalize_slicer_filament` (regression guard for the Bambu-official cloud-down path); literal material name ("PETG") still clears both (regression guard that PFUS preservation doesn't accidentally preserve material-name leaks). Full backend `pytest -n 30`: 6410/6410 in 73 s. Ruff clean. **Scope.** No DB / API surface / i18n / frontend changes. No change to the caller (`apply_spool_to_slot_via_mqtt`) — its `if tray_info_idx and not setting_id` guard at `inventory.py:172` already preserves whatever setting_id the resolver returns. No change to the manual Configure modal path (already carried both fields end-to-end). The `on_ams_change` replay path in `main.py` (which passes `current_user=None` and was the original motivator for the defensive filter) now also preserves setting_id — same desired outcome since the replay only fires when SpoolBuddy pre-assigned an empty slot and the spool was later inserted, and the slicer needs the setting_id to resolve the right preset. diff --git a/backend/app/core/database.py b/backend/app/core/database.py index 5b977f228..1aaba895e 100644 --- a/backend/app/core/database.py +++ b/backend/app/core/database.py @@ -2655,9 +2655,12 @@ async def run_migrations(conn): await _safe_execute( conn, "ALTER TABLE filament_sku_settings ADD COLUMN alerts_snoozed BOOLEAN NOT NULL DEFAULT 0" ) - # Migration: add color_name so forecasts distinguish colours within a SKU. + # Migration: add color_name to filament_sku_settings so forecasts + # distinguish colours within a SKU. The matching ALTER for + # filament_shopping_list runs AFTER that table's CREATE below — on + # fresh installs the table doesn't exist yet at this point and + # _safe_execute does not swallow "no such table". await _safe_execute(conn, "ALTER TABLE filament_sku_settings ADD COLUMN color_name VARCHAR(100)") - await _safe_execute(conn, "ALTER TABLE filament_shopping_list ADD COLUMN color_name VARCHAR(100)") # Backfill and drop legacy safety_margin_days column — SQLite requires a table rebuild. # Only run if the stale column still exists. cols_result = await conn.execute(text("PRAGMA table_info(filament_sku_settings)")) @@ -2766,6 +2769,10 @@ async def run_migrations(conn): added_at DATETIME DEFAULT CURRENT_TIMESTAMP )""", ) + # Backfill color_name on pre-#1814 upgrades — the CREATE above already + # has it for fresh installs; the ALTER is the upgrade path. "duplicate + # column name" is swallowed by _safe_execute, so re-runs are no-ops. + await _safe_execute(conn, "ALTER TABLE filament_shopping_list ADD COLUMN color_name VARCHAR(100)") # SQLite has no implicit updated_at trigger — add one so the column stays current. await _safe_execute( conn, @@ -2806,10 +2813,12 @@ async def run_migrations(conn): conn, "ALTER TABLE filament_sku_settings ADD COLUMN IF NOT EXISTS alerts_snoozed BOOLEAN NOT NULL DEFAULT FALSE", ) - # Migration: add color_name and widen the unique key to include it so - # forecasts distinguish colours within a SKU (#forecast-color-grouping). + # Migration: add color_name to filament_sku_settings and widen the + # unique key to include it so forecasts distinguish colours within a + # SKU (#forecast-color-grouping). The matching ALTER for + # filament_shopping_list runs AFTER that table's CREATE below — on + # fresh installs the table doesn't exist yet at this point. await _safe_execute(conn, "ALTER TABLE filament_sku_settings ADD COLUMN IF NOT EXISTS color_name VARCHAR(100)") - await _safe_execute(conn, "ALTER TABLE filament_shopping_list ADD COLUMN IF NOT EXISTS color_name VARCHAR(100)") # Widen UNIQUE (material, subtype, brand) → (material, subtype, brand, color_name). # The original constraint was declared with name="uq_filament_sku" in the # model, so we drop/re-add by that name. Gated on a pg_constraint lookup so @@ -2868,6 +2877,9 @@ async def run_migrations(conn): "ALTER TABLE filament_shopping_list ADD COLUMN IF NOT EXISTS status VARCHAR(20) NOT NULL DEFAULT 'pending'", ) await _safe_execute(conn, "ALTER TABLE filament_shopping_list ADD COLUMN IF NOT EXISTS purchased_at TIMESTAMP") + # Backfill color_name on pre-#1814 upgrades — the CREATE above already + # has it for fresh installs; the ALTER is the upgrade path. + await _safe_execute(conn, "ALTER TABLE filament_shopping_list ADD COLUMN IF NOT EXISTS color_name VARCHAR(100)") # Migration: Add inventory stock alert columns to notification_providers. # Postgres rejects `DEFAULT 0` for BOOLEAN columns. diff --git a/static/assets/index-Nmah4kx-.js b/static/assets/index-B9FR66k0.js similarity index 89% rename from static/assets/index-Nmah4kx-.js rename to static/assets/index-B9FR66k0.js index 9f7469c85..416ef4dd3 100644 --- a/static/assets/index-Nmah4kx-.js +++ b/static/assets/index-B9FR66k0.js @@ -9,7 +9,7 @@ Error generating stack: `+e.message+` `).replace($,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Rt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Rt(e,``+r);break;case`className`:Ct(e,`class`,r);break;case`tabIndex`:Ct(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ct(e,n,r);break;case`style`:Vt(e,r,o);break;case`data`:if(t!==`object`){Ct(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Gt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Gt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Kt);break;case`onScroll`:r!=null&&yd(`scroll`,e);break;case`onScrollEnd`:r!=null&&yd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Gt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:yd(`beforetoggle`,e),yd(`toggle`,e),St(e,`popover`,r);break;case`xlinkActuate`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:wt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:wt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:St(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Mt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Mt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Mt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Mt(n.imageSizes)+`"]`)):i+=`[href="`+Mt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),pt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Mt(r)+`"][href="`+Mt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),pt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=ft(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);pt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=ft(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),pt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=ft(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),pt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ie.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=ft(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=ft(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=ft(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Mt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),pt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Mt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Mt(n.href)+`"]`);if(r)return t.instance=r,pt(r),r;var a=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),pt(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,pt(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,pt(a),a):(r=n,(a=mf.get(o))&&(r=p({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),pt(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,pt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=_()})),y=l(f()),b=v(),x=e=>typeof e==`string`,S=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},C=e=>e==null?``:``+e,w=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},T=/###/g,E=e=>e&&e.indexOf(`###`)>-1?e.replace(T,`.`):e,D=e=>!e||x(e),O=(e,t,n)=>{let r=x(t)?t.split(`.`):t,i=0;for(;i{let{obj:r,k:i}=O(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=O(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=O(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},A=(e,t,n,r)=>{let{obj:i,k:a}=O(e,t,Object);i[a]=i[a]||[],i[a].push(n)},j=(e,t)=>{let{obj:n,k:r}=O(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},M=(e,t,n)=>{let r=j(e,n);return r===void 0?j(t,n):r},N=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?x(e[r])||e[r]instanceof String||x(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):N(e[r],t[r],n):e[r]=t[r]);return e},P=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),F={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},I=e=>x(e)?e.replace(/[&<>"'\/]/g,e=>F[e]):e,L=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},R=[` `,`,`,`?`,`!`,`;`],z=new L(20),B=(e,t,n)=>{t||=``,n||=``;let r=R.filter(e=>t.indexOf(e)<0&&n.indexOf(e)<0);if(r.length===0)return!0;let i=z.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},V=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e-1&&oe?.replace(`_`,`-`),te={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},ne=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||te,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(x(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},re=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r{for(let i=0;i-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.indexOf(`.`)>-1?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):x(n)&&i?o.push(...n.split(i)):o.push(n)));let s=j(this.data,o);return!s&&!t&&!n&&e.indexOf(`.`)>-1&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!x(n)?s:V(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(`.`)>-1&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),k(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(x(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.indexOf(`.`)>-1&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=j(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?N(s,n,i):s={...s,...n},k(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},H={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},ae=Symbol(`i18next/PATH_KEY`);function oe(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===ae?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function U(e,t){let{[ae]:n}=e(oe());return n.join(t?.keySeparator??`.`)}var se={},ce=e=>!x(e)&&typeof e!=`boolean`&&typeof e!=`number`,le=class e extends re{constructor(e,t={}){super(),w([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=ne.create(`translator`)}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=ce(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!B(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:x(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(a[0])>-1)&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:x(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=U(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]);let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!x(i.count),S=e.hasDefaultValue(i),C=b?this.pluralResolver.getSuffix(d,i.count,i):``,w=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,T=b&&!i.ordinal&&i.count===0,E=T&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${w}`]||i.defaultValue,D=m;y&&!m&&S&&(D=E);let O=ce(D),k=Object.prototype.toString.apply(D);if(y&&D&&O&&_.indexOf(k)<0&&!(x(v)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,D,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(D),t=e?[]:{},n=e?g:h;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${o}${e}`;S&&!m?t[e]=this.translate(r,{...i,defaultValue:ce(E)?E[e]:void 0,joinArrays:!1,ns:c}):t[e]=this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=D[e])}m=t}}else if(y&&x(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&S&&(e=!0,m=E),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=S&&E!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,s,c?E:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n{let r=S&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);T&&i[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||E)})}):n(e,s,E))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=x(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!x(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;oi?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=x(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=H.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return x(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!x(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(x(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!se[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(se[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.indexOf(i)===0&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.indexOf(i)===0&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!x(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.substring(0,12)===`defaultValue`&&e[t]!==void 0)return!0;return!1}},ue=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ne.create(`languageUtils`)}getScriptPartFromCode(e){if(e=ee(e),!e||e.indexOf(`-`)<0)return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=ee(e),!e||e.indexOf(`-`)<0)return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(x(e)&&e.indexOf(`-`)>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>{if(e===r||!(e.indexOf(`-`)<0&&r.indexOf(`-`)<0)&&(e.indexOf(`-`)>0&&r.indexOf(`-`)<0&&e.substring(0,e.indexOf(`-`))===r||e.indexOf(r)===0&&r.length>1))return e})}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),x(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return x(e)&&(e.indexOf(`-`)>-1||e.indexOf(`_`)>-1)?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):x(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.indexOf(e)<0&&i(this.formatLanguageCode(e))}),r}},de={zero:0,one:1,two:2,few:3,many:4,other:5},fe={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},pe=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=ne.create(`pluralResolver`),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=ee(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(!Intl)return this.logger.error(`No Intl support, please use an Intl polyfill!`),fe;if(!e.match(/-|_/))return fe;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>de[e]-de[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},me=(e,t,n,r=`.`,i=!0)=>{let a=M(e,t,n);return!a&&i&&x(n)&&(a=V(e,n,r),a===void 0&&(a=V(t,n,r))),a},he=e=>e.replace(/\$/g,`$$$$`),ge=class{constructor(e={}){this.logger=ne.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?I:t,this.escapeValue=n===void 0?!0:n,this.useRawValueToEscape=r===void 0?!1:r,this.prefix=i?P(i):a||`{{`,this.suffix=o?P(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u||`-`,this.unescapeSuffix=this.unescapePrefix?``:l||``,this.nestingPrefix=d?P(d):f||P(`$t(`),this.nestingSuffix=p?P(p):m||P(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_===void 0?!1:_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(e.indexOf(this.formatSeparator)<0){let i=me(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(me(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp();let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>he(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?he(this.escape(e)):he(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0)if(typeof l==`function`){let t=l(e,i,r);a=x(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``;else !x(a)&&!this.useRawValueToEscape&&(a=C(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;let r=e.split(RegExp(`${n}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!x(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=/{.*}/.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(c!==-1&&(s=r[1].slice(c).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,c)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!x(i))return i;x(i)||(i=C(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),s.length&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},_e=e=>{let t=e.toLowerCase().trim(),n={};if(e.indexOf(`(`)>-1){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].substring(0,r[1].length-1);t===`currency`&&i.indexOf(`:`)<0?n.currency||=i.trim():t===`relativetime`&&i.indexOf(`:`)<0?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},ve=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(ee(r),i),t[o]=s),s(n)}},ye=e=>(t,n,r)=>e(ee(n),r)(t),be=class{constructor(e={}){this.logger=ne.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?ve:ye;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=ve(t)}format(e,t,n,r={}){let i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf(`(`)>1&&i[0].indexOf(`)`)<0&&i.find(e=>e.indexOf(`)`)>-1)){let e=i.findIndex(e=>e.indexOf(`)`)>-1);i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:a}=_e(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}else this.logger.warn(`there was no format function for ${i}`);return e},e)}},xe=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},Se=class extends re{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=ne.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{A(n.loaded,[i],a),xe(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r{this.read.call(this,e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();x(e)&&(e=this.languageUtils.toResolveHierarchy(e)),x(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(!(n==null||n===``)){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}!e||!e[0]||this.store.addResource(e[0],t,n,r)}}},Ce=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,simplifyPluralSuffix:!0,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),x(e[1])&&(t.defaultValue=e[1]),x(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),we=e=>(x(e.ns)&&(e.ns=[e.ns]),x(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),x(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.(`cimode`)<0&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),typeof e.initImmediate==`boolean`&&(e.initAsync=e.initImmediate),e),Te=()=>{},Ee=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},De=class e extends re{constructor(e={},t){if(super(),this.options=we(e),this.services={},this.logger=ne,this.modules={external:[]},Ee(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(x(e.ns)?e.defaultNS=e.ns:e.ns.indexOf(`translation`)<0&&(e.defaultNS=e.ns[0]));let n=Ce();this.options={...n,...this.options,...we(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?ne.init(r(this.modules.logger),this.options):ne.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:be;let t=new ue(this.options);this.store=new ie(this.options.resources,this.options);let i=this.services;i.logger=ne,i.resourceStore=this.store,i.languageUtils=t,i.pluralResolver=new pe(t,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format&&this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`),e&&(!this.options.interpolation.format||this.options.interpolation.format===n.interpolation.format)&&(i.formatter=r(e),i.formatter.init&&i.formatter.init(i,this.options),this.options.interpolation.format=i.formatter.format.bind(i.formatter)),i.interpolator=new ge(this.options),i.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},i.backendConnector=new Se(r(this.modules.backend),i.resourceStore,i,this.options),i.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(i.languageDetector=r(this.modules.languageDetector),i.languageDetector.init&&i.languageDetector.init(i,this.options.detection,this.options)),this.modules.i18nFormat&&(i.i18nFormat=r(this.modules.i18nFormat),i.i18nFormat.init&&i.i18nFormat.init(this)),this.translator=new le(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=Te,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=S(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=Te){let n=t,r=x(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&e.indexOf(t)<0&&e.push(t)})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=S();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=Te,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&H.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!([`cimode`,`dev`].indexOf(e)>-1)){for(let e=0;e-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&this.languages.indexOf(e)<0&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=S();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=x(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(x(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n){let r=(e,t,...i)=>{let a;a=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(i)),a.lng=a.lng||r.lng,a.lngs=a.lngs||r.lngs,a.ns=a.ns||r.ns,a.keyPrefix!==``&&(a.keyPrefix=a.keyPrefix||n||r.keyPrefix);let o=this.options.keySeparator||`.`,s;return a.keyPrefix&&Array.isArray(e)?s=e.map(e=>(typeof e==`function`&&(e=U(e,{...this.options,...t})),`${a.keyPrefix}${o}${e}`)):(typeof e==`function`&&(e=U(e,{...this.options,...t})),s=a.keyPrefix?`${a.keyPrefix}${o}${e}`:e),this.t(s,a)};return x(e)?r.lng=e:r.lngs=e,r.ns=t,r.keyPrefix=n,r}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=S();return this.options.ns?(x(e)&&(e=[e]),e.forEach(e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=S();x(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new ue(Ce());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=Te){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);return(t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new ie(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),a.translator=new le(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();De.createInstance,De.dir,De.init,De.loadResources,De.reloadResources,De.use,De.changeLanguage,De.getFixedT,De.t,De.exists,De.setDefaultNamespace,De.hasLoadedNamespace,De.loadNamespaces,De.loadLanguages;var Oe=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Fe(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},ke={},Ae=(e,t,n,r)=>{Fe(n)&&ke[n]||(Fe(n)&&(ke[n]=new Date),Oe(e,t,n,r))},je=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},Me=(e,t,n)=>{e.loadNamespaces(t,je(e,n))},Ne=(e,t,n,r)=>{if(Fe(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Me(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,je(e,r))},Pe=(e,t,n={})=>!t.languages||!t.languages.length?(Ae(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Fe=e=>typeof e==`string`,Ie=e=>typeof e==`object`&&!!e,Le=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Re={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":` `," ":` `,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},ze=e=>Re[e],Be={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(Le,ze),transDefaultProps:void 0},Ve=(e={})=>{Be={...Be,...e}},He=()=>Be,Ue,We=e=>{Ue=e},Ge=()=>Ue,Ke={type:`3rdParty`,init(e){Ve(e.options.react),We(e)}},qe=(0,y.createContext)(),Je=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},Ye=o((e=>{var t=f();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Xe=o(((e,t)=>{t.exports=Ye()})),Ze=Xe(),Qe={t:(e,t)=>Fe(t)?t:Ie(t)&&Fe(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e,ready:!1},$e=()=>()=>{},W=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,y.useContext)(qe)||{},a=n||r||Ge();a&&!a.reportNamespaces&&(a.reportNamespaces=new Je),a||Ae(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let o=(0,y.useMemo)(()=>({...He(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c}=o,l=e||i||a?.options?.defaultNS,u=Fe(l)?[l]:l||[`translation`],d=(0,y.useMemo)(()=>u,u);a?.reportNamespaces?.addUsedNamespaces?.(d);let f=(0,y.useRef)(0),p=(0,y.useCallback)(e=>{if(!a)return $e;let{bindI18n:t,bindI18nStore:n}=o,r=()=>{f.current+=1,e()};return t&&a.on(t,r),n&&a.store.on(n,r),()=>{t&&t.split(` `).forEach(e=>a.off(e,r)),n&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,o]),m=(0,y.useRef)(),h=(0,y.useCallback)(()=>{if(!a)return Qe;let e=!!(a.isInitialized||a.initializedStoreOnce)&&d.every(e=>Pe(e,a,o)),n=t.lng||a.language,r=f.current,i=m.current;if(i&&i.ready===e&&i.lng===n&&i.keyPrefix===c&&i.revision===r)return i;let s={t:a.getFixedT(n,o.nsMode===`fallback`?d:d[0],c),ready:e,lng:n,keyPrefix:c,revision:r};return m.current=s,s},[a,d,c,o,t.lng]),[g,_]=(0,y.useState)(0),{t:v,ready:b}=(0,Ze.useSyncExternalStore)(p,h,h);(0,y.useEffect)(()=>{if(a&&!b&&!s){let e=()=>_(e=>e+1);t.lng?Ne(a,t.lng,d,e):Me(a,d,e)}},[a,t.lng,d,b,s,g]);let x=a||{},S=(0,y.useRef)(null),C=(0,y.useRef)(),w=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},T=(0,y.useMemo)(()=>{let e=x,t=e?.language,n=e;e&&(S.current&&S.current.__original===e&&C.current===t?n=S.current:(n=w(e),S.current=n,C.current=t));let r=[v,n,b];return r.t=v,r.i18n=n,r.ready=b,r},[v,x,b,x.resolvedLanguage,x.language,x.languages]);if(a&&s&&!b)throw new Promise(e=>{let n=()=>e();t.lng?Ne(a,t.lng,d,n):Me(a,d,n)});return T},{slice:et,forEach:tt}=[];function nt(e){return tt.call(et.call(arguments,1),t=>{if(t)for(let n in t)e[n]===void 0&&(e[n]=t[n])}),e}function rt(e){return typeof e==`string`?[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(e)):!1}var it=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,at=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:`/`},r=`${e}=${encodeURIComponent(t)}`;if(n.maxAge>0){let e=n.maxAge-0;if(Number.isNaN(e))throw Error(`maxAge should be a Number`);r+=`; Max-Age=${Math.floor(e)}`}if(n.domain){if(!it.test(n.domain))throw TypeError(`option domain is invalid`);r+=`; Domain=${n.domain}`}if(n.path){if(!it.test(n.path))throw TypeError(`option path is invalid`);r+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!=`function`)throw TypeError(`option expires is invalid`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:r+=`; SameSite=Strict`;break;case`lax`:r+=`; SameSite=Lax`;break;case`strict`:r+=`; SameSite=Strict`;break;case`none`:r+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return n.partitioned&&(r+=`; Partitioned`),r},ot={create(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:`/`,sameSite:`strict`};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=at(e,t,i)},read(e){let t=`${e}=`,n=document.cookie.split(`;`);for(let e=0;e-1&&(e=window.location.hash.substring(window.location.hash.indexOf(`?`)));let r=e.substring(1).split(`&`);for(let e=0;e0&&r[e].substring(0,i)===t&&(n=r[e].substring(i+1))}}return n}},lt={name:`hash`,lookup(e){let{lookupHash:t,lookupFromHashIndex:n}=e,r;if(typeof window<`u`){let{hash:e}=window.location;if(e&&e.length>2){let i=e.substring(1);if(t){let e=i.split(`&`);for(let n=0;n0&&e[n].substring(0,i)===t&&(r=e[n].substring(i+1))}}if(r)return r;if(!r&&n>-1){let t=e.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof n==`number`?n:0]?.replace(`/`,``):void 0}}}return r}},ut=null,dt=()=>{if(ut!==null)return ut;try{if(ut=typeof window<`u`&&window.localStorage!==null,!ut)return!1;let e=`i18next.translate.boo`;window.localStorage.setItem(e,`foo`),window.localStorage.removeItem(e)}catch{ut=!1}return ut},ft={name:`localStorage`,lookup(e){let{lookupLocalStorage:t}=e;if(t&&dt())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:n}=t;n&&dt()&&window.localStorage.setItem(n,e)}},pt=null,mt=()=>{if(pt!==null)return pt;try{if(pt=typeof window<`u`&&window.sessionStorage!==null,!pt)return!1;let e=`i18next.translate.boo`;window.sessionStorage.setItem(e,`foo`),window.sessionStorage.removeItem(e)}catch{pt=!1}return pt},ht={name:`sessionStorage`,lookup(e){let{lookupSessionStorage:t}=e;if(t&&mt())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:n}=t;n&&mt()&&window.sessionStorage.setItem(n,e)}},gt={name:`navigator`,lookup(e){let t=[];if(typeof navigator<`u`){let{languages:e,userLanguage:n,language:r}=navigator;if(e)for(let n=0;n0?t:void 0}},_t={name:`htmlTag`,lookup(e){let{htmlTag:t}=e,n,r=t||(typeof document<`u`?document.documentElement:null);return r&&typeof r.getAttribute==`function`&&(n=r.getAttribute(`lang`)),n}},vt={name:`path`,lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>`u`)return;let n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(Array.isArray(n))return n[typeof t==`number`?t:0]?.replace(`/`,``)}},yt={name:`subdomain`,lookup(e){let{lookupFromSubdomainIndex:t}=e,n=typeof t==`number`?t+1:1,r=typeof window<`u`&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},bt=!1;try{document.cookie,bt=!0}catch{}var xt=[`querystring`,`cookie`,`localStorage`,`sessionStorage`,`navigator`,`htmlTag`];bt||xt.splice(1,1);var St=()=>({order:xt,lookupQuerystring:`lng`,lookupCookie:`i18next`,lookupLocalStorage:`i18nextLng`,lookupSessionStorage:`i18nextLng`,caches:[`localStorage`],excludeCacheFor:[`cimode`],convertDetectedLanguage:e=>e}),Ct=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type=`languageDetector`,this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=nt(t,this.options||{},St()),typeof this.options.convertDetectedLanguage==`string`&&this.options.convertDetectedLanguage.indexOf(`15897`)>-1&&(this.options.convertDetectedLanguage=e=>e.replace(`-`,`_`)),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(st),this.addDetector(ct),this.addDetector(ft),this.addDetector(ht),this.addDetector(gt),this.addDetector(_t),this.addDetector(vt),this.addDetector(yt),this.addDetector(lt)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(e=>{if(this.detectors[e]){let n=this.detectors[e].lookup(this.options);n&&typeof n==`string`&&(n=[n]),n&&(t=t.concat(n))}}),t=t.filter(e=>e!=null&&!rt(e)).map(e=>this.options.convertDetectedLanguage(e)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(t=>{this.detectors[t]&&this.detectors[t].cacheUserLanguage(e,this.options)}))}};Ct.type=`languageDetector`;var wt={en:{translation:{nav:{printers:`Printers`,archives:`Archives`,queue:`Print Queue`,stats:`Statistics`,profiles:`Profiles`,maintenance:`Maintenance`,projects:`Projects`,inventory:`Filament`,files:`File Manager`,makerworld:`MakerWorld`,notifications:`Notifications`,settings:`Settings`,system:`System`,collapseSidebar:`Collapse sidebar`,expandSidebar:`Expand sidebar`,update:`Update`,updateAvailable:`Update available: v{{version}}`,updateAvailableBanner:`Version {{version}} is available!`,viewUpdate:`View update`,viewOnGithub:`View on GitHub`,keyboardShortcuts:`Keyboard shortcuts (?)`,switchToLight:`Switch to light mode`,switchToDark:`Switch to dark mode`,switchToSystem:`Switch to system mode`,smartSwitches:`Smart Switches`,logout:`Logout`,installApp:`Install app`,installAppSuccess:`Bambuddy was installed`},common:{save:`Save`,saving:`Saving...`,cancel:`Cancel`,delete:`Delete`,edit:`Edit`,add:`Add`,close:`Close`,confirm:`Confirm`,loading:`Loading...`,error:`Error`,errorLoading:`Error loading data`,retry:`Retry`,success:`Success`,warning:`Warning`,enabled:`Enabled`,disabled:`Disabled`,yes:`Yes`,no:`No`,on:`On`,off:`Off`,all:`All`,none:`None`,search:`Search`,filter:`Filter`,sort:`Sort`,refresh:`Refresh`,download:`Download`,upload:`Upload`,uploading:`Uploading...`,uploadFailed:`Upload failed`,actions:`Actions`,status:`Status`,name:`Name`,description:`Description`,date:`Date`,time:`Time`,hours:`hours`,minutes:`minutes`,seconds:`seconds`,days:`days`,enable:`Enable`,disable:`Disable`,permissions:`Permissions`,noPrinters:`No printers configured`,noData:`No data available`,linkNotFound:`Link not found`,required:`Required`,optional:`Optional`,dismiss:`Dismiss`,apply:`Apply`,reset:`Reset`,export:`Export`,import:`Import`,clear:`Clear`,selectAll:`Select All`,deselectAll:`Deselect All`,noChange:`— No change —`,unchanged:`Unchanged`,unassigned:`Unassigned`,unknown:`Unknown`,unknownError:`Unknown error`,today:`Today`,tomorrow:`Tomorrow`,asap:`ASAP`,overdue:`Overdue`,now:`Now`,collapse:`Collapse`,expand:`Expand`,viewArchive:`View archive`,viewInFileManager:`View in File Manager`,addedBy:`Added by {{username}}`,prints:`prints`,more:`+{{count}} more`,ascending:`Ascending`,descending:`Descending`,back:`Back`,copy:`Copy`,copied:`Copied!`,printer:`Printer`,remove:`Remove`,type:`Type`,print:`Print`,rename:`Rename`,move:`Move`,create:`Create`,duplicate:`Duplicate`,left:`Left`,right:`Right`},printers:{title:`Printers`,addPrinter:`Add Printer`,addPreflight:{checking:`Checking connection...`,warning:`Some connection checks failed. This printer may show as offline. Review the checks below, fix what you can, or save anyway.`,back:`Back`,saveAnyway:`Save anyway`},editPrinter:`Edit Printer`,deletePrinter:`Delete Printer`,printerName:`Printer Name`,serialNumber:`Serial Number`,ipAddress:`IP Address / Hostname`,accessCode:`Access Code`,model:`Model`,nozzleCount:`Nozzle Count`,autoArchive:`Auto Archive`,status:{available:`Available`,idle:`Idle`,printing:`Printing`,paused:`Paused`,offline:`Offline`,problem:`Problem`,error:`Error`,finished:`Finished`,unknown:`Unknown`},temperatures:{nozzle:`Nozzle`,bed:`Bed`,chamber:`Chamber`},heaterHistory:{title:`Heater History`,openLabel:`View heater history`,nozzle:`Nozzle`,nozzle2:`Nozzle 2`,bed:`Bed`,chamber:`Chamber`,error:`Failed to load history`,empty:`No data recorded yet`},progress:`{{percent}}% complete`,timeRemaining:`{{time}} remaining`,deleteConfirm:`Are you sure you want to delete "{{name}}"?`,maintenanceOk:`Maintenance OK`,maintenanceWarning:`{{count}} warning`,maintenanceWarning_plural:`{{count}} warnings`,maintenanceDue:`{{count}} due`,maintenanceDue_plural:`{{count}} due`,sort:{name:`Name`,status:`Status`,model:`Model`,location:`Location`,eta:`ETA`,ascending:`Sort ascending`,descending:`Sort descending`},cardSize:{small:`Small cards`,medium:`Medium cards`,large:`Large cards`,extraLarge:`Extra large cards`},hideOffline:`Hide offline`,nextAvailable:`Next available`,powerOn:`Power On`,offlinePrintersWithPlugs:`Offline printers with smart plugs`,noPrintersConfigured:`No printers configured yet`,search:`Search printers...`,noSearchResults:`No printers match your search or filters`,filter:{allStatuses:`All statuses`,allLocations:`All locations`},toolbar:{filters:`Filters`,view:`View`,actions:`Actions`},readyToPrint:`Ready to print`,external:`External`,extL:`Ext-L`,extR:`Ext-R`,deleteArchives:`Delete print archives`,noLabel:`No label`,printPreview:`Print preview`,width:`Width`,height:`Height`,noObjectsFound:`No objects found`,objectsLoadedOnPrintStart:`Objects are loaded when a print starts`,willBeSkipped:`Will be skipped`,name:`Name`,serialCannotBeChanged:`Serial number cannot be changed`,locationHelp:`Used to group printers and filter queue jobs`,wifiSignal:{veryWeak:`Very weak`,weak:`Weak`,fair:`Fair`,good:`Good`,excellent:`Excellent`},maintenanceUpToDate:`All maintenance up to date - Click to view`,maintenance:{title:`In Maintenance`,subtitle:`This printer is paused — not connected, not eligible for the queue, not sending notifications.`,pillLabel:`Maintenance`,exitButton:`Exit maintenance`,menuEnter:`Enter maintenance mode`,menuExit:`Exit maintenance mode`,toastEntered:`{{name}} is now in maintenance mode`,toastExited:`{{name}} is back online`,confirmMidPrintTitle:`Enter maintenance mode mid-print?`,confirmMidPrintMessage:`{{name}} is currently printing. Entering maintenance mode will disconnect MQTT and stop progress tracking and completion notifications for this job. Continue?`,editFieldLabel:`Maintenance mode`,editFieldHelp:`When on, this printer is paused from MQTT, queue dispatch and notifications — useful for repair, parallel Bambuddy installs, or temporary suspension.`},chamberLightOn:`Turn on chamber light`,chamberLightOff:`Turn off chamber light`,files:`Files`,browseFiles:`Browse printer files`,autoOffAfterPrint:`Auto power-off after print`,autoOffExecuted:`Auto-off was executed - turn printer on to reset`,hmsErrors:`HMS Errors`,viewHmsErrors:`View {{count}} HMS error(s)`,resume:`Resume`,pause:`Pause`,stop:`Stop`,camera:`Camera`,skipObject:`Skip Object`,reconnect:`Reconnect`,forceRefresh:`Force Refresh`,forceRefreshSuccess:`Refresh requested`,mqttDebug:`MQTT Debug`,printerInformation:`Printer Information`,copyToClipboard:`Copy`,copied:`Copied!`,state:`State`,wifiSignalLabel:`WiFi Signal`,developerMode:`Developer Mode`,enabled:`Enabled`,disabled:`Disabled`,addedOn:`Added`,sdCard:`SD Card`,inserted:`Inserted`,notInserted:`Not inserted`,totalPrintHours:`Print Hours`,activeNozzle:`Active: {{nozzle}} nozzle`,nozzleRack:`Nozzle Rack`,nozzleDocked:`Docked`,nozzleMounted:`Mounted`,nozzleActive:`Active`,nozzleIdle:`Idle`,nozzleDiameter:`Diameter`,nozzleType:`Type`,nozzleStatus:`Status`,nozzleFilament:`Filament`,nozzleWear:`Wear`,nozzleMaxTemp:`Max Temp`,nozzleSerial:`Serial`,nozzleHardenedSteel:`Hardened Steel`,nozzleStainlessSteel:`Stainless Steel`,nozzleTungstenCarbide:`Tungsten Carbide`,nozzleFlow:`Flow`,nozzleHighFlow:`High Flow`,nozzleStandardFlow:`Standard`,firmwareUpdate:`Firmware Update`,firmwareInstructions:`On the printer's touchscreen, go to`,firmwareNav:`Navigate to`,settings:`Settings`,firmware:`Firmware`,discoverPrinters:`Discover Printers`,searching:`Searching...`,manualEntry:`Manual Entry`,addFromCloud:`Add from Cloud`,toast:{printerDeleted:`Printer deleted`,missingSpoolAssignment:`Print started on {{printer}}. Missing spool assignment for: {{slots}}`,printerAdded:`Printer added`,printerUpdated:`Printer updated`,failedToDelete:`Failed to delete printer`,failedToAdd:`Failed to add printer`,connectionFailedNotAdded:`Could not connect to the printer. Verify the IP, serial number, and access code, and confirm LAN-only mode is on. The printer was not added.`,failedToUpdate:`Failed to update printer`,commandSent:`Command sent`,failedToSendCommand:`Failed to send command`,turnedOn:`{{name}} turned on`,failedToPowerOn:`Failed to power on {{name}}`,scriptTriggered:`Script triggered`,printStopped:`Print stopped`,printPaused:`Print paused`,printResumed:`Print resumed`,referenceDeleted:`Reference deleted`,detectionAreaSaved:`Detection area saved`,failedToRunScript:`Failed to run script`,failedToStopPrint:`Failed to stop print`,failedToPausePrint:`Failed to pause print`,failedToResumePrint:`Failed to resume print`,failedToControlChamberLight:`Failed to control chamber light`,failedToSetSpeed:`Failed to set print speed`,failedToUpdateSetting:`Failed to update setting`,failedToSkipObjects:`Failed to skip objects`,failedToRereadRfid:`Failed to re-read RFID`,failedToCheckPlate:`Failed to check plate`,failedToUpdateLabel:`Failed to update label`,failedToDeleteReference:`Failed to delete reference`,failedToSaveDetectionArea:`Failed to save detection area`,plateCheckEnabled:`Plate check enabled`,plateCheckDisabled:`Plate check disabled`,calibrationSaved:`Calibration saved!`,calibrationFailed:`Calibration failed`,rfidRereadInitiated:`RFID re-read initiated`,loadInitiated:`Loading filament…`,unloadInitiated:`Unloading filament…`,failedToLoad:`Failed to load filament`,failedToUnload:`Failed to unload filament`},connection:{connected:`Connected`,offline:`Offline`},plateStatus:{markCleared:`Mark plate as cleared`,cleared:`Plate Clear`,notCleared:`Plate not Clear`,inUse:`Plate in Use`},queue:{inQueue:`{{count}} print in queue`,inQueue_plural:`{{count}} prints in queue`},controls:`Controls`,rfid:{reread:`Re-read RFID`},ams:{load:`Load`,unload:`Unload`},bedJog:{title:`Jog Controls`,bed:`Bed`,step:`Step (mm)`,up:`Move plate up`,down:`Move plate down`,disabledWhilePrinting:`Disabled while printing`,notHomedTitle:`Printer is not homed`,notHomedMessage:`The printer has not been homed since the last print. Run auto-home first for safe positioning (parks the toolhead, then homes X, Y, and Z), or move anyway — soft endstops will be bypassed.`,homeZ:`Auto Home`,moveAnyway:`Move anyway`,homingStarted:`Auto-homing printer…`},permission:{noAdd:`You do not have permission to add printers`,noEdit:`You do not have permission to edit printers`,noDelete:`You do not have permission to delete printers`,noControl:`You do not have permission to control printers`,noFiles:`You do not have permission to access printer files`,noAmsRfid:`You do not have permission to re-read AMS RFID`,noSmartPlugControl:`You do not have permission to control smart plugs`,noCamera:`You do not have permission to view cameras`},modal:{addTitle:`Add Printer`,editTitle:`Edit Printer`,myPrinter:`My Printer`,selectModel:`Select model...`,locationGroup:`Location / Group (optional)`,locationPlaceholder:`e.g., Workshop, Office, Basement`,autoArchiveLabel:`Auto-archive completed prints`,fromPrinterSettings:`From printer settings`,modelOptional:`Model (optional)`,saveChanges:`Save Changes`},skipObjects:{tooltip:`Skip objects`,onlyWhilePrinting:`Skip objects (only while printing)`,requiresMultiple:`Skip objects (requires 2+ objects)`,title:`Skip Objects`,matchIdsInfo:`Match IDs with your printer display`,printerShowsIds:`The printer screen shows object IDs on the build plate`,skipSelected:`Skip Selected`,skipping:`Skipping...`,noObjectsSelected:`No objects selected`,selectObjectsToSkip:`Select objects you want to skip from the current print`,skipped:`skipped`,objectsSkipped:`Objects skipped`,activeCount:`{{count}} active`,waitForLayer:`Wait for layer 2+ to skip objects (currently layer {{layer}})`,skip:`Skip`,confirmTitle:`Skip Object?`,confirmMessage:`Are you sure you want to skip "{{name}}"? This cannot be undone.`},confirm:{deleteTitle:`Delete Printer`,deleteMessage:`Are you sure you want to delete "{{name}}"? This will remove all connection settings.`,deleteArchivesNote:`All print history for this printer will be permanently deleted.`,keepArchivesNote:`Print history will be kept but no longer associated with this printer.`,stopTitle:`Stop Print`,stopMessage:`Are you sure you want to stop the current print on "{{name}}"? This will cancel the print job.`,stopButton:`Stop Print`,pauseTitle:`Pause Print`,pauseMessage:`Are you sure you want to pause the current print on "{{name}}"?`,pauseButton:`Pause Print`,resumeTitle:`Resume Print`,resumeMessage:`Are you sure you want to resume the print on "{{name}}"?`,resumeButton:`Resume Print`,powerOnTitle:`Power On Printer`,powerOnMessage:`Are you sure you want to turn ON the power for "{{name}}"?`,powerOnButton:`Power On`,powerOffTitle:`Power Off Printer`,powerOffMessage:`Are you sure you want to turn OFF the power for "{{name}}"?`,powerOffWarning:`WARNING: "{{name}}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.`,powerOffButton:`Power Off`,haToggleTitle:`Toggle "{{name}}"`,haToggleMessage:`Toggle the Home Assistant entity {{entity}}? This may turn power off if it is currently on.`,haToggleWarning:`WARNING: "{{name}}" is currently printing! Toggling {{entity}} may cut power and interrupt the print. Continue?`,haToggleButton:`Toggle`},bulk:{select:`Select`,selectAll:`Select All`,selectByLocation:`Select by Location`,selected:`{{count}} selected`,actions:{stop:`Stop`,pause:`Pause`,resume:`Resume`,clearPlate:`Clear Bed`,clearHMS:`Clear Notifications`},confirm:{stopTitle:`Stop {{count}} Prints`,stopMessage:`This will cancel active prints on {{count}} printer(s). This action cannot be undone.`,stopButton:`Stop All`,pauseTitle:`Pause {{count}} Prints`,pauseMessage:`This will pause active prints on {{count}} printer(s).`,pauseButton:`Pause All`,clearPlateTitle:`Clear {{count}} Print Beds`,clearPlateMessage:`This will clear the print bed on {{count}} printer(s) and may trigger queued jobs.`,clearPlateButton:`Clear All`},success:`{{action}} completed on {{count}} printer(s)`,partial:`{{succeeded}} succeeded, {{failed}} failed`,noneApplicable:`No selected printers are in the right state for this action`,selectByState:`Select by State`},discovery:{title:`Discover Printers`,searching:`Searching...`,scanning:`Scanning...`,scanProgress:`Scanning... {{scanned}}/{{total}}`,foundPrinters:`Found {{count}} printer(s)`,noPrintersFound:`No printers found`,noPrintersFoundSubnet:`No printers found in the specified subnet.`,noPrintersFoundNetwork:`No printers found on the network.`,allConfigured:`All discovered printers are already configured.`,alreadyAdded:`Already added`,select:`Select`,manualEntry:`Manual Entry`,addFromCloud:`Add from Cloud`,subnetToScan:`Subnet to scan`,dockerNote:`Docker detected. Enter your printer's subnet in CIDR notation. Requires network_mode: host in docker-compose.yml.`,scanSubnet:`Scan Subnet for Printers`,discoverNetwork:`Discover Printers on Network`,scanningSubnet:`Scanning subnet for Bambu printers...`,scanningNetwork:`Scanning network...`,serialRequired:`Serial required`,unknown:`Unknown`,failedToStart:`Failed to start discovery`,customSubnetOption:`Custom subnet...`,customSubnetLabel:`Custom subnet (CIDR)`,customSubnetNote:`Use a custom subnet if your printer is on a different network than this server. The FTP (990) and MQTT (8883) ports must be reachable across the routing boundary.`},drying:{start:`Start Drying`,stop:`Stop Drying`,temperature:`Temperature`,duration:`Duration`,hours:`hours`,timeRemaining:`{{time}} left`,active:`Drying`,notSupported:`Drying not supported`,powerRequired:`Connect AMS power adapter to enable drying`,startingDrying:`Starting drying...`,stoppingDrying:`Stopping drying...`,rotateTray:`Rotate spool during drying`},amsBackup:{titleOn:`AMS Filament Backup is ON. Click to disable.`,titleOff:`AMS Filament Backup is OFF. Click to enable.`,titleUnknown:`AMS Filament Backup status unavailable on this printer.`,toastEnabled:`AMS Filament Backup enabled`,toastDisabled:`AMS Filament Backup disabled`,modalTitle:`AMS Filament Backup`,modalHelp:`When the active slot runs out, the printer cycles through any matching same-preset, same-colour slots in this order.`,modalNoSlots:`No filament loaded.`,modalNoPairs:`No backup pairs — no two slots share the same filament profile and colour.`,extruderRightShort:`R`,extruderLeftShort:`L`,stateOn:`Enabled`,stateOff:`Disabled`,stateUnknown:`Unsupported on this printer`},activeJobSlot:{title:`This slot is filament {{n}} in the active print`,ariaLabel:`Active print slot {{n}}`},filaments:`Filaments`,openCameraOverlay:`Open camera overlay`,openCameraWindow:`Open camera in new window`,firmwareUpdateAvailable:`Firmware update available: {{current}} → {{latest}}`,firmwareUpToDate:`Firmware {{version}} — Up to date`,firmwareUpdateButton:`Update`,plateDetection:{noPermission:`You do not have permission to update printers`,enabledClick:`Plate check enabled - Click to disable`,disabledClick:`Plate check disabled - Click to enable`,manageCalibration:`Manage plate detection calibration`,calibrationRequired:`Calibration Required`,calibrationInstructions:`Please ensure the build plate is completely empty, then click Calibrate.`,calibrationDescription:`Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects.`,calibrationTip:`Tip: You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking.`,plateEmpty:`Plate appears empty`,objectsDetected:`Objects detected on plate`,confidence:`Confidence`,difference:`Difference`,analysisPreview:`Analysis preview:`,analysisLegend:`Green box = detection area, Red overlay = differences from calibration`,savedReferences:`Saved References ({{count}}/{{max}})`,deleteReference:`Delete reference`,labelPlaceholder:`Label...`,clickToEdit:`{{label}} - Click to edit`,clickToAddLabel:`Click to add label`},speed:{title:`Print Speed`,silent:`Silent (50%)`,standard:`Standard (100%)`,sport:`Sport (124%)`,ludicrous:`Ludicrous (166%)`},airduct:{title:`Airduct Mode`,cooling:`Cooling`,heating:`Heating`},noSdCard:`No SD`,door:{open:`Open`,closed:`Closed`},fans:{partCooling:`Part Cooling Fan`,auxiliary:`Auxiliary Fan`,chamber:`Chamber Fan`},clickToViewHmsErrors:`Click to view HMS errors`,estimatedCompletion:`Estimated completion time`,plateNumber:`Plate {{number}}`,slotOptions:`Slot options`,amsPopup:{friendlyName:`AMS Name`,friendlyNamePlaceholder:`e.g. AMS Friendly Name`,serialNumber:`Serial Number`,firmwareVersion:`Firmware`,save:`Save`,clear:`Clear`,noEditPermission:`You do not have permission to rename AMS units`},firmwareModal:{title:`Firmware Update`,titleUpToDate:`Firmware Info`,currentVersion:`Current:`,latestVersion:`Latest:`,releaseNotes:`Release Notes`,checkingPrereqs:`Checking prerequisites...`,sdCardReady:`SD card ready. Click below to upload firmware.`,uploadedSuccess:`Firmware uploaded to SD card!`,applyInstructions:`To apply the update on your printer:`,step1:`On the printer's touchscreen, go to Settings`,step2:`Navigate to Firmware`,step3:`Select Update from SD card`,step4:`The update will take 10-20 minutes`,done:`Done`,starting:`Starting...`,uploadFirmware:`Upload Firmware`,uploadFailed:`Failed to start upload: {{error}}`,uploadedToast:`Firmware uploaded! Trigger update from printer screen.`,availableVersions:`Available versions`,usable:`Usable`,unavailable:`Unavailable`,installed:`Installed`,newerBadge:`newer`,olderBadge:`older`,currentBadge:`current`},accessCodePlaceholder:`Leave empty to keep current`,roi:{title:`Detection Area (ROI)`,xStart:`X Start`,yStart:`Y Start`,width:`Width`,height:`Height`,instruction:`Adjust the detection area to focus on the build plate. The green box in the preview shows the current area.`},developerModeWarning:`Developer LAN mode is not enabled on: {{names}}. Some features may not work.`,howToEnable:`How to enable`,incompatibleFile:`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,dropNotPrintable:`Only .gcode and .gcode.3mf files can be printed`,dropToPrint:`Drop to print`,cannotPrint:`Printer busy`},archives:{title:`Print Archives`,no3mfBanner:{title:`Some recent prints couldn't be archived with thumbnails`,body:`The slicer didn't leave the .gcode.3mf on the printer's SD card, so Bambuddy couldn't pull the thumbnail or slicer metadata. This is usually because "Store sent files on external storage" is off in the slicer (Bambu Studio / OrcaSlicer Device tab).`,docsLink:`See install step 4`,dismissLabel:`Dismiss this notice`},searchPlaceholder:`Search archives...`,filterByPrinter:`Filter by printer`,filterByStatus:`Filter by status`,sortBy:`Sort by`,sortNewest:`Newest first`,sortOldest:`Oldest first`,sortName:`Name`,sortDuration:`Duration`,sortLargest:`Largest first`,sortSmallest:`Smallest first`,sortSize:`Size`,noArchives:`No archives found`,noArchivesSearch:`No archives match your search`,originalPrintNotVisible:`Original print not visible - try clearing filters`,noArchivesYet:`No archives yet`,prints:`prints`,pagination:{showing:`Showing`,to:`to`,of:`of`,show:`Show`,page:`Page`,all:`All`},loadingArchives:`Loading archives...`,releaseToUpload:`Release to upload`,showAll:`Show all`,showFavoritesOnly:`Show favorites only`,gridView:`Grid view`,listView:`List view`,calendarView:`Calendar view`,logView:`Print Log`,manageTags:`Manage Tags`,showFailedPrints:`Show failed prints`,hideFailedPrints:`Hide failed prints`,hideDuplicates:`Hide Duplicates`,viewOriginalPrint:`Click to view original print (#{{id}})`,printTime:`Print Time`,filamentUsed:`Filament Used`,cost:`Cost`,reprint:`Reprint`,preview:`Preview`,deleteArchive:`Delete Archive`,deleteConfirm:`Are you sure you want to delete this archive?`,favorite:`Favorite`,unfavorite:`Remove from favorites`,viewDetails:`View Details`,status:{completed:`Completed`,failed:`Failed`,stopped:`Stopped`},toast:{source3mfAttached:`Source 3MF attached: {{filename}}`,failedUploadSource3mf:`Failed to upload source 3MF`,source3mfRemoved:`Source 3MF removed`,failedRemoveSource3mf:`Failed to remove source 3MF`,f3dAttached:`F3D attached: {{filename}}`,failedUploadF3d:`Failed to upload F3D`,f3dRemoved:`F3D removed`,failedRemoveF3d:`Failed to remove F3D`,timelapseAttached:`Timelapse attached: {{filename}}`,timelapseAlreadyAttached:`Timelapse already attached`,noMatchingTimelapse:`No matching timelapse found`,failedScanTimelapse:`Failed to scan for timelapse`,failedAttachTimelapse:`Failed to attach timelapse`,timelapseRemoved:`Timelapse removed`,failedRemoveTimelapse:`Failed to remove timelapse`,timelapseUploaded:`Timelapse uploaded: {{filename}}`,failedUploadTimelapse:`Failed to upload timelapse`,archiveDeleted:`Archive deleted`,failedDeleteArchive:`Failed to delete archive`,addedToFavorites:`Added to favorites`,removedFromFavorites:`Removed from favorites`,projectUpdated:`Project updated`,failedUpdateProject:`Failed to update project`,linkCopied:`Link copied to clipboard`,failedCopyLink:`Failed to copy link`,photoDeleted:`Photo deleted`,failedDeletePhoto:`Failed to delete photo`,failedDeleteArchives:`Failed to delete archives`,failedUpdateFavorites:`Failed to update favorites`,exportDownloaded:`Export downloaded`,exportFailed:`Export failed`},menu:{print:`Print`,schedule:`Schedule`,openInBambuStudio:`Open in Slicer`,slice:`Slice`,externalLink:`External Link`,viewOnMakerWorld:`View on MakerWorld`,preview3d:`3D Preview`,viewTimelapse:`View Timelapse`,scanForTimelapse:`Scan for Timelapse`,uploadTimelapse:`Upload Timelapse`,removeTimelapse:`Remove Timelapse`,downloadSource3mf:`Download Source 3MF`,uploadSource3mf:`Upload Source 3MF`,replaceSource3mf:`Replace Source 3MF`,removeSource3mf:`Remove Source 3MF`,uploadF3d:`Upload F3D`,replaceF3d:`Replace F3D`,downloadF3d:`Download F3D`,removeF3d:`Remove F3D`,download:`Download`,copyDownloadLink:`Copy Download Link`,qrCode:`QR Code`,viewPhotos:`View Photos`,viewPhotosCount:`View Photos ({{count}})`,projectPage:`Project Page`,addToFavorites:`Add to Favorites`,removeFromFavorites:`Remove from Favorites`,edit:`Edit`,printLog:`Print Log`,goToProject:`Go to Project: {{name}}`,addToProject:`Add to Project`,removeFromProject:`Remove from Project`,loading:`Loading...`,noProjectsAvailable:`No projects available`,searchProjects:`Search projects…`,select:`Select`,deselect:`Deselect`,delete:`Delete`},permission:{noReprint:`You do not have permission to reprint this archive`,noAddToQueue:`You do not have permission to add to queue`,noUpdateArchives:`You do not have permission to update archives`,noUploadFiles:`You do not have permission to upload files`,noDownload:`You do not have permission to download archives`,noCopyLink:`You do not have permission to copy download links`,noDelete:`You do not have permission to delete this archive`,noEdit:`You do not have permission to edit this entry`,noCreate:`You do not have permission to create archives`},platePicker:{title:`Select plate to preview`,hint:`This archive has multiple plates. Pick one to open in the GCode viewer.`,plateLabel:`Plate {{index}}`,objectCount:`{{count}} object`,objectCount_plural:`{{count}} objects`,noGcode:`This archive has no sliced G-code to preview. Open it in Bambu Studio to slice first.`},card:{previousPlate:`Previous plate`,nextPlate:`Next plate`,plateNumber:`Plate {{index}}`,moreOptions:`Right-click for more options`,addToFavorites:`Add to favorites`,removeFromFavorites:`Remove from favorites`,cancelled:`cancelled`,failed:`failed`,duplicate:`duplicate`,duplicateTitle:`This model has been printed before`,openSource3mf:`Open source 3MF in Bambu Studio (right-click for more options)`,downloadF3d:`Download Fusion 360 design file`,viewTimelapse:`View timelapse`,viewPhoto:`View 1 photo`,viewPhotos:`View {{count}} photos`,openFolder:`Open folder: {{name}}`,slicedFile:`Sliced file - ready to print`,sourceFile:`Source file only - no AMS mapping available`,gcode:`GCODE`,source:`SOURCE`,project:`Project: {{name}}`,runsBadge:`{{count}} prints`,runsBadgeTitle:`{{count}} prints total — {{successful}} successful, {{failed}} failed. Click to see the full print log.`,estimated:`Estimated: {{time}}`,actual:`Actual: {{time}}`,accuracy:`Accuracy: {{percent}}%`,filament:`{{weight}}g`,layer:`{{count}} layer`,layers:`{{count}} layers`,object:`{{count}} object`,objects:`{{count}} objects`,slicedFor:`Sliced for {{model}}`,uploadedBy:`Uploaded By`,noPermissionReprint:`You do not have permission to reprint`,noFileForReprint:`No 3MF file available — the file could not be downloaded from the printer when the print was recorded`,noPermissionEdit:`You do not have permission to edit archives`,noPermissionDelete:`You do not have permission to delete archives`,reprint:`Reprint`,schedulePrint:`Schedule Print`,schedule:`Schedule`,openInBambuStudio:`Open in Slicer`,openInBambuStudioToSlice:`Open in Slicer to slice`,slice:`Slice`,externalLink:`External Link`,makerWorld:`MakerWorld: {{designer}}`,viewProject:`View project`,noExternalLink:`No external link`,preview3d:`3D Preview`,download:`Download`,edit:`Edit`,delete:`Delete`},runLog:{title:`Print Log`,modalTitle:`Print Log — {{name}}`,modalTitleFallback:`this archive`,empty:`No print events recorded for this archive yet.`,col:{date:`Date`,status:`Status`,duration:`Duration`,filament:`Filament`,cost:`Cost`},status:{completed:`Completed`,failed:`Failed`,cancelled:`Cancelled`,stopped:`Stopped`,skipped:`Skipped`,printing:`Printing`}},modal:{deleteArchive:`Delete Archive`,deleteConfirm:`Are you sure you want to delete "{{name}}"? This action cannot be undone.`,deleteButton:`Delete`,deletePurgeStats:`Also remove this print from Quick Stats (filament, time, cost, energy)`,deleteQueueItemsWarning:`{{count}} queue item(s) linked to this archive will also be removed.`,deleteBlockedByPrinting:`Cannot delete — {{count}} queue item(s) are currently printing. Stop the print first, then retry.`,removeSource3mf:`Remove Source 3MF`,removeSource3mfConfirm:`Are you sure you want to remove the source 3MF file from "{{name}}"? This will delete the original slicer project file.`,removeButton:`Remove`,removeF3d:`Remove F3D`,removeF3dConfirm:`Are you sure you want to remove the Fusion 360 design file from "{{name}}"?`,removeTimelapse:`Remove Timelapse`,removeTimelapseConfirm:`Are you sure you want to remove the timelapse video from "{{name}}"?`,timelapse:`{{name}} - Timelapse`,selectTimelapse:`Select Timelapse`,selectTimelapseDesc:`No auto-match found. Select the timelapse for this print:`,deleteArchives:`Delete Archives`,deleteArchivesConfirm:`Are you sure you want to delete {{count}} archive(s)? This action cannot be undone.`,deleteCount:`Delete {{count}}`},page:{title:`Archives`,printsCount:`{{filtered}} of {{total}} prints`,dropFilesHere:`Drop .3mf files here`,releaseToUpload:`Release to upload`,only3mfSupported:`Only .3mf files are supported`,close:`Close`,selected:`{{count}} selected`,selectAll:`Select All`,tags:`Tags`,project:`Project`,favorite:`Favorite`,delete:`Delete`,toggledFavorites:`Toggled favorites for {{count}} archive(s)`,failedUpdateFavorites:`Failed to update favorites`,archivesDeleted:`{{count}} archive(s) deleted`,failedDeleteArchives:`Failed to delete archives`,photoDeleted:`Photo deleted`,failedDeletePhoto:`Failed to delete photo`},list:{name:`Name`,printer:`Printer`,date:`Date`,size:`Size`,actions:`Actions`,hasTimelapse:`Has timelapse`},log:{date:`Date`,printName:`Print Name`,printer:`Printer`,user:`User`,status:`Status`,duration:`Duration`,filament:`Filament`,allPrinters:`All Printers`,allUsers:`All Users`,allStatuses:`All Statuses`,cancelled:`Cancelled`,skipped:`Skipped`,dateFrom:`From`,dateTo:`To`,noEntries:`No print log entries found`,showing:`Showing {{count}} of {{total}} entries`,rowsPerPage:`Rows`,page:`Page`,prev:`Prev`,next:`Next`,clearLog:`Clear Log`,clearLogTitle:`Clear Print Log`,clearLogConfirm:`All print log entries will be permanently deleted. Archives and queue items are not affected. This action cannot be undone. Are you sure?`,clearLogButton:`Clear All`,cleared:`{{count}} log entries cleared`,clearFailed:`Failed to clear print log`,deleteEntryTitle:`Delete print log entry`,deleteEntryConfirm:`This entry will be removed from the log and its filament, time, and cost contributions will drop out of Quick Stats. The matching archive (if any) is not affected. This action cannot be undone.`,entryDeleted:`Print log entry deleted`,entryDeleteFailed:`Failed to delete print log entry`,editEntryTitle:`Edit print log entry`,editEntryDescription:`Classify this print run. The Failure Analysis widget groups by these values, so updates flow through to stats immediately.`,entryUpdated:`Print log entry updated`,entryUpdateFailed:`Failed to update print log entry`,statuses:{completed:`Completed`,failed:`Failed`,stopped:`Stopped`,cancelled:`Cancelled`,skipped:`Skipped`}}},queue:{title:`Print Queue`,subtitle:`Schedule and manage your print jobs`,addToQueue:`Add to Queue`,filamentShort:{rowBadge:`Insufficient filament for the assigned spool`,rowTooltip:`The dispatch scheduler flagged this item. Click Play to see the per-slot deficit and decide whether to print anyway.`,confirmTitle:`Insufficient filament`,confirmIntro:`The assigned spool cannot satisfy at least one slot. Print anyway?`,lineItem:`Slot {{slot}}: needs {{required}} g, {{remaining}} g remaining`,unknown:`unknown`,printAnyway:`Print Anyway`},print:`Print`,reprint:`Re-print`,schedulePrint:`Schedule Print`,editQueueItem:`Edit Queue Item`,printToPrinters:`Print to {{count}} Printers`,queueToPrinters:`Queue to {{count}} Printers`,queueSelectedPlates:`Queue {{count}} Plates`,selectAllPlates:`Select All {{count}} Plates`,deselectAll:`Deselect All`,printQueued:`Print queued`,itemsQueued:`{{count}} items queued`,sending:`Sending...`,sendingProgress:`Sending {{current}}/{{total}}...`,adding:`Adding...`,addingProgress:`Adding {{current}}/{{total}}...`,savingProgress:`Saving {{current}}/{{total}}...`,clearQueue:`Clear Queue`,clearHistory:`Clear History`,emptyQueue:`Queue is empty`,position:`Position`,scheduledTime:`Scheduled Time`,moveUp:`Move Up`,moveDown:`Move Down`,startNow:`Start Now`,printingInProgress:`Printing in progress...`,viewArchive:`View archive`,viewInFileManager:`View in File Manager`,itemCount:`{{count}} item`,itemCount_plural:`{{count}} items`,dragToReorder:`Drag to reorder (ASAP only)`,reorderHint:`Position only affects ASAP items. Scheduled items run at their set time.`,sjf:{label:`SJF`,tooltip:`Shortest Job First — scheduler prioritizes shorter prints`},addedBy:`Added by {{name}}`,nextInQueue:`Next in queue`,clearPlateSuccess:`Plate cleared — ready for next print`,plateNumber:`Plate {{index}}`,quantity:`Quantity`,quantityHint:`Creates {{count}} queue items`,activeBatches:`Active Batches`,batchProgress:`{{completed}} of {{total}} completed`,cancelBatch:`Cancel Remaining`,batchCancelled:`Remaining batch items cancelled`,cancelBatchConfirmTitle:`Cancel Batch`,cancelBatchConfirmMessage:`Cancel all remaining pending items in this batch?`,batch:{defaultName:`Batch`,label:`{{count}} item`,label_plural:`{{count}} items`,pendingCount:`{{count}} pending`,pendingCount_plural:`{{count}} pending`,expand:`Expand batch`,collapse:`Collapse batch`,groupAsBatch:`Group as batch…`,groupAsBatchDescription:`Combine the {{count}} selected items into a single collapsible batch.`,nameLabel:`Batch name`,namePlaceholder:`e.g. Friday gifts`,create:`Create batch`,ungroup:`Ungroup`,ungroupConfirmTitle:`Ungroup batch?`,ungroupConfirmMessage:`The items will stay in the queue but no longer be grouped together.`,dragGroup:`Drag group`},tabs:{queue:`Queue`,history:`History`,timeline:`Timeline`},layout:{flatList:`List`,byPrinter:`By Printer`,groupByPrinter:`Group by Printer`},history:{emptyTitle:`No history yet`,emptyDescription:`Completed, cancelled, and failed prints will appear here.`},dragGhost:{multiCount:`{{count}} items`,batch:`{{name}} ({{count}} copy)`,batch_plural:`{{name}} ({{count}} copies)`},sections:{currentlyPrinting:`Currently Printing`,queued:`Queued`,history:`History`},status:{pending:`Pending`,waiting:`Waiting`,printing:`Printing`,paused:`Paused`,completed:`Completed`,failed:`Failed`,skipped:`Skipped`,cancelled:`Cancelled`},summary:{printing:`Printing`,queued:`Queued`,totalTime:`Total Queue Time`,totalWeight:`Total Queue Weight`,history:`History`},filter:{allPrinters:`All Printers`,unassigned:`Unassigned`,allStatus:`All Status`,allLocations:`All Locations`,any:`Any`},sort:{byPosition:`Sort by Position`,byName:`Sort by Name`,byPrinter:`Sort by Printer`,bySchedule:`Sort by Schedule`,byDate:`Sort by Date`,ascendingOldest:`Ascending (oldest first)`,descendingNewest:`Descending (newest first)`},badges:{staged:`Staged`,requiresPrevious:`Requires previous success`,autoPowerOff:`Auto power off`,gcodeInjection:`G-code`},empty:{title:`No prints scheduled`,description:`Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.`},time:{asap:`ASAP`,overdue:`Overdue`,now:`Now`,lessThanMinute:`In less than a minute`,inMinutes:`In {{count}} min`,inHours:`In {{count}} hours`},actions:{stopPrint:`Stop Print`,startPrint:`Start Print`,requeue:`Re-queue`},bulkEdit:{title:`Edit {{count}} Item`,title_plural:`Edit {{count}} Items`,description:`Only changed settings will be applied to selected items.`,printer:`Printer`,noChange:`— No change —`,queueOptions:`Queue Options`,staged:`Staged (manual start)`,autoPowerOff:`Auto power off after print`,requirePrevious:`Require previous success`,printOptions:`Print Options`,bedLevelling:`Bed levelling`,flowCalibration:`Flow calibration`,vibrationCalibration:`Vibration calibration`,layerInspection:`First layer inspection`,timelapse:`Timelapse`,useAms:`Use AMS`,nozzleOffsetCali:`Nozzle offset calibration`,applyChanges:`Apply Changes`,selectAll:`Select All`,deselectAll:`Deselect All`,selected:`{{count}} selected`,editSelected:`Edit Selected`,cancelSelected:`Cancel Selected`},confirm:{cancelTitle:`Cancel Scheduled Print`,cancelMessage:`Are you sure you want to cancel "{{name}}"?`,stopTitle:`Stop Print`,stopMessage:`Are you sure you want to stop the current print "{{name}}"? This will cancel the print job on the printer.`,removeTitle:`Remove from History`,removeMessage:`Are you sure you want to remove "{{name}}" from the queue history?`,clearHistoryTitle:`Clear History`,clearHistoryMessage:`Are you sure you want to remove all {{count}} item(s) from the history?`,cancelButton:`Cancel Print`,stopButton:`Stop Print`,thisPrint:`this print`,thisItem:`this item`},toast:{cancelled:`Queue item cancelled`,cancelFailed:`Failed to cancel item`,removed:`Queue item removed`,removeFailed:`Failed to remove item`,stopped:`Print stopped`,stopFailed:`Failed to stop print`,released:`Print released to queue`,startFailed:`Failed to start print`,reorderFailed:`Failed to reorder queue`,historyCleared:`Cleared {{count}} history item(s)`,clearHistoryFailed:`Failed to clear history`,updateFailed:`Failed to update items`,bulkCancelled:`Cancelled {{count}} item(s)`,bulkCancelFailed:`Failed to cancel items`,batchCreated:`Batch "{{name}}" created`,batchCreateFailed:`Failed to create batch`,batchUngrouped:`Ungrouped {{count}} item(s)`,batchUngroupFailed:`Failed to ungroup batch`,resumedAfterFailure:`Resumed queue — {{restored}} job(s) restored to pending`,resumeAfterFailureFailed:`Failed to resume queue`},resumeAfterFailure:{banner:`{{printer}} is blocked by a previous-print failure — {{count}} job(s) skipped`,bannerHint:`Fix the printer issue, then resume to restore the skipped jobs and clear the gate.`,button:`Resume after failure`,confirmTitle:`Resume queue after failure?`,confirmMessage:`Restore {{count}} skipped job(s) on {{printer}} to pending and clear the previous-print gate. Make sure the printer is ready before continuing.`},timeline:{listView:`List`,timelineView:`Timeline`,unassigned:`Unassigned`,noData:`No scheduled prints for this day`,nothingCommitted:`No committed schedules in this window. Staged items, waiting items, and ASAP jobs on idle printers are not shown — set a scheduled time or release a staged item to see it here.`,allDoneBy:`All prints estimated done by {{time}}`,staged:`Staged`,filterAll:`Show All`,filterPrinting:`Printing`,filterQueued:`Queued`,time:{anyMoment:`any moment`,minutesLeft:`{{minutes}}m left`,hoursLeft:`{{hours}}h left`,hoursMinutesLeft:`{{hours}}h {{minutes}}m left`},day:{previous:`Previous day`,next:`Next day`,today:`Today`},window:{back12h:`Back 12 hours`,forward12h:`Forward 12 hours`,now:`Now`},printerColumnHeader:`Printer`},permissions:{noStopPrint:`You do not have permission to stop prints`,noStartPrint:`You do not have permission to start prints`,noEdit:`You do not have permission to edit this queue item`,noCancel:`You do not have permission to cancel this queue item`,noRequeue:`You do not have permission to re-queue items`,noRemove:`You do not have permission to remove this queue item`,noClearHistory:`You do not have permission to clear all history`,noEditItems:`You do not have permission to edit queue items`,noCancelItems:`You do not have permission to cancel queue items`}},backgroundDispatch:{unknownFile:`Unknown file`,unknownPrinter:`Unknown printer`,startingPrints:`Starting prints`,progressSummary:`{{complete}}/{{total}} complete • Dispatched: {{dispatched}} • Processing: {{processing}}`,expandDetails:`Expand dispatch details`,collapseDetails:`Collapse dispatch details`,dismissToast:`Dismiss dispatch toast`,cancelDispatchJob:`Cancel dispatch job`,cancel:`Cancel`,cancelling:`Cancelling…`,awaitingPrinter:`Awaiting printer…`,status:{dispatched:`Dispatched`,processing:`Processing`,completed:`Completed`,failed:`Failed`,cancelled:`Cancelled`},toast:{cancellingUpload:`Cancelling upload...`,cancelled:`Dispatch cancelled`,cancelFailed:`Failed to cancel dispatch`,completeWithFailures:`Background dispatch complete: {{completed}} succeeded, {{failed}} failed`,completeSuccess:`Background dispatch complete: {{completed}} succeeded`,printStartedRemaining:`{{completed}} print(s) started, {{remaining}} more sending...`}},stats:{title:`Statistics`,subtitle:`Drag widgets to rearrange. Click the eye icon to hide.`,overview:`Overview`,totalPrints:`Total Prints`,successRate:`Success Rate`,totalPrintTime:`Total Print Time`,printTime:`Print Time`,totalFilament:`Total Filament Used`,filamentUsed:`Filament Used`,filamentCost:`Filament Cost`,totalCost:`Total Cost`,energyUsed:`Energy Used`,energyCost:`Energy Cost`,energyWarmingUpTooltip:`Energy tracking is still collecting hourly snapshots. Date-range totals will become accurate once at least one snapshot exists before the selected range. Early values may undercount.`,averagePrintTime:`Average Print Time`,printsPerDay:`Prints per Day`,byPrinter:`By Printer`,printsByPrinter:`Prints by Printer`,byMaterial:`By Material`,byMonth:`By Month`,last7Days:`Last 7 Days`,last30Days:`Last 30 Days`,last90Days:`Last 90 Days`,allTime:`All Time`,quickStats:`Quick Stats`,printActivity:`Print Activity`,filamentTypes:`Filament Types`,filamentTrends:`Filament Trends`,failureAnalysis:`Failure Analysis`,timeAccuracy:`Time Accuracy`,successful:`Successful:`,failed:`Failed:`,cancelled:`Cancelled:`,perfectEstimate:`100% = perfect estimate`,noTimeAccuracyData:`No time accuracy data yet`,noFilamentData:`No filament data available`,noPrinterData:`No printer data available`,noPrintData:`No print data available`,noPrintDataLast30Days:`No print data in the last 30 days`,failureReasons:`Failure Reasons`,topFailureReasons:`Top Failure Reasons`,failedPrintsCount:`{{failed}} / {{total}} prints failed`,lastWeekRate:`Last week: {{rate}}%`,resetLayout:`Reset Layout`,recalculateCosts:`Recalculate Costs`,recalculateCostsHint:`Recalculate all archive costs using current filament prices`,exportStats:`Export Stats`,exportAsCsv:`Export as CSV`,exportAsExcel:`Export as Excel`,hiddenCount:`{{count}} Hidden`,exportDownloaded:`Export downloaded`,exportFailed:`Export failed`,layoutReset:`Layout reset`,recalculatedCosts:`Recalculated costs for {{count}} archives`,recalculateFailed:`Failed to recalculate costs`,loadingStats:`Loading statistics...`,noPermissionResetLayout:`You do not have permission to reset layout`,noPermissionRecalculate:`You do not have permission to recalculate costs`,noPrintDataInRange:`No print data in selected range`,periodFilament:`Period Filament`,periodCost:`Period Cost`,avgPerPrint:`Avg per Print`,usageOverTime:`Usage Over Time`,filamentByWeight:`Weight`,printDuration:`Print Duration`,printerUtilization:`Printer Utilization`,filamentSuccess:`Success by Material`,printHabits:`Print Habits`,printTimeOfDay:`Print Time of Day`,colorDistribution:`Color Distribution`,noColorData:`No color data available`,records:`Records`,longestPrint:`Longest Print`,heaviestPrint:`Heaviest Print`,mostExpensivePrint:`Most Expensive`,busiestDay:`Busiest Day`,successStreak:`Success Streak`,streakPrint:`consecutive print`,streakPrints:`{{count}} consecutive prints`,printerStats:`Printer Stats`,hours:`hours`,avgPrints:`Avg. prints`,noArchiveData:`No print data available`,filamentByTime:`Time`,avgWeight:`Avg. weight`,avgTime:`Avg. time`,filamentByPrints:`Prints`,timeframe:{today:`Today`,"this-week":`This Week`,"this-month":`This Month`,"last-7":`Last 7 Days`,"last-30":`Last 30 Days`,"last-90":`Last 90 Days`,"this-year":`This Year`,"all-time":`All Time`,custom:`Custom Range`,from:`From`,to:`To`},allUsers:`All Users`,noUser:`No User (System)`,filterByUser:`Filter by User`},maintenance:{title:`Maintenance`,overview:`Overview`,allOk:`All maintenance up to date`,dueCount:`{{count}} item due`,dueCount_plural:`{{count}} items due`,warningCount:`{{count}} warning`,warningCount_plural:`{{count}} warnings`,totalPrintTime:`Total Print Time`,nextMaintenance:`Next Maintenance`,nothingDue:`Nothing due`,tasks:`Tasks`,lastPerformed:`Last performed`,interval:`Interval`,hoursRemaining:`{{hours}}h remaining`,hoursOverdue:`{{hours}}h overdue`,markDone:`Mark as Done`,performMaintenance:`Perform Maintenance`,history:`History`,noHistory:`No maintenance history`,editPrintHours:`Edit Print Hours`,currentHours:`Current Hours`,statusTab:`Status`,settingsTab:`Settings`,overdueCount:`{{count}} overdue`,dueSoonCount:`{{count}} due soon`,dueSoon:`Due soon`,allGood:`All good`,overdueBy:`Overdue by {{duration}}`,dueIn:`Due in {{duration}}`,timeLeft:`{{duration}} left`,day:`1 day`,days:`{{count}} days`,week:`1 week`,weeks:`{{count}} weeks`,month:`1 month`,months:`{{count}} months`,year:`1 year`,maintenanceTypes:`Maintenance Types`,maintenanceTypesDescription:`System types and your custom maintenance tasks`,addCustomType:`Add Custom Type`,restoreDefaults:`Restore Default Tasks`,intervalType:`Interval Type`,intervalValue:`Interval ({{type}})`,icon:`Icon`,documentationLink:`Documentation Link (optional)`,assignToPrinters:`Assign to Printers`,selectAtLeastOnePrinter:`Select at least one printer`,addType:`Add Type`,custom:`Custom`,printHours:`Print Hours`,calendarDays:`Calendar Days`,exampleName:`e.g., Replace HEPA Filter`,viewDocumentation:`View documentation`,timeBasedInterval:`Time-based interval`,intervalOverrides:`Interval Overrides`,intervalOverridesDescription:`Customize intervals for specific printers`,assignedToPrinters:`Assigned to printers:`,noPrintersAssigned:`No printers assigned`,addPrinterShort:`Add:`,printersAssignedClick:`{{count}} printer(s) assigned - click to manage`,removeFromPrinter:`Remove from this printer`,types:{lubricateCarbonRods:`Lubricate Carbon Rods`,lubricateRails:`Lubricate Linear Rails`,cleanNozzle:`Clean Nozzle/Hotend`,checkBelts:`Check Belt Tension`,cleanBuildPlate:`Clean Build Plate`,checkExtruder:`Check Extruder Gears`,checkCooling:`Check Cooling Fans`,generalInspection:`General Inspection`,cleanCarbonRods:`Clean Carbon Rods`,lubricateSteelRods:`Lubricate Steel Rods`,cleanSteelRods:`Clean Steel Rods`,cleanLinearRails:`Clean Linear Rails`,checkPtfeTube:`Check PTFE Tube`,replaceHepaFilter:`Replace HEPA Filter`,replaceCarbonFilter:`Replace Carbon Filter`,lubricateLeftNozzleRail:`Lubricate Left Nozzle Rail`},maintenanceComplete:`Maintenance marked as complete`,typeUpdated:`Maintenance type updated`,typeDeleted:`Maintenance type deleted`,defaultsRestored:`Restored {{count}} default task(s)`,printHoursUpdated:`Print hours updated`,printerAssigned:`Printer assigned`,printerRemoved:`Printer removed`,deleteTypeConfirm:`Delete "{{name}}"?`,deleteSystemTypeTitle:`Delete default maintenance task?`,deleteSystemTypeMessage:`Are you sure you want to delete the default maintenance task "{{name}}"?`,noPermissionUpdate:`You do not have permission to update maintenance items`,noPermissionPerform:`You do not have permission to perform maintenance`,noPermissionEditTypes:`You do not have permission to edit maintenance types`,noPermissionDeleteTypes:`You do not have permission to delete maintenance types`,noPermissionEditHours:`You do not have permission to edit print hours`,noPermissionRemovePrinter:`You do not have permission to remove printer assignments`,noPermissionAssignPrinter:`You do not have permission to assign printers`,noPermissionEditIntervals:`You do not have permission to edit intervals`,configureSettings:`Configure maintenance types and intervals`},settings:{title:`Settings`,general:`General`,tabs:{general:`General`,smartPlugs:`Smart Plugs`,notifications:`Notifications`,queue:`Workflow`,filament:`Filament`,network:`Network`,apiKeys:`API Keys`,virtualPrinter:`Virtual Printer`,spoolbuddy:`SpoolBuddy`,failureDetection:`Failure Detection`,users:`Authentication`,backup:`Backup`,emailAuth:`Email Authentication`,ldap:`LDAP`,twoFa:`Two-Factor Auth`,oidc:`SSO / OIDC`,security:`Security`},spoolbuddy:{infoTitle:`SpoolBuddy devices`,infoBody:`SpoolBuddy kiosks register themselves automatically via heartbeat. Unregister a device here if it is no longer in use or if a stale duplicate was left behind by a daemon crash.`,duplicatesTitle:`{{count}} devices registered`,duplicatesBody:`Only the first registered device is used by the kiosk UI. If one of these is a stale duplicate from a crash, unregister it — an online device will re-register itself on its next heartbeat.`,empty:`No SpoolBuddy devices registered yet.`,online:`Online`,offline:`Offline`,unregister:`Unregister`,unregisterSuccess:`Device unregistered`,unregisterError:`Failed to unregister device`,confirmTitle:`Unregister SpoolBuddy device?`,confirmBody:`This will remove "{{hostname}}" ({{deviceId}}) from the database. If the device is online, it will re-register itself on its next heartbeat.`,ipAddress:`IP address`,firmware:`Firmware`,lastSeen:`Last seen`,daemonUptime:`Daemon uptime`,systemUptime:`System uptime`,never:`never`,nfc:`NFC`,scale:`Scale`,cpuTemp:`CPU temp`,cpuLoad:`CPU load`,memory:`Memory`,disk:`Disk`,update:`Update`,updateConfirmTitle:`Update Spoolbuddy daemon?`,updateConfirmBody:`Trigger a software update on "{{hostname}}"? The daemon will restart once the update is applied.`,restartBrowser:`Restart Browser`,restartBrowserConfirmTitle:`Restart kiosk browser?`,restartBrowserConfirmBody:`Restart the kiosk browser on "{{hostname}}"? The display will blank briefly.`,restartDaemon:`Restart Daemon`,restartDaemonConfirmTitle:`Restart Spoolbuddy daemon?`,restartDaemonConfirmBody:`Restart the Spoolbuddy daemon on "{{hostname}}"? The device will go offline for a few seconds.`,reboot:`Reboot`,rebootConfirmTitle:`Reboot device?`,rebootConfirmBody:`Reboot "{{hostname}}"? The device will be offline for around a minute.`,shutdown:`Shutdown`,shutdownConfirmTitle:`Shutdown device?`,shutdownConfirmBody:`Shutdown "{{hostname}}"? You will need physical access to power it back on.`,commandConfirm:`Confirm`,commandQueued:`Command queued`,commandError:`Failed to send command`},ldap:{title:`LDAP Authentication`,enabledDesc:`LDAP authentication is enabled`,disabledDesc:`LDAP authentication is disabled`,disabledHint:`Configure and save LDAP settings below, then enable.`,enabled:`LDAP authentication enabled`,disabled:`LDAP authentication disabled`,feature1:`Users can login with LDAP credentials`,feature2:`Local admin account remains as fallback`,feature3:`LDAP groups are mapped to BamBuddy groups on login`,serverConfig:`LDAP Server Configuration`,serverUrl:`Server URL`,serverUrlHint:`Use ldaps:// for SSL or ldap:// with StartTLS`,security:`Security`,securityHint:`StartTLS upgrades a plain connection to TLS. LDAPS uses TLS from the start.`,bindDn:`Bind DN (Service Account)`,bindPassword:`Bind Password`,searchBase:`Search Base DN`,userFilter:`User Search Filter`,userFilterHint:`{username} is replaced with the login username. Use (uid={username}) for OpenLDAP.`,advanced:`Advanced`,autoProvision:`Auto-provision users`,autoProvisionHint:`Automatically create a BamBuddy account on first LDAP login`,defaultGroup:`Default group`,defaultGroupNone:`— None (no fallback) —`,defaultGroupHint:`Fallback group assigned when an LDAP user authenticates but is not listed in any mapped LDAP group. Leave empty to leave unmapped users without permissions.`,groupMapping:`Group Mapping (JSON)`,groupMappingHint:`Map LDAP group DNs to BamBuddy groups. Available groups: `,testConnection:`Test Connection`,settingsSaved:`LDAP settings saved`,errors:{serverRequired:`LDAP server URL is required`,searchBaseRequired:`Search base DN is required`,enableAuthFirst:`Enable authentication first`,configureLdapFirst:`Save LDAP settings first`}},email:{smtpSettings:`SMTP Configuration`,smtpHost:`SMTP Server`,smtpPort:`SMTP Port`,security:`Security`,authentication:`Authentication`,username:`Username`,password:`Password`,fromEmail:`From Email`,fromName:`From Name`,testConnection:`Test SMTP Connection`,testRecipient:`Test Recipient Email`,sendTest:`Send Test Email`,sending:`Sending...`,save:`Save Settings`,saving:`Saving...`,advancedAuth:`Advanced Authentication`,advancedAuthEnabled:`Advanced Authentication is enabled`,advancedAuthEnabledDesc:`Email-based user management features are active. New users will receive auto-generated passwords via email, and users can reset their passwords through the forgot password feature.`,advancedAuthDisabled:`Advanced Authentication is disabled`,advancedAuthDisabledDesc:`Enable advanced authentication to activate email-based features for user management.`,enable:`Enable`,disable:`Disable`,feature1:`Passwords are auto-generated and emailed to new users`,feature2:`Users can login with username or email`,feature3:`Forgot password feature is available`,feature4:`Admins can reset user passwords via email`,errors:{requiredFields:`Please fill in all required fields`,usernameRequired:`Username is required when authentication is enabled`,enterTestEmail:`Please enter a test email address`,smtpServerAndEmail:`Please fill in SMTP Server and From Email before testing`,usernamePasswordRequired:`Username and Password are required when authentication is enabled`,configureSmtpFirst:`Please configure and test SMTP settings first`,enableAuthFirst:`Please enable authentication first to use email-based features.`},success:{settingsSaved:`SMTP settings saved successfully`},securityOptions:{starttls:`STARTTLS (Port 587)`,ssl:`SSL/TLS (Port 465)`,none:`None (Port 25)`},authOptions:{enabled:`Enabled`,disabled:`Disabled`}},appearance:`Appearance`,notifications:`Notifications`,smartPlugs:`Smart Plugs`,spoolman:`Spoolman`,updates:`Updates`,language:`Language`,languageDescription:`Select your preferred language`,theme:`Theme`,themeLight:`Light`,themeDark:`Dark`,themeSystem:`System`,defaultView:`Default View`,defaultViewDescription:`Page to show when opening the app`,checkForUpdates:`Check for Updates`,autoUpdate:`Auto Update`,currentVersion:`Current Version`,latestVersion:`Latest Version`,upToDate:`You are up to date`,updateAvailable:`Update available`,notificationLanguage:`Notification Language`,notificationLanguageDescription:`Language for push notifications`,bedCooledThreshold:`Bed Cooled Threshold`,bedCooledThresholdDescription:`Temperature below which the bed is considered cooled after a print`,userNotificationsEnabled:`User Notifications`,userNotificationsEnabledDescription:`Enable the user notifications menu and email notifications for print job events. Requires Advanced Authentication.`,userNotificationsDisabledHint:`Enable Advanced Authentication to use user notifications.`,notificationProviders:`Notification Providers`,addProvider:`Add Provider`,editProvider:`Edit Provider`,providerType:`Provider Type`,testNotification:`Test Notification`,testSuccess:`Test notification sent successfully`,testFailed:`Failed to send test notification`,quietHours:`Quiet Hours`,quietHoursDescription:`Do not disturb during these hours`,quietHoursStart:`Start`,quietHoursEnd:`End`,events:{title:`Notification Events`,printStart:`Print Started`,printComplete:`Print Completed`,printFailed:`Print Failed`,printStopped:`Print Stopped`,printProgress:`Progress Milestones`,printProgressDescription:`Notify at 25%, 50%, 75%`,printerOffline:`Printer Offline`,printerError:`Printer Error`,filamentLow:`Low Filament`,maintenanceDue:`Maintenance Due`,maintenanceDueDescription:`Notify when maintenance is needed`},smartPlug:{title:`Smart Plugs`,add:`Add Smart Plug`,edit:`Edit Smart Plug`,name:`Name`,ipAddress:`IP Address`,linkedPrinter:`Linked Printer`,autoOn:`Auto Power On`,autoOnDescription:`Turn on when print starts`,autoOff:`Auto Power Off`,autoOffDescription:`Turn off after print completes`,offDelay:`Off Delay`,offDelayMinutes:`Minutes after print`,offDelayTemp:`When nozzle below temperature`,currentState:`Current State`,turnOn:`Turn On`,turnOff:`Turn Off`},filamentTracking:`Filament Tracking`,filamentTrackingDesc:`Choose how to track your filament spools. You can use the built-in inventory or connect an external Spoolman server.`,autoAddUnknownRfid:`Auto-add unknown RFID spools`,autoAddUnknownRfidDesc:`Automatically create an inventory entry when a spool with an unknown RFID tag is detected. Turn off if you pre-register new spools manually to avoid duplicates.`,filamentChecks:`Filament checks`,disableFilamentWarnings:`Disable filament warnings`,disableFilamentWarningsDesc:`Don't show warnings about insufficient filament when printing or queueing`,preferLowestFilament:`Prefer lowest remaining filament`,preferLowestFilamentDesc:`When multiple spools match, use the one with the least filament remaining`,preferLowestFilamentBackupNote:`Only takes effect when AMS Filament Backup is enabled on the printer — otherwise the printer cannot switch to a second spool when the picked one runs out.`,trackingModeBuiltIn:`Built-in Inventory`,trackingModeBuiltInDesc:`RFID auto-matching and usage tracking included`,trackingModeSpoolmanDesc:`External filament management server`,builtInFeatureRfid:`Automatically detects Bambu Lab RFID spools in AMS`,builtInFeatureUsage:`Tracks filament consumption per print`,builtInFeatureCatalog:`Manage spools, colors, and K-factor profiles`,builtInFeatureThirdParty:`Third-party spools can be assigned to inventory spools`,amsSyncButton:`Sync Weights from AMS`,amsSyncTitle:`Sync Spool Weights from AMS`,amsSyncMessage:`This will overwrite all inventory spool weights with the current AMS remain% values from connected printers. Use this to recover from corrupted weight data. Printers must be online.`,amsSyncing:`Syncing...`,amsSyncSuccess:`{{synced}} spool(s) synced, {{skipped}} skipped`,amsSyncError:`Failed to sync weights from AMS`,spoolmanAmsSyncButton:`Sync Spoolman Weights from AMS`,spoolmanAmsSyncTitle:`Sync Spoolman Spool Weights from AMS`,spoolmanAmsSyncMessage:`This will update all Spoolman spool weights based on the current AMS remain% values from connected printers. Printers must be online.`,spoolmanAmsSyncing:`Syncing...`,spoolmanAmsSyncSuccess:`{{synced}} spool(s) synced, {{skipped}} skipped`,spoolmanAmsSyncError:`Failed to sync Spoolman weights from AMS`,spoolmanAmsSyncErrorUnreachable:`Failed to sync Spoolman weights (Spoolman unreachable)`,spoolmanAmsSyncErrorNotConfigured:`Failed to sync Spoolman weights (Spoolman not configured)`,spoolmanNotConfigured:`Spoolman not configured`,spoolmanFilamentCatalogTitle:`Spoolman Filament Catalog`,spoolmanFilamentCatalogDesc:`Filament names and tare weights from your Spoolman instance. Name and spool weight are editable here; all other properties are managed directly in Spoolman.`,spoolmanUrl:`Spoolman URL`,spoolmanUrlHint:`URL of your Spoolman server (e.g., http://localhost:7912)`,spoolmanConnected:`Connected`,spoolmanDisconnected:`Disconnected`,status:`Status`,connect:`Connect`,disconnect:`Disconnect`,howSyncWorks:`How Sync Works`,syncInfoRfidOnly:`Only official Bambu Lab spools with RFID are synced`,syncInfoAutoCreate:`New spools are auto-created in Spoolman on first sync`,syncInfoThirdPartySkipped:`Non-Bambu Lab spools (third-party, refilled) are skipped`,linkingExistingSpools:`Linking Existing Spools`,linkingExistingSpoolsDesc:`To link existing Spoolman spools to your AMS, hover over an AMS slot and click "Link to Spoolman".`,syncMode:`Sync Mode`,syncModeAuto:`Automatic`,syncModeManual:`Manual Only`,syncModeAutoDesc:`AMS data syncs automatically when changes are detected`,syncModeManualDesc:`Only sync when manually triggered`,syncAmsData:`Sync AMS Data`,syncAmsDataDesc:`Manually sync printer AMS data to Spoolman`,allPrinters:`All Printers`,noDefaultPrinter:`No default (ask each time)`,sidebarOrder:`Sidebar order`,saveThumbnails:`Save thumbnails`,captureFinishPhoto:`Capture finish photo`,noPrintersConfigured:`No printers configured`,archiveMode:{always:`Always create archive entry`,never:`Never create archive entry`,ask:`Ask each time`},checkForUpdatesLabel:`Check for updates`,checkPrinterFirmware:`Check printer firmware`,includeBetaUpdates:`Include beta versions`,includeBetaUpdatesDesc:`Notify about beta and prerelease versions when checking for updates`,enableRetry:`Enable retry`,homeAssistantDescription:`Control smart plugs via Home Assistant`,environmentManagedLabel:`(Environment Managed)`,autoEnabledViaEnv:`Automatically enabled via environment variables`,urlFromEnvReadOnly:`Value set by HA_URL environment variable (read-only)`,tokenFromEnvReadOnly:`Value set by HA_TOKEN environment variable (read-only)`,mqttConnectedTo:`Connected to`,prometheusDescription:`Expose printer data in Prometheus format`,noSmartPlugsTitle:`No smart plugs configured`,noSmartPlugsDescription:`Add a Tasmota-based smart plug to track energy usage and automate power control.`,noProvidersTitle:`No providers configured`,noProvidersDescription:`Add a provider to receive alerts.`,noTemplatesAvailable:`No templates available. Restart the backend to seed default templates.`,apiPermissionView:`View printer status and queue`,apiPermissionEdit:`Add and remove items from print queue`,apiKeysEmptyTitle:`No API keys`,apiKeysEmptyDescription:`Create an API key to integrate with external services.`,noUsersFound:`No users found`,noGroupsFound:`No groups found`,noGroupsAvailable:`No groups available`,passwordsDoNotMatch:`Passwords do not match`,systemGroupWarning:`System group names cannot be changed`,authDisabledTitle:`Authentication is Disabled`,authDisabledFeature1:`Require login to access the system`,authDisabledFeature2:`Create multiple users with group-based permissions`,authDisabledFeature3:`Control access with 50+ granular permissions`,userHasCreated:`This user has created:`,userItemsQuestion:`What would you like to do with these items?`,deleteUserConfirm:`Are you sure you want to delete this user?`,actionCannotBeUndone:`This action cannot be undone.`,addFirstSmartPlug:`Add Your First Smart Plug`,providers:`Providers`,log:`Log`,testAll:`Test All`,testResults:`Test Results`,testPassedCount:`{{count}} passed`,testFailedCount:`{{count}} failed`,messageTemplates:`Message Templates`,messageTemplatesDescription:`Customize notification messages for each event.`,apiKeys:`API Keys`,apiKeysDescription:`Create API keys for external integrations and webhooks.`,createKey:`Create Key`,apiKeyCreated:`API Key Created Successfully`,apiKeyCopyWarning:`Copy this key now - it won't be shown again!`,useInApiBrowser:`Use in API Browser`,apiKeyQrButton:`QR code`,apiKeyQrTitle:`Scan to configure`,apiKeyQrCaption:`Scan with your mobile app to add this server and API key.`,apiKeyQrWarning:`Contains your secret API key — don't share or screenshot it where others can see.`,createNewApiKey:`Create New API Key`,keyName:`Key Name`,keyNamePlaceholder:`e.g., Home Assistant, OctoPrint`,readStatus:`Read Status`,readStatusDescription:`View printer status and queue`,manageQueue:`Manage Queue`,manageQueueDescription:`Add and remove items from print queue`,controlPrinter:`Control Printer`,controlPrinterDescription:`Pause, resume, and stop prints`,manageLibrary:`Manage Library`,manageLibraryDescription:`Upload, rename, and delete library files; import models from MakerWorld`,manageInventory:`Manage Inventory`,manageInventoryDescription:`Create, update, and delete spools and inventory records. Required for SpoolBuddy kiosks (NFC scan, scale readings, kiosk system commands).`,libraryBadge:`Library`,inventoryBadge:`Inventory`,cloudAccess:`Allow cloud access`,cloudAccessDescription:`Read Bambu Cloud presets and filaments on your behalf. Requires you to be signed into Bambu Cloud.`,cloudBadge:`Cloud`,updateEnergyCost:`Update electricity price`,updateEnergyCostDescription:`Allow this key to POST a new per-kWh electricity price to /settings/electricity-price. Useful for Home Assistant dynamic-tariff automations (Tibber, Octopus, etc.). This is the only settings field writable via API key.`,energyCostBadge:`Energy`,legacyKey:`Legacy`,legacyKeyTooltip:`Created before per-user ownership; recreate to use cloud access`,unnamedKey:`Unnamed Key`,lastUsed:`Last used`,read:`Read`,control:`Control`,createFirstKey:`Create Your First Key`,webhookEndpoints:`Webhook Endpoints`,webhookApiKeyHint:`Use your API key in the X-API-Key header.`,webhook:{getAllStatus:`Get all printer status`,getSpecificStatus:`Get specific printer status`,addToQueue:`Add to print queue`,pausePrint:`Pause print`,resumePrint:`Resume print`,stopPrint:`Stop print`},apiBrowser:`API Browser`,apiBrowserDescription:`Explore and test all available API endpoints.`,apiKeyForTesting:`API Key for Testing`,apiKeyPlaceholder:`Paste your API key here to test authenticated endpoints...`,apiKeyHint:`This key will be sent as X-API-Key header with requests.`,deleteApiKeyTitle:`Delete API Key`,deleteApiKeyMessage:`Are you sure you want to delete this API key? Any integrations using this key will stop working.`,deleteKey:`Delete Key`,amsDisplayThresholds:`AMS Display Thresholds`,amsThresholdsDescription:`Configure color thresholds for AMS humidity and temperature indicators.`,humidity:`Humidity`,goodGreen:`Good (green)`,fairOrange:`Fair (orange)`,aboveFairBad:`Above fair threshold shows as red (bad)`,fairAlsoDryingThreshold:`This threshold is also used to trigger auto-drying when enabled`,temperature:`Temperature`,goodBlue:`Good (blue)`,aboveFairHot:`Above fair threshold shows as red (hot)`,historyRetention:`History Retention`,keepSensorHistory:`Keep sensor history for`,historyRetentionDescription:`Older humidity and temperature data will be automatically deleted`,defaultPrintOptions:`Default Print Options`,defaultPrintOptionsDescription:`Set default values for print options when starting new prints. These can be overridden per print in the print dialog.`,defaultBedLevelling:`Bed Levelling`,defaultBedLevellingDesc:`Auto-level bed before print`,defaultFlowCali:`Flow Calibration`,defaultFlowCaliDesc:`Calibrate extrusion flow`,defaultVibrationCali:`Vibration Calibration`,defaultVibrationCaliDesc:`Reduce ringing artifacts`,defaultLayerInspect:`First Layer Inspection`,defaultLayerInspectDesc:`AI inspection of first layer`,defaultTimelapse:`Timelapse`,defaultTimelapseDesc:`Record timelapse video`,defaultNozzleOffsetCali:`Nozzle Offset Calibration`,defaultNozzleOffsetCaliDesc:`Calibrate nozzle offsets between extruders`,tempFanPresetsTitle:`Temperature & Fan Presets`,tempFanPresetsDescription:`Customize the quick-select values shown in printer-card temperature and fan-speed popovers. The Off button is always shown.`,tempFanPresetsNozzle:`Nozzle temperature`,tempFanPresetsBed:`Bed temperature`,tempFanPresetsChamber:`Chamber temperature`,tempFanPresetsFan:`Fan speed`,tempFanPresetsReset:`Reset to defaults`,staggeredStart:`Staggered Start`,staggeredStartDescription:`Default group size and interval when staggering multi-printer batch starts. Can be overridden per batch in the print modal.`,plateClear:`Plate-Clear Confirmation`,requirePlateClear:`Require plate-clear confirmation`,requirePlateClearDescription:`When enabled, the scheduler waits for per-printer plate-clear confirmation before starting queued prints on printers with finished jobs. Disabling this also hides the plate status badge and the "Mark plate as cleared" button on printer cards.`,gcodeInjection:`G-code Injection`,gcodeInjectionDescription:`Configure custom G-code to inject at the start and/or end of prints for auto-print systems like Farmloop, SwapMod, AutoClear, and Printflow 3D. Snippets are configured per printer model and applied when "Inject G-code" is enabled on a queue item.`,gcodeInjectionNoPrinters:`No printers found. Add printers to configure G-code snippets.`,gcodeStartLabel:`Start G-code`,gcodeEndLabel:`End G-code`,gcodeStartPlaceholder:`G-code prepended before the print starts...`,gcodeEndPlaceholder:`G-code appended after the print ends...`,staggerGroupSize:`Group size`,staggerGroupSizeHelp:`Printers to start simultaneously per group`,staggerInterval:`Interval (minutes)`,staggerIntervalHelp:`Delay between each group starting`,queueDrying:`Queue Auto-Drying`,queueDryingDescription:`Automatically dry AMS filament when printer is idle between queued prints. Uses humidity threshold above to trigger drying.`,queueDryingEnabled:`Enable auto-drying`,queueDryingEnabledDescription:`Start AMS drying automatically when printer is idle and humidity is above threshold`,queueDryingBlock:`Wait for drying to complete`,queueDryingBlockDescription:`Block the print queue until drying finishes. When off, prints take priority over drying.`,ambientDryingEnabled:`Ambient drying`,ambientDryingEnabledDescription:`Automatically dry filament on idle printers when humidity exceeds threshold, even without queued prints.`,dryingPresets:`Drying Presets`,dryingPresetsDescription:`Temperature and duration per filament type. AMS 2 Pro uses lower temps, AMS-HT supports higher temps.`,dryingFilament:`Filament`,humidityThresholds:`Humidity Thresholds`,humidityThresholdsDescription:`Per-filament humidity trigger for auto-drying and alarms. Mixed loads in one AMS use the lowest threshold.`,humidityThresholdCol:`Threshold`,humidityThresholdDefault:`Default (unknown types)`,printModal:`Print Modal`,expandCustomMapping:`Expand custom mapping by default`,expandCustomMappingDescription:`When printing to multiple printers, show per-printer AMS mapping expanded`,authentication:`Authentication`,authEnabledDescription:`Your instance is secured with user authentication`,authDisabledDescription:`Enable to require login and manage user access`,authDisabledMessage:`Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance.`,enableAuthentication:`Enable Authentication`,currentUser:`Current User`,changePassword:`Change Password`,admin:`Admin`,users:`Users`,addUser:`Add User`,groups:`Groups`,addGroup:`Add Group`,system:`System`,noDescription:`No description`,userCount:`{{count}} users`,permissionCount:`{{count}} permissions`,createUser:`Create User`,username:`Username`,enterUsername:`Enter username`,password:`Password`,enterPassword:`Enter password`,passwordRequirements:`At least 8 characters, with one uppercase, one lowercase, one digit, and one special character.`,confirmPassword:`Confirm Password`,confirmPasswordPlaceholder:`Confirm password`,viewReleaseOnGitHub:`View release on GitHub`,turnAllPlugsOn:`Turn all plugs on`,turnAllPlugsOff:`Turn all plugs off`,clearNotificationLogs:`Clear Notification Logs`,clearLogsMessage:`This will permanently delete all notification logs older than 30 days. This action cannot be undone.`,clearLogs:`Clear Logs`,resetUiPreferences:`Reset UI Preferences`,resetUiPreferencesMessage:`This will reset all UI preferences to defaults: sidebar order, theme, dashboard layout, view modes, and sorting preferences. Your printers, archives, and server settings will NOT be affected. The page will reload after clearing.`,resetPreferences:`Reset Preferences`,deleteGroupTitle:`Delete Group`,deleteGroupMessage:`Are you sure you want to delete this group? Users in this group will lose these permissions.`,deleteGroup:`Delete Group`,disableAuthenticationTitle:`Disable Authentication`,disableAuthenticationMessage:`Are you sure you want to disable authentication? This will make your Bambuddy instance accessible without login. All users will remain in the database but authentication will be disabled.`,disableAuthentication:`Disable Authentication`,configureBambuddy:`Configure Bambuddy`,systemDefault:`System Default`,archiveSettings:`Archive Settings`,newWindow:`New Window`,embeddedOverlay:`Embedded Overlay`,preferredSlicer:`Preferred Slicer`,preferredSlicerDescription:`Slicer used for in-app slicing via the API sidecar`,openInSlicerLabel:`Open in Slicer`,openInSlicerInherit:`Same as API slicer`,openInSlicerDescription:`Desktop slicer used by the 'Open in Slicer' button. Leave on 'Same as API slicer' to inherit, or pick a different slicer to use locally.`,orcaslicerKnownIssuesWarning:`OrcaSlicer 2.3.2 / 2.4.0-dev have known CLI bugs that block slicing many Bambu-authored 3MFs — see upstream issues #12426 (segfault on painted multi-extruder files) and #13386 (parameter-range strict-validation reject). Bambu Studio is recommended until the upstream fixes land.`,useSlicerApi:`Use Slicer API`,useSlicerApiDescription:`When on, "Slice" actions open the in-app slicer modal and call the slicer-API sidecar. When off (default), they hand off to the desktop slicer via URI scheme.`,slicerCard:`Slicer`,orcaslicerApiUrl:`OrcaSlicer sidecar URL`,bambuStudioApiUrl:`Bambu Studio sidecar URL`,slicerApiUrlDescription:`URL of the slicer-API sidecar container. Leave blank to use the SLICER_API_URL / BAMBU_STUDIO_API_URL env var defaults.`,slicerBundlesRemoved:{title:`Slicer Bundles (removed)`,description:`Printer Preset Bundle (.bbscfg) import was removed. BambuStudio's bundle export only includes user-customised presets, so the import never delivered standard processes / filaments and slicing fell back to embedded settings.`,alternatives:`Use Single Preset Import for individual customs, or sync via Bambu Cloud / Orca Cloud. Stock presets come from the slicer sidecar automatically.`,lookupOrder:`Slice-time preset lookup order: 1) Imported (local), 2) Orca Cloud, 3) Bambu Cloud, 4) Standard (sidecar fallback).`},externalCameras:`External Cameras`,costTracking:`Cost Tracking`,printsOnly:`Prints Only`,totalConsumption:`Total Consumption`,dataManagement:`Data Management`,storageUsage:`Storage Usage`,storageUsageDescription:`Breakdown of data usage by category`,storageUsageTotal:`Total`,storageUsageErrors:`Errors`,storageUsageOtherBreakdown:`Other (includes static assets, scripts, and configuration files)`,storageUsageSystem:`System`,storageUsageData:`Data`,storageUsageUnavailable:`Storage usage information unavailable`,clearNotificationLogsDescription:`Delete notification logs older than 30 days`,resetUiPreferencesDescription:`Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.`,enableHomeAssistant:`Enable Home Assistant`,enableMqtt:`Enable MQTT`,useTls:`Use TLS`,enableMetricsEndpoint:`Enable Metrics Endpoint`,availableMetrics:`Available Metrics`,editUser:`Edit User`,deleteUserTitle:`Delete User`,groupName:`Group Name`,leaveEmptyForAnonymous:`Leave empty for anonymous`,leaveEmptyForNoAuth:`Leave empty for no authentication`,enterNewPassword:`Enter new password`,confirmNewPassword:`Confirm new password`,enterGroupName:`Enter group name`,enterDescriptionOptional:`Enter description (optional)`,enterCurrentPassword:`Enter current password`,enterNewPasswordMin6:`Enter new password (min 6 characters)`,toast:{keyCopied:`Key copied to clipboard`,copyFailed:`Failed to copy key`,keyAddedToBrowser:`Key added to API Browser`,clearLogsFailed:`Failed to clear logs`,uiPreferencesReset:`UI preferences reset. Refreshing...`,authDisabled:`Authentication disabled successfully`,authDisableFailed:`Failed to disable authentication`,apiKeyCreated:`API key created`,apiKeyDeleted:`API key deleted`,userCreated:`User created successfully`,userUpdated:`User updated successfully`,userDeleted:`User deleted successfully`,groupCreated:`Group created successfully`,groupUpdated:`Group updated successfully`,groupDeleted:`Group deleted successfully`,fillRequiredFields:`Please fill in all required fields`,passwordsDoNotMatch:`Passwords do not match`,passwordTooShort:`Password must be at least 8 characters`,passwordNeedsUppercase:`Password must contain at least one uppercase letter`,passwordNeedsLowercase:`Password must contain at least one lowercase letter`,passwordNeedsDigit:`Password must contain at least one digit`,passwordNeedsSpecial:`Password must contain at least one special character`,enterGroupName:`Please enter a group name`,settingsSaved:`Settings saved`,noPermissionUpdate:`You do not have permission to change settings`,cameraSettingsSaved:`Camera settings saved`,enterCameraUrl:`Please enter a camera URL`,passwordChanged:`Password changed successfully`,connectionFailed:`Connection failed`,testFailed:`Test failed`,cameraConnected:`Camera connected{{resolution}}`},testConnection:`Test Connection`,catalog:{spoolCatalog:`Spool Catalog`,spoolCatalogDescription:`Empty spool weights by brand/type. Used for automatic weight lookup when adding spools.`,searchCatalog:`Search catalog...`,addNewEntry:`Add New Entry`,namePlaceholder:`Name (e.g., Bambu Lab - Plastic)`,weight:`Weight`,type:`Type`,default:`Default`,custom:`Custom`,noMatch:`No entries match your search`,empty:`No entries in catalog`,deleteEntry:`Delete Entry`,deleteConfirm:`Are you sure you want to delete "{{name}}"?`,resetCatalog:`Reset Catalog`,resetConfirm:`Reset catalog to defaults? This will remove all custom entries.`,loadFailed:`Failed to load spool catalog`,nameWeightRequired:`Name and weight are required`,entryAdded:`Entry added`,addFailed:`Failed to add entry`,entryUpdated:`Entry updated`,updateFailed:`Failed to update entry`,entryDeleted:`Entry deleted`,deleteFailed:`Failed to delete entry`,resetSuccess:`Catalog reset to defaults`,resetFailed:`Failed to reset catalog`,exported:`Exported {{count}} entries`,imported:`Imported {{added}} entries ({{skipped}} skipped)`,importFailed:`Failed to import: invalid JSON format`,exportTooltip:`Export catalog to JSON`,importTooltip:`Import catalog from JSON`,resetTooltip:`Reset to defaults`,selectedCount:`{{count}} selected`,deleteSelected:`Delete Selected`,bulkDeleteConfirm:`Are you sure you want to delete {{count}} entries?`,bulkDeleted:`Deleted {{count}} entries`,bulkDeleteFailed:`Failed to delete entries`,material:`Material`,spoolWeight:`Spool Weight`,color:`Color`,updateSpoolWeight:`Update Spool Weight`,filamentUpdated:`Filament updated`,filamentUpdateFailed:`Failed to update filament`,filamentUpdateInvalid:`Invalid filament data`,keepExistingSpoolWeight:`Keep old weight for existing spools`,keepExistingSpoolWeightDesc:`Spools already created with this filament type retain the old tare weight. New spools use the updated value.`,applyToAllSpools:`Apply to all spools`,applyToAllSpoolsDesc:`All weight calculations for this filament type immediately use the new tare weight.`},colorCatalog:{title:`Color Catalog`,description:`Filament colors by manufacturer/material. Used for automatic color lookup when adding spools.`,searchColors:`Search colors...`,allManufacturers:`All manufacturers`,addNewColor:`Add New Color`,manufacturer:`Manufacturer`,colorName:`Color Name`,hex:`Hex`,materialOptional:`Material (optional)`,showing:`Showing {{filtered}} of {{total}} colors`,noMatch:`No colors match your search`,empty:`No colors in catalog`,deleteColor:`Delete Color`,deleteConfirm:`Are you sure you want to delete "{{name}}"?`,resetCatalog:`Reset Color Catalog`,resetConfirm:`Reset catalog to defaults? This will remove all custom colors.`,sync:`Sync`,starting:`Starting...`,syncTooltip:`Sync from FilamentColors.xyz (2000+ colors, may take a minute)`,loadFailed:`Failed to load color catalog`,fieldsRequired:`Manufacturer, color name, and hex color are required`,colorAdded:`Color added`,addFailed:`Failed to add color`,colorUpdated:`Color updated`,updateFailed:`Failed to update color`,colorDeleted:`Color deleted`,deleteFailed:`Failed to delete color`,resetSuccess:`Color catalog reset to defaults`,resetFailed:`Failed to reset catalog`,syncUpToDate:`Already up to date ({{count}} colors checked)`,syncComplete:`Added {{added}} new colors ({{skipped}} already existed)`,syncError:`Sync error`,syncFailed:`Failed to sync from FilamentColors.xyz`,exported:`Exported {{count}} colors`,imported:`Imported {{added}} colors ({{skipped}} skipped)`,importFailed:`Failed to import: invalid JSON format`,selectedCount:`{{count}} selected`,deleteSelected:`Delete Selected`,bulkDeleteConfirm:`Are you sure you want to delete {{count}} colors?`,bulkDeleted:`Deleted {{count}} colors`,bulkDeleteFailed:`Failed to delete colors`},dateFormat:`Date Format`,dateFormatUs:`US (MM/DD/YYYY)`,dateFormatEu:`EU (DD/MM/YYYY)`,dateFormatIso:`ISO (YYYY-MM-DD)`,timeFormat:`Time Format`,timeFormat12:`12-hour (3:30 PM)`,timeFormat24:`24-hour (15:30)`,defaultPrinter:`Default Printer`,defaultPrinterDescription:`Pre-select this printer for uploads, reprints, and other operations.`,slicerBambuStudio:`Bambu Studio`,slicerOrcaSlicer:`OrcaSlicer`,sidebarOrderDescription:`Use Sidebar to reorder items, reset visibility, and manage custom links.`,setDefault:`Set Default`,sidebarOrderSetDefaultHint:`Set default applies the current menu order to users who haven't customized theirs.`,sidebarDefaultSet:`Default menu order has been set.`,sidebarDefaultCleared:`Default menu order cleared.`,sidebarDefaultFailed:`Failed to set default menu order.`,reset:`Reset`,darkMode:`Dark Mode`,lightMode:`Light Mode`,active:`(active)`,background:`Background`,accent:`Accent`,style:`Style`,bgNeutral:`Neutral`,bgWarm:`Warm`,bgCool:`Cool`,bgOled:`OLED Black`,bgSlate:`Slate Blue`,bgForest:`Forest Green`,accentGreen:`Green`,accentTeal:`Teal`,accentBlue:`Blue`,accentOrange:`Orange`,accentPurple:`Purple`,accentRed:`Red`,styleClassic:`Classic`,styleGlow:`Glow`,styleVibrant:`Vibrant`,themeToggleHint:`Toggle between dark, light, and system mode using the icon in the sidebar.`,autoArchivePrints:`Auto-archive prints`,autoArchiveDescription:`Automatically save 3MF files when prints complete`,saveThumbnailsDescription:`Extract and save preview images from 3MF files`,captureFinishPhotoDescription:`Take a photo from printer camera when print completes. Bambuddy records a brief timelapse during the print so the photo can be sourced from the moment before the bed drops; the timelapse file is kept if you enabled timelapse for this print, otherwise it is deleted automatically after the photo is captured.`,ffmpegNotInstalled:`ffmpeg not installed`,ffmpegRequired:`Camera capture requires ffmpeg. Install it via brew install ffmpeg (macOS) or apt install ffmpeg (Linux).`,camera:`Camera`,cameraViewMode:`Camera View Mode`,cameraOverlayDescription:`Camera opens in a resizable overlay on the main screen`,cameraWindowDescription:`Camera opens in a separate browser window`,externalCamerasDescription:`Configure external cameras to replace the built-in printer camera. Supports MJPEG streams, RTSP, HTTP snapshots, and USB cameras (V4L2). When enabled, the external camera is used for live view and finish photos.`,cameraPlaceholderUsb:`Device path (/dev/video0)`,cameraPlaceholderUrl:`Camera URL (rtsp://... or http://...)`,cameraTypeMjpeg:`MJPEG Stream`,cameraTypeRtsp:`RTSP Stream`,cameraTypeSnapshot:`HTTP Snapshot`,cameraTypeUsb:`USB Camera (V4L2)`,cameraSnapshotUrl:`Snapshot URL (optional)`,cameraSnapshotUrlPlaceholder:`http://192.168.1.61:1984/api/frame.jpeg?src=printer`,cameraSnapshotUrlHelp:`Single-frame URL used for notification thumbnails, finish photos, layer-timelapse frames, and plate detection. Timelapse and plate detection each require their own per-printer toggle — this URL is just the image source they pull from when active. Leave blank to capture from the live stream above. Useful for go2rtc (/api/frame.jpeg) and IP cameras with a dedicated snapshot endpoint.`,cameraRotation:`Rotation`,test:`Test`,connected:`Connected`,disconnected:`Disconnected`,currency:`Currency`,defaultFilamentCost:`Default filament cost (per kg)`,electricityCost:`Electricity cost per kWh`,energyDisplayMode:`Energy display mode`,energyModePrintDescription:`Dashboard shows sum of energy used during prints`,energyModeTotalDescription:`Dashboard shows lifetime energy from smart plugs`,fileManager:`File Manager`,createArchiveEntry:`Create Archive Entry When Printing`,createArchiveEntryDescription:`When printing from File Manager, optionally create an archive entry`,lowDiskSpaceWarning:`Low Disk Space Warning`,lowDiskSpaceDescription:`Show warning when free disk space falls below this threshold`,printerFirmware:`Printer Firmware`,checkFirmwareDescription:`Check for printer firmware updates from Bambu Lab`,bambuddySoftware:`Bambuddy Software`,autoCheckDescription:`Automatically check for new versions on startup`,checkNow:`Check now`,updateAvailableVersion:`Update available: v{{version}}`,releaseNotes:`Release Notes`,updateViaDocker:`Update via Docker Compose:`,updateViaHomeAssistant:`Updates are managed by the Home Assistant Supervisor. Open Settings → Add-ons → Bambuddy in Home Assistant to install the new version.`,updateViaWindowsInstaller:`Windows installations are updated by re-running the installer. Download the new version below — your data, settings and printers are preserved.`,downloadWindowsInstaller:`Download installer for v{{version}}`,installUpdate:`Install Update`,latestVersionRunning:`You're running the latest version`,failedToCheckUpdates:`Failed to check for updates: {{error}}`,backupRestore:`Backup & Restore`,backupRestoreDescription:`Export/import settings and configure GitHub backup`,goToBackup:`Go to Backup`,externalUrl:`External URL`,externalUrlDescription:`The external URL where Bambuddy is accessible. Used for notification images and external integrations.`,bambuddyUrl:`Bambuddy URL`,externalUrlHint:`Include protocol and port (e.g., http://192.168.1.100:8000)`,ftpRetry:`FTP Retry`,ftpRetryDescription:`Retry FTP operations when printer WiFi is unreliable. Applies to 3MF downloads, print uploads, timelapse downloads, and firmware updates.`,autoRetryDescription:`Automatically retry failed FTP operations`,retryAttempts:`Retry attempts`,retryDelay:`Retry delay`,connectionTimeout:`Connection timeout`,time_one:`{{count}} time`,time_other:`{{count}} times`,second_one:`{{count}} second`,second_other:`{{count}} seconds`,nSeconds:`{{count}} seconds`,increaseForWeakWifi:`Increase for printers with weak WiFi`,homeAssistant:`Home Assistant`,homeAssistantFullDescription:`Connect to Home Assistant to control smart plugs via HA's REST API. Supports switch, light, input_boolean, and script entities.`,homeAssistantUrl:`Home Assistant URL`,longLivedAccessToken:`Long-Lived Access Token`,haTokenHint:`Create a token in HA: Profile → Long-Lived Access Tokens → Create Token`,connectionSuccessful:`Connection Successful`,connectionFailed:`Connection Failed`,haConnectionSuccess:`Successfully connected to Home Assistant.`,haConnectionFailed:`Failed to connect to Home Assistant.`,mqttPublishing:`MQTT Publishing`,mqttDescription:`Publish BamBuddy events to an external MQTT broker for integration with Node-RED, Home Assistant, and other automation systems.`,mqttEnableDescription:`Publish events to external MQTT broker`,brokerHostname:`Broker hostname`,port:`Port`,usernameOptional:`Username (optional)`,passwordOptional:`Password (optional)`,topicPrefix:`Topic prefix`,topicPrefixHint:`Topics will be: {{prefix}}/printers//status, etc.`,prometheusMetrics:`Prometheus Metrics`,prometheusEndpointDescription:`Expose printer metrics at /api/v1/metrics for Prometheus/Grafana monitoring.`,bearerTokenOptional:`Bearer Token (optional)`,bearerTokenHint:`If set, requests must include Authorization: Bearer `,metricsConnectionStatus:`Connection status`,metricsPrinterState:`Printer state (idle/printing/etc)`,metricsPrintProgress:`Print progress 0-100%`,metricsBedTemp:`Bed temperature`,metricsNozzleTemp:`Nozzle temperature`,metricsPrintsTotal:`Total prints by result`,metricsMore:`...and more (layers, fans, queue, filament usage)`,smartPlugsDescription:`Connect smart plugs (Tasmota or Home Assistant) to automate power control and track energy usage for your printers.`,allOn:`All On`,allOff:`All Off`,addSmartPlug:`Add Smart Plug`,energySummary:`Energy Summary`,currentPower:`Current Power`,plugsOnline:`{{reachable}}/{{total}} plugs online`,today:`Today`,yesterday:`Yesterday`,total:`Total`,enablePlugsForSummary:`Enable plugs to see energy summary`,addNotificationProvider:`Add`,systemBadge:`(System)`,creating:`Creating...`,changing:`Changing...`,deleteUserAndItems:`Delete user AND their items`,deleteUserKeepItems:`Delete user, keep items (become ownerless)`,ok:`OK`,twoFa:{totpTitle:`Authenticator App (TOTP)`,totpDesc:`Use an authenticator app like Google Authenticator, Aegis or Authy.`,emailOtpTitle:`Email OTP`,emailOtpDesc:`Send a one-time code to {{email}} when you log in.`,emailOtpNoEmail:`Add an email address to your account to enable this method.`,addEmailFirst:`Your account has no email address. Ask an admin to add one before enabling Email OTP.`,setupTotp:`Set up Authenticator App`,setupAuthApp:`Set up Authenticator App`,setupInstructions:`Scan the QR code below with your authenticator app, then confirm with a code.`,manualEntry:`Can't scan? Enter this secret manually:`,scannedContinue:`I've scanned the code — continue`,enterCodeToConfirm:`Enter the 6-digit code from your authenticator app to confirm setup.`,activate:`Activate`,disableTotp:`Disable Authenticator`,disableConfirmHint:`Enter a valid TOTP code or a backup code to disable the authenticator.`,totpDisabled:`Authenticator app disabled.`,emailOtpEnabled:`Email OTP enabled.`,emailOtpDisabled:`Email OTP disabled.`,smtpRequired:`Please configure and test SMTP settings first.`,invalidCode:`Invalid code. Please try again.`,enableEmailOtp:`Enable Email OTP`,disableEmailOtp:`Disable Email OTP`,emailSetupEnterCode:`A verification code has been sent to your email address. Enter it below to confirm you own this inbox.`,verifyAndEnable:`Verify & Enable`,emailDisablePasswordHint:`Enter your account password to confirm disabling email OTP.`,passwordPlaceholder:`Enter your password`,backupCodesTitle:`Save your backup codes`,backupCodesWarning:`Save these codes somewhere safe. Each code can only be used once and they will not be shown again.`,backupCodesRemaining:`{{count}} backup codes remaining`,savedCodes:`I've saved my codes`,regenBackup:`Regenerate Backup Codes`,regenBackupHint:`Enter your current TOTP code to generate 10 new backup codes. All existing backup codes will be invalidated.`,newBackupCodes:`New backup codes`,linkedAccounts:`Linked SSO Accounts`,linkedAccountsDesc:`These external identity providers are linked to your account.`,oidcUnlinked:`Account unlinked.`},sessionPolicy:{title:`Session Policy`,description:`Maximum session lifetime for new user logins. Already-issued tokens keep their original expiry.`,preset24h:`24 hours`,preset7d:`7 days`,preset30d:`30 days`,customHoursLabel:`Custom session lifetime in hours`,hoursSuffix:`hours`,warning:`Longer sessions reduce automatic logout protection. Recommended only for trusted single-user deployments.`},oidc:{title:`SSO / OIDC Providers`,desc:`Configure OpenID Connect providers to allow single sign-on via external identity providers.`,addProvider:`Add Provider`,newProvider:`New Provider`,empty:`No OIDC providers configured yet.`,created:`Provider created.`,updated:`Provider updated.`,deleted:`Provider deleted.`,refreshIcon:`Refresh icon`,removeIcon:`Remove icon`,iconRefreshed:`Icon refreshed.`,iconRemoved:`Icon removed.`,iconFetchFailed:`Icon could not be fetched from the provider URL.`,deleteTitle:`Delete Provider`,deleteMessage:`Delete "{{name}}"? All linked user accounts will be disconnected.`,form:{name:`Display Name`,issuerUrl:`Issuer URL`,clientId:`Client ID`,clientSecret:`Client Secret`,scopes:`Scopes`,iconUrl:`Icon URL (optional)`,enabled:`Enabled`,autoCreate:`Auto-create users`,autoCreateDesc:`Automatically create a local account on first login.`,autoLink:`Auto-link existing accounts`,autoLinkDesc:`Link existing local accounts by matching email on first login.`,secretHint:`leave blank to keep current`,secretPlaceholder:`new secret`,emailClaim:`Email Claim`,emailClaimDesc:`JWT claim used as email identity. Use 'preferred_username' or 'upn' for Azure Entra ID (which does not send email_verified). Only use trusted claim names.`,emailClaimPlaceholder:`email`,emailClaimCustomClaimAutoLinkWarning:`Custom claims are safe for auto-link only when the value is tenant-administered (e.g. Azure Entra ID upn / preferred_username). Do not enable auto-link if your IdP allows users to self-assert this claim.`,requireEmailVerified:`Require email verified`,requireEmailVerifiedDesc:`Only accept the email claim when the provider marks it as verified.`,requireEmailVerifiedWarning:`Warning: email will be accepted even without verification. Use only with trusted providers.`,requireEmailVerifiedAutoLink:`Disable auto-link first to change this setting.`,defaultGroup:`Default Group`,defaultGroupDesc:`Group assigned to auto-created users. Falls back to Viewers if not set.`,defaultGroupViewersFallback:`Viewers (default)`}},encryption:{title:`MFA Encryption Status`,enabledFromEnv:`At-rest encryption enabled (key from MFA_ENCRYPTION_KEY environment variable)`,enabledFromFile:`At-rest encryption enabled (key loaded from data directory)`,enabledGenerated:`At-rest encryption enabled with auto-generated key`,notConfigured:`At-rest encryption not configured`,notConfiguredDesc:`TOTP secrets and OIDC client_secrets are stored in plaintext. Set MFA_ENCRYPTION_KEY or restart Bambuddy with a writable data directory to auto-generate one.`,allEncrypted:`All MFA secrets are encrypted at rest.`,legacyRowsLabel:`Legacy plaintext rows`,encryptedRowsLabel:`Encrypted rows`,legacyRowsWarning:`{{count}} legacy plaintext row(s) detected. Re-save the OIDC provider or re-enroll the user’s authenticator app to migrate to encrypted storage.`,backupHint:`The auto-generated key is stored at DATA_DIR/.mfa_encryption_key and is included in local backup ZIPs. Keep your backups secure or set MFA_ENCRYPTION_KEY explicitly.`,decryptionBrokenTitle:`Encryption key missing`,decryptionBrokenError:`{{count}} encrypted record(s) cannot be decrypted because the encryption key is no longer available. Restore the previous MFA_ENCRYPTION_KEY or DATA_DIR/.mfa_encryption_key to recover.`,migrationErrorWarning:`{{count}} legacy row(s) failed to re-encrypt at startup. Check server logs and restart Bambuddy to retry.`}},notification:{printStarted:{title:`Print Started`,body:`{{printer}}: {{filename}} has started printing`},printCompleted:{title:`Print Completed`,body:`{{printer}}: {{filename}} completed successfully`},printFailed:{title:`Print Failed`,body:`{{printer}}: {{filename}} has failed`},printStopped:{title:`Print Stopped`,body:`{{printer}}: {{filename}} was stopped`},printProgress:{title:`Print Progress`,body:`{{printer}}: {{filename}} is {{percent}}% complete`},printerOffline:{title:`Printer Offline`,body:`{{printer}} is offline`},printerError:{title:`Printer Error`,body:`{{printer}}: {{error}}`},filamentLow:{title:`Low Filament`,body:`{{printer}}: Filament is running low`},maintenanceDue:{title:`Maintenance Due`,body:`{{printer}}: {{items}} need attention`}},errors:{generic:`Something went wrong`,networkError:`Network error. Please check your connection.`,notFound:`Not found`,unauthorized:`Unauthorized`,serverError:`Server error`,validationError:`Please check your input`,printerConnectionFailed:`Failed to connect to printer`,saveFailed:`Failed to save changes`,deleteFailed:`Failed to delete`,loadFailed:`Failed to load data`},hmsErrors:{title:`Errors - {{name}}`,noErrors:`No errors`,viewOnWiki:`View on Bambu Lab Wiki`,clearInstructions:`Clear errors on the printer to dismiss them here.`,clearErrors:`Clear Errors`,clearSuccess:`HMS errors cleared`,clearFailed:`Failed to clear HMS errors`},mqttDebug:{title:`MQTT Debug Log`,searchPlaceholder:`Search topic or payload...`,noMessages:`No messages logged yet`,startLoggingHint:`Click "Start Logging" to begin capturing MQTT messages`,noMessagesMatch:`No messages match your filter`,adjustFilterHint:`Try adjusting your search or filter criteria`,incoming:`Incoming`,outgoing:`Outgoing`,loggingStopped:`Logging stopped`,loggingActive:`Logging active - messages will auto-refresh`,startLogging:`Start Logging`,stopLogging:`Stop Logging`,clearLog:`Clear Log`,topic:`Topic`,timestamp:`Timestamp`,direction:`Direction`,all:`All`},printerFiles:{title:`File Manager`,storageUsed:`Used:`,storageFree:`Free:`,filterPlaceholder:`Filter files...`,deleteButton:`Delete`,deleteFiles:`Delete {{count}} Files`,deleteFileConfirm:`Delete "{{name}}"? This cannot be undone.`,deleteFilesConfirm:`Delete {{count}} selected files? This cannot be undone.`,noFiles:`No files on printer`,loadingFiles:`Loading files...`,failedToLoad:`Failed to load files`,toast:{filesDeleted:`Deleted {{count}} file(s)`,deleteFailed:`Delete failed: {{error}}`}},confirm:{delete:`Are you sure you want to delete this?`,unsavedChanges:`You have unsaved changes. Are you sure you want to leave?`,clearQueue:`Are you sure you want to clear the queue?`},login:{title:`Bambuddy Login`,subtitle:`Sign in to your account`,username:`Username`,usernamePlaceholder:`Enter your username`,usernameOrEmail:`Username or Email`,usernameOrEmailPlaceholder:`Username or @ Email`,password:`Password`,passwordPlaceholder:`Enter your password`,signIn:`Sign in`,signingIn:`Logging in...`,rememberMe:`Remember Me`,forgotPassword:`Forgot your password?`,loginSuccess:`Logged in successfully`,loginFailed:`Login failed`,enterCredentials:`Please enter username and password`,enterEmail:`Please enter your email address`,oidcLoginFailed:`OIDC login failed`,oidcErrors:{providerError:`The identity provider returned an error`,missingParameters:`OIDC callback is missing required parameters`,invalidState:`OIDC state is invalid or has already been used`,stateExpired:`OIDC login session expired — please try again`,providerNotFound:`OIDC provider not found`,discoveryFailed:`Failed to fetch OIDC discovery document`,invalidDiscovery:`OIDC discovery document is invalid`,networkError:`Network error during OIDC token exchange`,badResponse:`Unexpected response during OIDC token exchange`,noIdToken:`OIDC provider did not return an ID token`,validationFailed:`OIDC token validation failed`,nonceMismatch:`OIDC nonce mismatch — possible replay attack`,missingSubClaim:`OIDC token is missing the sub claim`,noLinkedAccount:`No local account is linked to this OIDC identity`,accountInactive:`Your account is inactive`,userResolutionFailed:`Failed to resolve your account`,internalError:`An internal error occurred during OIDC login`,tokenExchangeFailed:`OIDC token exchange failed`},forgotPasswordTitle:`Forgot Password`,forgotPasswordMessage:`If you've forgotten your password, please contact your system administrator to reset it.`,forgotPasswordEmailMessage:`Enter your email address and we'll send you a new password.`,emailAddress:`Email Address`,emailPlaceholder:`your.email@example.com`,cancel:`Cancel`,sending:`Sending...`,sendResetEmail:`Send Reset Email`,howToReset:`How to reset your password:`,resetStep1:`Contact your Bambuddy administrator`,resetStep2:`Ask them to reset your password in User Management`,resetStep3:`They can set a new temporary password for you`,resetStep4:`Log in with the new password and change it in Settings`,gotIt:`Got it`,resetPassword:{title:`Set New Password`,subtitle:`Enter and confirm your new password below.`,newPassword:`New Password`,newPasswordPlaceholder:`At least 8 characters`,confirmPassword:`Confirm Password`,confirmPasswordPlaceholder:`Repeat new password`,saving:`Saving…`,submit:`Set New Password`,backToLogin:`Back to login`,passwordsDoNotMatch:`Passwords do not match`,passwordTooShort:`Password must be at least 8 characters`,resetFailed:`Password reset failed. The link may have expired.`},twoFA:{title:`Two-Factor Authentication`,subtitle:`Your account is protected with 2FA. Enter the verification code below.`,methodAuthenticator:`Authenticator App`,methodEmail:`Email Code`,methodBackup:`Backup Code`,instructionsTotp:`Open your authenticator app and enter the 6-digit code for Bambuddy.`,instructionsEmail:`A 6-digit code has been sent to your email address. It expires in 10 minutes.`,instructionsEmailNotSent:`Click the button below to receive a verification code via email.`,instructionsBackup:`Enter one of your 8-character backup recovery codes. Each code can only be used once.`,sendCodeButton:`Send Code via Email`,sendingCode:`Sending...`,resendCode:`Resend code`,codeLabel:`Verification Code`,backupCodeLabel:`Backup Code`,codePlaceholder:`000000`,backupCodePlaceholder:`XXXXXXXX`,verifyButton:`Verify`,verifyingButton:`Verifying...`,backToLogin:`← Back to login`,orContinueWith:`or continue with`,signInWith:`Sign in with {{provider}}`,enterCode:`Please enter the verification code`,sendCodeFailed:`Failed to send verification code`,invalidCode:`Invalid code. Please try again.`}},setup:{title:`Bambuddy Setup`,subtitle:`Configure authentication for your Bambuddy instance`,enableAuth:`Enable Authentication`,adminAccount:`Admin Account`,adminAccountDesc:`If admin users already exist, authentication will be enabled using the existing admin accounts. Leave the fields below empty to use existing admins, or enter new credentials to create a new admin user.`,adminUsername:`Admin Username`,adminPassword:`Admin Password`,optionalIfAdminExists:`(optional if admin users exist)`,adminUsernamePlaceholder:`Enter admin username (optional)`,adminPasswordPlaceholder:`Enter admin password (optional)`,confirmPassword:`Confirm Password`,confirmPasswordPlaceholder:`Confirm admin password`,settingUp:`Setting up...`,completeSetup:`Complete Setup`,toast:{authEnabledAdminCreated:`Authentication enabled and admin user created`,authEnabledExistingAdmins:`Authentication enabled using existing admin users`,setupCompleted:`Setup completed`,enterBothCredentials:`Please enter both admin username and password, or leave both empty to use existing admin users`,passwordsDoNotMatch:`Passwords do not match`,passwordTooShort:`Password must be at least 6 characters`}},changePassword:{title:`Change Password`,currentPassword:`Current Password`,currentPasswordPlaceholder:`Enter current password`,newPassword:`New Password`,newPasswordPlaceholder:`Enter new password (min 6 characters)`,confirmPassword:`Confirm New Password`,confirmPasswordPlaceholder:`Confirm new password`,passwordsDoNotMatch:`Passwords do not match`,passwordTooShort:`Password must be at least 6 characters`,changing:`Changing...`,success:`Password changed successfully`,failed:`Failed to change password`},plateAlert:{title:`Print Paused!`,message:`Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print.`,understand:`I Understand`},camera:{title:`Camera View`,invalidPrinterId:`Invalid printer ID`,live:`Live`,snapshot:`Snapshot`,restartStream:`Restart stream`,refreshSnapshot:`Refresh snapshot`,fullscreen:`Fullscreen`,exitFullscreen:`Exit fullscreen`,connectingToCamera:`Connecting to camera...`,capturingSnapshot:`Capturing snapshot...`,connectionLost:`Connection lost`,connectionFailed:`Camera connection failed`,reconnecting:`Reconnecting in {{countdown}}s... (attempt {{attempt}}/{{max}})`,reconnectNow:`Reconnect now`,cameraUnavailable:`Camera unavailable`,cameraUnavailableDesc:`Make sure the printer is powered on and connected.`,noCamera:`No camera available`,retry:`Retry`,cameraStream:`Camera stream`,zoomOut:`Zoom out`,zoomIn:`Zoom in`,resetZoom:`Reset zoom`,recording:`Recording`,startRecording:`Start Recording`,stopRecording:`Stop Recording`,chamberLight:`Toggle chamber light`,unavailable:`Camera unavailable`,diagnose:{button:`Diagnose`,modalTitle:`Camera diagnostic`,running:`Running diagnostic...`,runFailed:`Diagnostic could not run: {{error}}`,retry:`Run again`,stage:{tcp_reachable:`Network reachability`,first_frame:`Frame capture`,live_stream_active:`Live stream active`},summary:{all_ok:`Camera is working. The diagnostic completed all stages successfully.`,live_stream_active_healthy:`Camera is currently streaming with recent frames — no test needed.`,printer_unreachable:`Printer is not reachable. Check the IP address, network connection, and that the printer is powered on.`,camera_port_closed:`Printer is reachable but the camera port is closed. Make sure LAN-only mode and Developer Mode are enabled in the printer settings.`,no_frame:`Connected to the camera but no frames were received. Try again, or check that the camera is enabled in the printer settings.`,unknown_failure:`Camera diagnostic failed for an unknown reason. Check the support log for details.`},meta:{protocol:`Protocol`,port:`Port`,profile:`Profile`}}},groups:{title:`Group Management`,subtitle:`Manage permission groups for access control`,backToSettings:`Back to Settings`,createGroup:`Create Group`,noPermission:`You do not have permission to access this page.`,system:`System`,noDescription:`No description`,usersCount:`{{count}} users`,permissionsCount:`{{count}} permissions`,edit:`Edit`,delete:`Delete`,toast:{created:`Group created successfully`,updated:`Group updated successfully`,deleted:`Group deleted successfully`,enterGroupName:`Please enter a group name`},modal:{editGroup:`Edit Group`,createGroup:`Create Group`,cancel:`Cancel`,saving:`Saving...`,creating:`Creating...`,saveChanges:`Save Changes`},form:{groupName:`Group Name`,groupNamePlaceholder:`Enter group name`,systemGroupWarning:`System group names cannot be changed`,description:`Description`,descriptionPlaceholder:`Enter description (optional)`,permissions:`Permissions ({{count}} selected)`},deleteModal:{title:`Delete Group`,message:`Are you sure you want to delete this group? Users in this group will lose these permissions.`,confirm:`Delete Group`},editor:{title:`Edit Group`,createTitle:`Create Group`,search:`Search permissions...`,selectAll:`Select All`,clearAll:`Clear All`,permissionsSelected:`{{count}} selected`,noResults:`No permissions match your search`}},users:{title:`User Management`,subtitle:`Manage users and their access to your Bambuddy instance`,backToSettings:`Back to Settings`,createUser:`Create User`,noPermission:`You do not have permission to access this page.`,admin:`Admin`,noGroups:`No groups`,active:`Active`,inactive:`Inactive`,edit:`Edit`,delete:`Delete`,system:`System`,noGroupsAvailable:`No groups available`,table:{username:`Username`,groups:`Groups`,status:`Status`,actions:`Actions`},toast:{created:`User created successfully`,updated:`User updated successfully`,deleted:`User deleted successfully`,fillRequired:`Please fill in all required fields`,passwordsDoNotMatch:`Passwords do not match`,passwordTooShort:`Password must be at least 6 characters`,ldapProvisioned:`Provisioned LDAP user "{{username}}"`},modal:{createUser:`Create User`,editUser:`Edit User`,cancel:`Cancel`,creating:`Creating...`,saving:`Saving...`,saveChanges:`Save Changes`,advancedAuthSubtitle:`with Advanced Authentication`,tabsAriaLabel:`User source`,localTab:`Local`,ldapTab:`LDAP`,ldapSearchLabel:`Search directory`,ldapSearchPlaceholder:`Type a username, name, or email...`,ldapMinChars:`Type at least 2 characters to search`,ldapTypeToSearch:`Start typing to search the LDAP directory`,ldapSearching:`Searching directory...`,ldapNoResults:`No matching users in the directory`,ldapSearchError:`Directory search failed. Check the LDAP server status.`,ldapAlreadyProvisioned:`Already provisioned`,ldapSelectedLabel:`Selected`,ldapProvision:`Provision user`,ldapProvisioning:`Provisioning...`,ldapErrorProvision:`Provisioning failed. Check the LDAP server status and try again.`},form:{username:`Username`,usernamePlaceholder:`Enter username`,email:`Email`,emailPlaceholder:`user@example.com`,password:`Password`,passwordPlaceholder:`Enter password`,confirmPassword:`Confirm Password`,confirmPasswordPlaceholder:`Confirm password`,newPasswordPlaceholder:`Enter new password`,confirmNewPasswordPlaceholder:`Confirm new password`,leaveBlankToKeep:`leave blank to keep current`,groups:`Groups`,optional:`optional`,autoGeneratedPassword:`A secure password will be automatically generated and emailed to the user.`,passwordManagedByAdvancedAuth:`Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.`,resetPassword:`Reset Password`,resettingPassword:`Resetting Password...`},deleteModal:{title:`Delete User`,message:`Are you sure you want to delete this user? This action cannot be undone.`,confirm:`Delete User`}},streamOverlay:{title:`Stream Overlay`,invalidPrinterId:`Invalid printer ID`,cameraStream:`Camera stream`,progress:`Progress`,eta:`ETA`,printerIdle:`Printer is idle`,printerOffline:`Printer offline`,status:{printing:`Printing`,paused:`Paused`,finished:`Finished`,failed:`Failed`,idle:`Idle`,unknown:`Unknown`}},profiles:{title:`Profiles`,subtitle:`Manage your slicer presets and pressure advance calibrations`,tabs:{bambuCloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,local:`Local Profiles`,kprofiles:`K-Profiles`},orcaCloud:{connectedAs:`Connected as`,logout:`Disconnect`,noLogoutPermission:`You do not have permission to disconnect`,noConnectPermission:`You do not have permission to connect to Orca Cloud`,retry:`Retry`,back:`Use a different sign-in method`,connect:{title:`Connect to Orca Cloud`,description:`Sign in to your Orca Cloud account to sync your slicer profiles into Bambuddy.`},providers:{google:`Sign in with Google`,apple:`Sign in with Apple`,github:`Sign in with GitHub`,email:`Sign in with email and password`},password:{title:`Sign in with email and password`,email:`Email`,emailPlaceholder:`you@example.com`,password:`Password`,submit:`Sign in`},paste:{title:`Finish signing in`,step1:`A new tab opened with the Orca Cloud sign-in page. Sign in with your Orca account.`,step2:`Your browser will be redirected to a "localhost" URL that fails to load. That is expected — the URL is what we need.`,step3:`Copy the entire URL from your browser's address bar and paste it below.`,signInUrl:`If the sign-in tab did not open, click this URL:`,label:`Paste the callback URL here`,placeholder:`http://localhost:41172/callback?code=...&state=...`,submit:`Finish connecting`},profiles:{title:`Your Orca Cloud profiles ({{count}})`,refresh:`Refresh`,empty:`No profiles found in your Orca Cloud account yet.`},toast:{connected:`Connected to Orca Cloud as {{email}}`,disconnected:`Disconnected from Orca Cloud`},errors:{startFailed:`Could not start the Orca Cloud sign-in flow.`,finishFailed:`Could not finish the Orca Cloud sign-in.`,passwordFailed:`Could not sign in with that email and password.`,passwordEmpty:`Please enter both your email and password.`,emptyPaste:`Please paste the callback URL from your browser.`,noCode:`That URL does not look like an Orca Cloud callback (no code parameter). Copy the full URL from your address bar.`}},localProfiles:{title:`Local Profiles`,subtitle:`Import and manage slicer presets from OrcaSlicer`,import:`Import Profiles`,importDesc:`Drop .bbscfg, .bbsflmt, .orca_filament, .zip, or .json files here`,importing:`Importing...`,search:`Search local presets...`,noPresets:`No local presets yet`,noSearchResults:`No presets match your search`,badge:`Local`,edit:`Edit`,delete:`Delete`,cancel:`Cancel`,deleteConfirmTitle:`Delete Preset`,deleteConfirm:`Are you sure you want to delete this preset? This cannot be undone.`,source:`Source`,inheritsFrom:`Inherits`,filamentType:`Type`,vendor:`Vendor`,compatiblePrinters:`Printers`,nozzleTemp:`Nozzle Temp`,cost:`Cost`,density:`Density`,pressureAdvance:`Pressure Advance`,filament:`Filament`,process:`Process`,printer:`Printer`,toast:{importSuccess:`{{count}} preset(s) imported`,importSkipped:`{{count}} preset(s) skipped (duplicates)`,importError:`{{count}} error(s) during import`,deleted:`Preset deleted`,updated:`Preset updated`}},connectedAs:`Connected as`,logout:`Logout`,noLogoutPermission:`You do not have permission to logout`,failedToLoad:`Failed to load profiles`,retry:`Retry`,time:{justNow:`Just now`,minsAgo:`{{count}}m ago`,hoursAgo:`{{count}}h ago`,daysAgo:`{{count}}d ago`},toast:{loggedOut:`Logged out`},login:{title:`Connect to Bambu Cloud`,subtitle:`Sync your slicer presets across devices`,email:`Email`,password:`Password`,region:`Region`,regionGlobal:`Global`,regionChina:`China`,verificationCode:`Verification Code`,totpCode:`Authenticator Code`,checkEmail:`Check your email ({{email}}) for a 6-digit code`,enterTotpHint:`Enter the 6-digit code from your authenticator app`,accessToken:`Access Token`,accessTokenHint:`Paste your Bambu Cloud access token. China-region accounts must use this path (phone-bound — email login unavailable). See the wiki for how to retrieve the token from MakerWorld cookies.`,back:`Back`,loginButton:`Login`,verifyButton:`Verify`,setTokenButton:`Set Token`,useToken:`Use access token instead`,useEmail:`Login with email instead`,toast:{loggedIn:`Logged in successfully`,codeSent:`Verification code sent to your email`,enterTotp:`Enter code from your authenticator app`,tokenSet:`Token set successfully`}},presets:{myPreset:`My preset (editable)`,duplicate:`Duplicate`,editable:`Editable`,failedToLoadDetails:`Failed to load preset details`,deleteConfirm:`Delete this preset?`,deleteWarning:`This will permanently delete "{{name}}" from Bambu Cloud. This cannot be undone.`,noDuplicatePermission:`You do not have permission to duplicate presets`,noEditPermission:`You do not have permission to edit presets`,noDeletePermission:`You do not have permission to delete presets`,types:{filament:`Filament preset`,printer:`Printer preset`,process:`Process preset`},toast:{deleted:`Preset deleted`,created:`Preset created`,updated:`Preset updated`,duplicated:`Preset duplicated`,fieldAdded:`Field "{{key}}" added`,exported:`Preset exported`},baseLabel:`Base: {{name}}`,currentLabel:`Current: {{name}}`,newPreset:`New Preset`,editPreset:`Edit Preset`,duplicatePreset:`Duplicate Preset`,createNewPreset:`Create New Preset`,customizeSettings:`Customize settings for your new preset`,compareWithBase:`Compare with base preset`,compare:`Compare`,basePreset:`Base Preset`,selectBasePreset:`Select base preset...`,presetName:`Preset Name`,myCustomPreset:`My custom preset`,inheritsFrom:`Inherits from`,dropJsonToImport:`Drop JSON to import`,tabs:{common:`Common`,allFields:`All Fields`},availableFields:`Available Fields`,searchFieldsPlaceholder:`Search fields...`,noMatchingFields:`No matching fields`,allFieldsAdded:`All fields added`,addCustomField:`Add custom field`,yourOverrides:`Your Overrides`,noOverridesYet:`No overrides yet`,clickFieldsToAdd:`Click fields on the left to add them`,saveAsTemplate:`Save as template`,jsonTip:`Tip: Drag & drop a .json file anywhere on this modal to import settings`},cloudView:{searchPlaceholder:`Search presets...`,templates:`Templates`,refresh:`Refresh`,newPreset:`New Preset`,clearFilters:`Clear filters`,compareMode:`Compare Mode`,selectAnotherPreset:`Select another {{type}} preset`,clickTwoPresets:`Click two presets of the same type to compare`,selectFirst:`1. Select first`,selectSecond:`2. Select second`,compareNow:`Compare Now`,lastSynced:`Last synced:`,showingCount:`Showing {{showing}} of {{total}} presets`,noPresetsFound:`No presets found`,columns:{filament:`Filament`,process:`Process`,printer:`Printer`},noFilamentPresets:`No filament presets`,noProcessPresets:`No process presets`,noPrinterPresets:`No printer presets`,filters:{type:`Type`,owner:`Owner`,printer:`Printer`,nozzle:`Nozzle`,filament:`Filament`,layer:`Layer`,all:`All`,myPresets:`My Presets`,builtIn:`Built-in`,process:`Process`},noTemplatesPermission:`You do not have permission to manage templates`,noRefreshPermission:`You do not have permission to refresh profiles`,noCreatePermission:`You do not have permission to create presets`},templates:{title:`Quick Templates`,noTemplates:`No templates yet`,createFirst:`Create templates from the preset editor`,typeFilter:`Type:`,deleteTitle:`Delete Template`,deleteWarning:`This action cannot be undone`,deleteConfirm:`Are you sure you want to delete "{{name}}"?`,namePlaceholder:`Template name`,descriptionPlaceholder:`Description`,settingsJson:`Settings (JSON)`,fieldsCount:`{{count}} fields`,shownInModals:`Shown in modals`,hiddenInModals:`Hidden in modals`,apply:`Apply`,toast:{deleted:`Template deleted`,updated:`Template updated`,created:`Template created`,applied:`Template applied`}}},support:{debugLoggingActive:`Debug logging is active`,manageLogs:`Manage`,collectItem7:`Printer connectivity and firmware versions`,collectItem8:`Integration status (Spoolman, MQTT, HA)`,collectItem9:`Network interfaces (subnets only)`,collectItem10:`Python package versions`,collectItem11:`Database health checks`,collectItem12:`Docker environment details`,bundleGenerating:`Generating bundle...`,bundleStepConnection:`Running printer connectivity checks`,bundleStepVirtualPrinters:`Running virtual-printer setup checks`,bundleStepLogScan:`Scanning recent logs for known issues`,bundleStepBuild:`Building the support bundle ZIP`},fileManager:{title:`File Manager`,subtitle:`Organize and manage your print files`,uploadFiles:`Upload Files`,newFolder:`New Folder`,folderName:`Folder Name`,folderNamePlaceholder:`e.g., Functional Parts`,renameFile:`Rename File`,renameFolder:`Rename Folder`,invalidFilenameChar:`The character "{{char}}" is not allowed in print filenames. The printer SD card rejects: < > : " / \\ | ? *`,moveFiles:`Move {{count}} File(s)`,rootNoFolder:`Root (No Folder)`,current:`current`,linkFolder:`Link Folder`,linkFolderDescription:`Link "{{name}}" to a project or archive for quick access.`,project:`Project`,archive:`Archive`,noProjectsFound:`No projects found`,noArchivesFound:`No archives found`,unlink:`Unlink`,link:`Link`,dragDropFiles:`Drag & drop files here`,dropFilesHere:`Drop files here`,releaseToUpload:`Release to upload`,orClickToBrowse:`or click to browse`,allFileTypesSupported:`All file types supported. ZIP files will be extracted.`,zipFilesDetected:`ZIP files detected`,zipExtractOptions:`ZIP files will be extracted. Choose how to handle folder structure:`,preserveZipStructure:`Preserve folder structure from ZIP`,createFolderFromZip:`Create folder from ZIP filename`,stlThumbnailGeneration:`STL thumbnail generation`,zipMayContainStl:`ZIP files may contain STL files. Thumbnails can be generated during extraction.`,thumbnailsCanBeGenerated:`Thumbnails can be generated for STL files. Large models may take longer to process.`,generateThumbnailsForStl:`Generate thumbnails for STL files`,threemfDetected:`3MF files detected`,threemfExtractionInfo:`Printer model, material, color, and print settings will be automatically extracted from 3MF files.`,willBeExtracted:`Will be extracted`,filesExtracted:`{{count}} files extracted`,uploadComplete:`Upload complete: {{succeeded}} succeeded`,uploadFailed:`Upload failed`,zipFilesFailed:`{{count}} files failed`,uploading:`Uploading...`,changeLink:`Change Link...`,linkTo:`Link to...`,linkToProjectOrArchive:`Link to project or archive`,addToQueue:`Add to Queue`,schedulePrint:`Schedule`,generateThumbnail:`Generate Thumbnail`,generateThumbnails:`Generate Thumbnails`,generateThumbnailsForMissing:`Generate thumbnails for STL files missing them`,gridView:`Grid view`,listView:`List view`,lowDiskSpaceWarning:`Low disk space warning`,lowDiskSpaceDetails:`Only {{free}} free of {{total}} total. Threshold is set to {{threshold}} GB in settings.`,files:`Files`,folders:`Folders`,size:`Size`,free:`Free`,allFiles:`All Files`,allExternal:`External`,externalIsEmpty:`No external files`,externalEmptyDescription:`Files in your linked external folders will appear here.`,wrap:`Wrap`,enableTextWrapping:`Enable text wrapping`,disableTextWrapping:`Disable text wrapping`,collapse:`Collapse`,collapseFoldersByDefault:`Collapse folders by default`,expandFoldersByDefault:`Expand folders by default`,folderSort:`Sort folders`,folderSortByName:`By name`,folderSortByActivity:`By recent activity`,dragToResizeTooltip:`Drag to resize, double-click to reset`,searchFiles:`Search files...`,searchSubfoldersHint:`Including subfolders`,readme:{truncated:`Truncated`},tags:{title:`Tags`,subtitle:`Label files for cross-cutting filtering — toys, kid-safe, PETG-only, anything.`,manage:`Tags`,manageTitle:`Manage tag catalog`,add:`New tag`,edit:`Rename tag`,name:`Name`,fileCount:`Files`,empty:`No tags yet. Create one to start labelling files.`,noMatches:`No matching tags.`,createPlaceholder:`e.g. toys, kid-safe, petg`,createButton:`Create`,nameRequired:`Name is required.`,searchPlaceholder:`Filter tags...`,created:`Tag created.`,updated:`Tag renamed.`,deleted:`Tag removed.`,saveFailed:`Could not save tag.`,deleteFailed:`Could not remove tag.`,applyFailed:`Could not apply tags.`,applyAdd:`Add tags`,applyRemove:`Remove tags`,applyAddSuccess:`Added {{count}} tag(s) across {{files}} file(s).`,applyRemoveSuccess:`Removed {{count}} tag(s) across {{files}} file(s).`,actionAdd:`Add to selected files`,actionRemove:`Remove from selected files`,tagAction:`Tag`,bulkTitle:`Tag {{count}} selected file(s)`,bulkTooltip:`Add or remove tags on every selected file.`,noPermission:`You do not have permission to tag files.`,filterLabel:`Filtering by:`,clearAll:`Clear all`,confirmDelete:`Delete tag "{{name}}"?`,confirmDeleteMessage:`This removes the tag from the catalog. Files keep their other tags.`,confirmDeleteInUseMessage:`This tag is on {{count}} file(s). Deleting removes the chip from all of them; files themselves are untouched.`,editAria:`Edit {{name}}`,deleteAria:`Delete {{name}}`},allTypes:`All types`,prints:`Prints`,ascending:`Ascending`,descending:`Descending`,resultsCount:`{{showing}} of {{total}} files`,selectAll:`Select All`,deselectAll:`Deselect All`,selected:`{{count}} selected`,adding:`Adding...`,loadingFiles:`Loading files...`,folderIsEmpty:`Folder is empty`,noFilesYet:`No files yet`,folderEmptyDescription:`Upload files or move files into this folder to get started.`,noFilesDescription:`Upload files to start organizing your print-related files.`,noMatchingFiles:`No matching files`,noMatchingFilesDescription:`No files match your current search or filter criteria.`,clearFilters:`Clear filters`,printedCount:`Printed {{count}}x`,uploadedBy:`Uploaded By`,deleteFolder:`Delete Folder`,deleteFile:`Delete File`,deleteFilesCount:`Delete {{count}} Files`,deleteFolderConfirm:`Are you sure you want to delete this folder? All files inside will also be deleted.`,deleteFileConfirm:`Are you sure you want to delete this file?`,deleteFilesConfirm:`Are you sure you want to delete {{count}} selected files? This action cannot be undone.`,deleting:`Deleting...`,noPermissionRenameFolder:`You do not have permission to rename folders`,noPermissionLinkFolder:`You do not have permission to link folders`,noPermissionDeleteFolder:`You do not have permission to delete folders`,noPermissionPrint:`You do not have permission to print`,noPermissionAddToQueue:`You do not have permission to add to queue`,noPermissionSlice:`You do not have permission to slice files`,noPermissionDownload:`You do not have permission to download files`,noPermissionRenameFile:`You do not have permission to rename this file`,noPermissionGenerateThumbnail:`You do not have permission to generate thumbnails`,noPermissionDeleteFile:`You do not have permission to delete this file`,noPermissionCreateFolder:`You do not have permission to create folders`,noPermissionUpload:`You do not have permission to upload files`,noPermissionMoveFiles:`You do not have permission to move files`,noPermissionDeleteFiles:`You do not have permission to delete files`,linkExternal:`Link External`,linkExternalFolder:`Link External Folder`,linkExternalFolderDescription:`Mount a host directory (NAS, USB, network share) into the File Manager. Files are not copied — they are accessed directly from the original path.`,externalFolderNamePlaceholder:`e.g., NAS Prints`,externalPath:`Host Path`,externalPathHelp:`Absolute path to the directory on the Docker host. Must be bind-mounted into the container.`,readOnly:`Read Only`,readOnlyHelp:`prevents uploads and deletions`,showHiddenFiles:`Show hidden files (dotfiles)`,externalFolder:`External Folder`,scanFolder:`Scan`,toast:{folderCreated:`Folder created`,folderDeleted:`Folder deleted`,fileDeleted:`File deleted`,filesDeleted:`Deleted {{count}} files`,filesMoved:`Files moved`,folderLinked:`Folder linked`,folderUnlinked:`Folder unlinked`,externalFolderLinked:`External folder linked and scanned`,folderScanned:`Scan complete: {{added}} added, {{removed}} removed`,addedToQueue:`Added {{count}} file(s) to queue`,addedToQueuePartial:`Added {{added}} file(s), {{failed}} failed`,failedToAddToQueue:`Failed to add files: {{error}}`,fileRenamed:`File renamed`,folderRenamed:`Folder renamed`,thumbnailsGenerated:`Generated {{count}} thumbnail(s)`,thumbnailsGeneratedPartial:`Generated {{succeeded}} thumbnail(s), {{failed}} failed`,noStlMissingThumbnails:`No STL files missing thumbnails`,failedToGenerateThumbnails:`Failed to generate thumbnails: {{error}}`,thumbnailGenerated:`Thumbnail generated`,failedToGenerateThumbnail:`Failed to generate thumbnail: {{error}}`}},projects:{title:`Projects`,subtitle:`Organize and track your 3D printing projects`,newProject:`New Project`,editProject:`Edit Project`,deleteProject:`Delete Project`,projectName:`Project Name`,description:`Description`,noProjects:`No projects yet`,noProjectsFiltered:`No {{status}} projects`,noProjectsFilteredHelp:`You don't have any {{status}} projects. Projects will appear here when their status changes.`,createFirst:`Create your first project to start organizing related prints, tracking progress, and managing your builds.`,createFirstButton:`Create Your First Project`,create:`Create`,files:`Files`,prints:`Prints`,plates:`plates`,parts:`parts`,lastModified:`Last Modified`,deleteConfirm:`Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.`,addFiles:`Add Files`,removeFile:`Remove File`,viewDetails:`View Details`,namePlaceholder:`e.g., Voron 2.4 Build`,descriptionPlaceholder:`Optional description...`,urlLabel:`URL`,urlPlaceholder:`https://makerworld.com/...`,urlInvalid:`URL must start with http:// or https://`,openExternalUrl:`Open project URL`,coverImageLabel:`Cover photo`,coverImageAlt:`Project cover photo`,coverImageUpload:`Upload`,coverImageReplace:`Replace`,coverImageRemove:`Remove`,color:`Color`,targetPlates:`Target Plates`,targetPlatesPlaceholder:`e.g., 25`,targetPlatesHelp:`Number of print jobs`,targetParts:`Target Parts`,targetPartsPlaceholder:`e.g., 150`,targetPartsHelp:`Total objects needed`,tagsLabel:`Tags (comma-separated)`,tagsPlaceholder:`e.g., voron, functional, gift`,dueDate:`Due Date`,priority:`Priority`,priorityLow:`Low`,priorityNormal:`Normal`,priorityHigh:`High`,priorityUrgent:`Urgent`,statusActive:`Active`,statusCompleted:`Completed`,statusArchived:`Archived`,done:`Done`,completed:`completed`,failed:`failed`,inQueue:`in queue`,noPrintsYet:`No prints yet`,printJobs:`Print jobs (plates)`,partsPrinted:`Parts printed`,failedParts:`Failed parts`,import:`Import`,export:`Export`,importProject:`Import project`,exportAll:`Export all projects`,loading:`Loading projects...`,noEditPermission:`You do not have permission to edit projects`,noDeletePermission:`You do not have permission to delete projects`,noCreatePermission:`You do not have permission to create projects`,noImportPermission:`You do not have permission to import projects`,noExportPermission:`You do not have permission to export projects`,toast:{created:`Project created`,updated:`Project updated`,deleted:`Project deleted`,imported:`Project imported`,multipleImported:`{{count}} projects imported`,importFailed:`Import failed`,exported:`Projects exported (metadata only)`}},projectDetail:{notFound:`Project not found`,backToProjects:`Back to Projects`,export:`Export`,exportProject:`Export project`,noExportPermission:`You do not have permission to export projects`,noEditPermission:`You do not have permission to edit projects`,partOf:`Part of:`,priorityLabel:`Priority:`,noPrints:`No prints in this project yet`,status:{active:`Active`,completed:`Completed`,archived:`Archived`},priority:{low:`Low`,normal:`Normal`,high:`High`,urgent:`Urgent`},dueDate:{overdue:`Overdue`,today:`Due today`,daysLeft:`{{count}} days left`},progress:{platesProgress:`Plates Progress`,partsProgress:`Parts Progress`,printJobs:`print jobs`,parts:`parts`,percentComplete:`{{percent}}% complete`,remaining:`{{count}} remaining`},stats:{printJobs:`Print Jobs`,total:`total`,failed:`{{count}} failed`,partsPrinted:`{{count}} parts printed`,printTime:`Print Time`,filamentUsed:`Filament Used`},cost:{title:`Cost Tracking`,filamentCost:`Filament Cost`,energy:`Energy`,totalCost:`Total Cost`,total:`Total`,includesBom:`incl. BOM`,budget:`Budget`,remaining:`Remaining`},subProjects:{title:`Sub-projects ({{count}})`},notes:{title:`Notes`,noEditPermission:`You do not have permission to edit notes`,placeholder:`Add notes about this project...`,empty:`No notes yet. Click Edit to add notes.`},files:{title:`Files`,linkFolders:`Link folders from the File Manager`,forQuickAccess:`to this project for quick access.`,fileCount:`{{count}} file(s)`,empty:`No folders linked. Go to File Manager and link a folder to this project.`,noFiles:`No files in this folder.`,print:`Print Now`,addToQueue:`Add to Queue`},bom:{title:`Bill of Materials`,acquired:`{{completed}}/{{total}} acquired`,showAll:`Show all`,hideDone:`Hide done`,addPart:`Add Part`,noAddPermission:`You do not have permission to add parts`,partNamePlaceholder:`Part name (e.g., M3x8 screws)`,partName:`Part name`,qty:`Qty`,price:`Price ({{currency}})`,sourcingUrlPlaceholder:`Sourcing URL (optional)`,remarksPlaceholder:`Remarks (optional)`,deletePart:`Delete Part`,deleteConfirm:`Are you sure you want to delete "{{name}}"?`,noUpdatePermission:`You do not have permission to update parts`,noEditPermission:`You do not have permission to edit parts`,noDeletePermission:`You do not have permission to delete parts`,totalCost:`Total cost:`,empty:`No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced.`},timeline:{title:`Activity Timeline`,empty:`No activity yet.`},template:{saveAsTemplate:`Save as Template`,noCreatePermission:`You do not have permission to create templates`},queue:{title:`Queue`,viewAll:`View all`,printing:`{{count}} printing`,queued:`{{count}} queued`},prints:{title:`Prints ({{count}})`},toast:{projectUpdated:`Project updated`,partAdded:`Part added`,partRemoved:`Part removed`,exportFailed:`Export failed`,projectExported:`Project exported`,templateCreated:`Template created`}},system:{title:`System Information`,version:`Version`,uptime:`Uptime`,cpuUsage:`CPU Usage`,memoryUsage:`Memory Usage`,diskUsage:`Disk Usage`,networkInfo:`Network Info`,logs:`Logs`,debugMode:`Debug Mode`,enableDebug:`Enable Debug Logging`,disableDebug:`Disable Debug Logging`,downloadLogs:`Download Logs`,clearLogs:`Clear Logs`,dockerInfo:`Docker Info`,containerName:`Container Name`,imageName:`Image Name`,platform:`Platform`,architecture:`Architecture`},sponsors:{sectionTitle:`Independent & community-funded`,tagline:`Bambuddy is free and stays that way because people choose to support it. No VC, no cloud lock-in.`,viewSupporters:`View supporters`,toastPrints:`You've completed {{count}} prints with Bambuddy. Bambuddy stays free thanks to its supporters.`,toastCost:`You've tracked {{total}} in filament with Bambuddy. See who keeps the project independent.`,toastArchives:`{{count}} prints archived with Bambuddy. See who keeps it independent.`,toastAnniversary:`One year with Bambuddy! See who keeps the project independent.`,toastVersionUpdate:`Updated to v{{version}}. Bambuddy stays free thanks to its supporters.`},library:{title:`Filament Library`,addFilament:`Add Filament`,editFilament:`Edit Filament`,deleteFilament:`Delete Filament`,vendor:`Vendor`,material:`Material`,color:`Color`,kFactor:`K Factor`,temperature:`Temperature`,noFilaments:`No filaments in library`,deleteConfirm:`Are you sure you want to delete this filament?`,importFromPrinter:`Import from Printer`,exportToFile:`Export to File`},slice:{title:`Slice model`,action:`Slice`,actionAll:`Slice all {{count}} plates`,actionAllTitle:`Slice every plate into one multi-plate output (single archive). Filament selection covers every slot the project defines.`,allPlatesToggle:`Slice all {{count}} plates`,slicing:`Slicing…`,printer:`Printer profile`,process:`Process profile`,filament:`Filament profile`,filamentSlot:`Filament {{index}} ({{type}})`,selectPreset:`— Select a preset —`,loadingPresets:`Loading presets…`,analyzingPlateFilaments:`Analyzing plate filaments…`,analyzingPlateFilamentsHint:`Running a preview slice to discover which AMS slots this plate uses. Cached after — re-opening is instant.`,previewToast:`Analyzing {{name}} — {{elapsed}}`,previewWithProgress:`Analyzing {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,notUsedByPlate:`— not used by this plate`,noPresetsForSlot:`No presets available`,otherPrinters:`Other printers`,presetsLoadFailed:`Failed to load presets. Open Settings → Profiles to import them first.`,refreshPresets:`Refresh`,refreshPresetsTitle:`Refresh presets — fetch the latest cloud and bundled listings (use after deleting a preset in Bambu Studio or Bambu Handy)`,allPresetsRequired:`All presets must be selected`,enqueuing:`Submitting slice job…`,queued:`Queued…`,failed:`Slicing failed. Check the slicer sidecar logs.`,startedToast:`Slicing {{name}} in the background…`,queuedToast:`Queued: {{name}} — {{elapsed}}`,runningToast:`Slicing {{name}} — {{elapsed}}`,runningWithProgress:`{{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,runningWithProgressMultiPlate:`Plate {{plateIndex}} of {{plateCount}} • {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,completedToast:`Sliced {{name}}`,failedTitle:`Slicing failed`,failedToast:`Slicing {{name}} failed: {{detail}}`,tier:{local:`Imported`,cloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,standard:`Standard`},cloud:{notAuthenticated:`Sign in to Bambu Cloud (Settings → Profiles → Bambu Cloud) to see your cloud presets.`,expired:`Bambu Cloud session expired — sign in again to refresh your cloud presets.`,unreachable:`Bambu Cloud is unreachable right now. Local and standard presets still work.`},orcaCloud:{notAuthenticated:`Sign in to Orca Cloud (Profiles → Orca Cloud) to see your Orca presets.`,expired:`Orca Cloud session expired — sign in again to refresh your Orca presets.`,unreachable:`Orca Cloud is unreachable right now. Other presets still work.`},bedType:{label:`Build plate`,auto:`Auto (use process preset)`,coolPlate:`Cool Plate`,coolPlateSuperTack:`Cool Plate SuperTack`,engineering:`Engineering Plate`,highTemp:`High Temp Plate`,texturedPEI:`Textured PEI Plate`,smoothPEI:`Smooth PEI Plate`}},spoolman:{title:`Spoolman Integration`,enabled:`Spoolman Enabled`,url:`Spoolman URL`,connected:`Connected`,disconnected:`Not Connected`,testConnection:`Test Connection`,sync:`Sync`,syncing:`Syncing...`,lastSync:`Last Sync`,linkToSpoolman:`Link to Spoolman`,openInSpoolman:`Open in Spoolman`,unlinkSpool:`Unlink Spool`,unlinkConfirmTitle:`Unassign Spool?`,unlinkConfirmMessage:`This will remove the spool from this slot. The spool data itself will remain unchanged.`,selectSpool:`Select Spool`,noUnlinkedSpools:`No unassigned spools available`,linkSuccess:`Spool assigned successfully`,linkFailed:`Failed to assign spool`,unlinkSuccess:`Spool unassigned successfully`,unlinkFailed:`Failed to unassign spool`,linkedSpool:`Assigned spool`,spoolId:`Spool ID`,fillSourceLabel:`(Spoolman)`,weight:`Weight`,remaining:`Remaining`,disableWeightSync:`Disable AMS Estimated Weight Sync`,disableWeightSyncDesc:`Don't update remaining capacity from AMS estimates. Use this if you prefer Spoolman's usage tracking over AMS percentage-based estimates. New spools will still use the AMS estimate as their initial weight.`,reportPartialUsage:`Report Partial Usage for Failed Prints`,reportPartialUsageDesc:`When a print fails or is cancelled, report the estimated filament used up to that point based on layer progress.`},locations:{title:`Storage Locations`,subtitle:`Manage shelves, drawers, and other physical storage spots for your spools`,add:`Add Location`,addShort:`Add`,edit:`Edit Location`,name:`Name`,spools:`Spools`,empty:`No storage locations yet. Create your first shelf or drawer.`,manage:`Locations`,createPlaceholder:`e.g. Shelf A, Drawer 1`,nameRequired:`Location name is required`,created:`Location created`,updated:`Location updated`,deleted:`Location deleted`,saveFailed:`Failed to save location`,deleteFailed:`Failed to delete location`,deleteBlocked:`Remove all spools from this location before deleting`,confirmDelete:`Delete "{{name}}"?`,confirmDeleteMessage:`This location will be removed from the catalog. Spools must be moved first.`},inventory:{title:`Spool Inventory`,subtitle:`Manage your spools`,addToInventory:`Add to Inventory`,addToInventoryPending:`Adding...`,addToInventorySuccess:`Spool added to inventory`,addToInventoryFailed:`Failed to add spool to inventory`,unknownSpoolTitle:`New filament detected`,unknownSpoolMessage:`A spool with an unknown RFID tag was detected at {{location}}. Add it to your inventory now?`,unknownSpoolSlot:`Slot`,bulk:{selectAllVisible:`Select all visible`,selectRow:`Select row`,selectGroup:`Select group`,selectionCount:`{{count}} selected`,edit:`Edit`,printLabels:`Print labels`,resetUsage:`Reset usage`,restore:`Restore`,archive:`Archive`,delete:`Delete`,clearSelection:`Clear selection`,editTitle:`Bulk edit spools`,editSubtitle:`Applies to {{count}} selected spools. Only fields you tick get updated.`,editHint:`Type into a field to mark it for update — only ticked rows are sent. Leaving a field empty leaves the spools unchanged (clearing fields is per-spool only).`,useCustom:`Use "{{value}}"`,toggleField:`Toggle update for this field`,changeCount:`{{count}} fields will be updated.`,applyPending:`Applying...`,applyButton:`Apply to {{count}} spools`,deleteTitle:`Delete selected spools`,archiveTitle:`Archive selected spools`,restoreTitle:`Restore selected spools`,resetUsageTitle:`Reset usage on selected spools`,deleteMessage:`Permanently delete {{count}} spools? This cannot be undone.`,archiveMessage:`Archive {{count}} spools? They can be restored later.`,restoreMessage:`Restore {{count}} archived spools?`,resetUsageMessage:`Reset the "Total Consumed" counter on {{count}} spools? Remaining weight is preserved.`,updateSuccess:`{{count}} spools updated`,updateFailed:`Bulk update failed`,updatePartial:`{{ok}} spools updated, {{failed}} failed`,updateAllFailed:`All {{count}} spool updates failed — selection kept so you can retry`,deleteSuccess:`{{count}} spools deleted`,deleteFailed:`Bulk delete failed`,deletePartial:`{{ok}} spools deleted, {{failed}} failed`,deleteAllFailed:`All {{count}} spool deletions failed — selection kept so you can retry`,archiveSuccess:`{{count}} spools archived`,archiveFailed:`Bulk archive failed`,archivePartial:`{{ok}} spools archived, {{failed}} failed`,archiveAllFailed:`All {{count}} spool archives failed — selection kept so you can retry`,restoreSuccess:`{{count}} spools restored`,restoreFailed:`Bulk restore failed`,restorePartial:`{{ok}} spools restored, {{failed}} failed`,restoreAllFailed:`All {{count}} spool restores failed — selection kept so you can retry`,invalidHex:`Enter 6 hex characters (RRGGBB) or 8 (RRGGBBAA). The field will not be applied otherwise.`},spoolmanMixedContentTitle:`Spoolman can't load over HTTPS — mixed-content blocked by your browser`,spoolmanMixedContentBody:`Bambuddy is served over HTTPS (via your reverse proxy), but your Spoolman URL is still plain HTTP. Browsers block mixed content for security, so the embedded Spoolman UI can't render. Spoolman needs to be reachable over HTTPS for this to work.`,spoolmanMixedContentFixReverseProxy:`Put Spoolman behind the same reverse proxy as Bambuddy (Traefik / Nginx / Caddy) with HTTPS, then update the Spoolman URL in Settings to the new HTTPS address.`,spoolmanMixedContentFixOpenNewTab:`As a workaround, open Spoolman in a new browser tab over HTTP — mixed-content rules only apply to embedded frames, so a standalone tab still works.`,spoolmanOpenInNewTab:`Open Spoolman in a new tab`,labels:{title:`Print spool labels`,selectedCount:`{{count}} selected`,pickSpools:`Pick which spools to print labels for:`,searchPlaceholder:`Search name, brand, or #ID`,filterByMaterial:`Material:`,allMaterials:`All`,selectVisible:`Select all visible ({{count}})`,deselectVisible:`Deselect visible`,clearAll:`Clear all`,noSpoolsToShow:`No spools to show. Adjust your filter and try again.`,noMatches:`No spools match the current search or filter.`,printOne:`Print label for this spool`,printLabels:`Print labels…`,bulkTitle:`Pick spools to print labels for from the {{count}} currently shown`,noSpoolsTitle:`No spools to label`,error:`Could not generate labels: {{msg}}`,sortBy:{label:`Sort:`,id:`By ID`,color:`By colour`},templates:{amsHolderSmall:{label:`AMS holder — small (74 × 33 mm)`,hint:`Single label per page; matches the printable label from MakerWorld model 752566 (AMS Filament Label Holder).`},amsHolderLarge:{label:`AMS holder — large (75 × 55 mm)`,hint:`Single label per page; fits the cardstock-insert variant of the AMS Filament Label Holder. Roomy enough for swatch, brand, material, ID, and QR code.`},box40x30:{label:`Box label (40 × 30 mm)`,hint:`Single label per page; common DK/Brother roll size, good for filament-bag and storage-bin labels.`},box:{label:`Box label (62 × 29 mm)`,hint:`Single label per page; sized for Brother PT/QL and Dymo small labels.`},averyL7160:{label:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,hint:`EU sheet stock; 21 labels per A4 page.`},avery5160:{label:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,hint:`US sheet stock; 30 labels per Letter page.`}}},csv:{importButton:`Import CSV`,exportButton:`Export CSV`,modalTitle:`Import spools from CSV`,selectFile:`Choose a CSV file or drag it here`,dragHint:`Header: material (required), brand, subtype, color_name, rgba, …`,parsing:`Reading file…`,previewError:`Could not read the CSV file`,validCount:`{{count}} valid`,errorCount:`{{count}} error`,skippedCount:`{{count}} skipped`,colRow:`Row`,colStatus:`Status`,colColor:`Color`,colorResolved:`Color filled from catalog`,colorCrossMaterial:`Color taken from a different material — no exact match in catalog`,duplicateExisting:`A spool with this material, brand and color already exists — it will still be imported as a new spool`,spoolmanHint:`In Spoolman mode, use Spoolman's built-in CSV import/export.`,importValidRows:`Import {{count}} valid rows`,noValidRows:`No valid rows`,importing:`Importing…`,importSuccess:`{{count}} spools imported`,importError:`Import failed`,exportError:`Export failed`},addSpool:`Add Spool`,editSpool:`Edit Spool`,copySpool:`Copy Spool`,material:`Material`,selectMaterial:`Select material...`,subtype:`Subtype`,brand:`Brand`,searchBrand:`Search brand...`,useCustomBrand:`Use "{{brand}}"`,useCustomMaterial:`Use custom material: {{material}}`,colorName:`Color Name`,colorNamePlaceholder:`Jade White, Fire Red...`,color:`Color`,hexColor:`Hex Color`,pickColor:`Pick custom color`,labelWeight:`Label Weight`,coreWeight:`Empty Spool Weight`,searchSpoolWeight:`Search spool weight...`,weightUsed:`Used`,currentWeight:`Remaining Weight`,measuredWeight:`Measured Weight`,spoolName:`Spool`,costPerKg:`Cost per kg`,storageLocation:`Storage Location`,storageLocationPlaceholder:`e.g. Shelf A, Drawer 1`,openInInventory:`Open in Inventory`,measuredWeightError:`Measured weight must be between {{min}}g and {{max}}g.`,slicerFilament:`Slicer Filament`,slicerFilamentName:`Slicer Preset Name`,slicerPreset:`Slicer Preset`,searchPresets:`Search filament presets...`,selectedPreset:`Selected`,noPresetsFound:`No presets found`,tempOverrides:`Temperature Overrides`,note:`Note`,notePlaceholder:`Any additional notes about this spool...`,category:`Category`,categoryPlaceholder:`e.g. Production, Prototype, Client A`,categoryNone:`Uncategorized`,storageLocationNone:`No location set`,lowStockThresholdOverride:`Low-stock threshold (this spool)`,lowStockThresholdOverrideHelp:`Leave blank to use the global threshold ({{global}}%).`,clearRfid:`Clear RFID Tag`,rfidCleared:`RFID tag cleared`,archive:`Archive`,restore:`Restore`,noSpools:`No spools yet. Add your first spool to get started.`,noAvailableSpools:`No spools available. Add a spool to your inventory or unassign one from another slot first.`,kProfiles:`K-Profiles`,addKProfile:`Add K-Profile`,assignSpool:`Assign Spool`,unassignSpool:`Unassign`,assignSuccess:`Spool assigned and AMS slot configured`,assignPendingInsert:`Assigned. Slot will configure when you insert the spool.`,assignFailed:`Failed to assign spool`,selectSpool:`Select a spool to assign to this slot`,assigned:`Assigned`,assigning:`Assigning...`,searchSpools:`Search spools...`,showAllSpools:`Show all spools`,spoolmanSpools:`Spoolman Spools`,allMaterials:`All Materials`,filterByBrand:`Filter by brand...`,showArchived:`Show archived`,quickAdd:`Quick Add (Stock)`,quantity:`Quantity`,stock:`Stock`,configured:`Configured`,spoolsCreated:`{{count}} spools created`,spoolsPartiallyCreated:`{{created}} of {{total}} spools created (some failed)`,spoolCreated:`Spool created`,spoolUpdated:`Spool updated`,spoolDeleted:`Spool deleted`,deepLinkSpoolNotFound:`Spool not found`,deepLinkFetchFailed:`Could not load spool — try again`,spoolArchived:`Spool archived`,spoolRestored:`Spool restored`,kProfileSaveFailed:`K-profile settings could not be saved`,syncWeightSpoolNotFound:`Spool not found — it may have been deleted`,syncWeightSpoolmanUnreachable:`Spoolman is unreachable — try again later`,syncWeightFailed:`Failed to sync weight`,spoolmanUnreachable:`Spoolman is not reachable — please try again later`,deleteSpoolNotFound:`Spool not found — it may have already been deleted`,deleteFailed:`Failed to delete spool`,archiveSpoolNotFound:`Spool not found — it may have already been deleted`,archiveFailed:`Failed to archive spool`,restoreSpoolNotFound:`Spool not found — it may have already been deleted`,restoreFailed:`Failed to restore spool`,saveFailed:`Failed to save changes`,tagClearFailed:`Failed to clear tag`,deleteConfirm:`Are you sure you want to delete this spool? This cannot be undone.`,archiveConfirm:`Are you sure you want to archive this spool?`,advancedSettings:`Advanced Settings`,filamentInfoTab:`Filament Info`,paProfileTab:`PA Profile`,filamentInfo:`Filament`,additional:`Additional`,loadingPresets:`Loading cloud presets...`,cloudConnected:`Cloud connected`,cloudNotConnected:`Cloud not connected (using defaults)`,recentColors:`Recent`,searchColors:`Search colors...`,searchResults:`Search results`,allColors:`All colors`,commonColors:`Common colors`,showLess:`Show less`,showAll:`Show all`,noColorsFound:`No colors match your search`,noResults:`No matches found`,extraColorsLabel:`Extra colors`,extraColorsPlaceholder:`EC984C,#6CD4BC,A66EB9,D87694`,extraColorsHint:`Paste 2 to 8 hex stops, separated by commas. Renders as a gradient.`,extraColorsInvalid:`Ignored invalid hex: {{tokens}}`,colorEffectLabel:`Effect`,colorEffect:{none:`None`,sparkle:`Sparkle`,wood:`Wood`,marble:`Marble`,glow:`Glow`,matte:`Matte`,silk:`Silk`,galaxy:`Galaxy`,rainbow:`Rainbow`,metal:`Metal`,translucent:`Translucent`,gradient:`Gradient`,dualColor:`Dual Color`,triColor:`Tri Color`,multicolor:`Multicolor`},selectMaterialFirst:`Please select a material first in the Filament Info tab.`,noPrintersConfigured:`No printers configured. Add printers to use PA profiles.`,matchingFilter:`Matching`,anyBrand:`Any brand`,anyVariant:`Any variant`,autoSelect:`Auto-select`,matches:`matches`,match:`match`,noMatches:`No matches`,connected:`Connected`,offline:`Offline`,printerOffline:`Printer is offline. Connect to view calibration profiles.`,noKProfilesMatch:`No K-profiles match the selected filament.`,leftNozzle:`Left Nozzle`,rightNozzle:`Right Nozzle`,profilesSelected:`calibration profile(s) selected`,totalInventory:`Total Inventory`,totalConsumed:`Total Consumed`,byMaterial:`By Material`,inPrinter:`In Printer`,lowStock:`Low Stock`,sinceTracking:`Since tracking started`,resetConsumedCounter:`Reset counter`,resetConsumedCounterTooltip:`Zero the consumed-grams counter for this spool. Remaining weight is not changed.`,resetConsumedCounterConfirm:`Reset this spool's consumed-grams counter to 0? Future prints will track from zero again. The spool itself, its remaining weight calculation, and your settings are not changed.`,resetAllConsumedCounters:`Reset all counters`,resetAllConsumedCountersTooltip:`Zero the consumed-grams counter on every spool. Remaining weights are not changed.`,resetAllConsumedCountersConfirm:`Reset the consumed-grams counter to 0 on all {{count}} spools (archived ones included)? This clears the "Total Consumed" stat so future prints track from zero. Spools and remaining weights are not changed.`,consumedCounterReset:`Counter reset`,allConsumedCountersReset:`Counter reset for {{count}} spool(s)`,resetConsumedCounterFailed:`Failed to reset counter`,loadedInAms:`Loaded in AMS/Ext`,remaining:`Remaining`,weightCheck:`Weight Check`,lastWeighed:`Last weighed`,neverWeighed:`Never weighed`,search:`Search spools...`,showing:`Showing`,to:`to`,of:`of`,show:`Show`,spools:`spools`,spool:`spool`,page:`Page`,noSpoolsMatch:`No results found`,noSpoolsMatchDesc:`Try adjusting your search or filters to find what you're looking for.`,active:`Active`,archived:`Archived`,all:`All`,used:`Used`,new:`New`,clearFilters:`Clear filters`,table:`Table`,cards:`Cards`,net:`Net`,groupSimilar:`Group`,groupedSpools:`{{count}} identical spools`,groupedRows:`rows`,columns:`Columns`,configureColumns:`Configure Columns`,configureColumnsDesc:`Drag to reorder columns or use arrows. Toggle visibility with the eye icon.`,visible:`visible`,reset:`Reset`,cancel:`Cancel`,applyChanges:`Apply Changes`,moveUp:`Move up`,moveDown:`Move down`,hideColumn:`Hide column`,showColumn:`Show column`,linkToSpool:`Link to Spool`,tagLinked:`Tag linked to spool`,tagLinkFailed:`Failed to link tag`,tagAlreadyLinked:`Tag already linked to another spool`,unknownTag:`Unknown RFID tag detected`,usageHistory:`Usage History`,noUsageHistory:`No usage recorded yet`,printName:`Print Name`,weightConsumed:`Weight Consumed`,clearHistory:`Clear`,historyCleared:`Usage history cleared`,fillSourceLabel:`(Inv)`,lowStockThresholdError:`Threshold must be between 0.1 and 99.9`,assignMismatchTitle:`Material mismatch`,assignMismatchMessage:`The selected spool material "{{spoolMaterial}}" does not match the tray material "{{trayMaterial}}" for {{location}}. Assign anyway?`,assignMismatchConfirm:`Assign Anyway`,assignPartialMismatchMessage:`The spool material "{{spoolMaterial}}" is similar to but not exactly matching "{{trayMaterial}}" in {{location}}. Do you want to proceed?`,assignProfileMismatchMessage:`The spool profile "{{spoolProfile}}" does not match the tray profile "{{trayProfile}}" in {{location}}. Do you want to proceed?`,assignReconfigureNote:`The AMS slot will be reconfigured to use the spool's profile.`,spoolmanFilamentCatalog:`Spoolman Filament Catalog`,pickFromSpoolmanCatalog:`Pick from Spoolman catalog…`,spoolmanFilamentSelected:`Filament selected from Spoolman catalog`,spoolmanFilamentUnlinked:`Filament catalog link cleared`,noSpoolmanFilaments:`No filaments found in Spoolman catalog`,spoolmanFilamentColorSwatch:`Filament color`,spoolWeightManagedBySpoolman:`Empty spool weight is managed per filament type in Spoolman`,spoolmanCatalogLoadFailed:`Failed to load Spoolman filament catalog`},timelapse:{title:`Timelapse`,create:`Create Timelapse`,download:`Download`,delete:`Delete`,preview:`Preview`,frameRate:`Frame Rate`,quality:`Quality`,processing:`Processing...`,noTimelapses:`No timelapses available`},ams:{title:`AMS`,slot:`Slot`,empty:`Empty`,emptySlot:`Empty slot`,slotEmpty:`Empty`,slotUnconfigured:`?`,emptySlotReset:`No filament assigned`,unknown:`Unknown`,humidity:`Humidity`,temperature:`Temperature`,filamentType:`Filament Type`,filamentColor:`Color`,remaining:`Remaining`,history:`AMS History`,noHistory:`No history available`,configureSlot:`Configure Slot`,externalSpool:`External Spool`,profile:`Profile`,kFactor:`K Factor`,fill:`Fill`,configure:`Configure`,used:`used`,remainingUnit:`remaining`},printModal:{title:`Start Print`,selectPrinter:`Select Printer`,selectPlate:`Select Plate`,filamentMapping:`Filament Mapping`,totalCost:`Total cost:`,slotRemainingShort:` - {{grams}}g left`,printSettings:`Print Settings`,bedLeveling:`Bed Leveling`,flowCalibration:`Flow Calibration`,vibrationCalibration:`Vibration Calibration`,layerInspection:`First Layer Inspection`,timelapse:`Timelapse`,startPrint:`Start Print`,addToQueue:`Add to Queue`,cancel:`Cancel`,noPrintersAvailable:`No printers available`,printerBusy:`Printer is busy`,printerOffline:`Printer is offline`,sameTypeDifferentColor:`Same type, different color`,filamentTypeNotLoaded:`Filament type not loaded`,openCalendar:`Open calendar`,leftNozzle:`L`,rightNozzle:`R`,leftNozzleTooltip:`Left nozzle`,rightNozzleTooltip:`Right nozzle`,filamentOverride:`Filament Override`,filamentOverrideHint:`Optionally override filaments for model-based assignment. The scheduler will match against your selected filaments instead of the original 3MF values.`,originalFilament:`Original`,overrideWith:`Override with`,resetToOriginal:`Reset to original`,insufficientFilamentTitle:`Not enough filament`,insufficientFilamentMessage:`Some assigned spools have less filament remaining than this print needs:`,insufficientFilamentLine:`{{printer}} - {{slot}}: needs {{required}}g, remaining {{remaining}}g`,printAnyway:`Print anyway`,forceColorMatch:`Force color match`,staggerPrinterStarts:`Stagger printer starts`,staggerGroupSize:`Group size`,staggerInterval:`Interval (min)`,staggerPreview:`{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min`,staggerLastGroup:`last group: {{count}}`,staggerTotal:`total: {{minutes}} min`,staggerToPrinters:`Stagger to {{count}} printers`,gcodeInjection:`Inject auto-print G-code`},backup:{includesEncryptionKey:`Local backups include the MFA encryption key file (DATA_DIR/.mfa_encryption_key) so a backup ZIP is self-contained. Treat the ZIP as sensitive — anyone with the file can decrypt the OIDC client secrets and TOTP secrets stored inside.`,title:`Backup & Restore`,createBackup:`Create Backup`,restoreBackup:`Restore Backup`,restoreDescription:`Replace all data from a backup file`,downloadBackup:`Download Backup`,uploadBackup:`Upload Backup`,lastBackup:`Last Backup`,autoBackup:`Auto Backup`,backupNow:`Backup Now`,restoreWarning:`Warning: Restoring a backup will overwrite all current data.`,includeArchives:`Include Archives`,includeSettings:`Include Settings`,includeProfiles:`Include Profiles`,backupSuccess:`Backup created successfully`,restoreSuccess:`Backup restored successfully`,backupFailed:`Backup failed`,restoreFailed:`Restore failed`,restoreNote:`Virtual Printer will be stopped during restore`,githubBackup:`Git Backup`,enabled:`Enabled`,cloudLoginRequired:`Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup.`,cloudLoginRequiredShort:`Cloud login required`,githubDescription:`Automatically sync your profiles to a private GitHub repository for backup and version history.`,repoIsPrivate:`Repository is private — safe to back up to.`,repoIsPublicWarning:`Repository is PUBLIC. Bambuddy backups include MQTT credentials, Home Assistant tokens, Prometheus tokens, your Bambu Cloud email, and printer access codes via K-profiles. Saving is blocked until you make the repository private in your provider's settings.`,repoVisibilityUnknown:`Could not determine repository visibility. Bambuddy refuses to back up to anything not confirmed private; saving will be blocked.`,repositoryUrl:`Repository URL`,repoUrlPlaceholderGitHub:`https://github.com/username/repo-name`,repoUrlPlaceholderGitea:`https://gitea.example.com/username/repo-name`,repoUrlPlaceholderForgejo:`https://forgejo.example.com/username/repo-name`,repoUrlPlaceholderGitLab:`https://gitlab.com/username/repo-name`,allowInsecureHttp:`Allow insecure HTTP`,allowInsecureHttpHint:`Enable for self-hosted instances on private networks without TLS`,personalAccessToken:`Personal Access Token`,tokenSaved:`(saved)`,enterNewToken:`Enter new token to update`,tokenHint:`Fine-grained token with Contents read/write permission`,branch:`Branch`,provider:`Git Provider`,providerGitHub:`GitHub`,providerGitLab:`GitLab`,providerGitea:`Gitea`,providerForgejo:`Forgejo`,manualOnly:`Manual only`,hourly:`Hourly`,daily:`Daily`,weekly:`Weekly`,includeInBackup:`Include in backup`,kProfiles:`K-Profiles`,kProfilesDescription:`Pressure advance calibration from connected printers`,noPrintersConnected:`No printers connected`,printersConnected:`{{connected}}/{{total}} connected`,cloudProfiles:`Cloud Profiles`,cloudProfilesDescription:`Filament, printer, and process presets from Bambu Cloud`,appSettings:`App Settings`,appSettingsDescription:`Bambuddy configuration (complete database)`,spoolInventory:`Spool Inventory`,spoolInventoryDescription:`Filament spools, usage history, and cost tracking`,printArchives:`Print Archives`,printArchivesDescription:`Print history metadata (no gcode/3MF files)`,lastBackupAt:`Last backup:`,noBackupsYet:`No backups yet`,next:`Next:`,startingBackup:`Starting backup...`,test:`Test`,enableBackup:`Enable Backup`,testConnection:`Test Connection`,enterRepoUrl:`Enter repository URL`,enterRepoAndToken:`Enter repository URL and access token`,repoRequired:`Repository URL is required`,tokenRequired:`Access token is required`,githubBackupEnabled:`GitHub backup enabled`,tokenUpdated:`Token updated`,settingsSaved:`Settings saved`,failedToSave:`Failed to save: {{message}}`,backupCompleteFiles:`Backup complete - {{count}} files updated`,backupSkippedNoChanges:`Backup skipped - no changes`,backupFailed2:`Backup failed: {{message}}`,clearedLogs:`Cleared {{count}} logs`,failedToClearLogs:`Failed to clear logs: {{message}}`,history:`History`,clear:`Clear`,date:`Date`,status:`Status`,commit:`Commit`,localBackup:`Local Backup`,localBackupDescription:`Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files.`,downloadBackupLabel:`Download Backup`,completeBackupZip:`Complete backup: database + all files (ZIP)`,download:`Download`,preparingBackup:`Preparing backup...`,creatingArchive:`Creating backup archive... This may take a while for large archives.`,downloadingFile:`Downloading backup file...`,backupDownloaded:`Backup downloaded successfully`,failedToCreateBackup:`Failed to create backup: {{message}}`,restore:`Restore`,restoreReplacesAll:`Restore replaces all data.`,restoreReplacesAllDetail:`Your current database and files will be completely replaced. A restart is required after restore.`,restoreConfirmTitle:`Restore Backup`,restoreConfirmMessage:`Are you sure you want to restore from "{{filename}}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,restoreConfirmButton:`Restore Backup`,uploadingFile:`Uploading backup file...`,backupRestoredRestart:`Backup restored. Please restart Bambuddy.`,failedToRestore:`Failed to restore backup. Please check the file format.`,reloadNow:`Reload Now`,creatingBackup:`Creating Backup`,restoringBackup:`Restoring Backup`,preparing:`Preparing...`,processing:`Processing...`,doNotClosePage:`Please do not close this page or navigate away. This operation may take several minutes for large backups.`,restoring:`Restoring...`,restoreComplete:`Restore Complete`,restoreFailed2:`Restore Failed`,importSettings:`Import settings from a backup file`,pleaseWaitRestoring:`Please wait while your data is being restored`,selectBackupFile:`Click to select backup file (.json or .zip)`,duplicateHandling:`How duplicate handling works:`,matchPrinters:`Printers`,matchPrintersBy:`matched by serial number`,matchSmartPlugs:`Smart Plugs`,matchSmartPlugsBy:`matched by IP address`,matchNotificationProviders:`Notification Providers`,matchNotificationProvidersBy:`matched by name`,matchFilaments:`Filaments`,matchFilamentsBy:`matched by name + type + brand`,matchArchives:`Archives`,matchArchivesBy:`matched by content hash (always skipped)`,matchPendingUploads:`Pending Uploads`,matchPendingUploadsBy:`matched by filename`,matchSettingsTemplates:`Settings & Templates`,matchSettingsTemplatesBy:`always overwritten`,replaceExisting:`Replace existing data`,keepExisting:`Keep existing data`,overwriteDescription:`Overwrite items that already exist with backup data`,keepDescription:`Only restore items that don't already exist`,overwriteCaution:`Caution:`,overwriteWarning:`Overwriting will replace your current configurations with data from the backup. Printer access codes are never overwritten for security.`,cancel:`Cancel`,processingBackup:`Processing backup file...`,itemsRestored:`Items Restored`,itemsSkipped:`Items Skipped`,restored:`Restored`,skippedAlreadyExist:`Skipped (already exist)`,filesCategory:`Files (3MF, thumbnails, etc.)`,andMore:`...and {{count}} more`,newApiKeysGenerated:`New API Keys Generated`,keysShownOnce:`These keys are only shown once. Copy them now!`,copy:`Copy`,noDataFound:`No data was found to restore in the backup file.`,close:`Close`,scheduledBackup:`Scheduled Backups`,scheduledBackupDescription:`Automatically create backup snapshots on a schedule. Output directory can be mounted to a NAS or external storage.`,frequency:`Frequency`,backupTime:`Time`,retention:`Retention`,retentionDescription:`Number of backups to keep`,outputPath:`Output Path`,outputPathPlaceholder:`Default: {{path}}`,outputPathDescription:`Leave empty for default location`,runNow:`Run Now`,backupFiles:`Backup Files`,noScheduledBackups:`No backups yet`,deleteBackup:`Delete`,deleteBackupConfirm:`Delete this backup file?`,backupRunning:`Backup in progress...`,scheduledBackupComplete:`Backup completed successfully`,scheduledBackupFailed:`Backup failed`,nextBackup:`Next backup`,backupSize:`Size`,localTimeHint:`Local time ({{tz}})`,defaultPathLabel:`Default:`,categories:{settings:`Settings`,notification_providers:`Notification Providers`,notification_templates:`Notification Templates`,smart_plugs:`Smart Plugs`,printers:`Printers`,filaments:`Filaments`,maintenance_types:`Maintenance Types`,archives:`Archives`,projects:`Projects`,pending_uploads:`Pending Uploads`,external_links:`External Links`,api_keys:`API Keys`}},tags:{title:`Tags`,addTag:`Add Tag`,editTag:`Edit Tag`,deleteTag:`Delete Tag`,tagName:`Tag Name`,tagColor:`Tag Color`,noTags:`No tags`,deleteConfirm:`Are you sure you want to delete this tag?`,manageTags:`Manage Tags`},uploadModal:{title:`Upload 3MF Files`,dragDrop:`Drag & drop .3mf files here`,or:`or`,browseFiles:`Browse Files`,extractionInfo:`The printer model will be automatically extracted from the 3MF file metadata.`,uploaded:`uploaded`,failed:`failed`,uploading:`Uploading...`,upload:`Upload`,uploadFailed:`Upload failed`},editArchive:{title:`Edit Archive`,name:`Name`,namePlaceholder:`Print name`,printer:`Printer`,noPrinter:`No printer`,project:`Project`,noProject:`No project`,itemsPrinted:`Items Printed`,itemsPrintedHelp:`Number of items produced in this print job`,notes:`Notes`,notesPlaceholder:`Add notes about this print...`,externalLink:`External Link`,externalLinkPlaceholder:`https://printables.com/model/...`,externalLinkHelp:`Link to Printables, Thingiverse, or other source`,tags:`Tags`,tagsPlaceholder:`Add tags...`,addMoreTags:`Add more tags...`,matchingTags:`Matching "{{query}}"`,existingTags:`Existing tags`,clickToAdd:`(click to add)`,status:`Status`,failureReason:`Failure Reason`,selectReason:`Select reason...`,photos:`Photos of Printed Result`,photosHelp:`Click + to add photos of your printed result`,printResult:`Print result`,saving:`Saving...`,failureReasons:{adhesionFailure:`Adhesion failure`,spaghettiDetached:`Spaghetti / Detached`,layerShift:`Layer shift`,cloggedNozzle:`Clogged nozzle`,filamentRunout:`Filament runout`,warping:`Warping`,stringing:`Stringing`,underExtrusion:`Under-extrusion`,powerFailure:`Power failure`,userCancelled:`User cancelled`,other:`Other`},statuses:{completed:`Completed`,failed:`Failed`,aborted:`Cancelled`,printing:`Printing`}},kProfiles:{title:`K-Profiles`,noPrintersConfigured:`No Printers Configured`,addPrinterInSettings:`Add a printer in Settings to manage K-profiles`,noActivePrinters:`No Active Printers`,enablePrinterConnection:`Enable a printer connection to view its K-profiles`,loadingProfiles:`Loading K-Profiles...`,printerOffline:`Printer Offline`,printerOfflineDesc:`The selected printer is not connected. Power it on to view K-profiles.`,noMatchingProfiles:`No Matching Profiles`,noMatchingProfilesDesc:`No profiles match your search criteria`,noKProfiles:`No K-Profiles`,noKProfilesDesc:`No pressure advance profiles found for {{diameter}}mm nozzle`,createFirstProfile:`Create First Profile`,printer:`Printer`,nozzle:`Nozzle`,refresh:`Refresh`,addProfile:`Add Profile`,export:`Export`,import:`Import`,select:`Select`,selectAll:`Select All`,delete:`Delete`,searchPlaceholder:`Search by name or filament...`,allExtruders:`All Extruders`,leftOnly:`Left Only`,rightOnly:`Right Only`,allFlow:`All Flow`,hfOnly:`HF Only`,sOnly:`S Only`,sortName:`Sort: Name`,sortKValue:`Sort: K-Value`,sortFilament:`Sort: Filament`,leftExtruder:`Left Extruder`,rightExtruder:`Right Extruder`,modal:{addTitle:`Add K-Profile`,editTitle:`Edit K-Profile`,profileName:`Profile Name`,profileNamePlaceholder:`My PLA Profile`,kValue:`K-Value`,kValuePlaceholder:`0.020`,kValueHelp:`Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG`,filament:`Filament`,selectFilament:`Select filament...`,noFilamentsHelp:`No filaments found. Create a K-profile in Bambu Studio first.`,flowType:`Flow Type`,highFlow:`High Flow`,standard:`Standard`,nozzleSize:`Nozzle Size`,extruder:`Extruder`,extruders:`Extruders`,left:`Left`,right:`Right`,notes:`Notes (stored locally)`,notesPlaceholder:`Add notes about this profile...`,notesHelp:`Notes are saved in Bambuddy, not on the printer`,syncing:`Syncing with printer...`,savingExtruder:`Saving to extruder {{current}}/{{total}}...`,pleaseWait:`Please wait`},deleteConfirm:{title:`Delete Profile`,cannotUndo:`This cannot be undone`,message:`Are you sure you want to delete "{{name}}" from the printer?`},bulkDelete:{title:`Delete Profiles`,cannotUndo:`This cannot be undone`,message:`Are you sure you want to delete {{count}} selected profiles from the printer?`},toast:{profileSaved:`K-profile saved`,profilesSaved:`K-profile saved to {{count}} extruders`,selectAtLeastOneExtruder:`Please select at least one extruder`,profileDeleted:`K-profile deleted`,profilesDeleted:`Deleted {{count}} profiles`,exportedProfiles:`Exported {{count}} profiles`,importedProfiles:`Imported {{count}} of {{total}} profiles`,noProfilesToExport:`No profiles to export`,invalidFileFormat:`Invalid file format`,failedToParseImport:`Failed to parse import file`,failedToSaveBatch:`Failed to save K-profiles`,noteSaved:`Note saved`,failedToSaveNote:`Failed to save note`},permission:{noRead:`You do not have permission to refresh profiles`,noCreate:`You do not have permission to add profiles`,noUpdate:`You do not have permission to update K-profiles`,noDelete:`You do not have permission to delete K-profiles`,noExport:`You do not have permission to export profiles`,noImport:`You do not have permission to import profiles`}},virtualPrinter:{title:`Virtual Printer`,running:`Running`,stopped:`Stopped`,description:{default:`Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing.`,proxy:`Enable a proxy that relays slicer traffic to a real printer, allowing remote printing over any network.`},enable:{title:`Enable Virtual Printer`,visibleInSlicer:`Visible as "Bambuddy" in slicer discovery`,proxyingTo:`Proxying to {{name}}`,notActive:`Not active`},model:{title:`Printer Model`,description:`Select which printer model to emulate.`,restartWarning:`Changing the model will restart the virtual printer`},accessCode:{title:`Access Code`,isSet:`Access code is set`,notSet:`No access code set - required to enable`,placeholder:`Enter 8-char code`,placeholderChange:`Enter new code to change`,hint:`Must be exactly 8 characters. Used by slicers to authenticate.`,charCount:`({{count}}/8)`,inheritedFromTarget:`Inherited from target`,derivedFromTargetHint:`Uses the target printer's access code. The bridge forwards slicer auth to the real printer, so the codes must match — edit the printer's access code to change this value.`,reveal:`Show access code`,hide:`Hide access code`},targetPrinter:{title:`Target Printer`,configured:`Proxy target configured`,notConfigured:`No target printer selected - required for proxy mode`,placeholder:`Select a printer...`,hint:`Select the printer to proxy slicer traffic to. The printer must be in LAN mode.`,noPrinters:`No printers configured. Add a printer first to use proxy mode.`},remoteInterface:{title:`Network Interface Override`,configured:`Interface override active`,optional:`Optional - use if auto-detected IP is wrong (e.g. multiple NICs, Docker, VPN)`,placeholder:`Auto-detect (default)...`,hint:`Override the IP address advertised via SSDP and used in the TLS certificate. Useful when Bambuddy has multiple network interfaces.`},mode:{title:`Mode`,archive:`Archive`,archiveDesc:`Archive files immediately`,review:`Review`,reviewDesc:`Review before archiving`,queue:`Queue`,queueDesc:`Archive and add to queue`,proxy:`Proxy`,proxyDesc:`Relay to real printer`},autoDispatch:{title:`Auto-dispatch`,description:`Automatically start prints when added to queue. When off, prints wait for manual dispatch.`},queueForceColorMatch:{title:`Force color match`,description:`Refuse to dispatch onto a printer that does not have the exact filament type and color loaded. Off by default — without this, the queue uses model-only matching and may pick a printer with the wrong color loaded.`},gcodeInjection:{title:`G-code injection`,description:`Apply the per-model G-code snippets configured in Settings to jobs from this VP. Off by default.`},tailscaleDisabled:{title:`Tailscale integration`,description:`Enable to mark this VP as exposed over Tailscale. Shows the host's Tailscale address so you know which IP to paste into the slicer. The CA-import step is unchanged — this toggle has no effect on certificates.`},setupRequired:{title:`Setup Required`,description:`The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings.`,readGuide:`Read the setup guide before enabling`},archiveNameSource:{title:`Archive name source`,description:`Choose how new archives are named when files arrive via the virtual printer. "Metadata" uses the slicer-embedded Title from the 3MF (default). "Filename" uses the filename Bambu Studio sent over FTP. Note: Bambu Studio overwrites the name you type in the "send to printer" dialog with the 3MF's Title field whenever one is present, so both modes often produce the same string.`,metadata:`Metadata`,filename:`Filename`},caCert:{title:`Slicer certificate`,description:`Virtual printers use a TLS certificate signed by the Bambuddy CA. Import this CA certificate into your slicer's trust store once so it accepts the connection — no need to copy it from the command line.`,copy:`Copy`,copied:`Copied`,download:`Download`,fingerprint:`SHA-256`},howItWorks:{title:`How it works`,step1:`On the same LAN, virtual printers appear in your slicer (Bambu Studio / OrcaSlicer) automatically via discovery. From other networks, add them manually by IP address and access code.`,step2:`In Archive, Review, and Queue modes, use the "Send" button in your slicer to upload 3MF files to Bambuddy. The slicer will show "Print success" — the file is stored, not printed.`,step3:`In Proxy mode, the virtual printer relays all traffic to a real printer — prints start immediately as if connected directly.`},status:{title:`Status Details`,printerName:`Printer Name`,model:`Model`,serialNumber:`Serial Number`,mode:`Mode`,pendingFiles:`Pending Files`,targetPrinter:`Target Printer`,ftpPort:`FTP Port`,mqttPort:`MQTT Port`,ftpConnections:`FTP Connections`,mqttConnections:`MQTT Connections`},toast:{updated:`Virtual printer settings updated`,failedToUpdate:`Failed to update settings`,copyFailed:`Failed to copy — try selecting the text manually`,accessCodeRequired:`Please set an access code first`,targetPrinterRequired:`Please select a target printer first`,bindIpRequired:`Please set a bind IP first`,accessCodeEmpty:`Access code cannot be empty`,accessCodeLength:`Access code must be exactly 8 characters`,targetCodeChangedRebind:`Access code now matches the new target printer. Re-add this device in your slicer to pick up the new code.`,created:`Virtual printer created`,failedToCreate:`Failed to create virtual printer`,deleted:`Virtual printer deleted`,failedToDelete:`Failed to delete virtual printer`},list:{title:`Virtual Printers`,add:`Add`,addFirst:`Add Virtual Printer`,empty:`No virtual printers configured. Add one to get started.`},bindIp:{title:`Bind Interface`,placeholder:`Select interface...`,hint:`Network interface for this virtual printer to bind to. Must be unique per printer.`},proxy:{accessCodeHint:`In proxy mode, use your target printer's access code in the slicer. The connection is forwarded transparently to the real printer.`},addDialog:{title:`Add Virtual Printer`,name:`Name`,hint:`You can configure access code, target printer, and other settings after creating.`,create:`Create`},deleteConfirm:{title:`Delete Virtual Printer`,message:`Are you sure you want to delete "{{name}}"? This will stop all services for this printer.`}},modelViewer:{openInSlicer:`Open in Slicer`,tabs:{model:`3D Model`,gcode:`G-code Preview`},notAvailable:`not available`,notSliced:`not sliced`,plates:`Plates`,allPlates:`All Plates`,plateNumber:`Plate {{number}}`,plateCount:`{{count}} plate`,plateCount_other:`{{count}} plates`,objectCount:`{{count}} object`,objectCount_other:`{{count}} objects`,filamentCount:`{{count}} filament`,filamentCount_other:`{{count}} filaments`,eta:`ETA {{minutes}} min`,noPreview:`No preview available for this file`,pagination:{pageOf:`Page {{current}} of {{total}}`,prev:`Prev`,next:`Next`},errors:{failedToLoad:`Failed to load file`,noMeshes:`No meshes found in 3MF file`,unsupportedFormat:`Unsupported file format`}},maintenanceDescriptions:{lubricateCarbonRods:`Apply lubricant to carbon rods for smooth motion`,lubricateRails:`Apply lubricant to linear rails for smooth motion`,cleanNozzle:`Clean hotend and nozzle to prevent clogs`,checkBelts:`Verify belt tension for accurate prints`,cleanBuildPlate:`Clean build plate for better adhesion`,checkExtruder:`Inspect extruder gears for wear`,checkCooling:`Ensure cooling fans are working properly`,generalInspection:`General printer inspection`,cleanCarbonRods:`Clean carbon rods to reduce friction`,lubricateSteelRods:`Apply lubricant to steel rods for smooth motion`,cleanSteelRods:`Clean steel rods to reduce friction`,cleanLinearRails:`Wipe linear rails to remove dust and debris`,checkPtfeTube:`Inspect PTFE tube for wear or damage`,replaceHepaFilter:`Replace HEPA filter for air quality`,replaceCarbonFilter:`Replace activated carbon filter`,lubricateLeftNozzleRail:`Lubricate left nozzle rail (H2 series)`},smartPlugs:{offline:`Offline`,admin:`Admin`,openPlugAdminPage:`Open plug admin page`,deleteSmartPlug:`Delete Smart Plug`,turnOnSmartPlug:`Turn On Smart Plug`,turnOffSmartPlug:`Turn Off Smart Plug`,turnOn:`Turn On`,turnOff:`Turn Off`,addSmartPlug:{scanningNetwork:`Scanning network...`,chooseEntity:`Choose an entity...`,connectionFailed:`Connection failed`,searchEntities:`Search entities...`,searchPowerSensors:`Search power sensors...`,searchEnergySensors:`Search energy sensors...`,placeholders:{plugName:`Living Room Plug`,mqttStateOnValue:`ON, true, 1`,mqttSameAsPower:`Same as power topic, or different`}},linkedTo:`Linked to:`,monitorOnly:`Monitor Only`,alerts:`Alerts`,scheduleOn:`On {{time}}`,scheduleOff:`Off {{time}}`,on:`On`,off:`Off`,power:`Power`,kwhToday:`kWh Today`,settings:`Settings`,automationSettings:`Automation Settings`,showInSwitchbar:`Show in Switchbar`,quickAccessSidebar:`Quick access from sidebar`,enabled:`Enabled`,enableAutomation:`Enable automation for this plug`,autoOn:`Auto On`,autoOnDescription:`Turn on when print starts`,autoOff:`Auto Off`,autoOffDescription:`Turn off when print completes (one-shot)`,autoOffPersistent:`Keep Enabled`,autoOffPersistentDescription:`Stay enabled between prints instead of one-shot`,autoOffAfterDrying:`Auto Off After Drying`,autoOffAfterDryingDescription:`Turn off when AMS drying completes`,delayAfterDryingMinutes:`Drying delay (minutes)`,turnOffDelayMode:`Turn Off Delay Mode`,time:`Time`,temp:`Temp`,delayMinutes:`Delay (minutes)`,tempThreshold:`Temperature threshold (°C)`,tempThresholdDescription:`Turns off when nozzle cools below this temperature`,edit:`Edit`,deleteConfirm:`Are you sure you want to delete "{{name}}"? This cannot be undone.`,turnOnConfirm:`Are you sure you want to turn on "{{name}}"?`,turnOffConfirm:`Are you sure you want to turn off "{{name}}"? This will cut power to the connected device.`,failedToTurn:`Failed to turn {{action}} "{{name}}"`,unknown:`Unknown`,addTitle:`Add Smart Plug`,editTitle:`Edit Smart Plug`,stopScanning:`Stop Scanning`,discoverTasmota:`Discover Tasmota Devices`,foundDevices:`Found {{count}} device(s) - click to select:`,noDevicesFound:`No Tasmota devices found on your network`,haNotConfigured:`Home Assistant is not configured. Set it up in`,haSettingsPath:`Settings → Network → Home Assistant`,selectEntity:`Select Entity *`,ipAddress:`IP Address *`,nameLabel:`Name *`,username:`Username`,password:`Password`,authHint:`Leave empty if your Tasmota device doesn't require authentication`,linkToPrinter:`Link to Printer`,noPrinter:`No printer (manual control only)`,linkingDescription:`Linking enables automatic on/off when prints start/complete`,powerAlerts:`Power Alerts`,alertAbove:`Alert if above (W)`,alertBelow:`Alert if below (W)`,alertDescription:`Get notified when power consumption crosses these thresholds. Leave empty to disable that direction.`,dailySchedule:`Daily Schedule`,turnOnAt:`Turn On at`,turnOffAt:`Turn Off at`,scheduleDescription:`Automatically turn the plug on/off at these times daily. Leave empty to skip that action.`,showOnPrinterCard:`Show on Printer Card`,displayOnPrinterCard:`Display button on printer card`,connectedResult:`Connected!`,deviceLabel:`Device: {{name}} - `,stateLabel:`State: {{state}}`,test:`Test`,delete:`Delete`,save:`Save`,add:`Add`,cancel:`Cancel`,failedToStartScan:`Failed to start scan`,nameRequired:`Name is required`,entityRequired:`Entity is required for Home Assistant plugs`,mqttTopicRequired:`At least one MQTT topic must be configured for power, energy, or state monitoring`,loadingEntities:`Loading entities...`,loading:`Loading...`,failedToLoadEntities:`Failed to load entities: {{error}}`,noEntitiesMatching:`No entities found matching "{{search}}"`,noEntitiesAvailable:`No entities available`,searchingEntities:`Searching all entities ({{count}} found)`,showingEntities:`Showing switch, light, input_boolean ({{count}} available)`,energyMonitoringOptional:`Energy Monitoring (Optional)`,energyMonitoringHint:`Search and select sensors that provide power/energy data.`,powerSensorW:`Power Sensor (W)`,energyTodayKwh:`Energy Today (kWh)`,totalEnergyKwh:`Total Energy (kWh)`,noMatchingSensors:`No matching sensors`,none:`None`,mqttNotConfigured:`MQTT broker not configured. Set broker address in`,mqttSettingsPath:`Settings → Network → MQTT Publishing`,mqttNotConfiguredSuffix:`(you don't need to enable publishing, just fill in the broker details).`,mqttMonitorOnlyDescription:`MQTT plugs receive power/energy data via MQTT subscription. On/off control is not available - use your MQTT broker or home automation system.`,powerMonitoring:`Power Monitoring`,energyMonitoring:`Energy Monitoring`,stateMonitoring:`State Monitoring`,optional:`optional`,topic:`Topic`,jsonPath:`JSON Path`,multiplier:`Multiplier`,onValue:`ON Value`,mqttPowerHint:`JSON path extracts value from JSON payload (e.g., "power_l1"). Leave empty if topic publishes raw numeric values. Use multiplier 0.001 for mW→W, 1000 for kW→W.`,mqttEnergyHint:`JSON path extracts value from JSON payload. Leave empty for raw values. Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh.`,mqttStateHint:`JSON path extracts value from JSON payload. Leave empty for raw values. -ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).`,restControl:`Control`,restOnUrl:`Turn ON URL`,restOffUrl:`Turn OFF URL`,restOnBody:`ON Request Body`,restOffBody:`OFF Request Body`,restMethod:`HTTP Method`,restHeaders:`Custom Headers (JSON)`,restStatusUrl:`Status URL`,restStatusPath:`State JSON Path`,restStatusOnValue:`ON Value`,restPowerUrl:`Power URL`,restPowerPath:`Power JSON Path`,restPowerMultiplier:`Power Multiplier`,restEnergyUrl:`Energy URL`,restEnergyPath:`Energy JSON Path`,restEnergyMultiplier:`Energy Multiplier`,restUrlRequired:`At least one URL (ON or OFF) is required for REST plugs`,restHeadersHint:`e.g. {"Authorization": "Bearer your-token"}`,restBodyHint:`e.g. ON, {"state": "on"}`,restStatusHint:`URL to poll for current state`,restPathHint:`e.g. state or data.power.status`,restPowerUrlHint:`Separate URL for power data (uses Status URL if empty)`,restEnergyUrlHint:`Separate URL for energy data (uses Status URL if empty)`,restEnergyHint:`Each value can use its own URL or fall back to the Status URL. Use multipliers for unit conversion (e.g. 0.001 to convert Wh to kWh).`,testConnection:`Test Connection`,connectionSuccess:`Connection successful`,noSwitchesInSwitchbar:`No switches in switchbar`,enableSwitchbarHint:`Enable "Show in Switchbar" in Settings > Smart Plugs`},notifications:{providerTypes:{callmebot:`CallMeBot/WhatsApp`,ntfy:`ntfy`,pushover:`Pushover`,telegram:`Telegram`,email:`Email`,discord:`Discord`,webhook:`Webhook`,homeassistant:`Home Assistant`},providerDescriptions:{email:`SMTP email notifications`,telegram:`Notifications via Telegram bot`,discord:`Send to Discord channel via webhook`,ntfy:`Free, self-hostable push notifications`,pushover:`Simple, reliable push notifications`,callmebot:`Free WhatsApp notifications via CallMeBot`,webhook:`Generic HTTP POST to any URL`,homeassistant:`Persistent notifications in Home Assistant dashboard`},lastSuccess:`Last: {{date}}`,error:`Error`,printer:`Printer:`,allPrinters:`All printers`,sendTestNotification:`Send Test Notification`,eventSettings:`Event Settings`,enabled:`Enabled`,sendFromProvider:`Send notifications from this provider`,printEvents:`Print Events`,printerStatus:`Printer Status`,amsAlarms:`AMS Alarms`,amsHtAlarms:`AMS-HT Alarms`,printQueue:`Print Queue`,start:`Start`,plateCheck:`Plate Check`,complete:`Complete`,failed:`Failed`,stopped:`Stopped`,progress:`Progress`,offline:`Offline`,lowFilament:`Low Filament`,maintenance:`Maintenance`,amsHumidity:`AMS Humidity`,amsTemp:`AMS Temp`,amsHtHumidity:`AMS-HT Humidity`,amsHtTemp:`AMS-HT Temp`,bedCooled:`Bed Cooled`,firstLayer:`First Layer`,quiet:`Quiet`,digest:`Digest {{time}}`,printStarted:`Print Started`,plateNotEmpty:`Plate Not Empty`,plateNotEmptyDescription:`Objects detected before print`,printCompleted:`Print Completed`,bedCooledLabel:`Bed Cooled`,bedCooledDescription:`Bed cooled below threshold after print`,firstLayerCompleteLabel:`First Layer Complete`,firstLayerCompleteDescription:`Notify with snapshot when first layer finishes`,missingSpoolAssignmentLabel:`Missing Spool Assignment`,missingSpoolAssignmentDescription:`Notify when print starts and required trays have no assigned spool`,printFailed:`Print Failed`,printStopped:`Print Stopped`,progressMilestones:`Progress Milestones`,progressMilestonesDescription:`Notify at 25%, 50%, 75%`,printerOffline:`Printer Offline`,printerError:`Printer Error`,aiFailureDetection:`AI Failure Detection`,aiFailureDetectionDescription:`Notify when Obico AI detects a possible print failure`,lowFilamentLabel:`Low Filament`,maintenanceDue:`Maintenance Due`,maintenanceDueDescription:`Notify when maintenance is needed`,amsHumidityHigh:`AMS Humidity High`,amsHumidityHighDescription:`Regular AMS humidity exceeds threshold`,amsTemperatureHigh:`AMS Temperature High`,amsTemperatureHighDescription:`Regular AMS temperature exceeds threshold`,amsHtHumidityHigh:`AMS-HT Humidity High`,amsHtHumidityHighDescription:`AMS-HT humidity exceeds threshold`,amsHtTemperatureHigh:`AMS-HT Temperature High`,amsHtTemperatureHighDescription:`AMS-HT temperature exceeds threshold`,inventoryAlerts:`Inventory Alerts`,stockReorderAlert:`Reorder Alert`,stockReorderAlertDescription:`SKU has reached its reorder point`,stockBreakAlert:`Stock Break Alert`,stockBreakAlertDescription:`Stock will run out before replenishment arrives`,jobAdded:`Job Added`,jobAddedDescription:`Job added to queue`,jobAssigned:`Job Assigned`,jobAssignedDescription:`Model-based job assigned to printer`,jobStarted:`Job Started`,jobStartedDescription:`Queue job started printing`,jobWaiting:`Job Waiting`,jobWaitingDescription:`Job waiting for filament or printer`,jobSkipped:`Job Skipped`,jobSkippedDescription:`Job skipped (previous failed)`,jobFailed:`Job Failed`,jobFailedDescription:`Job failed to start`,queueComplete:`Queue Complete`,queueCompleteDescription:`All queue jobs finished`,quietHours:`Quiet Hours`,noNotificationsDuring:`No notifications during these hours`,editProviderToChangeQuietHours:`Edit provider to change quiet hours`,dailyDigest:`Daily Digest`,batchNotifications:`Batch notifications into a single daily summary`,sendAt:`Send at {{time}}`,editProviderToChangeDigestTime:`Edit provider to change digest time`,edit:`Edit`,deleteProvider:`Delete Notification Provider`,deleteConfirm:`Are you sure you want to delete "{{name}}"? This cannot be undone.`,delete:`Delete`,addTitle:`Add Notification Provider`,editTitle:`Edit Notification Provider`,nameLabel:`Name *`,namePlaceholder:`My Notifications`,providerTypeLabel:`Provider Type *`,configuration:`Configuration`,testConfiguration:`Test Configuration`,printerFilter:`Printer Filter`,onlyFromPrinter:`Only send notifications for events from this printer`,quietHoursDnd:`Quiet Hours (Do Not Disturb)`,quietStart:`Start`,quietEnd:`End`,dailyDigestLabel:`Daily Digest`,sendDigestAt:`Send digest at`,digestCollected:`Events will be collected and sent as a single summary at this time`,notificationEvents:`Notification Events`,progressPercent:`(25%, 50%, 75%)`,bedCooledAfterPrint:`(after print completes)`,eventPriority:{sectionTitle:`ntfy Priority`,helpNtfy:`Pick a priority for each enabled event. ntfy uses these to escalate alerts (sound, visibility, push behavior). Levels not set here use the ntfy server default.`,min:`Min`,low:`Low`,default:`Default`,high:`High`,urgent:`Urgent`},cancel:`Cancel`,save:`Save`,add:`Add`,nameRequired:`Name is required`,fieldRequired:`{{field}} is required`,phoneNumber:`Phone Number`,apiKey:`API Key`,serverUrl:`Server URL`,topic:`Topic`,authToken:`Auth Token`,userKey:`User Key`,appToken:`App Token`,priority:`Priority`,botToken:`Bot Token`,chatId:`Chat ID`,smtpServer:`SMTP Server`,smtpPort:`SMTP Port`,security:`Security`,authentication:`Authentication`,username:`Username`,password:`Password`,fromEmail:`From Email`,toEmail:`To Email`,webhookUrl:`Webhook URL`,payloadFormat:`Payload Format`,authorization:`Authorization`,titleFieldName:`Title Field Name`,messageFieldName:`Message Field Name`,editTemplate:`Edit Template: {{name}}`,titleLabel:`Title`,bodyLabel:`Body`,titlePlaceholder:`Notification title...`,bodyPlaceholder:`Notification body...`,availableVariables:`Available Variables`,clickToInsert:`Click to insert at cursor position in body`,livePreview:`Live Preview`,hide:`Hide`,show:`Show`,loadingPreview:`Loading preview...`,enterTemplateContent:`Enter template content to see preview`,titlePreview:`Title:`,bodyPreview:`Body:`,resetToDefault:`Reset to Default`,titleRequired:`Title is required`,bodyRequired:`Body is required`,notificationLog:`Notification Log`,showFailedOnly:`Failed only`,last24Hours:`Last 24 hours`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,last90Days:`Last 90 days`,justNow:`Just now`,noFailedNotifications:`No failed notifications`,noNotificationsLogged:`No notifications logged`,unknownProvider:`Unknown Provider`,logTitle:`Title`,logMessage:`Message`,logError:`Error`,logProvider:`Provider: {{type}}`,logTime:`Time: {{time}}`,refresh:`Refresh`,clearOld:`Clear Old`,statsSummary:`Last {{days}} days:`,statsNotifications:`notifications`,statsSent:`{{count}} sent`,statsFailed:`{{count}} failed`,eventTypes:{print_start:`Print Started`,print_complete:`Print Complete`,print_failed:`Print Failed`,print_stopped:`Print Stopped`,print_progress:`Progress`,printer_offline:`Printer Offline`,printer_error:`Printer Error`,filament_low:`Low Filament`,maintenance_due:`Maintenance Due`,test:`Test`},userEmail:{title:`Notifications`,emailNotifications:`Email Notifications`,emailNotificationsDesc:`Receive email notifications for your own print jobs. Emails are sent using the system SMTP settings configured in Advanced Authentication.`,sendingTo:`Notifications will be sent to`,noEmailWarning:`Your account does not have an email address. Contact an administrator to add one.`,printJobNotifications:`Print Job Notifications`,printJobNotificationsDesc:`Choose which events trigger email notifications for print jobs you submit.`,printJobStarts:`Print Job Starts`,printJobStartsDesc:`Get notified when your print job begins.`,printJobFinishes:`Print Job Finishes`,printJobFinishesDesc:`Get notified when your print job completes successfully.`,printErrors:`Print Errors`,printErrorsDesc:`Get notified when your print job fails or encounters an error.`,printJobStops:`Print Job Stops`,printJobStopsDesc:`Get notified when your print job is cancelled or stopped.`,saveSuccess:`Notification preferences saved.`,saveError:`Failed to save notification preferences.`}},richTextEditor:{bold:`Bold`,italic:`Italic`,underline:`Underline`,bulletList:`Bullet List`,numberedList:`Numbered List`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,addLink:`Add Link`,removeLink:`Remove Link`},externalLinks:{title:`Sidebar Links`,sidebarLayout:`Sidebar`,sidebarLayoutDescription:`Show or hide built-in pages, add external links, and drag items to reorder the sidebar navigation.`,systemPages:`Bambuddy pages`,externalLinks:`External links`,visibleInSidebar:`Visible in sidebar`,hiddenFromSidebar:`Hidden from sidebar`,requiredInSidebar:`Required in sidebar`,hidePage:`Hide page`,showPage:`Show page`,settingsCannotBeHidden:`Settings cannot be hidden`,noLinksConfigured:`No external links configured`,deleteLink:`Delete Link`,removeCustomIcon:`Remove custom icon`,openInNewTab:`Open in new tab`,placeholders:{linkName:`My Link`}},keyboardShortcuts:{title:`Keyboard Shortcuts`,navigation:`Navigation`,archivesSection:`Archives`,kProfilesSection:`K-Profiles`,generalSection:`General`,shortcuts:{goToPrinters:`Go to Printers`,goToArchives:`Go to Archives`,goToQueue:`Go to Queue`,goToStats:`Go to Statistics`,goToProfiles:`Go to Cloud Profiles`,goToSettings:`Go to Settings`,focusSearch:`Focus search`,openUploadModal:`Open upload modal`,clearSelection:`Clear selection / blur input`,contextMenu:`Context menu on cards`,refreshProfiles:`Refresh profiles`,newProfile:`New profile`,exitSelectionMode:`Exit selection mode`,showHelp:`Show this help`},footer:`Press Esc or click outside to close`},notificationLog:{title:`Notification Log`,events:{printStarted:`Print Started`,printComplete:`Print Complete`,printFailed:`Print Failed`,printStopped:`Print Stopped`,progress:`Progress`,printerOffline:`Printer Offline`,printerError:`Printer Error`,lowFilament:`Low Filament`,maintenanceDue:`Maintenance Due`,test:`Test`},timeAgo:{justNow:`Just now`,minutesAgo:`{{minutes}}m ago`,hoursAgo:`{{hours}}h ago`}},restoreBackup:{title:`Restore Backup`,restoring:`Restoring...`,restoreComplete:`Restore Complete`,restoreFailed:`Restore Failed`,importSettings:`Import settings from a backup file`,pleaseWait:`Please wait while your data is being restored`,clickToSelect:`Click to select backup file (.json or .zip)`,howDuplicateHandling:`How duplicate handling works:`,categories:{printers:`Printers`,smartPlugs:`Smart Plugs`,notificationProviders:`Notification Providers`,filaments:`Filaments`,archives:`Archives`,pendingUploads:`Pending Uploads`,settingsTemplates:`Settings & Templates`},matchingInfo:{printers:`matched by serial number`,smartPlugs:`matched by IP address`,notificationProviders:`matched by name`,filaments:`matched by name + type + brand`,archives:`matched by content hash`,pendingUploads:`matched by filename`,settingsTemplates:`always overwritten`},replaceExisting:`Replace existing data`,keepExisting:`Keep existing data`,replaceDescription:`Overwrite items that already exist with backup data`,keepDescription:`Only restore items that don't already exist`,caution:`Caution:`,cautionText:`Overwriting will replace your current configurations with backup data. Printer access codes are never overwritten for security.`,itemsRestored:`Items Restored`,itemsSkipped:`Items Skipped`,restored:`Restored`,skipped:`Skipped (already exist)`,filesLabel:`Files (3MF, thumbnails, etc.)`,newApiKeysGenerated:`New API Keys Generated`,newApiKeysWarning:`These keys are only shown once. Copy them now!`,processingBackup:`Processing backup file...`,noDataFound:`No data was found to restore in the backup file.`,failedToRestore:`Failed to restore backup. Please check the file format.`},backupExport:{title:`Export Backup`,selectData:`Select data to include`,selectAll:`Select All`,selectNone:`Select None`,categoryDescriptions:{settings:`Language, theme, update preferences`,notifications:`ntfy, Pushover, Discord, etc.`,templates:`Custom message templates`,smartPlugs:`Tasmota plug configurations`,externalLinks:`Sidebar links to external services`,printers:`Printer info (access codes excluded)`,plateDetection:`Empty plate reference images`,filaments:`Filament types and costs`,maintenance:`Custom maintenance schedules`,archives:`All print data + files (3MF, thumbnails, photos)`,projects:`Projects, BOM items, and attachments`,pendingUploads:`Virtual printer uploads awaiting review`,apiKeys:`Webhook API keys (new keys generated on import)`},requiresPrinters:`Requires Printers to be selected`,zipFileWarning:`ZIP file will be created.`,zipFileDescription:`Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file.`,includeAccessCodes:`Include Access Codes`,includeAccessCodesDescription:`For transferring to another machine`,includeAccessCodesWarning:`Access codes will be included in plain text. Keep this backup file secure!`,categoriesSelected:`{{selectedCount}} categories selected`},pendingUploads:{placeholders:{notes:`Add notes about this print...`},discardUpload:`Discard Upload`,archiveAllUploads:`Archive All Uploads`,discardAllUploads:`Discard All Uploads`,archive:`Archive`,timeAgo:{justNow:`Just now`,minutesAgo:`{{minutes}}m ago`,hoursAgo:`{{hours}}h ago`,daysAgo:`{{days}}d ago`}},apiBrowser:{placeholders:{requestBody:`JSON request body...`,searchEndpoints:`Search endpoints...`}},configureAmsSlot:{title:`Configure AMS Slot`,slotConfigured:`Slot Configured!`,configuringSlot:`Configuring slot:`,slotLabel:`{{ams}} Slot {{slot}}`,searchPresets:`Search presets...`,colorPlaceholder:`Color name or hex (e.g., brown, FF8800)`,clearCustomColor:`Clear custom color`,noCloudPresets:`No cloud presets. Login to Bambu Cloud to sync.`,noPresetsAvailable:`No presets available. Login to Bambu Cloud or import local profiles.`,noMatchingPresets:`No matching presets found.`,custom:`Custom`,builtin:`Built-in`,orcaCloud:`Orca Cloud`,bambuCloud:`Bambu Cloud`,settingsSentToPrinter:`Settings sent to printer`,filamentProfile:`Filament Profile`,kProfileLabel:`K Profile (Pressure Advance)`,filteringFor:`Filtering for: {{material}}`,noKProfile:`No K profile (use default 0.020)`,noMatchingKProfiles:`No matching K profiles found. Default K=0.020 will be used.`,selectFilamentFirst:`Select a filament profile first`,kFromCalibration:`K={{value}} from printer calibration`,customColorLabel:`Custom Color (optional)`,presetColors:`{{name}} colors:`,showLessColors:`Show less colors`,showMoreColors:`Show more colors`,clear:`Clear`,hexLabel:`Hex: #{{hex}}`,resetting:`Resetting...`,resetSlot:`Reset Slot`,cancel:`Cancel`,configuring:`Configuring...`,configureSlot:`Configure Slot`},githubBackup:{title:`Git Backup`,history:`History`,downloadBackup:`Download Backup`,restoreBackup:`Restore Backup`,noBackupsYet:`No backups yet`},emailSettings:{placeholders:{fromName:`BamBuddy`}},tagManagement:{searchTags:`Search tags...`,renameTag:`Rename tag`,deleteTag:`Delete tag`},notificationTemplates:{placeholders:{title:`Notification title...`,body:`Notification body...`}},batchTag:{placeholders:{newTag:`Enter new tag...`}},photoGallery:{deletePhoto:`Delete Photo`},filamentHoverCard:{copySpoolUuid:`Copy spool UUID`},kProfilesView:{hasNote:`Has note`,copyProfile:`Copy profile`},layout:{openMenu:`Open menu`,noPermissionSystemInfo:`You do not have permission to view system information`},dashboard:{dragToReorder:`Drag to reorder`,hideWidget:`Hide widget`},notificationProviderCard:{deleteNotificationProvider:`Delete Notification Provider`},fileManagerModal:{closeFileManager:`Close file manager`,sortFiles:`Sort files`,goToParentFolder:`Go to parent folder`,threeView:`3D View`},embeddedCameraViewer:{refreshStream:`Refresh stream`,close:`Close`,zoomOut:`Zoom out`,resetZoom:`Reset zoom`,zoomIn:`Zoom in`,dragToResize:`Drag to resize`},timelapseViewer:{skipBack5s:`Skip back 5s`,skipForward5s:`Skip forward 5s`},notificationProviders:{descriptions:{email:`SMTP email notifications`,telegram:`Notifications via Telegram bot`,discord:`Send to Discord channel via webhook`,ntfy:`Free, self-hostable push notifications`,pushover:`Simple, reliable push notifications`,callmebot:`Free WhatsApp notifications via CallMeBot`,webhook:`Generic HTTP POST to any URL`}},logViewer:{searchPlaceholder:`Search message or logger name...`,noLogEntries:`No log entries found`},switchbarPopover:{noSwitchesInSwitchbar:`No switches in switchbar`},projectPageModal:{placeholders:{title:`Title`,designer:`Designer`,license:`License`,description:`Enter description...`,profileTitle:`Profile Title`,profileDescription:`Profile description...`}},spoolmanSettings:{},time:{unknown:`-`,waiting:`Waiting`,justNow:`Just now`,now:`Now`,minsAgo:`{{count}}m ago`,inMins:`in {{count}}m`,hoursAgo:`{{count}}h ago`,inHours:`in {{count}}h`,daysAgo:`{{count}}d ago`,inDays:`in {{count}}d`},spoolbuddy:{nav:{dashboard:`Dashboard`,ams:`AMS`,inventory:`Inventory`,writeTag:`Write`,settings:`Settings`},status:{nfcReady:`NFC Ready`,nfcOff:`NFC Off`,offline:`Offline`,online:`Online`,noPrinters:`No printers`,deviceOffline:`Device Offline`,waitingConnection:`Waiting for device connection...`,systemReady:`System Ready`,status:`Status`},dashboard:{readyToScan:`Ready to scan`,idleMessage:`Place a spool on the scale to identify it`,nfcHint:`NFC tag will be read automatically`,device:`Device`,syncWeight:`Sync Weight`,weightSynced:`Synced!`,unknownTag:`Unknown Tag`,newTag:`New Tag Detected`,onScale:`on scale`,linkSpool:`Link to Spool`,linkTagTitle:`Link Tag to Spool`,linkTag:`Link Tag`,selectSpool:`Select a spool to link this tag to:`,noUntagged:`No spools without tags found`,tagDetected:`Tag detected`,noTag:`No tag`,tagId:`Tag`,grossWeight:`Gross weight`,spoolSize:`Spool size`,close:`Close`,currentSpool:`Current Spool`,plateReady:`Plate ready: {{name}}`,plateReadyLabel:`Plates ready to clear`,plateClearAction:`Clear`,plateClearedToast:`Plate marked as cleared`,plateClearFailed:`Could not mark plate as cleared`},modal:{spoolDetected:`Spool Detected`,assignToAms:`Assign to AMS`,syncWeight:`Sync Weight`,weightSynced:`Synced!`,syncing:`Syncing...`,newTagDetected:`New Tag Detected`,addToInventory:`Add to Inventory`,assignToAmsTitle:`Assign to AMS`,selectSlot:`Select a slot`,assign:`Assign`,assigning:`Assigning...`,assignSuccess:`Assigned!`,assignPendingInsert:`Assigned. Slot will configure when you insert the spool.`,assignError:`Failed to assign spool. Please try again.`,noPrinterSelected:`Select a printer...`,noAmsDetected:`No AMS detected on this printer`,slot:`Slot`},weight:{noReading:`No reading`,stable:`Stable`,measuring:`Measuring...`,tare:`Tare`,calibrate:`Calibrate`},spool:{remaining:`Remaining`,material:`Material`,brand:`Brand`,color:`Color`,coreWeight:`Core`,labelWeight:`Label`,scaleWeight:`Scale`,netWeight:`Net`,lastUsed:`Last used`},ams:{noData:`No AMS detected`,connectAms:`Connect an AMS to see filament slots`,noPrinter:`No printer selected`,selectPrinter:`Select a printer from the top bar`,printerDisconnected:`Printer disconnected`,humidity:`Humidity`,level:`Level`,active:`Active`,slot:`Slot`,empty:`Empty`},inventory:{search:`Search spools...`,empty:`No spools in inventory`,noResults:`No matching spools`,spools:`spools`,addSpool:`Add Spool`},settings:{tabDevice:`Device`,tabDisplay:`Display`,tabScale:`Scale`,tabUpdates:`Updates`,nfcReader:`NFC Reader`,type:`Type`,connection:`Connection`,notConnected:`N/A`,deviceInfo:`Device Info`,hostname:`Host`,uptime:`Uptime`,systemConfig:`Backend & Auth`,backendUrl:`Bambuddy Backend URL`,apiToken:`API Token`,apiTokenPlaceholder:`Enter API token`,saveConfig:`Save Config`,systemQueued:`Config queued.`,nfcDiagnostic:`NFC Diagnostic`,scaleDiagnostic:`Scale Diagnostic`,readTagDiagnostic:`Read Tag Diagnostic`,testNfc:`Test reader`,testScale:`Test accuracy`,testReadTag:`Read tag`,systemFieldsRequired:`Backend URL is required.`,brightness:`Brightness`,saved:`Saved`,noBacklight:`No DSI backlight detected. Brightness control requires a DSI display.`,screenBlank:`Screen Blank Timeout`,screenBlankDesc:`Screen turns off after inactivity. Touch to wake.`,displayNote:`Brightness is applied as a software filter.`,scaleCalibration:`Scale Calibration`,currentWeight:`Current weight`,tareOffset:`Tare`,calFactor:`Factor`,knownWeight:`Known weight`,calStep1:`Remove all items from the scale and press Set Zero.`,calStep2:`Place known weight on scale.`,setZero:`Set Zero`,calibrateNow:`Calibrate`,calibrated:`Calibrated`,tareSet:`Tare command sent. Waiting for device...`,tareComplete:`Tare complete!`,tareTimedOut:`Tare timed out — is the SpoolBuddy daemon running?`,tareFailed:`Failed to send tare command`,zeroSet:`Zero point set. Place known weight on scale.`,calibrationDone:`Calibration complete!`,calibrationFailed:`Calibration failed`,lastCalibrated:`Last calibrated`,stable:`Stable`,settling:`Settling...`,firmware:`Firmware`,scale:`Scale`,noDevice:`No SpoolBuddy device found`,daemonVersion:`Daemon Version`,currentVersion:`Current`,versionPending:`Waiting for daemon...`,checking:`Checking...`,checkUpdates:`Check for Updates`,updateAvailable:`Update available`,updateInstructions:`Update via SSH: run the SpoolBuddy install script to upgrade.`,upToDate:`Up to date`,includeBeta:`Include beta versions`},writeTag:{tabExisting:`Existing Spool`,tabNew:`New Spool`,tabReplace:`Replace Tag`,searchPlaceholder:`Search by material, color, brand...`,noUntaggedSpools:`No spools without tags`,noTaggedSpools:`No spools with tags`,selectSpool:`Select a spool, then place a blank NTAG on the reader`,placeTag:`Place an NTAG on the reader`,tagReady:`Tag detected — ready to write`,writeTag:`Write Tag`,replaceTag:`Replace Tag`,writing:`Writing tag...`,waiting:`Waiting for SpoolBuddy...`,writeSuccess:`Tag written successfully!`,writeFailed:`Write failed`,queueFailed:`Failed to queue write command`,tryAgain:`Try Again`,cancel:`Cancel`,replaceWarning:`Old tag will be unlinked. New tag will replace it.`,deviceOffline:`SpoolBuddy is offline`,material:`Material`,colorName:`Color Name`,color:`Color`,brand:`Brand`,weight:`Weight (g)`,createSpool:`Create Spool`,creating:`Creating...`,spoolCreated:`Spool created! Ready to write.`,createFailed:`Failed to create spool`,incompleteDataWarning:`Tag written with incomplete Spoolman data`},quickMenu:{printerPower:`Printer Power`,systemControls:`System`,restartDaemon:`Restart Daemon`,restartBrowser:`Restart Browser`,reboot:`Reboot`,shutdown:`Shutdown`,swipeToClose:`Swipe down to close`,confirmTitle:`Confirm`,confirmShutdown:`Are you sure you want to shut down the SpoolBuddy? You will need physical access to turn it back on.`,confirmReboot:`Are you sure you want to reboot the SpoolBuddy?`,confirmRestartDaemon:`Restart the SpoolBuddy daemon? NFC and scale will be temporarily unavailable.`,confirmRestartBrowser:`Restart the kiosk browser? The display will briefly go blank.`,confirm:`Confirm`,confirmPlugOn:`Turn on {{name}}?`,confirmPlugOff:`Turn off {{name}}?`,turnOn:`Turn On`,turnOff:`Turn Off`}},diagnostic:{modalTitle:`Connection diagnostic — {{name}}`,running:`Running diagnostic...`,runningElapsed:`Running diagnostic... ({{elapsed}}s)`,waitingForReportHint:`Listening for the printer to publish a status report — this can take up to {{max}} seconds.`,runFailed:`Diagnostic could not run: {{error}}`,retry:`Run again`,runButton:`Run diagnostic`,sectionTitle:`Connection Diagnostic`,sectionDescription:`Check why a printer won't connect or won't print — port reachability, LAN developer mode, Docker network mode, and credentials.`,noPrinters:`No printers configured.`,overall:{ok:`No problems found — the printer connection looks healthy.`,warnings:`The printer should work, but some things need attention.`,problems:`Found problems that explain why the printer won't connect or print.`},check:{port_mqtt:{title:`Control port (MQTT 8883)`,pass:`Reachable — the printer is accepting control connections.`,fail:`Port 8883 is unreachable. The printer is powered off, on a different IP address, or a firewall is blocking it. Verify the printer IP and that nothing blocks port 8883.`},port_ftps:{title:`File transfer port (FTPS 990)`,pass:`Reachable — sending print files will work.`,warn:`Port 990 is unreachable. Monitoring may still work, but sending prints to the printer will fail. Make sure port 990 is not blocked.`},external_storage:{title:`Store sent files on external storage (install step 4)`,pass:`The printer reports this option is on — sent files will be stored on the SD card and archives will have thumbnails and slicer metadata.`,fail:`The printer reports this option is off. Enable "Store sent files on external storage" — on newer firmware (P2S 01.02 / Bambu Studio 2.6+) the toggle lives on the printer's Print Settings; on older versions it's in Bambu Studio / OrcaSlicer's Device tab. Without it, every archived print is missing its thumbnail and slicer metadata.`,skip:`Not checked — needs a live MQTT connection. On older slicers where this setting lives only in the slicer the printer never reports it, so this check will pass even when the option is off — verify install step 4 manually.`},port_rtsps:{title:`Camera port ({{protocol}} {{port}})`,pass:`Reachable — the camera stream will work.`,warn:`Port {{port}} is unreachable. The live camera view will not work. This does not affect printing.`},network_mode:{title:`Docker network mode`,pass:`Running in host network mode.`,warn:`Bambuddy is running in Docker bridge networking. Printer discovery and the Virtual Printer need host network mode — recreate the container with "network_mode: host".`,skip:`Not running in Docker — not applicable.`},subnet:{title:`Network subnet`,pass:`The printer and Bambuddy are on the same subnet.`,warn:`The printer ({{printer_ip}}) and Bambuddy ({{host_ip}}) are on different subnets. They may not reach each other unless routing between the subnets is configured.`,skip:`Subnet could not be determined — skipped.`},mqtt_auth:{title:`Printer credentials`,pass:`The printer accepted the connection.`,fail:`The printer is reachable but rejected the connection. The access code or serial number is most likely wrong. The access code changes every time Developer Mode is toggled — re-copy it from the printer screen.`,skip:`Not checked — the printer could not be reached.`},developer_mode:{title:`LAN Developer Mode`,pass:`Developer Mode is enabled.`,fail:`Developer Mode is OFF on the printer. Enable it in the printer's LAN settings — and confirm with OK. Without it, prints will not start.`,skip:`Could not be checked — requires a live connection to the printer.`},printer_publishing:{title:`Printer is publishing status`,pass:`The printer is publishing status updates — AMS, filaments, and K-profiles will mirror correctly to the slicer.`,fail:`The MQTT broker accepted the connection but the printer has not published any status reports. This is almost always a wrong or mis-cased serial number — the device//report topic is case-sensitive. Re-check the serial in printer settings against the screen on the printer.`,skip:`Could not be checked — requires a live connection to the printer.`}}},systemHealth:{sectionTitle:`System Health`,sectionDescription:`Scans recent logs for known issues you can usually fix yourself, before they turn into a support ticket.`,rescan:`Re-scan`,clean:`No known issues found in the last {{times}} log entries.`,logUnavailable:`File logging is disabled, so logs cannot be scanned. Enable file logging to use this check.`,learnMore:`How to fix`,fixLabel:`Fix:`,occurrences:`Seen {{times}}× — last at {{lastSeen}}`,category:{layer8:`You can fix this`,environment:`Environment`,bug:`Please report this`},signature:{"ftp-auth-rejected":{name:`Printer rejected the access code`,cause:`The printer refused the file-transfer login. The access code is wrong, or it changed after Developer Mode was toggled.`,fix:`Re-copy the access code from the printer screen (LAN settings) and update it in the printer's settings in Bambuddy.`},"ftp-connection-timeout":{name:`File-transfer connection timed out`,cause:`Bambuddy could not reach the printer's file-transfer port (FTPS 990). The port is blocked, or the printer is off or on another subnet.`,fix:`Make sure nothing blocks port 990 between Bambuddy and the printer, and that both are on the same network.`},"ftp-ssl-error":{name:`Secure file-transfer handshake failed`,cause:`The TLS handshake with the printer's file-transfer server failed. This is often a firewall or outdated printer firmware.`,fix:`Update the printer firmware and check that no firewall or proxy intercepts the connection on port 990.`},"mqtt-connection-flapping":{name:`Printer connection keeps dropping`,cause:`The control connection (MQTT 8883) repeatedly disconnects and reconnects — usually a weak network path or a partially blocked port.`,fix:`Check the Wi-Fi signal at the printer, prefer a wired connection, and make sure port 8883 is reliably reachable.`},"camera-connection-refused":{name:`Camera stream unreachable`,cause:`The live camera could not be reached on port RTSPS 322. The port is blocked, or the camera or LAN liveview is off on the printer.`,fix:`Enable the camera and LAN liveview on the printer, and make sure port 322 is not blocked. This does not affect printing.`},"database-locked":{name:`Database write contention`,cause:`The SQLite database is hitting "database is locked" errors under load — common when running several printers at once.`,fix:`Switch Bambuddy to an external PostgreSQL database. See the PostgreSQL guide in the documentation.`}}},vpDiagnostic:{title:`Setup check — {{name}}`,runButton:`Run setup check`,running:`Running setup check...`,runFailed:`Could not run the setup check: {{error}}`,retry:`Run again`,overall:{ok:`All checks passed — this virtual printer is set up correctly.`,warnings:`The virtual printer should work, but some things need attention.`,problems:`Found problems that explain why the slicer can't see or use this virtual printer.`},check:{enabled:{title:`Virtual printer enabled`,fail:`This virtual printer is switched off. Toggle it on to make it discoverable.`},running:{title:`Services running`,fail:`The virtual printer is enabled but its services are not running. Check the Bambuddy log — a bind IP conflict or a permission error usually stops them.`},bind_interface:{title:`Bind network interface`,fail:`The bind interface is not set, or no longer exists on this host. Pick a current interface in the Bind Interface dropdown.`},access_code:{title:`Access code set`,fail:`No access code is set. The slicer must be given the same 8-character access code you set here.`},target_printer:{title:`Target printer`,fail:`No target printer is selected. Proxy mode needs a real printer to forward to.`,warn:`The target printer is offline right now — proxying will resume once it reconnects.`},port_ftps:{title:`File-upload service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer cannot upload files. A port conflict on this interface is the usual cause.`},port_mqtt:{title:`Control service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer cannot connect or show status.`},port_bind:{title:`Discovery service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer's discovery handshake fails.`},certificate:{title:`TLS certificate`,pass:`Certificate ready. Make sure the Bambuddy CA certificate (above) is imported into your slicer's trust store.`,fail:`The TLS certificate for this virtual printer is missing. Check that the Bambuddy data directory is writable.`}}},bugReport:{title:`Report a Bug`,description:`Description`,descriptionPlaceholder:`What went wrong? Please describe the issue...`,email:`Email (optional)`,emailPlaceholder:`your@email.com`,emailPrivacy:`If provided, your email will be included in a collapsed section of the GitHub issue so the maintainer can follow up.`,screenshot:`Screenshot`,uploadOrPaste:`Upload, paste, or drag an image`,dataCollectedSummary:`What data is included in the report?`,dataIncluded:`Included:`,dataIncludedList:`App version, OS, architecture, Python version, database stats (counts only), printer models, nozzle counts, firmware versions, connectivity status, integration status (Spoolman, MQTT, HA), non-sensitive settings, network interface count, Docker details, dependency versions.`,dataNeverIncluded:`Never included:`,dataNeverIncludedList:`Printer names, serial numbers, access codes, passwords, IP addresses, email addresses, API keys, tokens, webhook URLs, hostnames, or usernames.`,submit:`Submit`,startLogging:`Start Debug Logging`,stepEnableLogging:`Debug logging enabled`,stepReproduce:`Reproduce the issue now`,stepStopLogging:`Stop & submit report`,stopAndSubmit:`Stop & Submit`,maxDuration:`Auto-stops after {{minutes}} min`,stoppingLogs:`Collecting logs & submitting...`,submitting:`Submitting bug report...`,submittingStepConnection:`Running printer connectivity checks`,submittingStepVirtualPrinters:`Running virtual-printer setup checks`,submittingStepLogScan:`Scanning recent logs for known issues`,submittingStepSubmit:`Submitting report to GitHub`,submitSuccess:`Bug report submitted successfully!`,submitFailed:`Failed to submit bug report`,diagnosticChecking:`Checking printer connections...`,diagnosticHealthy:`Connection check passed — no problems found on your printers.`,diagnosticSummary:`{{problems}} of {{total}} printers have connection issues`,diagnosticIntro:`One or more printers have a connection problem that may be causing your issue. Expand a printer below to see the fix — resolving it could solve the problem without a bug report. You can still submit a report below.`,logHealthSummary:`Known issues found in your logs`,logHealthIntro:`Recent logs match known problems. Check the fixes below — resolving them could solve your issue without a bug report. You can still submit a report below.`,thankYou:`Thank you!`,submitted:`Your bug report has been submitted.`,viewIssue:`View Issue`,unexpectedError:`An unexpected error occurred`},failureDetection:{title:`AI Failure Detection`,description:`Monitor prints with a self-hosted Obico ML API and act on detected failures automatically.`,mlUrl:`Obico ML API URL`,mlUrlHint:`Base URL of your self-hosted Obico ml_api container (e.g. http://192.168.1.10:3333).`,test:`Test`,testSuccess:`ML API reachable and healthy.`,testFailed:`Could not reach the ML API.`,sensitivity:`Sensitivity`,sensitivityLow:`Low (fewer false positives)`,sensitivityMedium:`Medium (balanced)`,sensitivityHigh:`High (detect early, more false positives)`,sensitivityHint:`Adjusts the confidence thresholds that trigger warnings and failures.`,action:`Action on detected failure`,actionNotify:`Notify only`,actionPause:`Pause print`,actionPauseOff:`Pause and cut power`,pollInterval:`Poll interval (seconds)`,pollIntervalHint:`How often to check each printer while it is printing. Minimum 5s, maximum 120s.`,externalUrlMissing:`External URL is not set.`,externalUrlHint:`The ML API fetches the camera snapshot by URL. Set the External URL in General settings so the ML API container can reach Bambuddy.`,perPrinterTitle:`Monitored Printers`,perPrinterHint:`Choose which printers the detection service watches.`,monitorAll:`Monitor all connected printers`,statusTitle:`Status`,serviceRunning:`Service running`,thresholds:`Low / High thresholds`,activePrinters:`Active prints`,noActivePrints:`No prints currently running.`,historyTitle:`Recent Detections`,noHistory:`No detections yet.`},makerworld:{title:`MakerWorld`,description:`Paste a MakerWorld model URL to import and print it directly from Bambuddy — without leaving for the Bambu Handy app.`,pasteUrlHeader:`Import from MakerWorld`,pasteUrlPlaceholder:`https://makerworld.com/en/models/… or paste any MakerWorld link`,resolveButton:`Resolve`,signInRequiredTitle:`Bambu Cloud sign-in required to download`,signInRequiredBody:`You can browse model details anonymously, but MakerWorld requires a Bambu Cloud account to download 3MF files.`,openCloudSettings:`Open Cloud settings`,untitledModel:`Untitled model`,byCreator:`by {{name}}`,downloadsCount:`{{count}} downloads`,licensePrefix:`License`,alreadyImported:`Already in library`,openOnMakerworld:`Open on MakerWorld`,alreadyInLibrary:`This model is already in your library — find it in File Manager → MakerWorld`,importSuccess:`Imported {{filename}} — saved to File Manager → MakerWorld`,platesHeader:`Plates ({{count}})`,plateDefaultName:`Plate {{n}}`,materialCount:`{{count}} filaments`,amsRequired:`AMS required`,slicedFor:`Sliced for {{printer}}`,alsoCompatible:`Also marked compatible: {{printers}}`,importToLibrary:`Save`,sliceIn:`Save & Slice in {{slicer}}`,disclaimer:`MakerWorld integration uses community-documented API endpoints. Bambuddy is not affiliated with or endorsed by MakerWorld or Bambu Lab.`,lastImportSuccess:`Imported to your library`,lastImportAlreadyInLibrary:`Already in your library`,viewInLibrary:`View in File Manager`,openInBambuStudio:`Open in Bambu Studio`,openInOrcaSlicer:`Open in OrcaSlicer`,importTo:`Import to file manager`,recentImportsHeader:`Recent imports`,phaseResolving:`Resolving`,phaseDownloading:`Downloading`,folderAuto:`MakerWorld (default)`,importAll:`Import all`,importAllProgress:`Importing {{current}}/{{total}}`,openGallery:`Open image gallery`,galleryPrev:`Previous image`,galleryNext:`Next image`,deleteImport:`Remove from library`,importDeleting:`Removing…`,importDeleted:`Removed from library`,confirmDelete:`Remove {{filename}} from the library? This deletes the local file but the plate can be re-imported from MakerWorld.`,errors:{resolveFailed:`Could not resolve that MakerWorld URL.`,downloadFailed:`Download failed. Please try again.`,deleteFailed:`Could not remove the file from the library.`}},gcodeViewer:{back:`Back`,backToArchives:`Back to Print Archives`,backToFiles:`Back to File Manager`},libraryTrash:{title:`Trash`,headerButton:`Trash`,headerTooltip:`View files moved to the trash`,backToFiles:`Back to File Manager`,subtitleAdmin:`Deleted files stay here for {{days}} days, then auto-delete. This view shows trashed files for all users.`,subtitleUser:`Deleted files stay here for {{days}} days, then auto-delete.`,loading:`Loading trash…`,loadError:`Could not load the trash.`,empty:`The trash is empty.`,summary:`{{count}} files · {{size}}`,emptyTrash:`Empty trash`,restore:`Restore`,purgeNow:`Delete now`,autoPurgeIn:`Auto-deletes in {{when}}`,days:`days`,retentionLabel:`Auto-delete after`,selectAll:`Select all`,selectOne:`Select {{filename}}`,selectionCount:`{{count}} selected`,bulkRestore:`Restore selected`,bulkPurge:`Delete selected`,col:{filename:`File`,folder:`Folder`,size:`Size`,deleted:`Moved to trash`,autoPurge:`Auto-deletes`,owner:`Owner`,actions:`Actions`},confirm:{purgeTitle:`Delete permanently?`,purgeBody:`{{filename}} will be deleted from disk and cannot be restored.`,emptyTitle:`Empty the trash?`,emptyBody:`All {{count}} files will be deleted from disk. This cannot be undone.`,bulkPurgeTitle:`Delete selected files permanently?`,bulkPurgeBody:`The {{count}} selected files will be deleted from disk and cannot be restored.`,cta:`Delete permanently`},toast:{restored:`File restored.`,restoreFailed:`Could not restore the file.`,purged:`File deleted permanently.`,purgeFailed:`Could not delete the file.`,emptied:`Deleted {{count}} file(s) from trash.`,emptyFailed:`Could not empty the trash.`,retentionSaved:`Auto-delete set to {{days}} days.`,retentionFailed:`Could not save retention setting.`,bulkRestored:`Restored {{count}} file(s).`,bulkPurged:`Deleted {{count}} file(s).`}},libraryPurge:{title:`Purge old files`,headerButton:`Purge old`,headerTooltip:`Bulk-move old files to trash`,description:`Sweep old files out of your library in one shot. Files with a print history are aged by their last-printed date; files that were never printed are aged by their upload date.`,ageLabel:`Move files older than`,days:`days`,includeNeverPrinted:`Include files that have never been printed`,effectsTitle:`What happens when you click Purge`,effect1:`Matching files are moved to Trash — they are not deleted from disk yet.`,effect2:`You can restore them from Trash at any time until the retention window expires.`,effect3:`After retention, the trash sweeper permanently removes them from disk.`,effect4:`Files in external (linked) folders are skipped — Bambuddy never deletes bytes it does not own.`,previewLoading:`Checking how many files match…`,previewFailed:`Could not preview the purge.`,previewSummary:`{{count}} files · {{size}} would move to trash`,andMore:`…and {{count}} more`,warning:`Trashed files still count against storage until the retention window expires. Empty the Trash afterwards to free disk immediately.`,confirmCta:`Move {{count}} to trash`,purging:`Moving to trash…`,toast:{success:`Moved {{count}} file(s) to trash.`,failed:`Could not purge files.`}},libraryAutoPurge:{enableLabel:`Auto-purge old files`,enableDescription:`Runs the admin purge once per day. Files go to Trash first — they are not deleted immediately.`,ageLabel:`Auto-purge files older than`,ageDescription:`Minimum 7 days, maximum 10 years. Uses the same age rule as the manual Purge button.`,days:`days`,includeNeverPrinted:`Include files that have never been printed`,saveFailed:`Could not save auto-purge settings.`},archivePurge:{headerButton:`Purge old`,headerTooltip:`Bulk-delete old archives`,title:`Purge old archives`,description:`Clear out old print history. Each archive is aged by its most recent print completion — reprinting an archive refreshes its age, so active work is never purged.`,ageLabel:`Delete archives not printed in the last`,days:`days`,effectsTitle:`What happens when you click Purge`,effect1:`Each matching archive is hidden from the listings and its files are removed from disk (3MF, thumbnail, timelapse, source 3MF, F3D design file, photos).`,effect2:`The archive row stays in the database so Quick Stats keeps the filament, time, cost, and energy contribution — same as the single-archive delete default.`,effect3:`Tick "Also remove from statistics" below to drop the Quick Stats contribution too (matches the single-archive delete option). That path is irreversible.`,effect4:`Reprinting an archive refreshes its age clock, so archives you still use are safe.`,purgeStatsLabel:`Also remove from statistics`,purgeStatsHint:`Drops the matching archives from Quick Stats (filament, time, cost, energy). Without this, Quick Stats keeps every contribution and only the files leave disk.`,previewLoading:`Checking how many archives match…`,previewFailed:`Could not preview the purge.`,previewSummary:`{{count}} archives · {{size}} would be removed`,andMore:`…and {{count}} more`,warning:`Files are removed from disk and cannot be restored. Download or favourite anything you want to keep before continuing.`,confirmCta:`Remove {{count}} archive(s)`,purging:`Removing…`,toast:{success:`Removed {{count}} archive(s).`,failed:`Could not purge archives.`}},archiveAutoPurge:{enableLabel:`Auto-purge old archives`,enableDescription:`Once per day, hides archives from the listings and removes their files from disk when they have not been printed within the threshold. Reprinting an archive resets the clock.`,ageLabel:`Auto-delete archives not printed in the last`,ageDescription:`Minimum 7 days, maximum 10 years. Based on the most recent print completion — reprinting an archive refreshes its age. Removes the 3MF, thumbnail, timelapse, source 3MF, F3D, and photos.`,days:`days`,purgeStatsLabel:`Also remove from statistics`,purgeStatsDescription:`When enabled, the daily sweeper also drops each purged archive from Quick Stats (filament, time, cost, energy). Default off — Quick Stats keeps the contribution, only the files leave disk.`,runNow:`Purge archives now`,saveFailed:`Could not save auto-purge settings.`},cameraTokens:{title:`Camera API Tokens`,navTitle:`Camera API tokens`,description:`Long-lived tokens for embedding the camera stream into Home Assistant, Frigate, kiosks, or any other tool that needs a stable URL. Each token is camera-stream-only and can be revoked at any time.`,loading:`Loading…`,confirmRevoke:{title:`Revoke this token?`,body:`Any device using "{{name}}" will lose access immediately. This cannot be undone.`,cancel:`Cancel`,confirm:`Revoke`},create:{title:`Create new token`,nameLabel:`Token name`,namePlaceholder:`e.g. Home Assistant`,daysLabel:`Days until expiry`,submit:`Create`,hint:`Maximum lifetime is 365 days. The token value is shown only once on creation — copy it now.`},created:{title:`Token created — copy it now`,warning:`This is the only time this token will be visible. After you close this dialog you can never view it again.`,copy:`Copy`,dismiss:`I've saved it`},list:{myTitle:`My tokens`,allTitle:`All users (admin view)`,empty:`No tokens yet.`,name:`Name`,owner:`Owner`,prefix:`Prefix`,created:`Created`,expires:`Expires`,lastUsed:`Last used`,revoke:`Revoke`,expired:`Expired`},toast:{created:`Token created`,createFailed:`Failed to create token`,revoked:`Token revoked`,revokeFailed:`Failed to revoke token`,loadFailed:`Failed to load tokens`,copied:`Copied to clipboard`,copyFailed:`Copy failed — select and copy manually`}},forecast:{title:`Forecast`,noSpools:`No active spools found. Add spools to your inventory to see forecast data.`,noUsageData:`No usage data available — cannot project stock timeline.`,sku:`SKU`,material:`Material`,stock:`Stock`,dailyRate:`Rate`,daysLeft:`Days Left`,emptyBy:`Empty By`,reorderBy:`Reorder By`,actions:`Actions`,trend:`Trend`,estimated:`Est.`,noData:`No data`,timeframe:`Timeframe`,chartTitle:`Projected Stock — Top 5 Materials`,dashedLinesROP:`Dashed lines = reorder points`,stockLevel:`Stock Level`,reorderPoint:`Reorder Point`,safetyMargin:`Safety Margin`,trendLegend:`Trend (history-based, 95% service level)`,estimatedLegend:`Estimated (weight delta)`,noDataLegend:`No data`,ropLabel:`ROP`,ssLabel:`SS`,safetyStockLegend:`Safety stock`,stockArrivalLegend:`Stock arrival`,stockoutLegend:`Stockout`,alertCount_one:`{{count}} alert`,alertCount_other:`{{count}} alerts`,order:`Order`,save:`Save`,cancel:`Cancel`,settingsSaved:`Settings saved`,failedSaveSettings:`Failed to save settings`,globalLeadTimeSaved:`Global lead time saved`,globalLeadTime:`Global lead time`,globalLeadTimeHint:`Global lead time floor — used in reorder point calculation for all SKUs`,skuLeadTimeOverride:`SKU Lead Time Override`,skuLeadTimeHint:`0 = use global lead time. Set >0 to override for this SKU.`,safetyMarginLabel:`Safety Margin`,effectiveLeadTime:`Effective Lead Time`,effectiveLeadTimeHint:`max(global {{global}}d, SKU {{sku}}d)`,reorderPointHint:`d̄ × LT + safety margin — order when stock hits this level`,safetyMarginHint:`Statistical safety stock (z=1.65 × σ × √LT) + user-defined buffer`,safetyMarginHintDays:`Buffer added on top of statistical safety stock.{{approx}}`,safetyMarginHintDaysApprox:` ≈ {{g}}g at current rate.`,safetyMarginHintG:`Fixed weight buffer added on top of statistical safety stock.{{approx}}`,safetyMarginHintGApprox:` ≈ {{days}}d at current rate.`,individualSpools:`Individual spools`,labelWeight:`Label`,spoolCount_one:`{{count}} spool`,spoolCount_other:`{{count}} spools`,stockBreakRisk:`Stock break risk`,stockBreakDetail:`{{days}}d remaining, lead time {{lt}}d.`,stockBreakBefore:`Stock break before replenishment`,reorderNow:`Reorder now`,reorderTriggerPassed:`Trigger date {{date}} has passed.`,shoppingList:`Shopping List`,shoppingListItems_one:`({{count}} item)`,shoppingListItems_other:`({{count}} items)`,shoppingListEmpty:`Shopping list is empty. Click the cart icon on any row to add items.`,addToCart:`Add to shopping list`,alertsSnoozed:`Mute alerts for this SKU`,alertsEnabled:`Unmute alerts for this SKU`,addedToCart:`Added to shopping list`,failedAddItem:`Failed to add item`,listView:`List`,logisticsView:`Logistics`,qty:`Qty`,weight:`Weight`,leadTime:`Lead Time`,expectedRestock:`Expected Restock`,status:`Status`,note:`Note`,pending:`Pending`,purchased:`Purchased`,received:`Received`,markPurchased:`Mark as purchased`,markReceived:`Mark as received — adds spools to Stock inventory`,resetToPending:`Reset to pending`,remove:`Remove`,clearAll:`Clear all`,downloadCsv:`CSV`,addToCartTitle:`Add to Shopping List`,byQuantity:`By Quantity`,byDuration:`By Duration`,numberOfSpools:`Number of spools`,lastHowManyDays:`Should last how many days?`,noUsageQty:`No usage data — quantity set to 1.`,noteOptional:`Note (optional)`,notePlaceholder:`e.g. for project X, urgent…`,addNSpools_one:`Add {{count}} spool`,addNSpools_other:`Add {{count}} spools`,onArrival:`On Arrival`,stockBreakIn:`Stock break in {{days}}d.`,stockRunsOutBefore:`Stock runs out before the {{lt}}d lead time elapses.`,atRate:`At {{rate}}g/day you need`,moreSpools_one:`{{count}} more spool`,moreSpools_other:`{{count}} more spools`,bridgeGap:`to bridge the gap.`,noReadAccess:`You do not have permission to view inventory forecasts.`,noWriteAccess:`You do not have permission to modify forecast settings.`}}},de:{translation:{nav:{printers:`Drucker`,archives:`Archiv`,queue:`Druckwarteschlange`,stats:`Statistiken`,profiles:`Profile`,maintenance:`Wartung`,projects:`Projekte`,inventory:`Filament`,files:`Dateimanager`,makerworld:`MakerWorld`,notifications:`Benachrichtigungen`,settings:`Einstellungen`,system:`System`,collapseSidebar:`Seitenleiste einklappen`,expandSidebar:`Seitenleiste ausklappen`,update:`Aktualisieren`,updateAvailable:`Update verfügbar: v{{version}}`,updateAvailableBanner:`Version {{version}} ist verfügbar!`,viewUpdate:`Update anzeigen`,viewOnGithub:`Auf GitHub ansehen`,keyboardShortcuts:`Tastaturkürzel (?)`,switchToLight:`Zum hellen Modus wechseln`,switchToDark:`Zum dunklen Modus wechseln`,switchToSystem:`Zum Systemmodus wechseln`,smartSwitches:`Smart Switches`,logout:`Abmelden`,installApp:`App installieren`,installAppSuccess:`Bambuddy wurde installiert`},common:{save:`Speichern`,saving:`Speichern...`,cancel:`Abbrechen`,delete:`Löschen`,edit:`Bearbeiten`,add:`Hinzufügen`,close:`Schließen`,confirm:`Bestätigen`,loading:`Lädt...`,error:`Fehler`,errorLoading:`Fehler beim Laden`,retry:`Erneut versuchen`,success:`Erfolg`,warning:`Warnung`,enabled:`Aktiviert`,disabled:`Deaktiviert`,yes:`Ja`,no:`Nein`,on:`An`,off:`Aus`,all:`Alle`,none:`Keine`,search:`Suchen`,filter:`Filtern`,sort:`Sortieren`,refresh:`Aktualisieren`,download:`Herunterladen`,upload:`Hochladen`,uploading:`Hochladen...`,uploadFailed:`Hochladen fehlgeschlagen`,actions:`Aktionen`,status:`Status`,name:`Name`,description:`Beschreibung`,date:`Datum`,time:`Zeit`,hours:`Stunden`,minutes:`Minuten`,seconds:`Sekunden`,days:`Tage`,enable:`Aktivieren`,disable:`Deaktivieren`,permissions:`Berechtigungen`,noPrinters:`Keine Drucker konfiguriert`,noData:`Keine Daten verfügbar`,linkNotFound:`Link nicht gefunden`,required:`Erforderlich`,optional:`Optional`,dismiss:`Schließen`,apply:`Anwenden`,reset:`Zurücksetzen`,export:`Exportieren`,import:`Importieren`,clear:`Leeren`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,noChange:`— Keine Änderung —`,unchanged:`Unverändert`,unassigned:`Nicht zugewiesen`,unknown:`Unbekannt`,unknownError:`Unbekannter Fehler`,today:`Heute`,tomorrow:`Morgen`,asap:`Sofort`,overdue:`Überfällig`,now:`Jetzt`,collapse:`Einklappen`,expand:`Ausklappen`,viewArchive:`Archiv anzeigen`,viewInFileManager:`Im Dateimanager anzeigen`,addedBy:`Hinzugefügt von {{username}}`,prints:`Drucke`,more:`+{{count}} weitere`,ascending:`Aufsteigend`,descending:`Absteigend`,back:`Zurück`,copy:`Kopieren`,copied:`Kopiert!`,printer:`Drucker`,remove:`Entfernen`,type:`Typ`,print:`Drucken`,rename:`Umbenennen`,move:`Verschieben`,create:`Erstellen`,duplicate:`Duplizieren`,left:`Links`,right:`Rechts`},printers:{addPreflight:{checking:`Verbindung wird geprüft...`,warning:`Einige Verbindungsprüfungen sind fehlgeschlagen. Dieser Drucker wird möglicherweise als offline angezeigt. Prüfe die Punkte unten, behebe was möglich ist, oder speichere trotzdem.`,back:`Zurück`,saveAnyway:`Trotzdem speichern`},title:`Drucker`,addPrinter:`Drucker hinzufügen`,editPrinter:`Drucker bearbeiten`,deletePrinter:`Drucker löschen`,printerName:`Druckername`,serialNumber:`Seriennummer`,ipAddress:`IP-Adresse / Hostname`,accessCode:`Zugangscode`,model:`Modell`,nozzleCount:`Düsenanzahl`,autoArchive:`Automatische Archivierung`,status:{available:`Verfügbar`,idle:`Bereit`,printing:`Druckt`,paused:`Pausiert`,offline:`Offline`,problem:`Problem`,error:`Fehler`,finished:`Fertig`,unknown:`Unbekannt`},temperatures:{nozzle:`Düse`,bed:`Druckbett`,chamber:`Kammer`},heaterHistory:{title:`Heizungsverlauf`,openLabel:`Heizungsverlauf anzeigen`,nozzle:`Düse`,nozzle2:`Düse 2`,bed:`Druckbett`,chamber:`Kammer`,error:`Verlauf konnte nicht geladen werden`,empty:`Noch keine Daten aufgezeichnet`},progress:`{{percent}}% abgeschlossen`,timeRemaining:`Noch {{time}}`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,maintenanceOk:`Wartung OK`,maintenanceWarning:`{{count}} Warnung`,maintenanceWarning_plural:`{{count}} Warnungen`,maintenanceDue:`{{count}} fällig`,maintenanceDue_plural:`{{count}} fällig`,sort:{name:`Name`,status:`Status`,model:`Modell`,location:`Standort`,eta:`Restzeit`,ascending:`Aufsteigend sortieren`,descending:`Absteigend sortieren`},cardSize:{small:`Kleine Karten`,medium:`Mittlere Karten`,large:`Große Karten`,extraLarge:`Extra große Karten`},hideOffline:`Offline ausblenden`,nextAvailable:`Nächster verfügbar`,powerOn:`Einschalten`,offlinePrintersWithPlugs:`Offline-Drucker mit Smart-Plugs`,noPrintersConfigured:`Noch keine Drucker konfiguriert`,search:`Drucker suchen...`,noSearchResults:`Keine Drucker entsprechen deiner Suche oder deinen Filtern`,filter:{allStatuses:`Alle Status`,allLocations:`Alle Standorte`},toolbar:{filters:`Filter`,view:`Ansicht`,actions:`Aktionen`},readyToPrint:`Druckbereit`,external:`Extern`,extL:`Ext-L`,extR:`Ext-R`,deleteArchives:`Druckarchive löschen`,noLabel:`Keine Bezeichnung`,printPreview:`Druckvorschau`,width:`Breite`,height:`Höhe`,noObjectsFound:`Keine Objekte gefunden`,objectsLoadedOnPrintStart:`Objekte werden beim Druckstart geladen`,willBeSkipped:`Wird übersprungen`,name:`Name`,serialCannotBeChanged:`Seriennummer kann nicht geändert werden`,locationHelp:`Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen`,wifiSignal:{veryWeak:`Sehr schwach`,weak:`Schwach`,fair:`Ausreichend`,good:`Gut`,excellent:`Ausgezeichnet`},maintenanceUpToDate:`Alle Wartungen aktuell - Klicken zum Anzeigen`,maintenance:{title:`In Wartung`,subtitle:`Dieser Drucker ist pausiert — keine Verbindung, nicht für die Warteschlange verfügbar, keine Benachrichtigungen.`,pillLabel:`Wartung`,exitButton:`Wartung beenden`,menuEnter:`In den Wartungsmodus wechseln`,menuExit:`Wartungsmodus beenden`,toastEntered:`{{name}} ist jetzt im Wartungsmodus`,toastExited:`{{name}} ist wieder online`,confirmMidPrintTitle:`Wartungsmodus während des Drucks aktivieren?`,confirmMidPrintMessage:`{{name}} druckt gerade. Der Wartungsmodus trennt die MQTT-Verbindung und beendet das Fortschritts-Tracking sowie Abschlussbenachrichtigungen für diesen Auftrag. Fortfahren?`,editFieldLabel:`Wartungsmodus`,editFieldHelp:`Wenn aktiviert, ist dieser Drucker von MQTT, Warteschlangenversand und Benachrichtigungen pausiert — nützlich für Reparaturen, parallele Bambuddy-Installationen oder temporäre Außerbetriebnahme.`},chamberLightOn:`Kammerbeleuchtung einschalten`,chamberLightOff:`Kammerbeleuchtung ausschalten`,files:`Dateien`,browseFiles:`Druckerdateien durchsuchen`,autoOffAfterPrint:`Automatisches Ausschalten nach Druck`,autoOffExecuted:`Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen`,hmsErrors:`HMS-Fehler`,viewHmsErrors:`{{count}} HMS-Fehler anzeigen`,resume:`Fortsetzen`,pause:`Pausieren`,stop:`Stoppen`,camera:`Kamera`,skipObject:`Objekt überspringen`,reconnect:`Neu verbinden`,forceRefresh:`Aktualisierung erzwingen`,forceRefreshSuccess:`Aktualisierung angefordert`,mqttDebug:`MQTT-Debug`,printerInformation:`Druckerinformationen`,copyToClipboard:`Kopieren`,copied:`Kopiert!`,state:`Zustand`,wifiSignalLabel:`WLAN-Signal`,developerMode:`Entwicklermodus`,enabled:`Aktiviert`,disabled:`Deaktiviert`,addedOn:`Hinzugefügt`,sdCard:`SD-Karte`,inserted:`Eingelegt`,notInserted:`Nicht eingelegt`,totalPrintHours:`Druckstunden`,activeNozzle:`Aktiv: {{nozzle}} Düse`,nozzleRack:`Düsenhalter`,nozzleDocked:`Angedockt`,nozzleMounted:`Montiert`,nozzleActive:`Aktiv`,nozzleIdle:`Inaktiv`,nozzleDiameter:`Durchmesser`,nozzleType:`Typ`,nozzleStatus:`Status`,nozzleFilament:`Filament`,nozzleWear:`Verschleiß`,nozzleMaxTemp:`Max. Temp`,nozzleSerial:`Seriennr.`,nozzleHardenedSteel:`Gehärteter Stahl`,nozzleStainlessSteel:`Edelstahl`,nozzleTungstenCarbide:`Wolframkarbid`,nozzleFlow:`Durchfluss`,nozzleHighFlow:`Hoher Durchfluss`,nozzleStandardFlow:`Standard`,firmwareUpdate:`Firmware-Update`,firmwareInstructions:`Gehen Sie auf dem Touchscreen des Druckers zu`,firmwareNav:`Navigieren Sie zu`,settings:`Einstellungen`,firmware:`Firmware`,discoverPrinters:`Drucker entdecken`,searching:`Suche...`,manualEntry:`Manuelle Eingabe`,addFromCloud:`Aus Cloud hinzufügen`,toast:{printerDeleted:`Drucker gelöscht`,missingSpoolAssignment:`Druck gestartet auf {{printer}}. Fehlende Spulenzuordnung für: {{slots}}`,printerAdded:`Drucker hinzugefügt`,printerUpdated:`Drucker aktualisiert`,failedToDelete:`Drucker konnte nicht gelöscht werden`,failedToAdd:`Drucker konnte nicht hinzugefügt werden`,connectionFailedNotAdded:`Keine Verbindung zum Drucker möglich. Prüfen Sie IP-Adresse, Seriennummer und Zugangscode und stellen Sie sicher, dass der Nur-LAN-Modus aktiv ist. Der Drucker wurde nicht hinzugefügt.`,failedToUpdate:`Drucker konnte nicht aktualisiert werden`,commandSent:`Befehl gesendet`,failedToSendCommand:`Befehl konnte nicht gesendet werden`,turnedOn:`{{name}} eingeschaltet`,failedToPowerOn:`{{name}} konnte nicht eingeschaltet werden`,scriptTriggered:`Skript ausgelöst`,printStopped:`Druck gestoppt`,printPaused:`Druck pausiert`,printResumed:`Druck fortgesetzt`,referenceDeleted:`Referenz gelöscht`,detectionAreaSaved:`Erkennungsbereich gespeichert`,failedToRunScript:`Skript konnte nicht ausgeführt werden`,failedToStopPrint:`Druck konnte nicht gestoppt werden`,failedToPausePrint:`Druck konnte nicht pausiert werden`,failedToResumePrint:`Druck konnte nicht fortgesetzt werden`,failedToControlChamberLight:`Kammerbeleuchtung konnte nicht gesteuert werden`,failedToSetSpeed:`Druckgeschwindigkeit konnte nicht eingestellt werden`,failedToUpdateSetting:`Einstellung konnte nicht aktualisiert werden`,failedToSkipObjects:`Objekte konnten nicht übersprungen werden`,failedToRereadRfid:`RFID konnte nicht erneut gelesen werden`,failedToCheckPlate:`Platte konnte nicht überprüft werden`,failedToUpdateLabel:`Bezeichnung konnte nicht aktualisiert werden`,failedToDeleteReference:`Referenz konnte nicht gelöscht werden`,failedToSaveDetectionArea:`Erkennungsbereich konnte nicht gespeichert werden`,plateCheckEnabled:`Plattenprüfung aktiviert`,plateCheckDisabled:`Plattenprüfung deaktiviert`,calibrationSaved:`Kalibrierung gespeichert!`,calibrationFailed:`Kalibrierung fehlgeschlagen`,rfidRereadInitiated:`RFID-Neueinlesen gestartet`,loadInitiated:`Filament wird geladen…`,unloadInitiated:`Filament wird entladen…`,failedToLoad:`Filament konnte nicht geladen werden`,failedToUnload:`Filament konnte nicht entladen werden`},connection:{connected:`Verbunden`,offline:`Offline`},plateStatus:{markCleared:`Platte als freigegeben markieren`,cleared:`Platte freigegeben`,notCleared:`Platte nicht freigegeben`,inUse:`Platte in Benutzung`},queue:{inQueue:`{{count}} Druck in Warteschlange`,inQueue_plural:`{{count}} Drucke in Warteschlange`},controls:`Steuerung`,rfid:{reread:`RFID neu lesen`},ams:{load:`Laden`,unload:`Entladen`},bedJog:{title:`Jog-Steuerung`,bed:`Bett`,step:`Schritt (mm)`,up:`Platte hoch`,down:`Platte runter`,disabledWhilePrinting:`Während des Drucks deaktiviert`,notHomedTitle:`Drucker ist nicht referenziert`,notHomedMessage:`Der Drucker wurde seit dem letzten Druck nicht referenziert. Führen Sie zuerst die automatische Referenzfahrt aus (parkt den Werkzeugkopf und referenziert dann X, Y und Z) oder bewegen Sie trotzdem — die Software-Endschalter werden dabei umgangen.`,homeZ:`Automatische Referenzfahrt`,moveAnyway:`Trotzdem bewegen`,homingStarted:`Drucker wird automatisch referenziert…`},permission:{noAdd:`Sie haben keine Berechtigung, Drucker hinzuzufügen`,noEdit:`Sie haben keine Berechtigung, Drucker zu bearbeiten`,noDelete:`Sie haben keine Berechtigung, Drucker zu löschen`,noControl:`Sie haben keine Berechtigung, Drucker zu steuern`,noFiles:`Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen`,noAmsRfid:`Sie haben keine Berechtigung, AMS-RFID erneut zu lesen`,noSmartPlugControl:`Sie haben keine Berechtigung, Smart Plugs zu steuern`,noCamera:`Sie haben keine Berechtigung, Kameras anzuzeigen`},modal:{addTitle:`Drucker hinzufügen`,editTitle:`Drucker bearbeiten`,myPrinter:`Mein Drucker`,selectModel:`Modell auswählen...`,locationGroup:`Standort / Gruppe (optional)`,locationPlaceholder:`z.B. Werkstatt, Büro, Keller`,autoArchiveLabel:`Abgeschlossene Drucke automatisch archivieren`,fromPrinterSettings:`Aus Druckereinstellungen`,modelOptional:`Modell (optional)`,saveChanges:`Änderungen speichern`},skipObjects:{tooltip:`Objekte überspringen`,onlyWhilePrinting:`Objekte überspringen (nur während des Drucks)`,requiresMultiple:`Objekte überspringen (erfordert 2+ Objekte)`,title:`Objekte überspringen`,matchIdsInfo:`IDs mit Drucker-Display abgleichen`,printerShowsIds:`Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte`,skipSelected:`Ausgewählte überspringen`,skipping:`Überspringe...`,noObjectsSelected:`Keine Objekte ausgewählt`,selectObjectsToSkip:`Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten`,skipped:`übersprungen`,objectsSkipped:`Objekte übersprungen`,activeCount:`{{count}} aktiv`,waitForLayer:`Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})`,skip:`Überspringen`,confirmTitle:`Objekt überspringen?`,confirmMessage:`Möchten Sie "{{name}}" wirklich überspringen? Dies kann nicht rückgängig gemacht werden.`},confirm:{deleteTitle:`Drucker löschen`,deleteMessage:`Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.`,deleteArchivesNote:`Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.`,keepArchivesNote:`Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.`,stopTitle:`Druck stoppen`,stopMessage:`Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.`,stopButton:`Druck stoppen`,pauseTitle:`Druck pausieren`,pauseMessage:`Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?`,pauseButton:`Druck pausieren`,resumeTitle:`Druck fortsetzen`,resumeMessage:`Möchten Sie den Druck auf "{{name}}" fortsetzen?`,resumeButton:`Druck fortsetzen`,powerOnTitle:`Drucker einschalten`,powerOnMessage:`Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?`,powerOnButton:`Einschalten`,powerOffTitle:`Drucker ausschalten`,powerOffMessage:`Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?`,powerOffWarning:`WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.`,powerOffButton:`Ausschalten`,haToggleTitle:`"{{name}}" umschalten`,haToggleMessage:`Home-Assistant-Entität {{entity}} umschalten? Das kann die Stromversorgung ausschalten, falls sie gerade an ist.`,haToggleWarning:`WARNUNG: "{{name}}" druckt gerade! Umschalten von {{entity}} kann die Stromversorgung trennen und den Druck abbrechen. Fortfahren?`,haToggleButton:`Umschalten`},bulk:{select:`Auswählen`,selectAll:`Alle auswählen`,selectByLocation:`Nach Standort auswählen`,selected:`{{count}} ausgewählt`,actions:{stop:`Stoppen`,pause:`Pausieren`,resume:`Fortsetzen`,clearPlate:`Druckbett leeren`,clearHMS:`Benachrichtigungen löschen`},confirm:{stopTitle:`{{count}} Drucke stoppen`,stopMessage:`Dies wird aktive Drucke auf {{count}} Drucker(n) abbrechen. Diese Aktion kann nicht rückgängig gemacht werden.`,stopButton:`Alle stoppen`,pauseTitle:`{{count}} Drucke pausieren`,pauseMessage:`Dies wird aktive Drucke auf {{count}} Drucker(n) pausieren.`,pauseButton:`Alle pausieren`,clearPlateTitle:`{{count}} Druckbetten leeren`,clearPlateMessage:`Dies wird das Druckbett auf {{count}} Drucker(n) leeren und kann wartende Aufträge starten.`,clearPlateButton:`Alle leeren`},success:`{{action}} auf {{count}} Drucker(n) abgeschlossen`,partial:`{{succeeded}} erfolgreich, {{failed}} fehlgeschlagen`,noneApplicable:`Keine ausgewählten Drucker sind im richtigen Zustand für diese Aktion`,selectByState:`Nach Status auswählen`},discovery:{title:`Drucker entdecken`,searching:`Suche...`,scanning:`Scanne...`,scanProgress:`Scanne... {{scanned}}/{{total}}`,foundPrinters:`{{count}} Drucker gefunden`,noPrintersFound:`Keine Drucker gefunden`,noPrintersFoundSubnet:`Keine Drucker im angegebenen Subnetz gefunden.`,noPrintersFoundNetwork:`Keine Drucker im Netzwerk gefunden.`,allConfigured:`Alle erkannten Drucker sind bereits konfiguriert.`,alreadyAdded:`Bereits hinzugefügt`,select:`Auswählen`,manualEntry:`Manuelle Eingabe`,addFromCloud:`Aus Cloud hinzufügen`,subnetToScan:`Zu scannendes Subnetz`,dockerNote:`Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.`,scanSubnet:`Subnetz nach Druckern scannen`,discoverNetwork:`Drucker im Netzwerk suchen`,scanningSubnet:`Subnetz wird nach Bambu-Druckern gescannt...`,scanningNetwork:`Netzwerk wird gescannt...`,serialRequired:`Seriennummer erforderlich`,unknown:`Unbekannt`,failedToStart:`Erkennung konnte nicht gestartet werden`,customSubnetOption:`Eigenes Subnetz...`,customSubnetLabel:`Eigenes Subnetz (CIDR)`,customSubnetNote:`Wähle ein eigenes Subnetz, wenn dein Drucker in einem anderen Netzwerk als dieser Server steht. Die Ports FTP (990) und MQTT (8883) müssen über die Routinggrenze erreichbar sein.`},drying:{start:`Trocknung starten`,stop:`Trocknung stoppen`,temperature:`Temperatur`,duration:`Dauer`,hours:`Stunden`,timeRemaining:`{{time}} verbleibend`,active:`Trocknung`,notSupported:`Trocknung nicht unterstützt`,powerRequired:`AMS-Netzteil anschließen, um Trocknung zu aktivieren`,startingDrying:`Trocknung wird gestartet...`,stoppingDrying:`Trocknung wird gestoppt...`,rotateTray:`Spule während der Trocknung drehen`},amsBackup:{titleOn:`AMS Filament Backup ist EIN. Zum Deaktivieren klicken.`,titleOff:`AMS Filament Backup ist AUS. Zum Aktivieren klicken.`,titleUnknown:`AMS-Filament-Backup-Status auf diesem Drucker nicht verfügbar.`,toastEnabled:`AMS Filament Backup aktiviert`,toastDisabled:`AMS Filament Backup deaktiviert`,modalTitle:`AMS Filament Backup`,modalHelp:`Wenn der aktive Slot leer wird, wechselt der Drucker in dieser Reihenfolge zu Slots mit demselben Preset und derselben Farbe.`,modalNoSlots:`Kein Filament geladen.`,modalNoPairs:`Keine Backup-Paare — keine zwei Slots teilen sich Filament-Preset und Farbe.`,extruderRightShort:`R`,extruderLeftShort:`L`,stateOn:`Aktiviert`,stateOff:`Deaktiviert`,stateUnknown:`Auf diesem Drucker nicht unterstützt`},activeJobSlot:{title:`Dieser Slot ist Filament {{n}} im aktiven Druck`,ariaLabel:`Aktiver Druck-Slot {{n}}`},filaments:`Filamente`,openCameraOverlay:`Kamera-Overlay öffnen`,openCameraWindow:`Kamera in neuem Fenster öffnen`,firmwareUpdateAvailable:`Firmware-Update verfügbar: {{current}} → {{latest}}`,firmwareUpToDate:`Firmware {{version}} — Aktuell`,firmwareUpdateButton:`Aktualisieren`,plateDetection:{noPermission:`Sie haben keine Berechtigung, Drucker zu aktualisieren`,enabledClick:`Plattenprüfung aktiviert - Klicken zum Deaktivieren`,disabledClick:`Plattenprüfung deaktiviert - Klicken zum Aktivieren`,manageCalibration:`Platten-Erkennungskalibrierung verwalten`,calibrationRequired:`Kalibrierung erforderlich`,calibrationInstructions:`Bitte stellen Sie sicher, dass die Druckplatte vollständig leer ist, und klicken Sie dann auf Kalibrieren.`,calibrationDescription:`Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.`,calibrationTip:`Tipp: Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.`,plateEmpty:`Platte erscheint leer`,objectsDetected:`Objekte auf Platte erkannt`,confidence:`Konfidenz`,difference:`Differenz`,analysisPreview:`Analysevorschau:`,analysisLegend:`Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung`,savedReferences:`Gespeicherte Referenzen ({{count}}/{{max}})`,deleteReference:`Referenz löschen`,labelPlaceholder:`Bezeichnung...`,clickToEdit:`{{label}} - Zum Bearbeiten klicken`,clickToAddLabel:`Zum Hinzufügen einer Bezeichnung klicken`},speed:{title:`Druckgeschwindigkeit`,silent:`Leise (50%)`,standard:`Standard (100%)`,sport:`Sport (124%)`,ludicrous:`Ludicrous (166%)`},airduct:{title:`Luftkanal-Modus`,cooling:`Kühlen`,heating:`Heizen`},noSdCard:`Keine SD`,door:{open:`Offen`,closed:`Zu`},fans:{partCooling:`Bauteilkühlung`,auxiliary:`Hilfsventilator`,chamber:`Kammerventilator`},clickToViewHmsErrors:`Klicken, um HMS-Fehler anzuzeigen`,estimatedCompletion:`Geschätzte Fertigstellungszeit`,plateNumber:`Platte {{number}}`,slotOptions:`Slot-Optionen`,amsPopup:{friendlyName:`AMS-Name`,friendlyNamePlaceholder:`z. B. AMS-Anzeigename`,serialNumber:`Seriennummer`,firmwareVersion:`Firmware`,save:`Speichern`,clear:`Löschen`,noEditPermission:`Sie haben keine Berechtigung, AMS-Einheiten umzubenennen`},firmwareModal:{title:`Firmware-Update`,titleUpToDate:`Firmware-Info`,currentVersion:`Aktuell:`,latestVersion:`Neueste:`,releaseNotes:`Versionshinweise`,checkingPrereqs:`Prüfe Voraussetzungen...`,sdCardReady:`SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.`,uploadedSuccess:`Firmware auf SD-Karte hochgeladen!`,applyInstructions:`So wenden Sie das Update auf Ihrem Drucker an:`,step1:`Gehen Sie auf dem Touchscreen des Druckers zu Einstellungen`,step2:`Navigieren Sie zu Firmware`,step3:`Wählen Sie Update von SD-Karte`,step4:`Das Update dauert 10-20 Minuten`,done:`Fertig`,starting:`Starte...`,uploadFirmware:`Firmware hochladen`,uploadFailed:`Upload fehlgeschlagen: {{error}}`,uploadedToast:`Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm.`,availableVersions:`Verfügbare Versionen`,usable:`Installierbar`,unavailable:`Nicht verfügbar`,installed:`Installiert`,newerBadge:`neuer`,olderBadge:`älter`,currentBadge:`aktuell`},accessCodePlaceholder:`Leer lassen, um den aktuellen zu behalten`,roi:{title:`Erkennungsbereich (ROI)`,xStart:`X-Start`,yStart:`Y-Start`,width:`Breite`,height:`Höhe`,instruction:`Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich.`},developerModeWarning:`Der Entwickler-LAN-Modus ist nicht aktiviert auf: {{names}}. Einige Funktionen funktionieren möglicherweise nicht.`,howToEnable:`Aktivieren`,incompatibleFile:`Diese Datei wurde für {{slicedFor}} geslicet, aber dieser Drucker ist ein {{printerModel}}`,dropNotPrintable:`Nur .gcode- und .gcode.3mf-Dateien können gedruckt werden`,dropToPrint:`Zum Drucken ablegen`,cannotPrint:`Drucker beschäftigt`},archives:{title:`Druckarchiv`,no3mfBanner:{title:`Einige kürzliche Drucke konnten nicht mit Vorschaubild archiviert werden`,body:`Der Slicer hat die .gcode.3mf-Datei nicht auf der SD-Karte des Druckers hinterlegt, daher konnte Bambuddy weder Vorschaubild noch Slicer-Metadaten abrufen. Üblicherweise liegt das daran, dass "Gesendete Dateien auf externem Speicher speichern" im Slicer (Geräte-Tab in Bambu Studio / OrcaSlicer) deaktiviert ist.`,docsLink:`Installationsschritt 4 anzeigen`,dismissLabel:`Hinweis schließen`},searchPlaceholder:`Archiv durchsuchen...`,filterByPrinter:`Nach Drucker filtern`,filterByStatus:`Nach Status filtern`,sortBy:`Sortieren nach`,sortNewest:`Neueste zuerst`,sortOldest:`Älteste zuerst`,sortName:`Name`,sortDuration:`Dauer`,sortLargest:`Größte zuerst`,sortSmallest:`Kleinste zuerst`,sortSize:`Größe`,noArchives:`Keine Archive gefunden`,noArchivesSearch:`Keine Archive entsprechen Ihrer Suche`,originalPrintNotVisible:`Ursprünglicher Druck nicht sichtbar - versuchen Sie, die Filter zu löschen`,noArchivesYet:`Noch keine Archive`,prints:`Drucke`,pagination:{showing:`Zeige`,to:`bis`,of:`von`,show:`Zeige`,page:`Seite`,all:`Alle`},loadingArchives:`Lade Archive...`,releaseToUpload:`Loslassen zum Hochladen`,showAll:`Alle anzeigen`,showFavoritesOnly:`Nur Favoriten anzeigen`,gridView:`Rasteransicht`,listView:`Listenansicht`,calendarView:`Kalenderansicht`,logView:`Druckprotokoll`,manageTags:`Tags verwalten`,showFailedPrints:`Fehlgeschlagene Drucke anzeigen`,hideFailedPrints:`Fehlgeschlagene Drucke ausblenden`,hideDuplicates:`Duplikate ausblenden`,viewOriginalPrint:`Klicken, um den ursprünglichen Druck anzuzeigen (#{{id}})`,printTime:`Druckzeit`,filamentUsed:`Verbrauchtes Filament`,cost:`Kosten`,reprint:`Drucken`,preview:`Vorschau`,deleteArchive:`Archiv löschen`,deleteConfirm:`Möchten Sie dieses Archiv wirklich löschen?`,favorite:`Favorit`,unfavorite:`Aus Favoriten entfernen`,viewDetails:`Details anzeigen`,status:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,stopped:`Gestoppt`},toast:{source3mfAttached:`Quell-3MF angehängt: {{filename}}`,failedUploadSource3mf:`Fehler beim Hochladen der Quell-3MF`,source3mfRemoved:`Quell-3MF entfernt`,failedRemoveSource3mf:`Fehler beim Entfernen der Quell-3MF`,f3dAttached:`F3D angehängt: {{filename}}`,failedUploadF3d:`Fehler beim Hochladen der F3D`,f3dRemoved:`F3D entfernt`,failedRemoveF3d:`Fehler beim Entfernen der F3D`,timelapseAttached:`Zeitraffer angehängt: {{filename}}`,timelapseAlreadyAttached:`Zeitraffer bereits angehängt`,noMatchingTimelapse:`Kein passender Zeitraffer gefunden`,failedScanTimelapse:`Fehler beim Suchen nach Zeitraffer`,failedAttachTimelapse:`Fehler beim Anhängen des Zeitraffers`,timelapseRemoved:`Zeitraffer entfernt`,failedRemoveTimelapse:`Fehler beim Entfernen des Zeitraffers`,timelapseUploaded:`Zeitraffer hochgeladen: {{filename}}`,failedUploadTimelapse:`Fehler beim Hochladen des Zeitraffers`,archiveDeleted:`Archiv gelöscht`,failedDeleteArchive:`Fehler beim Löschen des Archivs`,addedToFavorites:`Zu Favoriten hinzugefügt`,removedFromFavorites:`Aus Favoriten entfernt`,projectUpdated:`Projekt aktualisiert`,failedUpdateProject:`Fehler beim Aktualisieren des Projekts`,linkCopied:`Link in die Zwischenablage kopiert`,failedCopyLink:`Fehler beim Kopieren des Links`,photoDeleted:`Foto gelöscht`,failedDeletePhoto:`Fehler beim Löschen des Fotos`,failedDeleteArchives:`Fehler beim Löschen der Archive`,failedUpdateFavorites:`Fehler beim Aktualisieren der Favoriten`,exportDownloaded:`Export heruntergeladen`,exportFailed:`Export fehlgeschlagen`},menu:{print:`Drucken`,schedule:`Planen`,openInBambuStudio:`Im Slicer öffnen`,slice:`Slicen`,externalLink:`Externer Link`,viewOnMakerWorld:`Auf MakerWorld ansehen`,preview3d:`3D-Vorschau`,viewTimelapse:`Zeitraffer ansehen`,scanForTimelapse:`Nach Zeitraffer suchen`,uploadTimelapse:`Zeitraffer hochladen`,removeTimelapse:`Zeitraffer entfernen`,downloadSource3mf:`Quell-3MF herunterladen`,uploadSource3mf:`Quell-3MF hochladen`,replaceSource3mf:`Quell-3MF ersetzen`,removeSource3mf:`Quell-3MF entfernen`,uploadF3d:`F3D hochladen`,replaceF3d:`F3D ersetzen`,downloadF3d:`F3D herunterladen`,removeF3d:`F3D entfernen`,download:`Herunterladen`,copyDownloadLink:`Download-Link kopieren`,qrCode:`QR-Code`,viewPhotos:`Fotos ansehen`,viewPhotosCount:`Fotos ansehen ({{count}})`,projectPage:`Projektseite`,addToFavorites:`Zu Favoriten hinzufügen`,removeFromFavorites:`Aus Favoriten entfernen`,edit:`Bearbeiten`,printLog:`Druckprotokoll`,goToProject:`Zum Projekt: {{name}}`,addToProject:`Zu Projekt hinzufügen`,removeFromProject:`Aus Projekt entfernen`,loading:`Laden...`,noProjectsAvailable:`Keine Projekte verfügbar`,searchProjects:`Projekte suchen…`,select:`Auswählen`,deselect:`Abwählen`,delete:`Löschen`},permission:{noReprint:`Sie haben keine Berechtigung, dieses Archiv erneut zu drucken`,noAddToQueue:`Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen`,noUpdateArchives:`Sie haben keine Berechtigung, Archive zu aktualisieren`,noUploadFiles:`Sie haben keine Berechtigung, Dateien hochzuladen`,noDownload:`Sie haben keine Berechtigung, Archive herunterzuladen`,noCopyLink:`Sie haben keine Berechtigung, Download-Links zu kopieren`,noDelete:`Sie haben keine Berechtigung, dieses Archiv zu löschen`,noEdit:`Sie haben keine Berechtigung, diesen Eintrag zu bearbeiten`,noCreate:`Sie haben keine Berechtigung, Archive zu erstellen`},platePicker:{title:`Platte zur Vorschau auswählen`,hint:`Dieses Archiv enthält mehrere Platten. Wähle eine, um sie im GCode-Viewer zu öffnen.`,plateLabel:`Platte {{index}}`,objectCount:`{{count}} Objekt`,objectCount_plural:`{{count}} Objekte`,noGcode:`Dieses Archiv enthält keinen geschnittenen G-Code zur Vorschau. Öffne es zuerst in Bambu Studio zum Slicen.`},card:{previousPlate:`Vorherige Platte`,nextPlate:`Nächste Platte`,plateNumber:`Platte {{index}}`,moreOptions:`Rechtsklick für mehr Optionen`,addToFavorites:`Zu Favoriten hinzufügen`,removeFromFavorites:`Aus Favoriten entfernen`,cancelled:`abgebrochen`,failed:`fehlgeschlagen`,duplicate:`Duplikat`,duplicateTitle:`Dieses Modell wurde bereits zuvor gedruckt`,openSource3mf:`Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)`,downloadF3d:`Fusion 360 Designdatei herunterladen`,viewTimelapse:`Zeitraffer ansehen`,viewPhoto:`1 Foto ansehen`,viewPhotos:`{{count}} Fotos ansehen`,openFolder:`Ordner öffnen: {{name}}`,slicedFile:`Geslicte Datei - druckbereit`,sourceFile:`Nur Quelldatei - keine AMS-Zuordnung verfügbar`,gcode:`GCODE`,source:`QUELLE`,project:`Projekt: {{name}}`,runsBadge:`{{count}} Drucke`,runsBadgeTitle:`Insgesamt {{count}} Drucke — {{successful}} erfolgreich, {{failed}} fehlgeschlagen. Klicken, um das vollständige Druckprotokoll zu öffnen.`,estimated:`Geschätzt: {{time}}`,actual:`Tatsächlich: {{time}}`,accuracy:`Genauigkeit: {{percent}}%`,filament:`{{weight}} g`,layer:`{{count}} Schicht`,layers:`{{count}} Schichten`,object:`{{count}} Objekt`,objects:`{{count}} Objekte`,slicedFor:`Geslict für {{model}}`,uploadedBy:`Hochgeladen von`,noPermissionReprint:`Sie haben keine Berechtigung, erneut zu drucken`,noFileForReprint:`Keine 3MF-Datei verfügbar — die Datei konnte beim Aufzeichnen des Drucks nicht vom Drucker heruntergeladen werden`,noPermissionEdit:`Sie haben keine Berechtigung, Archive zu bearbeiten`,noPermissionDelete:`Sie haben keine Berechtigung, Archive zu löschen`,reprint:`Drucken`,schedulePrint:`Druck planen`,schedule:`Planen`,openInBambuStudio:`Im Slicer öffnen`,openInBambuStudioToSlice:`Im Slicer öffnen zum Slicen`,slice:`Slicen`,externalLink:`Externer Link`,makerWorld:`MakerWorld – {{designer}}`,viewProject:`Projekt ansehen`,noExternalLink:`Kein externer Link`,preview3d:`3D-Vorschau`,download:`Herunterladen`,edit:`Bearbeiten`,delete:`Löschen`},runLog:{title:`Druckprotokoll`,modalTitle:`Druckprotokoll — {{name}}`,modalTitleFallback:`dieses Archiv`,empty:`Für dieses Archiv wurden noch keine Druckereignisse aufgezeichnet.`,col:{date:`Datum`,status:`Status`,duration:`Dauer`,filament:`Filament`,cost:`Kosten`},status:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,cancelled:`Abgebrochen`,stopped:`Gestoppt`,skipped:`Übersprungen`,printing:`Druckt`}},modal:{deleteArchive:`Archiv löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleteButton:`Löschen`,deletePurgeStats:`Diesen Druck auch aus den Quick Stats entfernen (Filament, Zeit, Kosten, Energie)`,deleteQueueItemsWarning:`{{count}} mit diesem Archiv verknüpfte Warteschlangeneinträge werden ebenfalls entfernt.`,deleteBlockedByPrinting:`Löschen nicht möglich — {{count}} Warteschlangeneinträge werden derzeit gedruckt. Druck zuerst stoppen und erneut versuchen.`,removeSource3mf:`Quell-3MF entfernen`,removeSource3mfConfirm:`Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.`,removeButton:`Entfernen`,removeF3d:`F3D entfernen`,removeF3dConfirm:`Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?`,removeTimelapse:`Zeitraffer entfernen`,removeTimelapseConfirm:`Möchten Sie das Zeitraffervideo wirklich von "{{name}}" entfernen?`,timelapse:`{{name}} - Zeitraffer`,selectTimelapse:`Zeitraffer auswählen`,selectTimelapseDesc:`Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:`,deleteArchives:`Archive löschen`,deleteArchivesConfirm:`Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleteCount:`{{count}} löschen`},page:{title:`Archive`,printsCount:`{{filtered}} von {{total}} Drucken`,dropFilesHere:`.3mf-Dateien hier ablegen`,releaseToUpload:`Loslassen zum Hochladen`,only3mfSupported:`Nur .3mf-Dateien werden unterstützt`,close:`Schließen`,selected:`{{count}} ausgewählt`,selectAll:`Alle auswählen`,tags:`Tags`,project:`Projekt`,favorite:`Favorit`,delete:`Löschen`,toggledFavorites:`Favoriten für {{count}} Archiv(e) umgeschaltet`,failedUpdateFavorites:`Fehler beim Aktualisieren der Favoriten`,archivesDeleted:`{{count}} Archiv(e) gelöscht`,failedDeleteArchives:`Fehler beim Löschen der Archive`,photoDeleted:`Foto gelöscht`,failedDeletePhoto:`Fehler beim Löschen des Fotos`},list:{name:`Name`,printer:`Drucker`,date:`Datum`,size:`Größe`,actions:`Aktionen`,hasTimelapse:`Hat Zeitraffer`},log:{date:`Datum`,printName:`Druckname`,printer:`Drucker`,user:`Benutzer`,status:`Status`,duration:`Dauer`,filament:`Filament`,allPrinters:`Alle Drucker`,allUsers:`Alle Benutzer`,allStatuses:`Alle Status`,cancelled:`Abgebrochen`,skipped:`Übersprungen`,dateFrom:`Von`,dateTo:`Bis`,noEntries:`Keine Druckprotokolleinträge gefunden`,showing:`{{count}} von {{total}} Einträgen`,rowsPerPage:`Zeilen`,page:`Seite`,prev:`Zurück`,next:`Weiter`,clearLog:`Protokoll löschen`,clearLogTitle:`Druckprotokoll löschen`,clearLogConfirm:`Alle Druckprotokolleinträge werden dauerhaft gelöscht. Archive und Warteschlangeneinträge sind nicht betroffen. Diese Aktion kann nicht rückgängig gemacht werden. Sind Sie sicher?`,clearLogButton:`Alle löschen`,cleared:`{{count}} Protokolleinträge gelöscht`,clearFailed:`Druckprotokoll konnte nicht gelöscht werden`,deleteEntryTitle:`Druckprotokoll-Eintrag löschen`,deleteEntryConfirm:`Dieser Eintrag wird aus dem Protokoll entfernt und sein Filament-, Zeit- und Kostenbeitrag verschwindet aus den Schnellstatistiken. Das zugehörige Archiv (falls vorhanden) ist nicht betroffen. Diese Aktion kann nicht rückgängig gemacht werden.`,entryDeleted:`Druckprotokoll-Eintrag gelöscht`,entryDeleteFailed:`Druckprotokoll-Eintrag konnte nicht gelöscht werden`,editEntryTitle:`Druckprotokoll-Eintrag bearbeiten`,editEntryDescription:`Diesen Druckdurchlauf klassifizieren. Das Fehleranalyse-Widget gruppiert nach diesen Werten, sodass Aktualisierungen sofort in die Statistik einfließen.`,entryUpdated:`Druckprotokoll-Eintrag aktualisiert`,entryUpdateFailed:`Druckprotokoll-Eintrag konnte nicht aktualisiert werden`,statuses:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,stopped:`Gestoppt`,cancelled:`Abgebrochen`,skipped:`Übersprungen`}}},queue:{filamentShort:{rowBadge:`Filament fuer die zugewiesene Spule reicht nicht`,rowTooltip:`Der Dispatcher hat diese Position markiert. Klicke auf Play, um den Pro-Slot-Fehlbestand zu sehen und zu entscheiden, ob trotzdem gedruckt werden soll.`,confirmTitle:`Filament reicht nicht`,confirmIntro:`Die zugewiesene Spule kann mindestens einen Slot nicht versorgen. Trotzdem drucken?`,lineItem:`Slot {{slot}}: benoetigt {{required}} g, {{remaining}} g verbleibend`,unknown:`unbekannt`,printAnyway:`Trotzdem drucken`},title:`Druckwarteschlange`,subtitle:`Planen und verwalten Sie Ihre Druckaufträge`,addToQueue:`Zur Warteschlange hinzufügen`,print:`Drucken`,reprint:`Erneut drucken`,schedulePrint:`Druck planen`,editQueueItem:`Warteschlangeneintrag bearbeiten`,printToPrinters:`Auf {{count}} Druckern drucken`,queueToPrinters:`Zu {{count}} Druckern hinzufügen`,queueSelectedPlates:`{{count}} Platten in die Warteschlange`,selectAllPlates:`Alle {{count}} Platten auswählen`,deselectAll:`Alle abwählen`,printQueued:`Druck in Warteschlange`,itemsQueued:`{{count}} Einträge in Warteschlange`,sending:`Wird gesendet...`,sendingProgress:`Sende {{current}}/{{total}}...`,adding:`Wird hinzugefügt...`,addingProgress:`Füge hinzu {{current}}/{{total}}...`,savingProgress:`Speichere {{current}}/{{total}}...`,clearQueue:`Warteschlange leeren`,clearHistory:`Verlauf löschen`,emptyQueue:`Warteschlange ist leer`,position:`Position`,scheduledTime:`Geplante Zeit`,moveUp:`Nach oben`,moveDown:`Nach unten`,startNow:`Jetzt starten`,printingInProgress:`Druck läuft...`,viewArchive:`Archiv anzeigen`,viewInFileManager:`Im Dateimanager anzeigen`,itemCount:`{{count}} Element`,itemCount_plural:`{{count}} Elemente`,dragToReorder:`Ziehen zum Neuordnen (nur Sofort)`,reorderHint:`Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.`,sjf:{label:`SJF`,tooltip:`Kürzester Auftrag zuerst — Scheduler bevorzugt kürzere Drucke`},addedBy:`Hinzugefügt von {{name}}`,nextInQueue:`Nächster in der Warteschlange`,clearPlateSuccess:`Druckplatte freigegeben — bereit für nächsten Druck`,plateNumber:`Platte {{index}}`,quantity:`Menge`,quantityHint:`Erstellt {{count}} Warteschlangeneinträge`,activeBatches:`Aktive Stapel`,batchProgress:`{{completed}} von {{total}} abgeschlossen`,cancelBatch:`Verbleibende abbrechen`,batchCancelled:`Verbleibende Stapeleinträge abgebrochen`,cancelBatchConfirmTitle:`Stapel abbrechen`,cancelBatchConfirmMessage:`Alle verbleibenden ausstehenden Einträge in diesem Stapel abbrechen?`,batch:{defaultName:`Stapel`,label:`{{count}} Eintrag`,label_plural:`{{count}} Einträge`,pendingCount:`{{count}} ausstehend`,pendingCount_plural:`{{count}} ausstehend`,expand:`Stapel ausklappen`,collapse:`Stapel einklappen`,groupAsBatch:`Als Stapel gruppieren…`,groupAsBatchDescription:`Fasse die {{count}} ausgewählten Einträge zu einem einklappbaren Stapel zusammen.`,nameLabel:`Stapelname`,namePlaceholder:`z. B. Freitagsgeschenke`,create:`Stapel erstellen`,ungroup:`Gruppierung aufheben`,ungroupConfirmTitle:`Stapel auflösen?`,ungroupConfirmMessage:`Die Einträge bleiben in der Warteschlange, sind aber nicht mehr gruppiert.`,dragGroup:`Gruppe ziehen`},tabs:{queue:`Warteschlange`,history:`Verlauf`,timeline:`Zeitachse`},layout:{flatList:`Liste`,byPrinter:`Nach Drucker`,groupByPrinter:`Nach Drucker gruppieren`},history:{emptyTitle:`Noch kein Verlauf`,emptyDescription:`Abgeschlossene, abgebrochene und fehlgeschlagene Drucke erscheinen hier.`},dragGhost:{multiCount:`{{count}} Einträge`,batch:`{{name}} ({{count}} Kopie)`,batch_plural:`{{name}} ({{count}} Kopien)`},sections:{currentlyPrinting:`Aktuell druckend`,queued:`In Warteschlange`,history:`Verlauf`},status:{pending:`Ausstehend`,waiting:`Wartend`,printing:`Druckt`,paused:`Pausiert`,completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,skipped:`Übersprungen`,cancelled:`Abgebrochen`},summary:{printing:`Druckt`,queued:`In Warteschlange`,totalTime:`Gesamte Wartezeit`,totalWeight:`Gesamtgewicht der Warteschlange`,history:`Verlauf`},filter:{allPrinters:`Alle Drucker`,unassigned:`Nicht zugewiesen`,allStatus:`Alle Status`,allLocations:`Alle Standorte`,any:`Beliebig`},sort:{byPosition:`Nach Position sortieren`,byName:`Nach Name sortieren`,byPrinter:`Nach Drucker sortieren`,bySchedule:`Nach Zeitplan sortieren`,byDate:`Nach Datum sortieren`,ascendingOldest:`Aufsteigend (älteste zuerst)`,descendingNewest:`Absteigend (neueste zuerst)`},badges:{staged:`Bereitgestellt`,requiresPrevious:`Erfordert vorherigen Erfolg`,autoPowerOff:`Automatisch ausschalten`,gcodeInjection:`G-Code`},empty:{title:`Keine Drucke geplant`,description:`Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.`},time:{asap:`Sofort`,overdue:`Überfällig`,now:`Jetzt`,lessThanMinute:`In weniger als einer Minute`,inMinutes:`In {{count}} Min`,inHours:`In {{count}} Stunden`},actions:{stopPrint:`Druck stoppen`,startPrint:`Druck starten`,requeue:`Erneut einreihen`},bulkEdit:{title:`{{count}} Element bearbeiten`,title_plural:`{{count}} Elemente bearbeiten`,description:`Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.`,printer:`Drucker`,noChange:`— Keine Änderung —`,queueOptions:`Warteschlangenoptionen`,staged:`Bereitgestellt (manueller Start)`,autoPowerOff:`Nach Druck automatisch ausschalten`,requirePrevious:`Vorherigen Erfolg erfordern`,printOptions:`Druckoptionen`,bedLevelling:`Bett-Nivellierung`,flowCalibration:`Fluss-Kalibrierung`,vibrationCalibration:`Vibrations-Kalibrierung`,layerInspection:`Erste-Schicht-Prüfung`,timelapse:`Zeitraffer`,useAms:`AMS verwenden`,nozzleOffsetCali:`Düsenversatz-Kalibrierung`,applyChanges:`Änderungen übernehmen`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,selected:`{{count}} ausgewählt`,editSelected:`Ausgewählte bearbeiten`,cancelSelected:`Ausgewählte abbrechen`},confirm:{cancelTitle:`Geplanten Druck abbrechen`,cancelMessage:`Möchten Sie "{{name}}" wirklich abbrechen?`,stopTitle:`Druck stoppen`,stopMessage:`Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.`,removeTitle:`Aus Verlauf entfernen`,removeMessage:`Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?`,clearHistoryTitle:`Verlauf löschen`,clearHistoryMessage:`Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?`,cancelButton:`Druck abbrechen`,stopButton:`Druck stoppen`,thisPrint:`diesen Druck`,thisItem:`dieses Element`},toast:{cancelled:`Warteschlangenelement abgebrochen`,cancelFailed:`Element konnte nicht abgebrochen werden`,removed:`Warteschlangenelement entfernt`,removeFailed:`Element konnte nicht entfernt werden`,stopped:`Druck gestoppt`,stopFailed:`Druck konnte nicht gestoppt werden`,released:`Druck in Warteschlange freigegeben`,startFailed:`Druck konnte nicht gestartet werden`,reorderFailed:`Warteschlange konnte nicht neu geordnet werden`,historyCleared:`{{count}} Verlaufselement(e) gelöscht`,clearHistoryFailed:`Verlauf konnte nicht gelöscht werden`,updateFailed:`Elemente konnten nicht aktualisiert werden`,bulkCancelled:`{{count}} Element(e) abgebrochen`,bulkCancelFailed:`Elemente konnten nicht abgebrochen werden`,batchCreated:`Stapel „{{name}}“ erstellt`,batchCreateFailed:`Stapel konnte nicht erstellt werden`,batchUngrouped:`{{count}} Eintrag/Einträge aus Stapel gelöst`,batchUngroupFailed:`Stapel konnte nicht aufgelöst werden`,resumedAfterFailure:`Warteschlange fortgesetzt — {{restored}} Auftrag/Aufträge wieder eingereiht`,resumeAfterFailureFailed:`Warteschlange konnte nicht fortgesetzt werden`},resumeAfterFailure:{banner:`{{printer}} ist durch einen vorherigen Druckfehler blockiert — {{count}} Auftrag/Aufträge übersprungen`,bannerHint:`Behebe das Druckerproblem und setze die Warteschlange dann fort, um die übersprungenen Aufträge wiederherzustellen und die Sperre aufzuheben.`,button:`Nach Fehler fortsetzen`,confirmTitle:`Warteschlange nach Fehler fortsetzen?`,confirmMessage:`Setze {{count}} übersprungenen Auftrag/Aufträge auf {{printer}} wieder auf „Ausstehend“ und hebe die Vorgängersperre auf. Stelle vorher sicher, dass der Drucker bereit ist.`},timeline:{listView:`Liste`,timelineView:`Zeitstrahl`,unassigned:`Nicht zugewiesen`,noData:`Keine geplanten Drucke für diesen Tag`,nothingCommitted:`Keine festgelegten Pläne in diesem Zeitfenster. Vorgemerkte Einträge, wartende Einträge und ASAP-Aufträge auf inaktiven Druckern werden nicht angezeigt — leg eine geplante Zeit fest oder gib einen vorgemerkten Eintrag frei, damit er hier erscheint.`,allDoneBy:`Alle Drucke voraussichtlich fertig um {{time}}`,staged:`Bereitgestellt`,filterAll:`Alle anzeigen`,filterPrinting:`Druckend`,filterQueued:`Warteschlange`,time:{anyMoment:`jeden Moment`,minutesLeft:`{{minutes}}m übrig`,hoursLeft:`{{hours}}h übrig`,hoursMinutesLeft:`{{hours}}h {{minutes}}m übrig`},day:{previous:`Vorheriger Tag`,next:`Nächster Tag`,today:`Heute`},window:{back12h:`12 Stunden zurück`,forward12h:`12 Stunden vor`,now:`Jetzt`},printerColumnHeader:`Drucker`},permissions:{noStopPrint:`Sie haben keine Berechtigung, Drucke zu stoppen`,noStartPrint:`Sie haben keine Berechtigung, Drucke zu starten`,noEdit:`Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten`,noCancel:`Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen`,noRequeue:`Sie haben keine Berechtigung, Elemente erneut einzureihen`,noRemove:`Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen`,noClearHistory:`Sie haben keine Berechtigung, den gesamten Verlauf zu löschen`,noEditItems:`Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten`,noCancelItems:`Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen`}},backgroundDispatch:{unknownFile:`Unbekannte Datei`,unknownPrinter:`Unbekannter Drucker`,startingPrints:`Starte Drucke`,progressSummary:`{{complete}}/{{total}} abgeschlossen • Geplant: {{dispatched}} • In Bearbeitung: {{processing}}`,expandDetails:`Dispatch-Details ausklappen`,collapseDetails:`Dispatch-Details einklappen`,dismissToast:`Dispatch-Hinweis schließen`,cancelDispatchJob:`Dispatch-Job abbrechen`,cancel:`Abbrechen`,cancelling:`Wird abgebrochen…`,awaitingPrinter:`Warte auf Drucker…`,status:{dispatched:`Geplant`,processing:`In Bearbeitung`,completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,cancelled:`Abgebrochen`},toast:{cancellingUpload:`Upload wird abgebrochen...`,cancelled:`Dispatch abgebrochen`,cancelFailed:`Dispatch konnte nicht abgebrochen werden`,completeWithFailures:`Background Dispatch abgeschlossen: {{completed}} erfolgreich, {{failed}} fehlgeschlagen`,completeSuccess:`Background Dispatch abgeschlossen: {{completed}} erfolgreich`,printStartedRemaining:`{{completed}} Druck(e) gestartet, {{remaining}} weitere werden gesendet...`}},stats:{title:`Statistiken`,subtitle:`Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.`,overview:`Übersicht`,totalPrints:`Gesamtdrucke`,successRate:`Erfolgsrate`,totalPrintTime:`Gesamtdruckzeit`,printTime:`Druckzeit`,totalFilament:`Gesamtverbrauch Filament`,filamentUsed:`Filamentverbrauch`,filamentCost:`Filamentkosten`,totalCost:`Gesamtkosten`,energyUsed:`Energieverbrauch`,energyCost:`Energiekosten`,energyWarmingUpTooltip:`Die Energieerfassung sammelt noch stündliche Snapshots. Zeitraumwerte werden genau, sobald vor dem gewählten Bereich mindestens ein Snapshot vorliegt. Frühe Werte können zu niedrig sein.`,averagePrintTime:`Durchschnittliche Druckzeit`,printsPerDay:`Drucke pro Tag`,byPrinter:`Nach Drucker`,printsByPrinter:`Drucke nach Drucker`,byMaterial:`Nach Material`,byMonth:`Nach Monat`,last7Days:`Letzte 7 Tage`,last30Days:`Letzte 30 Tage`,last90Days:`Letzte 90 Tage`,allTime:`Gesamt`,quickStats:`Schnellstatistiken`,printActivity:`Druckaktivität`,filamentTypes:`Filamenttypen`,filamentTrends:`Filamenttrends`,failureAnalysis:`Fehleranalyse`,timeAccuracy:`Zeitgenauigkeit`,successful:`Erfolgreich:`,failed:`Fehlgeschlagen:`,cancelled:`Abgebrochen:`,perfectEstimate:`100% = perfekte Schätzung`,noTimeAccuracyData:`Noch keine Zeitgenauigkeitsdaten`,noFilamentData:`Keine Filamentdaten verfügbar`,noPrinterData:`Keine Druckerdaten verfügbar`,noPrintData:`Keine Druckdaten verfügbar`,noPrintDataLast30Days:`Keine Druckdaten in den letzten 30 Tagen`,failureReasons:`Fehlerursachen`,topFailureReasons:`Häufigste Fehlerursachen`,failedPrintsCount:`{{failed}} / {{total}} Drucke fehlgeschlagen`,lastWeekRate:`Letzte Woche: {{rate}}%`,resetLayout:`Layout zurücksetzen`,recalculateCosts:`Kosten neu berechnen`,recalculateCostsHint:`Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen`,exportStats:`Statistiken exportieren`,exportAsCsv:`Als CSV exportieren`,exportAsExcel:`Als Excel exportieren`,hiddenCount:`{{count}} ausgeblendet`,exportDownloaded:`Export heruntergeladen`,exportFailed:`Export fehlgeschlagen`,layoutReset:`Layout zurückgesetzt`,recalculatedCosts:`Kosten für {{count}} Archive neu berechnet`,recalculateFailed:`Kosten konnten nicht neu berechnet werden`,loadingStats:`Statistiken werden geladen...`,noPermissionResetLayout:`Sie haben keine Berechtigung, das Layout zurückzusetzen`,noPermissionRecalculate:`Sie haben keine Berechtigung, Kosten neu zu berechnen`,noPrintDataInRange:`Keine Druckdaten im ausgewählten Zeitraum`,periodFilament:`Filamentverbrauch`,periodCost:`Kosten`,avgPerPrint:`Durchschnitt pro Druck`,usageOverTime:`Verbrauch im Zeitverlauf`,filamentByWeight:`Gewicht`,printDuration:`Druckdauer`,printerUtilization:`Druckerauslastung`,filamentSuccess:`Erfolg nach Material`,printHabits:`Druckgewohnheiten`,printTimeOfDay:`Druck-Tageszeit`,colorDistribution:`Farbverteilung`,noColorData:`Keine Farbdaten verfügbar`,records:`Rekorde`,longestPrint:`Längster Druck`,heaviestPrint:`Schwerster Druck`,mostExpensivePrint:`Teuerster Druck`,busiestDay:`Aktivster Tag`,successStreak:`Erfolgsserie`,streakPrint:`aufeinanderfolgender Druck`,streakPrints:`{{count}} aufeinanderfolgende Drucke`,printerStats:`Druckerstatistiken`,hours:`Stunden`,avgPrints:`Ø Drucke`,noArchiveData:`Keine Druckdaten verfügbar`,filamentByTime:`Zeitverlauf`,avgWeight:`Ø Gewicht`,avgTime:`Ø Zeit`,filamentByPrints:`Drucke`,timeframe:{today:`Heute`,"this-week":`Diese Woche`,"this-month":`Dieser Monat`,"last-7":`Letzte 7 Tage`,"last-30":`Letzte 30 Tage`,"last-90":`Letzte 90 Tage`,"this-year":`Dieses Jahr`,"all-time":`Gesamt`,custom:`Benutzerdefiniert`,from:`Von`,to:`Bis`},allUsers:`Alle Benutzer`,noUser:`Kein Benutzer (System)`,filterByUser:`Nach Benutzer filtern`},maintenance:{title:`Wartung`,overview:`Übersicht`,allOk:`Alle Wartungen aktuell`,dueCount:`{{count}} Aufgabe fällig`,dueCount_plural:`{{count}} Aufgaben fällig`,warningCount:`{{count}} Warnung`,warningCount_plural:`{{count}} Warnungen`,totalPrintTime:`Gesamtdruckzeit`,nextMaintenance:`Nächste Wartung`,nothingDue:`Nichts fällig`,tasks:`Aufgaben`,lastPerformed:`Zuletzt durchgeführt`,interval:`Intervall`,hoursRemaining:`{{hours}}h verbleibend`,hoursOverdue:`{{hours}}h überfällig`,markDone:`Als erledigt markieren`,performMaintenance:`Wartung durchführen`,history:`Verlauf`,noHistory:`Kein Wartungsverlauf`,editPrintHours:`Druckstunden bearbeiten`,currentHours:`Aktuelle Stunden`,statusTab:`Status`,settingsTab:`Einstellungen`,overdueCount:`{{count}} überfällig`,dueSoonCount:`{{count}} bald fällig`,dueSoon:`Bald fällig`,allGood:`Alles in Ordnung`,overdueBy:`Überfällig um {{duration}}`,dueIn:`Fällig in {{duration}}`,timeLeft:`{{duration}} verbleibend`,day:`1 Tag`,days:`{{count}} Tage`,week:`1 Woche`,weeks:`{{count}} Wochen`,month:`1 Monat`,months:`{{count}} Monate`,year:`1 Jahr`,maintenanceTypes:`Wartungstypen`,maintenanceTypesDescription:`Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben`,addCustomType:`Benutzerdefinierten Typ hinzufügen`,restoreDefaults:`Standardaufgaben wiederherstellen`,intervalType:`Intervalltyp`,intervalValue:`Intervall ({{type}})`,icon:`Symbol`,documentationLink:`Dokumentationslink (optional)`,assignToPrinters:`Druckern zuweisen`,selectAtLeastOnePrinter:`Wählen Sie mindestens einen Drucker`,addType:`Typ hinzufügen`,custom:`Benutzerdefiniert`,printHours:`Druckstunden`,calendarDays:`Kalendertage`,exampleName:`z.B. HEPA-Filter ersetzen`,viewDocumentation:`Dokumentation anzeigen`,timeBasedInterval:`Zeitbasiertes Intervall`,intervalOverrides:`Intervall-Überschreibungen`,intervalOverridesDescription:`Intervalle für bestimmte Drucker anpassen`,assignedToPrinters:`Druckern zugewiesen:`,noPrintersAssigned:`Keine Drucker zugewiesen`,addPrinterShort:`Hinzufügen:`,printersAssignedClick:`{{count}} Drucker zugewiesen - klicken zum Verwalten`,removeFromPrinter:`Von diesem Drucker entfernen`,types:{lubricateCarbonRods:`Karbonstäbe schmieren`,lubricateRails:`Linearschienen schmieren`,cleanNozzle:`Düse/Hotend reinigen`,checkBelts:`Riemenspannung prüfen`,cleanBuildPlate:`Druckbett reinigen`,checkExtruder:`Extruderzahnräder prüfen`,checkCooling:`Kühlungslüfter prüfen`,generalInspection:`Allgemeine Inspektion`,cleanCarbonRods:`Kohlenstoffstangen reinigen`,lubricateSteelRods:`Stahlstangen schmieren`,cleanSteelRods:`Stahlstangen reinigen`,cleanLinearRails:`Linearschienen reinigen`,checkPtfeTube:`PTFE-Schlauch prüfen`,replaceHepaFilter:`HEPA-Filter ersetzen`,replaceCarbonFilter:`Aktivkohlefilter ersetzen`,lubricateLeftNozzleRail:`Linke Düsenschiene schmieren`},maintenanceComplete:`Wartung als abgeschlossen markiert`,typeUpdated:`Wartungstyp aktualisiert`,typeDeleted:`Wartungstyp gelöscht`,defaultsRestored:`{{count}} Standardaufgabe(n) wiederhergestellt`,printHoursUpdated:`Druckstunden aktualisiert`,printerAssigned:`Drucker zugewiesen`,printerRemoved:`Drucker entfernt`,deleteTypeConfirm:`"{{name}}" löschen?`,deleteSystemTypeTitle:`Standard-Wartungsaufgabe löschen?`,deleteSystemTypeMessage:`Möchten Sie die Standard-Wartungsaufgabe "{{name}}" wirklich löschen?`,noPermissionUpdate:`Sie haben keine Berechtigung, Wartungselemente zu aktualisieren`,noPermissionPerform:`Sie haben keine Berechtigung, Wartungen durchzuführen`,noPermissionEditTypes:`Sie haben keine Berechtigung, Wartungstypen zu bearbeiten`,noPermissionDeleteTypes:`Sie haben keine Berechtigung, Wartungstypen zu löschen`,noPermissionEditHours:`Sie haben keine Berechtigung, Druckstunden zu bearbeiten`,noPermissionRemovePrinter:`Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen`,noPermissionAssignPrinter:`Sie haben keine Berechtigung, Drucker zuzuweisen`,noPermissionEditIntervals:`Sie haben keine Berechtigung, Intervalle zu bearbeiten`,configureSettings:`Wartungstypen und Intervalle konfigurieren`},settings:{title:`Einstellungen`,general:`Allgemein`,tabs:{general:`Allgemein`,smartPlugs:`Smart Plugs`,notifications:`Benachrichtigungen`,queue:`Workflow`,filament:`Filament`,network:`Netzwerk`,apiKeys:`API-Schlüssel`,virtualPrinter:`Virtueller Drucker`,spoolbuddy:`SpoolBuddy`,failureDetection:`Fehlererkennung`,users:`Authentifizierung`,backup:`Sicherung`,emailAuth:`E-Mail-Authentifizierung`,ldap:`LDAP`,twoFa:`Zwei-Faktor-Auth`,oidc:`SSO / OIDC`,security:`Sicherheit`},spoolbuddy:{infoTitle:`SpoolBuddy-Geräte`,infoBody:`SpoolBuddy-Kioske registrieren sich automatisch per Heartbeat. Ein Gerät hier abmelden, wenn es nicht mehr verwendet wird oder wenn ein veralteter Eintrag nach einem Daemon-Absturz übrig geblieben ist.`,duplicatesTitle:`{{count}} Geräte registriert`,duplicatesBody:`Die Kiosk-Oberfläche verwendet nur das zuerst registrierte Gerät. Falls eines davon ein veralteter Doppeleintrag nach einem Absturz ist, kann es hier entfernt werden — ein laufendes Gerät registriert sich beim nächsten Heartbeat automatisch neu.`,empty:`Noch keine SpoolBuddy-Geräte registriert.`,online:`Online`,offline:`Offline`,unregister:`Abmelden`,unregisterSuccess:`Gerät abgemeldet`,unregisterError:`Gerät konnte nicht abgemeldet werden`,confirmTitle:`SpoolBuddy-Gerät abmelden?`,confirmBody:`Dies entfernt „{{hostname}}" ({{deviceId}}) aus der Datenbank. Ein laufendes Gerät registriert sich beim nächsten Heartbeat automatisch neu.`,ipAddress:`IP-Adresse`,firmware:`Firmware`,lastSeen:`Zuletzt gesehen`,daemonUptime:`Daemon-Laufzeit`,systemUptime:`System-Laufzeit`,never:`nie`,nfc:`NFC`,scale:`Waage`,cpuTemp:`CPU-Temp.`,cpuLoad:`CPU-Last`,memory:`Speicher`,disk:`Festplatte`,update:`Aktualisieren`,updateConfirmTitle:`Spoolbuddy-Daemon aktualisieren?`,updateConfirmBody:`Software-Update auf „{{hostname}}" auslösen? Der Daemon startet nach dem Update neu.`,restartBrowser:`Browser neu starten`,restartBrowserConfirmTitle:`Kiosk-Browser neu starten?`,restartBrowserConfirmBody:`Kiosk-Browser auf „{{hostname}}" neu starten? Die Anzeige wird kurz schwarz.`,restartDaemon:`Daemon neu starten`,restartDaemonConfirmTitle:`Spoolbuddy-Daemon neu starten?`,restartDaemonConfirmBody:`Spoolbuddy-Daemon auf „{{hostname}}" neu starten? Das Gerät ist für einige Sekunden offline.`,reboot:`Neustart`,rebootConfirmTitle:`Gerät neu starten?`,rebootConfirmBody:`„{{hostname}}" neu starten? Das Gerät ist für etwa eine Minute offline.`,shutdown:`Herunterfahren`,shutdownConfirmTitle:`Gerät herunterfahren?`,shutdownConfirmBody:`„{{hostname}}" herunterfahren? Physischer Zugriff ist nötig, um es wieder einzuschalten.`,commandConfirm:`Bestätigen`,commandQueued:`Befehl eingereiht`,commandError:`Befehl konnte nicht gesendet werden`},ldap:{title:`LDAP-Authentifizierung`,enabledDesc:`LDAP-Authentifizierung ist aktiviert`,disabledDesc:`LDAP-Authentifizierung ist deaktiviert`,disabledHint:`LDAP-Einstellungen unten konfigurieren und speichern, dann aktivieren.`,enabled:`LDAP-Authentifizierung aktiviert`,disabled:`LDAP-Authentifizierung deaktiviert`,feature1:`Benutzer können sich mit LDAP-Anmeldedaten anmelden`,feature2:`Lokales Admin-Konto bleibt als Fallback erhalten`,feature3:`LDAP-Gruppen werden bei der Anmeldung BamBuddy-Gruppen zugeordnet`,serverConfig:`LDAP-Server-Konfiguration`,serverUrl:`Server-URL`,serverUrlHint:`Verwenden Sie ldap:// für Standard oder ldaps:// für SSL-Verbindungen`,security:`Sicherheit`,securityHint:`StartTLS aktualisiert eine einfache Verbindung auf TLS. LDAPS verwendet TLS von Anfang an.`,bindDn:`Bind-DN (Dienstkonto)`,bindPassword:`Bind-Passwort`,searchBase:`Such-Basis-DN`,userFilter:`Benutzer-Suchfilter`,userFilterHint:`{username} wird durch den Anmeldenamen ersetzt. Verwenden Sie (uid={username}) für OpenLDAP.`,advanced:`Erweitert`,autoProvision:`Benutzer automatisch anlegen`,autoProvisionHint:`Automatisch ein BamBuddy-Konto bei der ersten LDAP-Anmeldung erstellen`,defaultGroup:`Standardgruppe`,defaultGroupNone:`— Keine (kein Fallback) —`,defaultGroupHint:`Fallback-Gruppe, die zugewiesen wird, wenn sich ein LDAP-Benutzer authentifiziert, aber in keiner zugeordneten LDAP-Gruppe enthalten ist. Leer lassen, um nicht zugeordnete Benutzer ohne Berechtigungen zu belassen.`,groupMapping:`Gruppenzuordnung (JSON)`,groupMappingHint:`LDAP-Gruppen-DNs BamBuddy-Gruppen zuordnen. Verfügbare Gruppen: `,testConnection:`Verbindung testen`,settingsSaved:`LDAP-Einstellungen gespeichert`,errors:{serverRequired:`LDAP-Server-URL ist erforderlich`,searchBaseRequired:`Such-Basis-DN ist erforderlich`,enableAuthFirst:`Authentifizierung zuerst aktivieren`,configureLdapFirst:`LDAP-Einstellungen zuerst speichern`}},email:{smtpSettings:`SMTP-Konfiguration`,smtpHost:`SMTP-Server`,smtpPort:`SMTP-Port`,security:`Sicherheit`,authentication:`Authentifizierung`,username:`Benutzername`,password:`Passwort`,fromEmail:`Absender-E-Mail`,fromName:`Absendername`,testConnection:`SMTP-Verbindung testen`,testRecipient:`Test-Empfänger-E-Mail`,sendTest:`Test-E-Mail senden`,sending:`Wird gesendet...`,save:`Einstellungen speichern`,saving:`Wird gespeichert...`,advancedAuth:`Erweiterte Authentifizierung`,advancedAuthEnabled:`Erweiterte Authentifizierung ist aktiviert`,advancedAuthEnabledDesc:`E-Mail-basierte Benutzerverwaltungsfunktionen sind aktiv. Neue Benutzer erhalten automatisch generierte Passwörter per E-Mail und können ihr Passwort über die Passwort vergessen Funktion zurücksetzen.`,advancedAuthDisabled:`Erweiterte Authentifizierung ist deaktiviert`,advancedAuthDisabledDesc:`Aktivieren Sie die erweiterte Authentifizierung, um E-Mail-basierte Funktionen für die Benutzerverwaltung zu aktivieren.`,enable:`Aktivieren`,disable:`Deaktivieren`,feature1:`Passwörter werden automatisch generiert und an neue Benutzer gesendet`,feature2:`Benutzer können sich mit Benutzername oder E-Mail anmelden`,feature3:`Passwort vergessen Funktion ist verfügbar`,feature4:`Administratoren können Benutzerpasswörter per E-Mail zurücksetzen`,errors:{requiredFields:`Bitte füllen Sie alle Pflichtfelder aus`,usernameRequired:`Benutzername ist erforderlich, wenn Authentifizierung aktiviert ist`,enterTestEmail:`Bitte geben Sie eine Test-E-Mail-Adresse ein`,smtpServerAndEmail:`Bitte füllen Sie SMTP-Server und Absender-E-Mail aus, bevor Sie testen`,usernamePasswordRequired:`Benutzername und Passwort sind erforderlich, wenn Authentifizierung aktiviert ist`,configureSmtpFirst:`Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen`,enableAuthFirst:`Bitte aktivieren Sie zuerst die Authentifizierung, um E-Mail-basierte Funktionen nutzen zu können.`},success:{settingsSaved:`SMTP-Einstellungen erfolgreich gespeichert`},securityOptions:{starttls:`STARTTLS (Port 587)`,ssl:`SSL/TLS (Port 465)`,none:`Keine (Port 25)`},authOptions:{enabled:`Aktiviert`,disabled:`Deaktiviert`}},appearance:`Erscheinungsbild`,notifications:`Benachrichtigungen`,smartPlugs:`Smart Plugs`,spoolman:`Spoolman`,updates:`Aktualisierungen`,language:`Sprache`,languageDescription:`Wählen Sie Ihre bevorzugte Sprache`,theme:`Design`,themeLight:`Hell`,themeDark:`Dunkel`,themeSystem:`System`,defaultView:`Standardansicht`,defaultViewDescription:`Seite, die beim Öffnen der App angezeigt wird`,checkForUpdates:`Nach Updates suchen`,autoUpdate:`Automatische Updates`,currentVersion:`Aktuelle Version`,latestVersion:`Neueste Version`,upToDate:`Sie sind auf dem neuesten Stand`,updateAvailable:`Update verfügbar`,notificationLanguage:`Benachrichtigungssprache`,notificationLanguageDescription:`Sprache für Push-Benachrichtigungen`,bedCooledThreshold:`Bett-Abkühlung Schwellenwert`,bedCooledThresholdDescription:`Temperatur, unter der das Bett nach einem Druck als abgekühlt gilt`,userNotificationsEnabled:`Benutzerbenachrichtigungen`,userNotificationsEnabledDescription:`Aktiviert das Benutzerbenachrichtigungsmenü und E-Mail-Benachrichtigungen für Druckereignisse. Erfordert Erweiterte Authentifizierung.`,userNotificationsDisabledHint:`Erweiterte Authentifizierung aktivieren, um Benutzerbenachrichtigungen zu verwenden.`,notificationProviders:`Benachrichtigungsanbieter`,addProvider:`Anbieter hinzufügen`,editProvider:`Anbieter bearbeiten`,providerType:`Anbietertyp`,testNotification:`Testbenachrichtigung`,testSuccess:`Testbenachrichtigung erfolgreich gesendet`,testFailed:`Testbenachrichtigung konnte nicht gesendet werden`,quietHours:`Ruhezeiten`,quietHoursDescription:`Keine Störungen während dieser Zeiten`,quietHoursStart:`Beginn`,quietHoursEnd:`Ende`,events:{title:`Benachrichtigungsereignisse`,printStart:`Druck gestartet`,printComplete:`Druck abgeschlossen`,printFailed:`Druck fehlgeschlagen`,printStopped:`Druck gestoppt`,printProgress:`Fortschrittsmeldungen`,printProgressDescription:`Bei 25%, 50%, 75% benachrichtigen`,printerOffline:`Drucker offline`,printerError:`Druckerfehler`,filamentLow:`Filament niedrig`,maintenanceDue:`Wartung fällig`,maintenanceDueDescription:`Benachrichtigen, wenn Wartung erforderlich`},smartPlug:{title:`Smart Plugs`,add:`Smart Plug hinzufügen`,edit:`Smart Plug bearbeiten`,name:`Name`,ipAddress:`IP-Adresse`,linkedPrinter:`Verknüpfter Drucker`,autoOn:`Automatisch einschalten`,autoOnDescription:`Einschalten beim Druckstart`,autoOff:`Automatisch ausschalten`,autoOffDescription:`Ausschalten nach Druckende`,offDelay:`Ausschaltverzögerung`,offDelayMinutes:`Minuten nach Druck`,offDelayTemp:`Wenn Düse unter Temperatur`,currentState:`Aktueller Status`,turnOn:`Einschalten`,turnOff:`Ausschalten`},filamentTracking:`Filament-Verfolgung`,filamentTrackingDesc:`Wählen Sie, wie Sie Ihre Filamentspulen verfolgen möchten. Sie können das integrierte Inventar oder einen externen Spoolman-Server verwenden.`,autoAddUnknownRfid:`Unbekannte RFID-Spulen automatisch hinzufügen`,autoAddUnknownRfidDesc:`Erstellt automatisch einen Inventareintrag, wenn eine Spule mit unbekanntem RFID-Tag erkannt wird. Deaktivieren, wenn Sie neue Spulen vorab manuell anlegen, um Duplikate zu vermeiden.`,filamentChecks:`Filament-Prüfungen`,disableFilamentWarnings:`Filament-Warnungen deaktivieren`,disableFilamentWarningsDesc:`Keine Warnungen über unzureichendes Filament beim Drucken oder Einreihen anzeigen`,preferLowestFilament:`Niedrigsten Filamentrest bevorzugen`,preferLowestFilamentDesc:`Bei mehreren passenden Spulen die mit dem geringsten Restfilament verwenden`,preferLowestFilamentBackupNote:`Wirkt nur, wenn AMS Filament Backup am Drucker aktiviert ist — sonst kann der Drucker beim Aufbrauchen der ersten Spule nicht auf eine zweite Spule wechseln.`,trackingModeBuiltIn:`Integriertes Inventar`,trackingModeBuiltInDesc:`RFID-Erkennung und Verbrauchserfassung inklusive`,trackingModeSpoolmanDesc:`Externer Filament-Management-Server`,builtInFeatureRfid:`Erkennt automatisch Bambu Lab RFID-Spulen im AMS`,builtInFeatureUsage:`Erfasst den Filamentverbrauch pro Druck`,builtInFeatureCatalog:`Spulen, Farben und K-Faktor-Profile verwalten`,builtInFeatureThirdParty:`Drittanbieter-Spulen können Inventarspulen zugewiesen werden`,amsSyncButton:`Gewichte vom AMS synchronisieren`,amsSyncTitle:`Spulengewichte vom AMS synchronisieren`,amsSyncMessage:`Alle Inventar-Spulengewichte werden mit den aktuellen AMS-Restwerten der verbundenen Drucker überschrieben. Verwenden Sie dies zur Wiederherstellung beschädigter Gewichtsdaten. Drucker müssen online sein.`,amsSyncing:`Synchronisiere...`,amsSyncSuccess:`{{synced}} Spule(n) synchronisiert, {{skipped}} übersprungen`,amsSyncError:`Synchronisierung der Gewichte vom AMS fehlgeschlagen`,spoolmanAmsSyncButton:`Spoolman-Gewichte vom AMS synchronisieren`,spoolmanAmsSyncTitle:`Spoolman-Spulengewichte vom AMS synchronisieren`,spoolmanAmsSyncMessage:`Dabei werden alle Spoolman-Spulengewichte anhand der aktuellen AMS-Füllstandswerte der verbundenen Drucker aktualisiert. Die Drucker müssen online sein.`,spoolmanAmsSyncing:`Synchronisiere...`,spoolmanAmsSyncSuccess:`{{synced}} Spule(n) synchronisiert, {{skipped}} übersprungen`,spoolmanAmsSyncError:`Synchronisierung der Spoolman-Gewichte vom AMS fehlgeschlagen`,spoolmanAmsSyncErrorUnreachable:`Synchronisierung fehlgeschlagen (Spoolman nicht erreichbar)`,spoolmanAmsSyncErrorNotConfigured:`Synchronisierung fehlgeschlagen (Spoolman nicht konfiguriert)`,spoolmanNotConfigured:`Spoolman nicht konfiguriert`,spoolmanFilamentCatalogTitle:`Spoolman-Filamentkatalog`,spoolmanFilamentCatalogDesc:`Filamentnamen und Leergewichte aus deiner Spoolman-Instanz. Name und Spulengewicht sind hier editierbar; alle anderen Eigenschaften werden direkt in Spoolman verwaltet.`,spoolmanUrl:`Spoolman URL`,spoolmanUrlHint:`URL Ihres Spoolman-Servers (z.B. http://localhost:7912)`,spoolmanConnected:`Verbunden`,spoolmanDisconnected:`Nicht verbunden`,status:`Status`,connect:`Verbinden`,disconnect:`Trennen`,howSyncWorks:`So funktioniert die Synchronisierung`,syncInfoRfidOnly:`Nur offizielle Bambu Lab Spulen mit RFID werden synchronisiert`,syncInfoAutoCreate:`Neue Spulen werden bei der ersten Synchronisierung automatisch in Spoolman erstellt`,syncInfoThirdPartySkipped:`Nicht-Bambu-Lab-Spulen (Drittanbieter, nachgefüllt) werden übersprungen`,linkingExistingSpools:`Vorhandene Spulen verknüpfen`,linkingExistingSpoolsDesc:`Um vorhandene Spoolman-Spulen mit Ihrem AMS zu verknüpfen, fahren Sie über einen AMS-Slot und klicken Sie auf "Mit Spoolman verknüpfen".`,syncMode:`Synchronisierungsmodus`,syncModeAuto:`Automatisch`,syncModeManual:`Nur manuell`,syncModeAutoDesc:`AMS-Daten werden automatisch synchronisiert, wenn Änderungen erkannt werden`,syncModeManualDesc:`Nur bei manueller Auslösung synchronisieren`,syncAmsData:`AMS-Daten synchronisieren`,syncAmsDataDesc:`AMS-Daten des Druckers manuell mit Spoolman synchronisieren`,allPrinters:`Alle Drucker`,noDefaultPrinter:`Kein Standard (jedes Mal fragen)`,sidebarOrder:`Seitenleisten-Reihenfolge`,saveThumbnails:`Vorschaubilder speichern`,captureFinishPhoto:`Abschlussfoto aufnehmen`,noPrintersConfigured:`Keine Drucker konfiguriert`,archiveMode:{always:`Immer Archiveintrag erstellen`,never:`Nie Archiveintrag erstellen`,ask:`Jedes Mal fragen`},checkForUpdatesLabel:`Nach Updates suchen`,checkPrinterFirmware:`Drucker-Firmware prüfen`,includeBetaUpdates:`Beta-Versionen einschließen`,includeBetaUpdatesDesc:`Über Beta- und Vorabversionen bei der Updateprüfung benachrichtigen`,enableRetry:`Wiederholung aktivieren`,homeAssistantDescription:`Smart Plugs über Home Assistant steuern`,environmentManagedLabel:`(Umgebungsvariable)`,autoEnabledViaEnv:`Automatisch über Umgebungsvariablen aktiviert`,urlFromEnvReadOnly:`Wert wird über HA_URL Umgebungsvariable gesetzt (schreibgeschützt)`,tokenFromEnvReadOnly:`Wert wird über HA_TOKEN Umgebungsvariable gesetzt (schreibgeschützt)`,mqttConnectedTo:`Verbunden mit`,prometheusDescription:`Druckerdaten im Prometheus-Format bereitstellen`,noSmartPlugsTitle:`Keine Smart Plugs konfiguriert`,noSmartPlugsDescription:`Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.`,noProvidersTitle:`Keine Anbieter konfiguriert`,noProvidersDescription:`Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.`,noTemplatesAvailable:`Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.`,apiPermissionView:`Druckerstatus und Warteschlange anzeigen`,apiPermissionEdit:`Elemente zur Druckwarteschlange hinzufügen und entfernen`,apiKeysEmptyTitle:`Keine API-Schlüssel`,apiKeysEmptyDescription:`Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.`,noUsersFound:`Keine Benutzer gefunden`,noGroupsFound:`Keine Gruppen gefunden`,noGroupsAvailable:`Keine Gruppen verfügbar`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,systemGroupWarning:`System-Gruppennamen können nicht geändert werden`,authDisabledTitle:`Authentifizierung ist deaktiviert`,authDisabledFeature1:`Anmeldung zum Zugriff auf das System erforderlich`,authDisabledFeature2:`Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen`,authDisabledFeature3:`Zugriff mit über 50 granularen Berechtigungen steuern`,userHasCreated:`Dieser Benutzer hat erstellt:`,userItemsQuestion:`Was möchten Sie mit diesen Elementen tun?`,deleteUserConfirm:`Möchten Sie diesen Benutzer wirklich löschen?`,actionCannotBeUndone:`Diese Aktion kann nicht rückgängig gemacht werden.`,addFirstSmartPlug:`Ersten Smart Plug hinzufügen`,providers:`Anbieter`,log:`Protokoll`,testAll:`Alle testen`,testResults:`Testergebnisse`,testPassedCount:`{{count}} bestanden`,testFailedCount:`{{count}} fehlgeschlagen`,messageTemplates:`Nachrichtenvorlagen`,messageTemplatesDescription:`Passen Sie Benachrichtigungen für jedes Ereignis an.`,apiKeys:`API-Schlüssel`,apiKeysDescription:`Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.`,createKey:`Schlüssel erstellen`,apiKeyCreated:`API-Schlüssel erfolgreich erstellt`,apiKeyCopyWarning:`Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!`,useInApiBrowser:`Im API-Browser verwenden`,apiKeyQrButton:`QR-Code`,apiKeyQrTitle:`Zum Einrichten scannen`,apiKeyQrCaption:`Mit deiner mobilen App scannen, um diesen Server und API-Schlüssel hinzuzufügen.`,apiKeyQrWarning:`Enthält deinen geheimen API-Schlüssel – nicht teilen oder dort abfotografieren, wo andere ihn sehen können.`,createNewApiKey:`Neuen API-Schlüssel erstellen`,keyName:`Schlüsselname`,keyNamePlaceholder:`z.B. Home Assistant, OctoPrint`,readStatus:`Status lesen`,readStatusDescription:`Druckerstatus und Warteschlange anzeigen`,manageQueue:`Warteschlange verwalten`,manageQueueDescription:`Elemente zur Druckwarteschlange hinzufügen und entfernen`,controlPrinter:`Drucker steuern`,controlPrinterDescription:`Drucke pausieren, fortsetzen und stoppen`,manageLibrary:`Bibliothek verwalten`,manageLibraryDescription:`Bibliotheksdateien hochladen, umbenennen und löschen; Modelle aus MakerWorld importieren`,manageInventory:`Bestand verwalten`,manageInventoryDescription:`Spulen und Bestandseinträge anlegen, ändern und löschen. Erforderlich für SpoolBuddy-Kioske (NFC-Scan, Waagenmessungen, Kiosk-Systembefehle).`,libraryBadge:`Bibliothek`,inventoryBadge:`Bestand`,cloudAccess:`Cloud-Zugriff erlauben`,cloudAccessDescription:`Liest Bambu-Cloud-Presets und -Filamente in Ihrem Namen. Erfordert eine Anmeldung in Bambu Cloud.`,cloudBadge:`Cloud`,updateEnergyCost:`Strompreis aktualisieren`,updateEnergyCostDescription:`Erlaubt diesem Schlüssel, einen neuen Strompreis pro kWh an /settings/electricity-price zu senden. Nützlich für Home-Assistant-Automatisierungen mit dynamischen Tarifen (Tibber, Octopus usw.). Dies ist das einzige Einstellungsfeld, das per API-Schlüssel schreibbar ist.`,energyCostBadge:`Energie`,legacyKey:`Alt`,legacyKeyTooltip:`Wurde vor der nutzerbezogenen Eigentümerschaft erstellt; neu erstellen, um Cloud-Zugriff zu nutzen`,unnamedKey:`Unbenannter Schlüssel`,lastUsed:`Zuletzt verwendet`,read:`Lesen`,control:`Steuern`,createFirstKey:`Ersten Schlüssel erstellen`,webhookEndpoints:`Webhook-Endpunkte`,webhookApiKeyHint:`Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.`,webhook:{getAllStatus:`Alle Druckerstatus abrufen`,getSpecificStatus:`Spezifischen Druckerstatus abrufen`,addToQueue:`Zur Druckwarteschlange hinzufügen`,pausePrint:`Druck pausieren`,resumePrint:`Druck fortsetzen`,stopPrint:`Druck stoppen`},apiBrowser:`API-Browser`,apiBrowserDescription:`Erkunden und testen Sie alle verfügbaren API-Endpunkte.`,apiKeyForTesting:`API-Schlüssel zum Testen`,apiKeyPlaceholder:`Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...`,apiKeyHint:`Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.`,deleteApiKeyTitle:`API-Schlüssel löschen`,deleteApiKeyMessage:`Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.`,deleteKey:`Schlüssel löschen`,amsDisplayThresholds:`AMS-Anzeigeschwellenwerte`,amsThresholdsDescription:`Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.`,humidity:`Luftfeuchtigkeit`,goodGreen:`Gut (grün)`,fairOrange:`Mittel (orange)`,aboveFairBad:`Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)`,fairAlsoDryingThreshold:`Dieser Schwellenwert wird auch für die automatische Trocknung verwendet`,temperature:`Temperatur`,goodBlue:`Gut (blau)`,aboveFairHot:`Über dem mittleren Schwellenwert wird rot angezeigt (heiß)`,historyRetention:`Verlaufsaufbewahrung`,keepSensorHistory:`Sensorverlauf behalten für`,historyRetentionDescription:`Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht`,defaultPrintOptions:`Standard-Druckoptionen`,defaultPrintOptionsDescription:`Standardwerte für Druckoptionen bei neuen Drucken festlegen. Diese können im Druckdialog pro Druck überschrieben werden.`,defaultBedLevelling:`Bett-Nivellierung`,defaultBedLevellingDesc:`Bett vor dem Druck automatisch nivellieren`,defaultFlowCali:`Fluss-Kalibrierung`,defaultFlowCaliDesc:`Extrusionsfluss kalibrieren`,defaultVibrationCali:`Vibrationskalibrierung`,defaultVibrationCaliDesc:`Ringing-Artefakte reduzieren`,defaultLayerInspect:`Erste-Schicht-Inspektion`,defaultLayerInspectDesc:`KI-Inspektion der ersten Schicht`,defaultTimelapse:`Zeitraffer`,defaultTimelapseDesc:`Zeitraffervideo aufnehmen`,defaultNozzleOffsetCali:`Düsenversatz-Kalibrierung`,defaultNozzleOffsetCaliDesc:`Düsenversatz zwischen Extrudern kalibrieren`,tempFanPresetsTitle:`Temperatur- und Lüfter-Vorgaben`,tempFanPresetsDescription:`Passen Sie die Schnellwahlwerte in den Temperatur- und Lüfter-Popovers der Druckerkarte an. Die Aus-Schaltfläche wird immer angezeigt.`,tempFanPresetsNozzle:`Düsentemperatur`,tempFanPresetsBed:`Betttemperatur`,tempFanPresetsChamber:`Kammertemperatur`,tempFanPresetsFan:`Lüftergeschwindigkeit`,tempFanPresetsReset:`Auf Standardwerte zurücksetzen`,staggeredStart:`Versetzter Start`,staggeredStartDescription:`Standard-Gruppengröße und -Intervall beim Staffeln von Mehrdrucker-Batchstarts. Pro Batch im Druck-Dialog überschreibbar.`,plateClear:`Druckplatte-Bestätigung`,requirePlateClear:`Druckplatte-Bestätigung erforderlich`,requirePlateClearDescription:`Wenn aktiviert, wartet der Scheduler auf eine Druckplatten-Bestätigung pro Drucker, bevor geplante Drucke auf Druckern mit abgeschlossenen Aufträgen gestartet werden. Wenn dies deaktiviert ist, werden auch das Druckplatten-Status-Badge und die Schaltfläche "Druckplatte als freigegeben markieren" auf den Druckerkarten ausgeblendet.`,gcodeInjection:`G-Code-Injektion`,gcodeInjectionDescription:`Konfigurieren Sie benutzerdefinierten G-code, der am Anfang und/oder Ende von Drucken für Auto-Print-Systeme wie Farmloop, SwapMod, AutoClear und Printflow 3D eingefügt wird. Snippets werden pro Druckermodell konfiguriert und angewendet, wenn "G-code einfügen" bei einem Warteschlangen-Element aktiviert ist.`,gcodeInjectionNoPrinters:`Keine Drucker gefunden. Fügen Sie Drucker hinzu, um G-code-Snippets zu konfigurieren.`,gcodeStartLabel:`Start-G-Code`,gcodeEndLabel:`End-G-Code`,gcodeStartPlaceholder:`G-code, der vor dem Druckstart eingefügt wird...`,gcodeEndPlaceholder:`G-code, der nach dem Druckende angefügt wird...`,staggerGroupSize:`Gruppengröße`,staggerGroupSizeHelp:`Anzahl gleichzeitig zu startender Drucker pro Gruppe`,staggerInterval:`Intervall (Minuten)`,staggerIntervalHelp:`Verzögerung zwischen Gruppenstart`,queueDrying:`Automatische Trocknung`,queueDryingDescription:`AMS-Filament automatisch trocknen, wenn der Drucker zwischen Warteschlangen-Drucken im Leerlauf ist. Verwendet den Feuchtigkeitsschwellenwert oben.`,queueDryingEnabled:`Automatische Trocknung aktivieren`,queueDryingEnabledDescription:`AMS-Trocknung automatisch starten, wenn der Drucker im Leerlauf ist und die Feuchtigkeit über dem Schwellenwert liegt`,queueDryingBlock:`Auf Trocknung warten`,queueDryingBlockDescription:`Druckwarteschlange blockieren, bis die Trocknung abgeschlossen ist. Wenn aus, haben Drucke Vorrang.`,ambientDryingEnabled:`Umgebungstrocknung`,ambientDryingEnabledDescription:`Filament auf inaktiven Druckern automatisch trocknen, wenn die Luftfeuchtigkeit den Schwellenwert überschreitet — auch ohne Warteschlange.`,dryingPresets:`Trocknungsvoreinstellungen`,dryingPresetsDescription:`Temperatur und Dauer pro Filamenttyp. AMS 2 Pro verwendet niedrigere Temperaturen, AMS-HT unterstützt höhere.`,dryingFilament:`Filament`,humidityThresholds:`Feuchtigkeitsschwellen`,humidityThresholdsDescription:`Feuchtigkeitsauslöser pro Filamenttyp für Auto-Trocknung und Alarme. Bei gemischter Bestückung gilt der niedrigste Wert.`,humidityThresholdCol:`Schwellenwert`,humidityThresholdDefault:`Standard (unbekannte Typen)`,printModal:`Druckdialog`,expandCustomMapping:`Benutzerdefinierte Zuordnung standardmäßig erweitern`,expandCustomMappingDescription:`Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen`,authentication:`Authentifizierung`,authEnabledDescription:`Ihre Instanz ist mit Benutzerauthentifizierung gesichert`,authDisabledDescription:`Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff`,authDisabledMessage:`Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.`,enableAuthentication:`Authentifizierung aktivieren`,currentUser:`Aktueller Benutzer`,changePassword:`Passwort ändern`,admin:`Admin`,users:`Benutzer`,addUser:`Benutzer hinzufügen`,groups:`Gruppen`,addGroup:`Gruppe hinzufügen`,system:`System`,noDescription:`Keine Beschreibung`,userCount:`{{count}} Benutzer`,permissionCount:`{{count}} Berechtigungen`,createUser:`Benutzer erstellen`,username:`Benutzername`,enterUsername:`Benutzername eingeben`,password:`Passwort`,enterPassword:`Passwort eingeben`,passwordRequirements:`Mindestens 8 Zeichen, davon ein Großbuchstabe, ein Kleinbuchstabe, eine Ziffer und ein Sonderzeichen.`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Passwort bestätigen`,viewReleaseOnGitHub:`Release auf GitHub anzeigen`,turnAllPlugsOn:`Alle Stecker einschalten`,turnAllPlugsOff:`Alle Stecker ausschalten`,clearNotificationLogs:`Benachrichtigungsprotokolle löschen`,clearLogsMessage:`Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.`,clearLogs:`Protokolle löschen`,resetUiPreferences:`UI-Einstellungen zurücksetzen`,resetUiPreferencesMessage:`Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.`,resetPreferences:`Einstellungen zurücksetzen`,deleteGroupTitle:`Gruppe löschen`,deleteGroupMessage:`Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.`,deleteGroup:`Gruppe löschen`,disableAuthenticationTitle:`Authentifizierung deaktivieren`,disableAuthenticationMessage:`Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.`,disableAuthentication:`Authentifizierung deaktivieren`,configureBambuddy:`Bambuddy konfigurieren`,systemDefault:`Systemstandard`,archiveSettings:`Archiv-Einstellungen`,newWindow:`Neues Fenster`,embeddedOverlay:`Eingebettetes Overlay`,preferredSlicer:`Bevorzugter Slicer`,preferredSlicerDescription:`Slicer für das In-App-Slicen über das API-Sidecar`,openInSlicerLabel:`Im Slicer öffnen`,openInSlicerInherit:`Wie API-Slicer`,openInSlicerDescription:`Desktop-Slicer, der vom „Im Slicer öffnen"-Button verwendet wird. Auf „Wie API-Slicer" belassen, um zu erben, oder einen anderen Slicer für die lokale Nutzung wählen.`,orcaslicerKnownIssuesWarning:`OrcaSlicer 2.3.2 / 2.4.0-dev haben bekannte CLI-Bugs, die das Slicen vieler von BambuStudio erstellter 3MF-Dateien blockieren — siehe Upstream-Issues #12426 (Segfault bei bemalten Multi-Extruder-Dateien) und #13386 (zu strikte Parameter-Range-Validierung). Bis die Upstream-Fixes verfügbar sind, wird Bambu Studio empfohlen.`,useSlicerApi:`Slicer-API verwenden`,useSlicerApiDescription:`Wenn aktiv, öffnen "Slice"-Aktionen das in-App Slicer-Modal und rufen den Slicer-API-Sidecar. Aus (Standard): Übergabe an den Desktop-Slicer per URI-Schema.`,slicerCard:`Slicer`,orcaslicerApiUrl:`OrcaSlicer Sidecar-URL`,bambuStudioApiUrl:`Bambu Studio Sidecar-URL`,slicerApiUrlDescription:`URL des Slicer-API-Sidecar-Containers. Leer lassen, um die SLICER_API_URL- bzw. BAMBU_STUDIO_API_URL-Umgebungsvariablen zu nutzen.`,slicerBundlesRemoved:{title:`Slicer-Bundles (entfernt)`,description:`Der Import von Drucker-Voreinstellungs-Bundles (.bbscfg) wurde entfernt. Der Bundle-Export von BambuStudio enthält nur benutzerdefinierte Voreinstellungen, daher lieferte der Import nie die Standard-Prozesse / -Filamente, und das Slicen fiel auf eingebettete Einstellungen zurück.`,alternatives:`Verwende Einzel-Voreinstellungs-Import für individuelle Anpassungen oder synchronisiere via Bambu Cloud / Orca Cloud. Standard-Voreinstellungen kommen automatisch vom Slicer-Sidecar.`,lookupOrder:`Reihenfolge der Voreinstellungssuche beim Slicen: 1) Importiert (lokal), 2) Orca Cloud, 3) Bambu Cloud, 4) Standard (Sidecar-Fallback).`},externalCameras:`Externe Kameras`,costTracking:`Kostenverfolgung`,printsOnly:`Nur Drucke`,totalConsumption:`Gesamtverbrauch`,dataManagement:`Datenverwaltung`,storageUsage:`Speichernutzung`,storageUsageDescription:`Aufschlüsselung der Datennutzung nach Kategorie`,storageUsageTotal:`Gesamt`,storageUsageErrors:`Fehler`,storageUsageOtherBreakdown:`Sonstiges (enthält statische Assets, Skripte und Konfigurationsdateien)`,storageUsageSystem:`System`,storageUsageData:`Daten`,storageUsageUnavailable:`Speichernutzungsinformationen nicht verfügbar`,clearNotificationLogsDescription:`Benachrichtigungsprotokolle älter als 30 Tage löschen`,resetUiPreferencesDescription:`Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.`,enableHomeAssistant:`Home Assistant aktivieren`,enableMqtt:`MQTT aktivieren`,useTls:`TLS verwenden`,enableMetricsEndpoint:`Metrik-Endpunkt aktivieren`,availableMetrics:`Verfügbare Metriken`,editUser:`Benutzer bearbeiten`,deleteUserTitle:`Benutzer löschen`,groupName:`Gruppenname`,leaveEmptyForAnonymous:`Leer lassen für anonym`,leaveEmptyForNoAuth:`Leer lassen für keine Authentifizierung`,enterNewPassword:`Neues Passwort eingeben`,confirmNewPassword:`Neues Passwort bestätigen`,enterGroupName:`Gruppenname eingeben`,enterDescriptionOptional:`Beschreibung eingeben (optional)`,enterCurrentPassword:`Aktuelles Passwort eingeben`,enterNewPasswordMin6:`Neues Passwort eingeben (min. 6 Zeichen)`,toast:{keyCopied:`Schlüssel in Zwischenablage kopiert`,copyFailed:`Schlüssel konnte nicht kopiert werden`,keyAddedToBrowser:`Schlüssel zum API-Browser hinzugefügt`,clearLogsFailed:`Protokolle konnten nicht gelöscht werden`,uiPreferencesReset:`UI-Einstellungen zurückgesetzt. Wird neu geladen...`,authDisabled:`Authentifizierung erfolgreich deaktiviert`,authDisableFailed:`Authentifizierung konnte nicht deaktiviert werden`,apiKeyCreated:`API-Schlüssel erstellt`,apiKeyDeleted:`API-Schlüssel gelöscht`,userCreated:`Benutzer erfolgreich erstellt`,userUpdated:`Benutzer erfolgreich aktualisiert`,userDeleted:`Benutzer erfolgreich gelöscht`,groupCreated:`Gruppe erfolgreich erstellt`,groupUpdated:`Gruppe erfolgreich aktualisiert`,groupDeleted:`Gruppe erfolgreich gelöscht`,fillRequiredFields:`Bitte füllen Sie alle erforderlichen Felder aus`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 8 Zeichen lang sein`,passwordNeedsUppercase:`Passwort muss mindestens einen Großbuchstaben enthalten`,passwordNeedsLowercase:`Passwort muss mindestens einen Kleinbuchstaben enthalten`,passwordNeedsDigit:`Passwort muss mindestens eine Ziffer enthalten`,passwordNeedsSpecial:`Passwort muss mindestens ein Sonderzeichen enthalten`,enterGroupName:`Bitte geben Sie einen Gruppennamen ein`,settingsSaved:`Einstellungen gespeichert`,noPermissionUpdate:`Sie haben keine Berechtigung, Einstellungen zu ändern`,cameraSettingsSaved:`Kamera-Einstellungen gespeichert`,enterCameraUrl:`Bitte geben Sie eine Kamera-URL ein`,passwordChanged:`Passwort erfolgreich geändert`,connectionFailed:`Verbindung fehlgeschlagen`,testFailed:`Test fehlgeschlagen`,cameraConnected:`Kamera verbunden{{resolution}}`},testConnection:`Verbindung testen`,catalog:{spoolCatalog:`Spulenkatalog`,spoolCatalogDescription:`Leerspulengewichte nach Marke/Typ. Wird für die automatische Gewichtssuche beim Hinzufügen von Spulen verwendet.`,searchCatalog:`Katalog durchsuchen...`,addNewEntry:`Neuen Eintrag hinzufügen`,namePlaceholder:`Name (z.B. Bambu Lab - Plastik)`,weight:`Gewicht`,type:`Typ`,default:`Standard`,custom:`Benutzerdefiniert`,noMatch:`Keine Einträge entsprechen Ihrer Suche`,empty:`Keine Einträge im Katalog`,deleteEntry:`Eintrag löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,resetCatalog:`Katalog zurücksetzen`,resetConfirm:`Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Einträge werden entfernt.`,loadFailed:`Spulenkatalog konnte nicht geladen werden`,nameWeightRequired:`Name und Gewicht sind erforderlich`,entryAdded:`Eintrag hinzugefügt`,addFailed:`Eintrag konnte nicht hinzugefügt werden`,entryUpdated:`Eintrag aktualisiert`,updateFailed:`Eintrag konnte nicht aktualisiert werden`,entryDeleted:`Eintrag gelöscht`,deleteFailed:`Eintrag konnte nicht gelöscht werden`,resetSuccess:`Katalog auf Standardwerte zurückgesetzt`,resetFailed:`Katalog konnte nicht zurückgesetzt werden`,exported:`{{count}} Einträge exportiert`,imported:`{{added}} Einträge importiert ({{skipped}} übersprungen)`,importFailed:`Import fehlgeschlagen: ungültiges JSON-Format`,exportTooltip:`Katalog als JSON exportieren`,importTooltip:`Katalog aus JSON importieren`,resetTooltip:`Auf Standardwerte zurücksetzen`,selectedCount:`{{count}} ausgewählt`,deleteSelected:`Ausgewählte löschen`,bulkDeleteConfirm:`Möchten Sie {{count}} Einträge wirklich löschen?`,bulkDeleted:`{{count}} Einträge gelöscht`,bulkDeleteFailed:`Fehler beim Löschen der Einträge`,material:`Material`,spoolWeight:`Spulengewicht`,color:`Farbe`,updateSpoolWeight:`Spulengewicht aktualisieren`,filamentUpdated:`Filament aktualisiert`,filamentUpdateFailed:`Filament konnte nicht aktualisiert werden`,filamentUpdateInvalid:`Ungültige Filamentdaten`,keepExistingSpoolWeight:`Altes Gewicht für bestehende Spulen behalten`,keepExistingSpoolWeightDesc:`Bereits erstellte Spulen dieses Filamenttyps behalten das alte Leergewicht. Neue Spulen nutzen den neuen Wert.`,applyToAllSpools:`Auf alle Spulen anwenden`,applyToAllSpoolsDesc:`Alle Gewichtsberechnungen für diesen Filamenttyp nutzen sofort das neue Leergewicht.`},colorCatalog:{title:`Farbkatalog`,description:`Filamentfarben nach Hersteller/Material. Wird für die automatische Farbsuche beim Hinzufügen von Spulen verwendet.`,searchColors:`Farben durchsuchen...`,allManufacturers:`Alle Hersteller`,addNewColor:`Neue Farbe hinzufügen`,manufacturer:`Hersteller`,colorName:`Farbname`,hex:`Hex`,materialOptional:`Material (optional)`,showing:`{{filtered}} von {{total}} Farben angezeigt`,noMatch:`Keine Farben entsprechen Ihrer Suche`,empty:`Keine Farben im Katalog`,deleteColor:`Farbe löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,resetCatalog:`Farbkatalog zurücksetzen`,resetConfirm:`Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Farben werden entfernt.`,sync:`Synchron.`,starting:`Starten...`,syncTooltip:`Von FilamentColors.xyz synchronisieren (2000+ Farben)`,loadFailed:`Farbkatalog konnte nicht geladen werden`,fieldsRequired:`Hersteller, Farbname und Hex-Farbe sind erforderlich`,colorAdded:`Farbe hinzugefügt`,addFailed:`Farbe konnte nicht hinzugefügt werden`,colorUpdated:`Farbe aktualisiert`,updateFailed:`Farbe konnte nicht aktualisiert werden`,colorDeleted:`Farbe gelöscht`,deleteFailed:`Farbe konnte nicht gelöscht werden`,resetSuccess:`Farbkatalog auf Standardwerte zurückgesetzt`,resetFailed:`Katalog konnte nicht zurückgesetzt werden`,syncUpToDate:`Bereits aktuell ({{count}} Farben geprüft)`,syncComplete:`{{added}} neue Farben hinzugefügt ({{skipped}} bereits vorhanden)`,syncError:`Sync-Fehler`,syncFailed:`Synchronisierung von FilamentColors.xyz fehlgeschlagen`,exported:`{{count}} Farben exportiert`,imported:`{{added}} Farben importiert ({{skipped}} übersprungen)`,importFailed:`Import fehlgeschlagen: ungültiges JSON-Format`,selectedCount:`{{count}} ausgewählt`,deleteSelected:`Ausgewählte löschen`,bulkDeleteConfirm:`Möchten Sie {{count}} Farben wirklich löschen?`,bulkDeleted:`{{count}} Farben gelöscht`,bulkDeleteFailed:`Fehler beim Löschen der Farben`},dateFormat:`Datumsformat`,dateFormatUs:`US (MM/TT/JJJJ)`,dateFormatEu:`EU (TT/MM/JJJJ)`,dateFormatIso:`ISO (JJJJ-MM-TT)`,timeFormat:`Zeitformat`,timeFormat12:`12-Stunden (3:30 PM)`,timeFormat24:`24-Stunden (15:30)`,defaultPrinter:`Standarddrucker`,defaultPrinterDescription:`Diesen Drucker für Uploads, Nachdrucke und andere Vorgänge vorauswählen.`,slicerBambuStudio:`Bambu Studio`,slicerOrcaSlicer:`OrcaSlicer`,sidebarOrderDescription:`Nutze das Seitenleisten-Layout, um Elemente neu anzuordnen, Sichtbarkeit zurückzusetzen und benutzerdefinierte Links zu verwalten.`,setDefault:`Standard setzen`,sidebarOrderSetDefaultHint:`Standard setzen übernimmt die aktuelle Menüreihenfolge für Benutzer, die ihre noch nicht angepasst haben.`,sidebarDefaultSet:`Standard-Menüreihenfolge wurde festgelegt.`,sidebarDefaultCleared:`Standard-Menüreihenfolge gelöscht.`,sidebarDefaultFailed:`Festlegen der Standard-Menüreihenfolge fehlgeschlagen.`,reset:`Zurücksetzen`,darkMode:`Dunkelmodus`,lightMode:`Hellmodus`,active:`(aktiv)`,background:`Hintergrund`,accent:`Akzent`,style:`Stil`,bgNeutral:`Neutral`,bgWarm:`Warm`,bgCool:`Kühl`,bgOled:`OLED Schwarz`,bgSlate:`Schieferblau`,bgForest:`Waldgrün`,accentGreen:`Grün`,accentTeal:`Türkis`,accentBlue:`Blau`,accentOrange:`Orange`,accentPurple:`Lila`,accentRed:`Rot`,styleClassic:`Klassisch`,styleGlow:`Leuchtend`,styleVibrant:`Lebendig`,themeToggleHint:`Zwischen Dunkel-, Hell- und Systemmodus mit dem Symbol in der Seitenleiste wechseln.`,autoArchivePrints:`Drucke automatisch archivieren`,autoArchiveDescription:`3MF-Dateien automatisch speichern, wenn Drucke abgeschlossen sind`,saveThumbnailsDescription:`Vorschaubilder aus 3MF-Dateien extrahieren und speichern`,captureFinishPhotoDescription:`Foto von der Druckerkamera aufnehmen, wenn der Druck abgeschlossen ist. Bambuddy zeichnet während des Drucks einen kurzen Zeitraffer auf, damit das Foto aus dem Moment vor dem Absenken der Druckplatte stammen kann. Die Zeitraffer-Datei bleibt erhalten, wenn du den Zeitraffer für diesen Druck aktiviert hast, andernfalls wird sie nach Aufnahme des Fotos automatisch gelöscht.`,ffmpegNotInstalled:`ffmpeg nicht installiert`,ffmpegRequired:`Kameraaufnahme benötigt ffmpeg. Installieren über brew install ffmpeg (macOS) oder apt install ffmpeg (Linux).`,camera:`Kamera`,cameraViewMode:`Kamera-Ansichtsmodus`,cameraOverlayDescription:`Kamera öffnet sich als größenveränderbares Overlay auf dem Hauptbildschirm`,cameraWindowDescription:`Kamera öffnet sich in einem separaten Browserfenster`,externalCamerasDescription:`Externe Kameras konfigurieren, um die eingebaute Druckerkamera zu ersetzen. Unterstützt MJPEG-Streams, RTSP, HTTP-Snapshots und USB-Kameras (V4L2). Wenn aktiviert, wird die externe Kamera für Live-Ansicht und Abschlussfotos verwendet.`,cameraPlaceholderUsb:`Gerätepfad (/dev/video0)`,cameraPlaceholderUrl:`Kamera-URL (rtsp://... oder http://...)`,cameraTypeMjpeg:`MJPEG-Stream`,cameraTypeRtsp:`RTSP-Stream`,cameraTypeSnapshot:`HTTP-Snapshot`,cameraTypeUsb:`USB-Kamera (V4L2)`,cameraSnapshotUrl:`Snapshot-URL (optional)`,cameraSnapshotUrlPlaceholder:`http://192.168.1.61:1984/api/frame.jpeg?src=printer`,cameraSnapshotUrlHelp:`URL für Einzelbildaufnahmen — wird für Benachrichtigungs-Vorschaubilder, Abschlussfotos, Schicht-Zeitraffer und Plattenerkennung verwendet. Zeitraffer und Plattenerkennung benötigen jeweils eigene drucker-spezifische Schalter — diese URL ist nur die Bildquelle, die sie verwenden, wenn sie aktiv sind. Leer lassen, um Bilder aus dem oben konfigurierten Live-Stream zu verwenden. Nützlich für go2rtc (/api/frame.jpeg) und IP-Kameras mit dediziertem Snapshot-Endpunkt.`,cameraRotation:`Drehung`,test:`Testen`,connected:`Verbunden`,disconnected:`Getrennt`,currency:`Währung`,defaultFilamentCost:`Standard-Filamentkosten (pro kg)`,electricityCost:`Stromkosten pro kWh`,energyDisplayMode:`Energieanzeige-Modus`,energyModePrintDescription:`Dashboard zeigt Summe der während Drucken verbrauchten Energie`,energyModeTotalDescription:`Dashboard zeigt Gesamtenergie der Smart Plugs`,fileManager:`Dateimanager`,createArchiveEntry:`Archiveintrag beim Drucken erstellen`,createArchiveEntryDescription:`Beim Drucken aus dem Dateimanager optional einen Archiveintrag erstellen`,lowDiskSpaceWarning:`Warnung bei wenig Speicherplatz`,lowDiskSpaceDescription:`Warnung anzeigen, wenn freier Speicherplatz unter diesen Schwellenwert fällt`,printerFirmware:`Drucker-Firmware`,checkFirmwareDescription:`Nach Firmware-Updates von Bambu Lab suchen`,bambuddySoftware:`Bambuddy-Software`,autoCheckDescription:`Automatisch beim Start nach neuen Versionen suchen`,checkNow:`Jetzt prüfen`,updateAvailableVersion:`Update verfügbar: v{{version}}`,releaseNotes:`Versionshinweise`,updateViaDocker:`Update über Docker Compose:`,updateViaHomeAssistant:`Updates werden vom Home Assistant Supervisor verwaltet. Öffne Einstellungen → Add-ons → Bambuddy in Home Assistant, um die neue Version zu installieren.`,updateViaWindowsInstaller:`Windows-Installationen werden durch erneutes Ausführen des Installers aktualisiert. Lade die neue Version unten herunter — deine Daten, Einstellungen und Drucker bleiben erhalten.`,downloadWindowsInstaller:`Installer für v{{version}} herunterladen`,installUpdate:`Update installieren`,latestVersionRunning:`Sie verwenden die neueste Version`,failedToCheckUpdates:`Update-Prüfung fehlgeschlagen: {{error}}`,backupRestore:`Sicherung & Wiederherstellung`,backupRestoreDescription:`Einstellungen exportieren/importieren und GitHub-Backup konfigurieren`,goToBackup:`Zur Sicherung`,externalUrl:`Externe URL`,externalUrlDescription:`Die externe URL, unter der Bambuddy erreichbar ist. Wird für Benachrichtigungsbilder und externe Integrationen verwendet.`,bambuddyUrl:`Bambuddy-URL`,externalUrlHint:`Protokoll und Port angeben (z.B. http://192.168.1.100:8000)`,ftpRetry:`FTP-Wiederholung`,ftpRetryDescription:`FTP-Operationen bei unzuverlässigem Drucker-WLAN wiederholen. Gilt für 3MF-Downloads, Druck-Uploads, Zeitraffer-Downloads und Firmware-Updates.`,autoRetryDescription:`Fehlgeschlagene FTP-Operationen automatisch wiederholen`,retryAttempts:`Wiederholungsversuche`,retryDelay:`Wiederholungsverzögerung`,connectionTimeout:`Verbindungs-Timeout`,time_one:`{{count}} Mal`,time_other:`{{count}} Mal`,second_one:`{{count}} Sekunde`,second_other:`{{count}} Sekunden`,nSeconds:`{{count}} Sekunden`,increaseForWeakWifi:`Erhöhen für Drucker mit schwachem WLAN`,homeAssistant:`Home Assistant`,homeAssistantFullDescription:`Mit Home Assistant verbinden, um Smart Plugs über die HA REST-API zu steuern. Unterstützt Switch-, Light-, Input_Boolean- und Script-Entitäten.`,homeAssistantUrl:`Home Assistant URL`,longLivedAccessToken:`Langlebiges Zugriffstoken`,haTokenHint:`Token in HA erstellen: Profil → Langlebige Zugriffstoken → Token erstellen`,connectionSuccessful:`Verbindung erfolgreich`,connectionFailed:`Verbindung fehlgeschlagen`,haConnectionSuccess:`Erfolgreich mit Home Assistant verbunden.`,haConnectionFailed:`Verbindung zu Home Assistant fehlgeschlagen.`,mqttPublishing:`MQTT-Veröffentlichung`,mqttDescription:`BamBuddy-Ereignisse an einen externen MQTT-Broker zur Integration mit Node-RED, Home Assistant und anderen Automatisierungssystemen veröffentlichen.`,mqttEnableDescription:`Ereignisse an externen MQTT-Broker veröffentlichen`,brokerHostname:`Broker-Hostname`,port:`Port`,usernameOptional:`Benutzername (optional)`,passwordOptional:`Passwort (optional)`,topicPrefix:`Topic-Präfix`,topicPrefixHint:`Topics werden sein: {{prefix}}/printers//status, etc.`,prometheusMetrics:`Prometheus-Metriken`,prometheusEndpointDescription:`Druckermetriken unter /api/v1/metrics für Prometheus/Grafana-Überwachung bereitstellen.`,bearerTokenOptional:`Bearer-Token (optional)`,bearerTokenHint:`Wenn gesetzt, müssen Anfragen Authorization: Bearer enthalten`,metricsConnectionStatus:`Verbindungsstatus`,metricsPrinterState:`Druckerstatus (idle/printing/etc)`,metricsPrintProgress:`Druckfortschritt 0-100%`,metricsBedTemp:`Betttemperatur`,metricsNozzleTemp:`Düsentemperatur`,metricsPrintsTotal:`Gesamtdrucke nach Ergebnis`,metricsMore:`...und mehr (Schichten, Lüfter, Warteschlange, Filamentverbrauch)`,smartPlugsDescription:`Smart Plugs (Tasmota oder Home Assistant) verbinden, um Stromsteuerung zu automatisieren und Energieverbrauch für Ihre Drucker zu verfolgen.`,allOn:`Alle Ein`,allOff:`Alle Aus`,addSmartPlug:`Smart Plug hinzufügen`,energySummary:`Energieübersicht`,currentPower:`Aktuelle Leistung`,plugsOnline:`{{reachable}}/{{total}} Plugs online`,today:`Heute`,yesterday:`Gestern`,total:`Gesamt`,enablePlugsForSummary:`Plugs aktivieren, um Energieübersicht zu sehen`,addNotificationProvider:`Hinzufügen`,systemBadge:`(System)`,creating:`Erstellen...`,changing:`Ändern...`,deleteUserAndItems:`Benutzer UND dessen Elemente löschen`,deleteUserKeepItems:`Benutzer löschen, Elemente behalten (werden herrenlos)`,ok:`OK`,twoFa:{totpTitle:`Authenticator-App (TOTP)`,totpDesc:`Verwende eine Authenticator-App wie Google Authenticator, Aegis oder Authy.`,emailOtpTitle:`E-Mail OTP`,emailOtpDesc:`Sende einen Einmalcode an {{email}} beim Einloggen.`,emailOtpNoEmail:`Füge eine E-Mail-Adresse zu deinem Konto hinzu, um diese Methode zu aktivieren.`,addEmailFirst:`Dein Konto hat keine E-Mail-Adresse. Bitte einen Administrator, eine hinzuzufügen.`,setupTotp:`Authenticator-App einrichten`,setupAuthApp:`Authenticator-App einrichten`,setupInstructions:`Scanne den QR-Code mit deiner Authenticator-App und bestätige mit einem Code.`,manualEntry:`Kein Scanner? Gib dieses Secret manuell ein:`,scannedContinue:`Code gescannt — weiter`,enterCodeToConfirm:`Gib den 6-stelligen Code aus deiner Authenticator-App ein, um die Einrichtung zu bestätigen.`,activate:`Aktivieren`,disableTotp:`Authenticator deaktivieren`,disableConfirmHint:`Gib einen gültigen TOTP-Code oder einen Backup-Code ein, um den Authenticator zu deaktivieren.`,totpDisabled:`Authenticator-App deaktiviert.`,emailOtpEnabled:`E-Mail OTP aktiviert.`,emailOtpDisabled:`E-Mail OTP deaktiviert.`,smtpRequired:`Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen.`,invalidCode:`Ungültiger Code. Bitte erneut versuchen.`,enableEmailOtp:`E-Mail OTP aktivieren`,disableEmailOtp:`E-Mail OTP deaktivieren`,emailSetupEnterCode:`Ein Bestätigungscode wurde an Ihre E-Mail-Adresse gesendet. Geben Sie ihn unten ein, um zu bestätigen, dass Ihnen dieses Postfach gehört.`,verifyAndEnable:`Verifizieren & Aktivieren`,emailDisablePasswordHint:`Geben Sie Ihr Kontopasswort ein, um die Deaktivierung des E-Mail OTP zu bestätigen.`,passwordPlaceholder:`Passwort eingeben`,backupCodesTitle:`Backup-Codes sichern`,backupCodesWarning:`Speichere diese Codes sicher. Jeder Code kann nur einmal verwendet werden und wird nicht erneut angezeigt.`,backupCodesRemaining:`{{count}} Backup-Codes verbleibend`,savedCodes:`Codes gespeichert`,regenBackup:`Backup-Codes neu generieren`,regenBackupHint:`Gib deinen aktuellen TOTP-Code ein, um 10 neue Backup-Codes zu generieren. Alle bestehenden Codes werden ungültig.`,newBackupCodes:`Neue Backup-Codes`,linkedAccounts:`Verknüpfte SSO-Konten`,linkedAccountsDesc:`Diese externen Identitätsanbieter sind mit deinem Konto verknüpft.`,oidcUnlinked:`Konto getrennt.`},sessionPolicy:{title:`Sitzungsrichtlinie`,description:`Maximale Sitzungsdauer für neue Benutzeranmeldungen. Bereits ausgegebene Token behalten ihren ursprünglichen Ablauf.`,preset24h:`24 Stunden`,preset7d:`7 Tage`,preset30d:`30 Tage`,customHoursLabel:`Individuelle Sitzungsdauer in Stunden`,hoursSuffix:`Stunden`,warning:`Längere Sitzungen reduzieren den automatischen Abmeldeschutz. Nur für vertrauenswürdige Einzelnutzer-Installationen empfohlen.`},oidc:{title:`SSO / OIDC-Anbieter`,desc:`Konfiguriere OpenID Connect-Anbieter für Single Sign-On.`,addProvider:`Anbieter hinzufügen`,newProvider:`Neuer Anbieter`,empty:`Noch keine OIDC-Anbieter konfiguriert.`,created:`Anbieter erstellt.`,updated:`Anbieter aktualisiert.`,deleted:`Anbieter gelöscht.`,refreshIcon:`Icon neu laden`,removeIcon:`Icon entfernen`,iconRefreshed:`Icon aktualisiert.`,iconRemoved:`Icon entfernt.`,iconFetchFailed:`Icon konnte von der Anbieter-URL nicht geladen werden.`,deleteTitle:`Anbieter löschen`,deleteMessage:`"{{name}}" löschen? Alle verknüpften Benutzerkonten werden getrennt.`,form:{name:`Anzeigename`,issuerUrl:`Aussteller-URL`,clientId:`Client-ID`,clientSecret:`Client-Secret`,scopes:`Bereiche`,iconUrl:`Symbol-URL (optional)`,enabled:`Aktiviert`,autoCreate:`Benutzer automatisch anlegen`,autoCreateDesc:`Erstellt beim ersten Login automatisch ein lokales Konto.`,autoLink:`Bestehende Konten automatisch verknüpfen`,autoLinkDesc:`Verknüpft beim ersten Login vorhandene lokale Konten anhand der E-Mail-Adresse.`,secretHint:`leer lassen zum Beibehalten`,secretPlaceholder:`neues Secret`,emailClaim:`E-Mail-Claim`,emailClaimDesc:`JWT-Claim für die E-Mail-Identität. Für Azure Entra ID 'preferred_username' oder 'upn' verwenden (sendet kein email_verified). Nur vertrauenswürdige Claim-Namen verwenden.`,emailClaimPlaceholder:`E-Mail`,emailClaimCustomClaimAutoLinkWarning:`Benutzerdefinierte Claims sind für die Auto-Verknüpfung nur sicher, wenn der Wert vom Mandanten verwaltet wird (z. B. Azure Entra ID upn / preferred_username). Aktiviere Auto-Verknüpfung nicht, wenn dein IdP Benutzern erlaubt, diesen Claim selbst zu setzen.`,requireEmailVerified:`E-Mail-Verifizierung erforderlich`,requireEmailVerifiedDesc:`E-Mail-Claim nur akzeptieren, wenn der Provider ihn als verifiziert markiert.`,requireEmailVerifiedWarning:`Warnung: E-Mail wird auch ohne Verifizierung akzeptiert. Nur bei vertrauenswürdigen Providern verwenden.`,requireEmailVerifiedAutoLink:`Auto-Verknüpfung zuerst deaktivieren, um diese Einstellung zu ändern.`,defaultGroup:`Standardgruppe`,defaultGroupDesc:`Gruppe, der automatisch erstellte Benutzer zugewiesen werden. Fallback auf Viewers, wenn nicht gesetzt.`,defaultGroupViewersFallback:`Viewers (Standard)`}},encryption:{title:`MFA-Verschlüsselungsstatus`,enabledFromEnv:`At-Rest-Verschlüsselung aktiv (Schlüssel aus Umgebungsvariable MFA_ENCRYPTION_KEY)`,enabledFromFile:`At-Rest-Verschlüsselung aktiv (Schlüssel aus dem Datenverzeichnis geladen)`,enabledGenerated:`At-Rest-Verschlüsselung aktiv mit automatisch generiertem Schlüssel`,notConfigured:`At-Rest-Verschlüsselung nicht konfiguriert`,notConfiguredDesc:`TOTP-Geheimnisse und OIDC-Client-Secrets werden im Klartext gespeichert. Setze MFA_ENCRYPTION_KEY oder starte Bambuddy mit beschreibbarem Datenverzeichnis neu, damit ein Schlüssel automatisch erzeugt wird.`,allEncrypted:`Alle MFA-Geheimnisse sind verschlüsselt gespeichert.`,legacyRowsLabel:`Klartext-Zeilen (Altbestand)`,encryptedRowsLabel:`Verschlüsselte Zeilen`,legacyRowsWarning:`{{count}} Klartext-Zeile(n) erkannt. Den OIDC-Provider neu speichern oder den Authenticator des Benutzers neu einrichten, um die Daten verschlüsselt abzulegen.`,backupHint:`Der automatisch erzeugte Schlüssel liegt unter DATA_DIR/.mfa_encryption_key und wird in lokalen Backup-ZIPs mitgesichert. Backups sicher aufbewahren oder MFA_ENCRYPTION_KEY explizit setzen.`,decryptionBrokenTitle:`Verschlüsselungsschlüssel fehlt`,decryptionBrokenError:`{{count}} verschlüsselte Datensätze können nicht entschlüsselt werden, weil der Schlüssel nicht mehr verfügbar ist. Den vorherigen MFA_ENCRYPTION_KEY oder DATA_DIR/.mfa_encryption_key wiederherstellen.`,migrationErrorWarning:`{{count}} Legacy-Eintrag/Einträge konnten beim Start nicht verschlüsselt werden. Prüfen Sie die Server-Logs und starten Sie Bambuddy neu.`}},notification:{printStarted:{title:`Druck gestartet`,body:`{{printer}}: {{filename}} wird gedruckt`},printCompleted:{title:`Druck abgeschlossen`,body:`{{printer}}: {{filename}} erfolgreich abgeschlossen`},printFailed:{title:`Druck fehlgeschlagen`,body:`{{printer}}: {{filename}} ist fehlgeschlagen`},printStopped:{title:`Druck gestoppt`,body:`{{printer}}: {{filename}} wurde gestoppt`},printProgress:{title:`Druckfortschritt`,body:`{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen`},printerOffline:{title:`Drucker offline`,body:`{{printer}} ist offline`},printerError:{title:`Druckerfehler`,body:`{{printer}} – {{error}}`},filamentLow:{title:`Filament niedrig`,body:`{{printer}}: Filament geht zur Neige`},maintenanceDue:{title:`Wartung fällig`,body:`{{printer}}: {{items}} benötigen Aufmerksamkeit`}},errors:{generic:`Etwas ist schiefgelaufen`,networkError:`Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.`,notFound:`Nicht gefunden`,unauthorized:`Nicht autorisiert`,serverError:`Serverfehler`,validationError:`Bitte überprüfen Sie Ihre Eingabe`,printerConnectionFailed:`Verbindung zum Drucker fehlgeschlagen`,saveFailed:`Speichern fehlgeschlagen`,deleteFailed:`Löschen fehlgeschlagen`,loadFailed:`Laden der Daten fehlgeschlagen`},hmsErrors:{title:`Fehler - {{name}}`,noErrors:`Keine Fehler`,viewOnWiki:`Im Bambu Lab Wiki ansehen`,clearInstructions:`Löschen Sie die Fehler am Drucker, um sie hier zu entfernen.`,clearErrors:`Fehler löschen`,clearSuccess:`HMS-Fehler gelöscht`,clearFailed:`HMS-Fehler konnten nicht gelöscht werden`},mqttDebug:{title:`MQTT-Debug-Protokoll`,searchPlaceholder:`Topic oder Payload suchen...`,noMessages:`Noch keine Nachrichten protokolliert`,startLoggingHint:`Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen`,noMessagesMatch:`Keine Nachrichten entsprechen Ihrem Filter`,adjustFilterHint:`Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen`,incoming:`Eingehend`,outgoing:`Ausgehend`,loggingStopped:`Protokollierung gestoppt`,loggingActive:`Protokollierung aktiv - Nachrichten werden automatisch aktualisiert`,startLogging:`Protokollierung starten`,stopLogging:`Protokollierung stoppen`,clearLog:`Protokoll löschen`,topic:`Thema`,timestamp:`Zeitstempel`,direction:`Richtung`,all:`Alle`},printerFiles:{title:`Dateimanager`,storageUsed:`Belegt:`,storageFree:`Frei:`,filterPlaceholder:`Dateien filtern...`,deleteButton:`Löschen`,deleteFiles:`{{count}} Dateien löschen`,deleteFileConfirm:`"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.`,deleteFilesConfirm:`{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.`,noFiles:`Keine Dateien auf dem Drucker`,loadingFiles:`Dateien werden geladen...`,failedToLoad:`Dateien konnten nicht geladen werden`,toast:{filesDeleted:`{{count}} Datei(en) gelöscht`,deleteFailed:`Löschen fehlgeschlagen: {{error}}`}},confirm:{delete:`Möchten Sie dies wirklich löschen?`,unsavedChanges:`Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?`,clearQueue:`Möchten Sie die Warteschlange wirklich leeren?`},login:{title:`Bambuddy Anmeldung`,subtitle:`Melden Sie sich bei Ihrem Konto an`,username:`Benutzername`,usernamePlaceholder:`Benutzername eingeben`,usernameOrEmail:`Benutzername oder E-Mail`,usernameOrEmailPlaceholder:`Benutzername oder @ E-Mail`,password:`Passwort`,passwordPlaceholder:`Passwort eingeben`,signIn:`Anmelden`,signingIn:`Anmeldung läuft...`,rememberMe:`Angemeldet bleiben`,forgotPassword:`Passwort vergessen?`,loginSuccess:`Erfolgreich angemeldet`,loginFailed:`Anmeldung fehlgeschlagen`,enterCredentials:`Bitte Benutzername und Passwort eingeben`,enterEmail:`Bitte geben Sie Ihre E-Mail-Adresse ein`,oidcLoginFailed:`OIDC-Anmeldung fehlgeschlagen`,oidcErrors:{providerError:`Der Identity-Provider hat einen Fehler zurückgegeben`,missingParameters:`Dem OIDC-Callback fehlen erforderliche Parameter`,invalidState:`OIDC-State ist ungültig oder wurde bereits verwendet`,stateExpired:`OIDC-Sitzung abgelaufen — bitte erneut versuchen`,providerNotFound:`OIDC-Provider nicht gefunden`,discoveryFailed:`OIDC-Discovery-Dokument konnte nicht abgerufen werden`,invalidDiscovery:`OIDC-Discovery-Dokument ist ungültig`,networkError:`Netzwerkfehler beim OIDC-Token-Austausch`,badResponse:`Unerwartete Antwort beim OIDC-Token-Austausch`,noIdToken:`OIDC-Provider hat kein ID-Token zurückgegeben`,validationFailed:`OIDC-Token-Validierung fehlgeschlagen`,nonceMismatch:`OIDC-Nonce stimmt nicht überein — möglicher Replay-Angriff`,missingSubClaim:`OIDC-Token enthält keinen Sub-Claim`,noLinkedAccount:`Kein lokales Konto mit dieser OIDC-Identität verknüpft`,accountInactive:`Ihr Konto ist inaktiv`,userResolutionFailed:`Ihr Konto konnte nicht aufgelöst werden`,internalError:`Interner Fehler beim OIDC-Login`,tokenExchangeFailed:`OIDC-Token-Austausch fehlgeschlagen`},forgotPasswordTitle:`Passwort vergessen`,forgotPasswordMessage:`Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.`,forgotPasswordEmailMessage:`Geben Sie Ihre E-Mail-Adresse ein und wir senden Ihnen ein neues Passwort.`,emailAddress:`E-Mail-Adresse`,emailPlaceholder:`ihre.email@beispiel.de`,cancel:`Abbrechen`,sending:`Wird gesendet...`,sendResetEmail:`Zurücksetzungs-E-Mail senden`,howToReset:`So setzen Sie Ihr Passwort zurück:`,resetStep1:`Kontaktieren Sie Ihren Bambuddy-Administrator`,resetStep2:`Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen`,resetStep3:`Er kann ein neues temporäres Passwort für Sie festlegen`,resetStep4:`Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen`,gotIt:`Verstanden`,resetPassword:{title:`Neues Passwort festlegen`,subtitle:`Geben Sie unten Ihr neues Passwort ein und bestätigen Sie es.`,newPassword:`Neues Passwort`,newPasswordPlaceholder:`Mindestens 8 Zeichen`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Neues Passwort wiederholen`,saving:`Wird gespeichert…`,submit:`Neues Passwort festlegen`,backToLogin:`Zurück zur Anmeldung`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 8 Zeichen lang sein`,resetFailed:`Passwort zurücksetzen fehlgeschlagen. Der Link ist möglicherweise abgelaufen.`},twoFA:{title:`Zwei-Faktor-Authentifizierung`,subtitle:`Ihr Konto ist mit 2FA geschützt. Geben Sie unten den Bestätigungscode ein.`,methodAuthenticator:`Authenticator-App`,methodEmail:`E-Mail-Code`,methodBackup:`Wiederherstellungscode`,instructionsTotp:`Öffnen Sie Ihre Authenticator-App und geben Sie den 6-stelligen Code für Bambuddy ein.`,instructionsEmail:`Ein 6-stelliger Code wurde an Ihre E-Mail-Adresse gesendet. Er ist 10 Minuten gültig.`,instructionsEmailNotSent:`Klicken Sie unten, um einen Bestätigungscode per E-Mail zu erhalten.`,instructionsBackup:`Geben Sie einen Ihrer 8-stelligen Wiederherstellungscodes ein. Jeder Code kann nur einmal verwendet werden.`,sendCodeButton:`Code per E-Mail senden`,sendingCode:`Wird gesendet...`,resendCode:`Code erneut senden`,codeLabel:`Bestätigungscode`,backupCodeLabel:`Wiederherstellungscode`,codePlaceholder:`000000`,backupCodePlaceholder:`XXXXXXXX`,verifyButton:`Bestätigen`,verifyingButton:`Wird überprüft...`,backToLogin:`← Zurück zur Anmeldung`,orContinueWith:`oder anmelden mit`,signInWith:`Anmelden mit {{provider}}`,enterCode:`Bitte geben Sie den Bestätigungscode ein`,sendCodeFailed:`Bestätigungscode konnte nicht gesendet werden`,invalidCode:`Ungültiger Code. Bitte erneut versuchen.`}},setup:{title:`Bambuddy Einrichtung`,subtitle:`Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz`,enableAuth:`Authentifizierung aktivieren`,adminAccount:`Admin-Konto`,adminAccountDesc:`Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.`,adminUsername:`Admin-Benutzername`,adminPassword:`Admin-Passwort`,optionalIfAdminExists:`(optional, wenn Admin-Benutzer existieren)`,adminUsernamePlaceholder:`Admin-Benutzernamen eingeben (optional)`,adminPasswordPlaceholder:`Admin-Passwort eingeben (optional)`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Admin-Passwort bestätigen`,settingUp:`Einrichtung läuft...`,completeSetup:`Einrichtung abschließen`,toast:{authEnabledAdminCreated:`Authentifizierung aktiviert und Admin-Benutzer erstellt`,authEnabledExistingAdmins:`Authentifizierung mit vorhandenen Admin-Benutzern aktiviert`,setupCompleted:`Einrichtung abgeschlossen`,enterBothCredentials:`Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`}},changePassword:{title:`Passwort ändern`,currentPassword:`Aktuelles Passwort`,currentPasswordPlaceholder:`Aktuelles Passwort eingeben`,newPassword:`Neues Passwort`,newPasswordPlaceholder:`Neues Passwort eingeben (min. 6 Zeichen)`,confirmPassword:`Neues Passwort bestätigen`,confirmPasswordPlaceholder:`Neues Passwort bestätigen`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`,changing:`Wird geändert...`,success:`Passwort erfolgreich geändert`,failed:`Passwortänderung fehlgeschlagen`},plateAlert:{title:`Druck pausiert!`,message:`Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.`,understand:`Verstanden`},camera:{title:`Kameraansicht`,invalidPrinterId:`Ungültige Drucker-ID`,live:`Live`,snapshot:`Schnappschuss`,restartStream:`Stream neu starten`,refreshSnapshot:`Schnappschuss aktualisieren`,fullscreen:`Vollbild`,exitFullscreen:`Vollbild beenden`,connectingToCamera:`Verbinde mit Kamera...`,capturingSnapshot:`Schnappschuss wird aufgenommen...`,connectionLost:`Verbindung verloren`,connectionFailed:`Kameraverbindung fehlgeschlagen`,reconnecting:`Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})`,reconnectNow:`Jetzt verbinden`,cameraUnavailable:`Kamera nicht verfügbar`,cameraUnavailableDesc:`Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.`,noCamera:`Keine Kamera verfügbar`,retry:`Erneut versuchen`,cameraStream:`Kamera-Stream`,zoomOut:`Verkleinern`,zoomIn:`Vergrößern`,resetZoom:`Zoom zurücksetzen`,recording:`Aufnahme`,startRecording:`Aufnahme starten`,stopRecording:`Aufnahme stoppen`,chamberLight:`Kammerbeleuchtung umschalten`,unavailable:`Kamera nicht verfügbar`,diagnose:{button:`Diagnose`,modalTitle:`Kamera-Diagnose`,running:`Diagnose läuft...`,runFailed:`Diagnose konnte nicht ausgeführt werden: {{error}}`,retry:`Erneut ausführen`,stage:{tcp_reachable:`Netzwerk-Erreichbarkeit`,first_frame:`Bilderfassung`,live_stream_active:`Live-Stream aktiv`},summary:{all_ok:`Kamera funktioniert. Die Diagnose hat alle Phasen erfolgreich abgeschlossen.`,live_stream_active_healthy:`Kamera streamt gerade mit aktuellen Bildern — kein Test nötig.`,printer_unreachable:`Drucker ist nicht erreichbar. Prüfe IP-Adresse, Netzwerkverbindung und ob der Drucker eingeschaltet ist.`,camera_port_closed:`Drucker ist erreichbar, aber der Kamera-Port ist geschlossen. Stelle sicher, dass LAN-Modus und Entwicklermodus in den Druckereinstellungen aktiviert sind.`,no_frame:`Verbindung zur Kamera hergestellt, aber keine Bilder empfangen. Versuche es erneut oder prüfe, ob die Kamera in den Druckereinstellungen aktiviert ist.`,unknown_failure:`Kamera-Diagnose aus unbekanntem Grund fehlgeschlagen. Prüfe das Support-Log für Details.`},meta:{protocol:`Protokoll`,port:`Port`,profile:`Profil`}}},groups:{title:`Gruppenverwaltung`,subtitle:`Berechtigungsgruppen für Zugriffskontrolle verwalten`,backToSettings:`Zurück zu Einstellungen`,createGroup:`Gruppe erstellen`,noPermission:`Sie haben keine Berechtigung, auf diese Seite zuzugreifen.`,system:`System`,noDescription:`Keine Beschreibung`,usersCount:`{{count}} Benutzer`,permissionsCount:`{{count}} Berechtigungen`,edit:`Bearbeiten`,delete:`Löschen`,toast:{created:`Gruppe erfolgreich erstellt`,updated:`Gruppe erfolgreich aktualisiert`,deleted:`Gruppe erfolgreich gelöscht`,enterGroupName:`Bitte geben Sie einen Gruppennamen ein`},modal:{editGroup:`Gruppe bearbeiten`,createGroup:`Gruppe erstellen`,cancel:`Abbrechen`,saving:`Speichern...`,creating:`Erstellen...`,saveChanges:`Änderungen speichern`},form:{groupName:`Gruppenname`,groupNamePlaceholder:`Gruppennamen eingeben`,systemGroupWarning:`Systemgruppennamen können nicht geändert werden`,description:`Beschreibung`,descriptionPlaceholder:`Beschreibung eingeben (optional)`,permissions:`Berechtigungen ({{count}} ausgewählt)`},deleteModal:{title:`Gruppe löschen`,message:`Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.`,confirm:`Gruppe löschen`},editor:{title:`Gruppe bearbeiten`,createTitle:`Gruppe erstellen`,search:`Berechtigungen suchen...`,selectAll:`Alle auswählen`,clearAll:`Alle abwählen`,permissionsSelected:`{{count}} ausgewählt`,noResults:`Keine Berechtigungen entsprechen Ihrer Suche`}},users:{title:`Benutzerverwaltung`,subtitle:`Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten`,backToSettings:`Zurück zu Einstellungen`,createUser:`Benutzer erstellen`,noPermission:`Sie haben keine Berechtigung, auf diese Seite zuzugreifen.`,admin:`Admin`,noGroups:`Keine Gruppen`,active:`Aktiv`,inactive:`Inaktiv`,edit:`Bearbeiten`,delete:`Löschen`,system:`System`,noGroupsAvailable:`Keine Gruppen verfügbar`,table:{username:`Benutzername`,groups:`Gruppen`,status:`Status`,actions:`Aktionen`},toast:{created:`Benutzer erfolgreich erstellt`,updated:`Benutzer erfolgreich aktualisiert`,deleted:`Benutzer erfolgreich gelöscht`,fillRequired:`Bitte füllen Sie alle Pflichtfelder aus`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`,ldapProvisioned:`LDAP-Benutzer „{{username}}" bereitgestellt`},modal:{createUser:`Benutzer erstellen`,editUser:`Benutzer bearbeiten`,cancel:`Abbrechen`,creating:`Erstellen...`,saving:`Speichern...`,saveChanges:`Änderungen speichern`,advancedAuthSubtitle:`mit erweiterter Authentifizierung`,tabsAriaLabel:`Benutzerquelle`,localTab:`Lokal`,ldapTab:`LDAP`,ldapSearchLabel:`Verzeichnis durchsuchen`,ldapSearchPlaceholder:`Benutzername, Name oder E-Mail eingeben...`,ldapMinChars:`Mindestens 2 Zeichen für die Suche eingeben`,ldapTypeToSearch:`Tippen, um das LDAP-Verzeichnis zu durchsuchen`,ldapSearching:`Verzeichnis wird durchsucht...`,ldapNoResults:`Keine passenden Benutzer im Verzeichnis`,ldapSearchError:`Verzeichnissuche fehlgeschlagen. Bitte LDAP-Server-Status prüfen.`,ldapAlreadyProvisioned:`Bereits bereitgestellt`,ldapSelectedLabel:`Ausgewählt`,ldapProvision:`Benutzer bereitstellen`,ldapProvisioning:`Wird bereitgestellt...`,ldapErrorProvision:`Bereitstellung fehlgeschlagen. Bitte LDAP-Server-Status prüfen und erneut versuchen.`},form:{username:`Benutzername`,usernamePlaceholder:`Benutzernamen eingeben`,email:`E-Mail`,emailPlaceholder:`benutzer@beispiel.de`,password:`Passwort`,passwordPlaceholder:`Passwort eingeben`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Passwort bestätigen`,newPasswordPlaceholder:`Neues Passwort eingeben`,confirmNewPasswordPlaceholder:`Neues Passwort bestätigen`,leaveBlankToKeep:`leer lassen, um das aktuelle zu behalten`,groups:`Gruppen`,optional:`optional`,autoGeneratedPassword:`Ein sicheres Passwort wird automatisch generiert und per E-Mail an den Benutzer gesendet.`,passwordManagedByAdvancedAuth:`Das Passwort wird durch erweiterte Authentifizierung verwaltet. Verwenden Sie "Passwort zurücksetzen", um ein neues Passwort per E-Mail an den Benutzer zu senden.`,resetPassword:`Passwort zurücksetzen`,resettingPassword:`Passwort wird zurückgesetzt...`},deleteModal:{title:`Benutzer löschen`,message:`Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.`,confirm:`Benutzer löschen`}},streamOverlay:{title:`Stream-Overlay`,invalidPrinterId:`Ungültige Drucker-ID`,cameraStream:`Kamera-Stream`,progress:`Fortschritt`,eta:`ETA`,printerIdle:`Drucker ist inaktiv`,printerOffline:`Drucker offline`,status:{printing:`Druckt`,paused:`Pausiert`,finished:`Fertig`,failed:`Fehlgeschlagen`,idle:`Inaktiv`,unknown:`Unbekannt`}},profiles:{title:`Profile`,subtitle:`Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen`,tabs:{bambuCloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,local:`Lokale Profile`,kprofiles:`K-Profile`},orcaCloud:{connectedAs:`Verbunden als`,logout:`Trennen`,noLogoutPermission:`Sie haben keine Berechtigung zum Trennen`,noConnectPermission:`Sie haben keine Berechtigung, sich mit Orca Cloud zu verbinden`,retry:`Erneut versuchen`,back:`Andere Anmeldemethode verwenden`,connect:{title:`Mit Orca Cloud verbinden`,description:`Melden Sie sich bei Ihrem Orca Cloud-Konto an, um Ihre Slicer-Profile in Bambuddy zu synchronisieren.`},providers:{google:`Mit Google anmelden`,apple:`Mit Apple anmelden`,github:`Mit GitHub anmelden`,email:`Mit E-Mail und Passwort anmelden`},password:{title:`Mit E-Mail und Passwort anmelden`,email:`E-Mail`,emailPlaceholder:`sie@beispiel.de`,password:`Passwort`,submit:`Anmelden`},paste:{title:`Anmeldung abschließen`,step1:`Ein neuer Tab wurde mit der Orca Cloud-Anmeldeseite geöffnet. Melden Sie sich mit Ihrem Orca-Konto an.`,step2:`Ihr Browser wird zu einer "localhost"-URL umgeleitet, die nicht geladen werden kann. Das ist normal — die URL ist es, was wir brauchen.`,step3:`Kopieren Sie die gesamte URL aus der Adressleiste Ihres Browsers und fügen Sie sie unten ein.`,signInUrl:`Falls sich der Anmelde-Tab nicht geöffnet hat, klicken Sie auf diese URL:`,label:`Callback-URL hier einfügen`,placeholder:`http://localhost:41172/callback?code=...&state=...`,submit:`Verbindung abschließen`},profiles:{title:`Ihre Orca Cloud-Profile ({{count}})`,refresh:`Aktualisieren`,empty:`Noch keine Profile in Ihrem Orca Cloud-Konto gefunden.`},toast:{connected:`Mit Orca Cloud verbunden als {{email}}`,disconnected:`Verbindung zu Orca Cloud getrennt`},errors:{startFailed:`Anmeldevorgang für Orca Cloud konnte nicht gestartet werden.`,finishFailed:`Orca Cloud-Anmeldung konnte nicht abgeschlossen werden.`,passwordFailed:`Anmeldung mit dieser E-Mail und diesem Passwort fehlgeschlagen.`,passwordEmpty:`Bitte geben Sie sowohl E-Mail als auch Passwort ein.`,emptyPaste:`Bitte fügen Sie die Callback-URL aus Ihrem Browser ein.`,noCode:`Diese URL sieht nicht wie ein Orca Cloud-Callback aus (kein code-Parameter). Kopieren Sie die vollständige URL aus der Adressleiste.`}},localProfiles:{title:`Lokale Profile`,subtitle:`Slicer-Voreinstellungen aus OrcaSlicer importieren und verwalten`,import:`Profile importieren`,importDesc:`.bbscfg-, .bbsflmt-, .orca_filament-, .zip- oder .json-Dateien hier ablegen`,importing:`Importiere...`,search:`Lokale Voreinstellungen durchsuchen...`,noPresets:`Noch keine lokalen Voreinstellungen`,noSearchResults:`Keine Voreinstellungen entsprechen deiner Suche`,badge:`Lokal`,edit:`Bearbeiten`,delete:`Löschen`,cancel:`Abbrechen`,deleteConfirmTitle:`Voreinstellung löschen`,deleteConfirm:`Möchten Sie diese Voreinstellung wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,source:`Quelle`,inheritsFrom:`Erbt von`,filamentType:`Typ`,vendor:`Hersteller`,compatiblePrinters:`Drucker`,nozzleTemp:`Düsentemperatur`,cost:`Kosten`,density:`Dichte`,pressureAdvance:`Druckvorschub`,filament:`Filament`,process:`Prozess`,printer:`Drucker`,toast:{importSuccess:`{{count}} Voreinstellung(en) importiert`,importSkipped:`{{count}} Voreinstellung(en) übersprungen (Duplikate)`,importError:`{{count}} Fehler beim Import`,deleted:`Voreinstellung gelöscht`,updated:`Voreinstellung aktualisiert`}},connectedAs:`Verbunden als`,logout:`Abmelden`,noLogoutPermission:`Sie haben keine Berechtigung zum Abmelden`,failedToLoad:`Profile konnten nicht geladen werden`,retry:`Erneut versuchen`,time:{justNow:`Gerade eben`,minsAgo:`vor {{count}}m`,hoursAgo:`vor {{count}}h`,daysAgo:`vor {{count}}d`},toast:{loggedOut:`Abgemeldet`},login:{title:`Mit Bambu Cloud verbinden`,subtitle:`Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend`,email:`E-Mail`,password:`Passwort`,region:`Region`,regionGlobal:`Global`,regionChina:`China`,verificationCode:`Bestätigungscode`,totpCode:`Authenticator-Code`,checkEmail:`Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code`,enterTotpHint:`Geben Sie den 6-stelligen Code aus Ihrer Authenticator-App ein`,accessToken:`Zugriffstoken`,accessTokenHint:`Fügen Sie Ihr Bambu-Cloud-Zugriffstoken ein. Konten der Region China müssen diesen Weg nutzen (telefonnummerngebunden — kein E-Mail-Login). Im Wiki steht, wie Sie das Token aus den MakerWorld-Cookies auslesen.`,back:`Zurück`,loginButton:`Anmelden`,verifyButton:`Bestätigen`,setTokenButton:`Token setzen`,useToken:`Stattdessen Zugriffstoken verwenden`,useEmail:`Stattdessen mit E-Mail anmelden`,toast:{loggedIn:`Erfolgreich angemeldet`,codeSent:`Bestätigungscode an Ihre E-Mail gesendet`,enterTotp:`Geben Sie den Code aus Ihrer Authenticator-App ein`,tokenSet:`Token erfolgreich gesetzt`}},presets:{myPreset:`Mein Profil (bearbeitbar)`,duplicate:`Duplizieren`,editable:`Bearbeitbar`,failedToLoadDetails:`Profil-Details konnten nicht geladen werden`,deleteConfirm:`Dieses Profil löschen?`,deleteWarning:`"{{name}}" wird dauerhaft aus Bambu Cloud gelöscht. Dies kann nicht rückgängig gemacht werden.`,noDuplicatePermission:`Sie haben keine Berechtigung zum Duplizieren von Profilen`,noEditPermission:`Sie haben keine Berechtigung zum Bearbeiten von Profilen`,noDeletePermission:`Sie haben keine Berechtigung zum Löschen von Profilen`,types:{filament:`Filament-Profil`,printer:`Drucker-Profil`,process:`Prozess-Profil`},toast:{deleted:`Profil gelöscht`,created:`Profil erstellt`,updated:`Profil aktualisiert`,duplicated:`Profil dupliziert`,fieldAdded:`Feld "{{key}}" hinzugefügt`,exported:`Profil exportiert`},baseLabel:`Basis: {{name}}`,currentLabel:`Aktuell: {{name}}`,newPreset:`Neues Profil`,editPreset:`Profil bearbeiten`,duplicatePreset:`Profil duplizieren`,createNewPreset:`Neues Profil erstellen`,customizeSettings:`Passen Sie die Einstellungen für Ihr neues Profil an`,compareWithBase:`Mit Basis-Profil vergleichen`,compare:`Vergleichen`,basePreset:`Basis-Profil`,selectBasePreset:`Basis-Profil auswählen...`,presetName:`Profilname`,myCustomPreset:`Mein eigenes Profil`,inheritsFrom:`Erbt von`,dropJsonToImport:`JSON zum Importieren ablegen`,tabs:{common:`Allgemein`,allFields:`Alle Felder`},availableFields:`Verfügbare Felder`,searchFieldsPlaceholder:`Felder suchen...`,noMatchingFields:`Keine passenden Felder`,allFieldsAdded:`Alle Felder hinzugefügt`,addCustomField:`Eigenes Feld hinzufügen`,yourOverrides:`Ihre Überschreibungen`,noOverridesYet:`Noch keine Überschreibungen`,clickFieldsToAdd:`Klicken Sie links auf Felder, um sie hinzuzufügen`,saveAsTemplate:`Als Vorlage speichern`,jsonTip:`Tipp: Ziehen Sie eine .json-Datei auf dieses Fenster, um Einstellungen zu importieren`},cloudView:{searchPlaceholder:`Profile suchen...`,templates:`Vorlagen`,refresh:`Aktualisieren`,newPreset:`Neues Profil`,clearFilters:`Filter zurücksetzen`,compareMode:`Vergleichsmodus`,selectAnotherPreset:`Wählen Sie ein weiteres {{type}}-Profil`,clickTwoPresets:`Klicken Sie auf zwei Profile des gleichen Typs zum Vergleichen`,selectFirst:`1. Erstes auswählen`,selectSecond:`2. Zweites auswählen`,compareNow:`Jetzt vergleichen`,lastSynced:`Zuletzt synchronisiert:`,showingCount:`{{showing}} von {{total}} Profilen`,noPresetsFound:`Keine Profile gefunden`,columns:{filament:`Filament`,process:`Prozess`,printer:`Drucker`},noFilamentPresets:`Keine Filament-Profile`,noProcessPresets:`Keine Prozess-Profile`,noPrinterPresets:`Keine Drucker-Profile`,filters:{type:`Typ`,owner:`Besitzer`,printer:`Drucker`,nozzle:`Düse`,filament:`Filament`,layer:`Schicht`,all:`Alle`,myPresets:`Meine Profile`,builtIn:`Voreingestellt`,process:`Prozess`},noTemplatesPermission:`Sie haben keine Berechtigung, Vorlagen zu verwalten`,noRefreshPermission:`Sie haben keine Berechtigung, Profile zu aktualisieren`,noCreatePermission:`Sie haben keine Berechtigung, Profile zu erstellen`},templates:{title:`Schnellvorlagen`,noTemplates:`Noch keine Vorlagen`,createFirst:`Erstellen Sie Vorlagen aus dem Preset-Editor`,typeFilter:`Typ:`,deleteTitle:`Vorlage löschen`,deleteWarning:`Diese Aktion kann nicht rückgängig gemacht werden`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,namePlaceholder:`Vorlagenname`,descriptionPlaceholder:`Beschreibung`,settingsJson:`Einstellungen (JSON)`,fieldsCount:`{{count}} Felder`,shownInModals:`In Dialogen angezeigt`,hiddenInModals:`In Dialogen ausgeblendet`,apply:`Anwenden`,toast:{deleted:`Vorlage gelöscht`,updated:`Vorlage aktualisiert`,created:`Vorlage erstellt`,applied:`Vorlage angewendet`}}},support:{debugLoggingActive:`Debug-Protokollierung ist aktiv`,manageLogs:`Verwalten`,collectItem7:`Drucker-Verbindungsstatus und Firmware-Versionen`,collectItem8:`Integrationsstatus (Spoolman, MQTT, HA)`,collectItem9:`Netzwerkschnittstellen (nur Subnetze)`,collectItem10:`Python-Paketversionen`,collectItem11:`Datenbankzustandsprüfungen`,collectItem12:`Docker-Umgebungsdetails`,bundleGenerating:`Bundle wird erstellt...`,bundleStepConnection:`Drucker-Verbindungsprüfungen werden ausgeführt`,bundleStepVirtualPrinters:`Setup-Prüfungen für virtuelle Drucker werden ausgeführt`,bundleStepLogScan:`Aktuelle Protokolle werden auf bekannte Probleme überprüft`,bundleStepBuild:`Support-Bundle-ZIP wird erstellt`},fileManager:{title:`Dateimanager`,subtitle:`Organisieren und verwalten Sie Ihre Druckdateien`,uploadFiles:`Dateien hochladen`,newFolder:`Neuer Ordner`,folderName:`Ordnername`,folderNamePlaceholder:`z.B. Funktionsteile`,renameFile:`Datei umbenennen`,renameFolder:`Ordner umbenennen`,invalidFilenameChar:`Das Zeichen "{{char}}" ist in Druck-Dateinamen nicht erlaubt. Die SD-Karte des Druckers lehnt folgende Zeichen ab: < > : " / \\ | ? *`,moveFiles:`{{count}} Datei(en) verschieben`,rootNoFolder:`Stammverzeichnis (Kein Ordner)`,current:`aktuell`,linkFolder:`Ordner verknüpfen`,linkFolderDescription:`"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.`,project:`Projekt`,archive:`Archiv`,noProjectsFound:`Keine Projekte gefunden`,noArchivesFound:`Keine Archive gefunden`,unlink:`Verknüpfung aufheben`,link:`Verknüpfen`,dragDropFiles:`Dateien hierher ziehen`,dropFilesHere:`Dateien hier ablegen`,releaseToUpload:`Loslassen zum Hochladen`,orClickToBrowse:`oder klicken zum Durchsuchen`,allFileTypesSupported:`Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.`,zipFilesDetected:`ZIP-Dateien erkannt`,zipExtractOptions:`ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:`,preserveZipStructure:`Ordnerstruktur aus ZIP beibehalten`,createFolderFromZip:`Ordner aus ZIP-Dateiname erstellen`,stlThumbnailGeneration:`STL-Vorschaubildgenerierung`,zipMayContainStl:`ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.`,thumbnailsCanBeGenerated:`Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.`,generateThumbnailsForStl:`Vorschaubilder für STL-Dateien generieren`,threemfDetected:`3MF-Dateien erkannt`,threemfExtractionInfo:`Druckermodell, Material, Farbe und Druckeinstellungen werden automatisch aus 3MF-Dateien extrahiert.`,willBeExtracted:`Wird extrahiert`,filesExtracted:`{{count}} Dateien extrahiert`,uploadComplete:`Upload abgeschlossen: {{succeeded}} erfolgreich`,uploadFailed:`Hochladen fehlgeschlagen`,zipFilesFailed:`{{count}} Dateien fehlgeschlagen`,uploading:`Hochladen...`,changeLink:`Verknüpfung ändern...`,linkTo:`Verknüpfen mit...`,linkToProjectOrArchive:`Mit Projekt oder Archiv verknüpfen`,addToQueue:`Zur Warteschlange`,schedulePrint:`Planen`,generateThumbnail:`Vorschaubild generieren`,generateThumbnails:`Vorschaubilder generieren`,generateThumbnailsForMissing:`Vorschaubilder für STL-Dateien ohne Vorschau generieren`,gridView:`Rasteransicht`,listView:`Listenansicht`,lowDiskSpaceWarning:`Warnung: Wenig Speicherplatz`,lowDiskSpaceDetails:`Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.`,files:`Dateien`,folders:`Ordner`,size:`Größe`,free:`Frei`,allFiles:`Alle Dateien`,allExternal:`Extern`,externalIsEmpty:`Keine externen Dateien`,externalEmptyDescription:`Dateien aus deinen verknüpften externen Ordnern erscheinen hier.`,wrap:`Umbrechen`,enableTextWrapping:`Textumbruch aktivieren`,disableTextWrapping:`Textumbruch deaktivieren`,collapse:`Einklappen`,collapseFoldersByDefault:`Ordner standardmäßig einklappen`,expandFoldersByDefault:`Ordner standardmäßig ausklappen`,folderSort:`Ordner sortieren`,folderSortByName:`Nach Name`,folderSortByActivity:`Nach letzter Aktivität`,dragToResizeTooltip:`Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen`,searchFiles:`Dateien suchen...`,searchSubfoldersHint:`Inklusive Unterordner`,readme:{truncated:`Gekürzt`},tags:{title:`Tags`,subtitle:`Dateien mit Labels versehen — Spielzeug, kindersicher, nur PETG, was immer du willst.`,manage:`Tags`,manageTitle:`Tag-Katalog verwalten`,add:`Neuer Tag`,edit:`Tag umbenennen`,name:`Name`,fileCount:`Dateien`,empty:`Noch keine Tags. Erstelle einen, um Dateien zu kennzeichnen.`,noMatches:`Keine passenden Tags.`,createPlaceholder:`z. B. Spielzeug, kindersicher, petg`,createButton:`Erstellen`,nameRequired:`Name ist erforderlich.`,searchPlaceholder:`Tags filtern...`,created:`Tag erstellt.`,updated:`Tag umbenannt.`,deleted:`Tag entfernt.`,saveFailed:`Tag konnte nicht gespeichert werden.`,deleteFailed:`Tag konnte nicht entfernt werden.`,applyFailed:`Tags konnten nicht angewendet werden.`,applyAdd:`Tags hinzufügen`,applyRemove:`Tags entfernen`,applyAddSuccess:`{{count}} Tag(s) zu {{files}} Datei(en) hinzugefügt.`,applyRemoveSuccess:`{{count}} Tag(s) von {{files}} Datei(en) entfernt.`,actionAdd:`Zu ausgewählten Dateien hinzufügen`,actionRemove:`Von ausgewählten Dateien entfernen`,tagAction:`Tag`,bulkTitle:`{{count}} ausgewählte Datei(en) taggen`,bulkTooltip:`Tags für alle ausgewählten Dateien hinzufügen oder entfernen.`,noPermission:`Du hast keine Berechtigung, Dateien zu taggen.`,filterLabel:`Filtern nach:`,clearAll:`Alle entfernen`,confirmDelete:`Tag "{{name}}" löschen?`,confirmDeleteMessage:`Entfernt den Tag aus dem Katalog. Dateien behalten ihre übrigen Tags.`,confirmDeleteInUseMessage:`Dieser Tag ist auf {{count}} Datei(en). Beim Löschen verschwindet er von allen; die Dateien selbst bleiben unverändert.`,editAria:`{{name}} bearbeiten`,deleteAria:`{{name}} löschen`},allTypes:`Alle Typen`,prints:`Drucke`,ascending:`Aufsteigend`,descending:`Absteigend`,resultsCount:`{{showing}} von {{total}} Dateien`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,selected:`{{count}} ausgewählt`,adding:`Hinzufügen...`,loadingFiles:`Dateien werden geladen...`,folderIsEmpty:`Ordner ist leer`,noFilesYet:`Noch keine Dateien`,folderEmptyDescription:`Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.`,noFilesDescription:`Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.`,noMatchingFiles:`Keine passenden Dateien`,noMatchingFilesDescription:`Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.`,clearFilters:`Filter zurücksetzen`,printedCount:`{{count}}x gedruckt`,uploadedBy:`Hochgeladen von`,deleteFolder:`Ordner löschen`,deleteFile:`Datei löschen`,deleteFilesCount:`{{count}} Dateien löschen`,deleteFolderConfirm:`Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.`,deleteFileConfirm:`Möchten Sie diese Datei wirklich löschen?`,deleteFilesConfirm:`Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleting:`Wird gelöscht...`,noPermissionRenameFolder:`Sie haben keine Berechtigung, Ordner umzubenennen`,noPermissionLinkFolder:`Sie haben keine Berechtigung, Ordner zu verknüpfen`,noPermissionDeleteFolder:`Sie haben keine Berechtigung, Ordner zu löschen`,noPermissionPrint:`Sie haben keine Berechtigung zum Drucken`,noPermissionSlice:`Sie haben keine Berechtigung, Dateien zu slicen`,noPermissionAddToQueue:`Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen`,noPermissionDownload:`Sie haben keine Berechtigung, Dateien herunterzuladen`,noPermissionRenameFile:`Sie haben keine Berechtigung, diese Datei umzubenennen`,noPermissionGenerateThumbnail:`Sie haben keine Berechtigung, Vorschaubilder zu generieren`,noPermissionDeleteFile:`Sie haben keine Berechtigung, diese Datei zu löschen`,noPermissionCreateFolder:`Sie haben keine Berechtigung, Ordner zu erstellen`,noPermissionUpload:`Sie haben keine Berechtigung, Dateien hochzuladen`,noPermissionMoveFiles:`Sie haben keine Berechtigung, Dateien zu verschieben`,noPermissionDeleteFiles:`Sie haben keine Berechtigung, Dateien zu löschen`,linkExternal:`Extern verknüpfen`,linkExternalFolder:`Externen Ordner verknüpfen`,linkExternalFolderDescription:`Ein Host-Verzeichnis (NAS, USB, Netzlaufwerk) in den Dateimanager einbinden. Dateien werden nicht kopiert — sie werden direkt vom Originalpfad gelesen.`,externalFolderNamePlaceholder:`z.B. NAS-Drucke`,externalPath:`Host-Pfad`,externalPathHelp:`Absoluter Pfad zum Verzeichnis auf dem Docker-Host. Muss als Bind-Mount in den Container eingebunden sein.`,readOnly:`Nur Lesen`,readOnlyHelp:`verhindert Uploads und Löschungen`,showHiddenFiles:`Versteckte Dateien anzeigen (Punkt-Dateien)`,externalFolder:`Externer Ordner`,scanFolder:`Scannen`,toast:{folderCreated:`Ordner erstellt`,folderDeleted:`Ordner gelöscht`,fileDeleted:`Datei gelöscht`,filesDeleted:`{{count}} Dateien gelöscht`,filesMoved:`Dateien verschoben`,folderLinked:`Ordner verknüpft`,folderUnlinked:`Ordnerverknüpfung aufgehoben`,externalFolderLinked:`Externer Ordner verknüpft und gescannt`,folderScanned:`Scan abgeschlossen: {{added}} hinzugefügt, {{removed}} entfernt`,addedToQueue:`{{count}} Datei(en) zur Warteschlange hinzugefügt`,addedToQueuePartial:`{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen`,failedToAddToQueue:`Fehler beim Hinzufügen: {{error}}`,fileRenamed:`Datei umbenannt`,folderRenamed:`Ordner umbenannt`,thumbnailsGenerated:`{{count}} Vorschaubild(er) generiert`,thumbnailsGeneratedPartial:`{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen`,noStlMissingThumbnails:`Keine STL-Dateien ohne Vorschaubild`,failedToGenerateThumbnails:`Fehler beim Generieren der Vorschaubilder: {{error}}`,thumbnailGenerated:`Vorschaubild generiert`,failedToGenerateThumbnail:`Fehler beim Generieren des Vorschaubildes: {{error}}`}},projects:{title:`Projekte`,subtitle:`Organisieren und verfolgen Sie Ihre 3D-Druckprojekte`,newProject:`Neues Projekt`,editProject:`Projekt bearbeiten`,deleteProject:`Projekt löschen`,projectName:`Projektname`,description:`Beschreibung`,noProjects:`Noch keine Projekte`,noProjectsFiltered:`Keine {{status}} Projekte`,noProjectsFilteredHelp:`Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.`,createFirst:`Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.`,createFirstButton:`Erstes Projekt erstellen`,create:`Erstellen`,files:`Dateien`,prints:`Drucke`,plates:`Platten`,parts:`Teile`,lastModified:`Zuletzt geändert`,deleteConfirm:`Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.`,addFiles:`Dateien hinzufügen`,removeFile:`Datei entfernen`,viewDetails:`Details anzeigen`,namePlaceholder:`z.B. Voron 2.4 Build`,descriptionPlaceholder:`Optionale Beschreibung...`,urlLabel:`URL`,urlPlaceholder:`https://makerworld.com/...`,urlInvalid:`URL muss mit http:// oder https:// beginnen`,openExternalUrl:`Projekt-URL öffnen`,coverImageLabel:`Titelbild`,coverImageAlt:`Projekt-Titelbild`,coverImageUpload:`Hochladen`,coverImageReplace:`Ersetzen`,coverImageRemove:`Entfernen`,color:`Farbe`,targetPlates:`Ziel-Platten`,targetPlatesPlaceholder:`z.B. 25`,targetPlatesHelp:`Anzahl der Druckaufträge`,targetParts:`Ziel-Teile`,targetPartsPlaceholder:`z.B. 150`,targetPartsHelp:`Benötigte Objekte insgesamt`,tagsLabel:`Tags (kommagetrennt)`,tagsPlaceholder:`z.B. voron, funktional, geschenk`,dueDate:`Fälligkeitsdatum`,priority:`Priorität`,priorityLow:`Niedrig`,priorityNormal:`Normal`,priorityHigh:`Hoch`,priorityUrgent:`Dringend`,statusActive:`Aktiv`,statusCompleted:`Abgeschlossen`,statusArchived:`Archiviert`,done:`Fertig`,completed:`abgeschlossen`,failed:`fehlgeschlagen`,inQueue:`in Warteschlange`,noPrintsYet:`Noch keine Drucke`,printJobs:`Druckaufträge (Platten)`,partsPrinted:`Gedruckte Teile`,failedParts:`Fehlgeschlagene Teile`,import:`Importieren`,export:`Exportieren`,importProject:`Projekt importieren`,exportAll:`Alle Projekte exportieren`,loading:`Projekte werden geladen...`,noEditPermission:`Sie haben keine Berechtigung, Projekte zu bearbeiten`,noDeletePermission:`Sie haben keine Berechtigung, Projekte zu löschen`,noCreatePermission:`Sie haben keine Berechtigung, Projekte zu erstellen`,noImportPermission:`Sie haben keine Berechtigung, Projekte zu importieren`,noExportPermission:`Sie haben keine Berechtigung, Projekte zu exportieren`,toast:{created:`Projekt erstellt`,updated:`Projekt aktualisiert`,deleted:`Projekt gelöscht`,imported:`Projekt importiert`,multipleImported:`{{count}} Projekte importiert`,importFailed:`Import fehlgeschlagen`,exported:`Projekte exportiert (nur Metadaten)`}},projectDetail:{notFound:`Projekt nicht gefunden`,backToProjects:`Zurück zu Projekten`,export:`Exportieren`,exportProject:`Projekt exportieren`,noExportPermission:`Sie haben keine Berechtigung, Projekte zu exportieren`,noEditPermission:`Sie haben keine Berechtigung, Projekte zu bearbeiten`,partOf:`Teil von:`,priorityLabel:`Priorität:`,noPrints:`Noch keine Drucke in diesem Projekt`,status:{active:`Aktiv`,completed:`Abgeschlossen`,archived:`Archiviert`},priority:{low:`Niedrig`,normal:`Normal`,high:`Hoch`,urgent:`Dringend`},dueDate:{overdue:`Überfällig`,today:`Heute fällig`,daysLeft:`{{count}} Tage übrig`},progress:{platesProgress:`Platten-Fortschritt`,partsProgress:`Teile-Fortschritt`,printJobs:`Druckaufträge`,parts:`Teile`,percentComplete:`{{percent}}% abgeschlossen`,remaining:`{{count}} verbleibend`},stats:{printJobs:`Druckaufträge`,total:`gesamt`,failed:`{{count}} fehlgeschlagen`,partsPrinted:`{{count}} Teile gedruckt`,printTime:`Druckzeit`,filamentUsed:`Filament verbraucht`},cost:{title:`Kostenverfolgung`,filamentCost:`Filamentkosten`,energy:`Energie`,totalCost:`Gesamtkosten`,total:`Gesamt`,includesBom:`inkl. Stückliste`,budget:`Budget`,remaining:`Verbleibend`},subProjects:{title:`Unterprojekte ({{count}})`},notes:{title:`Notizen`,noEditPermission:`Sie haben keine Berechtigung, Notizen zu bearbeiten`,placeholder:`Notizen zu diesem Projekt hinzufügen...`,empty:`Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen.`},files:{title:`Dateien`,linkFolders:`Ordner aus dem Dateimanager verknüpfen`,forQuickAccess:`für schnellen Zugriff auf dieses Projekt.`,fileCount:`{{count}} Datei(en)`,empty:`Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt.`,noFiles:`Keine Dateien in diesem Ordner.`,print:`Jetzt drucken`,addToQueue:`Zur Warteschlange`},bom:{title:`Stückliste`,acquired:`{{completed}}/{{total}} beschafft`,showAll:`Alle anzeigen`,hideDone:`Erledigte ausblenden`,addPart:`Teil hinzufügen`,noAddPermission:`Sie haben keine Berechtigung, Teile hinzuzufügen`,partNamePlaceholder:`Teilename (z.B. M3x8 Schrauben)`,partName:`Teilename`,qty:`Menge`,price:`Preis ({{currency}})`,sourcingUrlPlaceholder:`Bezugsquelle-URL (optional)`,remarksPlaceholder:`Bemerkungen (optional)`,deletePart:`Teil löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,noUpdatePermission:`Sie haben keine Berechtigung, Teile zu aktualisieren`,noEditPermission:`Sie haben keine Berechtigung, Teile zu bearbeiten`,noDeletePermission:`Sie haben keine Berechtigung, Teile zu löschen`,totalCost:`Gesamtkosten:`,empty:`Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss.`},timeline:{title:`Aktivitätsverlauf`,empty:`Noch keine Aktivität.`},template:{saveAsTemplate:`Als Vorlage speichern`,noCreatePermission:`Sie haben keine Berechtigung, Vorlagen zu erstellen`},queue:{title:`Warteschlange`,viewAll:`Alle anzeigen`,printing:`{{count}} druckend`,queued:`{{count}} in Warteschlange`},prints:{title:`Drucke ({{count}})`},toast:{projectUpdated:`Projekt aktualisiert`,partAdded:`Teil hinzugefügt`,partRemoved:`Teil entfernt`,exportFailed:`Export fehlgeschlagen`,projectExported:`Projekt exportiert`,templateCreated:`Vorlage erstellt`}},system:{title:`Systeminformationen`,version:`Version`,uptime:`Laufzeit`,cpuUsage:`CPU-Auslastung`,memoryUsage:`Speicherauslastung`,diskUsage:`Festplattenauslastung`,networkInfo:`Netzwerkinformationen`,logs:`Protokolle`,debugMode:`Debug-Modus`,enableDebug:`Debug-Protokollierung aktivieren`,disableDebug:`Debug-Protokollierung deaktivieren`,downloadLogs:`Protokolle herunterladen`,clearLogs:`Protokolle löschen`,dockerInfo:`Docker-Info`,containerName:`Container-Name`,imageName:`Image-Name`,platform:`Plattform`,architecture:`Architektur`},sponsors:{sectionTitle:`Unabhängig & von der Community finanziert`,tagline:`Bambuddy ist kostenlos und bleibt es, weil Menschen es freiwillig unterstützen. Kein VC, kein Cloud-Zwang.`,viewSupporters:`Unterstützer ansehen`,toastPrints:`Du hast {{count}} Drucke mit Bambuddy abgeschlossen. Bambuddy bleibt kostenlos dank seiner Unterstützer.`,toastCost:`Du hast {{total}} an Filament mit Bambuddy verfolgt. Sieh dir an, wer das Projekt unabhängig hält.`,toastArchives:`{{count}} Drucke mit Bambuddy archiviert. Sieh dir an, wer es unabhängig hält.`,toastAnniversary:`Ein Jahr mit Bambuddy! Sieh dir an, wer das Projekt unabhängig hält.`,toastVersionUpdate:`Aktualisiert auf v{{version}}. Bambuddy bleibt kostenlos dank seiner Unterstützer.`},library:{title:`Filament-Bibliothek`,addFilament:`Filament hinzufügen`,editFilament:`Filament bearbeiten`,deleteFilament:`Filament löschen`,vendor:`Hersteller`,material:`Material`,color:`Farbe`,kFactor:`K-Faktor`,temperature:`Temperatur`,noFilaments:`Keine Filamente in der Bibliothek`,deleteConfirm:`Möchten Sie dieses Filament wirklich löschen?`,importFromPrinter:`Vom Drucker importieren`,exportToFile:`In Datei exportieren`},slice:{title:`Modell slicen`,action:`Slicen`,actionAll:`Alle {{count}} Plates slicen`,actionAllTitle:`Alle Plates in eine einzelne Multi-Plate-Ausgabe slicen (ein Archiv). Die Filamentauswahl gilt für jeden Slot des Projekts.`,allPlatesToggle:`Alle {{count}} Plates slicen`,slicing:`Slicen…`,printer:`Drucker-Profil`,process:`Prozess-Profil`,filament:`Filament-Profil`,filamentSlot:`Filament {{index}} – {{type}}`,selectPreset:`— Profil auswählen —`,loadingPresets:`Profile werden geladen…`,analyzingPlateFilaments:`Plattenfilamente werden analysiert…`,analyzingPlateFilamentsHint:`Es wird ein Probeschnitt ausgeführt, um die belegten AMS-Slots dieser Platte zu ermitteln. Wird zwischengespeichert — erneutes Öffnen ist sofort.`,previewToast:`{{name}} wird analysiert — {{elapsed}}`,previewWithProgress:`{{name}} wird analysiert — {{stage}} ({{percent}}%) — {{elapsed}}`,notUsedByPlate:`— wird von dieser Platte nicht verwendet`,noPresetsForSlot:`Keine Profile verfügbar`,otherPrinters:`Andere Drucker`,presetsLoadFailed:`Profile konnten nicht geladen werden. Importiere sie zuerst unter Einstellungen → Profile.`,refreshPresets:`Aktualisieren`,refreshPresetsTitle:`Profile neu laden — die aktuellen Cloud- und Bundle-Listen abrufen (nach dem Löschen eines Profils in Bambu Studio oder Bambu Handy verwenden)`,allPresetsRequired:`Alle Profile müssen ausgewählt sein`,enqueuing:`Slice-Auftrag wird übermittelt…`,queued:`In Warteschlange…`,failed:`Slicen fehlgeschlagen. Logs des Slicer-Sidecars prüfen.`,startedToast:`{{name}} wird im Hintergrund gesliced…`,queuedToast:`Warteschlange: {{name}} — {{elapsed}}`,runningToast:`{{name}} wird gesliced — {{elapsed}}`,runningWithProgress:`{{name}} – {{stage}} ({{percent}} %) – {{elapsed}}`,runningWithProgressMultiPlate:`Plate {{plateIndex}} von {{plateCount}} • {{name}} – {{stage}} ({{percent}} %) – {{elapsed}}`,completedToast:`{{name}} wurde gesliced`,failedTitle:`Slicen fehlgeschlagen`,failedToast:`Slicen von {{name}} fehlgeschlagen: {{detail}}`,tier:{local:`Importiert`,cloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,standard:`Standard`},cloud:{notAuthenticated:`In Bambu Cloud anmelden (Einstellungen → Profile → Bambu Cloud), um deine Cloud-Profile zu sehen.`,expired:`Bambu-Cloud-Sitzung abgelaufen — erneut anmelden, um die Cloud-Profile zu aktualisieren.`,unreachable:`Bambu Cloud ist gerade nicht erreichbar. Lokale und Standard-Profile funktionieren weiterhin.`},orcaCloud:{notAuthenticated:`Bei Orca Cloud anmelden (Profile → Orca Cloud), um Ihre Orca-Profile zu sehen.`,expired:`Orca Cloud-Sitzung abgelaufen — erneut anmelden, um die Orca-Profile zu aktualisieren.`,unreachable:`Orca Cloud ist derzeit nicht erreichbar. Andere Profile funktionieren weiterhin.`},bedType:{label:`Druckbett`,auto:`Auto (aus Prozess-Profil)`,coolPlate:`Cool Plate`,coolPlateSuperTack:`Cool Plate SuperTack`,engineering:`Engineering Plate`,highTemp:`High Temp Plate`,texturedPEI:`Textured PEI Plate`,smoothPEI:`Smooth PEI Plate`}},spoolman:{title:`Spoolman-Integration`,enabled:`Spoolman aktiviert`,url:`Spoolman URL`,connected:`Verbunden`,disconnected:`Nicht verbunden`,testConnection:`Verbindung testen`,sync:`Synchronisieren`,syncing:`Synchronisiert...`,lastSync:`Letzte Synchronisierung`,linkToSpoolman:`Mit Spoolman verknüpfen`,openInSpoolman:`In Spoolman öffnen`,unlinkSpool:`Spule trennen`,unlinkConfirmTitle:`Spule entfernen?`,unlinkConfirmMessage:`Die Spule wird vom Slot entfernt. Die Spulendaten selbst bleiben unverändert.`,selectSpool:`Spule auswählen`,noUnlinkedSpools:`Keine nicht zugewiesenen Spulen verfügbar`,linkSuccess:`Spule erfolgreich zugewiesen`,linkFailed:`Spule konnte nicht zugewiesen werden`,unlinkSuccess:`Spule erfolgreich entfernt`,unlinkFailed:`Spule konnte nicht entfernt werden`,linkedSpool:`Zugewiesene Spule`,spoolId:`Spulen-ID`,fillSourceLabel:`(Spoolman)`,weight:`Gewicht`,remaining:`Verbleibend`,disableWeightSync:`AMS-Gewichtsschätzung deaktivieren`,disableWeightSyncDesc:`Verbleibende Kapazität nicht aus AMS-Schätzungen aktualisieren. Verwenden Sie dies, wenn Sie die Verbrauchserfassung von Spoolman gegenüber den prozentualen AMS-Schätzungen bevorzugen. Neue Spulen verwenden weiterhin die AMS-Schätzung als Anfangsgewicht.`,reportPartialUsage:`Teilverbrauch bei fehlgeschlagenen Drucken melden`,reportPartialUsageDesc:`Wenn ein Druck fehlschlägt oder abgebrochen wird, den geschätzten Filamentverbrauch bis zu diesem Zeitpunkt basierend auf dem Schichtfortschritt melden.`},locations:{title:`Lagerorte`,subtitle:`Regale, Schubladen und andere physische Lagerplätze für Spulen verwalten`,add:`Lagerort hinzufügen`,addShort:`Hinzufügen`,edit:`Lagerort bearbeiten`,name:`Name`,spools:`Spulen`,empty:`Noch keine Lagerorte. Erstellen Sie Ihr erstes Regal oder Ihre erste Schublade.`,manage:`Lagerorte`,createPlaceholder:`z. B. Regal A, Schublade 1`,nameRequired:`Name des Lagerorts ist erforderlich`,created:`Lagerort erstellt`,updated:`Lagerort aktualisiert`,deleted:`Lagerort gelöscht`,saveFailed:`Lagerort konnte nicht gespeichert werden`,deleteFailed:`Lagerort konnte nicht gelöscht werden`,deleteBlocked:`Entfernen Sie zuerst alle Spulen von diesem Lagerort`,confirmDelete:`„{{name}}“ löschen?`,confirmDeleteMessage:`Dieser Lagerort wird aus dem Katalog entfernt. Spulen müssen zuerst verschoben werden.`},inventory:{title:`Spulen-Inventar`,subtitle:`Verwalten Sie Ihre Spulen`,addToInventory:`Zum Inventar hinzufügen`,addToInventoryPending:`Wird hinzugefügt...`,addToInventorySuccess:`Spule zum Inventar hinzugefügt`,addToInventoryFailed:`Spule konnte nicht zum Inventar hinzugefügt werden`,unknownSpoolTitle:`Neues Filament erkannt`,unknownSpoolMessage:`An {{location}} wurde eine Spule mit unbekanntem RFID-Tag erkannt. Jetzt zum Inventar hinzufügen?`,unknownSpoolSlot:`Slot`,bulk:{selectAllVisible:`Alle sichtbaren auswählen`,selectRow:`Zeile auswählen`,selectGroup:`Gruppe auswählen`,selectionCount:`{{count}} ausgewählt`,edit:`Bearbeiten`,printLabels:`Etiketten drucken`,resetUsage:`Verbrauch zurücksetzen`,restore:`Wiederherstellen`,archive:`Archivieren`,delete:`Löschen`,clearSelection:`Auswahl aufheben`,editTitle:`Spulen sammelbearbeiten`,editSubtitle:`Wird auf {{count}} ausgewählte Spulen angewendet. Nur angekreuzte Felder werden aktualisiert.`,editHint:`In ein Feld tippen markiert es für die Aktualisierung — nur angekreuzte Zeilen werden gesendet. Leere Felder bleiben unverändert (Felder leeren geht nur pro Spule).`,useCustom:`„{{value}}" verwenden`,toggleField:`Aktualisierung für dieses Feld umschalten`,changeCount:`{{count}} Felder werden aktualisiert.`,applyPending:`Wird angewendet...`,applyButton:`Auf {{count}} Spulen anwenden`,deleteTitle:`Ausgewählte Spulen löschen`,archiveTitle:`Ausgewählte Spulen archivieren`,restoreTitle:`Ausgewählte Spulen wiederherstellen`,resetUsageTitle:`Verbrauch ausgewählter Spulen zurücksetzen`,deleteMessage:`{{count}} Spulen dauerhaft löschen? Dies kann nicht rückgängig gemacht werden.`,archiveMessage:`{{count}} Spulen archivieren? Sie können später wiederhergestellt werden.`,restoreMessage:`{{count}} archivierte Spulen wiederherstellen?`,resetUsageMessage:`Den "Gesamtverbrauch"-Zähler auf {{count}} Spulen zurücksetzen? Die verbleibende Menge bleibt erhalten.`,updateSuccess:`{{count}} Spulen aktualisiert`,updateFailed:`Sammelaktualisierung fehlgeschlagen`,updatePartial:`{{ok}} Spulen aktualisiert, {{failed}} fehlgeschlagen`,updateAllFailed:`Alle {{count}} Aktualisierungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,deleteSuccess:`{{count}} Spulen gelöscht`,deleteFailed:`Sammellöschung fehlgeschlagen`,deletePartial:`{{ok}} Spulen gelöscht, {{failed}} fehlgeschlagen`,deleteAllFailed:`Alle {{count}} Löschungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,archiveSuccess:`{{count}} Spulen archiviert`,archiveFailed:`Sammelarchivierung fehlgeschlagen`,archivePartial:`{{ok}} Spulen archiviert, {{failed}} fehlgeschlagen`,archiveAllFailed:`Alle {{count}} Archivierungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,restoreSuccess:`{{count}} Spulen wiederhergestellt`,restoreFailed:`Sammelwiederherstellung fehlgeschlagen`,restorePartial:`{{ok}} Spulen wiederhergestellt, {{failed}} fehlgeschlagen`,restoreAllFailed:`Alle {{count}} Wiederherstellungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,invalidHex:`6 Hex-Zeichen (RRGGBB) oder 8 (RRGGBBAA) eingeben. Anderenfalls wird das Feld nicht übernommen.`},spoolmanMixedContentTitle:`Spoolman lässt sich nicht über HTTPS laden — Browser blockiert gemischte Inhalte`,spoolmanMixedContentBody:`Bambuddy wird über HTTPS ausgeliefert (über deinen Reverse-Proxy), aber deine Spoolman-URL ist nach wie vor HTTP. Browser blockieren gemischte Inhalte aus Sicherheitsgründen, daher kann die eingebettete Spoolman-Oberfläche nicht geladen werden. Spoolman muss ebenfalls über HTTPS erreichbar sein.`,spoolmanMixedContentFixReverseProxy:`Stelle Spoolman hinter denselben Reverse-Proxy wie Bambuddy (Traefik / Nginx / Caddy) mit HTTPS und aktualisiere die Spoolman-URL in den Einstellungen auf die neue HTTPS-Adresse.`,spoolmanMixedContentFixOpenNewTab:`Als Workaround kannst du Spoolman in einem neuen Tab über HTTP öffnen — gemischte Inhalte werden nur innerhalb eingebetteter Frames blockiert, ein eigener Tab funktioniert weiterhin.`,spoolmanOpenInNewTab:`Spoolman in neuem Tab öffnen`,labels:{title:`Spulen-Etiketten drucken`,selectedCount:`{{count}} ausgewählt`,pickSpools:`Wählen Sie, für welche Spulen Etiketten gedruckt werden sollen:`,searchPlaceholder:`Name, Marke oder #ID suchen`,filterByMaterial:`Material:`,allMaterials:`Alle`,selectVisible:`Alle sichtbaren auswählen ({{count}})`,deselectVisible:`Sichtbare abwählen`,clearAll:`Alle entfernen`,noSpoolsToShow:`Keine Spulen anzuzeigen. Filter anpassen und erneut versuchen.`,noMatches:`Keine Spulen entsprechen der aktuellen Suche oder dem Filter.`,printOne:`Etikett für diese Spule drucken`,printLabels:`Etiketten drucken…`,bulkTitle:`Spulen aus den aktuell angezeigten {{count}} zum Etikettieren auswählen`,noSpoolsTitle:`Keine Spulen zum Etikettieren`,error:`Etiketten konnten nicht erstellt werden: {{msg}}`,sortBy:{label:`Sortieren:`,id:`Nach ID`,color:`Nach Farbe`},templates:{amsHolderSmall:{label:`AMS-Halter — klein (74 × 33 mm)`,hint:`Ein Etikett pro Seite; passt zum druckbaren Etikett aus dem MakerWorld-Modell 752566 (AMS-Filament-Etikettenhalter).`},amsHolderLarge:{label:`AMS-Halter — groß (75 × 55 mm)`,hint:`Ein Etikett pro Seite; passt zur Kartoneinleger-Variante des AMS-Filament-Etikettenhalters. Genug Platz für Farbprobe, Marke, Material, ID und QR-Code.`},box40x30:{label:`Boxetikett (40 × 30 mm)`,hint:`Ein Etikett pro Seite; gängige DK/Brother-Rollengröße, ideal für Filament-Beutel und Lager-Etiketten.`},box:{label:`Box label (62 × 29 mm)`,hint:`Ein Etikett pro Seite; für Brother PT/QL und Dymo-Kleinetiketten dimensioniert.`},averyL7160:{label:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,hint:`EU-Bogenformat; 21 Etiketten pro A4-Seite.`},avery5160:{label:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,hint:`US-Bogenformat; 30 Etiketten pro Letter-Seite.`}}},csv:{importButton:`CSV importieren`,exportButton:`CSV exportieren`,modalTitle:`Spulen aus CSV importieren`,selectFile:`CSV-Datei auswählen oder hierher ziehen`,dragHint:`Kopfzeile: material (erforderlich), brand, subtype, color_name, rgba, …`,parsing:`Datei wird gelesen…`,previewError:`CSV-Datei konnte nicht gelesen werden`,validCount:`{{count}} gültig`,errorCount:`{{count}} Fehler`,skippedCount:`{{count}} übersprungen`,colRow:`Zeile`,colStatus:`Status`,colColor:`Farbe`,colorResolved:`Farbe aus Katalog übernommen`,colorCrossMaterial:`Farbe von einem anderen Material übernommen — keine exakte Übereinstimmung im Katalog`,duplicateExisting:`Eine Spule mit diesem Material, dieser Marke und Farbe existiert bereits — sie wird trotzdem als neue Spule importiert`,spoolmanHint:`Im Spoolman-Modus den integrierten CSV-Import/-Export von Spoolman verwenden.`,importValidRows:`{{count}} gültige Zeilen importieren`,noValidRows:`Keine gültigen Zeilen`,importing:`Wird importiert…`,importSuccess:`{{count}} Spulen importiert`,importError:`Import fehlgeschlagen`,exportError:`Export fehlgeschlagen`},addSpool:`Spule hinzufügen`,copySpool:`Spule kopieren`,editSpool:`Spule bearbeiten`,material:`Material`,selectMaterial:`Material auswählen...`,subtype:`Untertyp`,brand:`Marke`,searchBrand:`Marke suchen...`,useCustomBrand:`"{{brand}}" verwenden`,useCustomMaterial:`Benutzerdefiniertes Material verwenden: {{material}}`,colorName:`Farbname`,colorNamePlaceholder:`Jadeweiß, Feuerrot...`,color:`Farbe`,hexColor:`Hex-Farbe`,pickColor:`Benutzerdefinierte Farbe wählen`,labelWeight:`Nenngewicht`,coreWeight:`Leergewicht der Spule`,searchSpoolWeight:`Spulengewicht suchen...`,weightUsed:`Verbraucht`,currentWeight:`Restgewicht`,measuredWeight:`Gemessenes Gewicht`,spoolName:`Spule`,costPerKg:`Kosten pro kg`,storageLocation:`Lagerstandort`,storageLocationPlaceholder:`z.B. Regal A, Schublade 1`,openInInventory:`Im Inventar öffnen`,measuredWeightError:`Das gemessene Gewicht muss zwischen {{min}}g und {{max}}g liegen.`,slicerFilament:`Slicer-Filament`,slicerFilamentName:`Slicer-Preset-Name`,slicerPreset:`Slicer-Preset`,searchPresets:`Filament-Presets suchen...`,selectedPreset:`Ausgewählt`,noPresetsFound:`Keine Presets gefunden`,tempOverrides:`Temperatur-Überschreibungen`,note:`Notiz`,notePlaceholder:`Zusätzliche Notizen zu dieser Spule...`,category:`Kategorie`,categoryPlaceholder:`z. B. Produktion, Prototyp, Kunde A`,categoryNone:`Ohne Kategorie`,storageLocationNone:`Kein Lagerort`,lowStockThresholdOverride:`Niedrigbestandsschwelle (diese Spule)`,lowStockThresholdOverrideHelp:`Leer lassen, um den globalen Schwellenwert ({{global}}%) zu verwenden.`,clearRfid:`RFID-Tag löschen`,rfidCleared:`RFID-Tag gelöscht`,archive:`Archivieren`,restore:`Wiederherstellen`,noSpools:`Noch keine Spulen. Fügen Sie Ihre erste Spule hinzu.`,noAvailableSpools:`Keine Spulen verfügbar. Fügen Sie eine Spule zum Inventar hinzu oder lösen Sie eine aus einem anderen Slot.`,kProfiles:`K-Profile`,addKProfile:`K-Profil hinzufügen`,assignSpool:`Spule zuweisen`,unassignSpool:`Zuweisung aufheben`,assignSuccess:`Spule zugewiesen und AMS-Slot konfiguriert`,assignPendingInsert:`Zugewiesen. Slot wird beim Einsetzen der Spule konfiguriert.`,assignFailed:`Spulenzuweisung fehlgeschlagen`,selectSpool:`Wählen Sie eine Spule für diesen Slot`,assigned:`Zugewiesen`,assigning:`Wird zugewiesen...`,searchSpools:`Spulen suchen...`,showAllSpools:`Alle Spulen anzeigen`,spoolmanSpools:`Spoolman-Spulen`,allMaterials:`Alle Materialien`,filterByBrand:`Nach Marke filtern...`,showArchived:`Archivierte anzeigen`,quickAdd:`Schnellerfassung (Lager)`,quantity:`Menge`,stock:`Lager`,configured:`Konfiguriert`,spoolsCreated:`{{count}} Spulen erstellt`,spoolsPartiallyCreated:`{{created}} von {{total}} Spulen erstellt (einige fehlgeschlagen)`,spoolCreated:`Spule erstellt`,spoolUpdated:`Spule aktualisiert`,spoolDeleted:`Spule gelöscht`,deepLinkSpoolNotFound:`Spule nicht gefunden`,deepLinkFetchFailed:`Spule konnte nicht geladen werden — bitte erneut versuchen`,spoolArchived:`Spule archiviert`,spoolRestored:`Spule wiederhergestellt`,kProfileSaveFailed:`K-Profil-Einstellungen konnten nicht gespeichert werden`,syncWeightSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise gelöscht`,syncWeightSpoolmanUnreachable:`Spoolman ist nicht erreichbar — bitte später erneut versuchen`,syncWeightFailed:`Gewicht konnte nicht synchronisiert werden`,spoolmanUnreachable:`Spoolman ist nicht erreichbar — bitte später erneut versuchen`,deleteSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,deleteFailed:`Spule konnte nicht gelöscht werden`,archiveSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,archiveFailed:`Spule konnte nicht archiviert werden`,restoreSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,restoreFailed:`Spule konnte nicht wiederhergestellt werden`,saveFailed:`Änderungen konnten nicht gespeichert werden`,tagClearFailed:`Tag konnte nicht gelöscht werden`,deleteConfirm:`Möchten Sie diese Spule wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,archiveConfirm:`Möchten Sie diese Spule wirklich archivieren?`,advancedSettings:`Erweiterte Einstellungen`,filamentInfoTab:`Filament-Info`,paProfileTab:`PA-Profil`,filamentInfo:`Filament`,additional:`Zusätzlich`,loadingPresets:`Cloud-Presets werden geladen...`,cloudConnected:`Cloud verbunden`,cloudNotConnected:`Cloud nicht verbunden (Standardwerte)`,recentColors:`Zuletzt`,searchColors:`Farben suchen...`,searchResults:`Suchergebnisse`,allColors:`Alle Farben`,commonColors:`Häufige Farben`,showLess:`Weniger`,showAll:`Alle`,noColorsFound:`Keine Farben gefunden`,noResults:`Keine Ergebnisse`,extraColorsLabel:`Zusätzliche Farben`,extraColorsPlaceholder:`EC984C,#6CD4BC,A66EB9,D87694`,extraColorsHint:`2 bis 8 Hex-Stops, durch Kommas getrennt. Wird als Verlauf dargestellt.`,extraColorsInvalid:`Ungültige Hex-Werte ignoriert: {{tokens}}`,colorEffectLabel:`Effekt`,colorEffect:{none:`Keiner`,sparkle:`Glitzer`,wood:`Holz`,marble:`Marmor`,glow:`Leuchtend`,matte:`Matt`,silk:`Seide`,galaxy:`Galaxie`,rainbow:`Regenbogen`,metal:`Metallic`,translucent:`Lichtdurchlässig`,gradient:`Verlauf`,dualColor:`Zweifarbig`,triColor:`Dreifarbig`,multicolor:`Mehrfarbig`},selectMaterialFirst:`Bitte zuerst ein Material im Filament-Info Tab auswählen.`,noPrintersConfigured:`Keine Drucker konfiguriert. Fügen Sie Drucker hinzu.`,matchingFilter:`Filter`,anyBrand:`Jede Marke`,anyVariant:`Jede Variante`,autoSelect:`Auto-Auswahl`,matches:`Treffer`,match:`Treffer`,noMatches:`Keine Treffer`,connected:`Verbunden`,offline:`Offline`,printerOffline:`Drucker ist offline. Verbinden Sie ihn, um Kalibrierungsprofile anzuzeigen.`,noKProfilesMatch:`Keine K-Profile stimmen mit dem gewählten Filament überein.`,leftNozzle:`Linke Düse`,rightNozzle:`Rechte Düse`,profilesSelected:`Kalibrierungsprofil(e) ausgewählt`,totalInventory:`Gesamtbestand`,totalConsumed:`Gesamtverbrauch`,byMaterial:`Nach Material`,inPrinter:`Im Drucker`,lowStock:`Niedriger Bestand`,sinceTracking:`Seit Beginn der Erfassung`,resetConsumedCounter:`Zähler zurücksetzen`,resetConsumedCounterTooltip:`Den verbrauchten Gramm-Zähler dieser Spule auf null setzen. Das Restgewicht bleibt unverändert.`,resetConsumedCounterConfirm:`Verbrauchten Gramm-Zähler dieser Spule auf 0 zurücksetzen? Künftige Drucke zählen wieder ab null. Die Spule selbst, ihre Restgewichtsberechnung und Ihre Einstellungen bleiben unverändert.`,resetAllConsumedCounters:`Alle Zähler zurücksetzen`,resetAllConsumedCountersTooltip:`Den verbrauchten Gramm-Zähler auf jeder Spule auf null setzen. Die Restgewichte bleiben unverändert.`,resetAllConsumedCountersConfirm:`Verbrauchten Gramm-Zähler auf allen {{count}} Spulen (archivierte eingeschlossen) auf 0 zurücksetzen? Das löscht den Wert „Insgesamt verbraucht“, sodass künftige Drucke wieder ab null gezählt werden. Spulen und Restgewichte bleiben unverändert.`,consumedCounterReset:`Zähler zurückgesetzt`,allConsumedCountersReset:`Zähler für {{count}} Spule(n) zurückgesetzt`,resetConsumedCounterFailed:`Zähler konnte nicht zurückgesetzt werden`,loadedInAms:`Im AMS/Ext geladen`,remaining:`Verbleibend`,weightCheck:`Gewichtskontrolle`,lastWeighed:`Zuletzt gewogen`,neverWeighed:`Nie gewogen`,search:`Spulen suchen...`,showing:`Zeige`,to:`bis`,of:`von`,show:`Zeige`,spools:`Spulen`,spool:`Spule`,page:`Seite`,noSpoolsMatch:`Keine Ergebnisse`,noSpoolsMatchDesc:`Versuchen Sie, Ihre Suche oder Filter anzupassen.`,active:`Aktiv`,archived:`Archiviert`,all:`Alle`,used:`Verwendet`,new:`Neu`,clearFilters:`Filter löschen`,table:`Tabelle`,cards:`Karten`,net:`Netto`,groupSimilar:`Gruppieren`,groupedSpools:`{{count}} identische Spulen`,groupedRows:`Zeilen`,columns:`Spalten`,configureColumns:`Spalten konfigurieren`,configureColumnsDesc:`Ziehen zum Neuordnen oder Pfeile verwenden. Sichtbarkeit mit dem Augensymbol umschalten.`,visible:`sichtbar`,reset:`Zurücksetzen`,cancel:`Abbrechen`,applyChanges:`Änderungen anwenden`,moveUp:`Nach oben`,moveDown:`Nach unten`,hideColumn:`Spalte ausblenden`,showColumn:`Spalte einblenden`,linkToSpool:`Mit Spule verknüpfen`,tagLinked:`Tag mit Spule verknüpft`,tagLinkFailed:`Tag-Verknüpfung fehlgeschlagen`,tagAlreadyLinked:`Tag bereits mit anderer Spule verknüpft`,unknownTag:`Unbekannter RFID-Tag erkannt`,usageHistory:`Verbrauchshistorie`,noUsageHistory:`Noch kein Verbrauch erfasst`,printName:`Druckname`,weightConsumed:`Verbrauchtes Gewicht`,clearHistory:`Löschen`,historyCleared:`Verbrauchshistorie gelöscht`,fillSourceLabel:`(Inv)`,lowStockThresholdError:`Der Schwellenwert muss zwischen 0.1 und 99.9 liegen`,assignMismatchTitle:`Material stimmt nicht überein`,assignMismatchMessage:`Das ausgewählte Spulenmaterial "{{spoolMaterial}}" stimmt nicht mit dem Tray-Material "{{trayMaterial}}" für {{location}} überein. Trotzdem zuweisen?`,assignMismatchConfirm:`Trotzdem zuweisen`,assignPartialMismatchMessage:`Das Spulenmaterial "{{spoolMaterial}}" ist ähnlich, stimmt aber nicht genau mit "{{trayMaterial}}" in {{location}} überein. Möchten Sie fortfahren?`,assignProfileMismatchMessage:`Das Spulenprofil "{{spoolProfile}}" stimmt nicht mit dem Fachprofil "{{trayProfile}}" in {{location}} überein. Möchten Sie fortfahren?`,assignReconfigureNote:`Der AMS-Slot wird mit dem Profil der Spule neu konfiguriert.`,spoolmanFilamentCatalog:`Spoolman-Filamentkatalog`,pickFromSpoolmanCatalog:`Aus Spoolman-Katalog wählen…`,spoolmanFilamentSelected:`Filament aus Spoolman-Katalog ausgewählt`,spoolmanFilamentUnlinked:`Verknüpfung mit Filamentkatalog aufgehoben`,noSpoolmanFilaments:`Keine Filamente im Spoolman-Katalog gefunden`,spoolmanFilamentColorSwatch:`Filamentfarbe`,spoolWeightManagedBySpoolman:`Das Leerspulengewicht wird pro Filamenttyp in Spoolman verwaltet`,spoolmanCatalogLoadFailed:`Spoolman-Filamentkatalog konnte nicht geladen werden`},timelapse:{title:`Zeitraffer`,create:`Zeitraffer erstellen`,download:`Herunterladen`,delete:`Löschen`,preview:`Vorschau`,frameRate:`Bildrate`,quality:`Qualität`,processing:`Wird verarbeitet...`,noTimelapses:`Keine Zeitraffer verfügbar`},ams:{title:`AMS`,slot:`Slot`,empty:`Leer`,emptySlot:`Leerer Slot`,slotEmpty:`Leer`,slotUnconfigured:`?`,emptySlotReset:`Keine Spule zugewiesen`,unknown:`Unbekannt`,humidity:`Luftfeuchtigkeit`,temperature:`Temperatur`,filamentType:`Filamenttyp`,filamentColor:`Farbe`,remaining:`Verbleibend`,history:`AMS-Verlauf`,noHistory:`Kein Verlauf verfügbar`,configureSlot:`Slot konfigurieren`,externalSpool:`Externe Spule`,profile:`Profil`,kFactor:`K-Faktor`,fill:`Füllstand`,configure:`Konfigurieren`,used:`verwendet`,remainingUnit:`verbleibend`},printModal:{title:`Druck starten`,selectPrinter:`Drucker auswählen`,selectPlate:`Platte auswählen`,filamentMapping:`Filamentzuordnung`,totalCost:`Gesamtkosten:`,slotRemainingShort:` - {{grams}}g übrig`,printSettings:`Druckeinstellungen`,bedLeveling:`Bett-Nivellierung`,flowCalibration:`Fluss-Kalibrierung`,vibrationCalibration:`Vibrations-Kalibrierung`,layerInspection:`Erste-Schicht-Prüfung`,timelapse:`Zeitraffer`,startPrint:`Druck starten`,addToQueue:`Zur Warteschlange hinzufügen`,cancel:`Abbrechen`,noPrintersAvailable:`Keine Drucker verfügbar`,printerBusy:`Drucker ist beschäftigt`,printerOffline:`Drucker ist offline`,sameTypeDifferentColor:`Gleicher Typ, andere Farbe`,filamentTypeNotLoaded:`Filamenttyp nicht geladen`,openCalendar:`Kalender öffnen`,leftNozzle:`L`,rightNozzle:`R`,leftNozzleTooltip:`Linke Düse`,rightNozzleTooltip:`Rechte Düse`,filamentOverride:`Filament-Überschreibung`,filamentOverrideHint:`Filamente für modellbasierte Zuweisung optional überschreiben. Der Planer wird gegen die ausgewählten Filamente statt der ursprünglichen 3MF-Werte abgleichen.`,originalFilament:`Original`,overrideWith:`Ersetzen mit`,resetToOriginal:`Auf Original zurücksetzen`,insufficientFilamentTitle:`Nicht genug Filament`,insufficientFilamentMessage:`Einige zugewiesene Spulen haben weniger Filament als dieser Druck benötigt:`,insufficientFilamentLine:`{{printer}} - {{slot}}: benötigt {{required}}g, verbleibend {{remaining}}g`,printAnyway:`Trotzdem drucken`,forceColorMatch:`Farbe erzwingen`,staggerPrinterStarts:`Druckerstarts staffeln`,staggerGroupSize:`Gruppengröße`,staggerInterval:`Intervall (Min.)`,staggerPreview:`{{printers}} Drucker → {{groups}} Gruppen à {{size}}, Start alle {{interval}} Min.`,staggerLastGroup:`letzte Gruppe: {{count}}`,staggerTotal:`insgesamt: {{minutes}} Min.`,staggerToPrinters:`Gestaffelt an {{count}} Drucker senden`,gcodeInjection:`Auto-Print G-code einfügen`},backup:{includesEncryptionKey:`Lokale Sicherungen enthalten die MFA-Schlüsseldatei (DATA_DIR/.mfa_encryption_key), damit ein Backup-ZIP selbstkonsistent ist. Behandle das ZIP als sensibel — wer Zugriff auf die Datei hat, kann die darin enthaltenen OIDC-Client-Secrets und TOTP-Geheimnisse entschlüsseln.`,title:`Sichern & Wiederherstellen`,createBackup:`Sicherung erstellen`,restoreBackup:`Sicherung wiederherstellen`,restoreDescription:`Alle Daten aus einer Sicherungsdatei ersetzen`,downloadBackup:`Sicherung herunterladen`,uploadBackup:`Sicherung hochladen`,lastBackup:`Letzte Sicherung`,autoBackup:`Automatische Sicherung`,backupNow:`Jetzt sichern`,restoreWarning:`Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.`,includeArchives:`Archive einschließen`,includeSettings:`Einstellungen einschließen`,includeProfiles:`Profile einschließen`,backupSuccess:`Sicherung erfolgreich erstellt`,restoreSuccess:`Sicherung erfolgreich wiederhergestellt`,backupFailed:`Sicherung fehlgeschlagen`,restoreFailed:`Wiederherstellung fehlgeschlagen`,restoreNote:`Virtueller Drucker wird während der Wiederherstellung gestoppt`,githubBackup:`Git-Backup`,enabled:`Aktiviert`,cloudLoginRequired:`Bambu Cloud Login erforderlich. Melden Sie sich unter Profile → Cloud-Profile an, um GitHub-Backup zu aktivieren.`,cloudLoginRequiredShort:`Cloud-Login erforderlich`,githubDescription:`Synchronisieren Sie Ihre Profile automatisch mit einem privaten GitHub-Repository für Backup und Versionsverlauf.`,repoIsPrivate:`Repository ist privat — Sicherung möglich.`,repoIsPublicWarning:`Das Repository ist ÖFFENTLICH. Bambuddy-Backups enthalten MQTT-Zugangsdaten, Home-Assistant-Tokens, Prometheus-Tokens, Ihre Bambu-Cloud-E-Mail-Adresse und über K-Profile auch Drucker-Zugangscodes. Speichern ist blockiert, bis Sie das Repository in den Einstellungen Ihres Anbieters auf privat stellen.`,repoVisibilityUnknown:`Die Sichtbarkeit des Repositories konnte nicht bestimmt werden. Bambuddy sichert nur in Repositories, die nachweislich privat sind; Speichern wird blockiert.`,repositoryUrl:`Repository-URL`,repoUrlPlaceholderGitHub:`https://github.com/username/repo-name`,repoUrlPlaceholderGitea:`https://gitea.example.com/username/repo-name`,repoUrlPlaceholderForgejo:`https://forgejo.example.com/username/repo-name`,repoUrlPlaceholderGitLab:`https://gitlab.com/username/repo-name`,allowInsecureHttp:`Unsicheres HTTP erlauben`,allowInsecureHttpHint:`Für selbst gehostete Instanzen in privaten Netzwerken ohne TLS aktivieren`,personalAccessToken:`Persönlicher Zugriffstoken`,tokenSaved:`(gespeichert)`,enterNewToken:`Neuen Token eingeben zum Aktualisieren`,tokenHint:`Feingranularer Token mit Lese-/Schreibberechtigung für Inhalte`,branch:`Branch`,provider:`Git-Anbieter`,providerGitHub:`GitHub`,providerGitLab:`GitLab`,providerGitea:`Gitea`,providerForgejo:`Forgejo`,manualOnly:`Nur manuell`,hourly:`Stündlich`,daily:`Täglich`,weekly:`Wöchentlich`,includeInBackup:`In Sicherung einschließen`,kProfiles:`K-Profile`,kProfilesDescription:`Druckvorschub-Kalibrierung von verbundenen Druckern`,noPrintersConnected:`Keine Drucker verbunden`,printersConnected:`{{connected}}/{{total}} verbunden`,cloudProfiles:`Cloud-Profile`,cloudProfilesDescription:`Filament-, Drucker- und Prozessprofile aus der Bambu Cloud`,appSettings:`App-Einstellungen`,appSettingsDescription:`Bambuddy-Konfiguration (komplette Datenbank)`,spoolInventory:`Spulenbestand`,spoolInventoryDescription:`Filamentspulen, Nutzungsverlauf und Kostenverfolgung`,printArchives:`Druckarchive`,printArchivesDescription:`Druckverlauf-Metadaten (keine GCode/3MF-Dateien)`,lastBackupAt:`Letzte Sicherung:`,noBackupsYet:`Noch keine Sicherungen`,next:`Nächste:`,startingBackup:`Sicherung wird gestartet...`,test:`Test`,enableBackup:`Sicherung aktivieren`,testConnection:`Verbindung testen`,enterRepoUrl:`Repository-URL eingeben`,enterRepoAndToken:`Repository-URL und Zugriffstoken eingeben`,repoRequired:`Repository-URL ist erforderlich`,tokenRequired:`Zugriffstoken ist erforderlich`,githubBackupEnabled:`GitHub-Backup aktiviert`,tokenUpdated:`Token aktualisiert`,settingsSaved:`Einstellungen gespeichert`,failedToSave:`Speichern fehlgeschlagen: {{message}}`,backupCompleteFiles:`Sicherung abgeschlossen - {{count}} Dateien aktualisiert`,backupSkippedNoChanges:`Sicherung übersprungen - keine Änderungen`,backupFailed2:`Sicherung fehlgeschlagen: {{message}}`,clearedLogs:`{{count}} Protokolle gelöscht`,failedToClearLogs:`Protokolle löschen fehlgeschlagen: {{message}}`,history:`Verlauf`,clear:`Löschen`,date:`Datum`,status:`Status`,commit:`Commit`,localBackup:`Lokale Sicherung`,localBackupDescription:`Erstellen Sie eine vollständige Sicherung Ihrer Bambuddy-Daten einschließlich Datenbank, Archive, Uploads und aller Dateien.`,downloadBackupLabel:`Sicherung herunterladen`,completeBackupZip:`Vollständige Sicherung: Datenbank + alle Dateien (ZIP)`,download:`Herunterladen`,preparingBackup:`Sicherung wird vorbereitet...`,creatingArchive:`Sicherungsarchiv wird erstellt... Dies kann bei großen Archiven eine Weile dauern.`,downloadingFile:`Sicherungsdatei wird heruntergeladen...`,backupDownloaded:`Sicherung erfolgreich heruntergeladen`,failedToCreateBackup:`Sicherung erstellen fehlgeschlagen: {{message}}`,restore:`Wiederherstellen`,restoreReplacesAll:`Wiederherstellung ersetzt alle Daten.`,restoreReplacesAllDetail:`Ihre aktuelle Datenbank und Dateien werden vollständig ersetzt. Nach der Wiederherstellung ist ein Neustart erforderlich.`,restoreConfirmTitle:`Sicherung wiederherstellen`,restoreConfirmMessage:`Sind Sie sicher, dass Sie von "{{filename}}" wiederherstellen möchten? Dies ersetzt Ihre aktuelle Datenbank und alle Dateien vollständig. Die Anwendung muss nach der Wiederherstellung neu gestartet werden.`,restoreConfirmButton:`Sicherung wiederherstellen`,uploadingFile:`Sicherungsdatei wird hochgeladen...`,backupRestoredRestart:`Sicherung wiederhergestellt. Bitte starten Sie Bambuddy neu.`,failedToRestore:`Sicherung wiederherstellen fehlgeschlagen. Bitte überprüfen Sie das Dateiformat.`,reloadNow:`Jetzt neu laden`,creatingBackup:`Sicherung erstellen`,restoringBackup:`Sicherung wiederherstellen`,preparing:`Vorbereiten...`,processing:`Verarbeiten...`,doNotClosePage:`Bitte schließen Sie diese Seite nicht und navigieren Sie nicht weg. Dieser Vorgang kann bei großen Sicherungen mehrere Minuten dauern.`,restoring:`Wiederherstellen...`,restoreComplete:`Wiederherstellung abgeschlossen`,restoreFailed2:`Wiederherstellung fehlgeschlagen`,importSettings:`Einstellungen aus einer Sicherungsdatei importieren`,pleaseWaitRestoring:`Bitte warten Sie, während Ihre Daten wiederhergestellt werden`,selectBackupFile:`Klicken Sie, um eine Sicherungsdatei auszuwählen (.json oder .zip)`,duplicateHandling:`So funktioniert die Duplikatbehandlung:`,matchPrinters:`Drucker`,matchPrintersBy:`abgeglichen nach Seriennummer`,matchSmartPlugs:`Smart Plugs`,matchSmartPlugsBy:`abgeglichen nach IP-Adresse`,matchNotificationProviders:`Benachrichtigungsanbieter`,matchNotificationProvidersBy:`abgeglichen nach Name`,matchFilaments:`Filamente`,matchFilamentsBy:`abgeglichen nach Name + Typ + Marke`,matchArchives:`Archive`,matchArchivesBy:`abgeglichen nach Inhaltshash (immer übersprungen)`,matchPendingUploads:`Ausstehende Uploads`,matchPendingUploadsBy:`abgeglichen nach Dateiname`,matchSettingsTemplates:`Einstellungen & Vorlagen`,matchSettingsTemplatesBy:`immer überschrieben`,replaceExisting:`Vorhandene Daten ersetzen`,keepExisting:`Vorhandene Daten behalten`,overwriteDescription:`Bereits vorhandene Elemente mit Sicherungsdaten überschreiben`,keepDescription:`Nur Elemente wiederherstellen, die noch nicht vorhanden sind`,overwriteCaution:`Achtung:`,overwriteWarning:`Das Überschreiben ersetzt Ihre aktuellen Konfigurationen durch Daten aus der Sicherung. Drucker-Zugangscodes werden aus Sicherheitsgründen nie überschrieben.`,cancel:`Abbrechen`,processingBackup:`Sicherungsdatei wird verarbeitet...`,itemsRestored:`Wiederhergestellt`,itemsSkipped:`Übersprungen`,restored:`Wiederhergestellt`,skippedAlreadyExist:`Übersprungen (bereits vorhanden)`,filesCategory:`Dateien (3MF, Thumbnails, etc.)`,andMore:`...und {{count}} weitere`,newApiKeysGenerated:`Neue API-Schlüssel generiert`,keysShownOnce:`Diese Schlüssel werden nur einmal angezeigt. Kopieren Sie sie jetzt!`,copy:`Kopieren`,noDataFound:`In der Sicherungsdatei wurden keine Daten zur Wiederherstellung gefunden.`,close:`Schließen`,scheduledBackup:`Geplante Backups`,scheduledBackupDescription:`Backup-Snapshots automatisch nach Zeitplan erstellen. Ausgabeverzeichnis kann auf einen NAS oder externen Speicher gemountet werden.`,frequency:`Frequenz`,backupTime:`Zeit`,retention:`Aufbewahrung`,retentionDescription:`Anzahl der zu behaltenden Backups`,outputPath:`Ausgabepfad`,outputPathPlaceholder:`Standard: {{path}}`,outputPathDescription:`Leer lassen für den Standardort`,runNow:`Jetzt ausführen`,backupFiles:`Backup-Dateien`,noScheduledBackups:`Noch keine Backups`,deleteBackup:`Löschen`,deleteBackupConfirm:`Diese Backup-Datei löschen?`,backupRunning:`Backup läuft...`,scheduledBackupComplete:`Backup erfolgreich abgeschlossen`,scheduledBackupFailed:`Backup fehlgeschlagen`,nextBackup:`Nächstes Backup`,backupSize:`Größe`,localTimeHint:`Ortszeit ({{tz}})`,defaultPathLabel:`Standard:`,categories:{settings:`Einstellungen`,notification_providers:`Benachrichtigungsanbieter`,notification_templates:`Benachrichtigungsvorlagen`,smart_plugs:`Smart Plugs`,printers:`Drucker`,filaments:`Filamente`,maintenance_types:`Wartungstypen`,archives:`Archive`,projects:`Projekte`,pending_uploads:`Ausstehende Uploads`,external_links:`Externe Links`,api_keys:`API-Schlüssel`}},tags:{title:`Tags`,addTag:`Tag hinzufügen`,editTag:`Tag bearbeiten`,deleteTag:`Tag löschen`,tagName:`Tag-Name`,tagColor:`Tag-Farbe`,noTags:`Keine Tags`,deleteConfirm:`Möchten Sie diesen Tag wirklich löschen?`,manageTags:`Tags verwalten`},uploadModal:{title:`3MF-Dateien hochladen`,dragDrop:`3MF-Dateien hierher ziehen`,or:`oder`,browseFiles:`Dateien durchsuchen`,extractionInfo:`Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.`,uploaded:`hochgeladen`,failed:`fehlgeschlagen`,uploading:`Wird hochgeladen...`,upload:`Hochladen`,uploadFailed:`Hochladen fehlgeschlagen`},editArchive:{title:`Archiv bearbeiten`,name:`Name`,namePlaceholder:`Druckname`,printer:`Drucker`,noPrinter:`Kein Drucker`,project:`Projekt`,noProject:`Kein Projekt`,itemsPrinted:`Gedruckte Teile`,itemsPrintedHelp:`Anzahl der in diesem Druckauftrag produzierten Teile`,notes:`Notizen`,notesPlaceholder:`Notizen zu diesem Druck hinzufügen...`,externalLink:`Externer Link`,externalLinkPlaceholder:`https://printables.com/model/...`,externalLinkHelp:`Link zu Printables, Thingiverse oder anderer Quelle`,tags:`Tags`,tagsPlaceholder:`Tags hinzufügen...`,addMoreTags:`Weitere Tags hinzufügen...`,matchingTags:`Übereinstimmend mit "{{query}}"`,existingTags:`Vorhandene Tags`,clickToAdd:`(zum Hinzufügen klicken)`,status:`Status`,failureReason:`Fehlergrund`,selectReason:`Grund auswählen...`,photos:`Fotos des Druckergebnisses`,photosHelp:`Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen`,printResult:`Druckergebnis`,saving:`Wird gespeichert...`,failureReasons:{adhesionFailure:`Haftungsfehler`,spaghettiDetached:`Spaghetti / Abgelöst`,layerShift:`Schichtversatz`,cloggedNozzle:`Verstopfte Düse`,filamentRunout:`Filament aufgebraucht`,warping:`Verformung`,stringing:`Fadenziehen`,underExtrusion:`Unterextrusion`,powerFailure:`Stromausfall`,userCancelled:`Vom Benutzer abgebrochen`,other:`Sonstiges`},statuses:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,aborted:`Abgebrochen`,printing:`Druckt`}},kProfiles:{title:`K-Profile`,noPrintersConfigured:`Keine Drucker konfiguriert`,addPrinterInSettings:`Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten`,noActivePrinters:`Keine aktiven Drucker`,enablePrinterConnection:`Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen`,loadingProfiles:`Lade K-Profile...`,printerOffline:`Drucker offline`,printerOfflineDesc:`Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.`,noMatchingProfiles:`Keine passenden Profile`,noMatchingProfilesDesc:`Keine Profile entsprechen Ihren Suchkriterien`,noKProfiles:`Keine K-Profile`,noKProfilesDesc:`Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden`,createFirstProfile:`Erstes Profil erstellen`,printer:`Drucker`,nozzle:`Düse`,refresh:`Aktualisieren`,addProfile:`Profil hinzufügen`,export:`Exportieren`,import:`Importieren`,select:`Auswählen`,selectAll:`Alle auswählen`,delete:`Löschen`,searchPlaceholder:`Nach Name oder Filament suchen...`,allExtruders:`Alle Extruder`,leftOnly:`Nur links`,rightOnly:`Nur rechts`,allFlow:`Alle Flusstypen`,hfOnly:`Nur HF`,sOnly:`Nur S`,sortName:`Sortieren: Name`,sortKValue:`Sortieren: K-Wert`,sortFilament:`Sortieren: Filament`,leftExtruder:`Linker Extruder`,rightExtruder:`Rechter Extruder`,modal:{addTitle:`K-Profil hinzufügen`,editTitle:`K-Profil bearbeiten`,profileName:`Profilname`,profileNamePlaceholder:`Mein PLA-Profil`,kValue:`K-Wert`,kValuePlaceholder:`0,020`,kValueHelp:`Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG`,filament:`Filament`,selectFilament:`Filament auswählen...`,noFilamentsHelp:`Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.`,flowType:`Flusstyp`,highFlow:`Hoher Durchfluss`,standard:`Standard`,nozzleSize:`Düsengröße`,extruder:`Extruder`,extruders:`Extruder`,left:`Links`,right:`Rechts`,notes:`Notizen (lokal gespeichert)`,notesPlaceholder:`Notizen zu diesem Profil hinzufügen...`,notesHelp:`Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker`,syncing:`Synchronisiert mit Drucker...`,savingExtruder:`Speichern auf Extruder {{current}}/{{total}}...`,pleaseWait:`Bitte warten`},deleteConfirm:{title:`Profil löschen`,cannotUndo:`Dies kann nicht rückgängig gemacht werden`,message:`Möchten Sie "{{name}}" wirklich vom Drucker löschen?`},bulkDelete:{title:`Profile löschen`,cannotUndo:`Dies kann nicht rückgängig gemacht werden`,message:`Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?`},toast:{profileSaved:`K-Profil gespeichert`,profilesSaved:`K-Profil auf {{count}} Extrudern gespeichert`,selectAtLeastOneExtruder:`Bitte wählen Sie mindestens einen Extruder aus`,profileDeleted:`K-Profil gelöscht`,profilesDeleted:`{{count}} Profile gelöscht`,exportedProfiles:`{{count}} Profile exportiert`,importedProfiles:`{{count}} von {{total}} Profilen importiert`,noProfilesToExport:`Keine Profile zum Exportieren`,invalidFileFormat:`Ungültiges Dateiformat`,failedToParseImport:`Import-Datei konnte nicht gelesen werden`,failedToSaveBatch:`K-Profile konnten nicht gespeichert werden`,noteSaved:`Notiz gespeichert`,failedToSaveNote:`Notiz konnte nicht gespeichert werden`},permission:{noRead:`Sie haben keine Berechtigung, Profile zu aktualisieren`,noCreate:`Sie haben keine Berechtigung, Profile hinzuzufügen`,noUpdate:`Sie haben keine Berechtigung, K-Profile zu aktualisieren`,noDelete:`Sie haben keine Berechtigung, K-Profile zu löschen`,noExport:`Sie haben keine Berechtigung, Profile zu exportieren`,noImport:`Sie haben keine Berechtigung, Profile zu importieren`}},virtualPrinter:{title:`Virtueller Drucker`,running:`Läuft`,stopped:`Gestoppt`,description:{default:`Aktiviere einen virtuellen Drucker, der in Bambu Studio und OrcaSlicer erscheint. Dateien, die an diesen Drucker gesendet werden, werden direkt archiviert ohne zu drucken.`,proxy:`Aktiviere einen Proxy, der Slicer-Datenverkehr an einen echten Drucker weiterleitet, um Ferndruck über jedes Netzwerk zu ermöglichen.`},enable:{title:`Virtuellen Drucker aktivieren`,visibleInSlicer:`Sichtbar als "Bambuddy" in der Slicer-Erkennung`,proxyingTo:`Proxy zu {{name}}`,notActive:`Nicht aktiv`},model:{title:`Druckermodell`,description:`Wähle welches Druckermodell emuliert werden soll.`,restartWarning:`Das Ändern des Modells startet den virtuellen Drucker neu`},accessCode:{title:`Zugangscode`,isSet:`Zugangscode ist gesetzt`,notSet:`Kein Zugangscode gesetzt - erforderlich zum Aktivieren`,placeholder:`8-Zeichen-Code eingeben`,placeholderChange:`Neuen Code eingeben zum Ändern`,hint:`Muss genau 8 Zeichen lang sein. Wird von Slicern zur Authentifizierung verwendet.`,charCount:`({{count}}/8)`,inheritedFromTarget:`Vom Zieldrucker übernommen`,derivedFromTargetHint:`Verwendet den Zugangscode des Zieldruckers. Die Brücke leitet die Slicer-Authentifizierung an den echten Drucker weiter, daher müssen die Codes übereinstimmen — den Druckercode in dessen Einstellungen ändern.`,reveal:`Zugangscode anzeigen`,hide:`Zugangscode verbergen`},targetPrinter:{title:`Zieldrucker`,configured:`Proxy-Ziel konfiguriert`,notConfigured:`Kein Zieldrucker ausgewählt - erforderlich für Proxy-Modus`,placeholder:`Drucker auswählen...`,hint:`Wähle den Drucker aus, an den der Slicer-Datenverkehr weitergeleitet werden soll. Der Drucker muss im LAN-Modus sein.`,noPrinters:`Keine Drucker konfiguriert. Füge zuerst einen Drucker hinzu, um den Proxy-Modus zu verwenden.`},remoteInterface:{title:`Netzwerkschnittstelle überschreiben`,configured:`Schnittstellenüberschreibung aktiv`,optional:`Optional - verwenden wenn die automatisch erkannte IP falsch ist (z.B. mehrere NICs, Docker, VPN)`,placeholder:`Automatisch erkennen (Standard)...`,hint:`Überschreibt die per SSDP beworbene und im TLS-Zertifikat verwendete IP-Adresse. Nützlich wenn Bambuddy mehrere Netzwerkschnittstellen hat.`},mode:{title:`Modus`,archive:`Archivieren`,archiveDesc:`Dateien sofort archivieren`,review:`Überprüfen`,reviewDesc:`Vor dem Archivieren überprüfen`,queue:`Warteschlange`,queueDesc:`Archivieren und zur Warteschlange hinzufügen`,proxy:`Proxy`,proxyDesc:`An echten Drucker weiterleiten`},autoDispatch:{title:`Automatisch starten`,description:`Drucke automatisch starten, wenn sie zur Warteschlange hinzugefügt werden. Wenn deaktiviert, warten Drucke auf manuellen Start.`},queueForceColorMatch:{title:`Farbabgleich erzwingen`,description:`Druckaufträge nur an Drucker senden, bei denen der genaue Filament-Typ und die genaue Farbe geladen sind. Standardmäßig deaktiviert — ohne diese Option verwendet die Warteschlange nur den Drucker-Modell-Abgleich und wählt möglicherweise einen Drucker mit der falschen Farbe.`},gcodeInjection:{title:`G-code-Injektion`,description:`Wendet die in den Einstellungen pro Modell konfigurierten G-code-Snippets auf Jobs dieses VP an. Standardmäßig aus.`},tailscaleDisabled:{title:`Tailscale-Integration`,description:`Aktivieren, um diesen VP als per Tailscale erreichbar zu markieren. Zeigt die Tailscale-Adresse des Hosts an, damit du weißt, welche IP du im Slicer eintragen musst. Der CA-Import bleibt unverändert — diese Option hat keinen Einfluss auf Zertifikate.`},setupRequired:{title:`Einrichtung erforderlich`,description:`Die virtuelle Druckerfunktion erfordert zusätzliche Systemkonfiguration, bevor sie funktioniert. Dies beinhaltet Portweiterleitung, Firewall-Regeln und plattformspezifische Einstellungen.`,readGuide:`Lese die Einrichtungsanleitung vor dem Aktivieren`},archiveNameSource:{title:`Quelle des Archivnamens`,description:`Lege fest, wie neue Archive benannt werden, wenn Dateien über den virtuellen Drucker eintreffen. "Metadaten" verwendet den im 3MF eingebetteten Titel des Slicers (Standard). "Dateiname" nutzt den Dateinamen, den Bambu Studio per FTP gesendet hat. Hinweis: Bambu Studio überschreibt den im Dialog "Zum Drucker senden" eingegebenen Namen mit dem Titelfeld der 3MF, sofern eines vorhanden ist — beide Modi liefern daher oft denselben Wert.`,metadata:`Metadaten`,filename:`Dateiname`},caCert:{title:`Slicer-Zertifikat`,description:`Virtuelle Drucker verwenden ein TLS-Zertifikat, das von der Bambuddy-CA signiert ist. Importieren Sie dieses CA-Zertifikat einmalig in den Vertrauensspeicher Ihres Slicers, damit er die Verbindung akzeptiert — kein Abrufen über die Kommandozeile mehr nötig.`,copy:`Kopieren`,copied:`Kopiert`,download:`Herunterladen`,fingerprint:`SHA-256`},howItWorks:{title:`So funktioniert es`,step1:`Im selben LAN erscheinen virtuelle Drucker automatisch in deinem Slicer (Bambu Studio / OrcaSlicer). Aus anderen Netzwerken füge sie manuell per IP-Adresse und Zugangscode hinzu.`,step2:`Im Archiv-, Überprüfungs- und Warteschlangen-Modus verwende die "Senden"-Funktion im Slicer, um 3MF-Dateien an Bambuddy zu senden. Der Slicer zeigt "Druck erfolgreich" — die Datei wird gespeichert, nicht gedruckt.`,step3:`Im Proxy-Modus leitet der virtuelle Drucker den gesamten Datenverkehr an einen echten Drucker weiter — Drucke starten sofort wie bei einer direkten Verbindung.`},status:{title:`Status-Details`,printerName:`Druckername`,model:`Modell`,serialNumber:`Seriennummer`,mode:`Modus`,pendingFiles:`Ausstehende Dateien`,targetPrinter:`Zieldrucker`,ftpPort:`FTP-Port`,mqttPort:`MQTT-Port`,ftpConnections:`FTP-Verbindungen`,mqttConnections:`MQTT-Verbindungen`},toast:{updated:`Virtuelle Druckereinstellungen aktualisiert`,failedToUpdate:`Einstellungen konnten nicht aktualisiert werden`,copyFailed:`Kopieren fehlgeschlagen — bitte Text manuell markieren`,accessCodeRequired:`Bitte zuerst einen Zugangscode setzen`,targetPrinterRequired:`Bitte zuerst einen Zieldrucker auswählen`,bindIpRequired:`Bitte zuerst eine Bind-IP setzen`,accessCodeEmpty:`Zugangscode darf nicht leer sein`,accessCodeLength:`Zugangscode muss genau 8 Zeichen lang sein`,targetCodeChangedRebind:`Zugangscode wurde an den neuen Zieldrucker angepasst. Bitte dieses Gerät im Slicer neu hinzufügen, damit der neue Code übernommen wird.`,created:`Virtueller Drucker erstellt`,failedToCreate:`Virtueller Drucker konnte nicht erstellt werden`,deleted:`Virtueller Drucker gelöscht`,failedToDelete:`Virtueller Drucker konnte nicht gelöscht werden`},list:{title:`Virtuelle Drucker`,add:`Hinzufügen`,addFirst:`Virtuellen Drucker hinzufügen`,empty:`Keine virtuellen Drucker konfiguriert. Fügen Sie einen hinzu, um zu beginnen.`},bindIp:{title:`Bind-Interface`,placeholder:`Interface auswählen...`,hint:`Netzwerkinterface, an das dieser virtuelle Drucker gebunden wird. Muss pro Drucker eindeutig sein.`},proxy:{accessCodeHint:`Im Proxy-Modus den Zugangscode des Zieldruckers im Slicer verwenden. Die Verbindung wird transparent zum echten Drucker weitergeleitet.`},addDialog:{title:`Virtuellen Drucker hinzufügen`,name:`Name`,hint:`Sie können Zugangscode, Zieldrucker und andere Einstellungen nach dem Erstellen konfigurieren.`,create:`Erstellen`},deleteConfirm:{title:`Virtuellen Drucker löschen`,message:`Möchten Sie "{{name}}" wirklich löschen? Dies stoppt alle Dienste für diesen Drucker.`}},modelViewer:{openInSlicer:`Im Slicer öffnen`,tabs:{model:`3D-Modell`,gcode:`G-Code Vorschau`},notAvailable:`nicht verfügbar`,notSliced:`nicht geslicet`,plates:`Platten`,allPlates:`Alle Platten`,plateNumber:`Platte {{number}}`,plateCount:`{{count}} Platte`,plateCount_other:`{{count}} Platten`,objectCount:`{{count}} Objekt`,objectCount_other:`{{count}} Objekte`,filamentCount:`{{count}} Filament`,filamentCount_other:`{{count}} Filamente`,eta:`ETA {{minutes}} Min`,noPreview:`Keine Vorschau für diese Datei verfügbar`,pagination:{pageOf:`Seite {{current}} von {{total}}`,prev:`Zurück`,next:`Weiter`},errors:{failedToLoad:`Datei konnte nicht geladen werden`,noMeshes:`Keine Meshes in 3MF-Datei gefunden`,unsupportedFormat:`Nicht unterstütztes Dateiformat`}},maintenanceDescriptions:{lubricateCarbonRods:`Schmiermittel auf Karbonstäbe für sanfte Bewegung auftragen`,lubricateRails:`Schmiermittel auf Linearschienen für sanfte Bewegung auftragen`,cleanNozzle:`Hotend und Düse reinigen, um Verstopfungen zu verhindern`,checkBelts:`Riemenspannung für präzise Drucke überprüfen`,cleanBuildPlate:`Druckplatte für bessere Haftung reinigen`,checkExtruder:`Extruderzahnräder auf Verschleiß prüfen`,checkCooling:`Sicherstellen, dass Lüfter ordnungsgemäß funktionieren`,generalInspection:`Allgemeine Druckerinspektion`,cleanCarbonRods:`Karbonstäbe reinigen, um Reibung zu reduzieren`,lubricateSteelRods:`Schmiermittel auf Stahlstangen für sanfte Bewegung auftragen`,cleanSteelRods:`Stahlstangen reinigen, um Reibung zu reduzieren`,cleanLinearRails:`Linearschienen abwischen, um Staub und Schmutz zu entfernen`,checkPtfeTube:`PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen`,replaceHepaFilter:`HEPA-Filter für Luftqualität ersetzen`,replaceCarbonFilter:`Aktivkohlefilter ersetzen`,lubricateLeftNozzleRail:`Linke Düsenschiene schmieren (H2-Serie)`},smartPlugs:{offline:`Offline`,admin:`Admin`,openPlugAdminPage:`Plug-Admin-Seite öffnen`,deleteSmartPlug:`Smart Plug löschen`,turnOnSmartPlug:`Smart Plug einschalten`,turnOffSmartPlug:`Smart Plug ausschalten`,turnOn:`Einschalten`,turnOff:`Ausschalten`,addSmartPlug:{scanningNetwork:`Netzwerk wird durchsucht...`,chooseEntity:`Entität auswählen...`,connectionFailed:`Verbindung fehlgeschlagen`,searchEntities:`Entitäten suchen...`,searchPowerSensors:`Leistungssensoren suchen...`,searchEnergySensors:`Energiesensoren suchen...`,placeholders:{plugName:`Wohnzimmer Steckdose`,mqttStateOnValue:`ON, true, 1`,mqttSameAsPower:`Gleich wie Leistungs-Topic oder anders`}},linkedTo:`Verbunden mit:`,monitorOnly:`Nur Überwachung`,alerts:`Alarme`,scheduleOn:`Ein {{time}}`,scheduleOff:`Aus {{time}}`,on:`Ein`,off:`Aus`,power:`Leistung`,kwhToday:`kWh Heute`,settings:`Einstellungen`,automationSettings:`Automatisierungseinstellungen`,showInSwitchbar:`In Schaltleiste anzeigen`,quickAccessSidebar:`Schnellzugriff über Seitenleiste`,enabled:`Aktiviert`,enableAutomation:`Automatisierung für diesen Stecker aktivieren`,autoOn:`Auto Ein`,autoOnDescription:`Einschalten wenn Druck startet`,autoOff:`Auto Aus`,autoOffDescription:`Ausschalten wenn Druck abgeschlossen (einmalig)`,autoOffPersistent:`Aktiviert lassen`,autoOffPersistentDescription:`Zwischen Drucken aktiviert bleiben statt einmalig`,autoOffAfterDrying:`Automatisch aus nach Trocknung`,autoOffAfterDryingDescription:`Ausschalten, wenn AMS-Trocknung abgeschlossen ist`,delayAfterDryingMinutes:`Verzögerung nach Trocknung (Minuten)`,turnOffDelayMode:`Ausschaltverzögerungsmodus`,time:`Zeit`,temp:`Temp.`,delayMinutes:`Verzögerung (Minuten)`,tempThreshold:`Temperaturschwelle (°C)`,tempThresholdDescription:`Schaltet aus wenn die Düse unter diese Temperatur abkühlt`,edit:`Bearbeiten`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,turnOnConfirm:`Möchten Sie "{{name}}" wirklich einschalten?`,turnOffConfirm:`Möchten Sie "{{name}}" wirklich ausschalten? Dies unterbricht die Stromversorgung des angeschlossenen Geräts.`,failedToTurn:`{{name}}" konnte nicht {{action}} werden`,unknown:`Unbekannt`,addTitle:`Smart Plug hinzufügen`,editTitle:`Smart Plug bearbeiten`,stopScanning:`Suche beenden`,discoverTasmota:`Tasmota Geräte suchen`,foundDevices:`{{count}} Gerät(e) gefunden - zum Auswählen klicken:`,noDevicesFound:`Keine Tasmota Geräte in Ihrem Netzwerk gefunden`,haNotConfigured:`Home Assistant ist nicht konfiguriert. Einrichtung unter`,haSettingsPath:`Einstellungen → Netzwerk → Home Assistant`,selectEntity:`Entität auswählen *`,ipAddress:`IP-Adresse *`,nameLabel:`Name *`,username:`Benutzername`,password:`Passwort`,authHint:`Leer lassen, wenn Ihr Tasmota-Gerät keine Authentifizierung benötigt`,linkToPrinter:`Mit Drucker verbinden`,noPrinter:`Kein Drucker (nur manuelle Steuerung)`,linkingDescription:`Verknüpfung ermöglicht automatisches Ein-/Ausschalten bei Druckstart/-ende`,powerAlerts:`Leistungsalarme`,alertAbove:`Alarm wenn über (W)`,alertBelow:`Alarm wenn unter (W)`,alertDescription:`Benachrichtigung wenn der Stromverbrauch diese Schwellenwerte überschreitet. Leer lassen um diese Richtung zu deaktivieren.`,dailySchedule:`Tagesplan`,turnOnAt:`Einschalten um`,turnOffAt:`Ausschalten um`,scheduleDescription:`Den Stecker automatisch täglich zu diesen Zeiten ein-/ausschalten. Leer lassen um diese Aktion zu überspringen.`,showOnPrinterCard:`Auf Druckerkarte anzeigen`,displayOnPrinterCard:`Schaltfläche auf Druckerkarte anzeigen`,connectedResult:`Verbunden!`,deviceLabel:`Gerät: {{name}} - `,stateLabel:`Status: {{state}}`,test:`Test`,delete:`Löschen`,save:`Speichern`,add:`Hinzufügen`,cancel:`Abbrechen`,failedToStartScan:`Suche konnte nicht gestartet werden`,nameRequired:`Name ist erforderlich`,entityRequired:`Entität ist für Home Assistant Stecker erforderlich`,mqttTopicRequired:`Mindestens ein MQTT-Topic muss für Leistung, Energie oder Statusüberwachung konfiguriert sein`,loadingEntities:`Entitäten werden geladen...`,loading:`Laden...`,failedToLoadEntities:`Entitäten konnten nicht geladen werden: {{error}}`,noEntitiesMatching:`Keine Entitäten gefunden die "{{search}}" entsprechen`,noEntitiesAvailable:`Keine Entitäten verfügbar`,searchingEntities:`Alle Entitäten durchsuchen ({{count}} gefunden)`,showingEntities:`Zeige switch, light, input_boolean ({{count}} verfügbar)`,energyMonitoringOptional:`Energieüberwachung (Optional)`,energyMonitoringHint:`Sensoren suchen und auswählen, die Leistungs-/Energiedaten liefern.`,powerSensorW:`Leistungssensor (W)`,energyTodayKwh:`Energie Heute (kWh)`,totalEnergyKwh:`Gesamtenergie (kWh)`,noMatchingSensors:`Keine passenden Sensoren`,none:`Keine`,mqttNotConfigured:`MQTT-Broker nicht konfiguriert. Broker-Adresse einstellen unter`,mqttSettingsPath:`Einstellungen → Netzwerk → MQTT-Veröffentlichung`,mqttNotConfiguredSuffix:`(Sie müssen die Veröffentlichung nicht aktivieren, nur die Broker-Details ausfüllen).`,mqttMonitorOnlyDescription:`MQTT-Stecker empfangen Leistungs-/Energiedaten über MQTT-Abonnement. Ein-/Ausschalten ist nicht verfügbar - verwenden Sie Ihren MQTT-Broker oder Ihr Home-Automation-System.`,powerMonitoring:`Leistungsüberwachung`,energyMonitoring:`Energieüberwachung`,stateMonitoring:`Statusüberwachung`,optional:`optional`,topic:`Thema`,jsonPath:`JSON-Pfad`,multiplier:`Multiplikator`,onValue:`EIN-Wert`,mqttPowerHint:`JSON-Pfad extrahiert Wert aus JSON-Payload (z.B. "power_l1"). Leer lassen wenn Topic rohe numerische Werte sendet. +ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).`,restControl:`Control`,restOnUrl:`Turn ON URL`,restOffUrl:`Turn OFF URL`,restOnBody:`ON Request Body`,restOffBody:`OFF Request Body`,restMethod:`HTTP Method`,restHeaders:`Custom Headers (JSON)`,restStatusUrl:`Status URL`,restStatusPath:`State JSON Path`,restStatusOnValue:`ON Value`,restPowerUrl:`Power URL`,restPowerPath:`Power JSON Path`,restPowerMultiplier:`Power Multiplier`,restEnergyUrl:`Energy URL`,restEnergyPath:`Energy JSON Path`,restEnergyMultiplier:`Energy Multiplier`,restUrlRequired:`At least one URL (ON or OFF) is required for REST plugs`,restHeadersHint:`e.g. {"Authorization": "Bearer your-token"}`,restBodyHint:`e.g. ON, {"state": "on"}`,restStatusHint:`URL to poll for current state`,restPathHint:`e.g. state or data.power.status`,restPowerUrlHint:`Separate URL for power data (uses Status URL if empty)`,restEnergyUrlHint:`Separate URL for energy data (uses Status URL if empty)`,restEnergyHint:`Each value can use its own URL or fall back to the Status URL. Use multipliers for unit conversion (e.g. 0.001 to convert Wh to kWh).`,testConnection:`Test Connection`,connectionSuccess:`Connection successful`,noSwitchesInSwitchbar:`No switches in switchbar`,enableSwitchbarHint:`Enable "Show in Switchbar" in Settings > Smart Plugs`},notifications:{providerTypes:{callmebot:`CallMeBot/WhatsApp`,ntfy:`ntfy`,pushover:`Pushover`,telegram:`Telegram`,email:`Email`,discord:`Discord`,webhook:`Webhook`,homeassistant:`Home Assistant`},providerDescriptions:{email:`SMTP email notifications`,telegram:`Notifications via Telegram bot`,discord:`Send to Discord channel via webhook`,ntfy:`Free, self-hostable push notifications`,pushover:`Simple, reliable push notifications`,callmebot:`Free WhatsApp notifications via CallMeBot`,webhook:`Generic HTTP POST to any URL`,homeassistant:`Persistent notifications in Home Assistant dashboard`},lastSuccess:`Last: {{date}}`,error:`Error`,printer:`Printer:`,allPrinters:`All printers`,sendTestNotification:`Send Test Notification`,eventSettings:`Event Settings`,enabled:`Enabled`,sendFromProvider:`Send notifications from this provider`,printEvents:`Print Events`,printerStatus:`Printer Status`,amsAlarms:`AMS Alarms`,amsHtAlarms:`AMS-HT Alarms`,printQueue:`Print Queue`,start:`Start`,plateCheck:`Plate Check`,complete:`Complete`,failed:`Failed`,stopped:`Stopped`,progress:`Progress`,offline:`Offline`,lowFilament:`Low Filament`,maintenance:`Maintenance`,amsHumidity:`AMS Humidity`,amsTemp:`AMS Temp`,amsHtHumidity:`AMS-HT Humidity`,amsHtTemp:`AMS-HT Temp`,bedCooled:`Bed Cooled`,firstLayer:`First Layer`,quiet:`Quiet`,digest:`Digest {{time}}`,printStarted:`Print Started`,plateNotEmpty:`Plate Not Empty`,plateNotEmptyDescription:`Objects detected before print`,printCompleted:`Print Completed`,bedCooledLabel:`Bed Cooled`,bedCooledDescription:`Bed cooled below threshold after print`,firstLayerCompleteLabel:`First Layer Complete`,firstLayerCompleteDescription:`Notify with snapshot when first layer finishes`,missingSpoolAssignmentLabel:`Missing Spool Assignment`,missingSpoolAssignmentDescription:`Notify when print starts and required trays have no assigned spool`,printFailed:`Print Failed`,printStopped:`Print Stopped`,progressMilestones:`Progress Milestones`,progressMilestonesDescription:`Notify at 25%, 50%, 75%`,printerOffline:`Printer Offline`,printerError:`Printer Error`,aiFailureDetection:`AI Failure Detection`,aiFailureDetectionDescription:`Notify when Obico AI detects a possible print failure`,lowFilamentLabel:`Low Filament`,maintenanceDue:`Maintenance Due`,maintenanceDueDescription:`Notify when maintenance is needed`,amsHumidityHigh:`AMS Humidity High`,amsHumidityHighDescription:`Regular AMS humidity exceeds threshold`,amsTemperatureHigh:`AMS Temperature High`,amsTemperatureHighDescription:`Regular AMS temperature exceeds threshold`,amsHtHumidityHigh:`AMS-HT Humidity High`,amsHtHumidityHighDescription:`AMS-HT humidity exceeds threshold`,amsHtTemperatureHigh:`AMS-HT Temperature High`,amsHtTemperatureHighDescription:`AMS-HT temperature exceeds threshold`,inventoryAlerts:`Inventory Alerts`,stockReorderAlert:`Reorder Alert`,stockReorderAlertDescription:`SKU has reached its reorder point`,stockBreakAlert:`Stock Break Alert`,stockBreakAlertDescription:`Stock will run out before replenishment arrives`,jobAdded:`Job Added`,jobAddedDescription:`Job added to queue`,jobAssigned:`Job Assigned`,jobAssignedDescription:`Model-based job assigned to printer`,jobStarted:`Job Started`,jobStartedDescription:`Queue job started printing`,jobWaiting:`Job Waiting`,jobWaitingDescription:`Job waiting for filament or printer`,jobSkipped:`Job Skipped`,jobSkippedDescription:`Job skipped (previous failed)`,jobFailed:`Job Failed`,jobFailedDescription:`Job failed to start`,queueComplete:`Queue Complete`,queueCompleteDescription:`All queue jobs finished`,quietHours:`Quiet Hours`,noNotificationsDuring:`No notifications during these hours`,editProviderToChangeQuietHours:`Edit provider to change quiet hours`,dailyDigest:`Daily Digest`,batchNotifications:`Batch notifications into a single daily summary`,sendAt:`Send at {{time}}`,editProviderToChangeDigestTime:`Edit provider to change digest time`,edit:`Edit`,deleteProvider:`Delete Notification Provider`,deleteConfirm:`Are you sure you want to delete "{{name}}"? This cannot be undone.`,delete:`Delete`,addTitle:`Add Notification Provider`,editTitle:`Edit Notification Provider`,nameLabel:`Name *`,namePlaceholder:`My Notifications`,providerTypeLabel:`Provider Type *`,configuration:`Configuration`,testConfiguration:`Test Configuration`,printerFilter:`Printer Filter`,onlyFromPrinter:`Only send notifications for events from this printer`,quietHoursDnd:`Quiet Hours (Do Not Disturb)`,quietStart:`Start`,quietEnd:`End`,dailyDigestLabel:`Daily Digest`,sendDigestAt:`Send digest at`,digestCollected:`Events will be collected and sent as a single summary at this time`,notificationEvents:`Notification Events`,progressPercent:`(25%, 50%, 75%)`,bedCooledAfterPrint:`(after print completes)`,eventPriority:{sectionTitle:`ntfy Priority`,helpNtfy:`Pick a priority for each enabled event. ntfy uses these to escalate alerts (sound, visibility, push behavior). Levels not set here use the ntfy server default.`,min:`Min`,low:`Low`,default:`Default`,high:`High`,urgent:`Urgent`},cancel:`Cancel`,save:`Save`,add:`Add`,nameRequired:`Name is required`,fieldRequired:`{{field}} is required`,phoneNumber:`Phone Number`,apiKey:`API Key`,serverUrl:`Server URL`,topic:`Topic`,authToken:`Auth Token`,userKey:`User Key`,appToken:`App Token`,priority:`Priority`,botToken:`Bot Token`,chatId:`Chat ID`,smtpServer:`SMTP Server`,smtpPort:`SMTP Port`,security:`Security`,authentication:`Authentication`,username:`Username`,password:`Password`,fromEmail:`From Email`,toEmail:`To Email`,webhookUrl:`Webhook URL`,payloadFormat:`Payload Format`,authorization:`Authorization`,titleFieldName:`Title Field Name`,messageFieldName:`Message Field Name`,editTemplate:`Edit Template: {{name}}`,titleLabel:`Title`,bodyLabel:`Body`,titlePlaceholder:`Notification title...`,bodyPlaceholder:`Notification body...`,availableVariables:`Available Variables`,clickToInsert:`Click to insert at cursor position in body`,livePreview:`Live Preview`,hide:`Hide`,show:`Show`,loadingPreview:`Loading preview...`,enterTemplateContent:`Enter template content to see preview`,titlePreview:`Title:`,bodyPreview:`Body:`,resetToDefault:`Reset to Default`,titleRequired:`Title is required`,bodyRequired:`Body is required`,notificationLog:`Notification Log`,showFailedOnly:`Failed only`,last24Hours:`Last 24 hours`,last7Days:`Last 7 days`,last30Days:`Last 30 days`,last90Days:`Last 90 days`,justNow:`Just now`,noFailedNotifications:`No failed notifications`,noNotificationsLogged:`No notifications logged`,unknownProvider:`Unknown Provider`,logTitle:`Title`,logMessage:`Message`,logError:`Error`,logProvider:`Provider: {{type}}`,logTime:`Time: {{time}}`,refresh:`Refresh`,clearOld:`Clear Old`,statsSummary:`Last {{days}} days:`,statsNotifications:`notifications`,statsSent:`{{count}} sent`,statsFailed:`{{count}} failed`,eventTypes:{print_start:`Print Started`,print_complete:`Print Complete`,print_failed:`Print Failed`,print_stopped:`Print Stopped`,print_progress:`Progress`,printer_offline:`Printer Offline`,printer_error:`Printer Error`,filament_low:`Low Filament`,maintenance_due:`Maintenance Due`,test:`Test`},userEmail:{title:`Notifications`,emailNotifications:`Email Notifications`,emailNotificationsDesc:`Receive email notifications for your own print jobs. Emails are sent using the system SMTP settings configured in Advanced Authentication.`,sendingTo:`Notifications will be sent to`,noEmailWarning:`Your account does not have an email address. Contact an administrator to add one.`,printJobNotifications:`Print Job Notifications`,printJobNotificationsDesc:`Choose which events trigger email notifications for print jobs you submit.`,printJobStarts:`Print Job Starts`,printJobStartsDesc:`Get notified when your print job begins.`,printJobFinishes:`Print Job Finishes`,printJobFinishesDesc:`Get notified when your print job completes successfully.`,printErrors:`Print Errors`,printErrorsDesc:`Get notified when your print job fails or encounters an error.`,printJobStops:`Print Job Stops`,printJobStopsDesc:`Get notified when your print job is cancelled or stopped.`,saveSuccess:`Notification preferences saved.`,saveError:`Failed to save notification preferences.`}},richTextEditor:{bold:`Bold`,italic:`Italic`,underline:`Underline`,bulletList:`Bullet List`,numberedList:`Numbered List`,alignLeft:`Align Left`,alignCenter:`Align Center`,alignRight:`Align Right`,addLink:`Add Link`,removeLink:`Remove Link`},externalLinks:{title:`Sidebar Links`,sidebarLayout:`Sidebar`,sidebarLayoutDescription:`Show or hide built-in pages, add external links, and drag items to reorder the sidebar navigation.`,systemPages:`Bambuddy pages`,externalLinks:`External links`,visibleInSidebar:`Visible in sidebar`,hiddenFromSidebar:`Hidden from sidebar`,requiredInSidebar:`Required in sidebar`,hidePage:`Hide page`,showPage:`Show page`,settingsCannotBeHidden:`Settings cannot be hidden`,noLinksConfigured:`No external links configured`,deleteLink:`Delete Link`,removeCustomIcon:`Remove custom icon`,openInNewTab:`Open in new tab`,placeholders:{linkName:`My Link`}},keyboardShortcuts:{title:`Keyboard Shortcuts`,navigation:`Navigation`,archivesSection:`Archives`,kProfilesSection:`K-Profiles`,generalSection:`General`,shortcuts:{goToPrinters:`Go to Printers`,goToArchives:`Go to Archives`,goToQueue:`Go to Queue`,goToStats:`Go to Statistics`,goToProfiles:`Go to Cloud Profiles`,goToSettings:`Go to Settings`,focusSearch:`Focus search`,openUploadModal:`Open upload modal`,clearSelection:`Clear selection / blur input`,contextMenu:`Context menu on cards`,refreshProfiles:`Refresh profiles`,newProfile:`New profile`,exitSelectionMode:`Exit selection mode`,showHelp:`Show this help`},footer:`Press Esc or click outside to close`},notificationLog:{title:`Notification Log`,events:{printStarted:`Print Started`,printComplete:`Print Complete`,printFailed:`Print Failed`,printStopped:`Print Stopped`,progress:`Progress`,printerOffline:`Printer Offline`,printerError:`Printer Error`,lowFilament:`Low Filament`,maintenanceDue:`Maintenance Due`,test:`Test`},timeAgo:{justNow:`Just now`,minutesAgo:`{{minutes}}m ago`,hoursAgo:`{{hours}}h ago`}},restoreBackup:{title:`Restore Backup`,restoring:`Restoring...`,restoreComplete:`Restore Complete`,restoreFailed:`Restore Failed`,importSettings:`Import settings from a backup file`,pleaseWait:`Please wait while your data is being restored`,clickToSelect:`Click to select backup file (.json or .zip)`,howDuplicateHandling:`How duplicate handling works:`,categories:{printers:`Printers`,smartPlugs:`Smart Plugs`,notificationProviders:`Notification Providers`,filaments:`Filaments`,archives:`Archives`,pendingUploads:`Pending Uploads`,settingsTemplates:`Settings & Templates`},matchingInfo:{printers:`matched by serial number`,smartPlugs:`matched by IP address`,notificationProviders:`matched by name`,filaments:`matched by name + type + brand`,archives:`matched by content hash`,pendingUploads:`matched by filename`,settingsTemplates:`always overwritten`},replaceExisting:`Replace existing data`,keepExisting:`Keep existing data`,replaceDescription:`Overwrite items that already exist with backup data`,keepDescription:`Only restore items that don't already exist`,caution:`Caution:`,cautionText:`Overwriting will replace your current configurations with backup data. Printer access codes are never overwritten for security.`,itemsRestored:`Items Restored`,itemsSkipped:`Items Skipped`,restored:`Restored`,skipped:`Skipped (already exist)`,filesLabel:`Files (3MF, thumbnails, etc.)`,newApiKeysGenerated:`New API Keys Generated`,newApiKeysWarning:`These keys are only shown once. Copy them now!`,processingBackup:`Processing backup file...`,noDataFound:`No data was found to restore in the backup file.`,failedToRestore:`Failed to restore backup. Please check the file format.`},backupExport:{title:`Export Backup`,selectData:`Select data to include`,selectAll:`Select All`,selectNone:`Select None`,categoryDescriptions:{settings:`Language, theme, update preferences`,notifications:`ntfy, Pushover, Discord, etc.`,templates:`Custom message templates`,smartPlugs:`Tasmota plug configurations`,externalLinks:`Sidebar links to external services`,printers:`Printer info (access codes excluded)`,plateDetection:`Empty plate reference images`,filaments:`Filament types and costs`,maintenance:`Custom maintenance schedules`,archives:`All print data + files (3MF, thumbnails, photos)`,projects:`Projects, BOM items, and attachments`,pendingUploads:`Virtual printer uploads awaiting review`,apiKeys:`Webhook API keys (new keys generated on import)`},requiresPrinters:`Requires Printers to be selected`,zipFileWarning:`ZIP file will be created.`,zipFileDescription:`Includes all 3MF files, thumbnails, timelapses, and photos. This may take a while and result in a large file.`,includeAccessCodes:`Include Access Codes`,includeAccessCodesDescription:`For transferring to another machine`,includeAccessCodesWarning:`Access codes will be included in plain text. Keep this backup file secure!`,categoriesSelected:`{{selectedCount}} categories selected`},pendingUploads:{placeholders:{notes:`Add notes about this print...`},discardUpload:`Discard Upload`,archiveAllUploads:`Archive All Uploads`,discardAllUploads:`Discard All Uploads`,archive:`Archive`,timeAgo:{justNow:`Just now`,minutesAgo:`{{minutes}}m ago`,hoursAgo:`{{hours}}h ago`,daysAgo:`{{days}}d ago`}},apiBrowser:{placeholders:{requestBody:`JSON request body...`,searchEndpoints:`Search endpoints...`}},configureAmsSlot:{title:`Configure AMS Slot`,slotConfigured:`Slot Configured!`,configuringSlot:`Configuring slot:`,slotLabel:`{{ams}} Slot {{slot}}`,searchPresets:`Search presets...`,colorPlaceholder:`Color name or hex (e.g., brown, FF8800)`,clearCustomColor:`Clear custom color`,noCloudPresets:`No cloud presets. Login to Bambu Cloud to sync.`,noPresetsAvailable:`No presets available. Login to Bambu Cloud or import local profiles.`,noMatchingPresets:`No matching presets found.`,custom:`Custom`,builtin:`Built-in`,orcaCloud:`Orca Cloud`,bambuCloud:`Bambu Cloud`,settingsSentToPrinter:`Settings sent to printer`,filamentProfile:`Filament Profile`,kProfileLabel:`K Profile (Pressure Advance)`,filteringFor:`Filtering for: {{material}}`,noKProfile:`No K profile (use default 0.020)`,noMatchingKProfiles:`No matching K profiles found. Default K=0.020 will be used.`,selectFilamentFirst:`Select a filament profile first`,kFromCalibration:`K={{value}} from printer calibration`,customColorLabel:`Custom Color (optional)`,presetColors:`{{name}} colors:`,showLessColors:`Show less colors`,showMoreColors:`Show more colors`,clear:`Clear`,hexLabel:`Hex: #{{hex}}`,resetting:`Resetting...`,resetSlot:`Reset Slot`,cancel:`Cancel`,configuring:`Configuring...`,configureSlot:`Configure Slot`},githubBackup:{title:`Git Backup`,history:`History`,downloadBackup:`Download Backup`,restoreBackup:`Restore Backup`,noBackupsYet:`No backups yet`},emailSettings:{placeholders:{fromName:`BamBuddy`}},tagManagement:{searchTags:`Search tags...`,renameTag:`Rename tag`,deleteTag:`Delete tag`},notificationTemplates:{placeholders:{title:`Notification title...`,body:`Notification body...`}},batchTag:{placeholders:{newTag:`Enter new tag...`}},photoGallery:{deletePhoto:`Delete Photo`},filamentHoverCard:{copySpoolUuid:`Copy spool UUID`},kProfilesView:{hasNote:`Has note`,copyProfile:`Copy profile`},layout:{openMenu:`Open menu`,noPermissionSystemInfo:`You do not have permission to view system information`},dashboard:{dragToReorder:`Drag to reorder`,hideWidget:`Hide widget`},notificationProviderCard:{deleteNotificationProvider:`Delete Notification Provider`},fileManagerModal:{closeFileManager:`Close file manager`,sortFiles:`Sort files`,goToParentFolder:`Go to parent folder`,threeView:`3D View`},embeddedCameraViewer:{refreshStream:`Refresh stream`,close:`Close`,zoomOut:`Zoom out`,resetZoom:`Reset zoom`,zoomIn:`Zoom in`,dragToResize:`Drag to resize`},timelapseViewer:{skipBack5s:`Skip back 5s`,skipForward5s:`Skip forward 5s`},notificationProviders:{descriptions:{email:`SMTP email notifications`,telegram:`Notifications via Telegram bot`,discord:`Send to Discord channel via webhook`,ntfy:`Free, self-hostable push notifications`,pushover:`Simple, reliable push notifications`,callmebot:`Free WhatsApp notifications via CallMeBot`,webhook:`Generic HTTP POST to any URL`}},logViewer:{searchPlaceholder:`Search message or logger name...`,noLogEntries:`No log entries found`},switchbarPopover:{noSwitchesInSwitchbar:`No switches in switchbar`},projectPageModal:{placeholders:{title:`Title`,designer:`Designer`,license:`License`,description:`Enter description...`,profileTitle:`Profile Title`,profileDescription:`Profile description...`}},spoolmanSettings:{},time:{unknown:`-`,waiting:`Waiting`,justNow:`Just now`,now:`Now`,minsAgo:`{{count}}m ago`,inMins:`in {{count}}m`,hoursAgo:`{{count}}h ago`,inHours:`in {{count}}h`,daysAgo:`{{count}}d ago`,inDays:`in {{count}}d`},spoolbuddy:{nav:{dashboard:`Dashboard`,ams:`AMS`,inventory:`Inventory`,writeTag:`Write`,settings:`Settings`},status:{nfcReady:`NFC Ready`,nfcOff:`NFC Off`,offline:`Offline`,online:`Online`,noPrinters:`No printers`,deviceOffline:`Device Offline`,waitingConnection:`Waiting for device connection...`,systemReady:`System Ready`,status:`Status`},dashboard:{readyToScan:`Ready to scan`,idleMessage:`Place a spool on the scale to identify it`,nfcHint:`NFC tag will be read automatically`,device:`Device`,syncWeight:`Sync Weight`,weightSynced:`Synced!`,unknownTag:`Unknown Tag`,newTag:`New Tag Detected`,onScale:`on scale`,linkSpool:`Link to Spool`,linkTagTitle:`Link Tag to Spool`,linkTag:`Link Tag`,selectSpool:`Select a spool to link this tag to:`,noUntagged:`No spools without tags found`,tagDetected:`Tag detected`,noTag:`No tag`,tagId:`Tag`,grossWeight:`Gross weight`,spoolSize:`Spool size`,close:`Close`,currentSpool:`Current Spool`,plateReady:`Plate ready: {{name}}`,plateReadyLabel:`Plates ready to clear`,plateClearAction:`Clear`,plateClearedToast:`Plate marked as cleared`,plateClearFailed:`Could not mark plate as cleared`},modal:{spoolDetected:`Spool Detected`,assignToAms:`Assign to AMS`,syncWeight:`Sync Weight`,weightSynced:`Synced!`,syncing:`Syncing...`,newTagDetected:`New Tag Detected`,addToInventory:`Add to Inventory`,assignToAmsTitle:`Assign to AMS`,selectSlot:`Select a slot`,assign:`Assign`,assigning:`Assigning...`,assignSuccess:`Assigned!`,assignPendingInsert:`Assigned. Slot will configure when you insert the spool.`,assignError:`Failed to assign spool. Please try again.`,noPrinterSelected:`Select a printer...`,noAmsDetected:`No AMS detected on this printer`,slot:`Slot`},weight:{noReading:`No reading`,stable:`Stable`,measuring:`Measuring...`,tare:`Tare`,calibrate:`Calibrate`},spool:{remaining:`Remaining`,material:`Material`,brand:`Brand`,color:`Color`,coreWeight:`Core`,labelWeight:`Label`,scaleWeight:`Scale`,netWeight:`Net`,lastUsed:`Last used`},ams:{noData:`No AMS detected`,connectAms:`Connect an AMS to see filament slots`,noPrinter:`No printer selected`,selectPrinter:`Select a printer from the top bar`,printerDisconnected:`Printer disconnected`,humidity:`Humidity`,level:`Level`,active:`Active`,slot:`Slot`,empty:`Empty`},inventory:{search:`Search spools...`,empty:`No spools in inventory`,noResults:`No matching spools`,spools:`spools`,addSpool:`Add Spool`},settings:{tabDevice:`Device`,tabDisplay:`Display`,tabScale:`Scale`,tabUpdates:`Updates`,nfcReader:`NFC Reader`,type:`Type`,connection:`Connection`,notConnected:`N/A`,deviceInfo:`Device Info`,hostname:`Host`,uptime:`Uptime`,systemConfig:`Backend & Auth`,backendUrl:`Bambuddy Backend URL`,apiToken:`API Token`,apiTokenPlaceholder:`Enter API token`,saveConfig:`Save Config`,systemQueued:`Config queued.`,nfcDiagnostic:`NFC Diagnostic`,scaleDiagnostic:`Scale Diagnostic`,readTagDiagnostic:`Read Tag Diagnostic`,testNfc:`Test reader`,testScale:`Test accuracy`,testReadTag:`Read tag`,systemFieldsRequired:`Backend URL is required.`,brightness:`Brightness`,saved:`Saved`,noBacklight:`No DSI backlight detected. Brightness control requires a DSI display.`,screenBlank:`Screen Blank Timeout`,screenBlankDesc:`Screen turns off after inactivity. Touch to wake.`,displayNote:`Brightness is applied as a software filter.`,scaleCalibration:`Scale Calibration`,currentWeight:`Current weight`,tareOffset:`Tare`,calFactor:`Factor`,knownWeight:`Known weight`,calStep1:`Remove all items from the scale and press Set Zero.`,calStep2:`Place known weight on scale.`,setZero:`Set Zero`,calibrateNow:`Calibrate`,calibrated:`Calibrated`,tareSet:`Tare command sent. Waiting for device...`,tareComplete:`Tare complete!`,tareTimedOut:`Tare timed out — is the SpoolBuddy daemon running?`,tareFailed:`Failed to send tare command`,zeroSet:`Zero point set. Place known weight on scale.`,calibrationDone:`Calibration complete!`,calibrationFailed:`Calibration failed`,lastCalibrated:`Last calibrated`,stable:`Stable`,settling:`Settling...`,firmware:`Firmware`,scale:`Scale`,noDevice:`No SpoolBuddy device found`,daemonVersion:`Daemon Version`,currentVersion:`Current`,versionPending:`Waiting for daemon...`,checking:`Checking...`,checkUpdates:`Check for Updates`,updateAvailable:`Update available`,updateInstructions:`Update via SSH: run the SpoolBuddy install script to upgrade.`,upToDate:`Up to date`,includeBeta:`Include beta versions`},writeTag:{tabExisting:`Existing Spool`,tabNew:`New Spool`,tabReplace:`Replace Tag`,searchPlaceholder:`Search by material, color, brand...`,noUntaggedSpools:`No spools without tags`,noTaggedSpools:`No spools with tags`,selectSpool:`Select a spool, then place a blank NTAG on the reader`,placeTag:`Place an NTAG on the reader`,tagReady:`Tag detected — ready to write`,writeTag:`Write Tag`,replaceTag:`Replace Tag`,writing:`Writing tag...`,waiting:`Waiting for SpoolBuddy...`,writeSuccess:`Tag written successfully!`,writeFailed:`Write failed`,queueFailed:`Failed to queue write command`,tryAgain:`Try Again`,cancel:`Cancel`,replaceWarning:`Old tag will be unlinked. New tag will replace it.`,deviceOffline:`SpoolBuddy is offline`,material:`Material`,colorName:`Color Name`,color:`Color`,brand:`Brand`,weight:`Weight (g)`,createSpool:`Create Spool`,creating:`Creating...`,spoolCreated:`Spool created! Ready to write.`,createFailed:`Failed to create spool`,incompleteDataWarning:`Tag written with incomplete Spoolman data`},quickMenu:{printerPower:`Printer Power`,systemControls:`System`,restartDaemon:`Restart Daemon`,restartBrowser:`Restart Browser`,reboot:`Reboot`,shutdown:`Shutdown`,swipeToClose:`Swipe down to close`,confirmTitle:`Confirm`,confirmShutdown:`Are you sure you want to shut down the SpoolBuddy? You will need physical access to turn it back on.`,confirmReboot:`Are you sure you want to reboot the SpoolBuddy?`,confirmRestartDaemon:`Restart the SpoolBuddy daemon? NFC and scale will be temporarily unavailable.`,confirmRestartBrowser:`Restart the kiosk browser? The display will briefly go blank.`,confirm:`Confirm`,confirmPlugOn:`Turn on {{name}}?`,confirmPlugOff:`Turn off {{name}}?`,turnOn:`Turn On`,turnOff:`Turn Off`}},diagnostic:{modalTitle:`Connection diagnostic — {{name}}`,running:`Running diagnostic...`,runningElapsed:`Running diagnostic... ({{elapsed}}s)`,waitingForReportHint:`Listening for the printer to publish a status report — this can take up to {{max}} seconds.`,runFailed:`Diagnostic could not run: {{error}}`,retry:`Run again`,runButton:`Run diagnostic`,sectionTitle:`Connection Diagnostic`,sectionDescription:`Check why a printer won't connect or won't print — port reachability, LAN developer mode, Docker network mode, and credentials.`,noPrinters:`No printers configured.`,overall:{ok:`No problems found — the printer connection looks healthy.`,warnings:`The printer should work, but some things need attention.`,problems:`Found problems that explain why the printer won't connect or print.`},check:{port_mqtt:{title:`Control port (MQTT 8883)`,pass:`Reachable — the printer is accepting control connections.`,fail:`Port 8883 is unreachable. The printer is powered off, on a different IP address, or a firewall is blocking it. Verify the printer IP and that nothing blocks port 8883.`},port_ftps:{title:`File transfer port (FTPS 990)`,pass:`Reachable — sending print files will work.`,warn:`Port 990 is unreachable. Monitoring may still work, but sending prints to the printer will fail. Make sure port 990 is not blocked.`},external_storage:{title:`Store sent files on external storage (install step 4)`,pass:`The printer reports this option is on — sent files will be stored on the SD card and archives will have thumbnails and slicer metadata.`,fail:`The printer reports this option is off. Enable "Store sent files on external storage" — on newer firmware (P2S 01.02 / Bambu Studio 2.6+) the toggle lives on the printer's Print Settings; on older versions it's in Bambu Studio / OrcaSlicer's Device tab. Without it, every archived print is missing its thumbnail and slicer metadata.`,skip:`Not checked — needs a live MQTT connection. On older slicers where this setting lives only in the slicer the printer never reports it, so this check will pass even when the option is off — verify install step 4 manually.`},port_rtsps:{title:`Camera port ({{protocol}} {{port}})`,pass:`Reachable — the camera stream will work.`,warn:`Port {{port}} is unreachable. The live camera view will not work. This does not affect printing.`},network_mode:{title:`Docker network mode`,pass:`Running in host network mode.`,warn:`Bambuddy is running in Docker bridge networking. Printer discovery and the Virtual Printer need host network mode — recreate the container with "network_mode: host".`,skip:`Not running in Docker — not applicable.`},subnet:{title:`Network subnet`,pass:`The printer and Bambuddy are on the same subnet.`,warn:`The printer ({{printer_ip}}) and Bambuddy ({{host_ip}}) are on different subnets. They may not reach each other unless routing between the subnets is configured.`,skip:`Subnet could not be determined — skipped.`},mqtt_auth:{title:`Printer credentials`,pass:`The printer accepted the connection.`,fail:`The printer is reachable but rejected the connection. The access code or serial number is most likely wrong. The access code changes every time Developer Mode is toggled — re-copy it from the printer screen.`,skip:`Not checked — the printer could not be reached.`},developer_mode:{title:`LAN Developer Mode`,pass:`Developer Mode is enabled.`,fail:`Developer Mode is OFF on the printer. Enable it in the printer's LAN settings — and confirm with OK. Without it, prints will not start.`,skip:`Could not be checked — requires a live connection to the printer.`},printer_publishing:{title:`Printer is publishing status`,pass:`The printer is publishing status updates — AMS, filaments, and K-profiles will mirror correctly to the slicer.`,fail:`The MQTT broker accepted the connection but the printer has not published any status reports. This is almost always a wrong or mis-cased serial number — the device//report topic is case-sensitive. Re-check the serial in printer settings against the screen on the printer.`,skip:`Could not be checked — requires a live connection to the printer.`}}},systemHealth:{sectionTitle:`System Health`,sectionDescription:`Scans recent logs for known issues you can usually fix yourself, before they turn into a support ticket.`,rescan:`Re-scan`,clean:`No known issues found in the last {{times}} log entries.`,logUnavailable:`File logging is disabled, so logs cannot be scanned. Enable file logging to use this check.`,learnMore:`How to fix`,fixLabel:`Fix:`,occurrences:`Seen {{times}}× — last at {{lastSeen}}`,category:{layer8:`You can fix this`,environment:`Environment`,bug:`Please report this`},signature:{"ftp-auth-rejected":{name:`Printer rejected the access code`,cause:`The printer refused the file-transfer login. The access code is wrong, or it changed after Developer Mode was toggled.`,fix:`Re-copy the access code from the printer screen (LAN settings) and update it in the printer's settings in Bambuddy.`},"ftp-connection-timeout":{name:`File-transfer connection timed out`,cause:`Bambuddy could not reach the printer's file-transfer port (FTPS 990). The port is blocked, or the printer is off or on another subnet.`,fix:`Make sure nothing blocks port 990 between Bambuddy and the printer, and that both are on the same network.`},"ftp-ssl-error":{name:`Secure file-transfer handshake failed`,cause:`The TLS handshake with the printer's file-transfer server failed. This is often a firewall or outdated printer firmware.`,fix:`Update the printer firmware and check that no firewall or proxy intercepts the connection on port 990.`},"mqtt-connection-flapping":{name:`Printer connection keeps dropping`,cause:`The control connection (MQTT 8883) repeatedly disconnects and reconnects — usually a weak network path or a partially blocked port.`,fix:`Check the Wi-Fi signal at the printer, prefer a wired connection, and make sure port 8883 is reliably reachable.`},"camera-connection-refused":{name:`Camera stream unreachable`,cause:`The live camera could not be reached on port RTSPS 322. The port is blocked, or the camera or LAN liveview is off on the printer.`,fix:`Enable the camera and LAN liveview on the printer, and make sure port 322 is not blocked. This does not affect printing.`},"database-locked":{name:`Database write contention`,cause:`The SQLite database is hitting "database is locked" errors under load — common when running several printers at once.`,fix:`Switch Bambuddy to an external PostgreSQL database. See the PostgreSQL guide in the documentation.`}}},vpDiagnostic:{title:`Setup check — {{name}}`,runButton:`Run setup check`,running:`Running setup check...`,runFailed:`Could not run the setup check: {{error}}`,retry:`Run again`,overall:{ok:`All checks passed — this virtual printer is set up correctly.`,warnings:`The virtual printer should work, but some things need attention.`,problems:`Found problems that explain why the slicer can't see or use this virtual printer.`},check:{enabled:{title:`Virtual printer enabled`,fail:`This virtual printer is switched off. Toggle it on to make it discoverable.`},running:{title:`Services running`,fail:`The virtual printer is enabled but its services are not running. Check the Bambuddy log — a bind IP conflict or a permission error usually stops them.`},bind_interface:{title:`Bind network interface`,fail:`The bind interface is not set, or no longer exists on this host. Pick a current interface in the Bind Interface dropdown.`},access_code:{title:`Access code set`,fail:`No access code is set. The slicer must be given the same 8-character access code you set here.`},target_printer:{title:`Target printer`,fail:`No target printer is selected. Proxy mode needs a real printer to forward to.`,warn:`The target printer is offline right now — proxying will resume once it reconnects.`},port_ftps:{title:`File-upload service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer cannot upload files. A port conflict on this interface is the usual cause.`},port_mqtt:{title:`Control service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer cannot connect or show status.`},port_bind:{title:`Discovery service (port {{port}})`,fail:`Nothing is listening on port {{port}} of the bind IP, so the slicer's discovery handshake fails.`},certificate:{title:`TLS certificate`,pass:`Certificate ready. Make sure the Bambuddy CA certificate (above) is imported into your slicer's trust store.`,fail:`The TLS certificate for this virtual printer is missing. Check that the Bambuddy data directory is writable.`}}},bugReport:{title:`Report a Bug`,description:`Description`,descriptionPlaceholder:`What went wrong? Please describe the issue...`,email:`Email (optional)`,emailPlaceholder:`your@email.com`,emailPrivacy:`If provided, your email will be included in a collapsed section of the GitHub issue so the maintainer can follow up.`,screenshot:`Screenshot`,uploadOrPaste:`Upload, paste, or drag an image`,dataCollectedSummary:`What data is included in the report?`,dataIncluded:`Included:`,dataIncludedList:`App version, OS, architecture, Python version, database stats (counts only), printer models, nozzle counts, firmware versions, connectivity status, integration status (Spoolman, MQTT, HA), non-sensitive settings, network interface count, Docker details, dependency versions.`,dataNeverIncluded:`Never included:`,dataNeverIncludedList:`Printer names, serial numbers, access codes, passwords, IP addresses, email addresses, API keys, tokens, webhook URLs, hostnames, or usernames.`,submit:`Submit`,startLogging:`Start Debug Logging`,stepEnableLogging:`Debug logging enabled`,stepReproduce:`Reproduce the issue now`,stepStopLogging:`Stop & submit report`,stopAndSubmit:`Stop & Submit`,maxDuration:`Auto-stops after {{minutes}} min`,stoppingLogs:`Collecting logs & submitting...`,submitting:`Submitting bug report...`,submittingStepConnection:`Running printer connectivity checks`,submittingStepVirtualPrinters:`Running virtual-printer setup checks`,submittingStepLogScan:`Scanning recent logs for known issues`,submittingStepSubmit:`Submitting report to GitHub`,submitSuccess:`Bug report submitted successfully!`,submitFailed:`Failed to submit bug report`,diagnosticChecking:`Checking printer connections...`,diagnosticHealthy:`Connection check passed — no problems found on your printers.`,diagnosticSummary:`{{problems}} of {{total}} printers have connection issues`,diagnosticIntro:`One or more printers have a connection problem that may be causing your issue. Expand a printer below to see the fix — resolving it could solve the problem without a bug report. You can still submit a report below.`,logHealthSummary:`Known issues found in your logs`,logHealthIntro:`Recent logs match known problems. Check the fixes below — resolving them could solve your issue without a bug report. You can still submit a report below.`,thankYou:`Thank you!`,submitted:`Your bug report has been submitted.`,viewIssue:`View Issue`,unexpectedError:`An unexpected error occurred`},failureDetection:{title:`AI Failure Detection`,description:`Monitor prints with a self-hosted Obico ML API and act on detected failures automatically.`,mlUrl:`Obico ML API URL`,mlUrlHint:`Base URL of your self-hosted Obico ml_api container (e.g. http://192.168.1.10:3333).`,test:`Test`,testSuccess:`ML API reachable and healthy.`,testFailed:`Could not reach the ML API.`,sensitivity:`Sensitivity`,sensitivityLow:`Low (fewer false positives)`,sensitivityMedium:`Medium (balanced)`,sensitivityHigh:`High (detect early, more false positives)`,sensitivityHint:`Adjusts the confidence thresholds that trigger warnings and failures.`,action:`Action on detected failure`,actionNotify:`Notify only`,actionPause:`Pause print`,actionPauseOff:`Pause and cut power`,pollInterval:`Poll interval (seconds)`,pollIntervalHint:`How often to check each printer while it is printing. Minimum 5s, maximum 120s.`,externalUrlMissing:`External URL is not set.`,externalUrlHint:`The ML API fetches the camera snapshot by URL. Set the External URL in General settings so the ML API container can reach Bambuddy.`,perPrinterTitle:`Monitored Printers`,perPrinterHint:`Choose which printers the detection service watches.`,monitorAll:`Monitor all connected printers`,statusTitle:`Status`,serviceRunning:`Service running`,thresholds:`Low / High thresholds`,activePrinters:`Active prints`,noActivePrints:`No prints currently running.`,historyTitle:`Recent Detections`,noHistory:`No detections yet.`},makerworld:{title:`MakerWorld`,description:`Paste a MakerWorld model URL to import and print it directly from Bambuddy — without leaving for the Bambu Handy app.`,pasteUrlHeader:`Import from MakerWorld`,pasteUrlPlaceholder:`https://makerworld.com/en/models/… or paste any MakerWorld link`,resolveButton:`Resolve`,signInRequiredTitle:`Bambu Cloud sign-in required to download`,signInRequiredBody:`You can browse model details anonymously, but MakerWorld requires a Bambu Cloud account to download 3MF files.`,openCloudSettings:`Open Cloud settings`,untitledModel:`Untitled model`,byCreator:`by {{name}}`,downloadsCount:`{{count}} downloads`,licensePrefix:`License`,alreadyImported:`Already in library`,openOnMakerworld:`Open on MakerWorld`,alreadyInLibrary:`This model is already in your library — find it in File Manager → MakerWorld`,importSuccess:`Imported {{filename}} — saved to File Manager → MakerWorld`,platesHeader:`Plates ({{count}})`,plateDefaultName:`Plate {{n}}`,materialCount:`{{count}} filaments`,amsRequired:`AMS required`,slicedFor:`Sliced for {{printer}}`,alsoCompatible:`Also marked compatible: {{printers}}`,importToLibrary:`Save`,sliceIn:`Save & Slice in {{slicer}}`,disclaimer:`MakerWorld integration uses community-documented API endpoints. Bambuddy is not affiliated with or endorsed by MakerWorld or Bambu Lab.`,lastImportSuccess:`Imported to your library`,lastImportAlreadyInLibrary:`Already in your library`,viewInLibrary:`View in File Manager`,openInBambuStudio:`Open in Bambu Studio`,openInOrcaSlicer:`Open in OrcaSlicer`,importTo:`Import to file manager`,recentImportsHeader:`Recent imports`,phaseResolving:`Resolving`,phaseDownloading:`Downloading`,folderAuto:`MakerWorld (default)`,importAll:`Import all`,importAllProgress:`Importing {{current}}/{{total}}`,openGallery:`Open image gallery`,galleryPrev:`Previous image`,galleryNext:`Next image`,deleteImport:`Remove from library`,importDeleting:`Removing…`,importDeleted:`Removed from library`,confirmDelete:`Remove {{filename}} from the library? This deletes the local file but the plate can be re-imported from MakerWorld.`,errors:{resolveFailed:`Could not resolve that MakerWorld URL.`,downloadFailed:`Download failed. Please try again.`,deleteFailed:`Could not remove the file from the library.`}},gcodeViewer:{back:`Back`,backToArchives:`Back to Print Archives`,backToFiles:`Back to File Manager`},libraryTrash:{title:`Trash`,headerButton:`Trash`,headerTooltip:`View files moved to the trash`,backToFiles:`Back to File Manager`,subtitleAdmin:`Deleted files stay here for {{days}} days, then auto-delete. This view shows trashed files for all users.`,subtitleUser:`Deleted files stay here for {{days}} days, then auto-delete.`,loading:`Loading trash…`,loadError:`Could not load the trash.`,empty:`The trash is empty.`,summary:`{{count}} files · {{size}}`,emptyTrash:`Empty trash`,restore:`Restore`,purgeNow:`Delete now`,autoPurgeIn:`Auto-deletes in {{when}}`,days:`days`,retentionLabel:`Auto-delete after`,selectAll:`Select all`,selectOne:`Select {{filename}}`,selectionCount:`{{count}} selected`,bulkRestore:`Restore selected`,bulkPurge:`Delete selected`,col:{filename:`File`,folder:`Folder`,size:`Size`,deleted:`Moved to trash`,autoPurge:`Auto-deletes`,owner:`Owner`,actions:`Actions`},confirm:{purgeTitle:`Delete permanently?`,purgeBody:`{{filename}} will be deleted from disk and cannot be restored.`,emptyTitle:`Empty the trash?`,emptyBody:`All {{count}} files will be deleted from disk. This cannot be undone.`,bulkPurgeTitle:`Delete selected files permanently?`,bulkPurgeBody:`The {{count}} selected files will be deleted from disk and cannot be restored.`,cta:`Delete permanently`},toast:{restored:`File restored.`,restoreFailed:`Could not restore the file.`,purged:`File deleted permanently.`,purgeFailed:`Could not delete the file.`,emptied:`Deleted {{count}} file(s) from trash.`,emptyFailed:`Could not empty the trash.`,retentionSaved:`Auto-delete set to {{days}} days.`,retentionFailed:`Could not save retention setting.`,bulkRestored:`Restored {{count}} file(s).`,bulkPurged:`Deleted {{count}} file(s).`}},libraryPurge:{title:`Purge old files`,headerButton:`Purge old`,headerTooltip:`Bulk-move old files to trash`,description:`Sweep old files out of your library in one shot. Files with a print history are aged by their last-printed date; files that were never printed are aged by their upload date.`,ageLabel:`Move files older than`,days:`days`,includeNeverPrinted:`Include files that have never been printed`,effectsTitle:`What happens when you click Purge`,effect1:`Matching files are moved to Trash — they are not deleted from disk yet.`,effect2:`You can restore them from Trash at any time until the retention window expires.`,effect3:`After retention, the trash sweeper permanently removes them from disk.`,effect4:`Files in external (linked) folders are skipped — Bambuddy never deletes bytes it does not own.`,previewLoading:`Checking how many files match…`,previewFailed:`Could not preview the purge.`,previewSummary:`{{count}} files · {{size}} would move to trash`,andMore:`…and {{count}} more`,warning:`Trashed files still count against storage until the retention window expires. Empty the Trash afterwards to free disk immediately.`,confirmCta:`Move {{count}} to trash`,purging:`Moving to trash…`,toast:{success:`Moved {{count}} file(s) to trash.`,failed:`Could not purge files.`}},libraryAutoPurge:{enableLabel:`Auto-purge old files`,enableDescription:`Runs the admin purge once per day. Files go to Trash first — they are not deleted immediately.`,ageLabel:`Auto-purge files older than`,ageDescription:`Minimum 7 days, maximum 10 years. Uses the same age rule as the manual Purge button.`,days:`days`,includeNeverPrinted:`Include files that have never been printed`,saveFailed:`Could not save auto-purge settings.`},archivePurge:{headerButton:`Purge old`,headerTooltip:`Bulk-delete old archives`,title:`Purge old archives`,description:`Clear out old print history. Each archive is aged by its most recent print completion — reprinting an archive refreshes its age, so active work is never purged.`,ageLabel:`Delete archives not printed in the last`,days:`days`,effectsTitle:`What happens when you click Purge`,effect1:`Each matching archive is hidden from the listings and its files are removed from disk (3MF, thumbnail, timelapse, source 3MF, F3D design file, photos).`,effect2:`The archive row stays in the database so Quick Stats keeps the filament, time, cost, and energy contribution — same as the single-archive delete default.`,effect3:`Tick "Also remove from statistics" below to drop the Quick Stats contribution too (matches the single-archive delete option). That path is irreversible.`,effect4:`Reprinting an archive refreshes its age clock, so archives you still use are safe.`,purgeStatsLabel:`Also remove from statistics`,purgeStatsHint:`Drops the matching archives from Quick Stats (filament, time, cost, energy). Without this, Quick Stats keeps every contribution and only the files leave disk.`,previewLoading:`Checking how many archives match…`,previewFailed:`Could not preview the purge.`,previewSummary:`{{count}} archives · {{size}} would be removed`,andMore:`…and {{count}} more`,warning:`Files are removed from disk and cannot be restored. Download or favourite anything you want to keep before continuing.`,confirmCta:`Remove {{count}} archive(s)`,purging:`Removing…`,toast:{success:`Removed {{count}} archive(s).`,failed:`Could not purge archives.`}},archiveAutoPurge:{enableLabel:`Auto-purge old archives`,enableDescription:`Once per day, hides archives from the listings and removes their files from disk when they have not been printed within the threshold. Reprinting an archive resets the clock.`,ageLabel:`Auto-delete archives not printed in the last`,ageDescription:`Minimum 7 days, maximum 10 years. Based on the most recent print completion — reprinting an archive refreshes its age. Removes the 3MF, thumbnail, timelapse, source 3MF, F3D, and photos.`,days:`days`,purgeStatsLabel:`Also remove from statistics`,purgeStatsDescription:`When enabled, the daily sweeper also drops each purged archive from Quick Stats (filament, time, cost, energy). Default off — Quick Stats keeps the contribution, only the files leave disk.`,runNow:`Purge archives now`,saveFailed:`Could not save auto-purge settings.`},cameraTokens:{title:`Camera API Tokens`,navTitle:`Camera API tokens`,description:`Long-lived tokens for embedding the camera stream into Home Assistant, Frigate, kiosks, or any other tool that needs a stable URL. Each token is camera-stream-only and can be revoked at any time.`,loading:`Loading…`,confirmRevoke:{title:`Revoke this token?`,body:`Any device using "{{name}}" will lose access immediately. This cannot be undone.`,cancel:`Cancel`,confirm:`Revoke`},create:{title:`Create new token`,nameLabel:`Token name`,namePlaceholder:`e.g. Home Assistant`,daysLabel:`Days until expiry`,submit:`Create`,hint:`Maximum lifetime is 365 days. The token value is shown only once on creation — copy it now.`},created:{title:`Token created — copy it now`,warning:`This is the only time this token will be visible. After you close this dialog you can never view it again.`,copy:`Copy`,dismiss:`I've saved it`},list:{myTitle:`My tokens`,allTitle:`All users (admin view)`,empty:`No tokens yet.`,name:`Name`,owner:`Owner`,prefix:`Prefix`,created:`Created`,expires:`Expires`,lastUsed:`Last used`,revoke:`Revoke`,expired:`Expired`},toast:{created:`Token created`,createFailed:`Failed to create token`,revoked:`Token revoked`,revokeFailed:`Failed to revoke token`,loadFailed:`Failed to load tokens`,copied:`Copied to clipboard`,copyFailed:`Copy failed — select and copy manually`}},forecast:{title:`Forecast`,noSpools:`No active spools found. Add spools to your inventory to see forecast data.`,noUsageData:`No usage data available — cannot project stock timeline.`,sku:`SKU`,material:`Material`,stock:`Stock`,dailyRate:`Rate`,daysLeft:`Days Left`,emptyBy:`Empty By`,reorderBy:`Reorder By`,actions:`Actions`,trend:`Trend`,estimated:`Est.`,noData:`No data`,timeframe:`Timeframe`,chartTitle:`Projected Stock — Top 5 Materials`,dashedLinesROP:`Dashed lines = reorder points`,stockLevel:`Stock Level`,reorderPoint:`Reorder Point`,safetyMargin:`Safety Margin`,trendLegend:`Trend (history-based, 95% service level)`,estimatedLegend:`Estimated (weight delta)`,noDataLegend:`No data`,ropLabel:`ROP`,ssLabel:`SS`,safetyStockLegend:`Safety stock`,stockArrivalLegend:`Stock arrival`,stockoutLegend:`Stockout`,alertCount_one:`{{count}} alert`,alertCount_other:`{{count}} alerts`,order:`Order`,save:`Save`,cancel:`Cancel`,settingsSaved:`Settings saved`,failedSaveSettings:`Failed to save settings`,globalLeadTimeSaved:`Global lead time saved`,globalLeadTime:`Global lead time`,globalLeadTimeHint:`Global lead time floor — used in reorder point calculation for all SKUs`,skuLeadTimeOverride:`Lead Time Override`,skuLeadTimeHint:`0 = use global lead time. Set >0 to override for this SKU.`,safetyMarginLabel:`Safety Margin`,effectiveLeadTime:`Effective Lead Time`,effectiveLeadTimeHint:`max(global {{global}}d, SKU {{sku}}d)`,reorderPointHint:`d̄ × LT + safety margin — order when stock hits this level`,safetyMarginHint:`Statistical safety stock (z=1.65 × σ × √LT) + user-defined buffer`,safetyMarginHintDays:`Buffer added on top of statistical safety stock.{{approx}}`,safetyMarginHintDaysApprox:` ≈ {{g}}g at current rate.`,safetyMarginHintG:`Fixed weight buffer added on top of statistical safety stock.{{approx}}`,safetyMarginHintGApprox:` ≈ {{days}}d at current rate.`,individualSpools:`Individual spools`,labelWeight:`Label`,spoolCount_one:`{{count}} spool`,spoolCount_other:`{{count}} spools`,stockBreakRisk:`Stock break risk`,stockBreakDetail:`{{days}}d remaining, lead time {{lt}}d.`,stockBreakBefore:`Stock break before replenishment`,reorderNow:`Reorder now`,reorderTriggerPassed:`Trigger date {{date}} has passed.`,shoppingList:`Shopping List`,shoppingListItems_one:`({{count}} item)`,shoppingListItems_other:`({{count}} items)`,shoppingListEmpty:`Shopping list is empty. Click the cart icon on any row to add items.`,addToCart:`Add to shopping list`,alertsSnoozed:`Mute alerts for this SKU`,alertsEnabled:`Unmute alerts for this SKU`,addedToCart:`Added to shopping list`,failedAddItem:`Failed to add item`,listView:`List`,logisticsView:`Logistics`,qty:`Qty`,weight:`Weight`,leadTime:`Lead Time`,expectedRestock:`Expected Restock`,status:`Status`,note:`Note`,pending:`Pending`,purchased:`Purchased`,received:`Received`,markPurchased:`Mark as purchased`,markReceived:`Mark as received — adds spools to Stock inventory`,resetToPending:`Reset to pending`,remove:`Remove`,clearAll:`Clear all`,downloadCsv:`CSV`,addToCartTitle:`Add to Shopping List`,byQuantity:`By Quantity`,byDuration:`By Duration`,numberOfSpools:`Number of spools`,lastHowManyDays:`Should last how many days?`,noUsageQty:`No usage data — quantity set to 1.`,noteOptional:`Note (optional)`,notePlaceholder:`e.g. for project X, urgent…`,addNSpools_one:`Add {{count}} spool`,addNSpools_other:`Add {{count}} spools`,onArrival:`On Arrival`,stockBreakIn:`Stock break in {{days}}d.`,stockRunsOutBefore:`Stock runs out before the {{lt}}d lead time elapses.`,atRate:`At {{rate}}g/day you need`,moreSpools_one:`{{count}} more spool`,moreSpools_other:`{{count}} more spools`,bridgeGap:`to bridge the gap.`,noReadAccess:`You do not have permission to view inventory forecasts.`,noWriteAccess:`You do not have permission to modify forecast settings.`}}},de:{translation:{nav:{printers:`Drucker`,archives:`Archiv`,queue:`Druckwarteschlange`,stats:`Statistiken`,profiles:`Profile`,maintenance:`Wartung`,projects:`Projekte`,inventory:`Filament`,files:`Dateimanager`,makerworld:`MakerWorld`,notifications:`Benachrichtigungen`,settings:`Einstellungen`,system:`System`,collapseSidebar:`Seitenleiste einklappen`,expandSidebar:`Seitenleiste ausklappen`,update:`Aktualisieren`,updateAvailable:`Update verfügbar: v{{version}}`,updateAvailableBanner:`Version {{version}} ist verfügbar!`,viewUpdate:`Update anzeigen`,viewOnGithub:`Auf GitHub ansehen`,keyboardShortcuts:`Tastaturkürzel (?)`,switchToLight:`Zum hellen Modus wechseln`,switchToDark:`Zum dunklen Modus wechseln`,switchToSystem:`Zum Systemmodus wechseln`,smartSwitches:`Smart Switches`,logout:`Abmelden`,installApp:`App installieren`,installAppSuccess:`Bambuddy wurde installiert`},common:{save:`Speichern`,saving:`Speichern...`,cancel:`Abbrechen`,delete:`Löschen`,edit:`Bearbeiten`,add:`Hinzufügen`,close:`Schließen`,confirm:`Bestätigen`,loading:`Lädt...`,error:`Fehler`,errorLoading:`Fehler beim Laden`,retry:`Erneut versuchen`,success:`Erfolg`,warning:`Warnung`,enabled:`Aktiviert`,disabled:`Deaktiviert`,yes:`Ja`,no:`Nein`,on:`An`,off:`Aus`,all:`Alle`,none:`Keine`,search:`Suchen`,filter:`Filtern`,sort:`Sortieren`,refresh:`Aktualisieren`,download:`Herunterladen`,upload:`Hochladen`,uploading:`Hochladen...`,uploadFailed:`Hochladen fehlgeschlagen`,actions:`Aktionen`,status:`Status`,name:`Name`,description:`Beschreibung`,date:`Datum`,time:`Zeit`,hours:`Stunden`,minutes:`Minuten`,seconds:`Sekunden`,days:`Tage`,enable:`Aktivieren`,disable:`Deaktivieren`,permissions:`Berechtigungen`,noPrinters:`Keine Drucker konfiguriert`,noData:`Keine Daten verfügbar`,linkNotFound:`Link nicht gefunden`,required:`Erforderlich`,optional:`Optional`,dismiss:`Schließen`,apply:`Anwenden`,reset:`Zurücksetzen`,export:`Exportieren`,import:`Importieren`,clear:`Leeren`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,noChange:`— Keine Änderung —`,unchanged:`Unverändert`,unassigned:`Nicht zugewiesen`,unknown:`Unbekannt`,unknownError:`Unbekannter Fehler`,today:`Heute`,tomorrow:`Morgen`,asap:`Sofort`,overdue:`Überfällig`,now:`Jetzt`,collapse:`Einklappen`,expand:`Ausklappen`,viewArchive:`Archiv anzeigen`,viewInFileManager:`Im Dateimanager anzeigen`,addedBy:`Hinzugefügt von {{username}}`,prints:`Drucke`,more:`+{{count}} weitere`,ascending:`Aufsteigend`,descending:`Absteigend`,back:`Zurück`,copy:`Kopieren`,copied:`Kopiert!`,printer:`Drucker`,remove:`Entfernen`,type:`Typ`,print:`Drucken`,rename:`Umbenennen`,move:`Verschieben`,create:`Erstellen`,duplicate:`Duplizieren`,left:`Links`,right:`Rechts`},printers:{addPreflight:{checking:`Verbindung wird geprüft...`,warning:`Einige Verbindungsprüfungen sind fehlgeschlagen. Dieser Drucker wird möglicherweise als offline angezeigt. Prüfe die Punkte unten, behebe was möglich ist, oder speichere trotzdem.`,back:`Zurück`,saveAnyway:`Trotzdem speichern`},title:`Drucker`,addPrinter:`Drucker hinzufügen`,editPrinter:`Drucker bearbeiten`,deletePrinter:`Drucker löschen`,printerName:`Druckername`,serialNumber:`Seriennummer`,ipAddress:`IP-Adresse / Hostname`,accessCode:`Zugangscode`,model:`Modell`,nozzleCount:`Düsenanzahl`,autoArchive:`Automatische Archivierung`,status:{available:`Verfügbar`,idle:`Bereit`,printing:`Druckt`,paused:`Pausiert`,offline:`Offline`,problem:`Problem`,error:`Fehler`,finished:`Fertig`,unknown:`Unbekannt`},temperatures:{nozzle:`Düse`,bed:`Druckbett`,chamber:`Kammer`},heaterHistory:{title:`Heizungsverlauf`,openLabel:`Heizungsverlauf anzeigen`,nozzle:`Düse`,nozzle2:`Düse 2`,bed:`Druckbett`,chamber:`Kammer`,error:`Verlauf konnte nicht geladen werden`,empty:`Noch keine Daten aufgezeichnet`},progress:`{{percent}}% abgeschlossen`,timeRemaining:`Noch {{time}}`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,maintenanceOk:`Wartung OK`,maintenanceWarning:`{{count}} Warnung`,maintenanceWarning_plural:`{{count}} Warnungen`,maintenanceDue:`{{count}} fällig`,maintenanceDue_plural:`{{count}} fällig`,sort:{name:`Name`,status:`Status`,model:`Modell`,location:`Standort`,eta:`Restzeit`,ascending:`Aufsteigend sortieren`,descending:`Absteigend sortieren`},cardSize:{small:`Kleine Karten`,medium:`Mittlere Karten`,large:`Große Karten`,extraLarge:`Extra große Karten`},hideOffline:`Offline ausblenden`,nextAvailable:`Nächster verfügbar`,powerOn:`Einschalten`,offlinePrintersWithPlugs:`Offline-Drucker mit Smart-Plugs`,noPrintersConfigured:`Noch keine Drucker konfiguriert`,search:`Drucker suchen...`,noSearchResults:`Keine Drucker entsprechen deiner Suche oder deinen Filtern`,filter:{allStatuses:`Alle Status`,allLocations:`Alle Standorte`},toolbar:{filters:`Filter`,view:`Ansicht`,actions:`Aktionen`},readyToPrint:`Druckbereit`,external:`Extern`,extL:`Ext-L`,extR:`Ext-R`,deleteArchives:`Druckarchive löschen`,noLabel:`Keine Bezeichnung`,printPreview:`Druckvorschau`,width:`Breite`,height:`Höhe`,noObjectsFound:`Keine Objekte gefunden`,objectsLoadedOnPrintStart:`Objekte werden beim Druckstart geladen`,willBeSkipped:`Wird übersprungen`,name:`Name`,serialCannotBeChanged:`Seriennummer kann nicht geändert werden`,locationHelp:`Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen`,wifiSignal:{veryWeak:`Sehr schwach`,weak:`Schwach`,fair:`Ausreichend`,good:`Gut`,excellent:`Ausgezeichnet`},maintenanceUpToDate:`Alle Wartungen aktuell - Klicken zum Anzeigen`,maintenance:{title:`In Wartung`,subtitle:`Dieser Drucker ist pausiert — keine Verbindung, nicht für die Warteschlange verfügbar, keine Benachrichtigungen.`,pillLabel:`Wartung`,exitButton:`Wartung beenden`,menuEnter:`In den Wartungsmodus wechseln`,menuExit:`Wartungsmodus beenden`,toastEntered:`{{name}} ist jetzt im Wartungsmodus`,toastExited:`{{name}} ist wieder online`,confirmMidPrintTitle:`Wartungsmodus während des Drucks aktivieren?`,confirmMidPrintMessage:`{{name}} druckt gerade. Der Wartungsmodus trennt die MQTT-Verbindung und beendet das Fortschritts-Tracking sowie Abschlussbenachrichtigungen für diesen Auftrag. Fortfahren?`,editFieldLabel:`Wartungsmodus`,editFieldHelp:`Wenn aktiviert, ist dieser Drucker von MQTT, Warteschlangenversand und Benachrichtigungen pausiert — nützlich für Reparaturen, parallele Bambuddy-Installationen oder temporäre Außerbetriebnahme.`},chamberLightOn:`Kammerbeleuchtung einschalten`,chamberLightOff:`Kammerbeleuchtung ausschalten`,files:`Dateien`,browseFiles:`Druckerdateien durchsuchen`,autoOffAfterPrint:`Automatisches Ausschalten nach Druck`,autoOffExecuted:`Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen`,hmsErrors:`HMS-Fehler`,viewHmsErrors:`{{count}} HMS-Fehler anzeigen`,resume:`Fortsetzen`,pause:`Pausieren`,stop:`Stoppen`,camera:`Kamera`,skipObject:`Objekt überspringen`,reconnect:`Neu verbinden`,forceRefresh:`Aktualisierung erzwingen`,forceRefreshSuccess:`Aktualisierung angefordert`,mqttDebug:`MQTT-Debug`,printerInformation:`Druckerinformationen`,copyToClipboard:`Kopieren`,copied:`Kopiert!`,state:`Zustand`,wifiSignalLabel:`WLAN-Signal`,developerMode:`Entwicklermodus`,enabled:`Aktiviert`,disabled:`Deaktiviert`,addedOn:`Hinzugefügt`,sdCard:`SD-Karte`,inserted:`Eingelegt`,notInserted:`Nicht eingelegt`,totalPrintHours:`Druckstunden`,activeNozzle:`Aktiv: {{nozzle}} Düse`,nozzleRack:`Düsenhalter`,nozzleDocked:`Angedockt`,nozzleMounted:`Montiert`,nozzleActive:`Aktiv`,nozzleIdle:`Inaktiv`,nozzleDiameter:`Durchmesser`,nozzleType:`Typ`,nozzleStatus:`Status`,nozzleFilament:`Filament`,nozzleWear:`Verschleiß`,nozzleMaxTemp:`Max. Temp`,nozzleSerial:`Seriennr.`,nozzleHardenedSteel:`Gehärteter Stahl`,nozzleStainlessSteel:`Edelstahl`,nozzleTungstenCarbide:`Wolframkarbid`,nozzleFlow:`Durchfluss`,nozzleHighFlow:`Hoher Durchfluss`,nozzleStandardFlow:`Standard`,firmwareUpdate:`Firmware-Update`,firmwareInstructions:`Gehen Sie auf dem Touchscreen des Druckers zu`,firmwareNav:`Navigieren Sie zu`,settings:`Einstellungen`,firmware:`Firmware`,discoverPrinters:`Drucker entdecken`,searching:`Suche...`,manualEntry:`Manuelle Eingabe`,addFromCloud:`Aus Cloud hinzufügen`,toast:{printerDeleted:`Drucker gelöscht`,missingSpoolAssignment:`Druck gestartet auf {{printer}}. Fehlende Spulenzuordnung für: {{slots}}`,printerAdded:`Drucker hinzugefügt`,printerUpdated:`Drucker aktualisiert`,failedToDelete:`Drucker konnte nicht gelöscht werden`,failedToAdd:`Drucker konnte nicht hinzugefügt werden`,connectionFailedNotAdded:`Keine Verbindung zum Drucker möglich. Prüfen Sie IP-Adresse, Seriennummer und Zugangscode und stellen Sie sicher, dass der Nur-LAN-Modus aktiv ist. Der Drucker wurde nicht hinzugefügt.`,failedToUpdate:`Drucker konnte nicht aktualisiert werden`,commandSent:`Befehl gesendet`,failedToSendCommand:`Befehl konnte nicht gesendet werden`,turnedOn:`{{name}} eingeschaltet`,failedToPowerOn:`{{name}} konnte nicht eingeschaltet werden`,scriptTriggered:`Skript ausgelöst`,printStopped:`Druck gestoppt`,printPaused:`Druck pausiert`,printResumed:`Druck fortgesetzt`,referenceDeleted:`Referenz gelöscht`,detectionAreaSaved:`Erkennungsbereich gespeichert`,failedToRunScript:`Skript konnte nicht ausgeführt werden`,failedToStopPrint:`Druck konnte nicht gestoppt werden`,failedToPausePrint:`Druck konnte nicht pausiert werden`,failedToResumePrint:`Druck konnte nicht fortgesetzt werden`,failedToControlChamberLight:`Kammerbeleuchtung konnte nicht gesteuert werden`,failedToSetSpeed:`Druckgeschwindigkeit konnte nicht eingestellt werden`,failedToUpdateSetting:`Einstellung konnte nicht aktualisiert werden`,failedToSkipObjects:`Objekte konnten nicht übersprungen werden`,failedToRereadRfid:`RFID konnte nicht erneut gelesen werden`,failedToCheckPlate:`Platte konnte nicht überprüft werden`,failedToUpdateLabel:`Bezeichnung konnte nicht aktualisiert werden`,failedToDeleteReference:`Referenz konnte nicht gelöscht werden`,failedToSaveDetectionArea:`Erkennungsbereich konnte nicht gespeichert werden`,plateCheckEnabled:`Plattenprüfung aktiviert`,plateCheckDisabled:`Plattenprüfung deaktiviert`,calibrationSaved:`Kalibrierung gespeichert!`,calibrationFailed:`Kalibrierung fehlgeschlagen`,rfidRereadInitiated:`RFID-Neueinlesen gestartet`,loadInitiated:`Filament wird geladen…`,unloadInitiated:`Filament wird entladen…`,failedToLoad:`Filament konnte nicht geladen werden`,failedToUnload:`Filament konnte nicht entladen werden`},connection:{connected:`Verbunden`,offline:`Offline`},plateStatus:{markCleared:`Platte als freigegeben markieren`,cleared:`Platte freigegeben`,notCleared:`Platte nicht freigegeben`,inUse:`Platte in Benutzung`},queue:{inQueue:`{{count}} Druck in Warteschlange`,inQueue_plural:`{{count}} Drucke in Warteschlange`},controls:`Steuerung`,rfid:{reread:`RFID neu lesen`},ams:{load:`Laden`,unload:`Entladen`},bedJog:{title:`Jog-Steuerung`,bed:`Bett`,step:`Schritt (mm)`,up:`Platte hoch`,down:`Platte runter`,disabledWhilePrinting:`Während des Drucks deaktiviert`,notHomedTitle:`Drucker ist nicht referenziert`,notHomedMessage:`Der Drucker wurde seit dem letzten Druck nicht referenziert. Führen Sie zuerst die automatische Referenzfahrt aus (parkt den Werkzeugkopf und referenziert dann X, Y und Z) oder bewegen Sie trotzdem — die Software-Endschalter werden dabei umgangen.`,homeZ:`Automatische Referenzfahrt`,moveAnyway:`Trotzdem bewegen`,homingStarted:`Drucker wird automatisch referenziert…`},permission:{noAdd:`Sie haben keine Berechtigung, Drucker hinzuzufügen`,noEdit:`Sie haben keine Berechtigung, Drucker zu bearbeiten`,noDelete:`Sie haben keine Berechtigung, Drucker zu löschen`,noControl:`Sie haben keine Berechtigung, Drucker zu steuern`,noFiles:`Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen`,noAmsRfid:`Sie haben keine Berechtigung, AMS-RFID erneut zu lesen`,noSmartPlugControl:`Sie haben keine Berechtigung, Smart Plugs zu steuern`,noCamera:`Sie haben keine Berechtigung, Kameras anzuzeigen`},modal:{addTitle:`Drucker hinzufügen`,editTitle:`Drucker bearbeiten`,myPrinter:`Mein Drucker`,selectModel:`Modell auswählen...`,locationGroup:`Standort / Gruppe (optional)`,locationPlaceholder:`z.B. Werkstatt, Büro, Keller`,autoArchiveLabel:`Abgeschlossene Drucke automatisch archivieren`,fromPrinterSettings:`Aus Druckereinstellungen`,modelOptional:`Modell (optional)`,saveChanges:`Änderungen speichern`},skipObjects:{tooltip:`Objekte überspringen`,onlyWhilePrinting:`Objekte überspringen (nur während des Drucks)`,requiresMultiple:`Objekte überspringen (erfordert 2+ Objekte)`,title:`Objekte überspringen`,matchIdsInfo:`IDs mit Drucker-Display abgleichen`,printerShowsIds:`Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte`,skipSelected:`Ausgewählte überspringen`,skipping:`Überspringe...`,noObjectsSelected:`Keine Objekte ausgewählt`,selectObjectsToSkip:`Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten`,skipped:`übersprungen`,objectsSkipped:`Objekte übersprungen`,activeCount:`{{count}} aktiv`,waitForLayer:`Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})`,skip:`Überspringen`,confirmTitle:`Objekt überspringen?`,confirmMessage:`Möchten Sie "{{name}}" wirklich überspringen? Dies kann nicht rückgängig gemacht werden.`},confirm:{deleteTitle:`Drucker löschen`,deleteMessage:`Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.`,deleteArchivesNote:`Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.`,keepArchivesNote:`Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.`,stopTitle:`Druck stoppen`,stopMessage:`Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.`,stopButton:`Druck stoppen`,pauseTitle:`Druck pausieren`,pauseMessage:`Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?`,pauseButton:`Druck pausieren`,resumeTitle:`Druck fortsetzen`,resumeMessage:`Möchten Sie den Druck auf "{{name}}" fortsetzen?`,resumeButton:`Druck fortsetzen`,powerOnTitle:`Drucker einschalten`,powerOnMessage:`Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?`,powerOnButton:`Einschalten`,powerOffTitle:`Drucker ausschalten`,powerOffMessage:`Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?`,powerOffWarning:`WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.`,powerOffButton:`Ausschalten`,haToggleTitle:`"{{name}}" umschalten`,haToggleMessage:`Home-Assistant-Entität {{entity}} umschalten? Das kann die Stromversorgung ausschalten, falls sie gerade an ist.`,haToggleWarning:`WARNUNG: "{{name}}" druckt gerade! Umschalten von {{entity}} kann die Stromversorgung trennen und den Druck abbrechen. Fortfahren?`,haToggleButton:`Umschalten`},bulk:{select:`Auswählen`,selectAll:`Alle auswählen`,selectByLocation:`Nach Standort auswählen`,selected:`{{count}} ausgewählt`,actions:{stop:`Stoppen`,pause:`Pausieren`,resume:`Fortsetzen`,clearPlate:`Druckbett leeren`,clearHMS:`Benachrichtigungen löschen`},confirm:{stopTitle:`{{count}} Drucke stoppen`,stopMessage:`Dies wird aktive Drucke auf {{count}} Drucker(n) abbrechen. Diese Aktion kann nicht rückgängig gemacht werden.`,stopButton:`Alle stoppen`,pauseTitle:`{{count}} Drucke pausieren`,pauseMessage:`Dies wird aktive Drucke auf {{count}} Drucker(n) pausieren.`,pauseButton:`Alle pausieren`,clearPlateTitle:`{{count}} Druckbetten leeren`,clearPlateMessage:`Dies wird das Druckbett auf {{count}} Drucker(n) leeren und kann wartende Aufträge starten.`,clearPlateButton:`Alle leeren`},success:`{{action}} auf {{count}} Drucker(n) abgeschlossen`,partial:`{{succeeded}} erfolgreich, {{failed}} fehlgeschlagen`,noneApplicable:`Keine ausgewählten Drucker sind im richtigen Zustand für diese Aktion`,selectByState:`Nach Status auswählen`},discovery:{title:`Drucker entdecken`,searching:`Suche...`,scanning:`Scanne...`,scanProgress:`Scanne... {{scanned}}/{{total}}`,foundPrinters:`{{count}} Drucker gefunden`,noPrintersFound:`Keine Drucker gefunden`,noPrintersFoundSubnet:`Keine Drucker im angegebenen Subnetz gefunden.`,noPrintersFoundNetwork:`Keine Drucker im Netzwerk gefunden.`,allConfigured:`Alle erkannten Drucker sind bereits konfiguriert.`,alreadyAdded:`Bereits hinzugefügt`,select:`Auswählen`,manualEntry:`Manuelle Eingabe`,addFromCloud:`Aus Cloud hinzufügen`,subnetToScan:`Zu scannendes Subnetz`,dockerNote:`Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.`,scanSubnet:`Subnetz nach Druckern scannen`,discoverNetwork:`Drucker im Netzwerk suchen`,scanningSubnet:`Subnetz wird nach Bambu-Druckern gescannt...`,scanningNetwork:`Netzwerk wird gescannt...`,serialRequired:`Seriennummer erforderlich`,unknown:`Unbekannt`,failedToStart:`Erkennung konnte nicht gestartet werden`,customSubnetOption:`Eigenes Subnetz...`,customSubnetLabel:`Eigenes Subnetz (CIDR)`,customSubnetNote:`Wähle ein eigenes Subnetz, wenn dein Drucker in einem anderen Netzwerk als dieser Server steht. Die Ports FTP (990) und MQTT (8883) müssen über die Routinggrenze erreichbar sein.`},drying:{start:`Trocknung starten`,stop:`Trocknung stoppen`,temperature:`Temperatur`,duration:`Dauer`,hours:`Stunden`,timeRemaining:`{{time}} verbleibend`,active:`Trocknung`,notSupported:`Trocknung nicht unterstützt`,powerRequired:`AMS-Netzteil anschließen, um Trocknung zu aktivieren`,startingDrying:`Trocknung wird gestartet...`,stoppingDrying:`Trocknung wird gestoppt...`,rotateTray:`Spule während der Trocknung drehen`},amsBackup:{titleOn:`AMS Filament Backup ist EIN. Zum Deaktivieren klicken.`,titleOff:`AMS Filament Backup ist AUS. Zum Aktivieren klicken.`,titleUnknown:`AMS-Filament-Backup-Status auf diesem Drucker nicht verfügbar.`,toastEnabled:`AMS Filament Backup aktiviert`,toastDisabled:`AMS Filament Backup deaktiviert`,modalTitle:`AMS Filament Backup`,modalHelp:`Wenn der aktive Slot leer wird, wechselt der Drucker in dieser Reihenfolge zu Slots mit demselben Preset und derselben Farbe.`,modalNoSlots:`Kein Filament geladen.`,modalNoPairs:`Keine Backup-Paare — keine zwei Slots teilen sich Filament-Preset und Farbe.`,extruderRightShort:`R`,extruderLeftShort:`L`,stateOn:`Aktiviert`,stateOff:`Deaktiviert`,stateUnknown:`Auf diesem Drucker nicht unterstützt`},activeJobSlot:{title:`Dieser Slot ist Filament {{n}} im aktiven Druck`,ariaLabel:`Aktiver Druck-Slot {{n}}`},filaments:`Filamente`,openCameraOverlay:`Kamera-Overlay öffnen`,openCameraWindow:`Kamera in neuem Fenster öffnen`,firmwareUpdateAvailable:`Firmware-Update verfügbar: {{current}} → {{latest}}`,firmwareUpToDate:`Firmware {{version}} — Aktuell`,firmwareUpdateButton:`Aktualisieren`,plateDetection:{noPermission:`Sie haben keine Berechtigung, Drucker zu aktualisieren`,enabledClick:`Plattenprüfung aktiviert - Klicken zum Deaktivieren`,disabledClick:`Plattenprüfung deaktiviert - Klicken zum Aktivieren`,manageCalibration:`Platten-Erkennungskalibrierung verwalten`,calibrationRequired:`Kalibrierung erforderlich`,calibrationInstructions:`Bitte stellen Sie sicher, dass die Druckplatte vollständig leer ist, und klicken Sie dann auf Kalibrieren.`,calibrationDescription:`Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.`,calibrationTip:`Tipp: Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.`,plateEmpty:`Platte erscheint leer`,objectsDetected:`Objekte auf Platte erkannt`,confidence:`Konfidenz`,difference:`Differenz`,analysisPreview:`Analysevorschau:`,analysisLegend:`Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung`,savedReferences:`Gespeicherte Referenzen ({{count}}/{{max}})`,deleteReference:`Referenz löschen`,labelPlaceholder:`Bezeichnung...`,clickToEdit:`{{label}} - Zum Bearbeiten klicken`,clickToAddLabel:`Zum Hinzufügen einer Bezeichnung klicken`},speed:{title:`Druckgeschwindigkeit`,silent:`Leise (50%)`,standard:`Standard (100%)`,sport:`Sport (124%)`,ludicrous:`Ludicrous (166%)`},airduct:{title:`Luftkanal-Modus`,cooling:`Kühlen`,heating:`Heizen`},noSdCard:`Keine SD`,door:{open:`Offen`,closed:`Zu`},fans:{partCooling:`Bauteilkühlung`,auxiliary:`Hilfsventilator`,chamber:`Kammerventilator`},clickToViewHmsErrors:`Klicken, um HMS-Fehler anzuzeigen`,estimatedCompletion:`Geschätzte Fertigstellungszeit`,plateNumber:`Platte {{number}}`,slotOptions:`Slot-Optionen`,amsPopup:{friendlyName:`AMS-Name`,friendlyNamePlaceholder:`z. B. AMS-Anzeigename`,serialNumber:`Seriennummer`,firmwareVersion:`Firmware`,save:`Speichern`,clear:`Löschen`,noEditPermission:`Sie haben keine Berechtigung, AMS-Einheiten umzubenennen`},firmwareModal:{title:`Firmware-Update`,titleUpToDate:`Firmware-Info`,currentVersion:`Aktuell:`,latestVersion:`Neueste:`,releaseNotes:`Versionshinweise`,checkingPrereqs:`Prüfe Voraussetzungen...`,sdCardReady:`SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.`,uploadedSuccess:`Firmware auf SD-Karte hochgeladen!`,applyInstructions:`So wenden Sie das Update auf Ihrem Drucker an:`,step1:`Gehen Sie auf dem Touchscreen des Druckers zu Einstellungen`,step2:`Navigieren Sie zu Firmware`,step3:`Wählen Sie Update von SD-Karte`,step4:`Das Update dauert 10-20 Minuten`,done:`Fertig`,starting:`Starte...`,uploadFirmware:`Firmware hochladen`,uploadFailed:`Upload fehlgeschlagen: {{error}}`,uploadedToast:`Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm.`,availableVersions:`Verfügbare Versionen`,usable:`Installierbar`,unavailable:`Nicht verfügbar`,installed:`Installiert`,newerBadge:`neuer`,olderBadge:`älter`,currentBadge:`aktuell`},accessCodePlaceholder:`Leer lassen, um den aktuellen zu behalten`,roi:{title:`Erkennungsbereich (ROI)`,xStart:`X-Start`,yStart:`Y-Start`,width:`Breite`,height:`Höhe`,instruction:`Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich.`},developerModeWarning:`Der Entwickler-LAN-Modus ist nicht aktiviert auf: {{names}}. Einige Funktionen funktionieren möglicherweise nicht.`,howToEnable:`Aktivieren`,incompatibleFile:`Diese Datei wurde für {{slicedFor}} geslicet, aber dieser Drucker ist ein {{printerModel}}`,dropNotPrintable:`Nur .gcode- und .gcode.3mf-Dateien können gedruckt werden`,dropToPrint:`Zum Drucken ablegen`,cannotPrint:`Drucker beschäftigt`},archives:{title:`Druckarchiv`,no3mfBanner:{title:`Einige kürzliche Drucke konnten nicht mit Vorschaubild archiviert werden`,body:`Der Slicer hat die .gcode.3mf-Datei nicht auf der SD-Karte des Druckers hinterlegt, daher konnte Bambuddy weder Vorschaubild noch Slicer-Metadaten abrufen. Üblicherweise liegt das daran, dass "Gesendete Dateien auf externem Speicher speichern" im Slicer (Geräte-Tab in Bambu Studio / OrcaSlicer) deaktiviert ist.`,docsLink:`Installationsschritt 4 anzeigen`,dismissLabel:`Hinweis schließen`},searchPlaceholder:`Archiv durchsuchen...`,filterByPrinter:`Nach Drucker filtern`,filterByStatus:`Nach Status filtern`,sortBy:`Sortieren nach`,sortNewest:`Neueste zuerst`,sortOldest:`Älteste zuerst`,sortName:`Name`,sortDuration:`Dauer`,sortLargest:`Größte zuerst`,sortSmallest:`Kleinste zuerst`,sortSize:`Größe`,noArchives:`Keine Archive gefunden`,noArchivesSearch:`Keine Archive entsprechen Ihrer Suche`,originalPrintNotVisible:`Ursprünglicher Druck nicht sichtbar - versuchen Sie, die Filter zu löschen`,noArchivesYet:`Noch keine Archive`,prints:`Drucke`,pagination:{showing:`Zeige`,to:`bis`,of:`von`,show:`Zeige`,page:`Seite`,all:`Alle`},loadingArchives:`Lade Archive...`,releaseToUpload:`Loslassen zum Hochladen`,showAll:`Alle anzeigen`,showFavoritesOnly:`Nur Favoriten anzeigen`,gridView:`Rasteransicht`,listView:`Listenansicht`,calendarView:`Kalenderansicht`,logView:`Druckprotokoll`,manageTags:`Tags verwalten`,showFailedPrints:`Fehlgeschlagene Drucke anzeigen`,hideFailedPrints:`Fehlgeschlagene Drucke ausblenden`,hideDuplicates:`Duplikate ausblenden`,viewOriginalPrint:`Klicken, um den ursprünglichen Druck anzuzeigen (#{{id}})`,printTime:`Druckzeit`,filamentUsed:`Verbrauchtes Filament`,cost:`Kosten`,reprint:`Drucken`,preview:`Vorschau`,deleteArchive:`Archiv löschen`,deleteConfirm:`Möchten Sie dieses Archiv wirklich löschen?`,favorite:`Favorit`,unfavorite:`Aus Favoriten entfernen`,viewDetails:`Details anzeigen`,status:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,stopped:`Gestoppt`},toast:{source3mfAttached:`Quell-3MF angehängt: {{filename}}`,failedUploadSource3mf:`Fehler beim Hochladen der Quell-3MF`,source3mfRemoved:`Quell-3MF entfernt`,failedRemoveSource3mf:`Fehler beim Entfernen der Quell-3MF`,f3dAttached:`F3D angehängt: {{filename}}`,failedUploadF3d:`Fehler beim Hochladen der F3D`,f3dRemoved:`F3D entfernt`,failedRemoveF3d:`Fehler beim Entfernen der F3D`,timelapseAttached:`Zeitraffer angehängt: {{filename}}`,timelapseAlreadyAttached:`Zeitraffer bereits angehängt`,noMatchingTimelapse:`Kein passender Zeitraffer gefunden`,failedScanTimelapse:`Fehler beim Suchen nach Zeitraffer`,failedAttachTimelapse:`Fehler beim Anhängen des Zeitraffers`,timelapseRemoved:`Zeitraffer entfernt`,failedRemoveTimelapse:`Fehler beim Entfernen des Zeitraffers`,timelapseUploaded:`Zeitraffer hochgeladen: {{filename}}`,failedUploadTimelapse:`Fehler beim Hochladen des Zeitraffers`,archiveDeleted:`Archiv gelöscht`,failedDeleteArchive:`Fehler beim Löschen des Archivs`,addedToFavorites:`Zu Favoriten hinzugefügt`,removedFromFavorites:`Aus Favoriten entfernt`,projectUpdated:`Projekt aktualisiert`,failedUpdateProject:`Fehler beim Aktualisieren des Projekts`,linkCopied:`Link in die Zwischenablage kopiert`,failedCopyLink:`Fehler beim Kopieren des Links`,photoDeleted:`Foto gelöscht`,failedDeletePhoto:`Fehler beim Löschen des Fotos`,failedDeleteArchives:`Fehler beim Löschen der Archive`,failedUpdateFavorites:`Fehler beim Aktualisieren der Favoriten`,exportDownloaded:`Export heruntergeladen`,exportFailed:`Export fehlgeschlagen`},menu:{print:`Drucken`,schedule:`Planen`,openInBambuStudio:`Im Slicer öffnen`,slice:`Slicen`,externalLink:`Externer Link`,viewOnMakerWorld:`Auf MakerWorld ansehen`,preview3d:`3D-Vorschau`,viewTimelapse:`Zeitraffer ansehen`,scanForTimelapse:`Nach Zeitraffer suchen`,uploadTimelapse:`Zeitraffer hochladen`,removeTimelapse:`Zeitraffer entfernen`,downloadSource3mf:`Quell-3MF herunterladen`,uploadSource3mf:`Quell-3MF hochladen`,replaceSource3mf:`Quell-3MF ersetzen`,removeSource3mf:`Quell-3MF entfernen`,uploadF3d:`F3D hochladen`,replaceF3d:`F3D ersetzen`,downloadF3d:`F3D herunterladen`,removeF3d:`F3D entfernen`,download:`Herunterladen`,copyDownloadLink:`Download-Link kopieren`,qrCode:`QR-Code`,viewPhotos:`Fotos ansehen`,viewPhotosCount:`Fotos ansehen ({{count}})`,projectPage:`Projektseite`,addToFavorites:`Zu Favoriten hinzufügen`,removeFromFavorites:`Aus Favoriten entfernen`,edit:`Bearbeiten`,printLog:`Druckprotokoll`,goToProject:`Zum Projekt: {{name}}`,addToProject:`Zu Projekt hinzufügen`,removeFromProject:`Aus Projekt entfernen`,loading:`Laden...`,noProjectsAvailable:`Keine Projekte verfügbar`,searchProjects:`Projekte suchen…`,select:`Auswählen`,deselect:`Abwählen`,delete:`Löschen`},permission:{noReprint:`Sie haben keine Berechtigung, dieses Archiv erneut zu drucken`,noAddToQueue:`Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen`,noUpdateArchives:`Sie haben keine Berechtigung, Archive zu aktualisieren`,noUploadFiles:`Sie haben keine Berechtigung, Dateien hochzuladen`,noDownload:`Sie haben keine Berechtigung, Archive herunterzuladen`,noCopyLink:`Sie haben keine Berechtigung, Download-Links zu kopieren`,noDelete:`Sie haben keine Berechtigung, dieses Archiv zu löschen`,noEdit:`Sie haben keine Berechtigung, diesen Eintrag zu bearbeiten`,noCreate:`Sie haben keine Berechtigung, Archive zu erstellen`},platePicker:{title:`Platte zur Vorschau auswählen`,hint:`Dieses Archiv enthält mehrere Platten. Wähle eine, um sie im GCode-Viewer zu öffnen.`,plateLabel:`Platte {{index}}`,objectCount:`{{count}} Objekt`,objectCount_plural:`{{count}} Objekte`,noGcode:`Dieses Archiv enthält keinen geschnittenen G-Code zur Vorschau. Öffne es zuerst in Bambu Studio zum Slicen.`},card:{previousPlate:`Vorherige Platte`,nextPlate:`Nächste Platte`,plateNumber:`Platte {{index}}`,moreOptions:`Rechtsklick für mehr Optionen`,addToFavorites:`Zu Favoriten hinzufügen`,removeFromFavorites:`Aus Favoriten entfernen`,cancelled:`abgebrochen`,failed:`fehlgeschlagen`,duplicate:`Duplikat`,duplicateTitle:`Dieses Modell wurde bereits zuvor gedruckt`,openSource3mf:`Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)`,downloadF3d:`Fusion 360 Designdatei herunterladen`,viewTimelapse:`Zeitraffer ansehen`,viewPhoto:`1 Foto ansehen`,viewPhotos:`{{count}} Fotos ansehen`,openFolder:`Ordner öffnen: {{name}}`,slicedFile:`Geslicte Datei - druckbereit`,sourceFile:`Nur Quelldatei - keine AMS-Zuordnung verfügbar`,gcode:`GCODE`,source:`QUELLE`,project:`Projekt: {{name}}`,runsBadge:`{{count}} Drucke`,runsBadgeTitle:`Insgesamt {{count}} Drucke — {{successful}} erfolgreich, {{failed}} fehlgeschlagen. Klicken, um das vollständige Druckprotokoll zu öffnen.`,estimated:`Geschätzt: {{time}}`,actual:`Tatsächlich: {{time}}`,accuracy:`Genauigkeit: {{percent}}%`,filament:`{{weight}} g`,layer:`{{count}} Schicht`,layers:`{{count}} Schichten`,object:`{{count}} Objekt`,objects:`{{count}} Objekte`,slicedFor:`Geslict für {{model}}`,uploadedBy:`Hochgeladen von`,noPermissionReprint:`Sie haben keine Berechtigung, erneut zu drucken`,noFileForReprint:`Keine 3MF-Datei verfügbar — die Datei konnte beim Aufzeichnen des Drucks nicht vom Drucker heruntergeladen werden`,noPermissionEdit:`Sie haben keine Berechtigung, Archive zu bearbeiten`,noPermissionDelete:`Sie haben keine Berechtigung, Archive zu löschen`,reprint:`Drucken`,schedulePrint:`Druck planen`,schedule:`Planen`,openInBambuStudio:`Im Slicer öffnen`,openInBambuStudioToSlice:`Im Slicer öffnen zum Slicen`,slice:`Slicen`,externalLink:`Externer Link`,makerWorld:`MakerWorld – {{designer}}`,viewProject:`Projekt ansehen`,noExternalLink:`Kein externer Link`,preview3d:`3D-Vorschau`,download:`Herunterladen`,edit:`Bearbeiten`,delete:`Löschen`},runLog:{title:`Druckprotokoll`,modalTitle:`Druckprotokoll — {{name}}`,modalTitleFallback:`dieses Archiv`,empty:`Für dieses Archiv wurden noch keine Druckereignisse aufgezeichnet.`,col:{date:`Datum`,status:`Status`,duration:`Dauer`,filament:`Filament`,cost:`Kosten`},status:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,cancelled:`Abgebrochen`,stopped:`Gestoppt`,skipped:`Übersprungen`,printing:`Druckt`}},modal:{deleteArchive:`Archiv löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleteButton:`Löschen`,deletePurgeStats:`Diesen Druck auch aus den Quick Stats entfernen (Filament, Zeit, Kosten, Energie)`,deleteQueueItemsWarning:`{{count}} mit diesem Archiv verknüpfte Warteschlangeneinträge werden ebenfalls entfernt.`,deleteBlockedByPrinting:`Löschen nicht möglich — {{count}} Warteschlangeneinträge werden derzeit gedruckt. Druck zuerst stoppen und erneut versuchen.`,removeSource3mf:`Quell-3MF entfernen`,removeSource3mfConfirm:`Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.`,removeButton:`Entfernen`,removeF3d:`F3D entfernen`,removeF3dConfirm:`Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?`,removeTimelapse:`Zeitraffer entfernen`,removeTimelapseConfirm:`Möchten Sie das Zeitraffervideo wirklich von "{{name}}" entfernen?`,timelapse:`{{name}} - Zeitraffer`,selectTimelapse:`Zeitraffer auswählen`,selectTimelapseDesc:`Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:`,deleteArchives:`Archive löschen`,deleteArchivesConfirm:`Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleteCount:`{{count}} löschen`},page:{title:`Archive`,printsCount:`{{filtered}} von {{total}} Drucken`,dropFilesHere:`.3mf-Dateien hier ablegen`,releaseToUpload:`Loslassen zum Hochladen`,only3mfSupported:`Nur .3mf-Dateien werden unterstützt`,close:`Schließen`,selected:`{{count}} ausgewählt`,selectAll:`Alle auswählen`,tags:`Tags`,project:`Projekt`,favorite:`Favorit`,delete:`Löschen`,toggledFavorites:`Favoriten für {{count}} Archiv(e) umgeschaltet`,failedUpdateFavorites:`Fehler beim Aktualisieren der Favoriten`,archivesDeleted:`{{count}} Archiv(e) gelöscht`,failedDeleteArchives:`Fehler beim Löschen der Archive`,photoDeleted:`Foto gelöscht`,failedDeletePhoto:`Fehler beim Löschen des Fotos`},list:{name:`Name`,printer:`Drucker`,date:`Datum`,size:`Größe`,actions:`Aktionen`,hasTimelapse:`Hat Zeitraffer`},log:{date:`Datum`,printName:`Druckname`,printer:`Drucker`,user:`Benutzer`,status:`Status`,duration:`Dauer`,filament:`Filament`,allPrinters:`Alle Drucker`,allUsers:`Alle Benutzer`,allStatuses:`Alle Status`,cancelled:`Abgebrochen`,skipped:`Übersprungen`,dateFrom:`Von`,dateTo:`Bis`,noEntries:`Keine Druckprotokolleinträge gefunden`,showing:`{{count}} von {{total}} Einträgen`,rowsPerPage:`Zeilen`,page:`Seite`,prev:`Zurück`,next:`Weiter`,clearLog:`Protokoll löschen`,clearLogTitle:`Druckprotokoll löschen`,clearLogConfirm:`Alle Druckprotokolleinträge werden dauerhaft gelöscht. Archive und Warteschlangeneinträge sind nicht betroffen. Diese Aktion kann nicht rückgängig gemacht werden. Sind Sie sicher?`,clearLogButton:`Alle löschen`,cleared:`{{count}} Protokolleinträge gelöscht`,clearFailed:`Druckprotokoll konnte nicht gelöscht werden`,deleteEntryTitle:`Druckprotokoll-Eintrag löschen`,deleteEntryConfirm:`Dieser Eintrag wird aus dem Protokoll entfernt und sein Filament-, Zeit- und Kostenbeitrag verschwindet aus den Schnellstatistiken. Das zugehörige Archiv (falls vorhanden) ist nicht betroffen. Diese Aktion kann nicht rückgängig gemacht werden.`,entryDeleted:`Druckprotokoll-Eintrag gelöscht`,entryDeleteFailed:`Druckprotokoll-Eintrag konnte nicht gelöscht werden`,editEntryTitle:`Druckprotokoll-Eintrag bearbeiten`,editEntryDescription:`Diesen Druckdurchlauf klassifizieren. Das Fehleranalyse-Widget gruppiert nach diesen Werten, sodass Aktualisierungen sofort in die Statistik einfließen.`,entryUpdated:`Druckprotokoll-Eintrag aktualisiert`,entryUpdateFailed:`Druckprotokoll-Eintrag konnte nicht aktualisiert werden`,statuses:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,stopped:`Gestoppt`,cancelled:`Abgebrochen`,skipped:`Übersprungen`}}},queue:{filamentShort:{rowBadge:`Filament fuer die zugewiesene Spule reicht nicht`,rowTooltip:`Der Dispatcher hat diese Position markiert. Klicke auf Play, um den Pro-Slot-Fehlbestand zu sehen und zu entscheiden, ob trotzdem gedruckt werden soll.`,confirmTitle:`Filament reicht nicht`,confirmIntro:`Die zugewiesene Spule kann mindestens einen Slot nicht versorgen. Trotzdem drucken?`,lineItem:`Slot {{slot}}: benoetigt {{required}} g, {{remaining}} g verbleibend`,unknown:`unbekannt`,printAnyway:`Trotzdem drucken`},title:`Druckwarteschlange`,subtitle:`Planen und verwalten Sie Ihre Druckaufträge`,addToQueue:`Zur Warteschlange hinzufügen`,print:`Drucken`,reprint:`Erneut drucken`,schedulePrint:`Druck planen`,editQueueItem:`Warteschlangeneintrag bearbeiten`,printToPrinters:`Auf {{count}} Druckern drucken`,queueToPrinters:`Zu {{count}} Druckern hinzufügen`,queueSelectedPlates:`{{count}} Platten in die Warteschlange`,selectAllPlates:`Alle {{count}} Platten auswählen`,deselectAll:`Alle abwählen`,printQueued:`Druck in Warteschlange`,itemsQueued:`{{count}} Einträge in Warteschlange`,sending:`Wird gesendet...`,sendingProgress:`Sende {{current}}/{{total}}...`,adding:`Wird hinzugefügt...`,addingProgress:`Füge hinzu {{current}}/{{total}}...`,savingProgress:`Speichere {{current}}/{{total}}...`,clearQueue:`Warteschlange leeren`,clearHistory:`Verlauf löschen`,emptyQueue:`Warteschlange ist leer`,position:`Position`,scheduledTime:`Geplante Zeit`,moveUp:`Nach oben`,moveDown:`Nach unten`,startNow:`Jetzt starten`,printingInProgress:`Druck läuft...`,viewArchive:`Archiv anzeigen`,viewInFileManager:`Im Dateimanager anzeigen`,itemCount:`{{count}} Element`,itemCount_plural:`{{count}} Elemente`,dragToReorder:`Ziehen zum Neuordnen (nur Sofort)`,reorderHint:`Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.`,sjf:{label:`SJF`,tooltip:`Kürzester Auftrag zuerst — Scheduler bevorzugt kürzere Drucke`},addedBy:`Hinzugefügt von {{name}}`,nextInQueue:`Nächster in der Warteschlange`,clearPlateSuccess:`Druckplatte freigegeben — bereit für nächsten Druck`,plateNumber:`Platte {{index}}`,quantity:`Menge`,quantityHint:`Erstellt {{count}} Warteschlangeneinträge`,activeBatches:`Aktive Stapel`,batchProgress:`{{completed}} von {{total}} abgeschlossen`,cancelBatch:`Verbleibende abbrechen`,batchCancelled:`Verbleibende Stapeleinträge abgebrochen`,cancelBatchConfirmTitle:`Stapel abbrechen`,cancelBatchConfirmMessage:`Alle verbleibenden ausstehenden Einträge in diesem Stapel abbrechen?`,batch:{defaultName:`Stapel`,label:`{{count}} Eintrag`,label_plural:`{{count}} Einträge`,pendingCount:`{{count}} ausstehend`,pendingCount_plural:`{{count}} ausstehend`,expand:`Stapel ausklappen`,collapse:`Stapel einklappen`,groupAsBatch:`Als Stapel gruppieren…`,groupAsBatchDescription:`Fasse die {{count}} ausgewählten Einträge zu einem einklappbaren Stapel zusammen.`,nameLabel:`Stapelname`,namePlaceholder:`z. B. Freitagsgeschenke`,create:`Stapel erstellen`,ungroup:`Gruppierung aufheben`,ungroupConfirmTitle:`Stapel auflösen?`,ungroupConfirmMessage:`Die Einträge bleiben in der Warteschlange, sind aber nicht mehr gruppiert.`,dragGroup:`Gruppe ziehen`},tabs:{queue:`Warteschlange`,history:`Verlauf`,timeline:`Zeitachse`},layout:{flatList:`Liste`,byPrinter:`Nach Drucker`,groupByPrinter:`Nach Drucker gruppieren`},history:{emptyTitle:`Noch kein Verlauf`,emptyDescription:`Abgeschlossene, abgebrochene und fehlgeschlagene Drucke erscheinen hier.`},dragGhost:{multiCount:`{{count}} Einträge`,batch:`{{name}} ({{count}} Kopie)`,batch_plural:`{{name}} ({{count}} Kopien)`},sections:{currentlyPrinting:`Aktuell druckend`,queued:`In Warteschlange`,history:`Verlauf`},status:{pending:`Ausstehend`,waiting:`Wartend`,printing:`Druckt`,paused:`Pausiert`,completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,skipped:`Übersprungen`,cancelled:`Abgebrochen`},summary:{printing:`Druckt`,queued:`In Warteschlange`,totalTime:`Gesamte Wartezeit`,totalWeight:`Gesamtgewicht der Warteschlange`,history:`Verlauf`},filter:{allPrinters:`Alle Drucker`,unassigned:`Nicht zugewiesen`,allStatus:`Alle Status`,allLocations:`Alle Standorte`,any:`Beliebig`},sort:{byPosition:`Nach Position sortieren`,byName:`Nach Name sortieren`,byPrinter:`Nach Drucker sortieren`,bySchedule:`Nach Zeitplan sortieren`,byDate:`Nach Datum sortieren`,ascendingOldest:`Aufsteigend (älteste zuerst)`,descendingNewest:`Absteigend (neueste zuerst)`},badges:{staged:`Bereitgestellt`,requiresPrevious:`Erfordert vorherigen Erfolg`,autoPowerOff:`Automatisch ausschalten`,gcodeInjection:`G-Code`},empty:{title:`Keine Drucke geplant`,description:`Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.`},time:{asap:`Sofort`,overdue:`Überfällig`,now:`Jetzt`,lessThanMinute:`In weniger als einer Minute`,inMinutes:`In {{count}} Min`,inHours:`In {{count}} Stunden`},actions:{stopPrint:`Druck stoppen`,startPrint:`Druck starten`,requeue:`Erneut einreihen`},bulkEdit:{title:`{{count}} Element bearbeiten`,title_plural:`{{count}} Elemente bearbeiten`,description:`Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.`,printer:`Drucker`,noChange:`— Keine Änderung —`,queueOptions:`Warteschlangenoptionen`,staged:`Bereitgestellt (manueller Start)`,autoPowerOff:`Nach Druck automatisch ausschalten`,requirePrevious:`Vorherigen Erfolg erfordern`,printOptions:`Druckoptionen`,bedLevelling:`Bett-Nivellierung`,flowCalibration:`Fluss-Kalibrierung`,vibrationCalibration:`Vibrations-Kalibrierung`,layerInspection:`Erste-Schicht-Prüfung`,timelapse:`Zeitraffer`,useAms:`AMS verwenden`,nozzleOffsetCali:`Düsenversatz-Kalibrierung`,applyChanges:`Änderungen übernehmen`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,selected:`{{count}} ausgewählt`,editSelected:`Ausgewählte bearbeiten`,cancelSelected:`Ausgewählte abbrechen`},confirm:{cancelTitle:`Geplanten Druck abbrechen`,cancelMessage:`Möchten Sie "{{name}}" wirklich abbrechen?`,stopTitle:`Druck stoppen`,stopMessage:`Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.`,removeTitle:`Aus Verlauf entfernen`,removeMessage:`Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?`,clearHistoryTitle:`Verlauf löschen`,clearHistoryMessage:`Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?`,cancelButton:`Druck abbrechen`,stopButton:`Druck stoppen`,thisPrint:`diesen Druck`,thisItem:`dieses Element`},toast:{cancelled:`Warteschlangenelement abgebrochen`,cancelFailed:`Element konnte nicht abgebrochen werden`,removed:`Warteschlangenelement entfernt`,removeFailed:`Element konnte nicht entfernt werden`,stopped:`Druck gestoppt`,stopFailed:`Druck konnte nicht gestoppt werden`,released:`Druck in Warteschlange freigegeben`,startFailed:`Druck konnte nicht gestartet werden`,reorderFailed:`Warteschlange konnte nicht neu geordnet werden`,historyCleared:`{{count}} Verlaufselement(e) gelöscht`,clearHistoryFailed:`Verlauf konnte nicht gelöscht werden`,updateFailed:`Elemente konnten nicht aktualisiert werden`,bulkCancelled:`{{count}} Element(e) abgebrochen`,bulkCancelFailed:`Elemente konnten nicht abgebrochen werden`,batchCreated:`Stapel „{{name}}“ erstellt`,batchCreateFailed:`Stapel konnte nicht erstellt werden`,batchUngrouped:`{{count}} Eintrag/Einträge aus Stapel gelöst`,batchUngroupFailed:`Stapel konnte nicht aufgelöst werden`,resumedAfterFailure:`Warteschlange fortgesetzt — {{restored}} Auftrag/Aufträge wieder eingereiht`,resumeAfterFailureFailed:`Warteschlange konnte nicht fortgesetzt werden`},resumeAfterFailure:{banner:`{{printer}} ist durch einen vorherigen Druckfehler blockiert — {{count}} Auftrag/Aufträge übersprungen`,bannerHint:`Behebe das Druckerproblem und setze die Warteschlange dann fort, um die übersprungenen Aufträge wiederherzustellen und die Sperre aufzuheben.`,button:`Nach Fehler fortsetzen`,confirmTitle:`Warteschlange nach Fehler fortsetzen?`,confirmMessage:`Setze {{count}} übersprungenen Auftrag/Aufträge auf {{printer}} wieder auf „Ausstehend“ und hebe die Vorgängersperre auf. Stelle vorher sicher, dass der Drucker bereit ist.`},timeline:{listView:`Liste`,timelineView:`Zeitstrahl`,unassigned:`Nicht zugewiesen`,noData:`Keine geplanten Drucke für diesen Tag`,nothingCommitted:`Keine festgelegten Pläne in diesem Zeitfenster. Vorgemerkte Einträge, wartende Einträge und ASAP-Aufträge auf inaktiven Druckern werden nicht angezeigt — leg eine geplante Zeit fest oder gib einen vorgemerkten Eintrag frei, damit er hier erscheint.`,allDoneBy:`Alle Drucke voraussichtlich fertig um {{time}}`,staged:`Bereitgestellt`,filterAll:`Alle anzeigen`,filterPrinting:`Druckend`,filterQueued:`Warteschlange`,time:{anyMoment:`jeden Moment`,minutesLeft:`{{minutes}}m übrig`,hoursLeft:`{{hours}}h übrig`,hoursMinutesLeft:`{{hours}}h {{minutes}}m übrig`},day:{previous:`Vorheriger Tag`,next:`Nächster Tag`,today:`Heute`},window:{back12h:`12 Stunden zurück`,forward12h:`12 Stunden vor`,now:`Jetzt`},printerColumnHeader:`Drucker`},permissions:{noStopPrint:`Sie haben keine Berechtigung, Drucke zu stoppen`,noStartPrint:`Sie haben keine Berechtigung, Drucke zu starten`,noEdit:`Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten`,noCancel:`Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen`,noRequeue:`Sie haben keine Berechtigung, Elemente erneut einzureihen`,noRemove:`Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen`,noClearHistory:`Sie haben keine Berechtigung, den gesamten Verlauf zu löschen`,noEditItems:`Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten`,noCancelItems:`Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen`}},backgroundDispatch:{unknownFile:`Unbekannte Datei`,unknownPrinter:`Unbekannter Drucker`,startingPrints:`Starte Drucke`,progressSummary:`{{complete}}/{{total}} abgeschlossen • Geplant: {{dispatched}} • In Bearbeitung: {{processing}}`,expandDetails:`Dispatch-Details ausklappen`,collapseDetails:`Dispatch-Details einklappen`,dismissToast:`Dispatch-Hinweis schließen`,cancelDispatchJob:`Dispatch-Job abbrechen`,cancel:`Abbrechen`,cancelling:`Wird abgebrochen…`,awaitingPrinter:`Warte auf Drucker…`,status:{dispatched:`Geplant`,processing:`In Bearbeitung`,completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,cancelled:`Abgebrochen`},toast:{cancellingUpload:`Upload wird abgebrochen...`,cancelled:`Dispatch abgebrochen`,cancelFailed:`Dispatch konnte nicht abgebrochen werden`,completeWithFailures:`Background Dispatch abgeschlossen: {{completed}} erfolgreich, {{failed}} fehlgeschlagen`,completeSuccess:`Background Dispatch abgeschlossen: {{completed}} erfolgreich`,printStartedRemaining:`{{completed}} Druck(e) gestartet, {{remaining}} weitere werden gesendet...`}},stats:{title:`Statistiken`,subtitle:`Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.`,overview:`Übersicht`,totalPrints:`Gesamtdrucke`,successRate:`Erfolgsrate`,totalPrintTime:`Gesamtdruckzeit`,printTime:`Druckzeit`,totalFilament:`Gesamtverbrauch Filament`,filamentUsed:`Filamentverbrauch`,filamentCost:`Filamentkosten`,totalCost:`Gesamtkosten`,energyUsed:`Energieverbrauch`,energyCost:`Energiekosten`,energyWarmingUpTooltip:`Die Energieerfassung sammelt noch stündliche Snapshots. Zeitraumwerte werden genau, sobald vor dem gewählten Bereich mindestens ein Snapshot vorliegt. Frühe Werte können zu niedrig sein.`,averagePrintTime:`Durchschnittliche Druckzeit`,printsPerDay:`Drucke pro Tag`,byPrinter:`Nach Drucker`,printsByPrinter:`Drucke nach Drucker`,byMaterial:`Nach Material`,byMonth:`Nach Monat`,last7Days:`Letzte 7 Tage`,last30Days:`Letzte 30 Tage`,last90Days:`Letzte 90 Tage`,allTime:`Gesamt`,quickStats:`Schnellstatistiken`,printActivity:`Druckaktivität`,filamentTypes:`Filamenttypen`,filamentTrends:`Filamenttrends`,failureAnalysis:`Fehleranalyse`,timeAccuracy:`Zeitgenauigkeit`,successful:`Erfolgreich:`,failed:`Fehlgeschlagen:`,cancelled:`Abgebrochen:`,perfectEstimate:`100% = perfekte Schätzung`,noTimeAccuracyData:`Noch keine Zeitgenauigkeitsdaten`,noFilamentData:`Keine Filamentdaten verfügbar`,noPrinterData:`Keine Druckerdaten verfügbar`,noPrintData:`Keine Druckdaten verfügbar`,noPrintDataLast30Days:`Keine Druckdaten in den letzten 30 Tagen`,failureReasons:`Fehlerursachen`,topFailureReasons:`Häufigste Fehlerursachen`,failedPrintsCount:`{{failed}} / {{total}} Drucke fehlgeschlagen`,lastWeekRate:`Letzte Woche: {{rate}}%`,resetLayout:`Layout zurücksetzen`,recalculateCosts:`Kosten neu berechnen`,recalculateCostsHint:`Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen`,exportStats:`Statistiken exportieren`,exportAsCsv:`Als CSV exportieren`,exportAsExcel:`Als Excel exportieren`,hiddenCount:`{{count}} ausgeblendet`,exportDownloaded:`Export heruntergeladen`,exportFailed:`Export fehlgeschlagen`,layoutReset:`Layout zurückgesetzt`,recalculatedCosts:`Kosten für {{count}} Archive neu berechnet`,recalculateFailed:`Kosten konnten nicht neu berechnet werden`,loadingStats:`Statistiken werden geladen...`,noPermissionResetLayout:`Sie haben keine Berechtigung, das Layout zurückzusetzen`,noPermissionRecalculate:`Sie haben keine Berechtigung, Kosten neu zu berechnen`,noPrintDataInRange:`Keine Druckdaten im ausgewählten Zeitraum`,periodFilament:`Filamentverbrauch`,periodCost:`Kosten`,avgPerPrint:`Durchschnitt pro Druck`,usageOverTime:`Verbrauch im Zeitverlauf`,filamentByWeight:`Gewicht`,printDuration:`Druckdauer`,printerUtilization:`Druckerauslastung`,filamentSuccess:`Erfolg nach Material`,printHabits:`Druckgewohnheiten`,printTimeOfDay:`Druck-Tageszeit`,colorDistribution:`Farbverteilung`,noColorData:`Keine Farbdaten verfügbar`,records:`Rekorde`,longestPrint:`Längster Druck`,heaviestPrint:`Schwerster Druck`,mostExpensivePrint:`Teuerster Druck`,busiestDay:`Aktivster Tag`,successStreak:`Erfolgsserie`,streakPrint:`aufeinanderfolgender Druck`,streakPrints:`{{count}} aufeinanderfolgende Drucke`,printerStats:`Druckerstatistiken`,hours:`Stunden`,avgPrints:`Ø Drucke`,noArchiveData:`Keine Druckdaten verfügbar`,filamentByTime:`Zeitverlauf`,avgWeight:`Ø Gewicht`,avgTime:`Ø Zeit`,filamentByPrints:`Drucke`,timeframe:{today:`Heute`,"this-week":`Diese Woche`,"this-month":`Dieser Monat`,"last-7":`Letzte 7 Tage`,"last-30":`Letzte 30 Tage`,"last-90":`Letzte 90 Tage`,"this-year":`Dieses Jahr`,"all-time":`Gesamt`,custom:`Benutzerdefiniert`,from:`Von`,to:`Bis`},allUsers:`Alle Benutzer`,noUser:`Kein Benutzer (System)`,filterByUser:`Nach Benutzer filtern`},maintenance:{title:`Wartung`,overview:`Übersicht`,allOk:`Alle Wartungen aktuell`,dueCount:`{{count}} Aufgabe fällig`,dueCount_plural:`{{count}} Aufgaben fällig`,warningCount:`{{count}} Warnung`,warningCount_plural:`{{count}} Warnungen`,totalPrintTime:`Gesamtdruckzeit`,nextMaintenance:`Nächste Wartung`,nothingDue:`Nichts fällig`,tasks:`Aufgaben`,lastPerformed:`Zuletzt durchgeführt`,interval:`Intervall`,hoursRemaining:`{{hours}}h verbleibend`,hoursOverdue:`{{hours}}h überfällig`,markDone:`Als erledigt markieren`,performMaintenance:`Wartung durchführen`,history:`Verlauf`,noHistory:`Kein Wartungsverlauf`,editPrintHours:`Druckstunden bearbeiten`,currentHours:`Aktuelle Stunden`,statusTab:`Status`,settingsTab:`Einstellungen`,overdueCount:`{{count}} überfällig`,dueSoonCount:`{{count}} bald fällig`,dueSoon:`Bald fällig`,allGood:`Alles in Ordnung`,overdueBy:`Überfällig um {{duration}}`,dueIn:`Fällig in {{duration}}`,timeLeft:`{{duration}} verbleibend`,day:`1 Tag`,days:`{{count}} Tage`,week:`1 Woche`,weeks:`{{count}} Wochen`,month:`1 Monat`,months:`{{count}} Monate`,year:`1 Jahr`,maintenanceTypes:`Wartungstypen`,maintenanceTypesDescription:`Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben`,addCustomType:`Benutzerdefinierten Typ hinzufügen`,restoreDefaults:`Standardaufgaben wiederherstellen`,intervalType:`Intervalltyp`,intervalValue:`Intervall ({{type}})`,icon:`Symbol`,documentationLink:`Dokumentationslink (optional)`,assignToPrinters:`Druckern zuweisen`,selectAtLeastOnePrinter:`Wählen Sie mindestens einen Drucker`,addType:`Typ hinzufügen`,custom:`Benutzerdefiniert`,printHours:`Druckstunden`,calendarDays:`Kalendertage`,exampleName:`z.B. HEPA-Filter ersetzen`,viewDocumentation:`Dokumentation anzeigen`,timeBasedInterval:`Zeitbasiertes Intervall`,intervalOverrides:`Intervall-Überschreibungen`,intervalOverridesDescription:`Intervalle für bestimmte Drucker anpassen`,assignedToPrinters:`Druckern zugewiesen:`,noPrintersAssigned:`Keine Drucker zugewiesen`,addPrinterShort:`Hinzufügen:`,printersAssignedClick:`{{count}} Drucker zugewiesen - klicken zum Verwalten`,removeFromPrinter:`Von diesem Drucker entfernen`,types:{lubricateCarbonRods:`Karbonstäbe schmieren`,lubricateRails:`Linearschienen schmieren`,cleanNozzle:`Düse/Hotend reinigen`,checkBelts:`Riemenspannung prüfen`,cleanBuildPlate:`Druckbett reinigen`,checkExtruder:`Extruderzahnräder prüfen`,checkCooling:`Kühlungslüfter prüfen`,generalInspection:`Allgemeine Inspektion`,cleanCarbonRods:`Kohlenstoffstangen reinigen`,lubricateSteelRods:`Stahlstangen schmieren`,cleanSteelRods:`Stahlstangen reinigen`,cleanLinearRails:`Linearschienen reinigen`,checkPtfeTube:`PTFE-Schlauch prüfen`,replaceHepaFilter:`HEPA-Filter ersetzen`,replaceCarbonFilter:`Aktivkohlefilter ersetzen`,lubricateLeftNozzleRail:`Linke Düsenschiene schmieren`},maintenanceComplete:`Wartung als abgeschlossen markiert`,typeUpdated:`Wartungstyp aktualisiert`,typeDeleted:`Wartungstyp gelöscht`,defaultsRestored:`{{count}} Standardaufgabe(n) wiederhergestellt`,printHoursUpdated:`Druckstunden aktualisiert`,printerAssigned:`Drucker zugewiesen`,printerRemoved:`Drucker entfernt`,deleteTypeConfirm:`"{{name}}" löschen?`,deleteSystemTypeTitle:`Standard-Wartungsaufgabe löschen?`,deleteSystemTypeMessage:`Möchten Sie die Standard-Wartungsaufgabe "{{name}}" wirklich löschen?`,noPermissionUpdate:`Sie haben keine Berechtigung, Wartungselemente zu aktualisieren`,noPermissionPerform:`Sie haben keine Berechtigung, Wartungen durchzuführen`,noPermissionEditTypes:`Sie haben keine Berechtigung, Wartungstypen zu bearbeiten`,noPermissionDeleteTypes:`Sie haben keine Berechtigung, Wartungstypen zu löschen`,noPermissionEditHours:`Sie haben keine Berechtigung, Druckstunden zu bearbeiten`,noPermissionRemovePrinter:`Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen`,noPermissionAssignPrinter:`Sie haben keine Berechtigung, Drucker zuzuweisen`,noPermissionEditIntervals:`Sie haben keine Berechtigung, Intervalle zu bearbeiten`,configureSettings:`Wartungstypen und Intervalle konfigurieren`},settings:{title:`Einstellungen`,general:`Allgemein`,tabs:{general:`Allgemein`,smartPlugs:`Smart Plugs`,notifications:`Benachrichtigungen`,queue:`Workflow`,filament:`Filament`,network:`Netzwerk`,apiKeys:`API-Schlüssel`,virtualPrinter:`Virtueller Drucker`,spoolbuddy:`SpoolBuddy`,failureDetection:`Fehlererkennung`,users:`Authentifizierung`,backup:`Sicherung`,emailAuth:`E-Mail-Authentifizierung`,ldap:`LDAP`,twoFa:`Zwei-Faktor-Auth`,oidc:`SSO / OIDC`,security:`Sicherheit`},spoolbuddy:{infoTitle:`SpoolBuddy-Geräte`,infoBody:`SpoolBuddy-Kioske registrieren sich automatisch per Heartbeat. Ein Gerät hier abmelden, wenn es nicht mehr verwendet wird oder wenn ein veralteter Eintrag nach einem Daemon-Absturz übrig geblieben ist.`,duplicatesTitle:`{{count}} Geräte registriert`,duplicatesBody:`Die Kiosk-Oberfläche verwendet nur das zuerst registrierte Gerät. Falls eines davon ein veralteter Doppeleintrag nach einem Absturz ist, kann es hier entfernt werden — ein laufendes Gerät registriert sich beim nächsten Heartbeat automatisch neu.`,empty:`Noch keine SpoolBuddy-Geräte registriert.`,online:`Online`,offline:`Offline`,unregister:`Abmelden`,unregisterSuccess:`Gerät abgemeldet`,unregisterError:`Gerät konnte nicht abgemeldet werden`,confirmTitle:`SpoolBuddy-Gerät abmelden?`,confirmBody:`Dies entfernt „{{hostname}}" ({{deviceId}}) aus der Datenbank. Ein laufendes Gerät registriert sich beim nächsten Heartbeat automatisch neu.`,ipAddress:`IP-Adresse`,firmware:`Firmware`,lastSeen:`Zuletzt gesehen`,daemonUptime:`Daemon-Laufzeit`,systemUptime:`System-Laufzeit`,never:`nie`,nfc:`NFC`,scale:`Waage`,cpuTemp:`CPU-Temp.`,cpuLoad:`CPU-Last`,memory:`Speicher`,disk:`Festplatte`,update:`Aktualisieren`,updateConfirmTitle:`Spoolbuddy-Daemon aktualisieren?`,updateConfirmBody:`Software-Update auf „{{hostname}}" auslösen? Der Daemon startet nach dem Update neu.`,restartBrowser:`Browser neu starten`,restartBrowserConfirmTitle:`Kiosk-Browser neu starten?`,restartBrowserConfirmBody:`Kiosk-Browser auf „{{hostname}}" neu starten? Die Anzeige wird kurz schwarz.`,restartDaemon:`Daemon neu starten`,restartDaemonConfirmTitle:`Spoolbuddy-Daemon neu starten?`,restartDaemonConfirmBody:`Spoolbuddy-Daemon auf „{{hostname}}" neu starten? Das Gerät ist für einige Sekunden offline.`,reboot:`Neustart`,rebootConfirmTitle:`Gerät neu starten?`,rebootConfirmBody:`„{{hostname}}" neu starten? Das Gerät ist für etwa eine Minute offline.`,shutdown:`Herunterfahren`,shutdownConfirmTitle:`Gerät herunterfahren?`,shutdownConfirmBody:`„{{hostname}}" herunterfahren? Physischer Zugriff ist nötig, um es wieder einzuschalten.`,commandConfirm:`Bestätigen`,commandQueued:`Befehl eingereiht`,commandError:`Befehl konnte nicht gesendet werden`},ldap:{title:`LDAP-Authentifizierung`,enabledDesc:`LDAP-Authentifizierung ist aktiviert`,disabledDesc:`LDAP-Authentifizierung ist deaktiviert`,disabledHint:`LDAP-Einstellungen unten konfigurieren und speichern, dann aktivieren.`,enabled:`LDAP-Authentifizierung aktiviert`,disabled:`LDAP-Authentifizierung deaktiviert`,feature1:`Benutzer können sich mit LDAP-Anmeldedaten anmelden`,feature2:`Lokales Admin-Konto bleibt als Fallback erhalten`,feature3:`LDAP-Gruppen werden bei der Anmeldung BamBuddy-Gruppen zugeordnet`,serverConfig:`LDAP-Server-Konfiguration`,serverUrl:`Server-URL`,serverUrlHint:`Verwenden Sie ldap:// für Standard oder ldaps:// für SSL-Verbindungen`,security:`Sicherheit`,securityHint:`StartTLS aktualisiert eine einfache Verbindung auf TLS. LDAPS verwendet TLS von Anfang an.`,bindDn:`Bind-DN (Dienstkonto)`,bindPassword:`Bind-Passwort`,searchBase:`Such-Basis-DN`,userFilter:`Benutzer-Suchfilter`,userFilterHint:`{username} wird durch den Anmeldenamen ersetzt. Verwenden Sie (uid={username}) für OpenLDAP.`,advanced:`Erweitert`,autoProvision:`Benutzer automatisch anlegen`,autoProvisionHint:`Automatisch ein BamBuddy-Konto bei der ersten LDAP-Anmeldung erstellen`,defaultGroup:`Standardgruppe`,defaultGroupNone:`— Keine (kein Fallback) —`,defaultGroupHint:`Fallback-Gruppe, die zugewiesen wird, wenn sich ein LDAP-Benutzer authentifiziert, aber in keiner zugeordneten LDAP-Gruppe enthalten ist. Leer lassen, um nicht zugeordnete Benutzer ohne Berechtigungen zu belassen.`,groupMapping:`Gruppenzuordnung (JSON)`,groupMappingHint:`LDAP-Gruppen-DNs BamBuddy-Gruppen zuordnen. Verfügbare Gruppen: `,testConnection:`Verbindung testen`,settingsSaved:`LDAP-Einstellungen gespeichert`,errors:{serverRequired:`LDAP-Server-URL ist erforderlich`,searchBaseRequired:`Such-Basis-DN ist erforderlich`,enableAuthFirst:`Authentifizierung zuerst aktivieren`,configureLdapFirst:`LDAP-Einstellungen zuerst speichern`}},email:{smtpSettings:`SMTP-Konfiguration`,smtpHost:`SMTP-Server`,smtpPort:`SMTP-Port`,security:`Sicherheit`,authentication:`Authentifizierung`,username:`Benutzername`,password:`Passwort`,fromEmail:`Absender-E-Mail`,fromName:`Absendername`,testConnection:`SMTP-Verbindung testen`,testRecipient:`Test-Empfänger-E-Mail`,sendTest:`Test-E-Mail senden`,sending:`Wird gesendet...`,save:`Einstellungen speichern`,saving:`Wird gespeichert...`,advancedAuth:`Erweiterte Authentifizierung`,advancedAuthEnabled:`Erweiterte Authentifizierung ist aktiviert`,advancedAuthEnabledDesc:`E-Mail-basierte Benutzerverwaltungsfunktionen sind aktiv. Neue Benutzer erhalten automatisch generierte Passwörter per E-Mail und können ihr Passwort über die Passwort vergessen Funktion zurücksetzen.`,advancedAuthDisabled:`Erweiterte Authentifizierung ist deaktiviert`,advancedAuthDisabledDesc:`Aktivieren Sie die erweiterte Authentifizierung, um E-Mail-basierte Funktionen für die Benutzerverwaltung zu aktivieren.`,enable:`Aktivieren`,disable:`Deaktivieren`,feature1:`Passwörter werden automatisch generiert und an neue Benutzer gesendet`,feature2:`Benutzer können sich mit Benutzername oder E-Mail anmelden`,feature3:`Passwort vergessen Funktion ist verfügbar`,feature4:`Administratoren können Benutzerpasswörter per E-Mail zurücksetzen`,errors:{requiredFields:`Bitte füllen Sie alle Pflichtfelder aus`,usernameRequired:`Benutzername ist erforderlich, wenn Authentifizierung aktiviert ist`,enterTestEmail:`Bitte geben Sie eine Test-E-Mail-Adresse ein`,smtpServerAndEmail:`Bitte füllen Sie SMTP-Server und Absender-E-Mail aus, bevor Sie testen`,usernamePasswordRequired:`Benutzername und Passwort sind erforderlich, wenn Authentifizierung aktiviert ist`,configureSmtpFirst:`Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen`,enableAuthFirst:`Bitte aktivieren Sie zuerst die Authentifizierung, um E-Mail-basierte Funktionen nutzen zu können.`},success:{settingsSaved:`SMTP-Einstellungen erfolgreich gespeichert`},securityOptions:{starttls:`STARTTLS (Port 587)`,ssl:`SSL/TLS (Port 465)`,none:`Keine (Port 25)`},authOptions:{enabled:`Aktiviert`,disabled:`Deaktiviert`}},appearance:`Erscheinungsbild`,notifications:`Benachrichtigungen`,smartPlugs:`Smart Plugs`,spoolman:`Spoolman`,updates:`Aktualisierungen`,language:`Sprache`,languageDescription:`Wählen Sie Ihre bevorzugte Sprache`,theme:`Design`,themeLight:`Hell`,themeDark:`Dunkel`,themeSystem:`System`,defaultView:`Standardansicht`,defaultViewDescription:`Seite, die beim Öffnen der App angezeigt wird`,checkForUpdates:`Nach Updates suchen`,autoUpdate:`Automatische Updates`,currentVersion:`Aktuelle Version`,latestVersion:`Neueste Version`,upToDate:`Sie sind auf dem neuesten Stand`,updateAvailable:`Update verfügbar`,notificationLanguage:`Benachrichtigungssprache`,notificationLanguageDescription:`Sprache für Push-Benachrichtigungen`,bedCooledThreshold:`Bett-Abkühlung Schwellenwert`,bedCooledThresholdDescription:`Temperatur, unter der das Bett nach einem Druck als abgekühlt gilt`,userNotificationsEnabled:`Benutzerbenachrichtigungen`,userNotificationsEnabledDescription:`Aktiviert das Benutzerbenachrichtigungsmenü und E-Mail-Benachrichtigungen für Druckereignisse. Erfordert Erweiterte Authentifizierung.`,userNotificationsDisabledHint:`Erweiterte Authentifizierung aktivieren, um Benutzerbenachrichtigungen zu verwenden.`,notificationProviders:`Benachrichtigungsanbieter`,addProvider:`Anbieter hinzufügen`,editProvider:`Anbieter bearbeiten`,providerType:`Anbietertyp`,testNotification:`Testbenachrichtigung`,testSuccess:`Testbenachrichtigung erfolgreich gesendet`,testFailed:`Testbenachrichtigung konnte nicht gesendet werden`,quietHours:`Ruhezeiten`,quietHoursDescription:`Keine Störungen während dieser Zeiten`,quietHoursStart:`Beginn`,quietHoursEnd:`Ende`,events:{title:`Benachrichtigungsereignisse`,printStart:`Druck gestartet`,printComplete:`Druck abgeschlossen`,printFailed:`Druck fehlgeschlagen`,printStopped:`Druck gestoppt`,printProgress:`Fortschrittsmeldungen`,printProgressDescription:`Bei 25%, 50%, 75% benachrichtigen`,printerOffline:`Drucker offline`,printerError:`Druckerfehler`,filamentLow:`Filament niedrig`,maintenanceDue:`Wartung fällig`,maintenanceDueDescription:`Benachrichtigen, wenn Wartung erforderlich`},smartPlug:{title:`Smart Plugs`,add:`Smart Plug hinzufügen`,edit:`Smart Plug bearbeiten`,name:`Name`,ipAddress:`IP-Adresse`,linkedPrinter:`Verknüpfter Drucker`,autoOn:`Automatisch einschalten`,autoOnDescription:`Einschalten beim Druckstart`,autoOff:`Automatisch ausschalten`,autoOffDescription:`Ausschalten nach Druckende`,offDelay:`Ausschaltverzögerung`,offDelayMinutes:`Minuten nach Druck`,offDelayTemp:`Wenn Düse unter Temperatur`,currentState:`Aktueller Status`,turnOn:`Einschalten`,turnOff:`Ausschalten`},filamentTracking:`Filament-Verfolgung`,filamentTrackingDesc:`Wählen Sie, wie Sie Ihre Filamentspulen verfolgen möchten. Sie können das integrierte Inventar oder einen externen Spoolman-Server verwenden.`,autoAddUnknownRfid:`Unbekannte RFID-Spulen automatisch hinzufügen`,autoAddUnknownRfidDesc:`Erstellt automatisch einen Inventareintrag, wenn eine Spule mit unbekanntem RFID-Tag erkannt wird. Deaktivieren, wenn Sie neue Spulen vorab manuell anlegen, um Duplikate zu vermeiden.`,filamentChecks:`Filament-Prüfungen`,disableFilamentWarnings:`Filament-Warnungen deaktivieren`,disableFilamentWarningsDesc:`Keine Warnungen über unzureichendes Filament beim Drucken oder Einreihen anzeigen`,preferLowestFilament:`Niedrigsten Filamentrest bevorzugen`,preferLowestFilamentDesc:`Bei mehreren passenden Spulen die mit dem geringsten Restfilament verwenden`,preferLowestFilamentBackupNote:`Wirkt nur, wenn AMS Filament Backup am Drucker aktiviert ist — sonst kann der Drucker beim Aufbrauchen der ersten Spule nicht auf eine zweite Spule wechseln.`,trackingModeBuiltIn:`Integriertes Inventar`,trackingModeBuiltInDesc:`RFID-Erkennung und Verbrauchserfassung inklusive`,trackingModeSpoolmanDesc:`Externer Filament-Management-Server`,builtInFeatureRfid:`Erkennt automatisch Bambu Lab RFID-Spulen im AMS`,builtInFeatureUsage:`Erfasst den Filamentverbrauch pro Druck`,builtInFeatureCatalog:`Spulen, Farben und K-Faktor-Profile verwalten`,builtInFeatureThirdParty:`Drittanbieter-Spulen können Inventarspulen zugewiesen werden`,amsSyncButton:`Gewichte vom AMS synchronisieren`,amsSyncTitle:`Spulengewichte vom AMS synchronisieren`,amsSyncMessage:`Alle Inventar-Spulengewichte werden mit den aktuellen AMS-Restwerten der verbundenen Drucker überschrieben. Verwenden Sie dies zur Wiederherstellung beschädigter Gewichtsdaten. Drucker müssen online sein.`,amsSyncing:`Synchronisiere...`,amsSyncSuccess:`{{synced}} Spule(n) synchronisiert, {{skipped}} übersprungen`,amsSyncError:`Synchronisierung der Gewichte vom AMS fehlgeschlagen`,spoolmanAmsSyncButton:`Spoolman-Gewichte vom AMS synchronisieren`,spoolmanAmsSyncTitle:`Spoolman-Spulengewichte vom AMS synchronisieren`,spoolmanAmsSyncMessage:`Dabei werden alle Spoolman-Spulengewichte anhand der aktuellen AMS-Füllstandswerte der verbundenen Drucker aktualisiert. Die Drucker müssen online sein.`,spoolmanAmsSyncing:`Synchronisiere...`,spoolmanAmsSyncSuccess:`{{synced}} Spule(n) synchronisiert, {{skipped}} übersprungen`,spoolmanAmsSyncError:`Synchronisierung der Spoolman-Gewichte vom AMS fehlgeschlagen`,spoolmanAmsSyncErrorUnreachable:`Synchronisierung fehlgeschlagen (Spoolman nicht erreichbar)`,spoolmanAmsSyncErrorNotConfigured:`Synchronisierung fehlgeschlagen (Spoolman nicht konfiguriert)`,spoolmanNotConfigured:`Spoolman nicht konfiguriert`,spoolmanFilamentCatalogTitle:`Spoolman-Filamentkatalog`,spoolmanFilamentCatalogDesc:`Filamentnamen und Leergewichte aus deiner Spoolman-Instanz. Name und Spulengewicht sind hier editierbar; alle anderen Eigenschaften werden direkt in Spoolman verwaltet.`,spoolmanUrl:`Spoolman URL`,spoolmanUrlHint:`URL Ihres Spoolman-Servers (z.B. http://localhost:7912)`,spoolmanConnected:`Verbunden`,spoolmanDisconnected:`Nicht verbunden`,status:`Status`,connect:`Verbinden`,disconnect:`Trennen`,howSyncWorks:`So funktioniert die Synchronisierung`,syncInfoRfidOnly:`Nur offizielle Bambu Lab Spulen mit RFID werden synchronisiert`,syncInfoAutoCreate:`Neue Spulen werden bei der ersten Synchronisierung automatisch in Spoolman erstellt`,syncInfoThirdPartySkipped:`Nicht-Bambu-Lab-Spulen (Drittanbieter, nachgefüllt) werden übersprungen`,linkingExistingSpools:`Vorhandene Spulen verknüpfen`,linkingExistingSpoolsDesc:`Um vorhandene Spoolman-Spulen mit Ihrem AMS zu verknüpfen, fahren Sie über einen AMS-Slot und klicken Sie auf "Mit Spoolman verknüpfen".`,syncMode:`Synchronisierungsmodus`,syncModeAuto:`Automatisch`,syncModeManual:`Nur manuell`,syncModeAutoDesc:`AMS-Daten werden automatisch synchronisiert, wenn Änderungen erkannt werden`,syncModeManualDesc:`Nur bei manueller Auslösung synchronisieren`,syncAmsData:`AMS-Daten synchronisieren`,syncAmsDataDesc:`AMS-Daten des Druckers manuell mit Spoolman synchronisieren`,allPrinters:`Alle Drucker`,noDefaultPrinter:`Kein Standard (jedes Mal fragen)`,sidebarOrder:`Seitenleisten-Reihenfolge`,saveThumbnails:`Vorschaubilder speichern`,captureFinishPhoto:`Abschlussfoto aufnehmen`,noPrintersConfigured:`Keine Drucker konfiguriert`,archiveMode:{always:`Immer Archiveintrag erstellen`,never:`Nie Archiveintrag erstellen`,ask:`Jedes Mal fragen`},checkForUpdatesLabel:`Nach Updates suchen`,checkPrinterFirmware:`Drucker-Firmware prüfen`,includeBetaUpdates:`Beta-Versionen einschließen`,includeBetaUpdatesDesc:`Über Beta- und Vorabversionen bei der Updateprüfung benachrichtigen`,enableRetry:`Wiederholung aktivieren`,homeAssistantDescription:`Smart Plugs über Home Assistant steuern`,environmentManagedLabel:`(Umgebungsvariable)`,autoEnabledViaEnv:`Automatisch über Umgebungsvariablen aktiviert`,urlFromEnvReadOnly:`Wert wird über HA_URL Umgebungsvariable gesetzt (schreibgeschützt)`,tokenFromEnvReadOnly:`Wert wird über HA_TOKEN Umgebungsvariable gesetzt (schreibgeschützt)`,mqttConnectedTo:`Verbunden mit`,prometheusDescription:`Druckerdaten im Prometheus-Format bereitstellen`,noSmartPlugsTitle:`Keine Smart Plugs konfiguriert`,noSmartPlugsDescription:`Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.`,noProvidersTitle:`Keine Anbieter konfiguriert`,noProvidersDescription:`Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.`,noTemplatesAvailable:`Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.`,apiPermissionView:`Druckerstatus und Warteschlange anzeigen`,apiPermissionEdit:`Elemente zur Druckwarteschlange hinzufügen und entfernen`,apiKeysEmptyTitle:`Keine API-Schlüssel`,apiKeysEmptyDescription:`Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.`,noUsersFound:`Keine Benutzer gefunden`,noGroupsFound:`Keine Gruppen gefunden`,noGroupsAvailable:`Keine Gruppen verfügbar`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,systemGroupWarning:`System-Gruppennamen können nicht geändert werden`,authDisabledTitle:`Authentifizierung ist deaktiviert`,authDisabledFeature1:`Anmeldung zum Zugriff auf das System erforderlich`,authDisabledFeature2:`Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen`,authDisabledFeature3:`Zugriff mit über 50 granularen Berechtigungen steuern`,userHasCreated:`Dieser Benutzer hat erstellt:`,userItemsQuestion:`Was möchten Sie mit diesen Elementen tun?`,deleteUserConfirm:`Möchten Sie diesen Benutzer wirklich löschen?`,actionCannotBeUndone:`Diese Aktion kann nicht rückgängig gemacht werden.`,addFirstSmartPlug:`Ersten Smart Plug hinzufügen`,providers:`Anbieter`,log:`Protokoll`,testAll:`Alle testen`,testResults:`Testergebnisse`,testPassedCount:`{{count}} bestanden`,testFailedCount:`{{count}} fehlgeschlagen`,messageTemplates:`Nachrichtenvorlagen`,messageTemplatesDescription:`Passen Sie Benachrichtigungen für jedes Ereignis an.`,apiKeys:`API-Schlüssel`,apiKeysDescription:`Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.`,createKey:`Schlüssel erstellen`,apiKeyCreated:`API-Schlüssel erfolgreich erstellt`,apiKeyCopyWarning:`Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!`,useInApiBrowser:`Im API-Browser verwenden`,apiKeyQrButton:`QR-Code`,apiKeyQrTitle:`Zum Einrichten scannen`,apiKeyQrCaption:`Mit deiner mobilen App scannen, um diesen Server und API-Schlüssel hinzuzufügen.`,apiKeyQrWarning:`Enthält deinen geheimen API-Schlüssel – nicht teilen oder dort abfotografieren, wo andere ihn sehen können.`,createNewApiKey:`Neuen API-Schlüssel erstellen`,keyName:`Schlüsselname`,keyNamePlaceholder:`z.B. Home Assistant, OctoPrint`,readStatus:`Status lesen`,readStatusDescription:`Druckerstatus und Warteschlange anzeigen`,manageQueue:`Warteschlange verwalten`,manageQueueDescription:`Elemente zur Druckwarteschlange hinzufügen und entfernen`,controlPrinter:`Drucker steuern`,controlPrinterDescription:`Drucke pausieren, fortsetzen und stoppen`,manageLibrary:`Bibliothek verwalten`,manageLibraryDescription:`Bibliotheksdateien hochladen, umbenennen und löschen; Modelle aus MakerWorld importieren`,manageInventory:`Bestand verwalten`,manageInventoryDescription:`Spulen und Bestandseinträge anlegen, ändern und löschen. Erforderlich für SpoolBuddy-Kioske (NFC-Scan, Waagenmessungen, Kiosk-Systembefehle).`,libraryBadge:`Bibliothek`,inventoryBadge:`Bestand`,cloudAccess:`Cloud-Zugriff erlauben`,cloudAccessDescription:`Liest Bambu-Cloud-Presets und -Filamente in Ihrem Namen. Erfordert eine Anmeldung in Bambu Cloud.`,cloudBadge:`Cloud`,updateEnergyCost:`Strompreis aktualisieren`,updateEnergyCostDescription:`Erlaubt diesem Schlüssel, einen neuen Strompreis pro kWh an /settings/electricity-price zu senden. Nützlich für Home-Assistant-Automatisierungen mit dynamischen Tarifen (Tibber, Octopus usw.). Dies ist das einzige Einstellungsfeld, das per API-Schlüssel schreibbar ist.`,energyCostBadge:`Energie`,legacyKey:`Alt`,legacyKeyTooltip:`Wurde vor der nutzerbezogenen Eigentümerschaft erstellt; neu erstellen, um Cloud-Zugriff zu nutzen`,unnamedKey:`Unbenannter Schlüssel`,lastUsed:`Zuletzt verwendet`,read:`Lesen`,control:`Steuern`,createFirstKey:`Ersten Schlüssel erstellen`,webhookEndpoints:`Webhook-Endpunkte`,webhookApiKeyHint:`Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.`,webhook:{getAllStatus:`Alle Druckerstatus abrufen`,getSpecificStatus:`Spezifischen Druckerstatus abrufen`,addToQueue:`Zur Druckwarteschlange hinzufügen`,pausePrint:`Druck pausieren`,resumePrint:`Druck fortsetzen`,stopPrint:`Druck stoppen`},apiBrowser:`API-Browser`,apiBrowserDescription:`Erkunden und testen Sie alle verfügbaren API-Endpunkte.`,apiKeyForTesting:`API-Schlüssel zum Testen`,apiKeyPlaceholder:`Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...`,apiKeyHint:`Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.`,deleteApiKeyTitle:`API-Schlüssel löschen`,deleteApiKeyMessage:`Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.`,deleteKey:`Schlüssel löschen`,amsDisplayThresholds:`AMS-Anzeigeschwellenwerte`,amsThresholdsDescription:`Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.`,humidity:`Luftfeuchtigkeit`,goodGreen:`Gut (grün)`,fairOrange:`Mittel (orange)`,aboveFairBad:`Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)`,fairAlsoDryingThreshold:`Dieser Schwellenwert wird auch für die automatische Trocknung verwendet`,temperature:`Temperatur`,goodBlue:`Gut (blau)`,aboveFairHot:`Über dem mittleren Schwellenwert wird rot angezeigt (heiß)`,historyRetention:`Verlaufsaufbewahrung`,keepSensorHistory:`Sensorverlauf behalten für`,historyRetentionDescription:`Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht`,defaultPrintOptions:`Standard-Druckoptionen`,defaultPrintOptionsDescription:`Standardwerte für Druckoptionen bei neuen Drucken festlegen. Diese können im Druckdialog pro Druck überschrieben werden.`,defaultBedLevelling:`Bett-Nivellierung`,defaultBedLevellingDesc:`Bett vor dem Druck automatisch nivellieren`,defaultFlowCali:`Fluss-Kalibrierung`,defaultFlowCaliDesc:`Extrusionsfluss kalibrieren`,defaultVibrationCali:`Vibrationskalibrierung`,defaultVibrationCaliDesc:`Ringing-Artefakte reduzieren`,defaultLayerInspect:`Erste-Schicht-Inspektion`,defaultLayerInspectDesc:`KI-Inspektion der ersten Schicht`,defaultTimelapse:`Zeitraffer`,defaultTimelapseDesc:`Zeitraffervideo aufnehmen`,defaultNozzleOffsetCali:`Düsenversatz-Kalibrierung`,defaultNozzleOffsetCaliDesc:`Düsenversatz zwischen Extrudern kalibrieren`,tempFanPresetsTitle:`Temperatur- und Lüfter-Vorgaben`,tempFanPresetsDescription:`Passen Sie die Schnellwahlwerte in den Temperatur- und Lüfter-Popovers der Druckerkarte an. Die Aus-Schaltfläche wird immer angezeigt.`,tempFanPresetsNozzle:`Düsentemperatur`,tempFanPresetsBed:`Betttemperatur`,tempFanPresetsChamber:`Kammertemperatur`,tempFanPresetsFan:`Lüftergeschwindigkeit`,tempFanPresetsReset:`Auf Standardwerte zurücksetzen`,staggeredStart:`Versetzter Start`,staggeredStartDescription:`Standard-Gruppengröße und -Intervall beim Staffeln von Mehrdrucker-Batchstarts. Pro Batch im Druck-Dialog überschreibbar.`,plateClear:`Druckplatte-Bestätigung`,requirePlateClear:`Druckplatte-Bestätigung erforderlich`,requirePlateClearDescription:`Wenn aktiviert, wartet der Scheduler auf eine Druckplatten-Bestätigung pro Drucker, bevor geplante Drucke auf Druckern mit abgeschlossenen Aufträgen gestartet werden. Wenn dies deaktiviert ist, werden auch das Druckplatten-Status-Badge und die Schaltfläche "Druckplatte als freigegeben markieren" auf den Druckerkarten ausgeblendet.`,gcodeInjection:`G-Code-Injektion`,gcodeInjectionDescription:`Konfigurieren Sie benutzerdefinierten G-code, der am Anfang und/oder Ende von Drucken für Auto-Print-Systeme wie Farmloop, SwapMod, AutoClear und Printflow 3D eingefügt wird. Snippets werden pro Druckermodell konfiguriert und angewendet, wenn "G-code einfügen" bei einem Warteschlangen-Element aktiviert ist.`,gcodeInjectionNoPrinters:`Keine Drucker gefunden. Fügen Sie Drucker hinzu, um G-code-Snippets zu konfigurieren.`,gcodeStartLabel:`Start-G-Code`,gcodeEndLabel:`End-G-Code`,gcodeStartPlaceholder:`G-code, der vor dem Druckstart eingefügt wird...`,gcodeEndPlaceholder:`G-code, der nach dem Druckende angefügt wird...`,staggerGroupSize:`Gruppengröße`,staggerGroupSizeHelp:`Anzahl gleichzeitig zu startender Drucker pro Gruppe`,staggerInterval:`Intervall (Minuten)`,staggerIntervalHelp:`Verzögerung zwischen Gruppenstart`,queueDrying:`Automatische Trocknung`,queueDryingDescription:`AMS-Filament automatisch trocknen, wenn der Drucker zwischen Warteschlangen-Drucken im Leerlauf ist. Verwendet den Feuchtigkeitsschwellenwert oben.`,queueDryingEnabled:`Automatische Trocknung aktivieren`,queueDryingEnabledDescription:`AMS-Trocknung automatisch starten, wenn der Drucker im Leerlauf ist und die Feuchtigkeit über dem Schwellenwert liegt`,queueDryingBlock:`Auf Trocknung warten`,queueDryingBlockDescription:`Druckwarteschlange blockieren, bis die Trocknung abgeschlossen ist. Wenn aus, haben Drucke Vorrang.`,ambientDryingEnabled:`Umgebungstrocknung`,ambientDryingEnabledDescription:`Filament auf inaktiven Druckern automatisch trocknen, wenn die Luftfeuchtigkeit den Schwellenwert überschreitet — auch ohne Warteschlange.`,dryingPresets:`Trocknungsvoreinstellungen`,dryingPresetsDescription:`Temperatur und Dauer pro Filamenttyp. AMS 2 Pro verwendet niedrigere Temperaturen, AMS-HT unterstützt höhere.`,dryingFilament:`Filament`,humidityThresholds:`Feuchtigkeitsschwellen`,humidityThresholdsDescription:`Feuchtigkeitsauslöser pro Filamenttyp für Auto-Trocknung und Alarme. Bei gemischter Bestückung gilt der niedrigste Wert.`,humidityThresholdCol:`Schwellenwert`,humidityThresholdDefault:`Standard (unbekannte Typen)`,printModal:`Druckdialog`,expandCustomMapping:`Benutzerdefinierte Zuordnung standardmäßig erweitern`,expandCustomMappingDescription:`Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen`,authentication:`Authentifizierung`,authEnabledDescription:`Ihre Instanz ist mit Benutzerauthentifizierung gesichert`,authDisabledDescription:`Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff`,authDisabledMessage:`Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.`,enableAuthentication:`Authentifizierung aktivieren`,currentUser:`Aktueller Benutzer`,changePassword:`Passwort ändern`,admin:`Admin`,users:`Benutzer`,addUser:`Benutzer hinzufügen`,groups:`Gruppen`,addGroup:`Gruppe hinzufügen`,system:`System`,noDescription:`Keine Beschreibung`,userCount:`{{count}} Benutzer`,permissionCount:`{{count}} Berechtigungen`,createUser:`Benutzer erstellen`,username:`Benutzername`,enterUsername:`Benutzername eingeben`,password:`Passwort`,enterPassword:`Passwort eingeben`,passwordRequirements:`Mindestens 8 Zeichen, davon ein Großbuchstabe, ein Kleinbuchstabe, eine Ziffer und ein Sonderzeichen.`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Passwort bestätigen`,viewReleaseOnGitHub:`Release auf GitHub anzeigen`,turnAllPlugsOn:`Alle Stecker einschalten`,turnAllPlugsOff:`Alle Stecker ausschalten`,clearNotificationLogs:`Benachrichtigungsprotokolle löschen`,clearLogsMessage:`Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.`,clearLogs:`Protokolle löschen`,resetUiPreferences:`UI-Einstellungen zurücksetzen`,resetUiPreferencesMessage:`Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.`,resetPreferences:`Einstellungen zurücksetzen`,deleteGroupTitle:`Gruppe löschen`,deleteGroupMessage:`Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.`,deleteGroup:`Gruppe löschen`,disableAuthenticationTitle:`Authentifizierung deaktivieren`,disableAuthenticationMessage:`Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.`,disableAuthentication:`Authentifizierung deaktivieren`,configureBambuddy:`Bambuddy konfigurieren`,systemDefault:`Systemstandard`,archiveSettings:`Archiv-Einstellungen`,newWindow:`Neues Fenster`,embeddedOverlay:`Eingebettetes Overlay`,preferredSlicer:`Bevorzugter Slicer`,preferredSlicerDescription:`Slicer für das In-App-Slicen über das API-Sidecar`,openInSlicerLabel:`Im Slicer öffnen`,openInSlicerInherit:`Wie API-Slicer`,openInSlicerDescription:`Desktop-Slicer, der vom „Im Slicer öffnen"-Button verwendet wird. Auf „Wie API-Slicer" belassen, um zu erben, oder einen anderen Slicer für die lokale Nutzung wählen.`,orcaslicerKnownIssuesWarning:`OrcaSlicer 2.3.2 / 2.4.0-dev haben bekannte CLI-Bugs, die das Slicen vieler von BambuStudio erstellter 3MF-Dateien blockieren — siehe Upstream-Issues #12426 (Segfault bei bemalten Multi-Extruder-Dateien) und #13386 (zu strikte Parameter-Range-Validierung). Bis die Upstream-Fixes verfügbar sind, wird Bambu Studio empfohlen.`,useSlicerApi:`Slicer-API verwenden`,useSlicerApiDescription:`Wenn aktiv, öffnen "Slice"-Aktionen das in-App Slicer-Modal und rufen den Slicer-API-Sidecar. Aus (Standard): Übergabe an den Desktop-Slicer per URI-Schema.`,slicerCard:`Slicer`,orcaslicerApiUrl:`OrcaSlicer Sidecar-URL`,bambuStudioApiUrl:`Bambu Studio Sidecar-URL`,slicerApiUrlDescription:`URL des Slicer-API-Sidecar-Containers. Leer lassen, um die SLICER_API_URL- bzw. BAMBU_STUDIO_API_URL-Umgebungsvariablen zu nutzen.`,slicerBundlesRemoved:{title:`Slicer-Bundles (entfernt)`,description:`Der Import von Drucker-Voreinstellungs-Bundles (.bbscfg) wurde entfernt. Der Bundle-Export von BambuStudio enthält nur benutzerdefinierte Voreinstellungen, daher lieferte der Import nie die Standard-Prozesse / -Filamente, und das Slicen fiel auf eingebettete Einstellungen zurück.`,alternatives:`Verwende Einzel-Voreinstellungs-Import für individuelle Anpassungen oder synchronisiere via Bambu Cloud / Orca Cloud. Standard-Voreinstellungen kommen automatisch vom Slicer-Sidecar.`,lookupOrder:`Reihenfolge der Voreinstellungssuche beim Slicen: 1) Importiert (lokal), 2) Orca Cloud, 3) Bambu Cloud, 4) Standard (Sidecar-Fallback).`},externalCameras:`Externe Kameras`,costTracking:`Kostenverfolgung`,printsOnly:`Nur Drucke`,totalConsumption:`Gesamtverbrauch`,dataManagement:`Datenverwaltung`,storageUsage:`Speichernutzung`,storageUsageDescription:`Aufschlüsselung der Datennutzung nach Kategorie`,storageUsageTotal:`Gesamt`,storageUsageErrors:`Fehler`,storageUsageOtherBreakdown:`Sonstiges (enthält statische Assets, Skripte und Konfigurationsdateien)`,storageUsageSystem:`System`,storageUsageData:`Daten`,storageUsageUnavailable:`Speichernutzungsinformationen nicht verfügbar`,clearNotificationLogsDescription:`Benachrichtigungsprotokolle älter als 30 Tage löschen`,resetUiPreferencesDescription:`Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.`,enableHomeAssistant:`Home Assistant aktivieren`,enableMqtt:`MQTT aktivieren`,useTls:`TLS verwenden`,enableMetricsEndpoint:`Metrik-Endpunkt aktivieren`,availableMetrics:`Verfügbare Metriken`,editUser:`Benutzer bearbeiten`,deleteUserTitle:`Benutzer löschen`,groupName:`Gruppenname`,leaveEmptyForAnonymous:`Leer lassen für anonym`,leaveEmptyForNoAuth:`Leer lassen für keine Authentifizierung`,enterNewPassword:`Neues Passwort eingeben`,confirmNewPassword:`Neues Passwort bestätigen`,enterGroupName:`Gruppenname eingeben`,enterDescriptionOptional:`Beschreibung eingeben (optional)`,enterCurrentPassword:`Aktuelles Passwort eingeben`,enterNewPasswordMin6:`Neues Passwort eingeben (min. 6 Zeichen)`,toast:{keyCopied:`Schlüssel in Zwischenablage kopiert`,copyFailed:`Schlüssel konnte nicht kopiert werden`,keyAddedToBrowser:`Schlüssel zum API-Browser hinzugefügt`,clearLogsFailed:`Protokolle konnten nicht gelöscht werden`,uiPreferencesReset:`UI-Einstellungen zurückgesetzt. Wird neu geladen...`,authDisabled:`Authentifizierung erfolgreich deaktiviert`,authDisableFailed:`Authentifizierung konnte nicht deaktiviert werden`,apiKeyCreated:`API-Schlüssel erstellt`,apiKeyDeleted:`API-Schlüssel gelöscht`,userCreated:`Benutzer erfolgreich erstellt`,userUpdated:`Benutzer erfolgreich aktualisiert`,userDeleted:`Benutzer erfolgreich gelöscht`,groupCreated:`Gruppe erfolgreich erstellt`,groupUpdated:`Gruppe erfolgreich aktualisiert`,groupDeleted:`Gruppe erfolgreich gelöscht`,fillRequiredFields:`Bitte füllen Sie alle erforderlichen Felder aus`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 8 Zeichen lang sein`,passwordNeedsUppercase:`Passwort muss mindestens einen Großbuchstaben enthalten`,passwordNeedsLowercase:`Passwort muss mindestens einen Kleinbuchstaben enthalten`,passwordNeedsDigit:`Passwort muss mindestens eine Ziffer enthalten`,passwordNeedsSpecial:`Passwort muss mindestens ein Sonderzeichen enthalten`,enterGroupName:`Bitte geben Sie einen Gruppennamen ein`,settingsSaved:`Einstellungen gespeichert`,noPermissionUpdate:`Sie haben keine Berechtigung, Einstellungen zu ändern`,cameraSettingsSaved:`Kamera-Einstellungen gespeichert`,enterCameraUrl:`Bitte geben Sie eine Kamera-URL ein`,passwordChanged:`Passwort erfolgreich geändert`,connectionFailed:`Verbindung fehlgeschlagen`,testFailed:`Test fehlgeschlagen`,cameraConnected:`Kamera verbunden{{resolution}}`},testConnection:`Verbindung testen`,catalog:{spoolCatalog:`Spulenkatalog`,spoolCatalogDescription:`Leerspulengewichte nach Marke/Typ. Wird für die automatische Gewichtssuche beim Hinzufügen von Spulen verwendet.`,searchCatalog:`Katalog durchsuchen...`,addNewEntry:`Neuen Eintrag hinzufügen`,namePlaceholder:`Name (z.B. Bambu Lab - Plastik)`,weight:`Gewicht`,type:`Typ`,default:`Standard`,custom:`Benutzerdefiniert`,noMatch:`Keine Einträge entsprechen Ihrer Suche`,empty:`Keine Einträge im Katalog`,deleteEntry:`Eintrag löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,resetCatalog:`Katalog zurücksetzen`,resetConfirm:`Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Einträge werden entfernt.`,loadFailed:`Spulenkatalog konnte nicht geladen werden`,nameWeightRequired:`Name und Gewicht sind erforderlich`,entryAdded:`Eintrag hinzugefügt`,addFailed:`Eintrag konnte nicht hinzugefügt werden`,entryUpdated:`Eintrag aktualisiert`,updateFailed:`Eintrag konnte nicht aktualisiert werden`,entryDeleted:`Eintrag gelöscht`,deleteFailed:`Eintrag konnte nicht gelöscht werden`,resetSuccess:`Katalog auf Standardwerte zurückgesetzt`,resetFailed:`Katalog konnte nicht zurückgesetzt werden`,exported:`{{count}} Einträge exportiert`,imported:`{{added}} Einträge importiert ({{skipped}} übersprungen)`,importFailed:`Import fehlgeschlagen: ungültiges JSON-Format`,exportTooltip:`Katalog als JSON exportieren`,importTooltip:`Katalog aus JSON importieren`,resetTooltip:`Auf Standardwerte zurücksetzen`,selectedCount:`{{count}} ausgewählt`,deleteSelected:`Ausgewählte löschen`,bulkDeleteConfirm:`Möchten Sie {{count}} Einträge wirklich löschen?`,bulkDeleted:`{{count}} Einträge gelöscht`,bulkDeleteFailed:`Fehler beim Löschen der Einträge`,material:`Material`,spoolWeight:`Spulengewicht`,color:`Farbe`,updateSpoolWeight:`Spulengewicht aktualisieren`,filamentUpdated:`Filament aktualisiert`,filamentUpdateFailed:`Filament konnte nicht aktualisiert werden`,filamentUpdateInvalid:`Ungültige Filamentdaten`,keepExistingSpoolWeight:`Altes Gewicht für bestehende Spulen behalten`,keepExistingSpoolWeightDesc:`Bereits erstellte Spulen dieses Filamenttyps behalten das alte Leergewicht. Neue Spulen nutzen den neuen Wert.`,applyToAllSpools:`Auf alle Spulen anwenden`,applyToAllSpoolsDesc:`Alle Gewichtsberechnungen für diesen Filamenttyp nutzen sofort das neue Leergewicht.`},colorCatalog:{title:`Farbkatalog`,description:`Filamentfarben nach Hersteller/Material. Wird für die automatische Farbsuche beim Hinzufügen von Spulen verwendet.`,searchColors:`Farben durchsuchen...`,allManufacturers:`Alle Hersteller`,addNewColor:`Neue Farbe hinzufügen`,manufacturer:`Hersteller`,colorName:`Farbname`,hex:`Hex`,materialOptional:`Material (optional)`,showing:`{{filtered}} von {{total}} Farben angezeigt`,noMatch:`Keine Farben entsprechen Ihrer Suche`,empty:`Keine Farben im Katalog`,deleteColor:`Farbe löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,resetCatalog:`Farbkatalog zurücksetzen`,resetConfirm:`Katalog auf Standardwerte zurücksetzen? Alle benutzerdefinierten Farben werden entfernt.`,sync:`Synchron.`,starting:`Starten...`,syncTooltip:`Von FilamentColors.xyz synchronisieren (2000+ Farben)`,loadFailed:`Farbkatalog konnte nicht geladen werden`,fieldsRequired:`Hersteller, Farbname und Hex-Farbe sind erforderlich`,colorAdded:`Farbe hinzugefügt`,addFailed:`Farbe konnte nicht hinzugefügt werden`,colorUpdated:`Farbe aktualisiert`,updateFailed:`Farbe konnte nicht aktualisiert werden`,colorDeleted:`Farbe gelöscht`,deleteFailed:`Farbe konnte nicht gelöscht werden`,resetSuccess:`Farbkatalog auf Standardwerte zurückgesetzt`,resetFailed:`Katalog konnte nicht zurückgesetzt werden`,syncUpToDate:`Bereits aktuell ({{count}} Farben geprüft)`,syncComplete:`{{added}} neue Farben hinzugefügt ({{skipped}} bereits vorhanden)`,syncError:`Sync-Fehler`,syncFailed:`Synchronisierung von FilamentColors.xyz fehlgeschlagen`,exported:`{{count}} Farben exportiert`,imported:`{{added}} Farben importiert ({{skipped}} übersprungen)`,importFailed:`Import fehlgeschlagen: ungültiges JSON-Format`,selectedCount:`{{count}} ausgewählt`,deleteSelected:`Ausgewählte löschen`,bulkDeleteConfirm:`Möchten Sie {{count}} Farben wirklich löschen?`,bulkDeleted:`{{count}} Farben gelöscht`,bulkDeleteFailed:`Fehler beim Löschen der Farben`},dateFormat:`Datumsformat`,dateFormatUs:`US (MM/TT/JJJJ)`,dateFormatEu:`EU (TT/MM/JJJJ)`,dateFormatIso:`ISO (JJJJ-MM-TT)`,timeFormat:`Zeitformat`,timeFormat12:`12-Stunden (3:30 PM)`,timeFormat24:`24-Stunden (15:30)`,defaultPrinter:`Standarddrucker`,defaultPrinterDescription:`Diesen Drucker für Uploads, Nachdrucke und andere Vorgänge vorauswählen.`,slicerBambuStudio:`Bambu Studio`,slicerOrcaSlicer:`OrcaSlicer`,sidebarOrderDescription:`Nutze das Seitenleisten-Layout, um Elemente neu anzuordnen, Sichtbarkeit zurückzusetzen und benutzerdefinierte Links zu verwalten.`,setDefault:`Standard setzen`,sidebarOrderSetDefaultHint:`Standard setzen übernimmt die aktuelle Menüreihenfolge für Benutzer, die ihre noch nicht angepasst haben.`,sidebarDefaultSet:`Standard-Menüreihenfolge wurde festgelegt.`,sidebarDefaultCleared:`Standard-Menüreihenfolge gelöscht.`,sidebarDefaultFailed:`Festlegen der Standard-Menüreihenfolge fehlgeschlagen.`,reset:`Zurücksetzen`,darkMode:`Dunkelmodus`,lightMode:`Hellmodus`,active:`(aktiv)`,background:`Hintergrund`,accent:`Akzent`,style:`Stil`,bgNeutral:`Neutral`,bgWarm:`Warm`,bgCool:`Kühl`,bgOled:`OLED Schwarz`,bgSlate:`Schieferblau`,bgForest:`Waldgrün`,accentGreen:`Grün`,accentTeal:`Türkis`,accentBlue:`Blau`,accentOrange:`Orange`,accentPurple:`Lila`,accentRed:`Rot`,styleClassic:`Klassisch`,styleGlow:`Leuchtend`,styleVibrant:`Lebendig`,themeToggleHint:`Zwischen Dunkel-, Hell- und Systemmodus mit dem Symbol in der Seitenleiste wechseln.`,autoArchivePrints:`Drucke automatisch archivieren`,autoArchiveDescription:`3MF-Dateien automatisch speichern, wenn Drucke abgeschlossen sind`,saveThumbnailsDescription:`Vorschaubilder aus 3MF-Dateien extrahieren und speichern`,captureFinishPhotoDescription:`Foto von der Druckerkamera aufnehmen, wenn der Druck abgeschlossen ist. Bambuddy zeichnet während des Drucks einen kurzen Zeitraffer auf, damit das Foto aus dem Moment vor dem Absenken der Druckplatte stammen kann. Die Zeitraffer-Datei bleibt erhalten, wenn du den Zeitraffer für diesen Druck aktiviert hast, andernfalls wird sie nach Aufnahme des Fotos automatisch gelöscht.`,ffmpegNotInstalled:`ffmpeg nicht installiert`,ffmpegRequired:`Kameraaufnahme benötigt ffmpeg. Installieren über brew install ffmpeg (macOS) oder apt install ffmpeg (Linux).`,camera:`Kamera`,cameraViewMode:`Kamera-Ansichtsmodus`,cameraOverlayDescription:`Kamera öffnet sich als größenveränderbares Overlay auf dem Hauptbildschirm`,cameraWindowDescription:`Kamera öffnet sich in einem separaten Browserfenster`,externalCamerasDescription:`Externe Kameras konfigurieren, um die eingebaute Druckerkamera zu ersetzen. Unterstützt MJPEG-Streams, RTSP, HTTP-Snapshots und USB-Kameras (V4L2). Wenn aktiviert, wird die externe Kamera für Live-Ansicht und Abschlussfotos verwendet.`,cameraPlaceholderUsb:`Gerätepfad (/dev/video0)`,cameraPlaceholderUrl:`Kamera-URL (rtsp://... oder http://...)`,cameraTypeMjpeg:`MJPEG-Stream`,cameraTypeRtsp:`RTSP-Stream`,cameraTypeSnapshot:`HTTP-Snapshot`,cameraTypeUsb:`USB-Kamera (V4L2)`,cameraSnapshotUrl:`Snapshot-URL (optional)`,cameraSnapshotUrlPlaceholder:`http://192.168.1.61:1984/api/frame.jpeg?src=printer`,cameraSnapshotUrlHelp:`URL für Einzelbildaufnahmen — wird für Benachrichtigungs-Vorschaubilder, Abschlussfotos, Schicht-Zeitraffer und Plattenerkennung verwendet. Zeitraffer und Plattenerkennung benötigen jeweils eigene drucker-spezifische Schalter — diese URL ist nur die Bildquelle, die sie verwenden, wenn sie aktiv sind. Leer lassen, um Bilder aus dem oben konfigurierten Live-Stream zu verwenden. Nützlich für go2rtc (/api/frame.jpeg) und IP-Kameras mit dediziertem Snapshot-Endpunkt.`,cameraRotation:`Drehung`,test:`Testen`,connected:`Verbunden`,disconnected:`Getrennt`,currency:`Währung`,defaultFilamentCost:`Standard-Filamentkosten (pro kg)`,electricityCost:`Stromkosten pro kWh`,energyDisplayMode:`Energieanzeige-Modus`,energyModePrintDescription:`Dashboard zeigt Summe der während Drucken verbrauchten Energie`,energyModeTotalDescription:`Dashboard zeigt Gesamtenergie der Smart Plugs`,fileManager:`Dateimanager`,createArchiveEntry:`Archiveintrag beim Drucken erstellen`,createArchiveEntryDescription:`Beim Drucken aus dem Dateimanager optional einen Archiveintrag erstellen`,lowDiskSpaceWarning:`Warnung bei wenig Speicherplatz`,lowDiskSpaceDescription:`Warnung anzeigen, wenn freier Speicherplatz unter diesen Schwellenwert fällt`,printerFirmware:`Drucker-Firmware`,checkFirmwareDescription:`Nach Firmware-Updates von Bambu Lab suchen`,bambuddySoftware:`Bambuddy-Software`,autoCheckDescription:`Automatisch beim Start nach neuen Versionen suchen`,checkNow:`Jetzt prüfen`,updateAvailableVersion:`Update verfügbar: v{{version}}`,releaseNotes:`Versionshinweise`,updateViaDocker:`Update über Docker Compose:`,updateViaHomeAssistant:`Updates werden vom Home Assistant Supervisor verwaltet. Öffne Einstellungen → Add-ons → Bambuddy in Home Assistant, um die neue Version zu installieren.`,updateViaWindowsInstaller:`Windows-Installationen werden durch erneutes Ausführen des Installers aktualisiert. Lade die neue Version unten herunter — deine Daten, Einstellungen und Drucker bleiben erhalten.`,downloadWindowsInstaller:`Installer für v{{version}} herunterladen`,installUpdate:`Update installieren`,latestVersionRunning:`Sie verwenden die neueste Version`,failedToCheckUpdates:`Update-Prüfung fehlgeschlagen: {{error}}`,backupRestore:`Sicherung & Wiederherstellung`,backupRestoreDescription:`Einstellungen exportieren/importieren und GitHub-Backup konfigurieren`,goToBackup:`Zur Sicherung`,externalUrl:`Externe URL`,externalUrlDescription:`Die externe URL, unter der Bambuddy erreichbar ist. Wird für Benachrichtigungsbilder und externe Integrationen verwendet.`,bambuddyUrl:`Bambuddy-URL`,externalUrlHint:`Protokoll und Port angeben (z.B. http://192.168.1.100:8000)`,ftpRetry:`FTP-Wiederholung`,ftpRetryDescription:`FTP-Operationen bei unzuverlässigem Drucker-WLAN wiederholen. Gilt für 3MF-Downloads, Druck-Uploads, Zeitraffer-Downloads und Firmware-Updates.`,autoRetryDescription:`Fehlgeschlagene FTP-Operationen automatisch wiederholen`,retryAttempts:`Wiederholungsversuche`,retryDelay:`Wiederholungsverzögerung`,connectionTimeout:`Verbindungs-Timeout`,time_one:`{{count}} Mal`,time_other:`{{count}} Mal`,second_one:`{{count}} Sekunde`,second_other:`{{count}} Sekunden`,nSeconds:`{{count}} Sekunden`,increaseForWeakWifi:`Erhöhen für Drucker mit schwachem WLAN`,homeAssistant:`Home Assistant`,homeAssistantFullDescription:`Mit Home Assistant verbinden, um Smart Plugs über die HA REST-API zu steuern. Unterstützt Switch-, Light-, Input_Boolean- und Script-Entitäten.`,homeAssistantUrl:`Home Assistant URL`,longLivedAccessToken:`Langlebiges Zugriffstoken`,haTokenHint:`Token in HA erstellen: Profil → Langlebige Zugriffstoken → Token erstellen`,connectionSuccessful:`Verbindung erfolgreich`,connectionFailed:`Verbindung fehlgeschlagen`,haConnectionSuccess:`Erfolgreich mit Home Assistant verbunden.`,haConnectionFailed:`Verbindung zu Home Assistant fehlgeschlagen.`,mqttPublishing:`MQTT-Veröffentlichung`,mqttDescription:`BamBuddy-Ereignisse an einen externen MQTT-Broker zur Integration mit Node-RED, Home Assistant und anderen Automatisierungssystemen veröffentlichen.`,mqttEnableDescription:`Ereignisse an externen MQTT-Broker veröffentlichen`,brokerHostname:`Broker-Hostname`,port:`Port`,usernameOptional:`Benutzername (optional)`,passwordOptional:`Passwort (optional)`,topicPrefix:`Topic-Präfix`,topicPrefixHint:`Topics werden sein: {{prefix}}/printers//status, etc.`,prometheusMetrics:`Prometheus-Metriken`,prometheusEndpointDescription:`Druckermetriken unter /api/v1/metrics für Prometheus/Grafana-Überwachung bereitstellen.`,bearerTokenOptional:`Bearer-Token (optional)`,bearerTokenHint:`Wenn gesetzt, müssen Anfragen Authorization: Bearer enthalten`,metricsConnectionStatus:`Verbindungsstatus`,metricsPrinterState:`Druckerstatus (idle/printing/etc)`,metricsPrintProgress:`Druckfortschritt 0-100%`,metricsBedTemp:`Betttemperatur`,metricsNozzleTemp:`Düsentemperatur`,metricsPrintsTotal:`Gesamtdrucke nach Ergebnis`,metricsMore:`...und mehr (Schichten, Lüfter, Warteschlange, Filamentverbrauch)`,smartPlugsDescription:`Smart Plugs (Tasmota oder Home Assistant) verbinden, um Stromsteuerung zu automatisieren und Energieverbrauch für Ihre Drucker zu verfolgen.`,allOn:`Alle Ein`,allOff:`Alle Aus`,addSmartPlug:`Smart Plug hinzufügen`,energySummary:`Energieübersicht`,currentPower:`Aktuelle Leistung`,plugsOnline:`{{reachable}}/{{total}} Plugs online`,today:`Heute`,yesterday:`Gestern`,total:`Gesamt`,enablePlugsForSummary:`Plugs aktivieren, um Energieübersicht zu sehen`,addNotificationProvider:`Hinzufügen`,systemBadge:`(System)`,creating:`Erstellen...`,changing:`Ändern...`,deleteUserAndItems:`Benutzer UND dessen Elemente löschen`,deleteUserKeepItems:`Benutzer löschen, Elemente behalten (werden herrenlos)`,ok:`OK`,twoFa:{totpTitle:`Authenticator-App (TOTP)`,totpDesc:`Verwende eine Authenticator-App wie Google Authenticator, Aegis oder Authy.`,emailOtpTitle:`E-Mail OTP`,emailOtpDesc:`Sende einen Einmalcode an {{email}} beim Einloggen.`,emailOtpNoEmail:`Füge eine E-Mail-Adresse zu deinem Konto hinzu, um diese Methode zu aktivieren.`,addEmailFirst:`Dein Konto hat keine E-Mail-Adresse. Bitte einen Administrator, eine hinzuzufügen.`,setupTotp:`Authenticator-App einrichten`,setupAuthApp:`Authenticator-App einrichten`,setupInstructions:`Scanne den QR-Code mit deiner Authenticator-App und bestätige mit einem Code.`,manualEntry:`Kein Scanner? Gib dieses Secret manuell ein:`,scannedContinue:`Code gescannt — weiter`,enterCodeToConfirm:`Gib den 6-stelligen Code aus deiner Authenticator-App ein, um die Einrichtung zu bestätigen.`,activate:`Aktivieren`,disableTotp:`Authenticator deaktivieren`,disableConfirmHint:`Gib einen gültigen TOTP-Code oder einen Backup-Code ein, um den Authenticator zu deaktivieren.`,totpDisabled:`Authenticator-App deaktiviert.`,emailOtpEnabled:`E-Mail OTP aktiviert.`,emailOtpDisabled:`E-Mail OTP deaktiviert.`,smtpRequired:`Bitte konfigurieren und testen Sie zuerst die SMTP-Einstellungen.`,invalidCode:`Ungültiger Code. Bitte erneut versuchen.`,enableEmailOtp:`E-Mail OTP aktivieren`,disableEmailOtp:`E-Mail OTP deaktivieren`,emailSetupEnterCode:`Ein Bestätigungscode wurde an Ihre E-Mail-Adresse gesendet. Geben Sie ihn unten ein, um zu bestätigen, dass Ihnen dieses Postfach gehört.`,verifyAndEnable:`Verifizieren & Aktivieren`,emailDisablePasswordHint:`Geben Sie Ihr Kontopasswort ein, um die Deaktivierung des E-Mail OTP zu bestätigen.`,passwordPlaceholder:`Passwort eingeben`,backupCodesTitle:`Backup-Codes sichern`,backupCodesWarning:`Speichere diese Codes sicher. Jeder Code kann nur einmal verwendet werden und wird nicht erneut angezeigt.`,backupCodesRemaining:`{{count}} Backup-Codes verbleibend`,savedCodes:`Codes gespeichert`,regenBackup:`Backup-Codes neu generieren`,regenBackupHint:`Gib deinen aktuellen TOTP-Code ein, um 10 neue Backup-Codes zu generieren. Alle bestehenden Codes werden ungültig.`,newBackupCodes:`Neue Backup-Codes`,linkedAccounts:`Verknüpfte SSO-Konten`,linkedAccountsDesc:`Diese externen Identitätsanbieter sind mit deinem Konto verknüpft.`,oidcUnlinked:`Konto getrennt.`},sessionPolicy:{title:`Sitzungsrichtlinie`,description:`Maximale Sitzungsdauer für neue Benutzeranmeldungen. Bereits ausgegebene Token behalten ihren ursprünglichen Ablauf.`,preset24h:`24 Stunden`,preset7d:`7 Tage`,preset30d:`30 Tage`,customHoursLabel:`Individuelle Sitzungsdauer in Stunden`,hoursSuffix:`Stunden`,warning:`Längere Sitzungen reduzieren den automatischen Abmeldeschutz. Nur für vertrauenswürdige Einzelnutzer-Installationen empfohlen.`},oidc:{title:`SSO / OIDC-Anbieter`,desc:`Konfiguriere OpenID Connect-Anbieter für Single Sign-On.`,addProvider:`Anbieter hinzufügen`,newProvider:`Neuer Anbieter`,empty:`Noch keine OIDC-Anbieter konfiguriert.`,created:`Anbieter erstellt.`,updated:`Anbieter aktualisiert.`,deleted:`Anbieter gelöscht.`,refreshIcon:`Icon neu laden`,removeIcon:`Icon entfernen`,iconRefreshed:`Icon aktualisiert.`,iconRemoved:`Icon entfernt.`,iconFetchFailed:`Icon konnte von der Anbieter-URL nicht geladen werden.`,deleteTitle:`Anbieter löschen`,deleteMessage:`"{{name}}" löschen? Alle verknüpften Benutzerkonten werden getrennt.`,form:{name:`Anzeigename`,issuerUrl:`Aussteller-URL`,clientId:`Client-ID`,clientSecret:`Client-Secret`,scopes:`Bereiche`,iconUrl:`Symbol-URL (optional)`,enabled:`Aktiviert`,autoCreate:`Benutzer automatisch anlegen`,autoCreateDesc:`Erstellt beim ersten Login automatisch ein lokales Konto.`,autoLink:`Bestehende Konten automatisch verknüpfen`,autoLinkDesc:`Verknüpft beim ersten Login vorhandene lokale Konten anhand der E-Mail-Adresse.`,secretHint:`leer lassen zum Beibehalten`,secretPlaceholder:`neues Secret`,emailClaim:`E-Mail-Claim`,emailClaimDesc:`JWT-Claim für die E-Mail-Identität. Für Azure Entra ID 'preferred_username' oder 'upn' verwenden (sendet kein email_verified). Nur vertrauenswürdige Claim-Namen verwenden.`,emailClaimPlaceholder:`E-Mail`,emailClaimCustomClaimAutoLinkWarning:`Benutzerdefinierte Claims sind für die Auto-Verknüpfung nur sicher, wenn der Wert vom Mandanten verwaltet wird (z. B. Azure Entra ID upn / preferred_username). Aktiviere Auto-Verknüpfung nicht, wenn dein IdP Benutzern erlaubt, diesen Claim selbst zu setzen.`,requireEmailVerified:`E-Mail-Verifizierung erforderlich`,requireEmailVerifiedDesc:`E-Mail-Claim nur akzeptieren, wenn der Provider ihn als verifiziert markiert.`,requireEmailVerifiedWarning:`Warnung: E-Mail wird auch ohne Verifizierung akzeptiert. Nur bei vertrauenswürdigen Providern verwenden.`,requireEmailVerifiedAutoLink:`Auto-Verknüpfung zuerst deaktivieren, um diese Einstellung zu ändern.`,defaultGroup:`Standardgruppe`,defaultGroupDesc:`Gruppe, der automatisch erstellte Benutzer zugewiesen werden. Fallback auf Viewers, wenn nicht gesetzt.`,defaultGroupViewersFallback:`Viewers (Standard)`}},encryption:{title:`MFA-Verschlüsselungsstatus`,enabledFromEnv:`At-Rest-Verschlüsselung aktiv (Schlüssel aus Umgebungsvariable MFA_ENCRYPTION_KEY)`,enabledFromFile:`At-Rest-Verschlüsselung aktiv (Schlüssel aus dem Datenverzeichnis geladen)`,enabledGenerated:`At-Rest-Verschlüsselung aktiv mit automatisch generiertem Schlüssel`,notConfigured:`At-Rest-Verschlüsselung nicht konfiguriert`,notConfiguredDesc:`TOTP-Geheimnisse und OIDC-Client-Secrets werden im Klartext gespeichert. Setze MFA_ENCRYPTION_KEY oder starte Bambuddy mit beschreibbarem Datenverzeichnis neu, damit ein Schlüssel automatisch erzeugt wird.`,allEncrypted:`Alle MFA-Geheimnisse sind verschlüsselt gespeichert.`,legacyRowsLabel:`Klartext-Zeilen (Altbestand)`,encryptedRowsLabel:`Verschlüsselte Zeilen`,legacyRowsWarning:`{{count}} Klartext-Zeile(n) erkannt. Den OIDC-Provider neu speichern oder den Authenticator des Benutzers neu einrichten, um die Daten verschlüsselt abzulegen.`,backupHint:`Der automatisch erzeugte Schlüssel liegt unter DATA_DIR/.mfa_encryption_key und wird in lokalen Backup-ZIPs mitgesichert. Backups sicher aufbewahren oder MFA_ENCRYPTION_KEY explizit setzen.`,decryptionBrokenTitle:`Verschlüsselungsschlüssel fehlt`,decryptionBrokenError:`{{count}} verschlüsselte Datensätze können nicht entschlüsselt werden, weil der Schlüssel nicht mehr verfügbar ist. Den vorherigen MFA_ENCRYPTION_KEY oder DATA_DIR/.mfa_encryption_key wiederherstellen.`,migrationErrorWarning:`{{count}} Legacy-Eintrag/Einträge konnten beim Start nicht verschlüsselt werden. Prüfen Sie die Server-Logs und starten Sie Bambuddy neu.`}},notification:{printStarted:{title:`Druck gestartet`,body:`{{printer}}: {{filename}} wird gedruckt`},printCompleted:{title:`Druck abgeschlossen`,body:`{{printer}}: {{filename}} erfolgreich abgeschlossen`},printFailed:{title:`Druck fehlgeschlagen`,body:`{{printer}}: {{filename}} ist fehlgeschlagen`},printStopped:{title:`Druck gestoppt`,body:`{{printer}}: {{filename}} wurde gestoppt`},printProgress:{title:`Druckfortschritt`,body:`{{printer}}: {{filename}} ist zu {{percent}}% abgeschlossen`},printerOffline:{title:`Drucker offline`,body:`{{printer}} ist offline`},printerError:{title:`Druckerfehler`,body:`{{printer}} – {{error}}`},filamentLow:{title:`Filament niedrig`,body:`{{printer}}: Filament geht zur Neige`},maintenanceDue:{title:`Wartung fällig`,body:`{{printer}}: {{items}} benötigen Aufmerksamkeit`}},errors:{generic:`Etwas ist schiefgelaufen`,networkError:`Netzwerkfehler. Bitte überprüfen Sie Ihre Verbindung.`,notFound:`Nicht gefunden`,unauthorized:`Nicht autorisiert`,serverError:`Serverfehler`,validationError:`Bitte überprüfen Sie Ihre Eingabe`,printerConnectionFailed:`Verbindung zum Drucker fehlgeschlagen`,saveFailed:`Speichern fehlgeschlagen`,deleteFailed:`Löschen fehlgeschlagen`,loadFailed:`Laden der Daten fehlgeschlagen`},hmsErrors:{title:`Fehler - {{name}}`,noErrors:`Keine Fehler`,viewOnWiki:`Im Bambu Lab Wiki ansehen`,clearInstructions:`Löschen Sie die Fehler am Drucker, um sie hier zu entfernen.`,clearErrors:`Fehler löschen`,clearSuccess:`HMS-Fehler gelöscht`,clearFailed:`HMS-Fehler konnten nicht gelöscht werden`},mqttDebug:{title:`MQTT-Debug-Protokoll`,searchPlaceholder:`Topic oder Payload suchen...`,noMessages:`Noch keine Nachrichten protokolliert`,startLoggingHint:`Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen`,noMessagesMatch:`Keine Nachrichten entsprechen Ihrem Filter`,adjustFilterHint:`Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen`,incoming:`Eingehend`,outgoing:`Ausgehend`,loggingStopped:`Protokollierung gestoppt`,loggingActive:`Protokollierung aktiv - Nachrichten werden automatisch aktualisiert`,startLogging:`Protokollierung starten`,stopLogging:`Protokollierung stoppen`,clearLog:`Protokoll löschen`,topic:`Thema`,timestamp:`Zeitstempel`,direction:`Richtung`,all:`Alle`},printerFiles:{title:`Dateimanager`,storageUsed:`Belegt:`,storageFree:`Frei:`,filterPlaceholder:`Dateien filtern...`,deleteButton:`Löschen`,deleteFiles:`{{count}} Dateien löschen`,deleteFileConfirm:`"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.`,deleteFilesConfirm:`{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.`,noFiles:`Keine Dateien auf dem Drucker`,loadingFiles:`Dateien werden geladen...`,failedToLoad:`Dateien konnten nicht geladen werden`,toast:{filesDeleted:`{{count}} Datei(en) gelöscht`,deleteFailed:`Löschen fehlgeschlagen: {{error}}`}},confirm:{delete:`Möchten Sie dies wirklich löschen?`,unsavedChanges:`Sie haben ungespeicherte Änderungen. Möchten Sie wirklich verlassen?`,clearQueue:`Möchten Sie die Warteschlange wirklich leeren?`},login:{title:`Bambuddy Anmeldung`,subtitle:`Melden Sie sich bei Ihrem Konto an`,username:`Benutzername`,usernamePlaceholder:`Benutzername eingeben`,usernameOrEmail:`Benutzername oder E-Mail`,usernameOrEmailPlaceholder:`Benutzername oder @ E-Mail`,password:`Passwort`,passwordPlaceholder:`Passwort eingeben`,signIn:`Anmelden`,signingIn:`Anmeldung läuft...`,rememberMe:`Angemeldet bleiben`,forgotPassword:`Passwort vergessen?`,loginSuccess:`Erfolgreich angemeldet`,loginFailed:`Anmeldung fehlgeschlagen`,enterCredentials:`Bitte Benutzername und Passwort eingeben`,enterEmail:`Bitte geben Sie Ihre E-Mail-Adresse ein`,oidcLoginFailed:`OIDC-Anmeldung fehlgeschlagen`,oidcErrors:{providerError:`Der Identity-Provider hat einen Fehler zurückgegeben`,missingParameters:`Dem OIDC-Callback fehlen erforderliche Parameter`,invalidState:`OIDC-State ist ungültig oder wurde bereits verwendet`,stateExpired:`OIDC-Sitzung abgelaufen — bitte erneut versuchen`,providerNotFound:`OIDC-Provider nicht gefunden`,discoveryFailed:`OIDC-Discovery-Dokument konnte nicht abgerufen werden`,invalidDiscovery:`OIDC-Discovery-Dokument ist ungültig`,networkError:`Netzwerkfehler beim OIDC-Token-Austausch`,badResponse:`Unerwartete Antwort beim OIDC-Token-Austausch`,noIdToken:`OIDC-Provider hat kein ID-Token zurückgegeben`,validationFailed:`OIDC-Token-Validierung fehlgeschlagen`,nonceMismatch:`OIDC-Nonce stimmt nicht überein — möglicher Replay-Angriff`,missingSubClaim:`OIDC-Token enthält keinen Sub-Claim`,noLinkedAccount:`Kein lokales Konto mit dieser OIDC-Identität verknüpft`,accountInactive:`Ihr Konto ist inaktiv`,userResolutionFailed:`Ihr Konto konnte nicht aufgelöst werden`,internalError:`Interner Fehler beim OIDC-Login`,tokenExchangeFailed:`OIDC-Token-Austausch fehlgeschlagen`},forgotPasswordTitle:`Passwort vergessen`,forgotPasswordMessage:`Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.`,forgotPasswordEmailMessage:`Geben Sie Ihre E-Mail-Adresse ein und wir senden Ihnen ein neues Passwort.`,emailAddress:`E-Mail-Adresse`,emailPlaceholder:`ihre.email@beispiel.de`,cancel:`Abbrechen`,sending:`Wird gesendet...`,sendResetEmail:`Zurücksetzungs-E-Mail senden`,howToReset:`So setzen Sie Ihr Passwort zurück:`,resetStep1:`Kontaktieren Sie Ihren Bambuddy-Administrator`,resetStep2:`Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen`,resetStep3:`Er kann ein neues temporäres Passwort für Sie festlegen`,resetStep4:`Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen`,gotIt:`Verstanden`,resetPassword:{title:`Neues Passwort festlegen`,subtitle:`Geben Sie unten Ihr neues Passwort ein und bestätigen Sie es.`,newPassword:`Neues Passwort`,newPasswordPlaceholder:`Mindestens 8 Zeichen`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Neues Passwort wiederholen`,saving:`Wird gespeichert…`,submit:`Neues Passwort festlegen`,backToLogin:`Zurück zur Anmeldung`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 8 Zeichen lang sein`,resetFailed:`Passwort zurücksetzen fehlgeschlagen. Der Link ist möglicherweise abgelaufen.`},twoFA:{title:`Zwei-Faktor-Authentifizierung`,subtitle:`Ihr Konto ist mit 2FA geschützt. Geben Sie unten den Bestätigungscode ein.`,methodAuthenticator:`Authenticator-App`,methodEmail:`E-Mail-Code`,methodBackup:`Wiederherstellungscode`,instructionsTotp:`Öffnen Sie Ihre Authenticator-App und geben Sie den 6-stelligen Code für Bambuddy ein.`,instructionsEmail:`Ein 6-stelliger Code wurde an Ihre E-Mail-Adresse gesendet. Er ist 10 Minuten gültig.`,instructionsEmailNotSent:`Klicken Sie unten, um einen Bestätigungscode per E-Mail zu erhalten.`,instructionsBackup:`Geben Sie einen Ihrer 8-stelligen Wiederherstellungscodes ein. Jeder Code kann nur einmal verwendet werden.`,sendCodeButton:`Code per E-Mail senden`,sendingCode:`Wird gesendet...`,resendCode:`Code erneut senden`,codeLabel:`Bestätigungscode`,backupCodeLabel:`Wiederherstellungscode`,codePlaceholder:`000000`,backupCodePlaceholder:`XXXXXXXX`,verifyButton:`Bestätigen`,verifyingButton:`Wird überprüft...`,backToLogin:`← Zurück zur Anmeldung`,orContinueWith:`oder anmelden mit`,signInWith:`Anmelden mit {{provider}}`,enterCode:`Bitte geben Sie den Bestätigungscode ein`,sendCodeFailed:`Bestätigungscode konnte nicht gesendet werden`,invalidCode:`Ungültiger Code. Bitte erneut versuchen.`}},setup:{title:`Bambuddy Einrichtung`,subtitle:`Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz`,enableAuth:`Authentifizierung aktivieren`,adminAccount:`Admin-Konto`,adminAccountDesc:`Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.`,adminUsername:`Admin-Benutzername`,adminPassword:`Admin-Passwort`,optionalIfAdminExists:`(optional, wenn Admin-Benutzer existieren)`,adminUsernamePlaceholder:`Admin-Benutzernamen eingeben (optional)`,adminPasswordPlaceholder:`Admin-Passwort eingeben (optional)`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Admin-Passwort bestätigen`,settingUp:`Einrichtung läuft...`,completeSetup:`Einrichtung abschließen`,toast:{authEnabledAdminCreated:`Authentifizierung aktiviert und Admin-Benutzer erstellt`,authEnabledExistingAdmins:`Authentifizierung mit vorhandenen Admin-Benutzern aktiviert`,setupCompleted:`Einrichtung abgeschlossen`,enterBothCredentials:`Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`}},changePassword:{title:`Passwort ändern`,currentPassword:`Aktuelles Passwort`,currentPasswordPlaceholder:`Aktuelles Passwort eingeben`,newPassword:`Neues Passwort`,newPasswordPlaceholder:`Neues Passwort eingeben (min. 6 Zeichen)`,confirmPassword:`Neues Passwort bestätigen`,confirmPasswordPlaceholder:`Neues Passwort bestätigen`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`,changing:`Wird geändert...`,success:`Passwort erfolgreich geändert`,failed:`Passwortänderung fehlgeschlagen`},plateAlert:{title:`Druck pausiert!`,message:`Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.`,understand:`Verstanden`},camera:{title:`Kameraansicht`,invalidPrinterId:`Ungültige Drucker-ID`,live:`Live`,snapshot:`Schnappschuss`,restartStream:`Stream neu starten`,refreshSnapshot:`Schnappschuss aktualisieren`,fullscreen:`Vollbild`,exitFullscreen:`Vollbild beenden`,connectingToCamera:`Verbinde mit Kamera...`,capturingSnapshot:`Schnappschuss wird aufgenommen...`,connectionLost:`Verbindung verloren`,connectionFailed:`Kameraverbindung fehlgeschlagen`,reconnecting:`Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})`,reconnectNow:`Jetzt verbinden`,cameraUnavailable:`Kamera nicht verfügbar`,cameraUnavailableDesc:`Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.`,noCamera:`Keine Kamera verfügbar`,retry:`Erneut versuchen`,cameraStream:`Kamera-Stream`,zoomOut:`Verkleinern`,zoomIn:`Vergrößern`,resetZoom:`Zoom zurücksetzen`,recording:`Aufnahme`,startRecording:`Aufnahme starten`,stopRecording:`Aufnahme stoppen`,chamberLight:`Kammerbeleuchtung umschalten`,unavailable:`Kamera nicht verfügbar`,diagnose:{button:`Diagnose`,modalTitle:`Kamera-Diagnose`,running:`Diagnose läuft...`,runFailed:`Diagnose konnte nicht ausgeführt werden: {{error}}`,retry:`Erneut ausführen`,stage:{tcp_reachable:`Netzwerk-Erreichbarkeit`,first_frame:`Bilderfassung`,live_stream_active:`Live-Stream aktiv`},summary:{all_ok:`Kamera funktioniert. Die Diagnose hat alle Phasen erfolgreich abgeschlossen.`,live_stream_active_healthy:`Kamera streamt gerade mit aktuellen Bildern — kein Test nötig.`,printer_unreachable:`Drucker ist nicht erreichbar. Prüfe IP-Adresse, Netzwerkverbindung und ob der Drucker eingeschaltet ist.`,camera_port_closed:`Drucker ist erreichbar, aber der Kamera-Port ist geschlossen. Stelle sicher, dass LAN-Modus und Entwicklermodus in den Druckereinstellungen aktiviert sind.`,no_frame:`Verbindung zur Kamera hergestellt, aber keine Bilder empfangen. Versuche es erneut oder prüfe, ob die Kamera in den Druckereinstellungen aktiviert ist.`,unknown_failure:`Kamera-Diagnose aus unbekanntem Grund fehlgeschlagen. Prüfe das Support-Log für Details.`},meta:{protocol:`Protokoll`,port:`Port`,profile:`Profil`}}},groups:{title:`Gruppenverwaltung`,subtitle:`Berechtigungsgruppen für Zugriffskontrolle verwalten`,backToSettings:`Zurück zu Einstellungen`,createGroup:`Gruppe erstellen`,noPermission:`Sie haben keine Berechtigung, auf diese Seite zuzugreifen.`,system:`System`,noDescription:`Keine Beschreibung`,usersCount:`{{count}} Benutzer`,permissionsCount:`{{count}} Berechtigungen`,edit:`Bearbeiten`,delete:`Löschen`,toast:{created:`Gruppe erfolgreich erstellt`,updated:`Gruppe erfolgreich aktualisiert`,deleted:`Gruppe erfolgreich gelöscht`,enterGroupName:`Bitte geben Sie einen Gruppennamen ein`},modal:{editGroup:`Gruppe bearbeiten`,createGroup:`Gruppe erstellen`,cancel:`Abbrechen`,saving:`Speichern...`,creating:`Erstellen...`,saveChanges:`Änderungen speichern`},form:{groupName:`Gruppenname`,groupNamePlaceholder:`Gruppennamen eingeben`,systemGroupWarning:`Systemgruppennamen können nicht geändert werden`,description:`Beschreibung`,descriptionPlaceholder:`Beschreibung eingeben (optional)`,permissions:`Berechtigungen ({{count}} ausgewählt)`},deleteModal:{title:`Gruppe löschen`,message:`Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.`,confirm:`Gruppe löschen`},editor:{title:`Gruppe bearbeiten`,createTitle:`Gruppe erstellen`,search:`Berechtigungen suchen...`,selectAll:`Alle auswählen`,clearAll:`Alle abwählen`,permissionsSelected:`{{count}} ausgewählt`,noResults:`Keine Berechtigungen entsprechen Ihrer Suche`}},users:{title:`Benutzerverwaltung`,subtitle:`Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten`,backToSettings:`Zurück zu Einstellungen`,createUser:`Benutzer erstellen`,noPermission:`Sie haben keine Berechtigung, auf diese Seite zuzugreifen.`,admin:`Admin`,noGroups:`Keine Gruppen`,active:`Aktiv`,inactive:`Inaktiv`,edit:`Bearbeiten`,delete:`Löschen`,system:`System`,noGroupsAvailable:`Keine Gruppen verfügbar`,table:{username:`Benutzername`,groups:`Gruppen`,status:`Status`,actions:`Aktionen`},toast:{created:`Benutzer erfolgreich erstellt`,updated:`Benutzer erfolgreich aktualisiert`,deleted:`Benutzer erfolgreich gelöscht`,fillRequired:`Bitte füllen Sie alle Pflichtfelder aus`,passwordsDoNotMatch:`Passwörter stimmen nicht überein`,passwordTooShort:`Passwort muss mindestens 6 Zeichen lang sein`,ldapProvisioned:`LDAP-Benutzer „{{username}}" bereitgestellt`},modal:{createUser:`Benutzer erstellen`,editUser:`Benutzer bearbeiten`,cancel:`Abbrechen`,creating:`Erstellen...`,saving:`Speichern...`,saveChanges:`Änderungen speichern`,advancedAuthSubtitle:`mit erweiterter Authentifizierung`,tabsAriaLabel:`Benutzerquelle`,localTab:`Lokal`,ldapTab:`LDAP`,ldapSearchLabel:`Verzeichnis durchsuchen`,ldapSearchPlaceholder:`Benutzername, Name oder E-Mail eingeben...`,ldapMinChars:`Mindestens 2 Zeichen für die Suche eingeben`,ldapTypeToSearch:`Tippen, um das LDAP-Verzeichnis zu durchsuchen`,ldapSearching:`Verzeichnis wird durchsucht...`,ldapNoResults:`Keine passenden Benutzer im Verzeichnis`,ldapSearchError:`Verzeichnissuche fehlgeschlagen. Bitte LDAP-Server-Status prüfen.`,ldapAlreadyProvisioned:`Bereits bereitgestellt`,ldapSelectedLabel:`Ausgewählt`,ldapProvision:`Benutzer bereitstellen`,ldapProvisioning:`Wird bereitgestellt...`,ldapErrorProvision:`Bereitstellung fehlgeschlagen. Bitte LDAP-Server-Status prüfen und erneut versuchen.`},form:{username:`Benutzername`,usernamePlaceholder:`Benutzernamen eingeben`,email:`E-Mail`,emailPlaceholder:`benutzer@beispiel.de`,password:`Passwort`,passwordPlaceholder:`Passwort eingeben`,confirmPassword:`Passwort bestätigen`,confirmPasswordPlaceholder:`Passwort bestätigen`,newPasswordPlaceholder:`Neues Passwort eingeben`,confirmNewPasswordPlaceholder:`Neues Passwort bestätigen`,leaveBlankToKeep:`leer lassen, um das aktuelle zu behalten`,groups:`Gruppen`,optional:`optional`,autoGeneratedPassword:`Ein sicheres Passwort wird automatisch generiert und per E-Mail an den Benutzer gesendet.`,passwordManagedByAdvancedAuth:`Das Passwort wird durch erweiterte Authentifizierung verwaltet. Verwenden Sie "Passwort zurücksetzen", um ein neues Passwort per E-Mail an den Benutzer zu senden.`,resetPassword:`Passwort zurücksetzen`,resettingPassword:`Passwort wird zurückgesetzt...`},deleteModal:{title:`Benutzer löschen`,message:`Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.`,confirm:`Benutzer löschen`}},streamOverlay:{title:`Stream-Overlay`,invalidPrinterId:`Ungültige Drucker-ID`,cameraStream:`Kamera-Stream`,progress:`Fortschritt`,eta:`ETA`,printerIdle:`Drucker ist inaktiv`,printerOffline:`Drucker offline`,status:{printing:`Druckt`,paused:`Pausiert`,finished:`Fertig`,failed:`Fehlgeschlagen`,idle:`Inaktiv`,unknown:`Unbekannt`}},profiles:{title:`Profile`,subtitle:`Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen`,tabs:{bambuCloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,local:`Lokale Profile`,kprofiles:`K-Profile`},orcaCloud:{connectedAs:`Verbunden als`,logout:`Trennen`,noLogoutPermission:`Sie haben keine Berechtigung zum Trennen`,noConnectPermission:`Sie haben keine Berechtigung, sich mit Orca Cloud zu verbinden`,retry:`Erneut versuchen`,back:`Andere Anmeldemethode verwenden`,connect:{title:`Mit Orca Cloud verbinden`,description:`Melden Sie sich bei Ihrem Orca Cloud-Konto an, um Ihre Slicer-Profile in Bambuddy zu synchronisieren.`},providers:{google:`Mit Google anmelden`,apple:`Mit Apple anmelden`,github:`Mit GitHub anmelden`,email:`Mit E-Mail und Passwort anmelden`},password:{title:`Mit E-Mail und Passwort anmelden`,email:`E-Mail`,emailPlaceholder:`sie@beispiel.de`,password:`Passwort`,submit:`Anmelden`},paste:{title:`Anmeldung abschließen`,step1:`Ein neuer Tab wurde mit der Orca Cloud-Anmeldeseite geöffnet. Melden Sie sich mit Ihrem Orca-Konto an.`,step2:`Ihr Browser wird zu einer "localhost"-URL umgeleitet, die nicht geladen werden kann. Das ist normal — die URL ist es, was wir brauchen.`,step3:`Kopieren Sie die gesamte URL aus der Adressleiste Ihres Browsers und fügen Sie sie unten ein.`,signInUrl:`Falls sich der Anmelde-Tab nicht geöffnet hat, klicken Sie auf diese URL:`,label:`Callback-URL hier einfügen`,placeholder:`http://localhost:41172/callback?code=...&state=...`,submit:`Verbindung abschließen`},profiles:{title:`Ihre Orca Cloud-Profile ({{count}})`,refresh:`Aktualisieren`,empty:`Noch keine Profile in Ihrem Orca Cloud-Konto gefunden.`},toast:{connected:`Mit Orca Cloud verbunden als {{email}}`,disconnected:`Verbindung zu Orca Cloud getrennt`},errors:{startFailed:`Anmeldevorgang für Orca Cloud konnte nicht gestartet werden.`,finishFailed:`Orca Cloud-Anmeldung konnte nicht abgeschlossen werden.`,passwordFailed:`Anmeldung mit dieser E-Mail und diesem Passwort fehlgeschlagen.`,passwordEmpty:`Bitte geben Sie sowohl E-Mail als auch Passwort ein.`,emptyPaste:`Bitte fügen Sie die Callback-URL aus Ihrem Browser ein.`,noCode:`Diese URL sieht nicht wie ein Orca Cloud-Callback aus (kein code-Parameter). Kopieren Sie die vollständige URL aus der Adressleiste.`}},localProfiles:{title:`Lokale Profile`,subtitle:`Slicer-Voreinstellungen aus OrcaSlicer importieren und verwalten`,import:`Profile importieren`,importDesc:`.bbscfg-, .bbsflmt-, .orca_filament-, .zip- oder .json-Dateien hier ablegen`,importing:`Importiere...`,search:`Lokale Voreinstellungen durchsuchen...`,noPresets:`Noch keine lokalen Voreinstellungen`,noSearchResults:`Keine Voreinstellungen entsprechen deiner Suche`,badge:`Lokal`,edit:`Bearbeiten`,delete:`Löschen`,cancel:`Abbrechen`,deleteConfirmTitle:`Voreinstellung löschen`,deleteConfirm:`Möchten Sie diese Voreinstellung wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,source:`Quelle`,inheritsFrom:`Erbt von`,filamentType:`Typ`,vendor:`Hersteller`,compatiblePrinters:`Drucker`,nozzleTemp:`Düsentemperatur`,cost:`Kosten`,density:`Dichte`,pressureAdvance:`Druckvorschub`,filament:`Filament`,process:`Prozess`,printer:`Drucker`,toast:{importSuccess:`{{count}} Voreinstellung(en) importiert`,importSkipped:`{{count}} Voreinstellung(en) übersprungen (Duplikate)`,importError:`{{count}} Fehler beim Import`,deleted:`Voreinstellung gelöscht`,updated:`Voreinstellung aktualisiert`}},connectedAs:`Verbunden als`,logout:`Abmelden`,noLogoutPermission:`Sie haben keine Berechtigung zum Abmelden`,failedToLoad:`Profile konnten nicht geladen werden`,retry:`Erneut versuchen`,time:{justNow:`Gerade eben`,minsAgo:`vor {{count}}m`,hoursAgo:`vor {{count}}h`,daysAgo:`vor {{count}}d`},toast:{loggedOut:`Abgemeldet`},login:{title:`Mit Bambu Cloud verbinden`,subtitle:`Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend`,email:`E-Mail`,password:`Passwort`,region:`Region`,regionGlobal:`Global`,regionChina:`China`,verificationCode:`Bestätigungscode`,totpCode:`Authenticator-Code`,checkEmail:`Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code`,enterTotpHint:`Geben Sie den 6-stelligen Code aus Ihrer Authenticator-App ein`,accessToken:`Zugriffstoken`,accessTokenHint:`Fügen Sie Ihr Bambu-Cloud-Zugriffstoken ein. Konten der Region China müssen diesen Weg nutzen (telefonnummerngebunden — kein E-Mail-Login). Im Wiki steht, wie Sie das Token aus den MakerWorld-Cookies auslesen.`,back:`Zurück`,loginButton:`Anmelden`,verifyButton:`Bestätigen`,setTokenButton:`Token setzen`,useToken:`Stattdessen Zugriffstoken verwenden`,useEmail:`Stattdessen mit E-Mail anmelden`,toast:{loggedIn:`Erfolgreich angemeldet`,codeSent:`Bestätigungscode an Ihre E-Mail gesendet`,enterTotp:`Geben Sie den Code aus Ihrer Authenticator-App ein`,tokenSet:`Token erfolgreich gesetzt`}},presets:{myPreset:`Mein Profil (bearbeitbar)`,duplicate:`Duplizieren`,editable:`Bearbeitbar`,failedToLoadDetails:`Profil-Details konnten nicht geladen werden`,deleteConfirm:`Dieses Profil löschen?`,deleteWarning:`"{{name}}" wird dauerhaft aus Bambu Cloud gelöscht. Dies kann nicht rückgängig gemacht werden.`,noDuplicatePermission:`Sie haben keine Berechtigung zum Duplizieren von Profilen`,noEditPermission:`Sie haben keine Berechtigung zum Bearbeiten von Profilen`,noDeletePermission:`Sie haben keine Berechtigung zum Löschen von Profilen`,types:{filament:`Filament-Profil`,printer:`Drucker-Profil`,process:`Prozess-Profil`},toast:{deleted:`Profil gelöscht`,created:`Profil erstellt`,updated:`Profil aktualisiert`,duplicated:`Profil dupliziert`,fieldAdded:`Feld "{{key}}" hinzugefügt`,exported:`Profil exportiert`},baseLabel:`Basis: {{name}}`,currentLabel:`Aktuell: {{name}}`,newPreset:`Neues Profil`,editPreset:`Profil bearbeiten`,duplicatePreset:`Profil duplizieren`,createNewPreset:`Neues Profil erstellen`,customizeSettings:`Passen Sie die Einstellungen für Ihr neues Profil an`,compareWithBase:`Mit Basis-Profil vergleichen`,compare:`Vergleichen`,basePreset:`Basis-Profil`,selectBasePreset:`Basis-Profil auswählen...`,presetName:`Profilname`,myCustomPreset:`Mein eigenes Profil`,inheritsFrom:`Erbt von`,dropJsonToImport:`JSON zum Importieren ablegen`,tabs:{common:`Allgemein`,allFields:`Alle Felder`},availableFields:`Verfügbare Felder`,searchFieldsPlaceholder:`Felder suchen...`,noMatchingFields:`Keine passenden Felder`,allFieldsAdded:`Alle Felder hinzugefügt`,addCustomField:`Eigenes Feld hinzufügen`,yourOverrides:`Ihre Überschreibungen`,noOverridesYet:`Noch keine Überschreibungen`,clickFieldsToAdd:`Klicken Sie links auf Felder, um sie hinzuzufügen`,saveAsTemplate:`Als Vorlage speichern`,jsonTip:`Tipp: Ziehen Sie eine .json-Datei auf dieses Fenster, um Einstellungen zu importieren`},cloudView:{searchPlaceholder:`Profile suchen...`,templates:`Vorlagen`,refresh:`Aktualisieren`,newPreset:`Neues Profil`,clearFilters:`Filter zurücksetzen`,compareMode:`Vergleichsmodus`,selectAnotherPreset:`Wählen Sie ein weiteres {{type}}-Profil`,clickTwoPresets:`Klicken Sie auf zwei Profile des gleichen Typs zum Vergleichen`,selectFirst:`1. Erstes auswählen`,selectSecond:`2. Zweites auswählen`,compareNow:`Jetzt vergleichen`,lastSynced:`Zuletzt synchronisiert:`,showingCount:`{{showing}} von {{total}} Profilen`,noPresetsFound:`Keine Profile gefunden`,columns:{filament:`Filament`,process:`Prozess`,printer:`Drucker`},noFilamentPresets:`Keine Filament-Profile`,noProcessPresets:`Keine Prozess-Profile`,noPrinterPresets:`Keine Drucker-Profile`,filters:{type:`Typ`,owner:`Besitzer`,printer:`Drucker`,nozzle:`Düse`,filament:`Filament`,layer:`Schicht`,all:`Alle`,myPresets:`Meine Profile`,builtIn:`Voreingestellt`,process:`Prozess`},noTemplatesPermission:`Sie haben keine Berechtigung, Vorlagen zu verwalten`,noRefreshPermission:`Sie haben keine Berechtigung, Profile zu aktualisieren`,noCreatePermission:`Sie haben keine Berechtigung, Profile zu erstellen`},templates:{title:`Schnellvorlagen`,noTemplates:`Noch keine Vorlagen`,createFirst:`Erstellen Sie Vorlagen aus dem Preset-Editor`,typeFilter:`Typ:`,deleteTitle:`Vorlage löschen`,deleteWarning:`Diese Aktion kann nicht rückgängig gemacht werden`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,namePlaceholder:`Vorlagenname`,descriptionPlaceholder:`Beschreibung`,settingsJson:`Einstellungen (JSON)`,fieldsCount:`{{count}} Felder`,shownInModals:`In Dialogen angezeigt`,hiddenInModals:`In Dialogen ausgeblendet`,apply:`Anwenden`,toast:{deleted:`Vorlage gelöscht`,updated:`Vorlage aktualisiert`,created:`Vorlage erstellt`,applied:`Vorlage angewendet`}}},support:{debugLoggingActive:`Debug-Protokollierung ist aktiv`,manageLogs:`Verwalten`,collectItem7:`Drucker-Verbindungsstatus und Firmware-Versionen`,collectItem8:`Integrationsstatus (Spoolman, MQTT, HA)`,collectItem9:`Netzwerkschnittstellen (nur Subnetze)`,collectItem10:`Python-Paketversionen`,collectItem11:`Datenbankzustandsprüfungen`,collectItem12:`Docker-Umgebungsdetails`,bundleGenerating:`Bundle wird erstellt...`,bundleStepConnection:`Drucker-Verbindungsprüfungen werden ausgeführt`,bundleStepVirtualPrinters:`Setup-Prüfungen für virtuelle Drucker werden ausgeführt`,bundleStepLogScan:`Aktuelle Protokolle werden auf bekannte Probleme überprüft`,bundleStepBuild:`Support-Bundle-ZIP wird erstellt`},fileManager:{title:`Dateimanager`,subtitle:`Organisieren und verwalten Sie Ihre Druckdateien`,uploadFiles:`Dateien hochladen`,newFolder:`Neuer Ordner`,folderName:`Ordnername`,folderNamePlaceholder:`z.B. Funktionsteile`,renameFile:`Datei umbenennen`,renameFolder:`Ordner umbenennen`,invalidFilenameChar:`Das Zeichen "{{char}}" ist in Druck-Dateinamen nicht erlaubt. Die SD-Karte des Druckers lehnt folgende Zeichen ab: < > : " / \\ | ? *`,moveFiles:`{{count}} Datei(en) verschieben`,rootNoFolder:`Stammverzeichnis (Kein Ordner)`,current:`aktuell`,linkFolder:`Ordner verknüpfen`,linkFolderDescription:`"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.`,project:`Projekt`,archive:`Archiv`,noProjectsFound:`Keine Projekte gefunden`,noArchivesFound:`Keine Archive gefunden`,unlink:`Verknüpfung aufheben`,link:`Verknüpfen`,dragDropFiles:`Dateien hierher ziehen`,dropFilesHere:`Dateien hier ablegen`,releaseToUpload:`Loslassen zum Hochladen`,orClickToBrowse:`oder klicken zum Durchsuchen`,allFileTypesSupported:`Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.`,zipFilesDetected:`ZIP-Dateien erkannt`,zipExtractOptions:`ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:`,preserveZipStructure:`Ordnerstruktur aus ZIP beibehalten`,createFolderFromZip:`Ordner aus ZIP-Dateiname erstellen`,stlThumbnailGeneration:`STL-Vorschaubildgenerierung`,zipMayContainStl:`ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.`,thumbnailsCanBeGenerated:`Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.`,generateThumbnailsForStl:`Vorschaubilder für STL-Dateien generieren`,threemfDetected:`3MF-Dateien erkannt`,threemfExtractionInfo:`Druckermodell, Material, Farbe und Druckeinstellungen werden automatisch aus 3MF-Dateien extrahiert.`,willBeExtracted:`Wird extrahiert`,filesExtracted:`{{count}} Dateien extrahiert`,uploadComplete:`Upload abgeschlossen: {{succeeded}} erfolgreich`,uploadFailed:`Hochladen fehlgeschlagen`,zipFilesFailed:`{{count}} Dateien fehlgeschlagen`,uploading:`Hochladen...`,changeLink:`Verknüpfung ändern...`,linkTo:`Verknüpfen mit...`,linkToProjectOrArchive:`Mit Projekt oder Archiv verknüpfen`,addToQueue:`Zur Warteschlange`,schedulePrint:`Planen`,generateThumbnail:`Vorschaubild generieren`,generateThumbnails:`Vorschaubilder generieren`,generateThumbnailsForMissing:`Vorschaubilder für STL-Dateien ohne Vorschau generieren`,gridView:`Rasteransicht`,listView:`Listenansicht`,lowDiskSpaceWarning:`Warnung: Wenig Speicherplatz`,lowDiskSpaceDetails:`Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.`,files:`Dateien`,folders:`Ordner`,size:`Größe`,free:`Frei`,allFiles:`Alle Dateien`,allExternal:`Extern`,externalIsEmpty:`Keine externen Dateien`,externalEmptyDescription:`Dateien aus deinen verknüpften externen Ordnern erscheinen hier.`,wrap:`Umbrechen`,enableTextWrapping:`Textumbruch aktivieren`,disableTextWrapping:`Textumbruch deaktivieren`,collapse:`Einklappen`,collapseFoldersByDefault:`Ordner standardmäßig einklappen`,expandFoldersByDefault:`Ordner standardmäßig ausklappen`,folderSort:`Ordner sortieren`,folderSortByName:`Nach Name`,folderSortByActivity:`Nach letzter Aktivität`,dragToResizeTooltip:`Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen`,searchFiles:`Dateien suchen...`,searchSubfoldersHint:`Inklusive Unterordner`,readme:{truncated:`Gekürzt`},tags:{title:`Tags`,subtitle:`Dateien mit Labels versehen — Spielzeug, kindersicher, nur PETG, was immer du willst.`,manage:`Tags`,manageTitle:`Tag-Katalog verwalten`,add:`Neuer Tag`,edit:`Tag umbenennen`,name:`Name`,fileCount:`Dateien`,empty:`Noch keine Tags. Erstelle einen, um Dateien zu kennzeichnen.`,noMatches:`Keine passenden Tags.`,createPlaceholder:`z. B. Spielzeug, kindersicher, petg`,createButton:`Erstellen`,nameRequired:`Name ist erforderlich.`,searchPlaceholder:`Tags filtern...`,created:`Tag erstellt.`,updated:`Tag umbenannt.`,deleted:`Tag entfernt.`,saveFailed:`Tag konnte nicht gespeichert werden.`,deleteFailed:`Tag konnte nicht entfernt werden.`,applyFailed:`Tags konnten nicht angewendet werden.`,applyAdd:`Tags hinzufügen`,applyRemove:`Tags entfernen`,applyAddSuccess:`{{count}} Tag(s) zu {{files}} Datei(en) hinzugefügt.`,applyRemoveSuccess:`{{count}} Tag(s) von {{files}} Datei(en) entfernt.`,actionAdd:`Zu ausgewählten Dateien hinzufügen`,actionRemove:`Von ausgewählten Dateien entfernen`,tagAction:`Tag`,bulkTitle:`{{count}} ausgewählte Datei(en) taggen`,bulkTooltip:`Tags für alle ausgewählten Dateien hinzufügen oder entfernen.`,noPermission:`Du hast keine Berechtigung, Dateien zu taggen.`,filterLabel:`Filtern nach:`,clearAll:`Alle entfernen`,confirmDelete:`Tag "{{name}}" löschen?`,confirmDeleteMessage:`Entfernt den Tag aus dem Katalog. Dateien behalten ihre übrigen Tags.`,confirmDeleteInUseMessage:`Dieser Tag ist auf {{count}} Datei(en). Beim Löschen verschwindet er von allen; die Dateien selbst bleiben unverändert.`,editAria:`{{name}} bearbeiten`,deleteAria:`{{name}} löschen`},allTypes:`Alle Typen`,prints:`Drucke`,ascending:`Aufsteigend`,descending:`Absteigend`,resultsCount:`{{showing}} von {{total}} Dateien`,selectAll:`Alle auswählen`,deselectAll:`Auswahl aufheben`,selected:`{{count}} ausgewählt`,adding:`Hinzufügen...`,loadingFiles:`Dateien werden geladen...`,folderIsEmpty:`Ordner ist leer`,noFilesYet:`Noch keine Dateien`,folderEmptyDescription:`Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.`,noFilesDescription:`Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.`,noMatchingFiles:`Keine passenden Dateien`,noMatchingFilesDescription:`Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.`,clearFilters:`Filter zurücksetzen`,printedCount:`{{count}}x gedruckt`,uploadedBy:`Hochgeladen von`,deleteFolder:`Ordner löschen`,deleteFile:`Datei löschen`,deleteFilesCount:`{{count}} Dateien löschen`,deleteFolderConfirm:`Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.`,deleteFileConfirm:`Möchten Sie diese Datei wirklich löschen?`,deleteFilesConfirm:`Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.`,deleting:`Wird gelöscht...`,noPermissionRenameFolder:`Sie haben keine Berechtigung, Ordner umzubenennen`,noPermissionLinkFolder:`Sie haben keine Berechtigung, Ordner zu verknüpfen`,noPermissionDeleteFolder:`Sie haben keine Berechtigung, Ordner zu löschen`,noPermissionPrint:`Sie haben keine Berechtigung zum Drucken`,noPermissionSlice:`Sie haben keine Berechtigung, Dateien zu slicen`,noPermissionAddToQueue:`Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen`,noPermissionDownload:`Sie haben keine Berechtigung, Dateien herunterzuladen`,noPermissionRenameFile:`Sie haben keine Berechtigung, diese Datei umzubenennen`,noPermissionGenerateThumbnail:`Sie haben keine Berechtigung, Vorschaubilder zu generieren`,noPermissionDeleteFile:`Sie haben keine Berechtigung, diese Datei zu löschen`,noPermissionCreateFolder:`Sie haben keine Berechtigung, Ordner zu erstellen`,noPermissionUpload:`Sie haben keine Berechtigung, Dateien hochzuladen`,noPermissionMoveFiles:`Sie haben keine Berechtigung, Dateien zu verschieben`,noPermissionDeleteFiles:`Sie haben keine Berechtigung, Dateien zu löschen`,linkExternal:`Extern verknüpfen`,linkExternalFolder:`Externen Ordner verknüpfen`,linkExternalFolderDescription:`Ein Host-Verzeichnis (NAS, USB, Netzlaufwerk) in den Dateimanager einbinden. Dateien werden nicht kopiert — sie werden direkt vom Originalpfad gelesen.`,externalFolderNamePlaceholder:`z.B. NAS-Drucke`,externalPath:`Host-Pfad`,externalPathHelp:`Absoluter Pfad zum Verzeichnis auf dem Docker-Host. Muss als Bind-Mount in den Container eingebunden sein.`,readOnly:`Nur Lesen`,readOnlyHelp:`verhindert Uploads und Löschungen`,showHiddenFiles:`Versteckte Dateien anzeigen (Punkt-Dateien)`,externalFolder:`Externer Ordner`,scanFolder:`Scannen`,toast:{folderCreated:`Ordner erstellt`,folderDeleted:`Ordner gelöscht`,fileDeleted:`Datei gelöscht`,filesDeleted:`{{count}} Dateien gelöscht`,filesMoved:`Dateien verschoben`,folderLinked:`Ordner verknüpft`,folderUnlinked:`Ordnerverknüpfung aufgehoben`,externalFolderLinked:`Externer Ordner verknüpft und gescannt`,folderScanned:`Scan abgeschlossen: {{added}} hinzugefügt, {{removed}} entfernt`,addedToQueue:`{{count}} Datei(en) zur Warteschlange hinzugefügt`,addedToQueuePartial:`{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen`,failedToAddToQueue:`Fehler beim Hinzufügen: {{error}}`,fileRenamed:`Datei umbenannt`,folderRenamed:`Ordner umbenannt`,thumbnailsGenerated:`{{count}} Vorschaubild(er) generiert`,thumbnailsGeneratedPartial:`{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen`,noStlMissingThumbnails:`Keine STL-Dateien ohne Vorschaubild`,failedToGenerateThumbnails:`Fehler beim Generieren der Vorschaubilder: {{error}}`,thumbnailGenerated:`Vorschaubild generiert`,failedToGenerateThumbnail:`Fehler beim Generieren des Vorschaubildes: {{error}}`}},projects:{title:`Projekte`,subtitle:`Organisieren und verfolgen Sie Ihre 3D-Druckprojekte`,newProject:`Neues Projekt`,editProject:`Projekt bearbeiten`,deleteProject:`Projekt löschen`,projectName:`Projektname`,description:`Beschreibung`,noProjects:`Noch keine Projekte`,noProjectsFiltered:`Keine {{status}} Projekte`,noProjectsFilteredHelp:`Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.`,createFirst:`Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.`,createFirstButton:`Erstes Projekt erstellen`,create:`Erstellen`,files:`Dateien`,prints:`Drucke`,plates:`Platten`,parts:`Teile`,lastModified:`Zuletzt geändert`,deleteConfirm:`Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.`,addFiles:`Dateien hinzufügen`,removeFile:`Datei entfernen`,viewDetails:`Details anzeigen`,namePlaceholder:`z.B. Voron 2.4 Build`,descriptionPlaceholder:`Optionale Beschreibung...`,urlLabel:`URL`,urlPlaceholder:`https://makerworld.com/...`,urlInvalid:`URL muss mit http:// oder https:// beginnen`,openExternalUrl:`Projekt-URL öffnen`,coverImageLabel:`Titelbild`,coverImageAlt:`Projekt-Titelbild`,coverImageUpload:`Hochladen`,coverImageReplace:`Ersetzen`,coverImageRemove:`Entfernen`,color:`Farbe`,targetPlates:`Ziel-Platten`,targetPlatesPlaceholder:`z.B. 25`,targetPlatesHelp:`Anzahl der Druckaufträge`,targetParts:`Ziel-Teile`,targetPartsPlaceholder:`z.B. 150`,targetPartsHelp:`Benötigte Objekte insgesamt`,tagsLabel:`Tags (kommagetrennt)`,tagsPlaceholder:`z.B. voron, funktional, geschenk`,dueDate:`Fälligkeitsdatum`,priority:`Priorität`,priorityLow:`Niedrig`,priorityNormal:`Normal`,priorityHigh:`Hoch`,priorityUrgent:`Dringend`,statusActive:`Aktiv`,statusCompleted:`Abgeschlossen`,statusArchived:`Archiviert`,done:`Fertig`,completed:`abgeschlossen`,failed:`fehlgeschlagen`,inQueue:`in Warteschlange`,noPrintsYet:`Noch keine Drucke`,printJobs:`Druckaufträge (Platten)`,partsPrinted:`Gedruckte Teile`,failedParts:`Fehlgeschlagene Teile`,import:`Importieren`,export:`Exportieren`,importProject:`Projekt importieren`,exportAll:`Alle Projekte exportieren`,loading:`Projekte werden geladen...`,noEditPermission:`Sie haben keine Berechtigung, Projekte zu bearbeiten`,noDeletePermission:`Sie haben keine Berechtigung, Projekte zu löschen`,noCreatePermission:`Sie haben keine Berechtigung, Projekte zu erstellen`,noImportPermission:`Sie haben keine Berechtigung, Projekte zu importieren`,noExportPermission:`Sie haben keine Berechtigung, Projekte zu exportieren`,toast:{created:`Projekt erstellt`,updated:`Projekt aktualisiert`,deleted:`Projekt gelöscht`,imported:`Projekt importiert`,multipleImported:`{{count}} Projekte importiert`,importFailed:`Import fehlgeschlagen`,exported:`Projekte exportiert (nur Metadaten)`}},projectDetail:{notFound:`Projekt nicht gefunden`,backToProjects:`Zurück zu Projekten`,export:`Exportieren`,exportProject:`Projekt exportieren`,noExportPermission:`Sie haben keine Berechtigung, Projekte zu exportieren`,noEditPermission:`Sie haben keine Berechtigung, Projekte zu bearbeiten`,partOf:`Teil von:`,priorityLabel:`Priorität:`,noPrints:`Noch keine Drucke in diesem Projekt`,status:{active:`Aktiv`,completed:`Abgeschlossen`,archived:`Archiviert`},priority:{low:`Niedrig`,normal:`Normal`,high:`Hoch`,urgent:`Dringend`},dueDate:{overdue:`Überfällig`,today:`Heute fällig`,daysLeft:`{{count}} Tage übrig`},progress:{platesProgress:`Platten-Fortschritt`,partsProgress:`Teile-Fortschritt`,printJobs:`Druckaufträge`,parts:`Teile`,percentComplete:`{{percent}}% abgeschlossen`,remaining:`{{count}} verbleibend`},stats:{printJobs:`Druckaufträge`,total:`gesamt`,failed:`{{count}} fehlgeschlagen`,partsPrinted:`{{count}} Teile gedruckt`,printTime:`Druckzeit`,filamentUsed:`Filament verbraucht`},cost:{title:`Kostenverfolgung`,filamentCost:`Filamentkosten`,energy:`Energie`,totalCost:`Gesamtkosten`,total:`Gesamt`,includesBom:`inkl. Stückliste`,budget:`Budget`,remaining:`Verbleibend`},subProjects:{title:`Unterprojekte ({{count}})`},notes:{title:`Notizen`,noEditPermission:`Sie haben keine Berechtigung, Notizen zu bearbeiten`,placeholder:`Notizen zu diesem Projekt hinzufügen...`,empty:`Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen.`},files:{title:`Dateien`,linkFolders:`Ordner aus dem Dateimanager verknüpfen`,forQuickAccess:`für schnellen Zugriff auf dieses Projekt.`,fileCount:`{{count}} Datei(en)`,empty:`Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt.`,noFiles:`Keine Dateien in diesem Ordner.`,print:`Jetzt drucken`,addToQueue:`Zur Warteschlange`},bom:{title:`Stückliste`,acquired:`{{completed}}/{{total}} beschafft`,showAll:`Alle anzeigen`,hideDone:`Erledigte ausblenden`,addPart:`Teil hinzufügen`,noAddPermission:`Sie haben keine Berechtigung, Teile hinzuzufügen`,partNamePlaceholder:`Teilename (z.B. M3x8 Schrauben)`,partName:`Teilename`,qty:`Menge`,price:`Preis ({{currency}})`,sourcingUrlPlaceholder:`Bezugsquelle-URL (optional)`,remarksPlaceholder:`Bemerkungen (optional)`,deletePart:`Teil löschen`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen?`,noUpdatePermission:`Sie haben keine Berechtigung, Teile zu aktualisieren`,noEditPermission:`Sie haben keine Berechtigung, Teile zu bearbeiten`,noDeletePermission:`Sie haben keine Berechtigung, Teile zu löschen`,totalCost:`Gesamtkosten:`,empty:`Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss.`},timeline:{title:`Aktivitätsverlauf`,empty:`Noch keine Aktivität.`},template:{saveAsTemplate:`Als Vorlage speichern`,noCreatePermission:`Sie haben keine Berechtigung, Vorlagen zu erstellen`},queue:{title:`Warteschlange`,viewAll:`Alle anzeigen`,printing:`{{count}} druckend`,queued:`{{count}} in Warteschlange`},prints:{title:`Drucke ({{count}})`},toast:{projectUpdated:`Projekt aktualisiert`,partAdded:`Teil hinzugefügt`,partRemoved:`Teil entfernt`,exportFailed:`Export fehlgeschlagen`,projectExported:`Projekt exportiert`,templateCreated:`Vorlage erstellt`}},system:{title:`Systeminformationen`,version:`Version`,uptime:`Laufzeit`,cpuUsage:`CPU-Auslastung`,memoryUsage:`Speicherauslastung`,diskUsage:`Festplattenauslastung`,networkInfo:`Netzwerkinformationen`,logs:`Protokolle`,debugMode:`Debug-Modus`,enableDebug:`Debug-Protokollierung aktivieren`,disableDebug:`Debug-Protokollierung deaktivieren`,downloadLogs:`Protokolle herunterladen`,clearLogs:`Protokolle löschen`,dockerInfo:`Docker-Info`,containerName:`Container-Name`,imageName:`Image-Name`,platform:`Plattform`,architecture:`Architektur`},sponsors:{sectionTitle:`Unabhängig & von der Community finanziert`,tagline:`Bambuddy ist kostenlos und bleibt es, weil Menschen es freiwillig unterstützen. Kein VC, kein Cloud-Zwang.`,viewSupporters:`Unterstützer ansehen`,toastPrints:`Du hast {{count}} Drucke mit Bambuddy abgeschlossen. Bambuddy bleibt kostenlos dank seiner Unterstützer.`,toastCost:`Du hast {{total}} an Filament mit Bambuddy verfolgt. Sieh dir an, wer das Projekt unabhängig hält.`,toastArchives:`{{count}} Drucke mit Bambuddy archiviert. Sieh dir an, wer es unabhängig hält.`,toastAnniversary:`Ein Jahr mit Bambuddy! Sieh dir an, wer das Projekt unabhängig hält.`,toastVersionUpdate:`Aktualisiert auf v{{version}}. Bambuddy bleibt kostenlos dank seiner Unterstützer.`},library:{title:`Filament-Bibliothek`,addFilament:`Filament hinzufügen`,editFilament:`Filament bearbeiten`,deleteFilament:`Filament löschen`,vendor:`Hersteller`,material:`Material`,color:`Farbe`,kFactor:`K-Faktor`,temperature:`Temperatur`,noFilaments:`Keine Filamente in der Bibliothek`,deleteConfirm:`Möchten Sie dieses Filament wirklich löschen?`,importFromPrinter:`Vom Drucker importieren`,exportToFile:`In Datei exportieren`},slice:{title:`Modell slicen`,action:`Slicen`,actionAll:`Alle {{count}} Plates slicen`,actionAllTitle:`Alle Plates in eine einzelne Multi-Plate-Ausgabe slicen (ein Archiv). Die Filamentauswahl gilt für jeden Slot des Projekts.`,allPlatesToggle:`Alle {{count}} Plates slicen`,slicing:`Slicen…`,printer:`Drucker-Profil`,process:`Prozess-Profil`,filament:`Filament-Profil`,filamentSlot:`Filament {{index}} – {{type}}`,selectPreset:`— Profil auswählen —`,loadingPresets:`Profile werden geladen…`,analyzingPlateFilaments:`Plattenfilamente werden analysiert…`,analyzingPlateFilamentsHint:`Es wird ein Probeschnitt ausgeführt, um die belegten AMS-Slots dieser Platte zu ermitteln. Wird zwischengespeichert — erneutes Öffnen ist sofort.`,previewToast:`{{name}} wird analysiert — {{elapsed}}`,previewWithProgress:`{{name}} wird analysiert — {{stage}} ({{percent}}%) — {{elapsed}}`,notUsedByPlate:`— wird von dieser Platte nicht verwendet`,noPresetsForSlot:`Keine Profile verfügbar`,otherPrinters:`Andere Drucker`,presetsLoadFailed:`Profile konnten nicht geladen werden. Importiere sie zuerst unter Einstellungen → Profile.`,refreshPresets:`Aktualisieren`,refreshPresetsTitle:`Profile neu laden — die aktuellen Cloud- und Bundle-Listen abrufen (nach dem Löschen eines Profils in Bambu Studio oder Bambu Handy verwenden)`,allPresetsRequired:`Alle Profile müssen ausgewählt sein`,enqueuing:`Slice-Auftrag wird übermittelt…`,queued:`In Warteschlange…`,failed:`Slicen fehlgeschlagen. Logs des Slicer-Sidecars prüfen.`,startedToast:`{{name}} wird im Hintergrund gesliced…`,queuedToast:`Warteschlange: {{name}} — {{elapsed}}`,runningToast:`{{name}} wird gesliced — {{elapsed}}`,runningWithProgress:`{{name}} – {{stage}} ({{percent}} %) – {{elapsed}}`,runningWithProgressMultiPlate:`Plate {{plateIndex}} von {{plateCount}} • {{name}} – {{stage}} ({{percent}} %) – {{elapsed}}`,completedToast:`{{name}} wurde gesliced`,failedTitle:`Slicen fehlgeschlagen`,failedToast:`Slicen von {{name}} fehlgeschlagen: {{detail}}`,tier:{local:`Importiert`,cloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,standard:`Standard`},cloud:{notAuthenticated:`In Bambu Cloud anmelden (Einstellungen → Profile → Bambu Cloud), um deine Cloud-Profile zu sehen.`,expired:`Bambu-Cloud-Sitzung abgelaufen — erneut anmelden, um die Cloud-Profile zu aktualisieren.`,unreachable:`Bambu Cloud ist gerade nicht erreichbar. Lokale und Standard-Profile funktionieren weiterhin.`},orcaCloud:{notAuthenticated:`Bei Orca Cloud anmelden (Profile → Orca Cloud), um Ihre Orca-Profile zu sehen.`,expired:`Orca Cloud-Sitzung abgelaufen — erneut anmelden, um die Orca-Profile zu aktualisieren.`,unreachable:`Orca Cloud ist derzeit nicht erreichbar. Andere Profile funktionieren weiterhin.`},bedType:{label:`Druckbett`,auto:`Auto (aus Prozess-Profil)`,coolPlate:`Cool Plate`,coolPlateSuperTack:`Cool Plate SuperTack`,engineering:`Engineering Plate`,highTemp:`High Temp Plate`,texturedPEI:`Textured PEI Plate`,smoothPEI:`Smooth PEI Plate`}},spoolman:{title:`Spoolman-Integration`,enabled:`Spoolman aktiviert`,url:`Spoolman URL`,connected:`Verbunden`,disconnected:`Nicht verbunden`,testConnection:`Verbindung testen`,sync:`Synchronisieren`,syncing:`Synchronisiert...`,lastSync:`Letzte Synchronisierung`,linkToSpoolman:`Mit Spoolman verknüpfen`,openInSpoolman:`In Spoolman öffnen`,unlinkSpool:`Spule trennen`,unlinkConfirmTitle:`Spule entfernen?`,unlinkConfirmMessage:`Die Spule wird vom Slot entfernt. Die Spulendaten selbst bleiben unverändert.`,selectSpool:`Spule auswählen`,noUnlinkedSpools:`Keine nicht zugewiesenen Spulen verfügbar`,linkSuccess:`Spule erfolgreich zugewiesen`,linkFailed:`Spule konnte nicht zugewiesen werden`,unlinkSuccess:`Spule erfolgreich entfernt`,unlinkFailed:`Spule konnte nicht entfernt werden`,linkedSpool:`Zugewiesene Spule`,spoolId:`Spulen-ID`,fillSourceLabel:`(Spoolman)`,weight:`Gewicht`,remaining:`Verbleibend`,disableWeightSync:`AMS-Gewichtsschätzung deaktivieren`,disableWeightSyncDesc:`Verbleibende Kapazität nicht aus AMS-Schätzungen aktualisieren. Verwenden Sie dies, wenn Sie die Verbrauchserfassung von Spoolman gegenüber den prozentualen AMS-Schätzungen bevorzugen. Neue Spulen verwenden weiterhin die AMS-Schätzung als Anfangsgewicht.`,reportPartialUsage:`Teilverbrauch bei fehlgeschlagenen Drucken melden`,reportPartialUsageDesc:`Wenn ein Druck fehlschlägt oder abgebrochen wird, den geschätzten Filamentverbrauch bis zu diesem Zeitpunkt basierend auf dem Schichtfortschritt melden.`},locations:{title:`Lagerorte`,subtitle:`Regale, Schubladen und andere physische Lagerplätze für Spulen verwalten`,add:`Lagerort hinzufügen`,addShort:`Hinzufügen`,edit:`Lagerort bearbeiten`,name:`Name`,spools:`Spulen`,empty:`Noch keine Lagerorte. Erstellen Sie Ihr erstes Regal oder Ihre erste Schublade.`,manage:`Lagerorte`,createPlaceholder:`z. B. Regal A, Schublade 1`,nameRequired:`Name des Lagerorts ist erforderlich`,created:`Lagerort erstellt`,updated:`Lagerort aktualisiert`,deleted:`Lagerort gelöscht`,saveFailed:`Lagerort konnte nicht gespeichert werden`,deleteFailed:`Lagerort konnte nicht gelöscht werden`,deleteBlocked:`Entfernen Sie zuerst alle Spulen von diesem Lagerort`,confirmDelete:`„{{name}}“ löschen?`,confirmDeleteMessage:`Dieser Lagerort wird aus dem Katalog entfernt. Spulen müssen zuerst verschoben werden.`},inventory:{title:`Spulen-Inventar`,subtitle:`Verwalten Sie Ihre Spulen`,addToInventory:`Zum Inventar hinzufügen`,addToInventoryPending:`Wird hinzugefügt...`,addToInventorySuccess:`Spule zum Inventar hinzugefügt`,addToInventoryFailed:`Spule konnte nicht zum Inventar hinzugefügt werden`,unknownSpoolTitle:`Neues Filament erkannt`,unknownSpoolMessage:`An {{location}} wurde eine Spule mit unbekanntem RFID-Tag erkannt. Jetzt zum Inventar hinzufügen?`,unknownSpoolSlot:`Slot`,bulk:{selectAllVisible:`Alle sichtbaren auswählen`,selectRow:`Zeile auswählen`,selectGroup:`Gruppe auswählen`,selectionCount:`{{count}} ausgewählt`,edit:`Bearbeiten`,printLabels:`Etiketten drucken`,resetUsage:`Verbrauch zurücksetzen`,restore:`Wiederherstellen`,archive:`Archivieren`,delete:`Löschen`,clearSelection:`Auswahl aufheben`,editTitle:`Spulen sammelbearbeiten`,editSubtitle:`Wird auf {{count}} ausgewählte Spulen angewendet. Nur angekreuzte Felder werden aktualisiert.`,editHint:`In ein Feld tippen markiert es für die Aktualisierung — nur angekreuzte Zeilen werden gesendet. Leere Felder bleiben unverändert (Felder leeren geht nur pro Spule).`,useCustom:`„{{value}}" verwenden`,toggleField:`Aktualisierung für dieses Feld umschalten`,changeCount:`{{count}} Felder werden aktualisiert.`,applyPending:`Wird angewendet...`,applyButton:`Auf {{count}} Spulen anwenden`,deleteTitle:`Ausgewählte Spulen löschen`,archiveTitle:`Ausgewählte Spulen archivieren`,restoreTitle:`Ausgewählte Spulen wiederherstellen`,resetUsageTitle:`Verbrauch ausgewählter Spulen zurücksetzen`,deleteMessage:`{{count}} Spulen dauerhaft löschen? Dies kann nicht rückgängig gemacht werden.`,archiveMessage:`{{count}} Spulen archivieren? Sie können später wiederhergestellt werden.`,restoreMessage:`{{count}} archivierte Spulen wiederherstellen?`,resetUsageMessage:`Den "Gesamtverbrauch"-Zähler auf {{count}} Spulen zurücksetzen? Die verbleibende Menge bleibt erhalten.`,updateSuccess:`{{count}} Spulen aktualisiert`,updateFailed:`Sammelaktualisierung fehlgeschlagen`,updatePartial:`{{ok}} Spulen aktualisiert, {{failed}} fehlgeschlagen`,updateAllFailed:`Alle {{count}} Aktualisierungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,deleteSuccess:`{{count}} Spulen gelöscht`,deleteFailed:`Sammellöschung fehlgeschlagen`,deletePartial:`{{ok}} Spulen gelöscht, {{failed}} fehlgeschlagen`,deleteAllFailed:`Alle {{count}} Löschungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,archiveSuccess:`{{count}} Spulen archiviert`,archiveFailed:`Sammelarchivierung fehlgeschlagen`,archivePartial:`{{ok}} Spulen archiviert, {{failed}} fehlgeschlagen`,archiveAllFailed:`Alle {{count}} Archivierungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,restoreSuccess:`{{count}} Spulen wiederhergestellt`,restoreFailed:`Sammelwiederherstellung fehlgeschlagen`,restorePartial:`{{ok}} Spulen wiederhergestellt, {{failed}} fehlgeschlagen`,restoreAllFailed:`Alle {{count}} Wiederherstellungen fehlgeschlagen — Auswahl bleibt erhalten zum erneuten Versuch`,invalidHex:`6 Hex-Zeichen (RRGGBB) oder 8 (RRGGBBAA) eingeben. Anderenfalls wird das Feld nicht übernommen.`},spoolmanMixedContentTitle:`Spoolman lässt sich nicht über HTTPS laden — Browser blockiert gemischte Inhalte`,spoolmanMixedContentBody:`Bambuddy wird über HTTPS ausgeliefert (über deinen Reverse-Proxy), aber deine Spoolman-URL ist nach wie vor HTTP. Browser blockieren gemischte Inhalte aus Sicherheitsgründen, daher kann die eingebettete Spoolman-Oberfläche nicht geladen werden. Spoolman muss ebenfalls über HTTPS erreichbar sein.`,spoolmanMixedContentFixReverseProxy:`Stelle Spoolman hinter denselben Reverse-Proxy wie Bambuddy (Traefik / Nginx / Caddy) mit HTTPS und aktualisiere die Spoolman-URL in den Einstellungen auf die neue HTTPS-Adresse.`,spoolmanMixedContentFixOpenNewTab:`Als Workaround kannst du Spoolman in einem neuen Tab über HTTP öffnen — gemischte Inhalte werden nur innerhalb eingebetteter Frames blockiert, ein eigener Tab funktioniert weiterhin.`,spoolmanOpenInNewTab:`Spoolman in neuem Tab öffnen`,labels:{title:`Spulen-Etiketten drucken`,selectedCount:`{{count}} ausgewählt`,pickSpools:`Wählen Sie, für welche Spulen Etiketten gedruckt werden sollen:`,searchPlaceholder:`Name, Marke oder #ID suchen`,filterByMaterial:`Material:`,allMaterials:`Alle`,selectVisible:`Alle sichtbaren auswählen ({{count}})`,deselectVisible:`Sichtbare abwählen`,clearAll:`Alle entfernen`,noSpoolsToShow:`Keine Spulen anzuzeigen. Filter anpassen und erneut versuchen.`,noMatches:`Keine Spulen entsprechen der aktuellen Suche oder dem Filter.`,printOne:`Etikett für diese Spule drucken`,printLabels:`Etiketten drucken…`,bulkTitle:`Spulen aus den aktuell angezeigten {{count}} zum Etikettieren auswählen`,noSpoolsTitle:`Keine Spulen zum Etikettieren`,error:`Etiketten konnten nicht erstellt werden: {{msg}}`,sortBy:{label:`Sortieren:`,id:`Nach ID`,color:`Nach Farbe`},templates:{amsHolderSmall:{label:`AMS-Halter — klein (74 × 33 mm)`,hint:`Ein Etikett pro Seite; passt zum druckbaren Etikett aus dem MakerWorld-Modell 752566 (AMS-Filament-Etikettenhalter).`},amsHolderLarge:{label:`AMS-Halter — groß (75 × 55 mm)`,hint:`Ein Etikett pro Seite; passt zur Kartoneinleger-Variante des AMS-Filament-Etikettenhalters. Genug Platz für Farbprobe, Marke, Material, ID und QR-Code.`},box40x30:{label:`Boxetikett (40 × 30 mm)`,hint:`Ein Etikett pro Seite; gängige DK/Brother-Rollengröße, ideal für Filament-Beutel und Lager-Etiketten.`},box:{label:`Box label (62 × 29 mm)`,hint:`Ein Etikett pro Seite; für Brother PT/QL und Dymo-Kleinetiketten dimensioniert.`},averyL7160:{label:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,hint:`EU-Bogenformat; 21 Etiketten pro A4-Seite.`},avery5160:{label:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,hint:`US-Bogenformat; 30 Etiketten pro Letter-Seite.`}}},csv:{importButton:`CSV importieren`,exportButton:`CSV exportieren`,modalTitle:`Spulen aus CSV importieren`,selectFile:`CSV-Datei auswählen oder hierher ziehen`,dragHint:`Kopfzeile: material (erforderlich), brand, subtype, color_name, rgba, …`,parsing:`Datei wird gelesen…`,previewError:`CSV-Datei konnte nicht gelesen werden`,validCount:`{{count}} gültig`,errorCount:`{{count}} Fehler`,skippedCount:`{{count}} übersprungen`,colRow:`Zeile`,colStatus:`Status`,colColor:`Farbe`,colorResolved:`Farbe aus Katalog übernommen`,colorCrossMaterial:`Farbe von einem anderen Material übernommen — keine exakte Übereinstimmung im Katalog`,duplicateExisting:`Eine Spule mit diesem Material, dieser Marke und Farbe existiert bereits — sie wird trotzdem als neue Spule importiert`,spoolmanHint:`Im Spoolman-Modus den integrierten CSV-Import/-Export von Spoolman verwenden.`,importValidRows:`{{count}} gültige Zeilen importieren`,noValidRows:`Keine gültigen Zeilen`,importing:`Wird importiert…`,importSuccess:`{{count}} Spulen importiert`,importError:`Import fehlgeschlagen`,exportError:`Export fehlgeschlagen`},addSpool:`Spule hinzufügen`,copySpool:`Spule kopieren`,editSpool:`Spule bearbeiten`,material:`Material`,selectMaterial:`Material auswählen...`,subtype:`Untertyp`,brand:`Marke`,searchBrand:`Marke suchen...`,useCustomBrand:`"{{brand}}" verwenden`,useCustomMaterial:`Benutzerdefiniertes Material verwenden: {{material}}`,colorName:`Farbname`,colorNamePlaceholder:`Jadeweiß, Feuerrot...`,color:`Farbe`,hexColor:`Hex-Farbe`,pickColor:`Benutzerdefinierte Farbe wählen`,labelWeight:`Nenngewicht`,coreWeight:`Leergewicht der Spule`,searchSpoolWeight:`Spulengewicht suchen...`,weightUsed:`Verbraucht`,currentWeight:`Restgewicht`,measuredWeight:`Gemessenes Gewicht`,spoolName:`Spule`,costPerKg:`Kosten pro kg`,storageLocation:`Lagerstandort`,storageLocationPlaceholder:`z.B. Regal A, Schublade 1`,openInInventory:`Im Inventar öffnen`,measuredWeightError:`Das gemessene Gewicht muss zwischen {{min}}g und {{max}}g liegen.`,slicerFilament:`Slicer-Filament`,slicerFilamentName:`Slicer-Preset-Name`,slicerPreset:`Slicer-Preset`,searchPresets:`Filament-Presets suchen...`,selectedPreset:`Ausgewählt`,noPresetsFound:`Keine Presets gefunden`,tempOverrides:`Temperatur-Überschreibungen`,note:`Notiz`,notePlaceholder:`Zusätzliche Notizen zu dieser Spule...`,category:`Kategorie`,categoryPlaceholder:`z. B. Produktion, Prototyp, Kunde A`,categoryNone:`Ohne Kategorie`,storageLocationNone:`Kein Lagerort`,lowStockThresholdOverride:`Niedrigbestandsschwelle (diese Spule)`,lowStockThresholdOverrideHelp:`Leer lassen, um den globalen Schwellenwert ({{global}}%) zu verwenden.`,clearRfid:`RFID-Tag löschen`,rfidCleared:`RFID-Tag gelöscht`,archive:`Archivieren`,restore:`Wiederherstellen`,noSpools:`Noch keine Spulen. Fügen Sie Ihre erste Spule hinzu.`,noAvailableSpools:`Keine Spulen verfügbar. Fügen Sie eine Spule zum Inventar hinzu oder lösen Sie eine aus einem anderen Slot.`,kProfiles:`K-Profile`,addKProfile:`K-Profil hinzufügen`,assignSpool:`Spule zuweisen`,unassignSpool:`Zuweisung aufheben`,assignSuccess:`Spule zugewiesen und AMS-Slot konfiguriert`,assignPendingInsert:`Zugewiesen. Slot wird beim Einsetzen der Spule konfiguriert.`,assignFailed:`Spulenzuweisung fehlgeschlagen`,selectSpool:`Wählen Sie eine Spule für diesen Slot`,assigned:`Zugewiesen`,assigning:`Wird zugewiesen...`,searchSpools:`Spulen suchen...`,showAllSpools:`Alle Spulen anzeigen`,spoolmanSpools:`Spoolman-Spulen`,allMaterials:`Alle Materialien`,filterByBrand:`Nach Marke filtern...`,showArchived:`Archivierte anzeigen`,quickAdd:`Schnellerfassung (Lager)`,quantity:`Menge`,stock:`Lager`,configured:`Konfiguriert`,spoolsCreated:`{{count}} Spulen erstellt`,spoolsPartiallyCreated:`{{created}} von {{total}} Spulen erstellt (einige fehlgeschlagen)`,spoolCreated:`Spule erstellt`,spoolUpdated:`Spule aktualisiert`,spoolDeleted:`Spule gelöscht`,deepLinkSpoolNotFound:`Spule nicht gefunden`,deepLinkFetchFailed:`Spule konnte nicht geladen werden — bitte erneut versuchen`,spoolArchived:`Spule archiviert`,spoolRestored:`Spule wiederhergestellt`,kProfileSaveFailed:`K-Profil-Einstellungen konnten nicht gespeichert werden`,syncWeightSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise gelöscht`,syncWeightSpoolmanUnreachable:`Spoolman ist nicht erreichbar — bitte später erneut versuchen`,syncWeightFailed:`Gewicht konnte nicht synchronisiert werden`,spoolmanUnreachable:`Spoolman ist nicht erreichbar — bitte später erneut versuchen`,deleteSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,deleteFailed:`Spule konnte nicht gelöscht werden`,archiveSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,archiveFailed:`Spule konnte nicht archiviert werden`,restoreSpoolNotFound:`Spule nicht gefunden — sie wurde möglicherweise bereits gelöscht`,restoreFailed:`Spule konnte nicht wiederhergestellt werden`,saveFailed:`Änderungen konnten nicht gespeichert werden`,tagClearFailed:`Tag konnte nicht gelöscht werden`,deleteConfirm:`Möchten Sie diese Spule wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,archiveConfirm:`Möchten Sie diese Spule wirklich archivieren?`,advancedSettings:`Erweiterte Einstellungen`,filamentInfoTab:`Filament-Info`,paProfileTab:`PA-Profil`,filamentInfo:`Filament`,additional:`Zusätzlich`,loadingPresets:`Cloud-Presets werden geladen...`,cloudConnected:`Cloud verbunden`,cloudNotConnected:`Cloud nicht verbunden (Standardwerte)`,recentColors:`Zuletzt`,searchColors:`Farben suchen...`,searchResults:`Suchergebnisse`,allColors:`Alle Farben`,commonColors:`Häufige Farben`,showLess:`Weniger`,showAll:`Alle`,noColorsFound:`Keine Farben gefunden`,noResults:`Keine Ergebnisse`,extraColorsLabel:`Zusätzliche Farben`,extraColorsPlaceholder:`EC984C,#6CD4BC,A66EB9,D87694`,extraColorsHint:`2 bis 8 Hex-Stops, durch Kommas getrennt. Wird als Verlauf dargestellt.`,extraColorsInvalid:`Ungültige Hex-Werte ignoriert: {{tokens}}`,colorEffectLabel:`Effekt`,colorEffect:{none:`Keiner`,sparkle:`Glitzer`,wood:`Holz`,marble:`Marmor`,glow:`Leuchtend`,matte:`Matt`,silk:`Seide`,galaxy:`Galaxie`,rainbow:`Regenbogen`,metal:`Metallic`,translucent:`Lichtdurchlässig`,gradient:`Verlauf`,dualColor:`Zweifarbig`,triColor:`Dreifarbig`,multicolor:`Mehrfarbig`},selectMaterialFirst:`Bitte zuerst ein Material im Filament-Info Tab auswählen.`,noPrintersConfigured:`Keine Drucker konfiguriert. Fügen Sie Drucker hinzu.`,matchingFilter:`Filter`,anyBrand:`Jede Marke`,anyVariant:`Jede Variante`,autoSelect:`Auto-Auswahl`,matches:`Treffer`,match:`Treffer`,noMatches:`Keine Treffer`,connected:`Verbunden`,offline:`Offline`,printerOffline:`Drucker ist offline. Verbinden Sie ihn, um Kalibrierungsprofile anzuzeigen.`,noKProfilesMatch:`Keine K-Profile stimmen mit dem gewählten Filament überein.`,leftNozzle:`Linke Düse`,rightNozzle:`Rechte Düse`,profilesSelected:`Kalibrierungsprofil(e) ausgewählt`,totalInventory:`Gesamtbestand`,totalConsumed:`Gesamtverbrauch`,byMaterial:`Nach Material`,inPrinter:`Im Drucker`,lowStock:`Niedriger Bestand`,sinceTracking:`Seit Beginn der Erfassung`,resetConsumedCounter:`Zähler zurücksetzen`,resetConsumedCounterTooltip:`Den verbrauchten Gramm-Zähler dieser Spule auf null setzen. Das Restgewicht bleibt unverändert.`,resetConsumedCounterConfirm:`Verbrauchten Gramm-Zähler dieser Spule auf 0 zurücksetzen? Künftige Drucke zählen wieder ab null. Die Spule selbst, ihre Restgewichtsberechnung und Ihre Einstellungen bleiben unverändert.`,resetAllConsumedCounters:`Alle Zähler zurücksetzen`,resetAllConsumedCountersTooltip:`Den verbrauchten Gramm-Zähler auf jeder Spule auf null setzen. Die Restgewichte bleiben unverändert.`,resetAllConsumedCountersConfirm:`Verbrauchten Gramm-Zähler auf allen {{count}} Spulen (archivierte eingeschlossen) auf 0 zurücksetzen? Das löscht den Wert „Insgesamt verbraucht“, sodass künftige Drucke wieder ab null gezählt werden. Spulen und Restgewichte bleiben unverändert.`,consumedCounterReset:`Zähler zurückgesetzt`,allConsumedCountersReset:`Zähler für {{count}} Spule(n) zurückgesetzt`,resetConsumedCounterFailed:`Zähler konnte nicht zurückgesetzt werden`,loadedInAms:`Im AMS/Ext geladen`,remaining:`Verbleibend`,weightCheck:`Gewichtskontrolle`,lastWeighed:`Zuletzt gewogen`,neverWeighed:`Nie gewogen`,search:`Spulen suchen...`,showing:`Zeige`,to:`bis`,of:`von`,show:`Zeige`,spools:`Spulen`,spool:`Spule`,page:`Seite`,noSpoolsMatch:`Keine Ergebnisse`,noSpoolsMatchDesc:`Versuchen Sie, Ihre Suche oder Filter anzupassen.`,active:`Aktiv`,archived:`Archiviert`,all:`Alle`,used:`Verwendet`,new:`Neu`,clearFilters:`Filter löschen`,table:`Tabelle`,cards:`Karten`,net:`Netto`,groupSimilar:`Gruppieren`,groupedSpools:`{{count}} identische Spulen`,groupedRows:`Zeilen`,columns:`Spalten`,configureColumns:`Spalten konfigurieren`,configureColumnsDesc:`Ziehen zum Neuordnen oder Pfeile verwenden. Sichtbarkeit mit dem Augensymbol umschalten.`,visible:`sichtbar`,reset:`Zurücksetzen`,cancel:`Abbrechen`,applyChanges:`Änderungen anwenden`,moveUp:`Nach oben`,moveDown:`Nach unten`,hideColumn:`Spalte ausblenden`,showColumn:`Spalte einblenden`,linkToSpool:`Mit Spule verknüpfen`,tagLinked:`Tag mit Spule verknüpft`,tagLinkFailed:`Tag-Verknüpfung fehlgeschlagen`,tagAlreadyLinked:`Tag bereits mit anderer Spule verknüpft`,unknownTag:`Unbekannter RFID-Tag erkannt`,usageHistory:`Verbrauchshistorie`,noUsageHistory:`Noch kein Verbrauch erfasst`,printName:`Druckname`,weightConsumed:`Verbrauchtes Gewicht`,clearHistory:`Löschen`,historyCleared:`Verbrauchshistorie gelöscht`,fillSourceLabel:`(Inv)`,lowStockThresholdError:`Der Schwellenwert muss zwischen 0.1 und 99.9 liegen`,assignMismatchTitle:`Material stimmt nicht überein`,assignMismatchMessage:`Das ausgewählte Spulenmaterial "{{spoolMaterial}}" stimmt nicht mit dem Tray-Material "{{trayMaterial}}" für {{location}} überein. Trotzdem zuweisen?`,assignMismatchConfirm:`Trotzdem zuweisen`,assignPartialMismatchMessage:`Das Spulenmaterial "{{spoolMaterial}}" ist ähnlich, stimmt aber nicht genau mit "{{trayMaterial}}" in {{location}} überein. Möchten Sie fortfahren?`,assignProfileMismatchMessage:`Das Spulenprofil "{{spoolProfile}}" stimmt nicht mit dem Fachprofil "{{trayProfile}}" in {{location}} überein. Möchten Sie fortfahren?`,assignReconfigureNote:`Der AMS-Slot wird mit dem Profil der Spule neu konfiguriert.`,spoolmanFilamentCatalog:`Spoolman-Filamentkatalog`,pickFromSpoolmanCatalog:`Aus Spoolman-Katalog wählen…`,spoolmanFilamentSelected:`Filament aus Spoolman-Katalog ausgewählt`,spoolmanFilamentUnlinked:`Verknüpfung mit Filamentkatalog aufgehoben`,noSpoolmanFilaments:`Keine Filamente im Spoolman-Katalog gefunden`,spoolmanFilamentColorSwatch:`Filamentfarbe`,spoolWeightManagedBySpoolman:`Das Leerspulengewicht wird pro Filamenttyp in Spoolman verwaltet`,spoolmanCatalogLoadFailed:`Spoolman-Filamentkatalog konnte nicht geladen werden`},timelapse:{title:`Zeitraffer`,create:`Zeitraffer erstellen`,download:`Herunterladen`,delete:`Löschen`,preview:`Vorschau`,frameRate:`Bildrate`,quality:`Qualität`,processing:`Wird verarbeitet...`,noTimelapses:`Keine Zeitraffer verfügbar`},ams:{title:`AMS`,slot:`Slot`,empty:`Leer`,emptySlot:`Leerer Slot`,slotEmpty:`Leer`,slotUnconfigured:`?`,emptySlotReset:`Keine Spule zugewiesen`,unknown:`Unbekannt`,humidity:`Luftfeuchtigkeit`,temperature:`Temperatur`,filamentType:`Filamenttyp`,filamentColor:`Farbe`,remaining:`Verbleibend`,history:`AMS-Verlauf`,noHistory:`Kein Verlauf verfügbar`,configureSlot:`Slot konfigurieren`,externalSpool:`Externe Spule`,profile:`Profil`,kFactor:`K-Faktor`,fill:`Füllstand`,configure:`Konfigurieren`,used:`verwendet`,remainingUnit:`verbleibend`},printModal:{title:`Druck starten`,selectPrinter:`Drucker auswählen`,selectPlate:`Platte auswählen`,filamentMapping:`Filamentzuordnung`,totalCost:`Gesamtkosten:`,slotRemainingShort:` - {{grams}}g übrig`,printSettings:`Druckeinstellungen`,bedLeveling:`Bett-Nivellierung`,flowCalibration:`Fluss-Kalibrierung`,vibrationCalibration:`Vibrations-Kalibrierung`,layerInspection:`Erste-Schicht-Prüfung`,timelapse:`Zeitraffer`,startPrint:`Druck starten`,addToQueue:`Zur Warteschlange hinzufügen`,cancel:`Abbrechen`,noPrintersAvailable:`Keine Drucker verfügbar`,printerBusy:`Drucker ist beschäftigt`,printerOffline:`Drucker ist offline`,sameTypeDifferentColor:`Gleicher Typ, andere Farbe`,filamentTypeNotLoaded:`Filamenttyp nicht geladen`,openCalendar:`Kalender öffnen`,leftNozzle:`L`,rightNozzle:`R`,leftNozzleTooltip:`Linke Düse`,rightNozzleTooltip:`Rechte Düse`,filamentOverride:`Filament-Überschreibung`,filamentOverrideHint:`Filamente für modellbasierte Zuweisung optional überschreiben. Der Planer wird gegen die ausgewählten Filamente statt der ursprünglichen 3MF-Werte abgleichen.`,originalFilament:`Original`,overrideWith:`Ersetzen mit`,resetToOriginal:`Auf Original zurücksetzen`,insufficientFilamentTitle:`Nicht genug Filament`,insufficientFilamentMessage:`Einige zugewiesene Spulen haben weniger Filament als dieser Druck benötigt:`,insufficientFilamentLine:`{{printer}} - {{slot}}: benötigt {{required}}g, verbleibend {{remaining}}g`,printAnyway:`Trotzdem drucken`,forceColorMatch:`Farbe erzwingen`,staggerPrinterStarts:`Druckerstarts staffeln`,staggerGroupSize:`Gruppengröße`,staggerInterval:`Intervall (Min.)`,staggerPreview:`{{printers}} Drucker → {{groups}} Gruppen à {{size}}, Start alle {{interval}} Min.`,staggerLastGroup:`letzte Gruppe: {{count}}`,staggerTotal:`insgesamt: {{minutes}} Min.`,staggerToPrinters:`Gestaffelt an {{count}} Drucker senden`,gcodeInjection:`Auto-Print G-code einfügen`},backup:{includesEncryptionKey:`Lokale Sicherungen enthalten die MFA-Schlüsseldatei (DATA_DIR/.mfa_encryption_key), damit ein Backup-ZIP selbstkonsistent ist. Behandle das ZIP als sensibel — wer Zugriff auf die Datei hat, kann die darin enthaltenen OIDC-Client-Secrets und TOTP-Geheimnisse entschlüsseln.`,title:`Sichern & Wiederherstellen`,createBackup:`Sicherung erstellen`,restoreBackup:`Sicherung wiederherstellen`,restoreDescription:`Alle Daten aus einer Sicherungsdatei ersetzen`,downloadBackup:`Sicherung herunterladen`,uploadBackup:`Sicherung hochladen`,lastBackup:`Letzte Sicherung`,autoBackup:`Automatische Sicherung`,backupNow:`Jetzt sichern`,restoreWarning:`Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.`,includeArchives:`Archive einschließen`,includeSettings:`Einstellungen einschließen`,includeProfiles:`Profile einschließen`,backupSuccess:`Sicherung erfolgreich erstellt`,restoreSuccess:`Sicherung erfolgreich wiederhergestellt`,backupFailed:`Sicherung fehlgeschlagen`,restoreFailed:`Wiederherstellung fehlgeschlagen`,restoreNote:`Virtueller Drucker wird während der Wiederherstellung gestoppt`,githubBackup:`Git-Backup`,enabled:`Aktiviert`,cloudLoginRequired:`Bambu Cloud Login erforderlich. Melden Sie sich unter Profile → Cloud-Profile an, um GitHub-Backup zu aktivieren.`,cloudLoginRequiredShort:`Cloud-Login erforderlich`,githubDescription:`Synchronisieren Sie Ihre Profile automatisch mit einem privaten GitHub-Repository für Backup und Versionsverlauf.`,repoIsPrivate:`Repository ist privat — Sicherung möglich.`,repoIsPublicWarning:`Das Repository ist ÖFFENTLICH. Bambuddy-Backups enthalten MQTT-Zugangsdaten, Home-Assistant-Tokens, Prometheus-Tokens, Ihre Bambu-Cloud-E-Mail-Adresse und über K-Profile auch Drucker-Zugangscodes. Speichern ist blockiert, bis Sie das Repository in den Einstellungen Ihres Anbieters auf privat stellen.`,repoVisibilityUnknown:`Die Sichtbarkeit des Repositories konnte nicht bestimmt werden. Bambuddy sichert nur in Repositories, die nachweislich privat sind; Speichern wird blockiert.`,repositoryUrl:`Repository-URL`,repoUrlPlaceholderGitHub:`https://github.com/username/repo-name`,repoUrlPlaceholderGitea:`https://gitea.example.com/username/repo-name`,repoUrlPlaceholderForgejo:`https://forgejo.example.com/username/repo-name`,repoUrlPlaceholderGitLab:`https://gitlab.com/username/repo-name`,allowInsecureHttp:`Unsicheres HTTP erlauben`,allowInsecureHttpHint:`Für selbst gehostete Instanzen in privaten Netzwerken ohne TLS aktivieren`,personalAccessToken:`Persönlicher Zugriffstoken`,tokenSaved:`(gespeichert)`,enterNewToken:`Neuen Token eingeben zum Aktualisieren`,tokenHint:`Feingranularer Token mit Lese-/Schreibberechtigung für Inhalte`,branch:`Branch`,provider:`Git-Anbieter`,providerGitHub:`GitHub`,providerGitLab:`GitLab`,providerGitea:`Gitea`,providerForgejo:`Forgejo`,manualOnly:`Nur manuell`,hourly:`Stündlich`,daily:`Täglich`,weekly:`Wöchentlich`,includeInBackup:`In Sicherung einschließen`,kProfiles:`K-Profile`,kProfilesDescription:`Druckvorschub-Kalibrierung von verbundenen Druckern`,noPrintersConnected:`Keine Drucker verbunden`,printersConnected:`{{connected}}/{{total}} verbunden`,cloudProfiles:`Cloud-Profile`,cloudProfilesDescription:`Filament-, Drucker- und Prozessprofile aus der Bambu Cloud`,appSettings:`App-Einstellungen`,appSettingsDescription:`Bambuddy-Konfiguration (komplette Datenbank)`,spoolInventory:`Spulenbestand`,spoolInventoryDescription:`Filamentspulen, Nutzungsverlauf und Kostenverfolgung`,printArchives:`Druckarchive`,printArchivesDescription:`Druckverlauf-Metadaten (keine GCode/3MF-Dateien)`,lastBackupAt:`Letzte Sicherung:`,noBackupsYet:`Noch keine Sicherungen`,next:`Nächste:`,startingBackup:`Sicherung wird gestartet...`,test:`Test`,enableBackup:`Sicherung aktivieren`,testConnection:`Verbindung testen`,enterRepoUrl:`Repository-URL eingeben`,enterRepoAndToken:`Repository-URL und Zugriffstoken eingeben`,repoRequired:`Repository-URL ist erforderlich`,tokenRequired:`Zugriffstoken ist erforderlich`,githubBackupEnabled:`GitHub-Backup aktiviert`,tokenUpdated:`Token aktualisiert`,settingsSaved:`Einstellungen gespeichert`,failedToSave:`Speichern fehlgeschlagen: {{message}}`,backupCompleteFiles:`Sicherung abgeschlossen - {{count}} Dateien aktualisiert`,backupSkippedNoChanges:`Sicherung übersprungen - keine Änderungen`,backupFailed2:`Sicherung fehlgeschlagen: {{message}}`,clearedLogs:`{{count}} Protokolle gelöscht`,failedToClearLogs:`Protokolle löschen fehlgeschlagen: {{message}}`,history:`Verlauf`,clear:`Löschen`,date:`Datum`,status:`Status`,commit:`Commit`,localBackup:`Lokale Sicherung`,localBackupDescription:`Erstellen Sie eine vollständige Sicherung Ihrer Bambuddy-Daten einschließlich Datenbank, Archive, Uploads und aller Dateien.`,downloadBackupLabel:`Sicherung herunterladen`,completeBackupZip:`Vollständige Sicherung: Datenbank + alle Dateien (ZIP)`,download:`Herunterladen`,preparingBackup:`Sicherung wird vorbereitet...`,creatingArchive:`Sicherungsarchiv wird erstellt... Dies kann bei großen Archiven eine Weile dauern.`,downloadingFile:`Sicherungsdatei wird heruntergeladen...`,backupDownloaded:`Sicherung erfolgreich heruntergeladen`,failedToCreateBackup:`Sicherung erstellen fehlgeschlagen: {{message}}`,restore:`Wiederherstellen`,restoreReplacesAll:`Wiederherstellung ersetzt alle Daten.`,restoreReplacesAllDetail:`Ihre aktuelle Datenbank und Dateien werden vollständig ersetzt. Nach der Wiederherstellung ist ein Neustart erforderlich.`,restoreConfirmTitle:`Sicherung wiederherstellen`,restoreConfirmMessage:`Sind Sie sicher, dass Sie von "{{filename}}" wiederherstellen möchten? Dies ersetzt Ihre aktuelle Datenbank und alle Dateien vollständig. Die Anwendung muss nach der Wiederherstellung neu gestartet werden.`,restoreConfirmButton:`Sicherung wiederherstellen`,uploadingFile:`Sicherungsdatei wird hochgeladen...`,backupRestoredRestart:`Sicherung wiederhergestellt. Bitte starten Sie Bambuddy neu.`,failedToRestore:`Sicherung wiederherstellen fehlgeschlagen. Bitte überprüfen Sie das Dateiformat.`,reloadNow:`Jetzt neu laden`,creatingBackup:`Sicherung erstellen`,restoringBackup:`Sicherung wiederherstellen`,preparing:`Vorbereiten...`,processing:`Verarbeiten...`,doNotClosePage:`Bitte schließen Sie diese Seite nicht und navigieren Sie nicht weg. Dieser Vorgang kann bei großen Sicherungen mehrere Minuten dauern.`,restoring:`Wiederherstellen...`,restoreComplete:`Wiederherstellung abgeschlossen`,restoreFailed2:`Wiederherstellung fehlgeschlagen`,importSettings:`Einstellungen aus einer Sicherungsdatei importieren`,pleaseWaitRestoring:`Bitte warten Sie, während Ihre Daten wiederhergestellt werden`,selectBackupFile:`Klicken Sie, um eine Sicherungsdatei auszuwählen (.json oder .zip)`,duplicateHandling:`So funktioniert die Duplikatbehandlung:`,matchPrinters:`Drucker`,matchPrintersBy:`abgeglichen nach Seriennummer`,matchSmartPlugs:`Smart Plugs`,matchSmartPlugsBy:`abgeglichen nach IP-Adresse`,matchNotificationProviders:`Benachrichtigungsanbieter`,matchNotificationProvidersBy:`abgeglichen nach Name`,matchFilaments:`Filamente`,matchFilamentsBy:`abgeglichen nach Name + Typ + Marke`,matchArchives:`Archive`,matchArchivesBy:`abgeglichen nach Inhaltshash (immer übersprungen)`,matchPendingUploads:`Ausstehende Uploads`,matchPendingUploadsBy:`abgeglichen nach Dateiname`,matchSettingsTemplates:`Einstellungen & Vorlagen`,matchSettingsTemplatesBy:`immer überschrieben`,replaceExisting:`Vorhandene Daten ersetzen`,keepExisting:`Vorhandene Daten behalten`,overwriteDescription:`Bereits vorhandene Elemente mit Sicherungsdaten überschreiben`,keepDescription:`Nur Elemente wiederherstellen, die noch nicht vorhanden sind`,overwriteCaution:`Achtung:`,overwriteWarning:`Das Überschreiben ersetzt Ihre aktuellen Konfigurationen durch Daten aus der Sicherung. Drucker-Zugangscodes werden aus Sicherheitsgründen nie überschrieben.`,cancel:`Abbrechen`,processingBackup:`Sicherungsdatei wird verarbeitet...`,itemsRestored:`Wiederhergestellt`,itemsSkipped:`Übersprungen`,restored:`Wiederhergestellt`,skippedAlreadyExist:`Übersprungen (bereits vorhanden)`,filesCategory:`Dateien (3MF, Thumbnails, etc.)`,andMore:`...und {{count}} weitere`,newApiKeysGenerated:`Neue API-Schlüssel generiert`,keysShownOnce:`Diese Schlüssel werden nur einmal angezeigt. Kopieren Sie sie jetzt!`,copy:`Kopieren`,noDataFound:`In der Sicherungsdatei wurden keine Daten zur Wiederherstellung gefunden.`,close:`Schließen`,scheduledBackup:`Geplante Backups`,scheduledBackupDescription:`Backup-Snapshots automatisch nach Zeitplan erstellen. Ausgabeverzeichnis kann auf einen NAS oder externen Speicher gemountet werden.`,frequency:`Frequenz`,backupTime:`Zeit`,retention:`Aufbewahrung`,retentionDescription:`Anzahl der zu behaltenden Backups`,outputPath:`Ausgabepfad`,outputPathPlaceholder:`Standard: {{path}}`,outputPathDescription:`Leer lassen für den Standardort`,runNow:`Jetzt ausführen`,backupFiles:`Backup-Dateien`,noScheduledBackups:`Noch keine Backups`,deleteBackup:`Löschen`,deleteBackupConfirm:`Diese Backup-Datei löschen?`,backupRunning:`Backup läuft...`,scheduledBackupComplete:`Backup erfolgreich abgeschlossen`,scheduledBackupFailed:`Backup fehlgeschlagen`,nextBackup:`Nächstes Backup`,backupSize:`Größe`,localTimeHint:`Ortszeit ({{tz}})`,defaultPathLabel:`Standard:`,categories:{settings:`Einstellungen`,notification_providers:`Benachrichtigungsanbieter`,notification_templates:`Benachrichtigungsvorlagen`,smart_plugs:`Smart Plugs`,printers:`Drucker`,filaments:`Filamente`,maintenance_types:`Wartungstypen`,archives:`Archive`,projects:`Projekte`,pending_uploads:`Ausstehende Uploads`,external_links:`Externe Links`,api_keys:`API-Schlüssel`}},tags:{title:`Tags`,addTag:`Tag hinzufügen`,editTag:`Tag bearbeiten`,deleteTag:`Tag löschen`,tagName:`Tag-Name`,tagColor:`Tag-Farbe`,noTags:`Keine Tags`,deleteConfirm:`Möchten Sie diesen Tag wirklich löschen?`,manageTags:`Tags verwalten`},uploadModal:{title:`3MF-Dateien hochladen`,dragDrop:`3MF-Dateien hierher ziehen`,or:`oder`,browseFiles:`Dateien durchsuchen`,extractionInfo:`Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.`,uploaded:`hochgeladen`,failed:`fehlgeschlagen`,uploading:`Wird hochgeladen...`,upload:`Hochladen`,uploadFailed:`Hochladen fehlgeschlagen`},editArchive:{title:`Archiv bearbeiten`,name:`Name`,namePlaceholder:`Druckname`,printer:`Drucker`,noPrinter:`Kein Drucker`,project:`Projekt`,noProject:`Kein Projekt`,itemsPrinted:`Gedruckte Teile`,itemsPrintedHelp:`Anzahl der in diesem Druckauftrag produzierten Teile`,notes:`Notizen`,notesPlaceholder:`Notizen zu diesem Druck hinzufügen...`,externalLink:`Externer Link`,externalLinkPlaceholder:`https://printables.com/model/...`,externalLinkHelp:`Link zu Printables, Thingiverse oder anderer Quelle`,tags:`Tags`,tagsPlaceholder:`Tags hinzufügen...`,addMoreTags:`Weitere Tags hinzufügen...`,matchingTags:`Übereinstimmend mit "{{query}}"`,existingTags:`Vorhandene Tags`,clickToAdd:`(zum Hinzufügen klicken)`,status:`Status`,failureReason:`Fehlergrund`,selectReason:`Grund auswählen...`,photos:`Fotos des Druckergebnisses`,photosHelp:`Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen`,printResult:`Druckergebnis`,saving:`Wird gespeichert...`,failureReasons:{adhesionFailure:`Haftungsfehler`,spaghettiDetached:`Spaghetti / Abgelöst`,layerShift:`Schichtversatz`,cloggedNozzle:`Verstopfte Düse`,filamentRunout:`Filament aufgebraucht`,warping:`Verformung`,stringing:`Fadenziehen`,underExtrusion:`Unterextrusion`,powerFailure:`Stromausfall`,userCancelled:`Vom Benutzer abgebrochen`,other:`Sonstiges`},statuses:{completed:`Abgeschlossen`,failed:`Fehlgeschlagen`,aborted:`Abgebrochen`,printing:`Druckt`}},kProfiles:{title:`K-Profile`,noPrintersConfigured:`Keine Drucker konfiguriert`,addPrinterInSettings:`Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten`,noActivePrinters:`Keine aktiven Drucker`,enablePrinterConnection:`Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen`,loadingProfiles:`Lade K-Profile...`,printerOffline:`Drucker offline`,printerOfflineDesc:`Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.`,noMatchingProfiles:`Keine passenden Profile`,noMatchingProfilesDesc:`Keine Profile entsprechen Ihren Suchkriterien`,noKProfiles:`Keine K-Profile`,noKProfilesDesc:`Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden`,createFirstProfile:`Erstes Profil erstellen`,printer:`Drucker`,nozzle:`Düse`,refresh:`Aktualisieren`,addProfile:`Profil hinzufügen`,export:`Exportieren`,import:`Importieren`,select:`Auswählen`,selectAll:`Alle auswählen`,delete:`Löschen`,searchPlaceholder:`Nach Name oder Filament suchen...`,allExtruders:`Alle Extruder`,leftOnly:`Nur links`,rightOnly:`Nur rechts`,allFlow:`Alle Flusstypen`,hfOnly:`Nur HF`,sOnly:`Nur S`,sortName:`Sortieren: Name`,sortKValue:`Sortieren: K-Wert`,sortFilament:`Sortieren: Filament`,leftExtruder:`Linker Extruder`,rightExtruder:`Rechter Extruder`,modal:{addTitle:`K-Profil hinzufügen`,editTitle:`K-Profil bearbeiten`,profileName:`Profilname`,profileNamePlaceholder:`Mein PLA-Profil`,kValue:`K-Wert`,kValuePlaceholder:`0,020`,kValueHelp:`Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG`,filament:`Filament`,selectFilament:`Filament auswählen...`,noFilamentsHelp:`Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.`,flowType:`Flusstyp`,highFlow:`Hoher Durchfluss`,standard:`Standard`,nozzleSize:`Düsengröße`,extruder:`Extruder`,extruders:`Extruder`,left:`Links`,right:`Rechts`,notes:`Notizen (lokal gespeichert)`,notesPlaceholder:`Notizen zu diesem Profil hinzufügen...`,notesHelp:`Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker`,syncing:`Synchronisiert mit Drucker...`,savingExtruder:`Speichern auf Extruder {{current}}/{{total}}...`,pleaseWait:`Bitte warten`},deleteConfirm:{title:`Profil löschen`,cannotUndo:`Dies kann nicht rückgängig gemacht werden`,message:`Möchten Sie "{{name}}" wirklich vom Drucker löschen?`},bulkDelete:{title:`Profile löschen`,cannotUndo:`Dies kann nicht rückgängig gemacht werden`,message:`Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?`},toast:{profileSaved:`K-Profil gespeichert`,profilesSaved:`K-Profil auf {{count}} Extrudern gespeichert`,selectAtLeastOneExtruder:`Bitte wählen Sie mindestens einen Extruder aus`,profileDeleted:`K-Profil gelöscht`,profilesDeleted:`{{count}} Profile gelöscht`,exportedProfiles:`{{count}} Profile exportiert`,importedProfiles:`{{count}} von {{total}} Profilen importiert`,noProfilesToExport:`Keine Profile zum Exportieren`,invalidFileFormat:`Ungültiges Dateiformat`,failedToParseImport:`Import-Datei konnte nicht gelesen werden`,failedToSaveBatch:`K-Profile konnten nicht gespeichert werden`,noteSaved:`Notiz gespeichert`,failedToSaveNote:`Notiz konnte nicht gespeichert werden`},permission:{noRead:`Sie haben keine Berechtigung, Profile zu aktualisieren`,noCreate:`Sie haben keine Berechtigung, Profile hinzuzufügen`,noUpdate:`Sie haben keine Berechtigung, K-Profile zu aktualisieren`,noDelete:`Sie haben keine Berechtigung, K-Profile zu löschen`,noExport:`Sie haben keine Berechtigung, Profile zu exportieren`,noImport:`Sie haben keine Berechtigung, Profile zu importieren`}},virtualPrinter:{title:`Virtueller Drucker`,running:`Läuft`,stopped:`Gestoppt`,description:{default:`Aktiviere einen virtuellen Drucker, der in Bambu Studio und OrcaSlicer erscheint. Dateien, die an diesen Drucker gesendet werden, werden direkt archiviert ohne zu drucken.`,proxy:`Aktiviere einen Proxy, der Slicer-Datenverkehr an einen echten Drucker weiterleitet, um Ferndruck über jedes Netzwerk zu ermöglichen.`},enable:{title:`Virtuellen Drucker aktivieren`,visibleInSlicer:`Sichtbar als "Bambuddy" in der Slicer-Erkennung`,proxyingTo:`Proxy zu {{name}}`,notActive:`Nicht aktiv`},model:{title:`Druckermodell`,description:`Wähle welches Druckermodell emuliert werden soll.`,restartWarning:`Das Ändern des Modells startet den virtuellen Drucker neu`},accessCode:{title:`Zugangscode`,isSet:`Zugangscode ist gesetzt`,notSet:`Kein Zugangscode gesetzt - erforderlich zum Aktivieren`,placeholder:`8-Zeichen-Code eingeben`,placeholderChange:`Neuen Code eingeben zum Ändern`,hint:`Muss genau 8 Zeichen lang sein. Wird von Slicern zur Authentifizierung verwendet.`,charCount:`({{count}}/8)`,inheritedFromTarget:`Vom Zieldrucker übernommen`,derivedFromTargetHint:`Verwendet den Zugangscode des Zieldruckers. Die Brücke leitet die Slicer-Authentifizierung an den echten Drucker weiter, daher müssen die Codes übereinstimmen — den Druckercode in dessen Einstellungen ändern.`,reveal:`Zugangscode anzeigen`,hide:`Zugangscode verbergen`},targetPrinter:{title:`Zieldrucker`,configured:`Proxy-Ziel konfiguriert`,notConfigured:`Kein Zieldrucker ausgewählt - erforderlich für Proxy-Modus`,placeholder:`Drucker auswählen...`,hint:`Wähle den Drucker aus, an den der Slicer-Datenverkehr weitergeleitet werden soll. Der Drucker muss im LAN-Modus sein.`,noPrinters:`Keine Drucker konfiguriert. Füge zuerst einen Drucker hinzu, um den Proxy-Modus zu verwenden.`},remoteInterface:{title:`Netzwerkschnittstelle überschreiben`,configured:`Schnittstellenüberschreibung aktiv`,optional:`Optional - verwenden wenn die automatisch erkannte IP falsch ist (z.B. mehrere NICs, Docker, VPN)`,placeholder:`Automatisch erkennen (Standard)...`,hint:`Überschreibt die per SSDP beworbene und im TLS-Zertifikat verwendete IP-Adresse. Nützlich wenn Bambuddy mehrere Netzwerkschnittstellen hat.`},mode:{title:`Modus`,archive:`Archivieren`,archiveDesc:`Dateien sofort archivieren`,review:`Überprüfen`,reviewDesc:`Vor dem Archivieren überprüfen`,queue:`Warteschlange`,queueDesc:`Archivieren und zur Warteschlange hinzufügen`,proxy:`Proxy`,proxyDesc:`An echten Drucker weiterleiten`},autoDispatch:{title:`Automatisch starten`,description:`Drucke automatisch starten, wenn sie zur Warteschlange hinzugefügt werden. Wenn deaktiviert, warten Drucke auf manuellen Start.`},queueForceColorMatch:{title:`Farbabgleich erzwingen`,description:`Druckaufträge nur an Drucker senden, bei denen der genaue Filament-Typ und die genaue Farbe geladen sind. Standardmäßig deaktiviert — ohne diese Option verwendet die Warteschlange nur den Drucker-Modell-Abgleich und wählt möglicherweise einen Drucker mit der falschen Farbe.`},gcodeInjection:{title:`G-code-Injektion`,description:`Wendet die in den Einstellungen pro Modell konfigurierten G-code-Snippets auf Jobs dieses VP an. Standardmäßig aus.`},tailscaleDisabled:{title:`Tailscale-Integration`,description:`Aktivieren, um diesen VP als per Tailscale erreichbar zu markieren. Zeigt die Tailscale-Adresse des Hosts an, damit du weißt, welche IP du im Slicer eintragen musst. Der CA-Import bleibt unverändert — diese Option hat keinen Einfluss auf Zertifikate.`},setupRequired:{title:`Einrichtung erforderlich`,description:`Die virtuelle Druckerfunktion erfordert zusätzliche Systemkonfiguration, bevor sie funktioniert. Dies beinhaltet Portweiterleitung, Firewall-Regeln und plattformspezifische Einstellungen.`,readGuide:`Lese die Einrichtungsanleitung vor dem Aktivieren`},archiveNameSource:{title:`Quelle des Archivnamens`,description:`Lege fest, wie neue Archive benannt werden, wenn Dateien über den virtuellen Drucker eintreffen. "Metadaten" verwendet den im 3MF eingebetteten Titel des Slicers (Standard). "Dateiname" nutzt den Dateinamen, den Bambu Studio per FTP gesendet hat. Hinweis: Bambu Studio überschreibt den im Dialog "Zum Drucker senden" eingegebenen Namen mit dem Titelfeld der 3MF, sofern eines vorhanden ist — beide Modi liefern daher oft denselben Wert.`,metadata:`Metadaten`,filename:`Dateiname`},caCert:{title:`Slicer-Zertifikat`,description:`Virtuelle Drucker verwenden ein TLS-Zertifikat, das von der Bambuddy-CA signiert ist. Importieren Sie dieses CA-Zertifikat einmalig in den Vertrauensspeicher Ihres Slicers, damit er die Verbindung akzeptiert — kein Abrufen über die Kommandozeile mehr nötig.`,copy:`Kopieren`,copied:`Kopiert`,download:`Herunterladen`,fingerprint:`SHA-256`},howItWorks:{title:`So funktioniert es`,step1:`Im selben LAN erscheinen virtuelle Drucker automatisch in deinem Slicer (Bambu Studio / OrcaSlicer). Aus anderen Netzwerken füge sie manuell per IP-Adresse und Zugangscode hinzu.`,step2:`Im Archiv-, Überprüfungs- und Warteschlangen-Modus verwende die "Senden"-Funktion im Slicer, um 3MF-Dateien an Bambuddy zu senden. Der Slicer zeigt "Druck erfolgreich" — die Datei wird gespeichert, nicht gedruckt.`,step3:`Im Proxy-Modus leitet der virtuelle Drucker den gesamten Datenverkehr an einen echten Drucker weiter — Drucke starten sofort wie bei einer direkten Verbindung.`},status:{title:`Status-Details`,printerName:`Druckername`,model:`Modell`,serialNumber:`Seriennummer`,mode:`Modus`,pendingFiles:`Ausstehende Dateien`,targetPrinter:`Zieldrucker`,ftpPort:`FTP-Port`,mqttPort:`MQTT-Port`,ftpConnections:`FTP-Verbindungen`,mqttConnections:`MQTT-Verbindungen`},toast:{updated:`Virtuelle Druckereinstellungen aktualisiert`,failedToUpdate:`Einstellungen konnten nicht aktualisiert werden`,copyFailed:`Kopieren fehlgeschlagen — bitte Text manuell markieren`,accessCodeRequired:`Bitte zuerst einen Zugangscode setzen`,targetPrinterRequired:`Bitte zuerst einen Zieldrucker auswählen`,bindIpRequired:`Bitte zuerst eine Bind-IP setzen`,accessCodeEmpty:`Zugangscode darf nicht leer sein`,accessCodeLength:`Zugangscode muss genau 8 Zeichen lang sein`,targetCodeChangedRebind:`Zugangscode wurde an den neuen Zieldrucker angepasst. Bitte dieses Gerät im Slicer neu hinzufügen, damit der neue Code übernommen wird.`,created:`Virtueller Drucker erstellt`,failedToCreate:`Virtueller Drucker konnte nicht erstellt werden`,deleted:`Virtueller Drucker gelöscht`,failedToDelete:`Virtueller Drucker konnte nicht gelöscht werden`},list:{title:`Virtuelle Drucker`,add:`Hinzufügen`,addFirst:`Virtuellen Drucker hinzufügen`,empty:`Keine virtuellen Drucker konfiguriert. Fügen Sie einen hinzu, um zu beginnen.`},bindIp:{title:`Bind-Interface`,placeholder:`Interface auswählen...`,hint:`Netzwerkinterface, an das dieser virtuelle Drucker gebunden wird. Muss pro Drucker eindeutig sein.`},proxy:{accessCodeHint:`Im Proxy-Modus den Zugangscode des Zieldruckers im Slicer verwenden. Die Verbindung wird transparent zum echten Drucker weitergeleitet.`},addDialog:{title:`Virtuellen Drucker hinzufügen`,name:`Name`,hint:`Sie können Zugangscode, Zieldrucker und andere Einstellungen nach dem Erstellen konfigurieren.`,create:`Erstellen`},deleteConfirm:{title:`Virtuellen Drucker löschen`,message:`Möchten Sie "{{name}}" wirklich löschen? Dies stoppt alle Dienste für diesen Drucker.`}},modelViewer:{openInSlicer:`Im Slicer öffnen`,tabs:{model:`3D-Modell`,gcode:`G-Code Vorschau`},notAvailable:`nicht verfügbar`,notSliced:`nicht geslicet`,plates:`Platten`,allPlates:`Alle Platten`,plateNumber:`Platte {{number}}`,plateCount:`{{count}} Platte`,plateCount_other:`{{count}} Platten`,objectCount:`{{count}} Objekt`,objectCount_other:`{{count}} Objekte`,filamentCount:`{{count}} Filament`,filamentCount_other:`{{count}} Filamente`,eta:`ETA {{minutes}} Min`,noPreview:`Keine Vorschau für diese Datei verfügbar`,pagination:{pageOf:`Seite {{current}} von {{total}}`,prev:`Zurück`,next:`Weiter`},errors:{failedToLoad:`Datei konnte nicht geladen werden`,noMeshes:`Keine Meshes in 3MF-Datei gefunden`,unsupportedFormat:`Nicht unterstütztes Dateiformat`}},maintenanceDescriptions:{lubricateCarbonRods:`Schmiermittel auf Karbonstäbe für sanfte Bewegung auftragen`,lubricateRails:`Schmiermittel auf Linearschienen für sanfte Bewegung auftragen`,cleanNozzle:`Hotend und Düse reinigen, um Verstopfungen zu verhindern`,checkBelts:`Riemenspannung für präzise Drucke überprüfen`,cleanBuildPlate:`Druckplatte für bessere Haftung reinigen`,checkExtruder:`Extruderzahnräder auf Verschleiß prüfen`,checkCooling:`Sicherstellen, dass Lüfter ordnungsgemäß funktionieren`,generalInspection:`Allgemeine Druckerinspektion`,cleanCarbonRods:`Karbonstäbe reinigen, um Reibung zu reduzieren`,lubricateSteelRods:`Schmiermittel auf Stahlstangen für sanfte Bewegung auftragen`,cleanSteelRods:`Stahlstangen reinigen, um Reibung zu reduzieren`,cleanLinearRails:`Linearschienen abwischen, um Staub und Schmutz zu entfernen`,checkPtfeTube:`PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen`,replaceHepaFilter:`HEPA-Filter für Luftqualität ersetzen`,replaceCarbonFilter:`Aktivkohlefilter ersetzen`,lubricateLeftNozzleRail:`Linke Düsenschiene schmieren (H2-Serie)`},smartPlugs:{offline:`Offline`,admin:`Admin`,openPlugAdminPage:`Plug-Admin-Seite öffnen`,deleteSmartPlug:`Smart Plug löschen`,turnOnSmartPlug:`Smart Plug einschalten`,turnOffSmartPlug:`Smart Plug ausschalten`,turnOn:`Einschalten`,turnOff:`Ausschalten`,addSmartPlug:{scanningNetwork:`Netzwerk wird durchsucht...`,chooseEntity:`Entität auswählen...`,connectionFailed:`Verbindung fehlgeschlagen`,searchEntities:`Entitäten suchen...`,searchPowerSensors:`Leistungssensoren suchen...`,searchEnergySensors:`Energiesensoren suchen...`,placeholders:{plugName:`Wohnzimmer Steckdose`,mqttStateOnValue:`ON, true, 1`,mqttSameAsPower:`Gleich wie Leistungs-Topic oder anders`}},linkedTo:`Verbunden mit:`,monitorOnly:`Nur Überwachung`,alerts:`Alarme`,scheduleOn:`Ein {{time}}`,scheduleOff:`Aus {{time}}`,on:`Ein`,off:`Aus`,power:`Leistung`,kwhToday:`kWh Heute`,settings:`Einstellungen`,automationSettings:`Automatisierungseinstellungen`,showInSwitchbar:`In Schaltleiste anzeigen`,quickAccessSidebar:`Schnellzugriff über Seitenleiste`,enabled:`Aktiviert`,enableAutomation:`Automatisierung für diesen Stecker aktivieren`,autoOn:`Auto Ein`,autoOnDescription:`Einschalten wenn Druck startet`,autoOff:`Auto Aus`,autoOffDescription:`Ausschalten wenn Druck abgeschlossen (einmalig)`,autoOffPersistent:`Aktiviert lassen`,autoOffPersistentDescription:`Zwischen Drucken aktiviert bleiben statt einmalig`,autoOffAfterDrying:`Automatisch aus nach Trocknung`,autoOffAfterDryingDescription:`Ausschalten, wenn AMS-Trocknung abgeschlossen ist`,delayAfterDryingMinutes:`Verzögerung nach Trocknung (Minuten)`,turnOffDelayMode:`Ausschaltverzögerungsmodus`,time:`Zeit`,temp:`Temp.`,delayMinutes:`Verzögerung (Minuten)`,tempThreshold:`Temperaturschwelle (°C)`,tempThresholdDescription:`Schaltet aus wenn die Düse unter diese Temperatur abkühlt`,edit:`Bearbeiten`,deleteConfirm:`Möchten Sie "{{name}}" wirklich löschen? Dies kann nicht rückgängig gemacht werden.`,turnOnConfirm:`Möchten Sie "{{name}}" wirklich einschalten?`,turnOffConfirm:`Möchten Sie "{{name}}" wirklich ausschalten? Dies unterbricht die Stromversorgung des angeschlossenen Geräts.`,failedToTurn:`{{name}}" konnte nicht {{action}} werden`,unknown:`Unbekannt`,addTitle:`Smart Plug hinzufügen`,editTitle:`Smart Plug bearbeiten`,stopScanning:`Suche beenden`,discoverTasmota:`Tasmota Geräte suchen`,foundDevices:`{{count}} Gerät(e) gefunden - zum Auswählen klicken:`,noDevicesFound:`Keine Tasmota Geräte in Ihrem Netzwerk gefunden`,haNotConfigured:`Home Assistant ist nicht konfiguriert. Einrichtung unter`,haSettingsPath:`Einstellungen → Netzwerk → Home Assistant`,selectEntity:`Entität auswählen *`,ipAddress:`IP-Adresse *`,nameLabel:`Name *`,username:`Benutzername`,password:`Passwort`,authHint:`Leer lassen, wenn Ihr Tasmota-Gerät keine Authentifizierung benötigt`,linkToPrinter:`Mit Drucker verbinden`,noPrinter:`Kein Drucker (nur manuelle Steuerung)`,linkingDescription:`Verknüpfung ermöglicht automatisches Ein-/Ausschalten bei Druckstart/-ende`,powerAlerts:`Leistungsalarme`,alertAbove:`Alarm wenn über (W)`,alertBelow:`Alarm wenn unter (W)`,alertDescription:`Benachrichtigung wenn der Stromverbrauch diese Schwellenwerte überschreitet. Leer lassen um diese Richtung zu deaktivieren.`,dailySchedule:`Tagesplan`,turnOnAt:`Einschalten um`,turnOffAt:`Ausschalten um`,scheduleDescription:`Den Stecker automatisch täglich zu diesen Zeiten ein-/ausschalten. Leer lassen um diese Aktion zu überspringen.`,showOnPrinterCard:`Auf Druckerkarte anzeigen`,displayOnPrinterCard:`Schaltfläche auf Druckerkarte anzeigen`,connectedResult:`Verbunden!`,deviceLabel:`Gerät: {{name}} - `,stateLabel:`Status: {{state}}`,test:`Test`,delete:`Löschen`,save:`Speichern`,add:`Hinzufügen`,cancel:`Abbrechen`,failedToStartScan:`Suche konnte nicht gestartet werden`,nameRequired:`Name ist erforderlich`,entityRequired:`Entität ist für Home Assistant Stecker erforderlich`,mqttTopicRequired:`Mindestens ein MQTT-Topic muss für Leistung, Energie oder Statusüberwachung konfiguriert sein`,loadingEntities:`Entitäten werden geladen...`,loading:`Laden...`,failedToLoadEntities:`Entitäten konnten nicht geladen werden: {{error}}`,noEntitiesMatching:`Keine Entitäten gefunden die "{{search}}" entsprechen`,noEntitiesAvailable:`Keine Entitäten verfügbar`,searchingEntities:`Alle Entitäten durchsuchen ({{count}} gefunden)`,showingEntities:`Zeige switch, light, input_boolean ({{count}} verfügbar)`,energyMonitoringOptional:`Energieüberwachung (Optional)`,energyMonitoringHint:`Sensoren suchen und auswählen, die Leistungs-/Energiedaten liefern.`,powerSensorW:`Leistungssensor (W)`,energyTodayKwh:`Energie Heute (kWh)`,totalEnergyKwh:`Gesamtenergie (kWh)`,noMatchingSensors:`Keine passenden Sensoren`,none:`Keine`,mqttNotConfigured:`MQTT-Broker nicht konfiguriert. Broker-Adresse einstellen unter`,mqttSettingsPath:`Einstellungen → Netzwerk → MQTT-Veröffentlichung`,mqttNotConfiguredSuffix:`(Sie müssen die Veröffentlichung nicht aktivieren, nur die Broker-Details ausfüllen).`,mqttMonitorOnlyDescription:`MQTT-Stecker empfangen Leistungs-/Energiedaten über MQTT-Abonnement. Ein-/Ausschalten ist nicht verfügbar - verwenden Sie Ihren MQTT-Broker oder Ihr Home-Automation-System.`,powerMonitoring:`Leistungsüberwachung`,energyMonitoring:`Energieüberwachung`,stateMonitoring:`Statusüberwachung`,optional:`optional`,topic:`Thema`,jsonPath:`JSON-Pfad`,multiplier:`Multiplikator`,onValue:`EIN-Wert`,mqttPowerHint:`JSON-Pfad extrahiert Wert aus JSON-Payload (z.B. "power_l1"). Leer lassen wenn Topic rohe numerische Werte sendet. Multiplikator 0.001 für mW→W, 1000 für kW→W verwenden.`,mqttEnergyHint:`JSON-Pfad extrahiert Wert aus JSON-Payload. Leer lassen für rohe Werte. Multiplikator 0.001 für Wh→kWh, 1000 für MWh→kWh verwenden.`,mqttStateHint:`JSON-Pfad extrahiert Wert aus JSON-Payload. Leer lassen für rohe Werte. EIN-Wert: der genaue String der "EIN" bedeutet. Leer lassen für Auto-Erkennung (ON, true, 1).`,restControl:`Steuerung`,restOnUrl:`Einschalt-URL`,restOffUrl:`Ausschalt-URL`,restOnBody:`EIN-Anforderungstext`,restOffBody:`AUS-Anforderungstext`,restMethod:`HTTP-Methode`,restHeaders:`Custom Headers (JSON)`,restStatusUrl:`Status-URL`,restStatusPath:`JSON-Pfad für Status`,restStatusOnValue:`EIN-Wert`,restPowerUrl:`Strom-URL`,restPowerPath:`JSON-Pfad für Leistung`,restPowerMultiplier:`Power Multiplikator`,restEnergyUrl:`Energie URL`,restEnergyPath:`JSON-Pfad für Energie`,restEnergyMultiplier:`Energie Multiplikator`,restUrlRequired:`Mindestens eine URL (ON oder OFF) ist für REST-Steckdosen erforderlich`,restHeadersHint:`z. B. {"Authorization": "Bearer your-token"}`,restBodyHint:`z. B. ON, {"state": "on"}`,restStatusHint:`URL zum Abfragen des aktuellen Status`,restPathHint:`z. B. state oder data.power.status`,restPowerUrlHint:`Eigene URL für Leistungsdaten (nutzt Status URL wenn leer)`,restEnergyUrlHint:`Eigene URL für Energiedaten (nutzt Status URL wenn leer)`,restEnergyHint:`Jeder Wert kann eine eigene URL verwenden oder auf die Status URL zurückgreifen. Multiplikatoren für Einheitenumrechnung verwenden (z.B. 0.001 für Wh zu kWh).`,testConnection:`Verbindung testen`,connectionSuccess:`Verbindung erfolgreich`,noSwitchesInSwitchbar:`Keine Schalter in der Schaltleiste`,enableSwitchbarHint:`"In Schaltleiste anzeigen" unter Einstellungen > Smart Plugs aktivieren`},notifications:{providerTypes:{callmebot:`CallMeBot/WhatsApp`,ntfy:`ntfy`,pushover:`Pushover`,telegram:`Telegram`,email:`E-Mail`,discord:`Discord`,webhook:`Webhook`,homeassistant:`Home Assistant`},providerDescriptions:{email:`SMTP-E-Mail-Benachrichtigungen`,telegram:`Benachrichtigungen über Telegram-Bot`,discord:`An Discord-Kanal per Webhook senden`,ntfy:`Kostenlose, selbst-hostbare Push-Benachrichtigungen`,pushover:`Einfache, zuverlässige Push-Benachrichtigungen`,callmebot:`Kostenlose WhatsApp-Benachrichtigungen über CallMeBot`,webhook:`Generischer HTTP-POST an beliebige URL`,homeassistant:`Dauerhafte Benachrichtigungen im Home Assistant Dashboard`},lastSuccess:`Zuletzt: {{date}}`,error:`Fehler`,printer:`Drucker:`,allPrinters:`Alle Drucker`,sendTestNotification:`Testbenachrichtigung senden`,eventSettings:`Ereigniseinstellungen`,enabled:`Aktiviert`,sendFromProvider:`Benachrichtigungen von diesem Anbieter senden`,printEvents:`Druckereignisse`,printerStatus:`Druckerstatus`,amsAlarms:`AMS-Alarme`,amsHtAlarms:`AMS-HT-Alarme`,printQueue:`Druckwarteschlange`,start:`Start`,plateCheck:`Plattenkontrolle`,complete:`Abgeschlossen`,failed:`Fehlgeschlagen`,stopped:`Gestoppt`,progress:`Fortschritt`,offline:`Offline`,lowFilament:`Filament niedrig`,maintenance:`Wartung`,amsHumidity:`AMS-Feuchtigkeit`,amsTemp:`AMS-Temperatur`,amsHtHumidity:`AMS-HT-Feuchtigkeit`,amsHtTemp:`AMS-HT-Temperatur`,bedCooled:`Bett abgekühlt`,firstLayer:`Erste Schicht`,quiet:`Ruhe`,digest:`Zusammenfassung {{time}}`,printStarted:`Druck gestartet`,plateNotEmpty:`Platte nicht leer`,plateNotEmptyDescription:`Objekte vor dem Druck erkannt`,printCompleted:`Druck abgeschlossen`,bedCooledLabel:`Bett abgekühlt`,bedCooledDescription:`Bett nach dem Druck unter Schwellenwert abgekühlt`,firstLayerCompleteLabel:`Erste Schicht fertig`,firstLayerCompleteDescription:`Benachrichtigung mit Foto nach erster Schicht`,missingSpoolAssignmentLabel:`Fehlende Spulenzuordnung`,missingSpoolAssignmentDescription:`Benachrichtigen, wenn ein Druck startet und benoetigte Schaechte keine zugeordnete Spule haben`,printFailed:`Druck fehlgeschlagen`,printStopped:`Druck gestoppt`,progressMilestones:`Fortschrittsmeilensteine`,progressMilestonesDescription:`Benachrichtigung bei 25%, 50%, 75%`,printerOffline:`Drucker offline`,printerError:`Druckerfehler`,aiFailureDetection:`KI-Fehlererkennung`,aiFailureDetectionDescription:`Benachrichtigen, wenn die Obico-KI einen möglichen Druckfehler erkennt`,lowFilamentLabel:`Filament niedrig`,maintenanceDue:`Wartung fällig`,maintenanceDueDescription:`Benachrichtigen, wenn Wartung erforderlich ist`,amsHumidityHigh:`AMS-Feuchtigkeit hoch`,amsHumidityHighDescription:`Normale AMS-Feuchtigkeit überschreitet Schwellenwert`,amsTemperatureHigh:`AMS-Temperatur hoch`,amsTemperatureHighDescription:`Normale AMS-Temperatur überschreitet Schwellenwert`,amsHtHumidityHigh:`AMS-HT-Feuchtigkeit hoch`,amsHtHumidityHighDescription:`AMS-HT-Feuchtigkeit überschreitet Schwellenwert`,amsHtTemperatureHigh:`AMS-HT-Temperatur hoch`,amsHtTemperatureHighDescription:`AMS-HT-Temperatur überschreitet Schwellenwert`,inventoryAlerts:`Bestandswarnungen`,stockReorderAlert:`Nachbestellungswarnung`,stockReorderAlertDescription:`SKU hat seinen Nachbestellungspunkt erreicht`,stockBreakAlert:`Bestandsunterbrechungswarnung`,stockBreakAlertDescription:`Der Bestand wird vor dem Eintreffen der Nachbestellung aufgebraucht sein`,jobAdded:`Auftrag hinzugefügt`,jobAddedDescription:`Auftrag zur Warteschlange hinzugefügt`,jobAssigned:`Auftrag zugewiesen`,jobAssignedDescription:`Modellbasierter Auftrag einem Drucker zugewiesen`,jobStarted:`Auftrag gestartet`,jobStartedDescription:`Warteschlangenauftrag hat Druck begonnen`,jobWaiting:`Auftrag wartet`,jobWaitingDescription:`Auftrag wartet auf Filament oder Drucker`,jobSkipped:`Auftrag übersprungen`,jobSkippedDescription:`Auftrag übersprungen (vorheriger fehlgeschlagen)`,jobFailed:`Auftrag fehlgeschlagen`,jobFailedDescription:`Auftrag konnte nicht gestartet werden`,queueComplete:`Warteschlange abgeschlossen`,queueCompleteDescription:`Alle Warteschlangenaufträge beendet`,quietHours:`Ruhezeiten`,noNotificationsDuring:`Keine Benachrichtigungen während dieser Zeiten`,editProviderToChangeQuietHours:`Anbieter bearbeiten, um Ruhezeiten zu ändern`,dailyDigest:`Tägliche Zusammenfassung`,batchNotifications:`Benachrichtigungen zu einer täglichen Zusammenfassung bündeln`,sendAt:`Senden um {{time}}`,editProviderToChangeDigestTime:`Anbieter bearbeiten, um Zusammenfassungszeit zu ändern`,edit:`Bearbeiten`,deleteProvider:`Benachrichtigungsanbieter löschen`,deleteConfirm:`Sind Sie sicher, dass Sie "{{name}}" löschen möchten? Dies kann nicht rückgängig gemacht werden.`,delete:`Löschen`,addTitle:`Benachrichtigungsanbieter hinzufügen`,editTitle:`Benachrichtigungsanbieter bearbeiten`,nameLabel:`Name *`,namePlaceholder:`Meine Benachrichtigungen`,providerTypeLabel:`Anbietertyp *`,configuration:`Konfiguration`,testConfiguration:`Konfiguration testen`,printerFilter:`Druckerfilter`,onlyFromPrinter:`Nur Benachrichtigungen für Ereignisse von diesem Drucker senden`,quietHoursDnd:`Ruhezeiten (Nicht stören)`,quietStart:`Start`,quietEnd:`Ende`,dailyDigestLabel:`Tägliche Zusammenfassung`,sendDigestAt:`Zusammenfassung senden um`,digestCollected:`Ereignisse werden gesammelt und als einzelne Zusammenfassung zu dieser Zeit gesendet`,notificationEvents:`Benachrichtigungsereignisse`,progressPercent:`(25 %, 50 %, 75 %)`,bedCooledAfterPrint:`(nach Druckabschluss)`,eventPriority:{sectionTitle:`ntfy-Priorität`,helpNtfy:`Wähle eine Priorität pro aktiviertem Ereignis. ntfy nutzt diese, um Hinweise (Ton, Sichtbarkeit, Push-Verhalten) zu eskalieren. Hier nicht gesetzte Stufen verwenden den ntfy-Server-Standard.`,min:`Min.`,low:`Niedrig`,default:`Standard`,high:`Hoch`,urgent:`Dringend`},cancel:`Abbrechen`,save:`Speichern`,add:`Hinzufügen`,nameRequired:`Name ist erforderlich`,fieldRequired:`{{field}} ist erforderlich`,phoneNumber:`Telefonnummer`,apiKey:`API-Schlüssel`,serverUrl:`Server-URL`,topic:`Thema`,authToken:`Auth-Token`,userKey:`Benutzerschlüssel`,appToken:`App-Token`,priority:`Priorität`,botToken:`Bot-Token`,chatId:`Chat-ID`,smtpServer:`SMTP-Server`,smtpPort:`SMTP-Port`,security:`Sicherheit`,authentication:`Authentifizierung`,username:`Benutzername`,password:`Passwort`,fromEmail:`Absender-E-Mail`,toEmail:`Empfänger-E-Mail`,webhookUrl:`Webhook-URL`,payloadFormat:`Payload-Format`,authorization:`Autorisierung`,titleFieldName:`Titel-Feldname`,messageFieldName:`Nachrichten-Feldname`,editTemplate:`Vorlage bearbeiten: {{name}}`,titleLabel:`Titel`,bodyLabel:`Inhalt`,titlePlaceholder:`Benachrichtigungstitel...`,bodyPlaceholder:`Benachrichtigungsinhalt...`,availableVariables:`Verfügbare Variablen`,clickToInsert:`Klicken, um an Cursorposition im Inhalt einzufügen`,livePreview:`Live-Vorschau`,hide:`Ausblenden`,show:`Anzeigen`,loadingPreview:`Vorschau wird geladen...`,enterTemplateContent:`Vorlageninhalt eingeben, um Vorschau zu sehen`,titlePreview:`Titel:`,bodyPreview:`Inhalt:`,resetToDefault:`Auf Standard zurücksetzen`,titleRequired:`Titel ist erforderlich`,bodyRequired:`Inhalt ist erforderlich`,notificationLog:`Benachrichtigungsprotokoll`,showFailedOnly:`Nur fehlgeschlagene`,last24Hours:`Letzte 24 Stunden`,last7Days:`Letzte 7 Tage`,last30Days:`Letzte 30 Tage`,last90Days:`Letzte 90 Tage`,justNow:`Gerade eben`,noFailedNotifications:`Keine fehlgeschlagenen Benachrichtigungen`,noNotificationsLogged:`Keine Benachrichtigungen protokolliert`,unknownProvider:`Unbekannter Anbieter`,logTitle:`Titel`,logMessage:`Nachricht`,logError:`Fehler`,logProvider:`Anbieter: {{type}}`,logTime:`Zeit: {{time}}`,refresh:`Aktualisieren`,clearOld:`Alte löschen`,statsSummary:`Letzte {{days}} Tage:`,statsNotifications:`Benachrichtigungen`,statsSent:`{{count}} gesendet`,statsFailed:`{{count}} fehlgeschlagen`,eventTypes:{print_start:`Druck gestartet`,print_complete:`Druck abgeschlossen`,print_failed:`Druck fehlgeschlagen`,print_stopped:`Druck gestoppt`,print_progress:`Fortschritt`,printer_offline:`Drucker offline`,printer_error:`Druckerfehler`,filament_low:`Filament niedrig`,maintenance_due:`Wartung fällig`,test:`Test`},userEmail:{title:`Benachrichtigungen`,emailNotifications:`E-Mail-Benachrichtigungen`,emailNotificationsDesc:`Erhalten Sie E-Mail-Benachrichtigungen für Ihre eigenen Druckaufträge. E-Mails werden über die in der erweiterten Authentifizierung konfigurierten SMTP-Einstellungen gesendet.`,sendingTo:`Benachrichtigungen werden gesendet an`,noEmailWarning:`Ihr Konto hat keine E-Mail-Adresse. Wenden Sie sich an einen Administrator, um eine hinzuzufügen.`,printJobNotifications:`Druckauftrags-Benachrichtigungen`,printJobNotificationsDesc:`Wählen Sie aus, welche Ereignisse E-Mail-Benachrichtigungen für von Ihnen gesendete Druckaufträge auslösen.`,printJobStarts:`Druckauftrag startet`,printJobStartsDesc:`Benachrichtigt werden, wenn Ihr Druckauftrag beginnt.`,printJobFinishes:`Druckauftrag fertig`,printJobFinishesDesc:`Benachrichtigt werden, wenn Ihr Druckauftrag erfolgreich abgeschlossen wurde.`,printErrors:`Druckfehler`,printErrorsDesc:`Benachrichtigt werden, wenn Ihr Druckauftrag fehlschlägt oder auf einen Fehler stößt.`,printJobStops:`Druckauftrag gestoppt`,printJobStopsDesc:`Benachrichtigt werden, wenn Ihr Druckauftrag abgebrochen oder gestoppt wird.`,saveSuccess:`Benachrichtigungseinstellungen gespeichert.`,saveError:`Benachrichtigungseinstellungen konnten nicht gespeichert werden.`}},richTextEditor:{bold:`Fett`,italic:`Kursiv`,underline:`Unterstrichen`,bulletList:`Aufzählungsliste`,numberedList:`Nummerierte Liste`,alignLeft:`Linksbündig`,alignCenter:`Zentriert`,alignRight:`Rechtsbündig`,addLink:`Link hinzufügen`,removeLink:`Link entfernen`},externalLinks:{title:`Seitenleisten-Links`,sidebarLayout:`Seitenleiste`,sidebarLayoutDescription:`Integrierte Seiten ein- oder ausblenden, externe Links hinzufügen und Elemente ziehen, um die Seitenleisten-Navigation neu zu ordnen.`,systemPages:`Bambuddy-Seiten`,externalLinks:`Externe Links`,visibleInSidebar:`In Seitenleiste sichtbar`,hiddenFromSidebar:`In Seitenleiste ausgeblendet`,requiredInSidebar:`In Seitenleiste erforderlich`,hidePage:`Seite ausblenden`,showPage:`Seite anzeigen`,settingsCannotBeHidden:`Einstellungen können nicht ausgeblendet werden`,noLinksConfigured:`Keine externen Links konfiguriert`,deleteLink:`Link löschen`,removeCustomIcon:`Benutzerdefiniertes Symbol entfernen`,openInNewTab:`In neuem Tab öffnen`,placeholders:{linkName:`Mein Link`}},keyboardShortcuts:{title:`Tastaturkürzel`,navigation:`Navigation`,archivesSection:`Archive`,kProfilesSection:`K-Profile`,generalSection:`Allgemein`,shortcuts:{goToPrinters:`Zu Drucker gehen`,goToArchives:`Zu Archiv gehen`,goToQueue:`Zur Warteschlange gehen`,goToStats:`Zu Statistiken gehen`,goToProfiles:`Zu Cloud-Profilen gehen`,goToSettings:`Zu Einstellungen gehen`,focusSearch:`Suche fokussieren`,openUploadModal:`Upload-Modal öffnen`,clearSelection:`Auswahl löschen / Eingabe aufheben`,contextMenu:`Kontextmenü auf Karten`,refreshProfiles:`Profile aktualisieren`,newProfile:`Neues Profil`,exitSelectionMode:`Auswahlmodus beenden`,showHelp:`Diese Hilfe anzeigen`},footer:`Drücken Sie Esc oder klicken Sie außerhalb, um zu schließen`},notificationLog:{title:`Benachrichtigungsprotokoll`,events:{printStarted:`Druck gestartet`,printComplete:`Druck abgeschlossen`,printFailed:`Druck fehlgeschlagen`,printStopped:`Druck gestoppt`,progress:`Fortschritt`,printerOffline:`Drucker offline`,printerError:`Druckerfehler`,lowFilament:`Wenig Filament`,maintenanceDue:`Wartung fällig`,test:`Test`},timeAgo:{justNow:`Gerade eben`,minutesAgo:`vor {{minutes}}m`,hoursAgo:`vor {{hours}}h`}},restoreBackup:{title:`Backup wiederherstellen`,restoring:`Wird wiederhergestellt...`,restoreComplete:`Wiederherstellung abgeschlossen`,restoreFailed:`Wiederherstellung fehlgeschlagen`,importSettings:`Einstellungen aus Backup-Datei importieren`,pleaseWait:`Bitte warten Sie, während Ihre Daten wiederhergestellt werden`,clickToSelect:`Klicken Sie, um Backup-Datei auszuwählen (.json oder .zip)`,howDuplicateHandling:`So funktioniert die Duplikatbehandlung:`,categories:{printers:`Drucker`,smartPlugs:`Smart Plugs`,notificationProviders:`Benachrichtigungsanbieter`,filaments:`Filamente`,archives:`Archive`,pendingUploads:`Ausstehende Uploads`,settingsTemplates:`Einstellungen & Vorlagen`},matchingInfo:{printers:`abgeglichen nach Seriennummer`,smartPlugs:`abgeglichen nach IP-Adresse`,notificationProviders:`abgeglichen nach Name`,filaments:`abgeglichen nach Name + Typ + Marke`,archives:`abgeglichen nach Inhalts-Hash`,pendingUploads:`abgeglichen nach Dateiname`,settingsTemplates:`immer überschrieben`},replaceExisting:`Vorhandene Daten ersetzen`,keepExisting:`Vorhandene Daten behalten`,replaceDescription:`Bereits vorhandene Elemente mit Backup-Daten überschreiben`,keepDescription:`Nur Elemente wiederherstellen, die noch nicht existieren`,caution:`Vorsicht:`,cautionText:`Das Überschreiben ersetzt Ihre aktuellen Konfigurationen durch Backup-Daten. Drucker-Zugangscodes werden aus Sicherheitsgründen niemals überschrieben.`,itemsRestored:`Wiederhergestellte Elemente`,itemsSkipped:`Übersprungene Elemente`,restored:`Wiederhergestellt`,skipped:`Übersprungen (existieren bereits)`,filesLabel:`Dateien (3MF, Thumbnails, etc.)`,newApiKeysGenerated:`Neue API-Schlüssel generiert`,newApiKeysWarning:`Diese Schlüssel werden nur einmal angezeigt. Kopieren Sie sie jetzt!`,processingBackup:`Backup-Datei wird verarbeitet...`,noDataFound:`In der Backup-Datei wurden keine wiederherzustellenden Daten gefunden.`,failedToRestore:`Backup konnte nicht wiederhergestellt werden. Bitte überprüfen Sie das Dateiformat.`},backupExport:{title:`Backup exportieren`,selectData:`Zu exportierende Daten auswählen`,selectAll:`Alle auswählen`,selectNone:`Keine auswählen`,categoryDescriptions:{settings:`Sprache, Theme, Update-Einstellungen`,notifications:`ntfy, Pushover, Discord, usw.`,templates:`Benutzerdefinierte Nachrichtenvorlagen`,smartPlugs:`Tasmota-Plug-Konfigurationen`,externalLinks:`Seitenleiste Links zu externen Diensten`,printers:`Druckerinformationen (Zugangscodes ausgeschlossen)`,plateDetection:`Leere Platten-Referenzbilder`,filaments:`Filamenttypen und -kosten`,maintenance:`Benutzerdefinierte Wartungspläne`,archives:`Alle Druckdaten + Dateien (3MF, Thumbnails, Fotos)`,projects:`Projekte, BOM-Elemente und Anhänge`,pendingUploads:`Virtueller Drucker-Uploads zur Überprüfung`,apiKeys:`Webhook-API-Schlüssel (neue Schlüssel bei Import generiert)`},requiresPrinters:`Drucker müssen ausgewählt sein`,zipFileWarning:`ZIP-Datei wird erstellt.`,zipFileDescription:`Enthält alle 3MF-Dateien, Thumbnails, Zeitraffer und Fotos. Dies kann eine Weile dauern und zu einer großen Datei führen.`,includeAccessCodes:`Zugangscodes einschließen`,includeAccessCodesDescription:`Für die Übertragung auf eine andere Maschine`,includeAccessCodesWarning:`Zugangscodes werden im Klartext eingeschlossen. Bewahren Sie diese Backup-Datei sicher auf!`,categoriesSelected:`{{selectedCount}} Kategorien ausgewählt`},pendingUploads:{placeholders:{notes:`Notizen zu diesem Druck hinzufügen...`},discardUpload:`Upload verwerfen`,archiveAllUploads:`Alle Uploads archivieren`,discardAllUploads:`Alle Uploads verwerfen`,archive:`Archivieren`,timeAgo:{justNow:`Gerade eben`,minutesAgo:`vor {{minutes}}m`,hoursAgo:`vor {{hours}}h`,daysAgo:`vor {{days}}d`}},apiBrowser:{placeholders:{requestBody:`JSON-Anforderungstext...`,searchEndpoints:`Endpunkte suchen...`}},configureAmsSlot:{title:`AMS-Slot konfigurieren`,slotConfigured:`Slot konfiguriert!`,configuringSlot:`Slot wird konfiguriert:`,slotLabel:`{{ams}} – Slot {{slot}}`,searchPresets:`Voreinstellungen suchen...`,colorPlaceholder:`Farbname oder Hex (z.B. braun, FF8800)`,clearCustomColor:`Benutzerdefinierte Farbe löschen`,noCloudPresets:`Keine Cloud-Voreinstellungen. Melden Sie sich bei Bambu Cloud an, um zu synchronisieren.`,noPresetsAvailable:`Keine Voreinstellungen verfügbar. Melden Sie sich bei Bambu Cloud an oder importieren Sie lokale Profile.`,noMatchingPresets:`Keine passenden Voreinstellungen gefunden.`,custom:`Benutzerdefiniert`,builtin:`Integriert`,orcaCloud:`Orca Cloud`,bambuCloud:`Bambu Cloud`,settingsSentToPrinter:`Einstellungen an Drucker gesendet`,filamentProfile:`Filamentprofil`,kProfileLabel:`K-Profil (Pressure Advance)`,filteringFor:`Filtern nach: {{material}}`,noKProfile:`Kein K-Profil (Standard 0.020 verwenden)`,noMatchingKProfiles:`Keine passenden K-Profile gefunden. Standard K=0.020 wird verwendet.`,selectFilamentFirst:`Zuerst ein Filamentprofil auswählen`,kFromCalibration:`K={{value}} aus Druckerkalibrierung`,customColorLabel:`Benutzerdefinierte Farbe (optional)`,presetColors:`{{name}} Farben:`,showLessColors:`Weniger Farben anzeigen`,showMoreColors:`Mehr Farben anzeigen`,clear:`Löschen`,hexLabel:`Hex – #{{hex}}`,resetting:`Wird zurückgesetzt...`,resetSlot:`Slot zurücksetzen`,cancel:`Abbrechen`,configuring:`Wird konfiguriert...`,configureSlot:`Slot konfigurieren`},githubBackup:{title:`Git-Backup`,history:`Verlauf`,downloadBackup:`Backup herunterladen`,restoreBackup:`Backup wiederherstellen`,noBackupsYet:`Noch keine Backups`},emailSettings:{placeholders:{fromName:`Bambuddy`}},tagManagement:{searchTags:`Tags suchen...`,renameTag:`Tag umbenennen`,deleteTag:`Tag löschen`},notificationTemplates:{placeholders:{title:`Benachrichtigungstitel...`,body:`Benachrichtigungstext...`}},batchTag:{placeholders:{newTag:`Neuen Tag eingeben...`}},photoGallery:{deletePhoto:`Foto löschen`},filamentHoverCard:{copySpoolUuid:`Spulen-UUID kopieren`},kProfilesView:{hasNote:`Hat Notiz`,copyProfile:`Profil kopieren`},layout:{openMenu:`Menü öffnen`,noPermissionSystemInfo:`Sie haben keine Berechtigung zum Anzeigen von Systeminformationen`},dashboard:{dragToReorder:`Ziehen zum Neuordnen`,hideWidget:`Widget ausblenden`},notificationProviderCard:{deleteNotificationProvider:`Benachrichtigungsanbieter löschen`},fileManagerModal:{closeFileManager:`Dateimanager schließen`,sortFiles:`Dateien sortieren`,goToParentFolder:`Zum übergeordneten Ordner gehen`,threeView:`3D-Ansicht`},embeddedCameraViewer:{refreshStream:`Stream aktualisieren`,close:`Schließen`,zoomOut:`Verkleinern`,resetZoom:`Zoom zurücksetzen`,zoomIn:`Vergrößern`,dragToResize:`Ziehen zum Größe ändern`},timelapseViewer:{skipBack5s:`5s zurückspringen`,skipForward5s:`5s vorspringen`},notificationProviders:{descriptions:{email:`SMTP-E-Mail-Benachrichtigungen`,telegram:`Benachrichtigungen über Telegram-Bot`,discord:`An Discord-Kanal über Webhook senden`,ntfy:`Kostenlose, selbst hostbare Push-Benachrichtigungen`,pushover:`Einfache, zuverlässige Push-Benachrichtigungen`,callmebot:`Kostenlose WhatsApp-Benachrichtigungen über CallMeBot`,webhook:`Generischer HTTP POST zu beliebiger URL`}},logViewer:{searchPlaceholder:`Nachricht oder Logger-Name suchen...`,noLogEntries:`Keine Logeinträge gefunden`},switchbarPopover:{noSwitchesInSwitchbar:`Keine Schalter in Schalterleiste`},projectPageModal:{placeholders:{title:`Titel`,designer:`Designer`,license:`Lizenz`,description:`Beschreibung eingeben...`,profileTitle:`Profil-Titel`,profileDescription:`Profilbeschreibung...`}},spoolmanSettings:{},time:{unknown:`-`,waiting:`Wartend`,justNow:`Gerade eben`,now:`Jetzt`,minsAgo:`vor {{count}}m`,inMins:`in {{count}}min`,hoursAgo:`vor {{count}}h`,inHours:`in {{count}}Std`,daysAgo:`vor {{count}}d`,inDays:`in {{count}}T`},spoolbuddy:{nav:{dashboard:`Übersicht`,ams:`AMS`,inventory:`Inventar`,writeTag:`Schreiben`,settings:`Einstellungen`},status:{nfcReady:`NFC bereit`,nfcOff:`NFC aus`,offline:`Offline`,online:`Online`,noPrinters:`Keine Drucker`,deviceOffline:`Gerät offline`,waitingConnection:`Warte auf Geräteverbindung...`,systemReady:`System bereit`,status:`Status`},dashboard:{readyToScan:`Bereit zum Scannen`,idleMessage:`Spule auf die Waage legen zum Identifizieren`,nfcHint:`NFC-Tag wird automatisch gelesen`,device:`Gerät`,syncWeight:`Gewicht sync.`,weightSynced:`Synchronisiert!`,unknownTag:`Unbekannter Tag`,newTag:`Neuer Tag erkannt`,onScale:`auf der Waage`,linkSpool:`Mit Spule verknüpfen`,linkTagTitle:`Tag mit Spule verknüpfen`,linkTag:`Tag verknüpfen`,selectSpool:`Spule zum Verknüpfen auswählen:`,noUntagged:`Keine Spulen ohne Tags gefunden`,tagDetected:`Tag erkannt`,noTag:`Kein Tag`,tagId:`Tag`,grossWeight:`Bruttogewicht`,spoolSize:`Spulengröße`,close:`Schließen`,currentSpool:`Aktuelle Spule`,plateReady:`Druckplatte bereit: {{name}}`,plateReadyLabel:`Bereit-zum-Quittieren-Liste`,plateClearAction:`Frei`,plateClearedToast:`Druckplatte als geleert markiert`,plateClearFailed:`Druckplatte konnte nicht als geleert markiert werden`},modal:{spoolDetected:`Spule erkannt`,assignToAms:`AMS zuweisen`,syncWeight:`Gewicht sync.`,weightSynced:`Synchronisiert!`,syncing:`Synchronisiere...`,newTagDetected:`Neuer Tag erkannt`,addToInventory:`Zum Inventar hinzufügen`,assignToAmsTitle:`AMS zuweisen`,selectSlot:`Slot auswählen`,assign:`Zuweisen`,assigning:`Zuweisen...`,assignSuccess:`Zugewiesen!`,assignPendingInsert:`Zugewiesen. Slot wird beim Einsetzen der Spule konfiguriert.`,assignError:`Fehler beim Zuweisen. Bitte erneut versuchen.`,noPrinterSelected:`Drucker auswählen...`,noAmsDetected:`Kein AMS an diesem Drucker erkannt`,slot:`Slot`},weight:{noReading:`Kein Messwert`,stable:`Stabil`,measuring:`Messen...`,tare:`Tarieren`,calibrate:`Kalibrieren`},spool:{remaining:`Verbleibend`,material:`Material`,brand:`Marke`,color:`Farbe`,coreWeight:`Kern`,labelWeight:`Etikett`,scaleWeight:`Waage`,netWeight:`Netto`,lastUsed:`Zuletzt verwendet`},ams:{noData:`Kein AMS erkannt`,connectAms:`AMS anschließen um Filament-Slots zu sehen`,noPrinter:`Kein Drucker ausgewählt`,selectPrinter:`Drucker in der oberen Leiste auswählen`,printerDisconnected:`Drucker getrennt`,humidity:`Feuchtigkeit`,level:`Stufe`,active:`Aktiv`,slot:`Slot`,empty:`Leer`},inventory:{search:`Spulen suchen...`,empty:`Keine Spulen im Inventar`,noResults:`Keine passenden Spulen`,spools:`Spulen`,addSpool:`Spule hinzufügen`},settings:{tabDevice:`Gerät`,tabDisplay:`Anzeige`,tabScale:`Waage`,tabUpdates:`Aktualisierungen`,nfcReader:`NFC-Leser`,type:`Typ`,connection:`Verbindung`,notConnected:`N/V`,deviceInfo:`Geräteinfo`,hostname:`Host`,uptime:`Betriebszeit`,systemConfig:`Backend & Auth`,backendUrl:`Bambuddy Backend URL`,apiToken:`API-Token`,apiTokenPlaceholder:`API-Token eingeben`,saveConfig:`Konfiguration speichern`,systemQueued:`Konfiguration in Warteschlange.`,nfcDiagnostic:`NFC-Diagnose`,scaleDiagnostic:`Waagen-Diagnose`,readTagDiagnostic:`Tag-Lese-Diagnose`,testNfc:`Leser testen`,testScale:`Genauigkeit testen`,testReadTag:`Tag lesen`,systemFieldsRequired:`Backend-URL ist erforderlich.`,brightness:`Helligkeit`,saved:`Gespeichert`,noBacklight:`Keine DSI-Hintergrundbeleuchtung erkannt. Helligkeitssteuerung erfordert ein DSI-Display.`,screenBlank:`Bildschirm-Abschaltzeit`,screenBlankDesc:`Bildschirm schaltet sich nach Inaktivität ab. Zum Aufwecken berühren.`,displayNote:`Helligkeit wird als Software-Filter angewendet.`,scaleCalibration:`Waagen-Kalibrierung`,currentWeight:`Aktuelles Gewicht`,tareOffset:`Tara`,calFactor:`Faktor`,knownWeight:`Bekanntes Gewicht`,calStep1:`Alle Gegenstände von der Waage entfernen und Nullpunkt setzen.`,calStep2:`Bekanntes Gewicht auf die Waage legen.`,setZero:`Nullpunkt setzen`,calibrateNow:`Kalibrieren`,calibrated:`Kalibriert`,tareSet:`Tara-Befehl gesendet. Warte auf Gerät...`,tareComplete:`Tara abgeschlossen!`,tareTimedOut:`Tara-Zeitüberschreitung — läuft der SpoolBuddy-Daemon?`,tareFailed:`Tara-Befehl fehlgeschlagen`,zeroSet:`Nullpunkt gesetzt. Bekanntes Gewicht auf die Waage legen.`,calibrationDone:`Kalibrierung abgeschlossen!`,calibrationFailed:`Kalibrierung fehlgeschlagen`,lastCalibrated:`Zuletzt kalibriert`,stable:`Stabil`,settling:`Stabilisierung...`,firmware:`Firmware`,scale:`Waage`,noDevice:`Kein SpoolBuddy-Gerät gefunden`,daemonVersion:`Daemon-Version`,currentVersion:`Aktuell`,versionPending:`Warte auf Daemon...`,checking:`Prüfe...`,checkUpdates:`Nach Updates suchen`,updateAvailable:`Update verfügbar`,updateInstructions:`Update per SSH: SpoolBuddy-Installationsskript ausführen.`,upToDate:`Aktuell`,includeBeta:`Beta-Versionen einschließen`},writeTag:{tabExisting:`Vorhandene Spule`,tabNew:`Neue Spule`,tabReplace:`Tag ersetzen`,searchPlaceholder:`Suche nach Material, Farbe, Marke...`,noUntaggedSpools:`Keine Spulen ohne Tags`,noTaggedSpools:`Keine Spulen mit Tags`,selectSpool:`Spule auswählen, dann einen NTAG auf den Leser legen`,placeTag:`NTAG auf den Leser legen`,tagReady:`Tag erkannt — bereit zum Schreiben`,writeTag:`Tag beschreiben`,replaceTag:`Tag ersetzen`,writing:`Tag wird beschrieben...`,waiting:`Warte auf SpoolBuddy...`,writeSuccess:`Tag erfolgreich beschrieben!`,writeFailed:`Schreiben fehlgeschlagen`,queueFailed:`Schreibbefehl konnte nicht eingereiht werden`,tryAgain:`Erneut versuchen`,cancel:`Abbrechen`,replaceWarning:`Alter Tag wird getrennt. Neuer Tag ersetzt ihn.`,deviceOffline:`SpoolBuddy ist offline`,material:`Material`,colorName:`Farbname`,color:`Farbe`,brand:`Marke`,weight:`Gewicht (g)`,createSpool:`Spule erstellen`,creating:`Wird erstellt...`,spoolCreated:`Spule erstellt! Bereit zum Schreiben.`,createFailed:`Spule konnte nicht erstellt werden`,incompleteDataWarning:`Tag mit unvollständigen Spoolman-Daten geschrieben`},quickMenu:{printerPower:`Drucker-Strom`,systemControls:`System`,restartDaemon:`Daemon neustarten`,restartBrowser:`Browser neustarten`,reboot:`Neustart`,shutdown:`Herunterfahren`,swipeToClose:`Nach unten wischen zum Schließen`,confirmTitle:`Bestätigen`,confirmShutdown:`Möchten Sie das SpoolBuddy wirklich herunterfahren? Sie benötigen physischen Zugang, um es wieder einzuschalten.`,confirmReboot:`Möchten Sie das SpoolBuddy wirklich neu starten?`,confirmRestartDaemon:`SpoolBuddy-Daemon neustarten? NFC und Waage sind vorübergehend nicht verfügbar.`,confirmRestartBrowser:`Kiosk-Browser neustarten? Das Display wird kurz schwarz.`,confirm:`Bestätigen`,confirmPlugOn:`{{name}} einschalten?`,confirmPlugOff:`{{name}} ausschalten?`,turnOn:`Einschalten`,turnOff:`Ausschalten`}},diagnostic:{modalTitle:`Verbindungsdiagnose — {{name}}`,running:`Diagnose läuft...`,runningElapsed:`Diagnose läuft... ({{elapsed}}s)`,waitingForReportHint:`Warten darauf, dass der Drucker einen Statusbericht sendet — kann bis zu {{max}} Sekunden dauern.`,runFailed:`Diagnose konnte nicht ausgeführt werden: {{error}}`,retry:`Erneut ausführen`,runButton:`Diagnose ausführen`,sectionTitle:`Verbindungsdiagnose`,sectionDescription:`Prüfen, warum ein Drucker keine Verbindung herstellt oder nicht druckt — Port-Erreichbarkeit, LAN-Entwicklermodus, Docker-Netzwerkmodus und Zugangsdaten.`,noPrinters:`Keine Drucker konfiguriert.`,overall:{ok:`Keine Probleme gefunden — die Druckerverbindung sieht gut aus.`,warnings:`Der Drucker sollte funktionieren, aber einige Punkte erfordern Aufmerksamkeit.`,problems:`Probleme gefunden, die erklären, warum der Drucker keine Verbindung herstellt oder nicht druckt.`},check:{port_mqtt:{title:`Steuerungsport (MQTT 8883)`,pass:`Erreichbar — der Drucker akzeptiert Steuerungsverbindungen.`,fail:`Port 8883 ist nicht erreichbar. Der Drucker ist ausgeschaltet, hat eine andere IP-Adresse oder eine Firewall blockiert ihn. Überprüfen Sie die Drucker-IP und dass nichts Port 8883 blockiert.`},port_ftps:{title:`Dateiübertragungsport (FTPS 990)`,pass:`Erreichbar — das Senden von Druckdateien funktioniert.`,warn:`Port 990 ist nicht erreichbar. Die Überwachung funktioniert möglicherweise weiterhin, aber das Senden von Drucken an den Drucker schlägt fehl. Stellen Sie sicher, dass Port 990 nicht blockiert ist.`},external_storage:{title:`Gesendete Dateien auf externem Speicher speichern (Installationsschritt 4)`,pass:`Der Drucker meldet, dass diese Option aktiv ist — gesendete Dateien werden auf der SD-Karte gespeichert und Archive enthalten Vorschaubilder und Slicer-Metadaten.`,fail:`Der Drucker meldet, dass diese Option deaktiviert ist. Aktivieren Sie "Gesendete Dateien auf externem Speicher speichern" — bei neuer Firmware (P2S 01.02 / Bambu Studio 2.6+) liegt der Schalter in den Druckeinstellungen des Druckers, bei älteren Versionen im Geräte-Tab von Bambu Studio / OrcaSlicer. Ohne diese Option fehlen jedem archivierten Druck Vorschaubild und Slicer-Metadaten.`,skip:`Nicht geprüft — eine aktive MQTT-Verbindung ist erforderlich. Bei älteren Slicern, in denen diese Einstellung nur im Slicer existiert, meldet sie der Drucker nicht — diese Prüfung besteht auch dann, wenn die Option deaktiviert ist. Prüfen Sie Installationsschritt 4 in diesem Fall manuell.`},port_rtsps:{title:`Kameraport ({{protocol}} {{port}})`,pass:`Erreichbar — der Kamerastream funktioniert.`,warn:`Port {{port}} ist nicht erreichbar. Die Live-Kameraansicht funktioniert nicht. Dies betrifft das Drucken nicht.`},network_mode:{title:`Docker-Netzwerkmodus`,pass:`Läuft im Host-Netzwerkmodus.`,warn:`Bambuddy läuft im Docker-Bridge-Netzwerkmodus. Die Druckererkennung und der virtuelle Drucker benötigen den Host-Netzwerkmodus — erstellen Sie den Container mit "network_mode: host" neu.`,skip:`Läuft nicht in Docker — nicht zutreffend.`},subnet:{title:`Netzwerk-Subnetz`,pass:`Drucker und Bambuddy befinden sich im selben Subnetz.`,warn:`Der Drucker ({{printer_ip}}) und Bambuddy ({{host_ip}}) befinden sich in unterschiedlichen Subnetzen. Sie können sich möglicherweise nicht erreichen, sofern kein Routing zwischen den Subnetzen konfiguriert ist.`,skip:`Subnetz konnte nicht ermittelt werden — übersprungen.`},mqtt_auth:{title:`Drucker-Zugangsdaten`,pass:`Der Drucker hat die Verbindung akzeptiert.`,fail:`Der Drucker ist erreichbar, hat die Verbindung aber abgelehnt. Der Zugangscode oder die Seriennummer ist höchstwahrscheinlich falsch. Der Zugangscode ändert sich bei jedem Umschalten des Entwicklermodus — kopieren Sie ihn erneut vom Druckerbildschirm.`,skip:`Nicht geprüft — der Drucker konnte nicht erreicht werden.`},developer_mode:{title:`LAN-Entwicklermodus`,pass:`Der Entwicklermodus ist aktiviert.`,fail:`Der Entwicklermodus ist am Drucker AUS. Aktivieren Sie ihn in den LAN-Einstellungen des Druckers — und bestätigen Sie mit OK. Ohne ihn starten Drucke nicht.`,skip:`Konnte nicht geprüft werden — erfordert eine aktive Verbindung zum Drucker.`},printer_publishing:{title:`Drucker sendet Statusmeldungen`,pass:`Der Drucker sendet Statusmeldungen — AMS, Filamente und K-Profile werden korrekt zum Slicer gespiegelt.`,fail:`Der MQTT-Broker hat die Verbindung akzeptiert, der Drucker sendet aber keine Statusmeldungen. Fast immer liegt eine falsche oder falsch geschriebene Seriennummer vor — das Topic device//report unterscheidet Groß- und Kleinschreibung. Prüfen Sie die Seriennummer in den Druckereinstellungen gegen die Anzeige am Drucker.`,skip:`Konnte nicht geprüft werden — erfordert eine aktive Verbindung zum Drucker.`}}},systemHealth:{sectionTitle:`Systemzustand`,sectionDescription:`Durchsucht aktuelle Logs nach bekannten Problemen, die du meist selbst beheben kannst, bevor daraus ein Support-Ticket wird.`,rescan:`Erneut prüfen`,clean:`Keine bekannten Probleme in den letzten {{times}} Log-Einträgen gefunden.`,logUnavailable:`Die Protokollierung in Dateien ist deaktiviert, daher können keine Logs durchsucht werden. Aktiviere die Datei-Protokollierung, um diese Prüfung zu nutzen.`,learnMore:`Lösung anzeigen`,fixLabel:`Lösung:`,occurrences:`{{times}}× aufgetreten — zuletzt um {{lastSeen}}`,category:{layer8:`Das kannst du beheben`,environment:`Umgebung`,bug:`Bitte melden`},signature:{"ftp-auth-rejected":{name:`Drucker hat den Zugriffscode abgelehnt`,cause:`Der Drucker hat die Anmeldung für die Dateiübertragung abgelehnt. Der Zugriffscode ist falsch oder hat sich nach dem Umschalten des Entwicklermodus geändert.`,fix:`Kopiere den Zugriffscode erneut vom Druckerbildschirm (LAN-Einstellungen) und aktualisiere ihn in den Druckereinstellungen in Bambuddy.`},"ftp-connection-timeout":{name:`Zeitüberschreitung bei der Dateiübertragung`,cause:`Bambuddy konnte den Dateiübertragungs-Port des Druckers (FTPS 990) nicht erreichen. Der Port ist blockiert, oder der Drucker ist aus oder in einem anderen Subnetz.`,fix:`Stelle sicher, dass Port 990 zwischen Bambuddy und dem Drucker nicht blockiert wird und beide im selben Netzwerk sind.`},"ftp-ssl-error":{name:`Sicherer Dateiübertragungs-Handshake fehlgeschlagen`,cause:`Der TLS-Handshake mit dem Dateiübertragungs-Server des Druckers ist fehlgeschlagen. Häufig liegt das an einer Firewall oder veralteter Drucker-Firmware.`,fix:`Aktualisiere die Drucker-Firmware und prüfe, dass keine Firewall oder Proxy die Verbindung auf Port 990 abfängt.`},"mqtt-connection-flapping":{name:`Druckerverbindung bricht ständig ab`,cause:`Die Steuerverbindung (MQTT 8883) trennt und verbindet sich wiederholt — meist wegen einer schwachen Netzwerkverbindung oder eines teilweise blockierten Ports.`,fix:`Prüfe das WLAN-Signal am Drucker, bevorzuge eine Kabelverbindung und stelle sicher, dass Port 8883 zuverlässig erreichbar ist.`},"camera-connection-refused":{name:`Kamera-Stream nicht erreichbar`,cause:`Die Live-Kamera war auf Port RTSPS 322 nicht erreichbar. Der Port ist blockiert, oder die Kamera bzw. die LAN-Liveansicht ist am Drucker deaktiviert.`,fix:`Aktiviere Kamera und LAN-Liveansicht am Drucker und stelle sicher, dass Port 322 nicht blockiert ist. Das Drucken ist davon nicht betroffen.`},"database-locked":{name:`Datenbank-Schreibkonflikte`,cause:`Die SQLite-Datenbank meldet unter Last "database is locked"-Fehler — häufig beim Betrieb mehrerer Drucker gleichzeitig.`,fix:`Stelle Bambuddy auf eine externe PostgreSQL-Datenbank um. Siehe die PostgreSQL-Anleitung in der Dokumentation.`}}},vpDiagnostic:{title:`Einrichtungsprüfung — {{name}}`,runButton:`Einrichtungsprüfung ausführen`,running:`Einrichtungsprüfung läuft...`,runFailed:`Einrichtungsprüfung konnte nicht ausgeführt werden: {{error}}`,retry:`Erneut prüfen`,overall:{ok:`Alle Prüfungen bestanden — dieser virtuelle Drucker ist korrekt eingerichtet.`,warnings:`Der virtuelle Drucker sollte funktionieren, aber einige Punkte brauchen Aufmerksamkeit.`,problems:`Es wurden Probleme gefunden, die erklären, warum der Slicer diesen virtuellen Drucker nicht sehen oder nutzen kann.`},check:{enabled:{title:`Virtueller Drucker aktiviert`,fail:`Dieser virtuelle Drucker ist ausgeschaltet. Schalten Sie ihn ein, damit er erkennbar wird.`},running:{title:`Dienste laufen`,fail:`Der virtuelle Drucker ist aktiviert, aber seine Dienste laufen nicht. Prüfen Sie das Bambuddy-Protokoll — meist stoppt sie ein Bind-IP-Konflikt oder ein Berechtigungsfehler.`},bind_interface:{title:`Bind-Netzwerkschnittstelle`,fail:`Die Bind-Schnittstelle ist nicht gesetzt oder existiert auf diesem Host nicht mehr. Wählen Sie im Dropdown "Bind-Schnittstelle" eine aktuelle Schnittstelle.`},access_code:{title:`Zugangscode gesetzt`,fail:`Es ist kein Zugangscode gesetzt. Dem Slicer muss derselbe 8-stellige Zugangscode angegeben werden, den Sie hier festlegen.`},target_printer:{title:`Zieldrucker`,fail:`Es ist kein Zieldrucker ausgewählt. Der Proxy-Modus benötigt einen echten Drucker zum Weiterleiten.`,warn:`Der Zieldrucker ist gerade offline — die Weiterleitung wird fortgesetzt, sobald er sich wieder verbindet.`},port_ftps:{title:`Datei-Upload-Dienst (Port {{port}})`,fail:`Auf Port {{port}} der Bind-IP lauscht nichts, daher kann der Slicer keine Dateien hochladen. Ursache ist meist ein Port-Konflikt auf dieser Schnittstelle.`},port_mqtt:{title:`Steuerungsdienst (Port {{port}})`,fail:`Auf Port {{port}} der Bind-IP lauscht nichts, daher kann der Slicer sich nicht verbinden oder den Status anzeigen.`},port_bind:{title:`Erkennungsdienst (Port {{port}})`,fail:`Auf Port {{port}} der Bind-IP lauscht nichts, daher schlägt der Erkennungs-Handshake des Slicers fehl.`},certificate:{title:`TLS-Zertifikat`,pass:`Zertifikat bereit. Stellen Sie sicher, dass das Bambuddy-CA-Zertifikat (oben) in den Vertrauensspeicher Ihres Slicers importiert ist.`,fail:`Das TLS-Zertifikat für diesen virtuellen Drucker fehlt. Prüfen Sie, ob das Bambuddy-Datenverzeichnis beschreibbar ist.`}}},bugReport:{logHealthSummary:`Bekannte Probleme in deinen Logs gefunden`,logHealthIntro:`Aktuelle Logs entsprechen bekannten Problemen. Sieh dir die Lösungen unten an — sie zu beheben könnte dein Problem ohne Fehlerbericht lösen. Du kannst unten trotzdem einen Bericht senden.`,title:`Fehler melden`,description:`Beschreibung`,descriptionPlaceholder:`Was ist schiefgelaufen? Bitte beschreiben Sie das Problem...`,email:`E-Mail (optional)`,emailPlaceholder:`ihre@email.de`,emailPrivacy:`Falls angegeben, wird Ihre E-Mail in einem eingeklappten Abschnitt des GitHub-Issues aufgeführt, damit der Betreuer sich melden kann.`,screenshot:`Screenshot`,uploadOrPaste:`Bild hochladen, einfügen oder ziehen`,dataCollectedSummary:`Welche Daten werden im Bericht gesendet?`,dataIncluded:`Enthalten:`,dataIncludedList:`App-Version, Betriebssystem, Architektur, Python-Version, Datenbankstatistiken (nur Anzahl), Druckermodelle, Düsenanzahl, Firmware-Versionen, Verbindungsstatus, Integrationsstatus (Spoolman, MQTT, HA), nicht-sensible Einstellungen, Netzwerkschnittstellenanzahl, Docker-Details, Abhängigkeitsversionen.`,dataNeverIncluded:`Nie enthalten:`,dataNeverIncludedList:`Druckernamen, Seriennummern, Zugangscodes, Passwörter, IP-Adressen, E-Mail-Adressen, API-Schlüssel, Tokens, Webhook-URLs, Hostnamen oder Benutzernamen.`,submit:`Absenden`,startLogging:`Debug-Protokollierung starten`,stepEnableLogging:`Debug-Protokollierung aktiviert`,stepReproduce:`Problem jetzt reproduzieren`,stepStopLogging:`Stoppen & Bericht senden`,stopAndSubmit:`Stoppen & Senden`,maxDuration:`Stoppt automatisch nach {{minutes}} Min.`,stoppingLogs:`Protokolle sammeln & senden...`,submitting:`Fehlerbericht wird gesendet...`,submittingStepConnection:`Drucker-Verbindungsprüfungen werden ausgeführt`,submittingStepVirtualPrinters:`Setup-Prüfungen für virtuelle Drucker werden ausgeführt`,submittingStepLogScan:`Aktuelle Protokolle werden auf bekannte Probleme überprüft`,submittingStepSubmit:`Bericht wird an GitHub gesendet`,submitSuccess:`Fehlerbericht erfolgreich gesendet!`,submitFailed:`Fehlerbericht konnte nicht gesendet werden`,diagnosticChecking:`Druckerverbindungen werden geprüft...`,diagnosticHealthy:`Verbindungsprüfung bestanden — keine Probleme an Ihren Druckern gefunden.`,diagnosticSummary:`{{problems}} von {{total}} Druckern haben Verbindungsprobleme`,diagnosticIntro:`Einer oder mehrere Drucker haben ein Verbindungsproblem, das die Ursache Ihres Problems sein könnte. Klappen Sie einen Drucker unten auf, um die Lösung zu sehen — sie zu beheben könnte das Problem ohne Fehlerbericht lösen. Sie können unten dennoch einen Bericht senden.`,thankYou:`Vielen Dank!`,submitted:`Ihr Fehlerbericht wurde eingereicht.`,viewIssue:`Issue ansehen`,unexpectedError:`Ein unerwarteter Fehler ist aufgetreten`},failureDetection:{title:`KI-Fehlererkennung`,description:`Überwacht Drucke über eine selbst gehostete Obico-ML-API und reagiert automatisch auf erkannte Fehldrucke.`,mlUrl:`Obico-ML-API-URL`,mlUrlHint:`Basis-URL deines selbst gehosteten Obico-ml_api-Containers (z. B. http://192.168.1.10:3333).`,test:`Testen`,testSuccess:`ML-API erreichbar und funktionsfähig.`,testFailed:`ML-API konnte nicht erreicht werden.`,sensitivity:`Empfindlichkeit`,sensitivityLow:`Niedrig (weniger Fehlalarme)`,sensitivityMedium:`Mittel (ausgewogen)`,sensitivityHigh:`Hoch (frühe Erkennung, mehr Fehlalarme)`,sensitivityHint:`Passt die Konfidenz-Schwellwerte an, die Warnungen und Fehler auslösen.`,action:`Aktion bei erkanntem Fehler`,actionNotify:`Nur benachrichtigen`,actionPause:`Druck pausieren`,actionPauseOff:`Pausieren und Strom abschalten`,pollInterval:`Prüfintervall (Sekunden)`,pollIntervalHint:`Wie oft jeder Drucker während eines laufenden Drucks geprüft wird. Minimum 5 s, Maximum 120 s.`,externalUrlMissing:`Externe URL ist nicht gesetzt.`,externalUrlHint:`Die ML-API ruft das Kamera-Snapshot per URL ab. Setze die externe URL in den allgemeinen Einstellungen, damit der ML-API-Container Bambuddy erreichen kann.`,perPrinterTitle:`Überwachte Drucker`,perPrinterHint:`Wähle, welche Drucker vom Erkennungsdienst überwacht werden.`,monitorAll:`Alle verbundenen Drucker überwachen`,statusTitle:`Status`,serviceRunning:`Dienst läuft`,thresholds:`Niedrig / Hoch-Schwellwerte`,activePrinters:`Aktive Drucke`,noActivePrints:`Derzeit laufen keine Drucke.`,historyTitle:`Letzte Erkennungen`,noHistory:`Noch keine Erkennungen.`},makerworld:{title:`MakerWorld`,description:`Füge eine MakerWorld-Modell-URL ein, um es direkt aus Bambuddy zu importieren und zu drucken — ohne die Bambu Handy App zu öffnen.`,pasteUrlHeader:`Von MakerWorld importieren`,pasteUrlPlaceholder:`https://makerworld.com/de/models/… oder beliebigen MakerWorld-Link einfügen`,resolveButton:`Laden`,signInRequiredTitle:`Bambu-Cloud-Anmeldung für Download erforderlich`,signInRequiredBody:`Modell-Details können anonym angezeigt werden, aber MakerWorld verlangt eine Bambu-Cloud-Anmeldung zum Herunterladen der 3MF-Dateien.`,openCloudSettings:`Cloud-Einstellungen öffnen`,untitledModel:`Unbenanntes Modell`,byCreator:`von {{name}}`,downloadsCount:`{{count}} Downloads`,licensePrefix:`Lizenz`,alreadyImported:`Bereits in Bibliothek`,openOnMakerworld:`Auf MakerWorld öffnen`,alreadyInLibrary:`Dieses Modell ist bereits in deiner Bibliothek — zu finden im Dateimanager → MakerWorld`,importSuccess:`{{filename}} importiert — gespeichert im Dateimanager → MakerWorld`,platesHeader:`Platten ({{count}})`,plateDefaultName:`Platte {{n}}`,materialCount:`{{count}} Filamente`,amsRequired:`AMS erforderlich`,slicedFor:`Gesliced für {{printer}}`,alsoCompatible:`Auch kompatibel: {{printers}}`,importToLibrary:`Speichern`,sliceIn:`Speichern & in {{slicer}} öffnen`,disclaimer:`Die MakerWorld-Integration verwendet von der Community dokumentierte API-Endpunkte. Bambuddy ist nicht mit MakerWorld oder Bambu Lab verbunden oder von diesen unterstützt.`,lastImportSuccess:`In deine Bibliothek importiert`,lastImportAlreadyInLibrary:`Bereits in deiner Bibliothek`,viewInLibrary:`Im Dateimanager anzeigen`,openInBambuStudio:`In Bambu Studio öffnen`,openInOrcaSlicer:`In OrcaSlicer öffnen`,importTo:`In Dateimanager importieren`,recentImportsHeader:`Zuletzt importiert`,phaseResolving:`Auflösen`,phaseDownloading:`Lade herunter`,folderAuto:`MakerWorld (Standard)`,importAll:`Alle importieren`,importAllProgress:`Importiere {{current}}/{{total}}`,openGallery:`Bildergalerie öffnen`,galleryPrev:`Vorheriges Bild`,galleryNext:`Nächstes Bild`,deleteImport:`Aus Bibliothek entfernen`,importDeleting:`Wird entfernt…`,importDeleted:`Aus Bibliothek entfernt`,confirmDelete:`{{filename}} aus der Bibliothek entfernen? Die lokale Datei wird gelöscht, die Platte kann aber erneut von MakerWorld importiert werden.`,errors:{resolveFailed:`Diese MakerWorld-URL konnte nicht aufgelöst werden.`,downloadFailed:`Download fehlgeschlagen. Bitte erneut versuchen.`,deleteFailed:`Datei konnte nicht aus der Bibliothek entfernt werden.`}},gcodeViewer:{back:`Zurück`,backToArchives:`Zurück zum Druckarchiv`,backToFiles:`Zurück zum Dateimanager`},libraryTrash:{title:`Papierkorb`,headerButton:`Papierkorb`,headerTooltip:`In den Papierkorb verschobene Dateien anzeigen`,backToFiles:`Zurück zum Dateimanager`,subtitleAdmin:`Gelöschte Dateien bleiben {{days}} Tage hier und werden dann automatisch entfernt. Diese Ansicht zeigt Papierkorb-Dateien aller Benutzer.`,subtitleUser:`Gelöschte Dateien bleiben {{days}} Tage hier und werden dann automatisch entfernt.`,loading:`Papierkorb wird geladen…`,loadError:`Papierkorb konnte nicht geladen werden.`,empty:`Der Papierkorb ist leer.`,summary:`{{count}} Dateien · {{size}}`,emptyTrash:`Papierkorb leeren`,restore:`Wiederherstellen`,purgeNow:`Jetzt löschen`,autoPurgeIn:`Wird in {{when}} gelöscht`,days:`Tage`,retentionLabel:`Automatisch löschen nach`,selectAll:`Alle auswählen`,selectOne:`{{filename}} auswählen`,selectionCount:`{{count}} ausgewählt`,bulkRestore:`Auswahl wiederherstellen`,bulkPurge:`Auswahl löschen`,col:{filename:`Datei`,folder:`Ordner`,size:`Größe`,deleted:`Verschoben`,autoPurge:`Löschung`,owner:`Besitzer`,actions:`Aktionen`},confirm:{purgeTitle:`Endgültig löschen?`,purgeBody:`{{filename}} wird von der Festplatte gelöscht und kann nicht wiederhergestellt werden.`,emptyTitle:`Papierkorb leeren?`,emptyBody:`Alle {{count}} Dateien werden endgültig von der Festplatte gelöscht.`,bulkPurgeTitle:`Ausgewählte Dateien endgültig löschen?`,bulkPurgeBody:`Die {{count}} ausgewählten Dateien werden von der Festplatte gelöscht und können nicht wiederhergestellt werden.`,cta:`Endgültig löschen`},toast:{restored:`Datei wiederhergestellt.`,restoreFailed:`Datei konnte nicht wiederhergestellt werden.`,purged:`Datei endgültig gelöscht.`,purgeFailed:`Datei konnte nicht gelöscht werden.`,emptied:`{{count}} Datei(en) aus dem Papierkorb gelöscht.`,emptyFailed:`Papierkorb konnte nicht geleert werden.`,retentionSaved:`Automatisches Löschen auf {{days}} Tage gesetzt.`,retentionFailed:`Einstellung konnte nicht gespeichert werden.`,bulkRestored:`{{count}} Datei(en) wiederhergestellt.`,bulkPurged:`{{count}} Datei(en) gelöscht.`}},libraryPurge:{title:`Alte Dateien entfernen`,headerButton:`Alte entfernen`,headerTooltip:`Alte Dateien im Block in den Papierkorb verschieben`,description:`Räume alte Dateien in einem Rutsch aus deiner Bibliothek. Dateien mit Druckverlauf werden nach dem letzten Druckdatum bewertet; nie gedruckte Dateien nach dem Upload-Datum.`,ageLabel:`Dateien älter als`,days:`Tage`,includeNeverPrinted:`Dateien einbeziehen, die nie gedruckt wurden`,effectsTitle:`Was passiert, wenn du auf „Entfernen" klickst`,effect1:`Passende Dateien werden in den Papierkorb verschoben — noch nicht von der Festplatte gelöscht.`,effect2:`Du kannst sie bis zum Ablauf der Aufbewahrungsfrist jederzeit wiederherstellen.`,effect3:`Nach Ablauf der Frist löscht der Papierkorb-Sweeper sie endgültig von der Festplatte.`,effect4:`Dateien in externen (verknüpften) Ordnern werden übersprungen — Bambuddy löscht keine Bytes, die ihm nicht gehören.`,previewLoading:`Prüfe, wie viele Dateien passen…`,previewFailed:`Vorschau konnte nicht geladen werden.`,previewSummary:`{{count}} Dateien · {{size}} würden in den Papierkorb verschoben`,andMore:`…und {{count}} weitere`,warning:`Dateien im Papierkorb zählen weiterhin zum Speicher, bis die Aufbewahrungsfrist abgelaufen ist. Leere den Papierkorb danach, um sofort Speicher freizugeben.`,confirmCta:`{{count}} in den Papierkorb verschieben`,purging:`Wird verschoben…`,toast:{success:`{{count}} Datei(en) in den Papierkorb verschoben.`,failed:`Dateien konnten nicht verschoben werden.`}},libraryAutoPurge:{enableLabel:`Alte Dateien automatisch entfernen`,enableDescription:`Führt die Admin-Bereinigung einmal pro Tag aus. Dateien landen zuerst im Papierkorb — sie werden nicht sofort gelöscht.`,ageLabel:`Dateien älter als`,ageDescription:`Minimum 7 Tage, Maximum 10 Jahre. Verwendet dieselbe Altersregel wie die manuelle „Alte entfernen“-Schaltfläche.`,days:`Tage`,includeNeverPrinted:`Dateien einbeziehen, die nie gedruckt wurden`,saveFailed:`Einstellungen konnten nicht gespeichert werden.`},archivePurge:{headerButton:`Alte löschen`,headerTooltip:`Alte Archive in einem Rutsch löschen`,title:`Alte Archive löschen`,description:`Räume alte Druckhistorie auf. Jedes Archiv wird nach seinem letzten abgeschlossenen Druck bewertet — ein erneuter Druck setzt die Frist zurück, aktive Arbeit bleibt sicher.`,ageLabel:`Archive löschen, die zuletzt gedruckt wurden vor`,days:`Tage`,effectsTitle:`Was passiert, wenn du auf „Löschen" klickst`,effect1:`Jedes passende Archiv wird aus der Listenansicht ausgeblendet und seine Dateien werden von der Festplatte entfernt (3MF, Vorschau, Timelapse, Quell-3MF, F3D, Fotos).`,effect2:`Die Archivzeile bleibt in der Datenbank, damit die Quick Stats den Filament-, Zeit-, Kosten- und Energiebeitrag behalten — wie der Standard beim Einzel-Löschen.`,effect3:`Aktiviere unten „Auch aus Statistiken entfernen", um zusätzlich den Quick-Stats-Beitrag zu verwerfen (entspricht dem Einzel-Löschen-Häkchen). Dieser Pfad ist unwiderruflich.`,effect4:`Ein erneuter Druck setzt die Frist zurück, Archive, die du weiterhin nutzt, bleiben sicher.`,purgeStatsLabel:`Auch aus Statistiken entfernen`,purgeStatsHint:`Verwirft die passenden Archive aus den Quick Stats (Filament, Zeit, Kosten, Energie). Ohne diese Option behalten die Quick Stats jeden Beitrag und nur die Dateien werden gelöscht.`,previewLoading:`Prüfe passende Archive…`,previewFailed:`Vorschau konnte nicht erstellt werden.`,previewSummary:`{{count}} Archive · {{size}} würden entfernt`,andMore:`…und {{count}} weitere`,warning:`Dateien werden von der Festplatte entfernt und können nicht wiederhergestellt werden. Lade wichtige Archive vorher herunter oder markiere sie als Favorit.`,confirmCta:`{{count}} Archiv(e) entfernen`,purging:`Entferne…`,toast:{success:`{{count}} Archiv(e) entfernt.`,failed:`Archive konnten nicht gelöscht werden.`}},archiveAutoPurge:{enableLabel:`Alte Archive automatisch löschen`,enableDescription:`Blendet einmal pro Tag Archive aus der Listenansicht aus und entfernt ihre Dateien von der Festplatte, wenn sie im angegebenen Zeitraum nicht gedruckt wurden. Ein erneuter Druck setzt die Frist zurück.`,ageLabel:`Archive automatisch löschen, die zuletzt gedruckt wurden vor`,ageDescription:`Minimum 7 Tage, Maximum 10 Jahre. Basiert auf dem letzten abgeschlossenen Druck — ein erneuter Druck setzt die Frist zurück. Entfernt 3MF, Vorschau, Timelapse, Quell-3MF, F3D und Fotos.`,days:`Tage`,purgeStatsLabel:`Auch aus Statistiken entfernen`,purgeStatsDescription:`Wenn aktiviert, verwirft der tägliche Sweeper auch den Quick-Stats-Beitrag (Filament, Zeit, Kosten, Energie) jedes gelöschten Archivs. Standard aus — Quick Stats behalten den Beitrag, nur die Dateien werden gelöscht.`,runNow:`Archive jetzt löschen`,saveFailed:`Einstellungen konnten nicht gespeichert werden.`},cameraTokens:{title:`Kamera-API-Tokens`,navTitle:`Kamera-API-Tokens`,description:`Langlebige Tokens zum Einbetten des Kamerastreams in Home Assistant, Frigate, Kioske oder andere Tools, die eine stabile URL benötigen. Jeder Token ist nur für den Kamerastream und kann jederzeit widerrufen werden.`,loading:`Laden…`,confirmRevoke:{title:`Dieses Token widerrufen?`,body:`Jedes Gerät, das "{{name}}" verwendet, verliert sofort den Zugriff. Dies kann nicht rückgängig gemacht werden.`,cancel:`Abbrechen`,confirm:`Widerrufen`},create:{title:`Neues Token erstellen`,nameLabel:`Token-Name`,namePlaceholder:`z. B. Home Assistant`,daysLabel:`Tage bis Ablauf`,submit:`Erstellen`,hint:`Maximale Lebensdauer 365 Tage. Der Token-Wert wird nur einmal bei der Erstellung angezeigt – jetzt kopieren.`},created:{title:`Token erstellt – jetzt kopieren`,warning:`Dies ist das einzige Mal, dass dieser Token sichtbar ist. Nach dem Schließen dieses Dialogs können Sie ihn nie wieder anzeigen.`,copy:`Kopieren`,dismiss:`Ich habe es gespeichert`},list:{myTitle:`Meine Tokens`,allTitle:`Alle Benutzer (Admin-Ansicht)`,empty:`Noch keine Tokens.`,name:`Name`,owner:`Eigentümer`,prefix:`Präfix`,created:`Erstellt`,expires:`Läuft ab`,lastUsed:`Zuletzt verwendet`,revoke:`Widerrufen`,expired:`Abgelaufen`},toast:{created:`Token erstellt`,createFailed:`Token konnte nicht erstellt werden`,revoked:`Token widerrufen`,revokeFailed:`Token konnte nicht widerrufen werden`,loadFailed:`Tokens konnten nicht geladen werden`,copied:`In Zwischenablage kopiert`,copyFailed:`Kopieren fehlgeschlagen – manuell auswählen und kopieren`}},forecast:{title:`Bestandsprognose`,noSpools:`Keine aktiven Spulen gefunden. Fügen Sie Spulen zu Ihrem Inventar hinzu, um Prognosedaten zu sehen.`,noUsageData:`Keine Verbrauchsdaten verfügbar — die Bestandszeitlinie kann nicht projiziert werden.`,sku:`SKU`,material:`Material`,stock:`Bestand`,dailyRate:`Rate`,daysLeft:`Verbleibende Tage`,emptyBy:`Aufgebraucht am`,reorderBy:`Nachbestellen bis`,actions:`Aktionen`,trend:`Trend`,estimated:`Gesch.`,noData:`Keine Daten`,timeframe:`Zeitraum`,chartTitle:`Bestandsprognose — Top 5 Materialien`,dashedLinesROP:`Gestrichelte Linien = Nachbestellpunkte`,stockLevel:`Bestandsniveau`,reorderPoint:`Nachbestellpunkt`,safetyMargin:`Sicherheitspuffer`,trendLegend:`Trend (verlaufsbasiert, 95 % Serviceniveau)`,estimatedLegend:`Geschätzt (Gewichtsdelta)`,noDataLegend:`Keine Daten`,ropLabel:`NBP`,ssLabel:`SB`,safetyStockLegend:`Sicherheitsbestand`,stockArrivalLegend:`Wareneingang`,stockoutLegend:`Fehlbestand`,alertCount_one:`{{count}} Warnung`,alertCount_other:`{{count}} Warnungen`,order:`Bestellen`,globalLeadTime:`Globale Lieferzeit`,globalLeadTimeHint:`Globale Lieferzeitvorgabe — wird in der Nachbestellpunktberechnung für alle SKUs verwendet`,save:`Speichern`,cancel:`Abbrechen`,settingsSaved:`Einstellungen gespeichert`,failedSaveSettings:`Einstellungen konnten nicht gespeichert werden`,globalLeadTimeSaved:`Globale Lieferzeit gespeichert`,skuLeadTimeOverride:`SKU-Lieferzeitüberschreibung`,skuLeadTimeHint:`0 = globale Lieferzeit verwenden. Größer 0 setzen, um für diesen SKU zu überschreiben.`,safetyMarginLabel:`Sicherheitspuffer`,effectiveLeadTime:`Effektive Lieferzeit`,effectiveLeadTimeHint:`max(global {{global}}T, SKU {{sku}}T)`,reorderPointHint:`d̄ × LT + safety margin — bei diesem Bestand bestellen`,safetyMarginHint:`Statistischer Sicherheitsbestand (z=1,65 × σ × √LT) + benutzerdefinierter Puffer`,safetyMarginHintDays:`Zusätzlicher Puffer auf den statistischen Sicherheitsbestand.{{approx}}`,safetyMarginHintDaysApprox:` ≈ {{g}}g beim aktuellen Verbrauch.`,safetyMarginHintG:`Fester Gewichtspuffer auf den statistischen Sicherheitsbestand.{{approx}}`,safetyMarginHintGApprox:` ≈ {{days}}d beim aktuellen Verbrauch.`,individualSpools:`Einzelne Spulen`,labelWeight:`Etikett`,spoolCount_one:`{{count}} Spule`,spoolCount_other:`{{count}} Spulen`,stockBreakRisk:`Bestandsunterbrechungsrisiko`,stockBreakBefore:`Bestandsunterbrechung vor Auffüllung`,stockBreakDetail:`{{days}}d verbleibend, Lieferzeit {{lt}}d.`,reorderNow:`Jetzt nachbestellen`,reorderTriggerPassed:`Auslösedatum {{date}} ist überschritten.`,shoppingList:`Einkaufsliste`,shoppingListItems_one:`({{count}} Artikel)`,shoppingListItems_other:`({{count}} Artikel)`,shoppingListEmpty:`Einkaufsliste ist leer. Klicken Sie auf das Warenkorbsymbol in einer Zeile, um Artikel hinzuzufügen.`,addToCart:`Zur Einkaufsliste hinzufügen`,alertsSnoozed:`Benachrichtigungen für diese SKU stummschalten`,alertsEnabled:`Benachrichtigungen für diese SKU aktivieren`,addedToCart:`Zur Einkaufsliste hinzugefügt`,failedAddItem:`Artikel konnte nicht hinzugefügt werden`,listView:`Liste`,logisticsView:`Logistik`,qty:`Menge`,weight:`Gewicht`,leadTime:`Lieferzeit`,expectedRestock:`Erwartete Auffüllung`,status:`Status`,note:`Notiz`,pending:`Ausstehend`,purchased:`Bestellt`,received:`Erhalten`,markPurchased:`Als bestellt markieren`,markReceived:`Als erhalten markieren — fügt Spulen dem Lagerbestand hinzu`,resetToPending:`Auf ausstehend zurücksetzen`,remove:`Entfernen`,clearAll:`Alle löschen`,downloadCsv:`CSV`,addToCartTitle:`Zur Einkaufsliste hinzufügen`,byQuantity:`Nach Menge`,byDuration:`Nach Dauer`,numberOfSpools:`Anzahl der Spulen`,lastHowManyDays:`Wie viele Tage soll es reichen?`,noUsageQty:`Keine Verbrauchsdaten — Menge auf 1 gesetzt.`,noteOptional:`Notiz (optional)`,notePlaceholder:`z. B. für Projekt X, dringend…`,addNSpools_one:`{{count}} Spule hinzufügen`,addNSpools_other:`{{count}} Spulen hinzufügen`,onArrival:`Bei Ankunft`,stockBreakIn:`Bestandsunterbrechung in {{days}}d.`,stockRunsOutBefore:`Bestand läuft vor Ablauf der {{lt}}d Lieferzeit aus.`,atRate:`Bei {{rate}}g/Tag benötigen Sie`,moreSpools_one:`{{count}} weitere Spule`,moreSpools_other:`{{count}} weitere Spulen`,bridgeGap:`um die Lücke zu überbrücken.`,noReadAccess:`Sie haben keine Berechtigung, Bestandsprognosen anzuzeigen.`,noWriteAccess:`Sie haben keine Berechtigung, Prognoseeinstellungen zu ändern.`}}},es:{translation:{nav:{printers:`Impresoras`,archives:`Archivos`,queue:`Cola de impresión`,stats:`Estadísticas`,profiles:`Perfiles`,maintenance:`Mantenimiento`,projects:`Proyectos`,inventory:`Filamento`,files:`Gestor de archivos`,makerworld:`MakerWorld`,notifications:`Notificaciones`,settings:`Ajustes`,system:`Sistema`,collapseSidebar:`Contraer barra lateral`,expandSidebar:`Expandir barra lateral`,update:`Actualizar`,updateAvailable:`Actualización disponible: v{{version}}`,updateAvailableBanner:`¡La versión {{version}} está disponible!`,viewUpdate:`Ver actualización`,viewOnGithub:`Ver en GitHub`,keyboardShortcuts:`Atajos de teclado (?)`,switchToLight:`Cambiar a modo claro`,switchToDark:`Cambiar a modo oscuro`,switchToSystem:`Cambiar a modo del sistema`,smartSwitches:`Interruptores inteligentes`,logout:`Cerrar sesión`,installApp:`Instalar app`,installAppSuccess:`Bambuddy se ha instalado`},common:{save:`Guardar`,saving:`Guardando...`,cancel:`Cancelar`,delete:`Eliminar`,edit:`Editar`,add:`Añadir`,close:`Cerrar`,confirm:`Confirmar`,loading:`Cargando...`,error:`Error`,errorLoading:`Error al cargar los datos`,retry:`Reintentar`,success:`Éxito`,warning:`Advertencia`,enabled:`Activado`,disabled:`Desactivado`,yes:`Sí`,no:`No`,on:`Encendido`,off:`Apagado`,all:`Todos`,none:`Ninguno`,search:`Buscar`,filter:`Filtrar`,sort:`Ordenar`,refresh:`Actualizar`,download:`Descargar`,upload:`Subir`,uploading:`Subiendo...`,uploadFailed:`Error al subir`,actions:`Acciones`,status:`Estado`,name:`Nombre`,description:`Descripción`,date:`Fecha`,time:`Hora`,hours:`horas`,minutes:`minutos`,seconds:`segundos`,days:`días`,enable:`Activar`,disable:`Desactivar`,permissions:`Permisos`,noPrinters:`No hay impresoras configuradas`,noData:`No hay datos disponibles`,linkNotFound:`Enlace no encontrado`,required:`Obligatorio`,optional:`Opcional`,dismiss:`Descartar`,apply:`Aplicar`,reset:`Restablecer`,export:`Exportar`,import:`Importar`,clear:`Borrar`,selectAll:`Seleccionar todo`,deselectAll:`Deseleccionar todo`,noChange:`— Sin cambios —`,unchanged:`Sin cambios`,unassigned:`Sin asignar`,unknown:`Desconocido`,unknownError:`Error desconocido`,today:`Hoy`,tomorrow:`Mañana`,asap:`Lo antes posible`,overdue:`Atrasado`,now:`Ahora`,collapse:`Contraer`,expand:`Expandir`,viewArchive:`Ver archivo`,viewInFileManager:`Ver en el gestor de archivos`,addedBy:`Añadido por {{username}}`,prints:`impresiones`,more:`+{{count}} más`,ascending:`Ascendente`,descending:`Descendente`,back:`Atrás`,copy:`Copiar`,copied:`¡Copiado!`,printer:`Impresora`,remove:`Quitar`,type:`Tipo`,print:`Imprimir`,rename:`Renombrar`,move:`Mover`,create:`Crear`,duplicate:`Duplicar`,left:`Izquierda`,right:`Derecha`},printers:{addPreflight:{checking:`Comprobando la conexión...`,warning:`Algunas comprobaciones de conexión fallaron. Esta impresora podría aparecer como desconectada. Revisa las comprobaciones de abajo, soluciona lo que puedas o guárdala de todos modos.`,back:`Atrás`,saveAnyway:`Guardar de todos modos`},title:`Impresoras`,addPrinter:`Añadir impresora`,editPrinter:`Editar impresora`,deletePrinter:`Eliminar impresora`,printerName:`Nombre de la impresora`,serialNumber:`Número de serie`,ipAddress:`Dirección IP / Nombre de host`,accessCode:`Código de acceso`,model:`Modelo`,nozzleCount:`Número de boquillas`,autoArchive:`Archivado automático`,status:{available:`Disponible`,idle:`Inactiva`,printing:`Imprimiendo`,paused:`En pausa`,offline:`Desconectada`,problem:`Problema`,error:`Error`,finished:`Finalizada`,unknown:`Desconocido`},temperatures:{nozzle:`Boquilla`,bed:`Cama`,chamber:`Cámara`},heaterHistory:{title:`Historial de calentadores`,openLabel:`Ver historial de calentadores`,nozzle:`Boquilla`,nozzle2:`Boquilla 2`,bed:`Cama`,chamber:`Cámara`,error:`No se pudo cargar el historial`,empty:`Aún no hay datos registrados`},progress:`{{percent}}% completado`,timeRemaining:`{{time}} restante`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"?`,maintenanceOk:`Mantenimiento correcto`,maintenanceWarning:`{{count}} advertencia`,maintenanceWarning_plural:`{{count}} advertencias`,maintenanceDue:`{{count}} pendiente`,maintenanceDue_plural:`{{count}} pendientes`,sort:{name:`Nombre`,status:`Estado`,model:`Modelo`,location:`Ubicación`,eta:`Tiempo restante`,ascending:`Orden ascendente`,descending:`Orden descendente`},cardSize:{small:`Tarjetas pequeñas`,medium:`Tarjetas medianas`,large:`Tarjetas grandes`,extraLarge:`Tarjetas extragrandes`},hideOffline:`Ocultar desconectadas`,nextAvailable:`Próxima disponible`,powerOn:`Encender`,offlinePrintersWithPlugs:`Impresoras desconectadas con enchufes inteligentes`,noPrintersConfigured:`Aún no hay impresoras configuradas`,search:`Buscar impresoras...`,noSearchResults:`Ninguna impresora coincide con su búsqueda o filtros`,filter:{allStatuses:`Todos los estados`,allLocations:`Todas las ubicaciones`},toolbar:{filters:`Filtros`,view:`Vista`,actions:`Acciones`},readyToPrint:`Lista para imprimir`,external:`Externo`,extL:`Ext-L`,extR:`Ext-R`,deleteArchives:`Eliminar archivos de impresión`,noLabel:`Sin etiqueta`,printPreview:`Vista previa de impresión`,width:`Anchura`,height:`Altura`,noObjectsFound:`No se encontraron objetos`,objectsLoadedOnPrintStart:`Los objetos se cargan al iniciar una impresión`,willBeSkipped:`Se omitirá`,name:`Nombre`,serialCannotBeChanged:`El número de serie no se puede cambiar`,locationHelp:`Se usa para agrupar impresoras y filtrar trabajos en cola`,wifiSignal:{veryWeak:`Muy débil`,weak:`Débil`,fair:`Aceptable`,good:`Buena`,excellent:`Excelente`},maintenanceUpToDate:`Todo el mantenimiento al día - Haga clic para ver`,maintenance:{title:`En mantenimiento`,subtitle:`Esta impresora está en pausa — sin conexión, no elegible para la cola y sin enviar notificaciones.`,pillLabel:`Mantenimiento`,exitButton:`Salir de mantenimiento`,menuEnter:`Entrar en modo mantenimiento`,menuExit:`Salir del modo mantenimiento`,toastEntered:`{{name}} ahora está en modo mantenimiento`,toastExited:`{{name}} vuelve a estar en línea`,confirmMidPrintTitle:`¿Entrar en modo mantenimiento durante una impresión?`,confirmMidPrintMessage:`{{name}} está imprimiendo actualmente. Entrar en modo mantenimiento desconectará MQTT y detendrá el seguimiento del progreso y las notificaciones de finalización para este trabajo. ¿Continuar?`,editFieldLabel:`Modo mantenimiento`,editFieldHelp:`Cuando está activado, esta impresora se pausa de MQTT, despacho de cola y notificaciones — útil para reparaciones, instalaciones paralelas de Bambuddy o suspensión temporal.`},chamberLightOn:`Encender luz de la cámara`,chamberLightOff:`Apagar luz de la cámara`,files:`Archivos`,browseFiles:`Explorar archivos de la impresora`,autoOffAfterPrint:`Apagado automático tras la impresión`,autoOffExecuted:`Se ejecutó el apagado automático - encienda la impresora para restablecer`,hmsErrors:`Errores HMS`,viewHmsErrors:`Ver {{count}} error(es) HMS`,resume:`Reanudar`,pause:`Pausar`,stop:`Detener`,camera:`Cámara`,skipObject:`Omitir objeto`,reconnect:`Reconectar`,forceRefresh:`Forzar actualización`,forceRefreshSuccess:`Actualización solicitada`,mqttDebug:`Depuración MQTT`,printerInformation:`Información de la impresora`,copyToClipboard:`Copiar`,copied:`¡Copiado!`,state:`Estado`,wifiSignalLabel:`Señal Wi-Fi`,developerMode:`Modo desarrollador`,enabled:`Activado`,disabled:`Desactivado`,addedOn:`Añadida`,sdCard:`Tarjeta SD`,inserted:`Insertada`,notInserted:`No insertada`,totalPrintHours:`Horas de impresión`,activeNozzle:`Activa: boquilla {{nozzle}}`,nozzleRack:`Soporte de boquillas`,nozzleDocked:`Acoplada`,nozzleMounted:`Montada`,nozzleActive:`Activa`,nozzleIdle:`Inactiva`,nozzleDiameter:`Diámetro`,nozzleType:`Tipo`,nozzleStatus:`Estado`,nozzleFilament:`Filamento`,nozzleWear:`Desgaste`,nozzleMaxTemp:`Temp. máx.`,nozzleSerial:`Serie`,nozzleHardenedSteel:`Acero endurecido`,nozzleStainlessSteel:`Acero inoxidable`,nozzleTungstenCarbide:`Carburo de tungsteno`,nozzleFlow:`Flujo`,nozzleHighFlow:`Flujo alto`,nozzleStandardFlow:`Estándar`,firmwareUpdate:`Actualización de firmware`,firmwareInstructions:`En la pantalla táctil de la impresora, vaya a`,firmwareNav:`Navegue hasta`,settings:`Ajustes`,firmware:`Firmware`,discoverPrinters:`Detectar impresoras`,searching:`Buscando...`,manualEntry:`Entrada manual`,addFromCloud:`Añadir desde la nube`,toast:{printerDeleted:`Impresora eliminada`,missingSpoolAssignment:`Impresión iniciada en {{printer}}. Falta la asignación de bobina para: {{slots}}`,printerAdded:`Impresora añadida`,printerUpdated:`Impresora actualizada`,failedToDelete:`Error al eliminar la impresora`,failedToAdd:`Error al añadir la impresora`,connectionFailedNotAdded:`No se pudo conectar con la impresora. Verifique la IP, el número de serie y el código de acceso, y confirme que el modo solo LAN está activado. La impresora no se añadió.`,failedToUpdate:`Error al actualizar la impresora`,commandSent:`Comando enviado`,failedToSendCommand:`Error al enviar el comando`,turnedOn:`{{name}} encendida`,failedToPowerOn:`Error al encender {{name}}`,scriptTriggered:`Script ejecutado`,printStopped:`Impresión detenida`,printPaused:`Impresión en pausa`,printResumed:`Impresión reanudada`,referenceDeleted:`Referencia eliminada`,detectionAreaSaved:`Área de detección guardada`,failedToRunScript:`Error al ejecutar el script`,failedToStopPrint:`Error al detener la impresión`,failedToPausePrint:`Error al pausar la impresión`,failedToResumePrint:`Error al reanudar la impresión`,failedToControlChamberLight:`Error al controlar la luz de la cámara`,failedToSetSpeed:`Error al establecer la velocidad de impresión`,failedToUpdateSetting:`Error al actualizar el ajuste`,failedToSkipObjects:`Error al omitir objetos`,failedToRereadRfid:`Error al releer el RFID`,failedToCheckPlate:`Error al comprobar la cama`,failedToUpdateLabel:`Error al actualizar la etiqueta`,failedToDeleteReference:`Error al eliminar la referencia`,failedToSaveDetectionArea:`Error al guardar el área de detección`,plateCheckEnabled:`Comprobación de cama activada`,plateCheckDisabled:`Comprobación de cama desactivada`,calibrationSaved:`¡Calibración guardada!`,calibrationFailed:`Error en la calibración`,rfidRereadInitiated:`Relectura de RFID iniciada`,loadInitiated:`Cargando filamento…`,unloadInitiated:`Descargando filamento…`,failedToLoad:`Error al cargar el filamento`,failedToUnload:`Error al descargar el filamento`},connection:{connected:`Conectada`,offline:`Desconectada`},plateStatus:{markCleared:`Marcar cama como despejada`,cleared:`Cama despejada`,notCleared:`Cama no despejada`,inUse:`Cama en uso`},queue:{inQueue:`{{count}} impresión en cola`,inQueue_plural:`{{count}} impresiones en cola`},controls:`Controles`,rfid:{reread:`Releer RFID`},ams:{load:`Cargar`,unload:`Descargar`},bedJog:{title:`Controles de movimiento`,bed:`Cama`,step:`Paso (mm)`,up:`Subir la cama`,down:`Bajar la cama`,disabledWhilePrinting:`Desactivado durante la impresión`,notHomedTitle:`La impresora no está en posición de origen`,notHomedMessage:`La impresora no se ha llevado a su posición de origen desde la última impresión. Ejecute el autoorigen primero para un posicionamiento seguro (estaciona el cabezal y luego lleva X, Y y Z al origen), o mueva de todos modos — los finales de carrera por software se omitirán.`,homeZ:`Autoorigen`,moveAnyway:`Mover de todos modos`,homingStarted:`Llevando la impresora al origen…`},permission:{noAdd:`No tiene permiso para añadir impresoras`,noEdit:`No tiene permiso para editar impresoras`,noDelete:`No tiene permiso para eliminar impresoras`,noControl:`No tiene permiso para controlar impresoras`,noFiles:`No tiene permiso para acceder a los archivos de la impresora`,noAmsRfid:`No tiene permiso para releer el RFID del AMS`,noSmartPlugControl:`No tiene permiso para controlar enchufes inteligentes`,noCamera:`No tiene permiso para ver las cámaras`},modal:{addTitle:`Añadir impresora`,editTitle:`Editar impresora`,myPrinter:`Mi impresora`,selectModel:`Seleccionar modelo...`,locationGroup:`Ubicación / Grupo (opcional)`,locationPlaceholder:`p. ej., Taller, Oficina, Sótano`,autoArchiveLabel:`Archivar automáticamente las impresiones completadas`,fromPrinterSettings:`Desde los ajustes de la impresora`,modelOptional:`Modelo (opcional)`,saveChanges:`Guardar cambios`},skipObjects:{tooltip:`Omitir objetos`,onlyWhilePrinting:`Omitir objetos (solo durante la impresión)`,requiresMultiple:`Omitir objetos (requiere 2 o más objetos)`,title:`Omitir objetos`,matchIdsInfo:`Haga coincidir los ID con la pantalla de su impresora`,printerShowsIds:`La pantalla de la impresora muestra los ID de los objetos en la cama de impresión`,skipSelected:`Omitir seleccionados`,skipping:`Omitiendo...`,noObjectsSelected:`No hay objetos seleccionados`,selectObjectsToSkip:`Seleccione los objetos que desea omitir de la impresión actual`,skipped:`omitidos`,objectsSkipped:`Objetos omitidos`,activeCount:`{{count}} activos`,waitForLayer:`Espere a la capa 2 o superior para omitir objetos (capa actual {{layer}})`,skip:`Omitir`,confirmTitle:`¿Omitir objeto?`,confirmMessage:`¿Está seguro de que desea omitir "{{name}}"? Esto no se puede deshacer.`},confirm:{deleteTitle:`Eliminar impresora`,deleteMessage:`¿Está seguro de que desea eliminar "{{name}}"? Esto eliminará todos los ajustes de conexión.`,deleteArchivesNote:`Todo el historial de impresión de esta impresora se eliminará permanentemente.`,keepArchivesNote:`El historial de impresión se conservará pero ya no estará asociado a esta impresora.`,stopTitle:`Detener impresión`,stopMessage:`¿Está seguro de que desea detener la impresión actual en "{{name}}"? Esto cancelará el trabajo de impresión.`,stopButton:`Detener impresión`,pauseTitle:`Pausar impresión`,pauseMessage:`¿Está seguro de que desea pausar la impresión actual en "{{name}}"?`,pauseButton:`Pausar impresión`,resumeTitle:`Reanudar impresión`,resumeMessage:`¿Está seguro de que desea reanudar la impresión en "{{name}}"?`,resumeButton:`Reanudar impresión`,powerOnTitle:`Encender impresora`,powerOnMessage:`¿Está seguro de que desea ENCENDER "{{name}}"?`,powerOnButton:`Encender`,powerOffTitle:`Apagar impresora`,powerOffMessage:`¿Está seguro de que desea APAGAR "{{name}}"?`,powerOffWarning:`ADVERTENCIA: ¡"{{name}}" está imprimiendo actualmente! ¿Está seguro de que desea APAGARLA? Esto interrumpirá la impresión y podría dañar la impresora.`,powerOffButton:`Apagar`,haToggleTitle:`Conmutar "{{name}}"`,haToggleMessage:`¿Conmutar la entidad de Home Assistant {{entity}}? Esto puede apagarla si está encendida actualmente.`,haToggleWarning:`ADVERTENCIA: ¡"{{name}}" está imprimiendo actualmente! Conmutar {{entity}} puede cortar la corriente e interrumpir la impresión. ¿Continuar?`,haToggleButton:`Conmutar`},bulk:{select:`Seleccionar`,selectAll:`Seleccionar todo`,selectByLocation:`Seleccionar por ubicación`,selected:`{{count}} seleccionadas`,actions:{stop:`Detener`,pause:`Pausar`,resume:`Reanudar`,clearPlate:`Despejar cama`,clearHMS:`Borrar notificaciones`},confirm:{stopTitle:`Detener {{count}} impresiones`,stopMessage:`Esto cancelará las impresiones activas en {{count}} impresora(s). Esta acción no se puede deshacer.`,stopButton:`Detener todo`,pauseTitle:`Pausar {{count}} impresiones`,pauseMessage:`Esto pausará las impresiones activas en {{count}} impresora(s).`,pauseButton:`Pausar todo`,clearPlateTitle:`Despejar {{count}} camas de impresión`,clearPlateMessage:`Esto despejará la cama de impresión en {{count}} impresora(s) y puede activar trabajos en cola.`,clearPlateButton:`Despejar todo`},success:`{{action}} completado en {{count}} impresora(s)`,partial:`{{succeeded}} con éxito, {{failed}} con error`,noneApplicable:`Ninguna de las impresoras seleccionadas está en el estado adecuado para esta acción`,selectByState:`Seleccionar por estado`},discovery:{title:`Detectar impresoras`,searching:`Buscando...`,scanning:`Escaneando...`,scanProgress:`Escaneando... {{scanned}}/{{total}}`,foundPrinters:`Se encontraron {{count}} impresora(s)`,noPrintersFound:`No se encontraron impresoras`,noPrintersFoundSubnet:`No se encontraron impresoras en la subred especificada.`,noPrintersFoundNetwork:`No se encontraron impresoras en la red.`,allConfigured:`Todas las impresoras detectadas ya están configuradas.`,alreadyAdded:`Ya añadida`,select:`Seleccionar`,manualEntry:`Entrada manual`,addFromCloud:`Añadir desde la nube`,subnetToScan:`Subred a escanear`,dockerNote:`Docker detectado. Introduzca la subred de su impresora en notación CIDR. Requiere network_mode: host en docker-compose.yml.`,scanSubnet:`Escanear subred en busca de impresoras`,discoverNetwork:`Detectar impresoras en la red`,scanningSubnet:`Escaneando la subred en busca de impresoras Bambu...`,scanningNetwork:`Escaneando la red...`,serialRequired:`Número de serie obligatorio`,unknown:`Desconocido`,failedToStart:`Error al iniciar la detección`,customSubnetOption:`Subred personalizada...`,customSubnetLabel:`Subred personalizada (CIDR)`,customSubnetNote:`Usa una subred personalizada si tu impresora está en una red distinta a la de este servidor. Los puertos FTP (990) y MQTT (8883) deben ser accesibles a través del límite de enrutamiento.`},drying:{start:`Iniciar secado`,stop:`Detener secado`,temperature:`Temperatura`,duration:`Duración`,hours:`horas`,timeRemaining:`{{time}} restante`,active:`Secando`,notSupported:`Secado no compatible`,powerRequired:`Conecte el adaptador de corriente del AMS para activar el secado`,startingDrying:`Iniciando el secado...`,stoppingDrying:`Deteniendo el secado...`,rotateTray:`Girar la bobina durante el secado`},amsBackup:{titleOn:`AMS Filament Backup está ACTIVADO. Haz clic para desactivar.`,titleOff:`AMS Filament Backup está DESACTIVADO. Haz clic para activar.`,titleUnknown:`Estado de AMS Filament Backup no disponible en esta impresora.`,toastEnabled:`AMS Filament Backup activado`,toastDisabled:`AMS Filament Backup desactivado`,modalTitle:`AMS Filament Backup`,modalHelp:`Cuando el slot activo se agota, la impresora rota a slots con el mismo preset y color en este orden.`,modalNoSlots:`Sin filamento cargado.`,modalNoPairs:`No hay pares de respaldo — no hay dos slots que compartan preset y color.`,extruderRightShort:`D`,extruderLeftShort:`I`,stateOn:`Activado`,stateOff:`Desactivado`,stateUnknown:`No compatible con esta impresora`},activeJobSlot:{title:`Este slot es el filamento {{n}} en la impresión activa`,ariaLabel:`Slot de impresión activa {{n}}`},filaments:`Filamentos`,openCameraOverlay:`Abrir la cámara superpuesta`,openCameraWindow:`Abrir la cámara en una ventana nueva`,firmwareUpdateAvailable:`Actualización de firmware disponible: {{current}} → {{latest}}`,firmwareUpToDate:`Firmware {{version}} — Actualizado`,firmwareUpdateButton:`Actualizar`,plateDetection:{noPermission:`No tiene permiso para actualizar impresoras`,enabledClick:`Comprobación de cama activada - Haga clic para desactivar`,disabledClick:`Comprobación de cama desactivada - Haga clic para activar`,manageCalibration:`Gestionar la calibración de detección de cama`,calibrationRequired:`Calibración necesaria`,calibrationInstructions:`Asegúrese de que la cama de impresión esté completamente vacía y luego haga clic en Calibrar.`,calibrationDescription:`La calibración captura una imagen de referencia de la cama vacía. Las comprobaciones futuras se compararán con esta referencia para detectar objetos.`,calibrationTip:`Consejo: puede almacenar hasta 5 calibraciones para distintas camas. El sistema usa automáticamente la mejor coincidencia al comprobar.`,plateEmpty:`La cama parece estar vacía`,objectsDetected:`Objetos detectados en la cama`,confidence:`Confianza`,difference:`Diferencia`,analysisPreview:`Vista previa del análisis:`,analysisLegend:`Recuadro verde = área de detección, Superposición roja = diferencias respecto a la calibración`,savedReferences:`Referencias guardadas ({{count}}/{{max}})`,deleteReference:`Eliminar referencia`,labelPlaceholder:`Etiqueta...`,clickToEdit:`{{label}} - Haga clic para editar`,clickToAddLabel:`Haga clic para añadir una etiqueta`},speed:{title:`Velocidad de impresión`,silent:`Silencioso (50%)`,standard:`Estándar (100%)`,sport:`Sport (124%)`,ludicrous:`Ludicrous (166%)`},airduct:{title:`Modo de conducto de aire`,cooling:`Refrigeración`,heating:`Calentamiento`},noSdCard:`Sin SD`,door:{open:`Abierta`,closed:`Cerrada`},fans:{partCooling:`Ventilador de refrigeración de piezas`,auxiliary:`Ventilador auxiliar`,chamber:`Ventilador de la cámara`},clickToViewHmsErrors:`Haga clic para ver los errores HMS`,estimatedCompletion:`Hora estimada de finalización`,plateNumber:`Cama {{number}}`,slotOptions:`Opciones de la ranura`,amsPopup:{friendlyName:`Nombre del AMS`,friendlyNamePlaceholder:`p. ej. Nombre descriptivo del AMS`,serialNumber:`Número de serie`,firmwareVersion:`Firmware`,save:`Guardar`,clear:`Borrar`,noEditPermission:`No tiene permiso para renombrar unidades AMS`},firmwareModal:{title:`Actualización de firmware`,titleUpToDate:`Información del firmware`,currentVersion:`Actual:`,latestVersion:`Más reciente:`,releaseNotes:`Notas de la versión`,checkingPrereqs:`Comprobando los requisitos previos...`,sdCardReady:`Tarjeta SD lista. Haga clic abajo para subir el firmware.`,uploadedSuccess:`¡Firmware subido a la tarjeta SD!`,applyInstructions:`Para aplicar la actualización en su impresora:`,step1:`En la pantalla táctil de la impresora, vaya a Ajustes`,step2:`Navegue hasta Firmware`,step3:`Seleccione Actualizar desde tarjeta SD`,step4:`La actualización tardará entre 10 y 20 minutos`,done:`Hecho`,starting:`Iniciando...`,uploadFirmware:`Subir firmware`,uploadFailed:`Error al iniciar la subida: {{error}}`,uploadedToast:`¡Firmware subido! Inicie la actualización desde la pantalla de la impresora.`,availableVersions:`Versiones disponibles`,usable:`Utilizable`,unavailable:`No disponible`,installed:`Instalada`,newerBadge:`más reciente`,olderBadge:`más antigua`,currentBadge:`actual`},accessCodePlaceholder:`Dejar vacío para conservar el actual`,roi:{title:`Área de detección (ROI)`,xStart:`Inicio X`,yStart:`Inicio Y`,width:`Anchura`,height:`Altura`,instruction:`Ajuste el área de detección para centrarse en la cama de impresión. El recuadro verde de la vista previa muestra el área actual.`},developerModeWarning:`El modo desarrollador LAN no está activado en: {{names}}. Es posible que algunas funciones no funcionen.`,howToEnable:`Cómo activarlo`,incompatibleFile:`Este archivo se laminó para {{slicedFor}}, pero esta impresora es una {{printerModel}}`,dropNotPrintable:`Solo se pueden imprimir archivos .gcode y .gcode.3mf`,dropToPrint:`Suelte para imprimir`,cannotPrint:`Impresora ocupada`},archives:{title:`Archivos de impresión`,no3mfBanner:{title:`Algunas impresiones recientes no se pudieron archivar con miniaturas`,body:`El slicer no dejó el archivo .gcode.3mf en la tarjeta SD de la impresora, así que Bambuddy no pudo recuperar ni la miniatura ni los metadatos del slicer. Esto suele deberse a que "Almacenar archivos enviados en almacenamiento externo" está desactivado en el slicer (pestaña Dispositivo de Bambu Studio / OrcaSlicer).`,docsLink:`Ver paso 4 de instalación`,dismissLabel:`Descartar este aviso`},searchPlaceholder:`Buscar archivos...`,filterByPrinter:`Filtrar por impresora`,filterByStatus:`Filtrar por estado`,sortBy:`Ordenar por`,sortNewest:`Más recientes primero`,sortOldest:`Más antiguos primero`,sortName:`Nombre`,sortDuration:`Duración`,sortLargest:`Mayores primero`,sortSmallest:`Menores primero`,sortSize:`Tamaño`,noArchives:`No se encontraron archivos`,noArchivesSearch:`Ningún archivo coincide con su búsqueda`,originalPrintNotVisible:`La impresión original no está visible - pruebe a borrar los filtros`,noArchivesYet:`Aún no hay archivos`,prints:`impresiones`,pagination:{showing:`Mostrando`,to:`a`,of:`de`,show:`Mostrar`,page:`Página`,all:`Todos`},loadingArchives:`Cargando archivos...`,releaseToUpload:`Suelte para subir`,showAll:`Mostrar todos`,showFavoritesOnly:`Mostrar solo favoritos`,gridView:`Vista de cuadrícula`,listView:`Vista de lista`,calendarView:`Vista de calendario`,logView:`Registro de impresión`,manageTags:`Gestionar etiquetas`,showFailedPrints:`Mostrar impresiones fallidas`,hideFailedPrints:`Ocultar impresiones fallidas`,hideDuplicates:`Ocultar duplicados`,viewOriginalPrint:`Haga clic para ver la impresión original (n.º {{id}})`,printTime:`Tiempo de impresión`,filamentUsed:`Filamento usado`,cost:`Coste`,reprint:`Reimprimir`,preview:`Vista previa`,deleteArchive:`Eliminar archivo`,deleteConfirm:`¿Está seguro de que desea eliminar este archivo?`,favorite:`Favorito`,unfavorite:`Quitar de favoritos`,viewDetails:`Ver detalles`,status:{completed:`Completada`,failed:`Fallida`,stopped:`Detenida`},toast:{source3mfAttached:`3MF de origen adjuntado: {{filename}}`,failedUploadSource3mf:`Error al subir el 3MF de origen`,source3mfRemoved:`3MF de origen eliminado`,failedRemoveSource3mf:`Error al eliminar el 3MF de origen`,f3dAttached:`F3D adjuntado: {{filename}}`,failedUploadF3d:`Error al subir el F3D`,f3dRemoved:`F3D eliminado`,failedRemoveF3d:`Error al eliminar el F3D`,timelapseAttached:`Time-lapse adjuntado: {{filename}}`,timelapseAlreadyAttached:`El time-lapse ya está adjuntado`,noMatchingTimelapse:`No se encontró ningún time-lapse coincidente`,failedScanTimelapse:`Error al buscar el time-lapse`,failedAttachTimelapse:`Error al adjuntar el time-lapse`,timelapseRemoved:`Time-lapse eliminado`,failedRemoveTimelapse:`Error al eliminar el time-lapse`,timelapseUploaded:`Time-lapse subido: {{filename}}`,failedUploadTimelapse:`Error al subir el time-lapse`,archiveDeleted:`Archivo eliminado`,failedDeleteArchive:`Error al eliminar el archivo`,addedToFavorites:`Añadido a favoritos`,removedFromFavorites:`Quitado de favoritos`,projectUpdated:`Proyecto actualizado`,failedUpdateProject:`Error al actualizar el proyecto`,linkCopied:`Enlace copiado al portapapeles`,failedCopyLink:`Error al copiar el enlace`,photoDeleted:`Foto eliminada`,failedDeletePhoto:`Error al eliminar la foto`,failedDeleteArchives:`Error al eliminar los archivos`,failedUpdateFavorites:`Error al actualizar los favoritos`,exportDownloaded:`Exportación descargada`,exportFailed:`Error en la exportación`},menu:{print:`Imprimir`,schedule:`Programar`,openInBambuStudio:`Abrir en el laminador`,slice:`Laminar`,externalLink:`Enlace externo`,viewOnMakerWorld:`Ver en MakerWorld`,preview3d:`Vista previa 3D`,viewTimelapse:`Ver time-lapse`,scanForTimelapse:`Buscar time-lapse`,uploadTimelapse:`Subir time-lapse`,removeTimelapse:`Eliminar time-lapse`,downloadSource3mf:`Descargar 3MF de origen`,uploadSource3mf:`Subir 3MF de origen`,replaceSource3mf:`Reemplazar 3MF de origen`,removeSource3mf:`Eliminar 3MF de origen`,uploadF3d:`Subir F3D`,replaceF3d:`Reemplazar F3D`,downloadF3d:`Descargar F3D`,removeF3d:`Eliminar F3D`,download:`Descargar`,copyDownloadLink:`Copiar enlace de descarga`,qrCode:`Código QR`,viewPhotos:`Ver fotos`,viewPhotosCount:`Ver fotos ({{count}})`,projectPage:`Página del proyecto`,addToFavorites:`Añadir a favoritos`,removeFromFavorites:`Quitar de favoritos`,edit:`Editar`,printLog:`Registro de impresión`,goToProject:`Ir al proyecto: {{name}}`,addToProject:`Añadir al proyecto`,removeFromProject:`Quitar del proyecto`,loading:`Cargando...`,noProjectsAvailable:`No hay proyectos disponibles`,searchProjects:`Buscar proyectos…`,select:`Seleccionar`,deselect:`Deseleccionar`,delete:`Eliminar`},permission:{noReprint:`No tiene permiso para reimprimir este archivo`,noAddToQueue:`No tiene permiso para añadir a la cola`,noUpdateArchives:`No tiene permiso para actualizar archivos`,noUploadFiles:`No tiene permiso para subir archivos`,noDownload:`No tiene permiso para descargar archivos`,noCopyLink:`No tiene permiso para copiar enlaces de descarga`,noDelete:`No tiene permiso para eliminar este archivo`,noEdit:`No tiene permiso para editar esta entrada`,noCreate:`No tiene permiso para crear archivos`},platePicker:{title:`Seleccione la cama para la vista previa`,hint:`Este archivo tiene varias camas. Elija una para abrirla en el visor de G-code.`,plateLabel:`Cama {{index}}`,objectCount:`{{count}} objeto`,objectCount_plural:`{{count}} objetos`,noGcode:`Este archivo no tiene G-code laminado para previsualizar. Ábralo en Bambu Studio para laminarlo primero.`},card:{previousPlate:`Cama anterior`,nextPlate:`Cama siguiente`,plateNumber:`Cama {{index}}`,moreOptions:`Haga clic con el botón derecho para más opciones`,addToFavorites:`Añadir a favoritos`,removeFromFavorites:`Quitar de favoritos`,cancelled:`cancelada`,failed:`fallida`,duplicate:`duplicado`,duplicateTitle:`Este modelo ya se ha impreso anteriormente`,openSource3mf:`Abrir el 3MF de origen en Bambu Studio (clic derecho para más opciones)`,downloadF3d:`Descargar el archivo de diseño de Fusion 360`,viewTimelapse:`Ver time-lapse`,viewPhoto:`Ver 1 foto`,viewPhotos:`Ver {{count}} fotos`,openFolder:`Abrir carpeta: {{name}}`,slicedFile:`Archivo laminado - listo para imprimir`,sourceFile:`Solo archivo de origen - no hay mapeo de AMS disponible`,gcode:`GCODE`,source:`ORIGEN`,project:`Proyecto: {{name}}`,runsBadge:`{{count}} impresiones`,runsBadgeTitle:`{{count}} impresiones en total — {{successful}} con éxito, {{failed}} fallidas. Haga clic para ver el registro completo de impresión.`,estimated:`Estimado: {{time}}`,actual:`Real: {{time}}`,accuracy:`Precisión: {{percent}}%`,filament:`{{weight}} g`,layer:`{{count}} capa`,layers:`{{count}} capas`,object:`{{count}} objeto`,objects:`{{count}} objetos`,slicedFor:`Laminado para {{model}}`,uploadedBy:`Subido por`,noPermissionReprint:`No tiene permiso para reimprimir`,noFileForReprint:`No hay archivo 3MF disponible — no se pudo descargar el archivo de la impresora cuando se registró la impresión`,noPermissionEdit:`No tiene permiso para editar archivos`,noPermissionDelete:`No tiene permiso para eliminar archivos`,reprint:`Reimprimir`,schedulePrint:`Programar impresión`,schedule:`Programar`,openInBambuStudio:`Abrir en el laminador`,openInBambuStudioToSlice:`Abrir en el laminador para laminar`,slice:`Laminar`,externalLink:`Enlace externo`,makerWorld:`MakerWorld: {{designer}}`,viewProject:`Ver proyecto`,noExternalLink:`Sin enlace externo`,preview3d:`Vista previa 3D`,download:`Descargar`,edit:`Editar`,delete:`Eliminar`},runLog:{title:`Registro de impresión`,modalTitle:`Registro de impresión — {{name}}`,modalTitleFallback:`este archivo`,empty:`Aún no se han registrado eventos de impresión para este archivo.`,col:{date:`Fecha`,status:`Estado`,duration:`Duración`,filament:`Filamento`,cost:`Coste`},status:{completed:`Completada`,failed:`Fallida`,cancelled:`Cancelada`,stopped:`Detenida`,skipped:`Omitida`,printing:`Imprimiendo`}},modal:{deleteArchive:`Eliminar archivo`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"? Esta acción no se puede deshacer.`,deleteButton:`Eliminar`,deletePurgeStats:`Eliminar también esta impresión de las estadísticas rápidas (filamento, tiempo, coste, energía)`,deleteQueueItemsWarning:`También se eliminarán {{count}} elemento(s) de la cola vinculado(s) a este archivo.`,deleteBlockedByPrinting:`No se puede eliminar — {{count}} elemento(s) de la cola se están imprimiendo. Detén la impresión primero y vuelve a intentarlo.`,removeSource3mf:`Eliminar 3MF de origen`,removeSource3mfConfirm:`¿Está seguro de que desea eliminar el archivo 3MF de origen de "{{name}}"? Esto eliminará el archivo de proyecto original del laminador.`,removeButton:`Eliminar`,removeF3d:`Eliminar F3D`,removeF3dConfirm:`¿Está seguro de que desea eliminar el archivo de diseño de Fusion 360 de "{{name}}"?`,removeTimelapse:`Eliminar time-lapse`,removeTimelapseConfirm:`¿Está seguro de que desea eliminar el vídeo time-lapse de "{{name}}"?`,timelapse:`{{name}} - Time-lapse`,selectTimelapse:`Seleccionar time-lapse`,selectTimelapseDesc:`No se encontró ninguna coincidencia automática. Seleccione el time-lapse para esta impresión:`,deleteArchives:`Eliminar archivos`,deleteArchivesConfirm:`¿Está seguro de que desea eliminar {{count}} archivo(s)? Esta acción no se puede deshacer.`,deleteCount:`Eliminar {{count}}`},page:{title:`Archivos`,printsCount:`{{filtered}} de {{total}} impresiones`,dropFilesHere:`Suelte aquí los archivos .3mf`,releaseToUpload:`Suelte para subir`,only3mfSupported:`Solo se admiten archivos .3mf`,close:`Cerrar`,selected:`{{count}} seleccionados`,selectAll:`Seleccionar todo`,tags:`Etiquetas`,project:`Proyecto`,favorite:`Favorito`,delete:`Eliminar`,toggledFavorites:`Se cambió el estado de favorito de {{count}} archivo(s)`,failedUpdateFavorites:`Error al actualizar los favoritos`,archivesDeleted:`{{count}} archivo(s) eliminado(s)`,failedDeleteArchives:`Error al eliminar los archivos`,photoDeleted:`Foto eliminada`,failedDeletePhoto:`Error al eliminar la foto`},list:{name:`Nombre`,printer:`Impresora`,date:`Fecha`,size:`Tamaño`,actions:`Acciones`,hasTimelapse:`Tiene time-lapse`},log:{date:`Fecha`,printName:`Nombre de la impresión`,printer:`Impresora`,user:`Usuario`,status:`Estado`,duration:`Duración`,filament:`Filamento`,allPrinters:`Todas las impresoras`,allUsers:`Todos los usuarios`,allStatuses:`Todos los estados`,cancelled:`Cancelada`,skipped:`Omitida`,dateFrom:`Desde`,dateTo:`Hasta`,noEntries:`No se encontraron entradas en el registro de impresión`,showing:`Mostrando {{count}} de {{total}} entradas`,rowsPerPage:`Filas`,page:`Página`,prev:`Anterior`,next:`Siguiente`,clearLog:`Borrar registro`,clearLogTitle:`Borrar el registro de impresión`,clearLogConfirm:`Todas las entradas del registro de impresión se eliminarán permanentemente. Los archivos y los elementos de la cola no se ven afectados. Esta acción no se puede deshacer. ¿Está seguro?`,clearLogButton:`Borrar todo`,cleared:`{{count}} entradas del registro borradas`,clearFailed:`Error al borrar el registro de impresión`,deleteEntryTitle:`Eliminar entrada del registro de impresión`,deleteEntryConfirm:`Esta entrada se eliminará del registro y sus contribuciones de filamento, tiempo y costo desaparecerán de las estadísticas rápidas. El archivo correspondiente (si lo hay) no se ve afectado. Esta acción no se puede deshacer.`,entryDeleted:`Entrada del registro de impresión eliminada`,entryDeleteFailed:`Error al eliminar la entrada del registro de impresión`,editEntryTitle:`Editar entrada del registro de impresión`,editEntryDescription:`Clasifica esta impresión. El widget de Análisis de fallos agrupa por estos valores, por lo que las actualizaciones se reflejan en las estadísticas de inmediato.`,entryUpdated:`Entrada del registro actualizada`,entryUpdateFailed:`No se pudo actualizar la entrada del registro`,statuses:{completed:`Completada`,failed:`Fallida`,stopped:`Detenida`,cancelled:`Cancelada`,skipped:`Omitida`}}},queue:{filamentShort:{rowBadge:`Filamento insuficiente para la bobina asignada`,rowTooltip:`El planificador marco este elemento. Pulsa Reproducir para ver el deficit por slot y decidir si imprimir de todos modos.`,confirmTitle:`Filamento insuficiente`,confirmIntro:`La bobina asignada no puede cubrir al menos un slot. Imprimir de todos modos?`,lineItem:`Slot {{slot}}: necesita {{required}} g, quedan {{remaining}} g`,unknown:`desconocido`,printAnyway:`Imprimir de todos modos`},title:`Cola de impresión`,subtitle:`Programe y gestione sus trabajos de impresión`,addToQueue:`Añadir a la cola`,print:`Imprimir`,reprint:`Reimprimir`,schedulePrint:`Programar impresión`,editQueueItem:`Editar elemento de la cola`,printToPrinters:`Imprimir en {{count}} impresoras`,queueToPrinters:`Encolar en {{count}} impresoras`,queueSelectedPlates:`Encolar {{count}} camas`,selectAllPlates:`Seleccionar las {{count}} camas`,deselectAll:`Deseleccionar todo`,printQueued:`Impresión encolada`,itemsQueued:`{{count}} elementos encolados`,sending:`Enviando...`,sendingProgress:`Enviando {{current}}/{{total}}...`,adding:`Añadiendo...`,addingProgress:`Añadiendo {{current}}/{{total}}...`,savingProgress:`Guardando {{current}}/{{total}}...`,clearQueue:`Vaciar la cola`,clearHistory:`Borrar el historial`,emptyQueue:`La cola está vacía`,position:`Posición`,scheduledTime:`Hora programada`,moveUp:`Subir`,moveDown:`Bajar`,startNow:`Iniciar ahora`,printingInProgress:`Impresión en curso...`,viewArchive:`Ver archivo`,viewInFileManager:`Ver en el gestor de archivos`,itemCount:`{{count}} elemento`,itemCount_plural:`{{count}} elementos`,dragToReorder:`Arrastre para reordenar (solo elementos «lo antes posible»)`,reorderHint:`La posición solo afecta a los elementos «lo antes posible». Los elementos programados se ejecutan a su hora establecida.`,sjf:{label:`SJF`,tooltip:`Trabajo más corto primero — el planificador prioriza las impresiones más cortas`},addedBy:`Añadido por {{name}}`,nextInQueue:`Siguiente en la cola`,clearPlateSuccess:`Cama despejada — lista para la próxima impresión`,plateNumber:`Cama {{index}}`,quantity:`Cantidad`,quantityHint:`Crea {{count}} elementos en la cola`,activeBatches:`Lotes activos`,batchProgress:`{{completed}} de {{total}} completados`,cancelBatch:`Cancelar los restantes`,batchCancelled:`Elementos restantes del lote cancelados`,cancelBatchConfirmTitle:`Cancelar lote`,cancelBatchConfirmMessage:`¿Cancelar todos los elementos pendientes restantes de este lote?`,batch:{defaultName:`Lote`,label:`{{count}} elemento`,label_plural:`{{count}} elementos`,pendingCount:`{{count}} pendiente`,pendingCount_plural:`{{count}} pendientes`,expand:`Expandir lote`,collapse:`Contraer lote`,groupAsBatch:`Agrupar como lote…`,groupAsBatchDescription:`Combinar los {{count}} elementos seleccionados en un único lote contraíble.`,nameLabel:`Nombre del lote`,namePlaceholder:`p. ej., Regalos del viernes`,create:`Crear lote`,ungroup:`Desagrupar`,ungroupConfirmTitle:`¿Desagrupar lote?`,ungroupConfirmMessage:`Los elementos permanecerán en la cola pero ya no estarán agrupados.`,dragGroup:`Arrastrar grupo`},tabs:{queue:`Cola`,history:`Historial`,timeline:`Cronología`},layout:{flatList:`Lista`,byPrinter:`Por impresora`,groupByPrinter:`Agrupar por impresora`},history:{emptyTitle:`Sin historial todavía`,emptyDescription:`Las impresiones completadas, canceladas y fallidas aparecerán aquí.`},dragGhost:{multiCount:`{{count}} elementos`,batch:`{{name}} ({{count}} copia)`,batch_plural:`{{name}} ({{count}} copias)`},sections:{currentlyPrinting:`Imprimiendo actualmente`,queued:`En cola`,history:`Historial`},status:{pending:`Pendiente`,waiting:`En espera`,printing:`Imprimiendo`,paused:`En pausa`,completed:`Completada`,failed:`Fallida`,skipped:`Omitida`,cancelled:`Cancelada`},summary:{printing:`Imprimiendo`,queued:`En cola`,totalTime:`Tiempo total de la cola`,totalWeight:`Peso total de la cola`,history:`Historial`},filter:{allPrinters:`Todas las impresoras`,unassigned:`Sin asignar`,allStatus:`Todos los estados`,allLocations:`Todas las ubicaciones`,any:`Cualquiera`},sort:{byPosition:`Ordenar por posición`,byName:`Ordenar por nombre`,byPrinter:`Ordenar por impresora`,bySchedule:`Ordenar por programación`,byDate:`Ordenar por fecha`,ascendingOldest:`Ascendente (más antiguos primero)`,descendingNewest:`Descendente (más recientes primero)`},badges:{staged:`Preparado`,requiresPrevious:`Requiere éxito previo`,autoPowerOff:`Apagado automático`,gcodeInjection:`G-code`},empty:{title:`No hay impresiones programadas`,description:`Programe una impresión desde la página de Archivos con la opción «Programar» del menú contextual, o arrastre y suelte archivos para empezar.`},time:{asap:`Lo antes posible`,overdue:`Atrasada`,now:`Ahora`,lessThanMinute:`En menos de un minuto`,inMinutes:`En {{count}} min`,inHours:`En {{count}} horas`},actions:{stopPrint:`Detener impresión`,startPrint:`Iniciar impresión`,requeue:`Volver a encolar`},bulkEdit:{title:`Editar {{count}} elemento`,title_plural:`Editar {{count}} elementos`,description:`Solo se aplicarán los ajustes modificados a los elementos seleccionados.`,printer:`Impresora`,noChange:`— Sin cambios —`,queueOptions:`Opciones de la cola`,staged:`Preparado (inicio manual)`,autoPowerOff:`Apagado automático tras la impresión`,requirePrevious:`Requerir éxito previo`,printOptions:`Opciones de impresión`,bedLevelling:`Nivelación de la cama`,flowCalibration:`Calibración del flujo`,vibrationCalibration:`Calibración de vibración`,layerInspection:`Inspección de la primera capa`,timelapse:`Time-lapse`,useAms:`Usar AMS`,nozzleOffsetCali:`Calibración del offset de boquillas`,applyChanges:`Aplicar cambios`,selectAll:`Seleccionar todo`,deselectAll:`Deseleccionar todo`,selected:`{{count}} seleccionados`,editSelected:`Editar seleccionados`,cancelSelected:`Cancelar seleccionados`},confirm:{cancelTitle:`Cancelar impresión programada`,cancelMessage:`¿Está seguro de que desea cancelar "{{name}}"?`,stopTitle:`Detener impresión`,stopMessage:`¿Está seguro de que desea detener la impresión actual "{{name}}"? Esto cancelará el trabajo de impresión en la impresora.`,removeTitle:`Quitar del historial`,removeMessage:`¿Está seguro de que desea quitar "{{name}}" del historial de la cola?`,clearHistoryTitle:`Borrar el historial`,clearHistoryMessage:`¿Está seguro de que desea quitar los {{count}} elemento(s) del historial?`,cancelButton:`Cancelar impresión`,stopButton:`Detener impresión`,thisPrint:`esta impresión`,thisItem:`este elemento`},toast:{cancelled:`Elemento de la cola cancelado`,cancelFailed:`Error al cancelar el elemento`,removed:`Elemento de la cola eliminado`,removeFailed:`Error al eliminar el elemento`,stopped:`Impresión detenida`,stopFailed:`Error al detener la impresión`,released:`Impresión liberada a la cola`,startFailed:`Error al iniciar la impresión`,reorderFailed:`Error al reordenar la cola`,historyCleared:`Se borraron {{count}} elemento(s) del historial`,clearHistoryFailed:`Error al borrar el historial`,updateFailed:`Error al actualizar los elementos`,bulkCancelled:`Se cancelaron {{count}} elemento(s)`,bulkCancelFailed:`Error al cancelar los elementos`,batchCreated:`Lote "{{name}}" creado`,batchCreateFailed:`Error al crear el lote`,batchUngrouped:`{{count}} elemento(s) desagrupado(s)`,batchUngroupFailed:`Error al desagrupar el lote`,resumedAfterFailure:`Cola reanudada — {{restored}} trabajo(s) restaurado(s) a pendientes`,resumeAfterFailureFailed:`Error al reanudar la cola`},resumeAfterFailure:{banner:`{{printer}} está bloqueado por un fallo de impresión previo — {{count}} trabajo(s) omitido(s)`,bannerHint:`Soluciona el problema de la impresora y reanuda para restaurar los trabajos omitidos y limpiar el bloqueo.`,button:`Reanudar tras fallo`,confirmTitle:`¿Reanudar la cola tras el fallo?`,confirmMessage:`Restaurar {{count}} trabajo(s) omitido(s) en {{printer}} a pendientes y limpiar el bloqueo del trabajo anterior. Asegúrate de que la impresora esté lista antes de continuar.`},timeline:{listView:`Lista`,timelineView:`Cronología`,unassigned:`Sin asignar`,noData:`No hay impresiones programadas para este día`,nothingCommitted:`No hay programaciones comprometidas en esta ventana. Los elementos preparados, los elementos en espera y los trabajos ASAP en impresoras inactivas no se muestran — establece una hora programada o libera un elemento preparado para verlo aquí.`,allDoneBy:`Todas las impresiones estimadas para las {{time}}`,staged:`Preparado`,filterAll:`Mostrar todo`,filterPrinting:`Imprimiendo`,filterQueued:`En cola`,time:{anyMoment:`en cualquier momento`,minutesLeft:`{{minutes}} min restantes`,hoursLeft:`{{hours}} h restantes`,hoursMinutesLeft:`{{hours}} h {{minutes}} min restantes`},day:{previous:`Día anterior`,next:`Día siguiente`,today:`Hoy`},window:{back12h:`12 horas atrás`,forward12h:`12 horas adelante`,now:`Ahora`},printerColumnHeader:`Impresora`},permissions:{noStopPrint:`No tiene permiso para detener impresiones`,noStartPrint:`No tiene permiso para iniciar impresiones`,noEdit:`No tiene permiso para editar este elemento de la cola`,noCancel:`No tiene permiso para cancelar este elemento de la cola`,noRequeue:`No tiene permiso para volver a encolar elementos`,noRemove:`No tiene permiso para eliminar este elemento de la cola`,noClearHistory:`No tiene permiso para borrar todo el historial`,noEditItems:`No tiene permiso para editar elementos de la cola`,noCancelItems:`No tiene permiso para cancelar elementos de la cola`}},backgroundDispatch:{unknownFile:`Archivo desconocido`,unknownPrinter:`Impresora desconocida`,startingPrints:`Iniciando impresiones`,progressSummary:`{{complete}}/{{total}} completadas • Enviadas: {{dispatched}} • Procesando: {{processing}}`,expandDetails:`Expandir los detalles del envío`,collapseDetails:`Contraer los detalles del envío`,dismissToast:`Descartar la notificación de envío`,cancelDispatchJob:`Cancelar el trabajo de envío`,cancel:`Cancelar`,cancelling:`Cancelando…`,awaitingPrinter:`Esperando a la impresora…`,status:{dispatched:`Enviada`,processing:`Procesando`,completed:`Completada`,failed:`Fallida`,cancelled:`Cancelada`},toast:{cancellingUpload:`Cancelando la subida...`,cancelled:`Envío cancelado`,cancelFailed:`Error al cancelar el envío`,completeWithFailures:`Envío en segundo plano completado: {{completed}} con éxito, {{failed}} con error`,completeSuccess:`Envío en segundo plano completado: {{completed}} con éxito`,printStartedRemaining:`{{completed}} impresión(es) iniciada(s), enviando {{remaining}} más...`}},stats:{title:`Estadísticas`,subtitle:`Arrastre los widgets para reorganizarlos. Haga clic en el icono del ojo para ocultarlos.`,overview:`Resumen`,totalPrints:`Impresiones totales`,successRate:`Tasa de éxito`,totalPrintTime:`Tiempo total de impresión`,printTime:`Tiempo de impresión`,totalFilament:`Filamento total usado`,filamentUsed:`Filamento usado`,filamentCost:`Coste del filamento`,totalCost:`Coste total`,energyUsed:`Energía usada`,energyCost:`Coste de la energía`,energyWarmingUpTooltip:`El seguimiento de energía aún está recopilando instantáneas horarias. Los totales por rango de fechas serán precisos una vez que exista al menos una instantánea antes del rango seleccionado. Los valores iniciales pueden quedarse cortos.`,averagePrintTime:`Tiempo medio de impresión`,printsPerDay:`Impresiones por día`,byPrinter:`Por impresora`,printsByPrinter:`Impresiones por impresora`,byMaterial:`Por material`,byMonth:`Por mes`,last7Days:`Últimos 7 días`,last30Days:`Últimos 30 días`,last90Days:`Últimos 90 días`,allTime:`Todo el tiempo`,quickStats:`Estadísticas rápidas`,printActivity:`Actividad de impresión`,filamentTypes:`Tipos de filamento`,filamentTrends:`Tendencias del filamento`,failureAnalysis:`Análisis de fallos`,timeAccuracy:`Precisión temporal`,successful:`Con éxito:`,failed:`Fallidas:`,cancelled:`Canceladas:`,perfectEstimate:`100% = estimación perfecta`,noTimeAccuracyData:`Aún no hay datos de precisión temporal`,noFilamentData:`No hay datos de filamento disponibles`,noPrinterData:`No hay datos de impresora disponibles`,noPrintData:`No hay datos de impresión disponibles`,noPrintDataLast30Days:`No hay datos de impresión en los últimos 30 días`,failureReasons:`Motivos de fallo`,topFailureReasons:`Principales motivos de fallo`,failedPrintsCount:`{{failed}} / {{total}} impresiones fallidas`,lastWeekRate:`Semana pasada: {{rate}}%`,resetLayout:`Restablecer disposición`,recalculateCosts:`Recalcular costes`,recalculateCostsHint:`Recalcular todos los costes de archivo usando los precios actuales del filamento`,exportStats:`Exportar estadísticas`,exportAsCsv:`Exportar como CSV`,exportAsExcel:`Exportar como Excel`,hiddenCount:`{{count}} ocultos`,exportDownloaded:`Exportación descargada`,exportFailed:`Error en la exportación`,layoutReset:`Disposición restablecida`,recalculatedCosts:`Costes recalculados para {{count}} archivos`,recalculateFailed:`Error al recalcular los costes`,loadingStats:`Cargando estadísticas...`,noPermissionResetLayout:`No tiene permiso para restablecer la disposición`,noPermissionRecalculate:`No tiene permiso para recalcular los costes`,noPrintDataInRange:`No hay datos de impresión en el rango seleccionado`,periodFilament:`Filamento del periodo`,periodCost:`Coste del periodo`,avgPerPrint:`Promedio por impresión`,usageOverTime:`Uso a lo largo del tiempo`,filamentByWeight:`Peso`,printDuration:`Duración de la impresión`,printerUtilization:`Uso de la impresora`,filamentSuccess:`Éxito por material`,printHabits:`Hábitos de impresión`,printTimeOfDay:`Hora del día de impresión`,colorDistribution:`Distribución de colores`,noColorData:`No hay datos de color disponibles`,records:`Récords`,longestPrint:`Impresión más larga`,heaviestPrint:`Impresión más pesada`,mostExpensivePrint:`Más cara`,busiestDay:`Día más activo`,successStreak:`Racha de éxitos`,streakPrint:`impresión consecutiva`,streakPrints:`{{count}} impresiones consecutivas`,printerStats:`Estadísticas de la impresora`,hours:`horas`,avgPrints:`Impresiones medias`,noArchiveData:`No hay datos de impresión disponibles`,filamentByTime:`Tiempo`,avgWeight:`Peso medio`,avgTime:`Tiempo medio`,filamentByPrints:`Impresiones`,timeframe:{today:`Hoy`,"this-week":`Esta semana`,"this-month":`Este mes`,"last-7":`Últimos 7 días`,"last-30":`Últimos 30 días`,"last-90":`Últimos 90 días`,"this-year":`Este año`,"all-time":`Todo el tiempo`,custom:`Rango personalizado`,from:`Desde`,to:`Hasta`},allUsers:`Todos los usuarios`,noUser:`Sin usuario (sistema)`,filterByUser:`Filtrar por usuario`},maintenance:{title:`Mantenimiento`,overview:`Resumen`,allOk:`Todo el mantenimiento al día`,dueCount:`{{count}} tarea pendiente`,dueCount_plural:`{{count}} tareas pendientes`,warningCount:`{{count}} advertencia`,warningCount_plural:`{{count}} advertencias`,totalPrintTime:`Tiempo total de impresión`,nextMaintenance:`Próximo mantenimiento`,nothingDue:`Nada pendiente`,tasks:`Tareas`,lastPerformed:`Realizado por última vez`,interval:`Intervalo`,hoursRemaining:`{{hours}} h restantes`,hoursOverdue:`{{hours}} h de retraso`,markDone:`Marcar como hecho`,performMaintenance:`Realizar mantenimiento`,history:`Historial`,noHistory:`No hay historial de mantenimiento`,editPrintHours:`Editar horas de impresión`,currentHours:`Horas actuales`,statusTab:`Estado`,settingsTab:`Ajustes`,overdueCount:`{{count}} atrasadas`,dueSoonCount:`{{count}} pronto pendientes`,dueSoon:`Pronto pendiente`,allGood:`Todo correcto`,overdueBy:`Atrasado {{duration}}`,dueIn:`Pendiente en {{duration}}`,timeLeft:`{{duration}} restante`,day:`1 día`,days:`{{count}} días`,week:`1 semana`,weeks:`{{count}} semanas`,month:`1 mes`,months:`{{count}} meses`,year:`1 año`,maintenanceTypes:`Tipos de mantenimiento`,maintenanceTypesDescription:`Tipos del sistema y sus tareas de mantenimiento personalizadas`,addCustomType:`Añadir tipo personalizado`,restoreDefaults:`Restaurar tareas predeterminadas`,intervalType:`Tipo de intervalo`,intervalValue:`Intervalo ({{type}})`,icon:`Icono`,documentationLink:`Enlace de documentación (opcional)`,assignToPrinters:`Asignar a impresoras`,selectAtLeastOnePrinter:`Seleccione al menos una impresora`,addType:`Añadir tipo`,custom:`Personalizado`,printHours:`Horas de impresión`,calendarDays:`Días naturales`,exampleName:`p. ej., Reemplazar filtro HEPA`,viewDocumentation:`Ver documentación`,timeBasedInterval:`Intervalo basado en el tiempo`,intervalOverrides:`Anulaciones de intervalo`,intervalOverridesDescription:`Personalizar intervalos para impresoras concretas`,assignedToPrinters:`Asignado a las impresoras:`,noPrintersAssigned:`No hay impresoras asignadas`,addPrinterShort:`Añadir:`,printersAssignedClick:`{{count}} impresora(s) asignada(s) - haga clic para gestionar`,removeFromPrinter:`Quitar de esta impresora`,types:{lubricateCarbonRods:`Lubricar varillas de carbono`,lubricateRails:`Lubricar guías lineales`,cleanNozzle:`Limpiar boquilla/fusor`,checkBelts:`Comprobar la tensión de las correas`,cleanBuildPlate:`Limpiar la cama de impresión`,checkExtruder:`Comprobar los engranajes del extrusor`,checkCooling:`Comprobar los ventiladores de refrigeración`,generalInspection:`Inspección general`,cleanCarbonRods:`Limpiar varillas de carbono`,lubricateSteelRods:`Lubricar varillas de acero`,cleanSteelRods:`Limpiar varillas de acero`,cleanLinearRails:`Limpiar guías lineales`,checkPtfeTube:`Comprobar el tubo de PTFE`,replaceHepaFilter:`Reemplazar filtro HEPA`,replaceCarbonFilter:`Reemplazar filtro de carbono`,lubricateLeftNozzleRail:`Lubricar la guía de la boquilla izquierda`},maintenanceComplete:`Mantenimiento marcado como completado`,typeUpdated:`Tipo de mantenimiento actualizado`,typeDeleted:`Tipo de mantenimiento eliminado`,defaultsRestored:`Se restauraron {{count}} tarea(s) predeterminada(s)`,printHoursUpdated:`Horas de impresión actualizadas`,printerAssigned:`Impresora asignada`,printerRemoved:`Impresora eliminada`,deleteTypeConfirm:`¿Eliminar "{{name}}"?`,deleteSystemTypeTitle:`¿Eliminar la tarea de mantenimiento predeterminada?`,deleteSystemTypeMessage:`¿Está seguro de que desea eliminar la tarea de mantenimiento predeterminada "{{name}}"?`,noPermissionUpdate:`No tiene permiso para actualizar elementos de mantenimiento`,noPermissionPerform:`No tiene permiso para realizar mantenimiento`,noPermissionEditTypes:`No tiene permiso para editar tipos de mantenimiento`,noPermissionDeleteTypes:`No tiene permiso para eliminar tipos de mantenimiento`,noPermissionEditHours:`No tiene permiso para editar las horas de impresión`,noPermissionRemovePrinter:`No tiene permiso para quitar asignaciones de impresoras`,noPermissionAssignPrinter:`No tiene permiso para asignar impresoras`,noPermissionEditIntervals:`No tiene permiso para editar intervalos`,configureSettings:`Configurar tipos e intervalos de mantenimiento`},settings:{title:`Ajustes`,general:`General`,tabs:{general:`General`,smartPlugs:`Enchufes inteligentes`,notifications:`Notificaciones`,queue:`Flujo de trabajo`,filament:`Filamento`,network:`Red`,apiKeys:`Claves API`,virtualPrinter:`Impresora virtual`,spoolbuddy:`SpoolBuddy`,failureDetection:`Detección de fallos`,users:`Autenticación`,backup:`Copia de seguridad`,emailAuth:`Autenticación por correo`,ldap:`LDAP`,twoFa:`Autenticación de dos factores`,oidc:`SSO / OIDC`,security:`Seguridad`},spoolbuddy:{infoTitle:`Dispositivos SpoolBuddy`,infoBody:`Los quioscos SpoolBuddy se registran automáticamente mediante una señal de latido. Anule el registro de un dispositivo aquí si ya no está en uso o si quedó un duplicado obsoleto tras el fallo de un demonio.`,duplicatesTitle:`{{count}} dispositivos registrados`,duplicatesBody:`La interfaz del quiosco solo usa el primer dispositivo registrado. Si uno de estos es un duplicado obsoleto de un fallo, anule su registro — un dispositivo en línea se volverá a registrar en su próxima señal de latido.`,empty:`Aún no hay dispositivos SpoolBuddy registrados.`,online:`En línea`,offline:`Desconectado`,unregister:`Anular registro`,unregisterSuccess:`Registro del dispositivo anulado`,unregisterError:`Error al anular el registro del dispositivo`,confirmTitle:`¿Anular el registro del dispositivo SpoolBuddy?`,confirmBody:`Esto eliminará "{{hostname}}" ({{deviceId}}) de la base de datos. Si el dispositivo está en línea, se volverá a registrar en su próxima señal de latido.`,ipAddress:`Dirección IP`,firmware:`Firmware`,lastSeen:`Visto por última vez`,daemonUptime:`Tiempo de actividad del demonio`,systemUptime:`Tiempo de actividad del sistema`,never:`nunca`,nfc:`NFC`,scale:`Báscula`,cpuTemp:`Temp. de CPU`,cpuLoad:`Carga de CPU`,memory:`Memoria`,disk:`Disco`,update:`Actualizar`,updateConfirmTitle:`¿Actualizar el demonio de Spoolbuddy?`,updateConfirmBody:`¿Iniciar una actualización de software en "{{hostname}}"? El demonio se reiniciará una vez aplicada la actualización.`,restartBrowser:`Reiniciar navegador`,restartBrowserConfirmTitle:`¿Reiniciar el navegador del quiosco?`,restartBrowserConfirmBody:`¿Reiniciar el navegador del quiosco en "{{hostname}}"? La pantalla se quedará en negro brevemente.`,restartDaemon:`Reiniciar demonio`,restartDaemonConfirmTitle:`¿Reiniciar el demonio de Spoolbuddy?`,restartDaemonConfirmBody:`¿Reiniciar el demonio de Spoolbuddy en "{{hostname}}"? El dispositivo se desconectará durante unos segundos.`,reboot:`Reiniciar`,rebootConfirmTitle:`¿Reiniciar el dispositivo?`,rebootConfirmBody:`¿Reiniciar "{{hostname}}"? El dispositivo estará desconectado durante alrededor de un minuto.`,shutdown:`Apagar`,shutdownConfirmTitle:`¿Apagar el dispositivo?`,shutdownConfirmBody:`¿Apagar "{{hostname}}"? Necesitará acceso físico para volver a encenderlo.`,commandConfirm:`Confirmar`,commandQueued:`Comando encolado`,commandError:`Error al enviar el comando`},ldap:{title:`Autenticación LDAP`,enabledDesc:`La autenticación LDAP está activada`,disabledDesc:`La autenticación LDAP está desactivada`,disabledHint:`Configure y guarde los ajustes de LDAP a continuación y luego actívela.`,enabled:`Autenticación LDAP activada`,disabled:`Autenticación LDAP desactivada`,feature1:`Los usuarios pueden iniciar sesión con credenciales LDAP`,feature2:`La cuenta de administrador local permanece como alternativa`,feature3:`Los grupos LDAP se asignan a los grupos de Bambuddy al iniciar sesión`,serverConfig:`Configuración del servidor LDAP`,serverUrl:`URL del servidor`,serverUrlHint:`Use ldaps:// para SSL o ldap:// con StartTLS`,security:`Seguridad`,securityHint:`StartTLS actualiza una conexión sin cifrar a TLS. LDAPS usa TLS desde el principio.`,bindDn:`Bind DN (cuenta de servicio)`,bindPassword:`Contraseña de Bind`,searchBase:`DN base de búsqueda`,userFilter:`Filtro de búsqueda de usuarios`,userFilterHint:`{username} se sustituye por el nombre de usuario de inicio de sesión. Use (uid={username}) para OpenLDAP.`,advanced:`Avanzado`,autoProvision:`Aprovisionar usuarios automáticamente`,autoProvisionHint:`Crear automáticamente una cuenta de Bambuddy en el primer inicio de sesión LDAP`,defaultGroup:`Grupo predeterminado`,defaultGroupNone:`— Ninguno (sin alternativa) —`,defaultGroupHint:`Grupo alternativo asignado cuando un usuario LDAP se autentica pero no figura en ningún grupo LDAP asignado. Déjelo vacío para dejar a los usuarios sin asignar sin permisos.`,groupMapping:`Asignación de grupos (JSON)`,groupMappingHint:`Asignar los DN de grupos LDAP a los grupos de Bambuddy. Grupos disponibles: `,testConnection:`Probar conexión`,settingsSaved:`Ajustes de LDAP guardados`,errors:{serverRequired:`La URL del servidor LDAP es obligatoria`,searchBaseRequired:`El DN base de búsqueda es obligatorio`,enableAuthFirst:`Active primero la autenticación`,configureLdapFirst:`Guarde primero los ajustes de LDAP`}},email:{smtpSettings:`Configuración SMTP`,smtpHost:`Servidor SMTP`,smtpPort:`Puerto SMTP`,security:`Seguridad`,authentication:`Autenticación`,username:`Nombre de usuario`,password:`Contraseña`,fromEmail:`Correo del remitente`,fromName:`Nombre del remitente`,testConnection:`Probar conexión SMTP`,testRecipient:`Correo del destinatario de prueba`,sendTest:`Enviar correo de prueba`,sending:`Enviando...`,save:`Guardar ajustes`,saving:`Guardando...`,advancedAuth:`Autenticación avanzada`,advancedAuthEnabled:`La autenticación avanzada está activada`,advancedAuthEnabledDesc:`Las funciones de gestión de usuarios basadas en correo están activas. Los nuevos usuarios recibirán contraseñas autogeneradas por correo, y los usuarios podrán restablecer sus contraseñas mediante la función de contraseña olvidada.`,advancedAuthDisabled:`La autenticación avanzada está desactivada`,advancedAuthDisabledDesc:`Active la autenticación avanzada para habilitar las funciones basadas en correo para la gestión de usuarios.`,enable:`Activar`,disable:`Desactivar`,feature1:`Las contraseñas se autogeneran y se envían por correo a los nuevos usuarios`,feature2:`Los usuarios pueden iniciar sesión con el nombre de usuario o el correo`,feature3:`La función de contraseña olvidada está disponible`,feature4:`Los administradores pueden restablecer las contraseñas de los usuarios por correo`,errors:{requiredFields:`Rellene todos los campos obligatorios`,usernameRequired:`El nombre de usuario es obligatorio cuando la autenticación está activada`,enterTestEmail:`Introduzca una dirección de correo de prueba`,smtpServerAndEmail:`Rellene el servidor SMTP y el correo del remitente antes de probar`,usernamePasswordRequired:`El nombre de usuario y la contraseña son obligatorios cuando la autenticación está activada`,configureSmtpFirst:`Configure y pruebe primero los ajustes de SMTP`,enableAuthFirst:`Active primero la autenticación para usar las funciones basadas en correo.`},success:{settingsSaved:`Ajustes de SMTP guardados correctamente`},securityOptions:{starttls:`STARTTLS (puerto 587)`,ssl:`SSL/TLS (puerto 465)`,none:`Ninguna (puerto 25)`},authOptions:{enabled:`Activada`,disabled:`Desactivada`}},appearance:`Apariencia`,notifications:`Notificaciones`,smartPlugs:`Enchufes inteligentes`,spoolman:`Spoolman`,updates:`Actualizaciones`,language:`Idioma`,languageDescription:`Seleccione su idioma preferido`,theme:`Tema`,themeLight:`Claro`,themeDark:`Oscuro`,themeSystem:`Sistema`,defaultView:`Vista predeterminada`,defaultViewDescription:`Página que se muestra al abrir la aplicación`,checkForUpdates:`Buscar actualizaciones`,autoUpdate:`Actualización automática`,currentVersion:`Versión actual`,latestVersion:`Versión más reciente`,upToDate:`Está actualizado`,updateAvailable:`Actualización disponible`,notificationLanguage:`Idioma de las notificaciones`,notificationLanguageDescription:`Idioma de las notificaciones push`,bedCooledThreshold:`Umbral de cama enfriada`,bedCooledThresholdDescription:`Temperatura por debajo de la cual se considera que la cama se ha enfriado tras una impresión`,userNotificationsEnabled:`Notificaciones de usuario`,userNotificationsEnabledDescription:`Activa el menú de notificaciones de usuario y las notificaciones por correo de los eventos de los trabajos de impresión. Requiere autenticación avanzada.`,userNotificationsDisabledHint:`Active la autenticación avanzada para usar las notificaciones de usuario.`,notificationProviders:`Proveedores de notificaciones`,addProvider:`Añadir proveedor`,editProvider:`Editar proveedor`,providerType:`Tipo de proveedor`,testNotification:`Notificación de prueba`,testSuccess:`Notificación de prueba enviada correctamente`,testFailed:`Error al enviar la notificación de prueba`,quietHours:`Horas de silencio`,quietHoursDescription:`No molestar durante estas horas`,quietHoursStart:`Inicio`,quietHoursEnd:`Fin`,events:{title:`Eventos de notificación`,printStart:`Impresión iniciada`,printComplete:`Impresión completada`,printFailed:`Impresión fallida`,printStopped:`Impresión detenida`,printProgress:`Hitos de progreso`,printProgressDescription:`Notificar al 25%, 50% y 75%`,printerOffline:`Impresora desconectada`,printerError:`Error de la impresora`,filamentLow:`Filamento bajo`,maintenanceDue:`Mantenimiento pendiente`,maintenanceDueDescription:`Notificar cuando se necesite mantenimiento`},smartPlug:{title:`Enchufes inteligentes`,add:`Añadir enchufe inteligente`,edit:`Editar enchufe inteligente`,name:`Nombre`,ipAddress:`Dirección IP`,linkedPrinter:`Impresora vinculada`,autoOn:`Encendido automático`,autoOnDescription:`Encender cuando comienza la impresión`,autoOff:`Apagado automático`,autoOffDescription:`Apagar tras completar la impresión`,offDelay:`Retardo de apagado`,offDelayMinutes:`Minutos tras la impresión`,offDelayTemp:`Cuando la boquilla está por debajo de la temperatura`,currentState:`Estado actual`,turnOn:`Encender`,turnOff:`Apagar`},filamentTracking:`Seguimiento del filamento`,filamentTrackingDesc:`Elija cómo realizar el seguimiento de sus bobinas de filamento. Puede usar el inventario integrado o conectar un servidor Spoolman externo.`,autoAddUnknownRfid:`Añadir automáticamente bobinas RFID desconocidas`,autoAddUnknownRfidDesc:`Crea automáticamente una entrada de inventario cuando se detecta una bobina con una etiqueta RFID desconocida. Desactive si registra manualmente las nuevas bobinas con antelación para evitar duplicados.`,filamentChecks:`Comprobaciones de filamento`,disableFilamentWarnings:`Desactivar las advertencias de filamento`,disableFilamentWarningsDesc:`No mostrar advertencias sobre filamento insuficiente al imprimir o encolar`,preferLowestFilament:`Preferir el filamento con menos restante`,preferLowestFilamentDesc:`Cuando varias bobinas coincidan, usar la que tenga menos filamento restante`,preferLowestFilamentBackupNote:`Solo surte efecto cuando AMS Filament Backup está activado en la impresora — de lo contrario, la impresora no puede cambiar a una segunda bobina cuando la elegida se acabe.`,trackingModeBuiltIn:`Inventario integrado`,trackingModeBuiltInDesc:`Incluye coincidencia automática por RFID y seguimiento del uso`,trackingModeSpoolmanDesc:`Servidor externo de gestión de filamento`,builtInFeatureRfid:`Detecta automáticamente las bobinas RFID de Bambu Lab en el AMS`,builtInFeatureUsage:`Realiza el seguimiento del consumo de filamento por impresión`,builtInFeatureCatalog:`Gestione bobinas, colores y perfiles de factor K`,builtInFeatureThirdParty:`Las bobinas de terceros se pueden asignar a bobinas del inventario`,amsSyncButton:`Sincronizar pesos desde el AMS`,amsSyncTitle:`Sincronizar los pesos de las bobinas desde el AMS`,amsSyncMessage:`Esto sobrescribirá todos los pesos de las bobinas del inventario con los valores actuales de % restante del AMS de las impresoras conectadas. Use esto para recuperarse de datos de peso dañados. Las impresoras deben estar en línea.`,amsSyncing:`Sincronizando...`,amsSyncSuccess:`{{synced}} bobina(s) sincronizada(s), {{skipped}} omitida(s)`,amsSyncError:`Error al sincronizar los pesos desde el AMS`,spoolmanAmsSyncButton:`Sincronizar pesos de Spoolman desde el AMS`,spoolmanAmsSyncTitle:`Sincronizar los pesos de las bobinas de Spoolman desde el AMS`,spoolmanAmsSyncMessage:`Esto actualizará todos los pesos de las bobinas de Spoolman según los valores actuales de % restante del AMS de las impresoras conectadas. Las impresoras deben estar en línea.`,spoolmanAmsSyncing:`Sincronizando...`,spoolmanAmsSyncSuccess:`{{synced}} bobina(s) sincronizada(s), {{skipped}} omitida(s)`,spoolmanAmsSyncError:`Error al sincronizar los pesos de Spoolman desde el AMS`,spoolmanAmsSyncErrorUnreachable:`Error al sincronizar los pesos de Spoolman (Spoolman inaccesible)`,spoolmanAmsSyncErrorNotConfigured:`Error al sincronizar los pesos de Spoolman (Spoolman no configurado)`,spoolmanNotConfigured:`Spoolman no configurado`,spoolmanFilamentCatalogTitle:`Catálogo de filamentos de Spoolman`,spoolmanFilamentCatalogDesc:`Nombres de filamentos y pesos de tara de su instancia de Spoolman. El nombre y el peso de la bobina se pueden editar aquí; el resto de las propiedades se gestionan directamente en Spoolman.`,spoolmanUrl:`URL de Spoolman`,spoolmanUrlHint:`URL de su servidor Spoolman (p. ej., http://localhost:7912)`,spoolmanConnected:`Conectado`,spoolmanDisconnected:`Desconectado`,status:`Estado`,connect:`Conectar`,disconnect:`Desconectar`,howSyncWorks:`Cómo funciona la sincronización`,syncInfoRfidOnly:`Solo se sincronizan las bobinas oficiales de Bambu Lab con RFID`,syncInfoAutoCreate:`Las bobinas nuevas se crean automáticamente en Spoolman en la primera sincronización`,syncInfoThirdPartySkipped:`Las bobinas que no son de Bambu Lab (de terceros, rellenadas) se omiten`,linkingExistingSpools:`Vincular bobinas existentes`,linkingExistingSpoolsDesc:`Para vincular bobinas existentes de Spoolman a su AMS, pase el cursor sobre una ranura del AMS y haga clic en "Vincular a Spoolman".`,syncMode:`Modo de sincronización`,syncModeAuto:`Automática`,syncModeManual:`Solo manual`,syncModeAutoDesc:`Los datos del AMS se sincronizan automáticamente cuando se detectan cambios`,syncModeManualDesc:`Sincronizar solo cuando se active manualmente`,syncAmsData:`Sincronizar datos del AMS`,syncAmsDataDesc:`Sincronizar manualmente los datos del AMS de la impresora con Spoolman`,allPrinters:`Todas las impresoras`,noDefaultPrinter:`Sin predeterminada (preguntar cada vez)`,sidebarOrder:`Orden de la barra lateral`,saveThumbnails:`Guardar miniaturas`,captureFinishPhoto:`Capturar foto de finalización`,noPrintersConfigured:`No hay impresoras configuradas`,archiveMode:{always:`Crear siempre una entrada de archivo`,never:`No crear nunca una entrada de archivo`,ask:`Preguntar cada vez`},checkForUpdatesLabel:`Buscar actualizaciones`,checkPrinterFirmware:`Comprobar el firmware de la impresora`,includeBetaUpdates:`Incluir versiones beta`,includeBetaUpdatesDesc:`Notificar sobre versiones beta y preliminares al buscar actualizaciones`,enableRetry:`Activar reintentos`,homeAssistantDescription:`Controlar enchufes inteligentes mediante Home Assistant`,environmentManagedLabel:`(Gestionado por el entorno)`,autoEnabledViaEnv:`Activado automáticamente mediante variables de entorno`,urlFromEnvReadOnly:`Valor establecido por la variable de entorno HA_URL (solo lectura)`,tokenFromEnvReadOnly:`Valor establecido por la variable de entorno HA_TOKEN (solo lectura)`,mqttConnectedTo:`Conectado a`,prometheusDescription:`Exponer los datos de la impresora en formato Prometheus`,noSmartPlugsTitle:`No hay enchufes inteligentes configurados`,noSmartPlugsDescription:`Añada un enchufe inteligente basado en Tasmota para realizar el seguimiento del consumo de energía y automatizar el control de la alimentación.`,noProvidersTitle:`No hay proveedores configurados`,noProvidersDescription:`Añada un proveedor para recibir alertas.`,noTemplatesAvailable:`No hay plantillas disponibles. Reinicie el backend para cargar las plantillas predeterminadas.`,apiPermissionView:`Ver el estado de la impresora y la cola`,apiPermissionEdit:`Añadir y quitar elementos de la cola de impresión`,apiKeysEmptyTitle:`No hay claves API`,apiKeysEmptyDescription:`Cree una clave API para integrarse con servicios externos.`,noUsersFound:`No se encontraron usuarios`,noGroupsFound:`No se encontraron grupos`,noGroupsAvailable:`No hay grupos disponibles`,passwordsDoNotMatch:`Las contraseñas no coinciden`,systemGroupWarning:`Los nombres de los grupos del sistema no se pueden cambiar`,authDisabledTitle:`La autenticación está desactivada`,authDisabledFeature1:`Exigir inicio de sesión para acceder al sistema`,authDisabledFeature2:`Crear varios usuarios con permisos basados en grupos`,authDisabledFeature3:`Controlar el acceso con más de 50 permisos granulares`,userHasCreated:`Este usuario ha creado:`,userItemsQuestion:`¿Qué desea hacer con estos elementos?`,deleteUserConfirm:`¿Está seguro de que desea eliminar este usuario?`,actionCannotBeUndone:`Esta acción no se puede deshacer.`,addFirstSmartPlug:`Añada su primer enchufe inteligente`,providers:`Proveedores`,log:`Registro`,testAll:`Probar todo`,testResults:`Resultados de la prueba`,testPassedCount:`{{count}} superadas`,testFailedCount:`{{count}} fallidas`,messageTemplates:`Plantillas de mensajes`,messageTemplatesDescription:`Personalice los mensajes de notificación para cada evento.`,apiKeys:`Claves API`,apiKeysDescription:`Cree claves API para integraciones externas y webhooks.`,createKey:`Crear clave`,apiKeyCreated:`Clave API creada correctamente`,apiKeyCopyWarning:`¡Copie esta clave ahora; no se volverá a mostrar!`,useInApiBrowser:`Usar en el explorador de API`,apiKeyQrButton:`Código QR`,apiKeyQrTitle:`Escanea para configurar`,apiKeyQrCaption:`Escanea con tu app móvil para añadir este servidor y la clave API.`,apiKeyQrWarning:`Contiene tu clave API secreta: no la compartas ni hagas capturas donde otros puedan verla.`,createNewApiKey:`Crear nueva clave API`,keyName:`Nombre de la clave`,keyNamePlaceholder:`p. ej., Home Assistant, OctoPrint`,readStatus:`Leer estado`,readStatusDescription:`Ver el estado de la impresora y la cola`,manageQueue:`Gestionar la cola`,manageQueueDescription:`Añadir y quitar elementos de la cola de impresión`,controlPrinter:`Controlar la impresora`,controlPrinterDescription:`Pausar, reanudar y detener impresiones`,manageLibrary:`Gestionar biblioteca`,manageLibraryDescription:`Subir, renombrar y eliminar archivos de la biblioteca; importar modelos desde MakerWorld`,manageInventory:`Gestionar inventario`,manageInventoryDescription:`Crear, actualizar y eliminar bobinas y registros de inventario. Necesario para los quioscos SpoolBuddy (escaneo NFC, lecturas de balanza, comandos del sistema del quiosco).`,libraryBadge:`Biblioteca`,inventoryBadge:`Inventario`,cloudAccess:`Permitir el acceso a la nube`,cloudAccessDescription:`Leer los preajustes y filamentos de Bambu Cloud en su nombre. Requiere que haya iniciado sesión en Bambu Cloud.`,cloudBadge:`Nube`,updateEnergyCost:`Actualizar el precio de la electricidad`,updateEnergyCostDescription:`Permite que esta clave envíe por POST un nuevo precio de electricidad por kWh a /settings/electricity-price. Útil para las automatizaciones de tarifa dinámica de Home Assistant (Tibber, Octopus, etc.). Este es el único campo de ajustes que se puede escribir mediante una clave API.`,energyCostBadge:`Energía`,legacyKey:`Heredada`,legacyKeyTooltip:`Creada antes de la propiedad por usuario; vuelva a crearla para usar el acceso a la nube`,unnamedKey:`Clave sin nombre`,lastUsed:`Usada por última vez`,read:`Lectura`,control:`Control`,createFirstKey:`Cree su primera clave`,webhookEndpoints:`Puntos de conexión de webhook`,webhookApiKeyHint:`Use su clave API en la cabecera X-API-Key.`,webhook:{getAllStatus:`Obtener el estado de todas las impresoras`,getSpecificStatus:`Obtener el estado de una impresora concreta`,addToQueue:`Añadir a la cola de impresión`,pausePrint:`Pausar impresión`,resumePrint:`Reanudar impresión`,stopPrint:`Detener impresión`},apiBrowser:`Explorador de API`,apiBrowserDescription:`Explore y pruebe todos los puntos de conexión de API disponibles.`,apiKeyForTesting:`Clave API para pruebas`,apiKeyPlaceholder:`Pegue aquí su clave API para probar los puntos de conexión autenticados...`,apiKeyHint:`Esta clave se enviará como cabecera X-API-Key en las solicitudes.`,deleteApiKeyTitle:`Eliminar clave API`,deleteApiKeyMessage:`¿Está seguro de que desea eliminar esta clave API? Cualquier integración que use esta clave dejará de funcionar.`,deleteKey:`Eliminar clave`,amsDisplayThresholds:`Umbrales de visualización del AMS`,amsThresholdsDescription:`Configure los umbrales de color para los indicadores de humedad y temperatura del AMS.`,humidity:`Humedad`,goodGreen:`Buena (verde)`,fairOrange:`Aceptable (naranja)`,aboveFairBad:`Por encima del umbral aceptable se muestra en rojo (mala)`,fairAlsoDryingThreshold:`Este umbral también se usa para activar el secado automático cuando está habilitado`,temperature:`Temperatura`,goodBlue:`Buena (azul)`,aboveFairHot:`Por encima del umbral aceptable se muestra en rojo (caliente)`,historyRetention:`Retención del historial`,keepSensorHistory:`Conservar el historial del sensor durante`,historyRetentionDescription:`Los datos de humedad y temperatura más antiguos se eliminarán automáticamente`,defaultPrintOptions:`Opciones de impresión predeterminadas`,defaultPrintOptionsDescription:`Establezca valores predeterminados para las opciones de impresión al iniciar nuevas impresiones. Se pueden anular por impresión en el diálogo de impresión.`,defaultBedLevelling:`Nivelación de la cama`,defaultBedLevellingDesc:`Nivelar automáticamente la cama antes de imprimir`,defaultFlowCali:`Calibración del flujo`,defaultFlowCaliDesc:`Calibrar el flujo de extrusión`,defaultVibrationCali:`Calibración de vibración`,defaultVibrationCaliDesc:`Reducir los artefactos de resonancia`,defaultLayerInspect:`Inspección de la primera capa`,defaultLayerInspectDesc:`Inspección de la primera capa por IA`,defaultTimelapse:`Time-lapse`,defaultTimelapseDesc:`Grabar vídeo time-lapse`,defaultNozzleOffsetCali:`Calibración del offset de boquillas`,defaultNozzleOffsetCaliDesc:`Calibrar los desplazamientos entre boquillas`,tempFanPresetsTitle:`Predefinidos de temperatura y ventilador`,tempFanPresetsDescription:`Personalice los valores de selección rápida en las ventanas emergentes de temperatura y velocidad del ventilador de la tarjeta de impresora. El botón Apagar siempre se muestra.`,tempFanPresetsNozzle:`Temperatura de la boquilla`,tempFanPresetsBed:`Temperatura de la cama`,tempFanPresetsChamber:`Temperatura de la cámara`,tempFanPresetsFan:`Velocidad del ventilador`,tempFanPresetsReset:`Restablecer valores predeterminados`,staggeredStart:`Inicio escalonado`,staggeredStartDescription:`Tamaño de grupo e intervalo predeterminados al escalonar los inicios de lotes en varias impresoras. Se pueden anular por lote en la ventana de impresión.`,plateClear:`Confirmación de cama despejada`,requirePlateClear:`Requerir confirmación de cama despejada`,requirePlateClearDescription:`Cuando está activado, el planificador espera la confirmación de cama despejada por impresora antes de iniciar impresiones en cola en impresoras con trabajos finalizados. Desactivar esto también oculta la insignia de estado de la cama y el botón "Marcar cama como despejada" en las tarjetas de impresora.`,gcodeInjection:`Inyección de G-code`,gcodeInjectionDescription:`Configure G-code personalizado para inyectar al inicio o al final de las impresiones para sistemas de impresión automática como Farmloop, SwapMod, AutoClear y Printflow 3D. Los fragmentos se configuran por modelo de impresora y se aplican cuando se activa "Inyectar G-code" en un elemento de la cola.`,gcodeInjectionNoPrinters:`No se encontraron impresoras. Añada impresoras para configurar fragmentos de G-code.`,gcodeStartLabel:`G-code de inicio`,gcodeEndLabel:`G-code de fin`,gcodeStartPlaceholder:`G-code añadido antes de que comience la impresión...`,gcodeEndPlaceholder:`G-code añadido después de que termine la impresión...`,staggerGroupSize:`Tamaño de grupo`,staggerGroupSizeHelp:`Impresoras que se inician simultáneamente por grupo`,staggerInterval:`Intervalo (minutos)`,staggerIntervalHelp:`Retardo entre el inicio de cada grupo`,queueDrying:`Secado automático de la cola`,queueDryingDescription:`Secar automáticamente el filamento del AMS cuando la impresora está inactiva entre impresiones en cola. Usa el umbral de humedad de arriba para activar el secado.`,queueDryingEnabled:`Activar el secado automático`,queueDryingEnabledDescription:`Iniciar el secado del AMS automáticamente cuando la impresora está inactiva y la humedad supera el umbral`,queueDryingBlock:`Esperar a que termine el secado`,queueDryingBlockDescription:`Bloquear la cola de impresión hasta que termine el secado. Cuando está desactivado, las impresiones tienen prioridad sobre el secado.`,ambientDryingEnabled:`Secado ambiental`,ambientDryingEnabledDescription:`Secar automáticamente el filamento en impresoras inactivas cuando la humedad supera el umbral, incluso sin impresiones en cola.`,dryingPresets:`Preajustes de secado`,dryingPresetsDescription:`Temperatura y duración por tipo de filamento. El AMS 2 Pro usa temperaturas más bajas; el AMS-HT admite temperaturas más altas.`,dryingFilament:`Filamento`,humidityThresholds:`Umbrales de humedad`,humidityThresholdsDescription:`Disparador de humedad por tipo de filamento para autosecado y alarmas. Cargas mixtas en un AMS usan el umbral más bajo.`,humidityThresholdCol:`Umbral`,humidityThresholdDefault:`Predeterminado (tipos desconocidos)`,printModal:`Ventana de impresión`,expandCustomMapping:`Expandir el mapeo personalizado de forma predeterminada`,expandCustomMappingDescription:`Al imprimir en varias impresoras, mostrar el mapeo de AMS por impresora expandido`,authentication:`Autenticación`,authEnabledDescription:`Su instancia está protegida con autenticación de usuario`,authDisabledDescription:`Active para exigir el inicio de sesión y gestionar el acceso de los usuarios`,authDisabledMessage:`Active la autenticación para crear cuentas de usuario, gestionar permisos y proteger su instancia de Bambuddy.`,enableAuthentication:`Activar la autenticación`,currentUser:`Usuario actual`,changePassword:`Cambiar contraseña`,admin:`Administrador`,users:`Usuarios`,addUser:`Añadir usuario`,groups:`Grupos`,addGroup:`Añadir grupo`,system:`Sistema`,noDescription:`Sin descripción`,userCount:`{{count}} usuarios`,permissionCount:`{{count}} permisos`,createUser:`Crear usuario`,username:`Nombre de usuario`,enterUsername:`Introduzca el nombre de usuario`,password:`Contraseña`,enterPassword:`Introduzca la contraseña`,passwordRequirements:`Al menos 8 caracteres, con una mayúscula, una minúscula, un dígito y un carácter especial.`,confirmPassword:`Confirmar contraseña`,confirmPasswordPlaceholder:`Confirme la contraseña`,viewReleaseOnGitHub:`Ver la versión en GitHub`,turnAllPlugsOn:`Encender todos los enchufes`,turnAllPlugsOff:`Apagar todos los enchufes`,clearNotificationLogs:`Borrar los registros de notificaciones`,clearLogsMessage:`Esto eliminará permanentemente todos los registros de notificaciones de más de 30 días. Esta acción no se puede deshacer.`,clearLogs:`Borrar registros`,resetUiPreferences:`Restablecer las preferencias de la interfaz`,resetUiPreferencesMessage:`Esto restablecerá todas las preferencias de la interfaz a sus valores predeterminados: orden de la barra lateral, tema, disposición del panel, modos de vista y preferencias de ordenación. Sus impresoras, archivos y ajustes del servidor NO se verán afectados. La página se recargará tras el restablecimiento.`,resetPreferences:`Restablecer preferencias`,deleteGroupTitle:`Eliminar grupo`,deleteGroupMessage:`¿Está seguro de que desea eliminar este grupo? Los usuarios de este grupo perderán estos permisos.`,deleteGroup:`Eliminar grupo`,disableAuthenticationTitle:`Desactivar la autenticación`,disableAuthenticationMessage:`¿Está seguro de que desea desactivar la autenticación? Esto hará que su instancia de Bambuddy sea accesible sin iniciar sesión. Todos los usuarios permanecerán en la base de datos, pero la autenticación se desactivará.`,disableAuthentication:`Desactivar la autenticación`,configureBambuddy:`Configurar Bambuddy`,systemDefault:`Predeterminado del sistema`,archiveSettings:`Ajustes de archivado`,newWindow:`Ventana nueva`,embeddedOverlay:`Superposición integrada`,preferredSlicer:`Laminador preferido`,preferredSlicerDescription:`Laminador usado para el corte en la aplicación a través del sidecar de la API`,openInSlicerLabel:`Abrir en el laminador`,openInSlicerInherit:`Igual que el laminador de la API`,openInSlicerDescription:`Laminador de escritorio que usa el botón «Abrir en el laminador». Déjelo en «Igual que el laminador de la API» para heredar, o elija un laminador distinto para uso local.`,orcaslicerKnownIssuesWarning:`OrcaSlicer 2.3.2 / 2.4.0-dev tienen errores conocidos de la CLI que impiden laminar muchos 3MF creados con Bambu — consulte las incidencias del proyecto original #12426 (cierre inesperado en archivos multiextrusor pintados) y #13386 (rechazo por validación estricta del rango de parámetros). Se recomienda Bambu Studio hasta que lleguen las correcciones.`,useSlicerApi:`Usar la API del laminador`,useSlicerApiDescription:`Cuando está activado, las acciones de «Laminar» abren la ventana del laminador integrada en la aplicación y llaman al contenedor auxiliar de la API del laminador. Cuando está desactivado (predeterminado), delegan en el laminador de escritorio mediante un esquema de URI.`,slicerCard:`Laminador`,orcaslicerApiUrl:`OrcaSlicer sidecar URL`,bambuStudioApiUrl:`Bambu Studio sidecar URL`,slicerApiUrlDescription:`URL del contenedor auxiliar de la API del laminador. Déjelo en blanco para usar los valores predeterminados de las variables de entorno SLICER_API_URL / BAMBU_STUDIO_API_URL.`,slicerBundlesRemoved:{title:`Paquetes del laminador (eliminado)`,description:`Se eliminó la importación de paquetes de preajustes de impresora (.bbscfg). La exportación de paquetes de BambuStudio solo incluye preajustes personalizados, por lo que la importación nunca entregaba procesos / filamentos estándar y el laminado recurría a la configuración incrustada.`,alternatives:`Usa Importación de preajuste individual para personalizaciones, o sincroniza vía Bambu Cloud / Orca Cloud. Los preajustes estándar vienen del sidecar del laminador automáticamente.`,lookupOrder:`Orden de búsqueda de preajustes al laminar: 1) Importado (local), 2) Orca Cloud, 3) Bambu Cloud, 4) Estándar (sidecar de respaldo).`},externalCameras:`Cámaras externas`,costTracking:`Seguimiento de costes`,printsOnly:`Solo impresiones`,totalConsumption:`Consumo total`,dataManagement:`Gestión de datos`,storageUsage:`Uso del almacenamiento`,storageUsageDescription:`Desglose del uso de datos por categoría`,storageUsageTotal:`Total`,storageUsageErrors:`Errores`,storageUsageOtherBreakdown:`Otros (incluye recursos estáticos, scripts y archivos de configuración)`,storageUsageSystem:`Sistema`,storageUsageData:`Datos`,storageUsageUnavailable:`Información de uso del almacenamiento no disponible`,clearNotificationLogsDescription:`Eliminar los registros de notificaciones de más de 30 días`,resetUiPreferencesDescription:`Restablecer el orden de la barra lateral, el tema, los modos de vista y las preferencias de disposición. Las impresoras, los archivos y los ajustes no se ven afectados.`,enableHomeAssistant:`Activar Home Assistant`,enableMqtt:`Activar MQTT`,useTls:`Usar TLS`,enableMetricsEndpoint:`Activar el punto de conexión de métricas`,availableMetrics:`Métricas disponibles`,editUser:`Editar usuario`,deleteUserTitle:`Eliminar usuario`,groupName:`Nombre del grupo`,leaveEmptyForAnonymous:`Dejar vacío para anónimo`,leaveEmptyForNoAuth:`Dejar vacío para sin autenticación`,enterNewPassword:`Introduzca la nueva contraseña`,confirmNewPassword:`Confirme la nueva contraseña`,enterGroupName:`Introduzca el nombre del grupo`,enterDescriptionOptional:`Introduzca una descripción (opcional)`,enterCurrentPassword:`Introduzca la contraseña actual`,enterNewPasswordMin6:`Introduzca la nueva contraseña (mín. 6 caracteres)`,toast:{keyCopied:`Clave copiada al portapapeles`,copyFailed:`Error al copiar la clave`,keyAddedToBrowser:`Clave añadida al explorador de API`,clearLogsFailed:`Error al borrar los registros`,uiPreferencesReset:`Preferencias de la interfaz restablecidas. Actualizando...`,authDisabled:`Autenticación desactivada correctamente`,authDisableFailed:`Error al desactivar la autenticación`,apiKeyCreated:`Clave API creada`,apiKeyDeleted:`Clave API eliminada`,userCreated:`Usuario creado correctamente`,userUpdated:`Usuario actualizado correctamente`,userDeleted:`Usuario eliminado correctamente`,groupCreated:`Grupo creado correctamente`,groupUpdated:`Grupo actualizado correctamente`,groupDeleted:`Grupo eliminado correctamente`,fillRequiredFields:`Rellene todos los campos obligatorios`,passwordsDoNotMatch:`Las contraseñas no coinciden`,passwordTooShort:`La contraseña debe tener al menos 8 caracteres`,passwordNeedsUppercase:`La contraseña debe contener al menos una letra mayúscula`,passwordNeedsLowercase:`La contraseña debe contener al menos una letra minúscula`,passwordNeedsDigit:`La contraseña debe contener al menos un dígito`,passwordNeedsSpecial:`La contraseña debe contener al menos un carácter especial`,enterGroupName:`Introduzca un nombre de grupo`,settingsSaved:`Ajustes guardados`,noPermissionUpdate:`No tiene permiso para cambiar los ajustes`,cameraSettingsSaved:`Ajustes de la cámara guardados`,enterCameraUrl:`Introduzca una URL de cámara`,passwordChanged:`Contraseña cambiada correctamente`,connectionFailed:`Error de conexión`,testFailed:`La prueba falló`,cameraConnected:`Cámara conectada{{resolution}}`},testConnection:`Probar conexión`,catalog:{spoolCatalog:`Catálogo de bobinas`,spoolCatalogDescription:`Pesos de bobinas vacías por marca/tipo. Se usa para la búsqueda automática de peso al añadir bobinas.`,searchCatalog:`Buscar en el catálogo...`,addNewEntry:`Añadir nueva entrada`,namePlaceholder:`Nombre (p. ej., Bambu Lab - Plástico)`,weight:`Peso`,type:`Tipo`,default:`Predeterminado`,custom:`Personalizado`,noMatch:`Ninguna entrada coincide con su búsqueda`,empty:`No hay entradas en el catálogo`,deleteEntry:`Eliminar entrada`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"?`,resetCatalog:`Restablecer catálogo`,resetConfirm:`¿Restablecer el catálogo a los valores predeterminados? Esto eliminará todas las entradas personalizadas.`,loadFailed:`Error al cargar el catálogo de bobinas`,nameWeightRequired:`El nombre y el peso son obligatorios`,entryAdded:`Entrada añadida`,addFailed:`Error al añadir la entrada`,entryUpdated:`Entrada actualizada`,updateFailed:`Error al actualizar la entrada`,entryDeleted:`Entrada eliminada`,deleteFailed:`Error al eliminar la entrada`,resetSuccess:`Catálogo restablecido a los valores predeterminados`,resetFailed:`Error al restablecer el catálogo`,exported:`Se exportaron {{count}} entradas`,imported:`Se importaron {{added}} entradas ({{skipped}} omitidas)`,importFailed:`Error al importar: formato JSON no válido`,exportTooltip:`Exportar el catálogo a JSON`,importTooltip:`Importar el catálogo desde JSON`,resetTooltip:`Restablecer a los valores predeterminados`,selectedCount:`{{count}} seleccionadas`,deleteSelected:`Eliminar seleccionadas`,bulkDeleteConfirm:`¿Está seguro de que desea eliminar {{count}} entradas?`,bulkDeleted:`Se eliminaron {{count}} entradas`,bulkDeleteFailed:`Error al eliminar las entradas`,material:`Material`,spoolWeight:`Peso de la bobina`,color:`Color`,updateSpoolWeight:`Actualizar el peso de la bobina`,filamentUpdated:`Filamento actualizado`,filamentUpdateFailed:`Error al actualizar el filamento`,filamentUpdateInvalid:`Datos de filamento no válidos`,keepExistingSpoolWeight:`Conservar el peso anterior para las bobinas existentes`,keepExistingSpoolWeightDesc:`Las bobinas ya creadas con este tipo de filamento conservan el peso de tara anterior. Las bobinas nuevas usan el valor actualizado.`,applyToAllSpools:`Aplicar a todas las bobinas`,applyToAllSpoolsDesc:`Todos los cálculos de peso para este tipo de filamento usan inmediatamente el nuevo peso de tara.`},colorCatalog:{title:`Catálogo de colores`,description:`Colores de filamento por fabricante/material. Se usa para la búsqueda automática de color al añadir bobinas.`,searchColors:`Buscar colores...`,allManufacturers:`Todos los fabricantes`,addNewColor:`Añadir nuevo color`,manufacturer:`Fabricante`,colorName:`Nombre del color`,hex:`Hex`,materialOptional:`Material (opcional)`,showing:`Mostrando {{filtered}} de {{total}} colores`,noMatch:`Ningún color coincide con su búsqueda`,empty:`No hay colores en el catálogo`,deleteColor:`Eliminar color`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"?`,resetCatalog:`Restablecer el catálogo de colores`,resetConfirm:`¿Restablecer el catálogo a los valores predeterminados? Esto eliminará todos los colores personalizados.`,sync:`Sincronizar`,starting:`Iniciando...`,syncTooltip:`Sincronizar desde FilamentColors.xyz (más de 2000 colores, puede tardar un minuto)`,loadFailed:`Error al cargar el catálogo de colores`,fieldsRequired:`El fabricante, el nombre del color y el color hexadecimal son obligatorios`,colorAdded:`Color añadido`,addFailed:`Error al añadir el color`,colorUpdated:`Color actualizado`,updateFailed:`Error al actualizar el color`,colorDeleted:`Color eliminado`,deleteFailed:`Error al eliminar el color`,resetSuccess:`Catálogo de colores restablecido a los valores predeterminados`,resetFailed:`Error al restablecer el catálogo`,syncUpToDate:`Ya está actualizado ({{count}} colores comprobados)`,syncComplete:`Se añadieron {{added}} colores nuevos ({{skipped}} ya existían)`,syncError:`Error de sincronización`,syncFailed:`Error al sincronizar desde FilamentColors.xyz`,exported:`Se exportaron {{count}} colores`,imported:`Se importaron {{added}} colores ({{skipped}} omitidos)`,importFailed:`Error al importar: formato JSON no válido`,selectedCount:`{{count}} seleccionados`,deleteSelected:`Eliminar seleccionados`,bulkDeleteConfirm:`¿Está seguro de que desea eliminar {{count}} colores?`,bulkDeleted:`Se eliminaron {{count}} colores`,bulkDeleteFailed:`Error al eliminar los colores`},dateFormat:`Formato de fecha`,dateFormatUs:`EE. UU. (MM/DD/AAAA)`,dateFormatEu:`UE (DD/MM/AAAA)`,dateFormatIso:`ISO (AAAA-MM-DD)`,timeFormat:`Formato de hora`,timeFormat12:`12 horas (3:30 PM)`,timeFormat24:`24 horas (15:30)`,defaultPrinter:`Impresora predeterminada`,defaultPrinterDescription:`Preseleccione esta impresora para subidas, reimpresiones y otras operaciones.`,slicerBambuStudio:`Bambu Studio`,slicerOrcaSlicer:`OrcaSlicer`,sidebarOrderDescription:`Use Diseño de la barra lateral para reordenar elementos, restablecer la visibilidad y gestionar enlaces personalizados.`,setDefault:`Establecer como predeterminado`,sidebarOrderSetDefaultHint:`Establecer como predeterminado aplica el orden de menú actual a los usuarios que no han personalizado el suyo.`,sidebarDefaultSet:`Se ha establecido el orden de menú predeterminado.`,sidebarDefaultCleared:`Orden de menú predeterminado borrado.`,sidebarDefaultFailed:`Error al establecer el orden de menú predeterminado.`,reset:`Restablecer`,darkMode:`Modo oscuro`,lightMode:`Modo claro`,active:`(activo)`,background:`Fondo`,accent:`Acento`,style:`Estilo`,bgNeutral:`Neutro`,bgWarm:`Cálido`,bgCool:`Frío`,bgOled:`Negro OLED`,bgSlate:`Azul pizarra`,bgForest:`Verde bosque`,accentGreen:`Verde`,accentTeal:`Verde azulado`,accentBlue:`Azul`,accentOrange:`Naranja`,accentPurple:`Morado`,accentRed:`Rojo`,styleClassic:`Clásico`,styleGlow:`Resplandor`,styleVibrant:`Vibrante`,themeToggleHint:`Alterne entre modo oscuro, claro y sistema con el icono en la barra lateral.`,autoArchivePrints:`Archivar impresiones automáticamente`,autoArchiveDescription:`Guardar automáticamente los archivos 3MF cuando se completan las impresiones`,saveThumbnailsDescription:`Extraer y guardar imágenes de vista previa de los archivos 3MF`,captureFinishPhotoDescription:`Tomar una foto desde la cámara de la impresora cuando se completa la impresión. Bambuddy graba un breve timelapse durante la impresión para que la foto pueda obtenerse del momento previo al descenso de la cama; el archivo del timelapse se conserva si activaste el timelapse para esta impresión, de lo contrario se elimina automáticamente tras capturar la foto.`,ffmpegNotInstalled:`ffmpeg no instalado`,ffmpegRequired:`La captura de cámara requiere ffmpeg. Instálelo mediante brew install ffmpeg (macOS) o apt install ffmpeg (Linux).`,camera:`Cámara`,cameraViewMode:`Modo de vista de la cámara`,cameraOverlayDescription:`La cámara se abre en una superposición redimensionable en la pantalla principal`,cameraWindowDescription:`La cámara se abre en una ventana de navegador independiente`,externalCamerasDescription:`Configure cámaras externas para sustituir la cámara integrada de la impresora. Admite transmisiones MJPEG, RTSP, capturas HTTP y cámaras USB (V4L2). Cuando está activada, la cámara externa se usa para la vista en directo y las fotos de finalización.`,cameraPlaceholderUsb:`Ruta del dispositivo (/dev/video0)`,cameraPlaceholderUrl:`URL de la cámara (rtsp://... o http://...)`,cameraTypeMjpeg:`Transmisión MJPEG`,cameraTypeRtsp:`Transmisión RTSP`,cameraTypeSnapshot:`Captura HTTP`,cameraTypeUsb:`Cámara USB (V4L2)`,cameraSnapshotUrl:`URL de captura (opcional)`,cameraSnapshotUrlPlaceholder:`http://192.168.1.61:1984/api/frame.jpeg?src=printer`,cameraSnapshotUrlHelp:`URL de fotograma único usada para las miniaturas de notificaciones, las fotos de finalización, los fotogramas de time-lapse por capa y la detección de cama. El time-lapse y la detección de cama requieren cada uno su propio interruptor por impresora; esta URL es solo la fuente de imagen de la que se nutren cuando están activos. Déjelo en blanco para capturar desde la transmisión en directo de arriba. Útil para go2rtc (/api/frame.jpeg) y cámaras IP con un punto de conexión de captura dedicado.`,cameraRotation:`Rotación`,test:`Probar`,connected:`Conectada`,disconnected:`Desconectada`,currency:`Moneda`,defaultFilamentCost:`Coste predeterminado del filamento (por kg)`,electricityCost:`Coste de la electricidad por kWh`,energyDisplayMode:`Modo de visualización de la energía`,energyModePrintDescription:`El panel muestra la suma de la energía usada durante las impresiones`,energyModeTotalDescription:`El panel muestra la energía total de los enchufes inteligentes`,fileManager:`Gestor de archivos`,createArchiveEntry:`Crear una entrada de archivo al imprimir`,createArchiveEntryDescription:`Al imprimir desde el gestor de archivos, crear opcionalmente una entrada de archivo`,lowDiskSpaceWarning:`Advertencia de poco espacio en disco`,lowDiskSpaceDescription:`Mostrar una advertencia cuando el espacio libre en disco caiga por debajo de este umbral`,printerFirmware:`Firmware de la impresora`,checkFirmwareDescription:`Buscar actualizaciones de firmware de la impresora de Bambu Lab`,bambuddySoftware:`Software de Bambuddy`,autoCheckDescription:`Buscar automáticamente nuevas versiones al iniciar`,checkNow:`Buscar ahora`,updateAvailableVersion:`Actualización disponible: v{{version}}`,releaseNotes:`Notas de la versión`,updateViaDocker:`Actualizar mediante Docker Compose:`,updateViaHomeAssistant:`Las actualizaciones las gestiona el Supervisor de Home Assistant. Abra Ajustes → Complementos → Bambuddy en Home Assistant para instalar la nueva versión.`,updateViaWindowsInstaller:`Las instalaciones en Windows se actualizan volviendo a ejecutar el instalador. Descarga la nueva versión abajo — tus datos, ajustes e impresoras se conservan.`,downloadWindowsInstaller:`Descargar instalador para v{{version}}`,installUpdate:`Instalar actualización`,latestVersionRunning:`Está ejecutando la versión más reciente`,failedToCheckUpdates:`Error al buscar actualizaciones: {{error}}`,backupRestore:`Copia de seguridad y restauración`,backupRestoreDescription:`Exportar/importar ajustes y configurar la copia de seguridad en GitHub`,goToBackup:`Ir a la copia de seguridad`,externalUrl:`URL externa`,externalUrlDescription:`La URL externa donde Bambuddy es accesible. Se usa para las imágenes de notificación y las integraciones externas.`,bambuddyUrl:`URL de Bambuddy`,externalUrlHint:`Incluya el protocolo y el puerto (p. ej., http://192.168.1.100:8000)`,ftpRetry:`Reintento de FTP`,ftpRetryDescription:`Reintentar las operaciones FTP cuando el Wi-Fi de la impresora no es fiable. Se aplica a las descargas de 3MF, las subidas de impresión, las descargas de time-lapse y las actualizaciones de firmware.`,autoRetryDescription:`Reintentar automáticamente las operaciones FTP fallidas`,retryAttempts:`Intentos de reintento`,retryDelay:`Retardo de reintento`,connectionTimeout:`Tiempo de espera de la conexión`,time_one:`{{count}} vez`,time_other:`{{count}} veces`,second_one:`{{count}} segundo`,second_other:`{{count}} segundos`,nSeconds:`{{count}} segundos`,increaseForWeakWifi:`Aumente para impresoras con Wi-Fi débil`,homeAssistant:`Home Assistant`,homeAssistantFullDescription:`Conéctese a Home Assistant para controlar enchufes inteligentes mediante la API REST de HA. Admite las entidades switch, light, input_boolean y script.`,homeAssistantUrl:`URL de Home Assistant`,longLivedAccessToken:`Token de acceso de larga duración`,haTokenHint:`Cree un token en HA: Perfil → Tokens de acceso de larga duración → Crear token`,connectionSuccessful:`Conexión correcta`,connectionFailed:`Error de conexión`,haConnectionSuccess:`Conexión con Home Assistant realizada correctamente.`,haConnectionFailed:`Error al conectar con Home Assistant.`,mqttPublishing:`Publicación MQTT`,mqttDescription:`Publique los eventos de Bambuddy en un broker MQTT externo para la integración con Node-RED, Home Assistant y otros sistemas de automatización.`,mqttEnableDescription:`Publicar eventos en un broker MQTT externo`,brokerHostname:`Nombre de host del broker`,port:`Puerto`,usernameOptional:`Nombre de usuario (opcional)`,passwordOptional:`Contraseña (opcional)`,topicPrefix:`Prefijo del tema`,topicPrefixHint:`Los temas serán: {{prefix}}/printers//status, etc.`,prometheusMetrics:`Métricas de Prometheus`,prometheusEndpointDescription:`Exponer las métricas de la impresora en /api/v1/metrics para la supervisión con Prometheus/Grafana.`,bearerTokenOptional:`Bearer Token (opcional)`,bearerTokenHint:`Si se establece, las solicitudes deben incluir Authorization: Bearer `,metricsConnectionStatus:`Estado de la conexión`,metricsPrinterState:`Estado de la impresora (inactiva/imprimiendo/etc.)`,metricsPrintProgress:`Progreso de la impresión 0-100%`,metricsBedTemp:`Temperatura de la cama`,metricsNozzleTemp:`Temperatura de la boquilla`,metricsPrintsTotal:`Total de impresiones por resultado`,metricsMore:`...y más (capas, ventiladores, cola, uso de filamento)`,smartPlugsDescription:`Conecte enchufes inteligentes (Tasmota o Home Assistant) para automatizar el control de la alimentación y realizar el seguimiento del consumo de energía de sus impresoras.`,allOn:`Encender todo`,allOff:`Apagar todo`,addSmartPlug:`Añadir enchufe inteligente`,energySummary:`Resumen de energía`,currentPower:`Potencia actual`,plugsOnline:`{{reachable}}/{{total}} enchufes en línea`,today:`Hoy`,yesterday:`Ayer`,total:`Total`,enablePlugsForSummary:`Active enchufes para ver el resumen de energía`,addNotificationProvider:`Añadir`,systemBadge:`(Sistema)`,creating:`Creando...`,changing:`Cambiando...`,deleteUserAndItems:`Eliminar el usuario Y sus elementos`,deleteUserKeepItems:`Eliminar el usuario, conservar los elementos (quedan sin propietario)`,ok:`Aceptar`,twoFa:{totpTitle:`Aplicación de autenticación (TOTP)`,totpDesc:`Use una aplicación de autenticación como Google Authenticator, Aegis o Authy.`,emailOtpTitle:`OTP por correo`,emailOtpDesc:`Enviar un código de un solo uso a {{email}} cuando inicie sesión.`,emailOtpNoEmail:`Añada una dirección de correo a su cuenta para habilitar este método.`,addEmailFirst:`Su cuenta no tiene dirección de correo. Pida a un administrador que añada una antes de activar el OTP por correo.`,setupTotp:`Configurar la aplicación de autenticación`,setupAuthApp:`Configurar la aplicación de autenticación`,setupInstructions:`Escanee el código QR de abajo con su aplicación de autenticación y luego confirme con un código.`,manualEntry:`¿No puede escanear? Introduzca este secreto manualmente:`,scannedContinue:`He escaneado el código — continuar`,enterCodeToConfirm:`Introduzca el código de 6 dígitos de su aplicación de autenticación para confirmar la configuración.`,activate:`Activar`,disableTotp:`Desactivar el autenticador`,disableConfirmHint:`Introduzca un código TOTP válido o un código de respaldo para desactivar el autenticador.`,totpDisabled:`Aplicación de autenticación desactivada.`,emailOtpEnabled:`OTP por correo activado.`,emailOtpDisabled:`OTP por correo desactivado.`,smtpRequired:`Configure y pruebe primero los ajustes de SMTP.`,invalidCode:`Código no válido. Inténtelo de nuevo.`,enableEmailOtp:`Activar el OTP por correo`,disableEmailOtp:`Desactivar el OTP por correo`,emailSetupEnterCode:`Se ha enviado un código de verificación a su dirección de correo. Introdúzcalo a continuación para confirmar que es el propietario de este buzón.`,verifyAndEnable:`Verificar y activar`,emailDisablePasswordHint:`Introduzca la contraseña de su cuenta para confirmar la desactivación del OTP por correo.`,passwordPlaceholder:`Introduzca su contraseña`,backupCodesTitle:`Guarde sus códigos de respaldo`,backupCodesWarning:`Guarde estos códigos en un lugar seguro. Cada código solo se puede usar una vez y no se volverán a mostrar.`,backupCodesRemaining:`Quedan {{count}} códigos de respaldo`,savedCodes:`He guardado mis códigos`,regenBackup:`Regenerar los códigos de respaldo`,regenBackupHint:`Introduzca su código TOTP actual para generar 10 códigos de respaldo nuevos. Todos los códigos de respaldo existentes quedarán invalidados.`,newBackupCodes:`Nuevos códigos de respaldo`,linkedAccounts:`Cuentas de SSO vinculadas`,linkedAccountsDesc:`Estos proveedores de identidad externos están vinculados a su cuenta.`,oidcUnlinked:`Cuenta desvinculada.`},sessionPolicy:{title:`Política de sesión`,description:`Duración máxima de sesión para nuevos inicios de sesión. Los tokens ya emitidos conservan su caducidad original.`,preset24h:`24 horas`,preset7d:`7 días`,preset30d:`30 días`,customHoursLabel:`Duración de sesión personalizada en horas`,hoursSuffix:`horas`,warning:`Las sesiones más largas reducen la protección de cierre automático. Recomendado solo para implementaciones de usuario único en entornos de confianza.`},oidc:{title:`Proveedores SSO / OIDC`,desc:`Configure proveedores de OpenID Connect para permitir el inicio de sesión único mediante proveedores de identidad externos.`,addProvider:`Añadir proveedor`,newProvider:`Nuevo proveedor`,empty:`Aún no hay proveedores OIDC configurados.`,created:`Proveedor creado.`,updated:`Proveedor actualizado.`,deleted:`Proveedor eliminado.`,refreshIcon:`Actualizar icono`,removeIcon:`Quitar icono`,iconRefreshed:`Icono actualizado.`,iconRemoved:`Icono eliminado.`,iconFetchFailed:`No se pudo obtener el icono de la URL del proveedor.`,deleteTitle:`Eliminar proveedor`,deleteMessage:`¿Eliminar "{{name}}"? Todas las cuentas de usuario vinculadas se desconectarán.`,form:{name:`Nombre visible`,issuerUrl:`URL del emisor`,clientId:`ID de cliente`,clientSecret:`Secreto de cliente`,scopes:`Ámbitos`,iconUrl:`URL del icono (opcional)`,enabled:`Activado`,autoCreate:`Crear usuarios automáticamente`,autoCreateDesc:`Crear automáticamente una cuenta local en el primer inicio de sesión.`,autoLink:`Vincular cuentas existentes automáticamente`,autoLinkDesc:`Vincular cuentas locales existentes haciendo coincidir el correo en el primer inicio de sesión.`,secretHint:`dejar en blanco para conservar el actual`,secretPlaceholder:`nuevo secreto`,emailClaim:`Claim de correo`,emailClaimDesc:`Claim de JWT usado como identidad de correo. Use «preferred_username» o «upn» para Azure Entra ID (que no envía email_verified). Use solo nombres de claim de confianza.`,emailClaimPlaceholder:`correo`,emailClaimCustomClaimAutoLinkWarning:`Los claims personalizados solo son seguros para la vinculación automática cuando el valor lo administra el inquilino (p. ej. upn / preferred_username de Azure Entra ID). No active la vinculación automática si su IdP permite a los usuarios autoasignarse este claim.`,requireEmailVerified:`Requerir correo verificado`,requireEmailVerifiedDesc:`Aceptar el claim de correo solo cuando el proveedor lo marca como verificado.`,requireEmailVerifiedWarning:`Advertencia: el correo se aceptará incluso sin verificación. Úselo solo con proveedores de confianza.`,requireEmailVerifiedAutoLink:`Desactive primero la vinculación automática para cambiar este ajuste.`,defaultGroup:`Grupo predeterminado`,defaultGroupDesc:`Grupo asignado a los usuarios creados automáticamente. Si no se establece, se usa Visores como alternativa.`,defaultGroupViewersFallback:`Visores (predeterminado)`}},encryption:{title:`Estado del cifrado de MFA`,enabledFromEnv:`Cifrado en reposo activado (clave de la variable de entorno MFA_ENCRYPTION_KEY)`,enabledFromFile:`Cifrado en reposo activado (clave cargada del directorio de datos)`,enabledGenerated:`Cifrado en reposo activado con una clave autogenerada`,notConfigured:`Cifrado en reposo no configurado`,notConfiguredDesc:`Los secretos TOTP y los client_secrets de OIDC se almacenan en texto plano. Establezca MFA_ENCRYPTION_KEY o reinicie Bambuddy con un directorio de datos con permisos de escritura para generar una automáticamente.`,allEncrypted:`Todos los secretos de MFA están cifrados en reposo.`,legacyRowsLabel:`Filas heredadas en texto plano`,encryptedRowsLabel:`Filas cifradas`,legacyRowsWarning:`Se detectaron {{count}} fila(s) heredada(s) en texto plano. Vuelva a guardar el proveedor OIDC o vuelva a registrar la aplicación de autenticación del usuario para migrar al almacenamiento cifrado.`,backupHint:`La clave autogenerada se almacena en DATA_DIR/.mfa_encryption_key y se incluye en los ZIP de copia de seguridad local. Mantenga sus copias de seguridad seguras o establezca MFA_ENCRYPTION_KEY de forma explícita.`,decryptionBrokenTitle:`Falta la clave de cifrado`,decryptionBrokenError:`{{count}} registro(s) cifrado(s) no se pueden descifrar porque la clave de cifrado ya no está disponible. Restaure la MFA_ENCRYPTION_KEY anterior o DATA_DIR/.mfa_encryption_key para recuperarlos.`,migrationErrorWarning:`{{count}} fila(s) heredada(s) no se pudieron volver a cifrar al iniciar. Revise los registros del servidor y reinicie Bambuddy para reintentarlo.`}},notification:{printStarted:{title:`Impresión iniciada`,body:`{{printer}}: {{filename}} ha empezado a imprimirse`},printCompleted:{title:`Impresión completada`,body:`{{printer}}: {{filename}} se completó correctamente`},printFailed:{title:`Impresión fallida`,body:`{{printer}}: {{filename}} ha fallado`},printStopped:{title:`Impresión detenida`,body:`{{printer}}: {{filename}} se detuvo`},printProgress:{title:`Progreso de la impresión`,body:`{{printer}}: {{filename}} está al {{percent}}%`},printerOffline:{title:`Impresora desconectada`,body:`{{printer}} está desconectada`},printerError:{title:`Error de la impresora`,body:`{{printer}}: {{error}}`},filamentLow:{title:`Filamento bajo`,body:`{{printer}}: el filamento se está agotando`},maintenanceDue:{title:`Mantenimiento pendiente`,body:`{{printer}}: {{items}} necesitan atención`}},errors:{generic:`Algo salió mal`,networkError:`Error de red. Compruebe su conexión.`,notFound:`No encontrado`,unauthorized:`No autorizado`,serverError:`Error del servidor`,validationError:`Compruebe los datos introducidos`,printerConnectionFailed:`Error al conectar con la impresora`,saveFailed:`Error al guardar los cambios`,deleteFailed:`Error al eliminar`,loadFailed:`Error al cargar los datos`},hmsErrors:{title:`Errores - {{name}}`,noErrors:`No hay errores`,viewOnWiki:`Ver en la wiki de Bambu Lab`,clearInstructions:`Borre los errores en la impresora para descartarlos aquí.`,clearErrors:`Borrar errores`,clearSuccess:`Errores HMS borrados`,clearFailed:`Error al borrar los errores HMS`},mqttDebug:{title:`Registro de depuración MQTT`,searchPlaceholder:`Buscar tema o carga útil...`,noMessages:`Aún no se han registrado mensajes`,startLoggingHint:`Haga clic en «Iniciar registro» para empezar a capturar mensajes MQTT`,noMessagesMatch:`Ningún mensaje coincide con su filtro`,adjustFilterHint:`Pruebe a ajustar su búsqueda o los criterios del filtro`,incoming:`Entrante`,outgoing:`Saliente`,loggingStopped:`Registro detenido`,loggingActive:`Registro activo - los mensajes se actualizarán automáticamente`,startLogging:`Iniciar registro`,stopLogging:`Detener registro`,clearLog:`Borrar registro`,topic:`Tema`,timestamp:`Marca de tiempo`,direction:`Dirección`,all:`Todos`},printerFiles:{title:`Gestor de archivos`,storageUsed:`Usado:`,storageFree:`Libre:`,filterPlaceholder:`Filtrar archivos...`,deleteButton:`Eliminar`,deleteFiles:`Eliminar {{count}} archivos`,deleteFileConfirm:`¿Eliminar "{{name}}"? Esto no se puede deshacer.`,deleteFilesConfirm:`¿Eliminar {{count}} archivos seleccionados? Esto no se puede deshacer.`,noFiles:`No hay archivos en la impresora`,loadingFiles:`Cargando archivos...`,failedToLoad:`Error al cargar los archivos`,toast:{filesDeleted:`Se eliminaron {{count}} archivo(s)`,deleteFailed:`Error al eliminar: {{error}}`}},confirm:{delete:`¿Está seguro de que desea eliminar esto?`,unsavedChanges:`Tiene cambios sin guardar. ¿Está seguro de que desea salir?`,clearQueue:`¿Está seguro de que desea vaciar la cola?`},login:{title:`Inicio de sesión en Bambuddy`,subtitle:`Inicie sesión en su cuenta`,username:`Nombre de usuario`,usernamePlaceholder:`Introduzca su nombre de usuario`,usernameOrEmail:`Nombre de usuario o correo`,usernameOrEmailPlaceholder:`Nombre de usuario o @ correo`,password:`Contraseña`,passwordPlaceholder:`Introduzca su contraseña`,signIn:`Iniciar sesión`,signingIn:`Iniciando sesión...`,rememberMe:`Recordarme`,forgotPassword:`¿Olvidó su contraseña?`,loginSuccess:`Sesión iniciada correctamente`,loginFailed:`Error al iniciar sesión`,enterCredentials:`Introduzca el nombre de usuario y la contraseña`,enterEmail:`Introduzca su dirección de correo`,oidcLoginFailed:`Error en el inicio de sesión con OIDC`,oidcErrors:{providerError:`El proveedor de identidad devolvió un error`,missingParameters:`A la respuesta de OIDC le faltan parámetros obligatorios`,invalidState:`El estado de OIDC no es válido o ya se ha usado`,stateExpired:`La sesión de inicio de sesión con OIDC ha caducado — inténtelo de nuevo`,providerNotFound:`Proveedor OIDC no encontrado`,discoveryFailed:`Error al obtener el documento de descubrimiento de OIDC`,invalidDiscovery:`El documento de descubrimiento de OIDC no es válido`,networkError:`Error de red durante el intercambio de tokens de OIDC`,badResponse:`Respuesta inesperada durante el intercambio de tokens de OIDC`,noIdToken:`El proveedor OIDC no devolvió un token de ID`,validationFailed:`Error en la validación del token de OIDC`,nonceMismatch:`Discrepancia de nonce de OIDC — posible ataque de repetición`,missingSubClaim:`Al token de OIDC le falta el claim sub`,noLinkedAccount:`Ninguna cuenta local está vinculada a esta identidad de OIDC`,accountInactive:`Su cuenta está inactiva`,userResolutionFailed:`Error al resolver su cuenta`,internalError:`Se produjo un error interno durante el inicio de sesión con OIDC`,tokenExchangeFailed:`Error en el intercambio de tokens de OIDC`},forgotPasswordTitle:`Contraseña olvidada`,forgotPasswordMessage:`Si ha olvidado su contraseña, póngase en contacto con el administrador de su sistema para restablecerla.`,forgotPasswordEmailMessage:`Introduzca su dirección de correo y le enviaremos una contraseña nueva.`,emailAddress:`Dirección de correo`,emailPlaceholder:`su.correo@ejemplo.com`,cancel:`Cancelar`,sending:`Enviando...`,sendResetEmail:`Enviar correo de restablecimiento`,howToReset:`Cómo restablecer su contraseña:`,resetStep1:`Póngase en contacto con su administrador de Bambuddy`,resetStep2:`Pídale que restablezca su contraseña en la gestión de usuarios`,resetStep3:`Puede establecerle una nueva contraseña temporal`,resetStep4:`Inicie sesión con la nueva contraseña y cámbiela en Ajustes`,gotIt:`Entendido`,resetPassword:{title:`Establecer nueva contraseña`,subtitle:`Introduzca y confirme su nueva contraseña a continuación.`,newPassword:`Nueva contraseña`,newPasswordPlaceholder:`Al menos 8 caracteres`,confirmPassword:`Confirmar contraseña`,confirmPasswordPlaceholder:`Repita la nueva contraseña`,saving:`Guardando…`,submit:`Establecer nueva contraseña`,backToLogin:`Volver al inicio de sesión`,passwordsDoNotMatch:`Las contraseñas no coinciden`,passwordTooShort:`La contraseña debe tener al menos 8 caracteres`,resetFailed:`Error al restablecer la contraseña. Es posible que el enlace haya caducado.`},twoFA:{title:`Autenticación de dos factores`,subtitle:`Su cuenta está protegida con 2FA. Introduzca el código de verificación a continuación.`,methodAuthenticator:`Aplicación de autenticación`,methodEmail:`Código por correo`,methodBackup:`Código de respaldo`,instructionsTotp:`Abra su aplicación de autenticación e introduzca el código de 6 dígitos para Bambuddy.`,instructionsEmail:`Se ha enviado un código de 6 dígitos a su dirección de correo. Caduca en 10 minutos.`,instructionsEmailNotSent:`Haga clic en el botón de abajo para recibir un código de verificación por correo.`,instructionsBackup:`Introduzca uno de sus códigos de recuperación de respaldo de 8 caracteres. Cada código solo se puede usar una vez.`,sendCodeButton:`Enviar código por correo`,sendingCode:`Enviando...`,resendCode:`Reenviar código`,codeLabel:`Código de verificación`,backupCodeLabel:`Código de respaldo`,codePlaceholder:`000000`,backupCodePlaceholder:`XXXXXXXX`,verifyButton:`Verificar`,verifyingButton:`Verificando...`,backToLogin:`← Volver al inicio de sesión`,orContinueWith:`o continuar con`,signInWith:`Iniciar sesión con {{provider}}`,enterCode:`Introduzca el código de verificación`,sendCodeFailed:`Error al enviar el código de verificación`,invalidCode:`Código no válido. Inténtelo de nuevo.`}},setup:{title:`Configuración de Bambuddy`,subtitle:`Configure la autenticación para su instancia de Bambuddy`,enableAuth:`Activar la autenticación`,adminAccount:`Cuenta de administrador`,adminAccountDesc:`Si ya existen usuarios administradores, la autenticación se activará usando las cuentas de administrador existentes. Deje los campos de abajo vacíos para usar los administradores existentes, o introduzca nuevas credenciales para crear un nuevo usuario administrador.`,adminUsername:`Nombre de usuario del administrador`,adminPassword:`Contraseña del administrador`,optionalIfAdminExists:`(opcional si existen usuarios administradores)`,adminUsernamePlaceholder:`Introduzca el nombre de usuario del administrador (opcional)`,adminPasswordPlaceholder:`Introduzca la contraseña del administrador (opcional)`,confirmPassword:`Confirmar contraseña`,confirmPasswordPlaceholder:`Confirme la contraseña del administrador`,settingUp:`Configurando...`,completeSetup:`Completar la configuración`,toast:{authEnabledAdminCreated:`Autenticación activada y usuario administrador creado`,authEnabledExistingAdmins:`Autenticación activada usando los usuarios administradores existentes`,setupCompleted:`Configuración completada`,enterBothCredentials:`Introduzca el nombre de usuario y la contraseña del administrador, o deje ambos vacíos para usar los usuarios administradores existentes`,passwordsDoNotMatch:`Las contraseñas no coinciden`,passwordTooShort:`La contraseña debe tener al menos 6 caracteres`}},changePassword:{title:`Cambiar contraseña`,currentPassword:`Contraseña actual`,currentPasswordPlaceholder:`Introduzca la contraseña actual`,newPassword:`Nueva contraseña`,newPasswordPlaceholder:`Introduzca la nueva contraseña (mín. 6 caracteres)`,confirmPassword:`Confirmar nueva contraseña`,confirmPasswordPlaceholder:`Confirme la nueva contraseña`,passwordsDoNotMatch:`Las contraseñas no coinciden`,passwordTooShort:`La contraseña debe tener al menos 6 caracteres`,changing:`Cambiando...`,success:`Contraseña cambiada correctamente`,failed:`Error al cambiar la contraseña`},plateAlert:{title:`¡Impresión en pausa!`,message:`Se han detectado objetos en la cama de impresión. La impresión se ha pausado automáticamente. Despeje la cama y reanude la impresión.`,understand:`Entendido`},camera:{title:`Vista de la cámara`,invalidPrinterId:`ID de impresora no válido`,live:`En directo`,snapshot:`Captura`,restartStream:`Reiniciar la transmisión`,refreshSnapshot:`Actualizar la captura`,fullscreen:`Pantalla completa`,exitFullscreen:`Salir de la pantalla completa`,connectingToCamera:`Conectando con la cámara...`,capturingSnapshot:`Capturando imagen...`,connectionLost:`Conexión perdida`,connectionFailed:`Error de conexión con la cámara`,reconnecting:`Reconectando en {{countdown}} s... (intento {{attempt}}/{{max}})`,reconnectNow:`Reconectar ahora`,cameraUnavailable:`Cámara no disponible`,cameraUnavailableDesc:`Asegúrese de que la impresora está encendida y conectada.`,noCamera:`No hay cámara disponible`,retry:`Reintentar`,cameraStream:`Transmisión de la cámara`,zoomOut:`Alejar`,zoomIn:`Acercar`,resetZoom:`Restablecer el zoom`,recording:`Grabando`,startRecording:`Iniciar grabación`,stopRecording:`Detener grabación`,chamberLight:`Conmutar la luz de la cámara`,unavailable:`Cámara no disponible`,diagnose:{button:`Diagnosticar`,modalTitle:`Diagnóstico de la cámara`,running:`Ejecutando el diagnóstico...`,runFailed:`No se pudo ejecutar el diagnóstico: {{error}}`,retry:`Ejecutar de nuevo`,stage:{tcp_reachable:`Accesibilidad de la red`,first_frame:`Captura de fotogramas`,live_stream_active:`Transmisión en directo activa`},summary:{all_ok:`La cámara funciona. El diagnóstico completó todas las etapas correctamente.`,live_stream_active_healthy:`La cámara está transmitiendo actualmente con fotogramas recientes — no se necesita ninguna prueba.`,printer_unreachable:`La impresora no es accesible. Compruebe la dirección IP, la conexión de red y que la impresora está encendida.`,camera_port_closed:`La impresora es accesible pero el puerto de la cámara está cerrado. Asegúrese de que el modo solo LAN y el modo desarrollador están activados en los ajustes de la impresora.`,no_frame:`Se conectó a la cámara pero no se recibieron fotogramas. Inténtelo de nuevo o compruebe que la cámara está activada en los ajustes de la impresora.`,unknown_failure:`El diagnóstico de la cámara falló por un motivo desconocido. Consulte el registro de soporte para más detalles.`},meta:{protocol:`Protocolo`,port:`Puerto`,profile:`Perfil`}}},groups:{title:`Gestión de grupos`,subtitle:`Gestione los grupos de permisos para el control de acceso`,backToSettings:`Volver a Ajustes`,createGroup:`Crear grupo`,noPermission:`No tiene permiso para acceder a esta página.`,system:`Sistema`,noDescription:`Sin descripción`,usersCount:`{{count}} usuarios`,permissionsCount:`{{count}} permisos`,edit:`Editar`,delete:`Eliminar`,toast:{created:`Grupo creado correctamente`,updated:`Grupo actualizado correctamente`,deleted:`Grupo eliminado correctamente`,enterGroupName:`Introduzca un nombre de grupo`},modal:{editGroup:`Editar grupo`,createGroup:`Crear grupo`,cancel:`Cancelar`,saving:`Guardando...`,creating:`Creando...`,saveChanges:`Guardar cambios`},form:{groupName:`Nombre del grupo`,groupNamePlaceholder:`Introduzca el nombre del grupo`,systemGroupWarning:`Los nombres de los grupos del sistema no se pueden cambiar`,description:`Descripción`,descriptionPlaceholder:`Introduzca una descripción (opcional)`,permissions:`Permisos ({{count}} seleccionados)`},deleteModal:{title:`Eliminar grupo`,message:`¿Está seguro de que desea eliminar este grupo? Los usuarios de este grupo perderán estos permisos.`,confirm:`Eliminar grupo`},editor:{title:`Editar grupo`,createTitle:`Crear grupo`,search:`Buscar permisos...`,selectAll:`Seleccionar todo`,clearAll:`Borrar todo`,permissionsSelected:`{{count}} seleccionados`,noResults:`Ningún permiso coincide con su búsqueda`}},users:{title:`Gestión de usuarios`,subtitle:`Gestione los usuarios y su acceso a su instancia de Bambuddy`,backToSettings:`Volver a Ajustes`,createUser:`Crear usuario`,noPermission:`No tiene permiso para acceder a esta página.`,admin:`Administrador`,noGroups:`Sin grupos`,active:`Activo`,inactive:`Inactivo`,edit:`Editar`,delete:`Eliminar`,system:`Sistema`,noGroupsAvailable:`No hay grupos disponibles`,table:{username:`Nombre de usuario`,groups:`Grupos`,status:`Estado`,actions:`Acciones`},toast:{created:`Usuario creado correctamente`,updated:`Usuario actualizado correctamente`,deleted:`Usuario eliminado correctamente`,fillRequired:`Rellene todos los campos obligatorios`,passwordsDoNotMatch:`Las contraseñas no coinciden`,passwordTooShort:`La contraseña debe tener al menos 6 caracteres`,ldapProvisioned:`Usuario LDAP "{{username}}" aprovisionado`},modal:{createUser:`Crear usuario`,editUser:`Editar usuario`,cancel:`Cancelar`,creating:`Creando...`,saving:`Guardando...`,saveChanges:`Guardar cambios`,advancedAuthSubtitle:`con autenticación avanzada`,tabsAriaLabel:`Origen del usuario`,localTab:`Local`,ldapTab:`LDAP`,ldapSearchLabel:`Buscar en el directorio`,ldapSearchPlaceholder:`Escriba un nombre de usuario, nombre o correo...`,ldapMinChars:`Escriba al menos 2 caracteres para buscar`,ldapTypeToSearch:`Empiece a escribir para buscar en el directorio LDAP`,ldapSearching:`Buscando en el directorio...`,ldapNoResults:`No hay usuarios coincidentes en el directorio`,ldapSearchError:`Error en la búsqueda en el directorio. Compruebe el estado del servidor LDAP.`,ldapAlreadyProvisioned:`Ya aprovisionado`,ldapSelectedLabel:`Seleccionado`,ldapProvision:`Aprovisionar usuario`,ldapProvisioning:`Aprovisionando...`,ldapErrorProvision:`Error en el aprovisionamiento. Compruebe el estado del servidor LDAP e inténtelo de nuevo.`},form:{username:`Nombre de usuario`,usernamePlaceholder:`Introduzca el nombre de usuario`,email:`Correo`,emailPlaceholder:`usuario@ejemplo.com`,password:`Contraseña`,passwordPlaceholder:`Introduzca la contraseña`,confirmPassword:`Confirmar contraseña`,confirmPasswordPlaceholder:`Confirme la contraseña`,newPasswordPlaceholder:`Introduzca la nueva contraseña`,confirmNewPasswordPlaceholder:`Confirme la nueva contraseña`,leaveBlankToKeep:`dejar en blanco para conservar la actual`,groups:`Grupos`,optional:`opcional`,autoGeneratedPassword:`Se generará automáticamente una contraseña segura y se enviará al usuario por correo.`,passwordManagedByAdvancedAuth:`La contraseña la gestiona la autenticación avanzada. Use «Restablecer contraseña» para enviar una nueva contraseña al usuario por correo.`,resetPassword:`Restablecer contraseña`,resettingPassword:`Restableciendo la contraseña...`},deleteModal:{title:`Eliminar usuario`,message:`¿Está seguro de que desea eliminar este usuario? Esta acción no se puede deshacer.`,confirm:`Eliminar usuario`}},streamOverlay:{title:`Superposición de transmisión`,invalidPrinterId:`ID de impresora no válido`,cameraStream:`Transmisión de la cámara`,progress:`Progreso`,eta:`Tiempo estimado`,printerIdle:`La impresora está inactiva`,printerOffline:`Impresora desconectada`,status:{printing:`Imprimiendo`,paused:`En pausa`,finished:`Finalizada`,failed:`Fallida`,idle:`Inactiva`,unknown:`Desconocido`}},profiles:{title:`Perfiles`,subtitle:`Gestione sus preajustes del laminador y las calibraciones de avance de presión`,tabs:{bambuCloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,local:`Perfiles locales`,kprofiles:`Perfiles K`},orcaCloud:{connectedAs:`Conectado como`,logout:`Desconectar`,noLogoutPermission:`No tienes permiso para desconectar`,noConnectPermission:`No tienes permiso para conectar a Orca Cloud`,retry:`Reintentar`,back:`Usar otro método de inicio de sesión`,connect:{title:`Conectar a Orca Cloud`,description:`Inicia sesión en tu cuenta Orca Cloud para sincronizar tus perfiles de slicer en Bambuddy.`},providers:{google:`Iniciar sesión con Google`,apple:`Iniciar sesión con Apple`,github:`Iniciar sesión con GitHub`,email:`Iniciar sesión con correo y contraseña`},password:{title:`Iniciar sesión con correo y contraseña`,email:`Correo electrónico`,emailPlaceholder:`tu@ejemplo.com`,password:`Contraseña`,submit:`Iniciar sesión`},paste:{title:`Finalizar inicio de sesión`,step1:`Se abrió una nueva pestaña con la página de inicio de sesión de Orca Cloud. Inicia sesión con tu cuenta de Orca.`,step2:`Tu navegador será redirigido a una URL "localhost" que no se cargará. Es lo esperado — esa URL es lo que necesitamos.`,step3:`Copia la URL completa desde la barra de direcciones del navegador y pégala abajo.`,signInUrl:`Si la pestaña de inicio de sesión no se abrió, haz clic en esta URL:`,label:`Pega aquí la URL de callback`,placeholder:`http://localhost:41172/callback?code=...&state=...`,submit:`Finalizar conexión`},profiles:{title:`Tus perfiles de Orca Cloud ({{count}})`,refresh:`Actualizar`,empty:`Aún no hay perfiles en tu cuenta de Orca Cloud.`},toast:{connected:`Conectado a Orca Cloud como {{email}}`,disconnected:`Desconectado de Orca Cloud`},errors:{startFailed:`No se pudo iniciar el inicio de sesión de Orca Cloud.`,finishFailed:`No se pudo finalizar el inicio de sesión de Orca Cloud.`,passwordFailed:`No se pudo iniciar sesión con ese correo y contraseña.`,passwordEmpty:`Por favor introduce tanto tu correo como tu contraseña.`,emptyPaste:`Pega la URL de callback desde tu navegador.`,noCode:`Esa URL no parece un callback de Orca Cloud (sin parámetro code). Copia la URL completa desde la barra de direcciones.`}},localProfiles:{title:`Perfiles locales`,subtitle:`Importe y gestione preajustes del laminador desde OrcaSlicer`,import:`Importar perfiles`,importDesc:`Suelte aquí archivos .bbscfg, .bbsflmt, .orca_filament, .zip o .json`,importing:`Importando...`,search:`Buscar preajustes locales...`,noPresets:`Aún no hay preajustes locales`,noSearchResults:`Ningún preajuste coincide con su búsqueda`,badge:`Local`,edit:`Editar`,delete:`Eliminar`,cancel:`Cancelar`,deleteConfirmTitle:`Eliminar preajuste`,deleteConfirm:`¿Está seguro de que desea eliminar este preajuste? Esto no se puede deshacer.`,source:`Origen`,inheritsFrom:`Hereda de`,filamentType:`Tipo`,vendor:`Proveedor`,compatiblePrinters:`Impresoras`,nozzleTemp:`Temp. de la boquilla`,cost:`Coste`,density:`Densidad`,pressureAdvance:`Avance de presión`,filament:`Filamento`,process:`Proceso`,printer:`Impresora`,toast:{importSuccess:`{{count}} preajuste(s) importado(s)`,importSkipped:`{{count}} preajuste(s) omitido(s) (duplicados)`,importError:`{{count}} error(es) durante la importación`,deleted:`Preajuste eliminado`,updated:`Preajuste actualizado`}},connectedAs:`Conectado como`,logout:`Cerrar sesión`,noLogoutPermission:`No tiene permiso para cerrar sesión`,failedToLoad:`Error al cargar los perfiles`,retry:`Reintentar`,time:{justNow:`Ahora mismo`,minsAgo:`hace {{count}} min`,hoursAgo:`hace {{count}} h`,daysAgo:`hace {{count}} d`},toast:{loggedOut:`Sesión cerrada`},login:{title:`Conectarse a Bambu Cloud`,subtitle:`Sincronice sus preajustes del laminador entre dispositivos`,email:`Correo`,password:`Contraseña`,region:`Región`,regionGlobal:`Global`,regionChina:`China`,verificationCode:`Código de verificación`,totpCode:`Código del autenticador`,checkEmail:`Compruebe su correo ({{email}}) en busca de un código de 6 dígitos`,enterTotpHint:`Introduzca el código de 6 dígitos de su aplicación de autenticación`,accessToken:`Token de acceso`,accessTokenHint:`Pegue su token de acceso de Bambu Cloud. Las cuentas de la región de China deben usar esta vía (vinculada al teléfono — inicio de sesión por correo no disponible). Consulte la wiki para saber cómo obtener el token de las cookies de MakerWorld.`,back:`Atrás`,loginButton:`Iniciar sesión`,verifyButton:`Verificar`,setTokenButton:`Establecer token`,useToken:`Usar token de acceso en su lugar`,useEmail:`Iniciar sesión con correo en su lugar`,toast:{loggedIn:`Sesión iniciada correctamente`,codeSent:`Código de verificación enviado a su correo`,enterTotp:`Introduzca el código de su aplicación de autenticación`,tokenSet:`Token establecido correctamente`}},presets:{myPreset:`Mi preajuste (editable)`,duplicate:`Duplicar`,editable:`Editable`,failedToLoadDetails:`Error al cargar los detalles del preajuste`,deleteConfirm:`¿Eliminar este preajuste?`,deleteWarning:`Esto eliminará permanentemente "{{name}}" de Bambu Cloud. Esto no se puede deshacer.`,noDuplicatePermission:`No tiene permiso para duplicar preajustes`,noEditPermission:`No tiene permiso para editar preajustes`,noDeletePermission:`No tiene permiso para eliminar preajustes`,types:{filament:`Preajuste de filamento`,printer:`Preajuste de impresora`,process:`Preajuste de proceso`},toast:{deleted:`Preajuste eliminado`,created:`Preajuste creado`,updated:`Preajuste actualizado`,duplicated:`Preajuste duplicado`,fieldAdded:`Campo "{{key}}" añadido`,exported:`Preajuste exportado`},baseLabel:`Base: {{name}}`,currentLabel:`Actual: {{name}}`,newPreset:`Nuevo preajuste`,editPreset:`Editar preajuste`,duplicatePreset:`Duplicar preajuste`,createNewPreset:`Crear nuevo preajuste`,customizeSettings:`Personalice los ajustes de su nuevo preajuste`,compareWithBase:`Comparar con el preajuste base`,compare:`Comparar`,basePreset:`Preajuste base`,selectBasePreset:`Seleccionar preajuste base...`,presetName:`Nombre del preajuste`,myCustomPreset:`Mi preajuste personalizado`,inheritsFrom:`Hereda de`,dropJsonToImport:`Suelte un JSON para importar`,tabs:{common:`Común`,allFields:`Todos los campos`},availableFields:`Campos disponibles`,searchFieldsPlaceholder:`Buscar campos...`,noMatchingFields:`No hay campos coincidentes`,allFieldsAdded:`Todos los campos añadidos`,addCustomField:`Añadir campo personalizado`,yourOverrides:`Sus anulaciones`,noOverridesYet:`Aún no hay anulaciones`,clickFieldsToAdd:`Haga clic en los campos de la izquierda para añadirlos`,saveAsTemplate:`Guardar como plantilla`,jsonTip:`Consejo: arrastre y suelte un archivo .json en cualquier parte de esta ventana para importar ajustes`},cloudView:{searchPlaceholder:`Buscar preajustes...`,templates:`Plantillas`,refresh:`Actualizar`,newPreset:`Nuevo preajuste`,clearFilters:`Borrar filtros`,compareMode:`Modo de comparación`,selectAnotherPreset:`Seleccione otro preajuste de {{type}}`,clickTwoPresets:`Haga clic en dos preajustes del mismo tipo para compararlos`,selectFirst:`1. Seleccione el primero`,selectSecond:`2. Seleccione el segundo`,compareNow:`Comparar ahora`,lastSynced:`Última sincronización:`,showingCount:`Mostrando {{showing}} de {{total}} preajustes`,noPresetsFound:`No se encontraron preajustes`,columns:{filament:`Filamento`,process:`Proceso`,printer:`Impresora`},noFilamentPresets:`No hay preajustes de filamento`,noProcessPresets:`No hay preajustes de proceso`,noPrinterPresets:`No hay preajustes de impresora`,filters:{type:`Tipo`,owner:`Propietario`,printer:`Impresora`,nozzle:`Boquilla`,filament:`Filamento`,layer:`Capa`,all:`Todos`,myPresets:`Mis preajustes`,builtIn:`Integrados`,process:`Proceso`},noTemplatesPermission:`No tiene permiso para gestionar plantillas`,noRefreshPermission:`No tiene permiso para actualizar perfiles`,noCreatePermission:`No tiene permiso para crear preajustes`},templates:{title:`Plantillas rápidas`,noTemplates:`Aún no hay plantillas`,createFirst:`Cree plantillas desde el editor de preajustes`,typeFilter:`Tipo:`,deleteTitle:`Eliminar plantilla`,deleteWarning:`Esta acción no se puede deshacer`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"?`,namePlaceholder:`Nombre de la plantilla`,descriptionPlaceholder:`Descripción`,settingsJson:`Ajustes (JSON)`,fieldsCount:`{{count}} campos`,shownInModals:`Mostrada en las ventanas`,hiddenInModals:`Oculta en las ventanas`,apply:`Aplicar`,toast:{deleted:`Plantilla eliminada`,updated:`Plantilla actualizada`,created:`Plantilla creada`,applied:`Plantilla aplicada`}}},support:{debugLoggingActive:`El registro de depuración está activo`,manageLogs:`Gestionar`,collectItem7:`Conectividad de la impresora y versiones de firmware`,collectItem8:`Estado de las integraciones (Spoolman, MQTT, HA)`,collectItem9:`Interfaces de red (solo subredes)`,collectItem10:`Versiones de los paquetes de Python`,collectItem11:`Comprobaciones de estado de la base de datos`,collectItem12:`Detalles del entorno de Docker`,bundleGenerating:`Generando paquete...`,bundleStepConnection:`Ejecutando comprobaciones de conectividad de impresoras`,bundleStepVirtualPrinters:`Ejecutando comprobaciones de configuración de impresoras virtuales`,bundleStepLogScan:`Analizando los registros recientes en busca de problemas conocidos`,bundleStepBuild:`Creando el archivo ZIP del paquete de soporte`},fileManager:{title:`Gestor de archivos`,subtitle:`Organice y gestione sus archivos de impresión`,uploadFiles:`Subir archivos`,newFolder:`Nueva carpeta`,folderName:`Nombre de la carpeta`,folderNamePlaceholder:`p. ej., Piezas funcionales`,renameFile:`Renombrar archivo`,renameFolder:`Renombrar carpeta`,invalidFilenameChar:`El carácter "{{char}}" no está permitido en nombres de archivos de impresión. La tarjeta SD de la impresora rechaza: < > : " / \\ | ? *`,moveFiles:`Mover {{count}} archivo(s)`,rootNoFolder:`Raíz (sin carpeta)`,current:`actual`,linkFolder:`Vincular carpeta`,linkFolderDescription:`Vincule "{{name}}" a un proyecto o archivo para un acceso rápido.`,project:`Proyecto`,archive:`Archivo`,noProjectsFound:`No se encontraron proyectos`,noArchivesFound:`No se encontraron archivos`,unlink:`Desvincular`,link:`Vincular`,dragDropFiles:`Arrastre y suelte archivos aquí`,dropFilesHere:`Suelte archivos aquí`,releaseToUpload:`Suelte para subir`,orClickToBrowse:`o haga clic para examinar`,allFileTypesSupported:`Se admiten todos los tipos de archivo. Los archivos ZIP se extraerán.`,zipFilesDetected:`Archivos ZIP detectados`,zipExtractOptions:`Los archivos ZIP se extraerán. Elija cómo gestionar la estructura de carpetas:`,preserveZipStructure:`Conservar la estructura de carpetas del ZIP`,createFolderFromZip:`Crear una carpeta a partir del nombre del archivo ZIP`,stlThumbnailGeneration:`Generación de miniaturas STL`,zipMayContainStl:`Los archivos ZIP pueden contener archivos STL. Se pueden generar miniaturas durante la extracción.`,thumbnailsCanBeGenerated:`Se pueden generar miniaturas para los archivos STL. Los modelos grandes pueden tardar más en procesarse.`,generateThumbnailsForStl:`Generar miniaturas para los archivos STL`,threemfDetected:`Archivos 3MF detectados`,threemfExtractionInfo:`El modelo de impresora, el material, el color y los ajustes de impresión se extraerán automáticamente de los archivos 3MF.`,willBeExtracted:`Se extraerá`,filesExtracted:`{{count}} archivos extraídos`,uploadComplete:`Subida completada: {{succeeded}} con éxito`,uploadFailed:`Error al subir`,zipFilesFailed:`{{count}} archivos fallidos`,uploading:`Subiendo...`,changeLink:`Cambiar enlace...`,linkTo:`Vincular a...`,linkToProjectOrArchive:`Vincular a un proyecto o archivo`,addToQueue:`Añadir a la cola`,schedulePrint:`Programar`,generateThumbnail:`Generar miniatura`,generateThumbnails:`Generar miniaturas`,generateThumbnailsForMissing:`Generar miniaturas para los archivos STL que no las tienen`,gridView:`Vista de cuadrícula`,listView:`Vista de lista`,lowDiskSpaceWarning:`Advertencia de poco espacio en disco`,lowDiskSpaceDetails:`Solo {{free}} libres de {{total}} en total. El umbral está establecido en {{threshold}} GB en los ajustes.`,files:`Archivos`,folders:`Carpetas`,size:`Tamaño`,free:`Libre`,allFiles:`Todos los archivos`,allExternal:`Externos`,externalIsEmpty:`Sin archivos externos`,externalEmptyDescription:`Los archivos de tus carpetas externas vinculadas aparecerán aquí.`,wrap:`Ajustar`,enableTextWrapping:`Activar el ajuste de texto`,disableTextWrapping:`Desactivar el ajuste de texto`,collapse:`Contraer`,collapseFoldersByDefault:`Contraer las carpetas de forma predeterminada`,expandFoldersByDefault:`Expandir las carpetas de forma predeterminada`,folderSort:`Ordenar carpetas`,folderSortByName:`Por nombre`,folderSortByActivity:`Por actividad reciente`,dragToResizeTooltip:`Arrastre para redimensionar, doble clic para restablecer`,searchFiles:`Buscar archivos...`,searchSubfoldersHint:`Incluyendo subcarpetas`,readme:{truncated:`Truncado`},tags:{title:`Etiquetas`,subtitle:`Etiqueta archivos para filtros transversales — juguetes, apto para niños, solo PETG, lo que necesites.`,manage:`Etiquetas`,manageTitle:`Gestionar el catálogo de etiquetas`,add:`Nueva etiqueta`,edit:`Renombrar etiqueta`,name:`Nombre`,fileCount:`Archivos`,empty:`Aún no hay etiquetas. Crea una para empezar a etiquetar archivos.`,noMatches:`No hay etiquetas que coincidan.`,createPlaceholder:`p. ej. juguetes, apto-niños, petg`,createButton:`Crear`,nameRequired:`El nombre es obligatorio.`,searchPlaceholder:`Filtrar etiquetas...`,created:`Etiqueta creada.`,updated:`Etiqueta renombrada.`,deleted:`Etiqueta eliminada.`,saveFailed:`No se pudo guardar la etiqueta.`,deleteFailed:`No se pudo eliminar la etiqueta.`,applyFailed:`No se pudieron aplicar las etiquetas.`,applyAdd:`Añadir etiquetas`,applyRemove:`Quitar etiquetas`,applyAddSuccess:`Se añadieron {{count}} etiqueta(s) en {{files}} archivo(s).`,applyRemoveSuccess:`Se quitaron {{count}} etiqueta(s) en {{files}} archivo(s).`,actionAdd:`Añadir a los archivos seleccionados`,actionRemove:`Quitar de los archivos seleccionados`,tagAction:`Etiquetar`,bulkTitle:`Etiquetar {{count}} archivo(s) seleccionado(s)`,bulkTooltip:`Añadir o quitar etiquetas en cada archivo seleccionado.`,noPermission:`No tienes permiso para etiquetar archivos.`,filterLabel:`Filtrando por:`,clearAll:`Limpiar todo`,confirmDelete:`¿Eliminar la etiqueta "{{name}}"?`,confirmDeleteMessage:`Esto elimina la etiqueta del catálogo. Los archivos conservan sus otras etiquetas.`,confirmDeleteInUseMessage:`Esta etiqueta está en {{count}} archivo(s). Al eliminarla desaparece de todos; los archivos en sí no se tocan.`,editAria:`Editar {{name}}`,deleteAria:`Eliminar {{name}}`},allTypes:`Todos los tipos`,prints:`Impresiones`,ascending:`Ascendente`,descending:`Descendente`,resultsCount:`{{showing}} de {{total}} archivos`,selectAll:`Seleccionar todo`,deselectAll:`Deseleccionar todo`,selected:`{{count}} seleccionados`,adding:`Añadiendo...`,loadingFiles:`Cargando archivos...`,folderIsEmpty:`La carpeta está vacía`,noFilesYet:`Aún no hay archivos`,folderEmptyDescription:`Suba archivos o mueva archivos a esta carpeta para empezar.`,noFilesDescription:`Suba archivos para empezar a organizar sus archivos relacionados con la impresión.`,noMatchingFiles:`No hay archivos coincidentes`,noMatchingFilesDescription:`Ningún archivo coincide con su búsqueda o los criterios de filtro actuales.`,clearFilters:`Borrar filtros`,printedCount:`Impreso {{count}} veces`,uploadedBy:`Subido por`,deleteFolder:`Eliminar carpeta`,deleteFile:`Eliminar archivo`,deleteFilesCount:`Eliminar {{count}} archivos`,deleteFolderConfirm:`¿Está seguro de que desea eliminar esta carpeta? Todos los archivos que contiene también se eliminarán.`,deleteFileConfirm:`¿Está seguro de que desea eliminar este archivo?`,deleteFilesConfirm:`¿Está seguro de que desea eliminar {{count}} archivos seleccionados? Esta acción no se puede deshacer.`,deleting:`Eliminando...`,noPermissionRenameFolder:`No tiene permiso para renombrar carpetas`,noPermissionLinkFolder:`No tiene permiso para vincular carpetas`,noPermissionDeleteFolder:`No tiene permiso para eliminar carpetas`,noPermissionPrint:`No tiene permiso para imprimir`,noPermissionAddToQueue:`No tiene permiso para añadir a la cola`,noPermissionSlice:`No tiene permiso para laminar archivos`,noPermissionDownload:`No tiene permiso para descargar archivos`,noPermissionRenameFile:`No tiene permiso para renombrar este archivo`,noPermissionGenerateThumbnail:`No tiene permiso para generar miniaturas`,noPermissionDeleteFile:`No tiene permiso para eliminar este archivo`,noPermissionCreateFolder:`No tiene permiso para crear carpetas`,noPermissionUpload:`No tiene permiso para subir archivos`,noPermissionMoveFiles:`No tiene permiso para mover archivos`,noPermissionDeleteFiles:`No tiene permiso para eliminar archivos`,linkExternal:`Vincular externa`,linkExternalFolder:`Vincular carpeta externa`,linkExternalFolderDescription:`Monte un directorio del host (NAS, USB, recurso compartido de red) en el gestor de archivos. Los archivos no se copian — se accede a ellos directamente desde la ruta original.`,externalFolderNamePlaceholder:`p. ej., Impresiones del NAS`,externalPath:`Ruta del host`,externalPathHelp:`Ruta absoluta al directorio en el host de Docker. Debe estar montado por enlace en el contenedor.`,readOnly:`Solo lectura`,readOnlyHelp:`impide las subidas y eliminaciones`,showHiddenFiles:`Mostrar archivos ocultos (con punto)`,externalFolder:`Carpeta externa`,scanFolder:`Escanear`,toast:{folderCreated:`Carpeta creada`,folderDeleted:`Carpeta eliminada`,fileDeleted:`Archivo eliminado`,filesDeleted:`Se eliminaron {{count}} archivos`,filesMoved:`Archivos movidos`,folderLinked:`Carpeta vinculada`,folderUnlinked:`Carpeta desvinculada`,externalFolderLinked:`Carpeta externa vinculada y escaneada`,folderScanned:`Escaneo completado: {{added}} añadidos, {{removed}} eliminados`,addedToQueue:`Se añadieron {{count}} archivo(s) a la cola`,addedToQueuePartial:`Se añadieron {{added}} archivo(s), {{failed}} fallidos`,failedToAddToQueue:`Error al añadir los archivos: {{error}}`,fileRenamed:`Archivo renombrado`,folderRenamed:`Carpeta renombrada`,thumbnailsGenerated:`Se generaron {{count}} miniatura(s)`,thumbnailsGeneratedPartial:`Se generaron {{succeeded}} miniatura(s), {{failed}} fallidas`,noStlMissingThumbnails:`No hay archivos STL sin miniaturas`,failedToGenerateThumbnails:`Error al generar las miniaturas: {{error}}`,thumbnailGenerated:`Miniatura generada`,failedToGenerateThumbnail:`Error al generar la miniatura: {{error}}`}},projects:{title:`Proyectos`,subtitle:`Organice y haga el seguimiento de sus proyectos de impresión 3D`,newProject:`Nuevo proyecto`,editProject:`Editar proyecto`,deleteProject:`Eliminar proyecto`,projectName:`Nombre del proyecto`,description:`Descripción`,noProjects:`Aún no hay proyectos`,noProjectsFiltered:`No hay proyectos {{status}}`,noProjectsFilteredHelp:`No tiene ningún proyecto {{status}}. Los proyectos aparecerán aquí cuando cambie su estado.`,createFirst:`Cree su primer proyecto para empezar a organizar impresiones relacionadas, hacer el seguimiento del progreso y gestionar sus construcciones.`,createFirstButton:`Cree su primer proyecto`,create:`Crear`,files:`Archivos`,prints:`Impresiones`,plates:`camas`,parts:`piezas`,lastModified:`Última modificación`,deleteConfirm:`¿Está seguro de que desea eliminar este proyecto? Los archivos y los elementos de la cola se desvincularán pero no se eliminarán.`,addFiles:`Añadir archivos`,removeFile:`Quitar archivo`,viewDetails:`Ver detalles`,namePlaceholder:`p. ej., Construcción de Voron 2.4`,descriptionPlaceholder:`Descripción opcional...`,urlLabel:`URL`,urlPlaceholder:`https://makerworld.com/...`,urlInvalid:`La URL debe empezar por http:// o https://`,openExternalUrl:`Abrir la URL del proyecto`,coverImageLabel:`Foto de portada`,coverImageAlt:`Foto de portada del proyecto`,coverImageUpload:`Subir`,coverImageReplace:`Reemplazar`,coverImageRemove:`Quitar`,color:`Color`,targetPlates:`Camas objetivo`,targetPlatesPlaceholder:`p. ej., 25`,targetPlatesHelp:`Número de trabajos de impresión`,targetParts:`Piezas objetivo`,targetPartsPlaceholder:`p. ej., 150`,targetPartsHelp:`Total de objetos necesarios`,tagsLabel:`Etiquetas (separadas por comas)`,tagsPlaceholder:`p. ej., voron, funcional, regalo`,dueDate:`Fecha límite`,priority:`Prioridad`,priorityLow:`Baja`,priorityNormal:`Normal`,priorityHigh:`Alta`,priorityUrgent:`Urgente`,statusActive:`Activo`,statusCompleted:`Completado`,statusArchived:`Archivado`,done:`Hecho`,completed:`completadas`,failed:`fallidas`,inQueue:`en cola`,noPrintsYet:`Aún no hay impresiones`,printJobs:`Trabajos de impresión (camas)`,partsPrinted:`Piezas impresas`,failedParts:`Piezas fallidas`,import:`Importar`,export:`Exportar`,importProject:`Importar proyecto`,exportAll:`Exportar todos los proyectos`,loading:`Cargando proyectos...`,noEditPermission:`No tiene permiso para editar proyectos`,noDeletePermission:`No tiene permiso para eliminar proyectos`,noCreatePermission:`No tiene permiso para crear proyectos`,noImportPermission:`No tiene permiso para importar proyectos`,noExportPermission:`No tiene permiso para exportar proyectos`,toast:{created:`Proyecto creado`,updated:`Proyecto actualizado`,deleted:`Proyecto eliminado`,imported:`Proyecto importado`,multipleImported:`{{count}} proyectos importados`,importFailed:`Error en la importación`,exported:`Proyectos exportados (solo metadatos)`}},projectDetail:{notFound:`Proyecto no encontrado`,backToProjects:`Volver a Proyectos`,export:`Exportar`,exportProject:`Exportar proyecto`,noExportPermission:`No tiene permiso para exportar proyectos`,noEditPermission:`No tiene permiso para editar proyectos`,partOf:`Parte de:`,priorityLabel:`Prioridad:`,noPrints:`Aún no hay impresiones en este proyecto`,status:{active:`Activo`,completed:`Completado`,archived:`Archivado`},priority:{low:`Baja`,normal:`Normal`,high:`Alta`,urgent:`Urgente`},dueDate:{overdue:`Atrasado`,today:`Vence hoy`,daysLeft:`Quedan {{count}} días`},progress:{platesProgress:`Progreso de camas`,partsProgress:`Progreso de piezas`,printJobs:`trabajos de impresión`,parts:`piezas`,percentComplete:`{{percent}}% completado`,remaining:`{{count}} restantes`},stats:{printJobs:`Trabajos de impresión`,total:`total`,failed:`{{count}} fallidos`,partsPrinted:`{{count}} piezas impresas`,printTime:`Tiempo de impresión`,filamentUsed:`Filamento usado`},cost:{title:`Seguimiento de costes`,filamentCost:`Coste del filamento`,energy:`Energía`,totalCost:`Coste total`,total:`Total`,includesBom:`incl. lista de materiales`,budget:`Presupuesto`,remaining:`Restante`},subProjects:{title:`Subproyectos ({{count}})`},notes:{title:`Notas`,noEditPermission:`No tiene permiso para editar notas`,placeholder:`Añada notas sobre este proyecto...`,empty:`Aún no hay notas. Haga clic en Editar para añadir notas.`},files:{title:`Archivos`,linkFolders:`Vincule carpetas del gestor de archivos`,forQuickAccess:`a este proyecto para un acceso rápido.`,fileCount:`{{count}} archivo(s)`,empty:`No hay carpetas vinculadas. Vaya al gestor de archivos y vincule una carpeta a este proyecto.`,noFiles:`No hay archivos en esta carpeta.`,print:`Imprimir ahora`,addToQueue:`Añadir a la cola`},bom:{title:`Lista de materiales`,acquired:`{{completed}}/{{total}} adquiridos`,showAll:`Mostrar todo`,hideDone:`Ocultar los hechos`,addPart:`Añadir pieza`,noAddPermission:`No tiene permiso para añadir piezas`,partNamePlaceholder:`Nombre de la pieza (p. ej., tornillos M3x8)`,partName:`Nombre de la pieza`,qty:`Cant.`,price:`Precio ({{currency}})`,sourcingUrlPlaceholder:`URL de aprovisionamiento (opcional)`,remarksPlaceholder:`Observaciones (opcional)`,deletePart:`Eliminar pieza`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"?`,noUpdatePermission:`No tiene permiso para actualizar piezas`,noEditPermission:`No tiene permiso para editar piezas`,noDeletePermission:`No tiene permiso para eliminar piezas`,totalCost:`Coste total:`,empty:`No hay piezas en la lista de materiales. Añada hardware, componentes electrónicos u otros componentes para hacer el seguimiento de lo que hay que aprovisionar.`},timeline:{title:`Cronología de actividad`,empty:`Aún no hay actividad.`},template:{saveAsTemplate:`Guardar como plantilla`,noCreatePermission:`No tiene permiso para crear plantillas`},queue:{title:`Cola`,viewAll:`Ver todo`,printing:`{{count}} imprimiendo`,queued:`{{count}} en cola`},prints:{title:`Impresiones ({{count}})`},toast:{projectUpdated:`Proyecto actualizado`,partAdded:`Pieza añadida`,partRemoved:`Pieza eliminada`,exportFailed:`Error en la exportación`,projectExported:`Proyecto exportado`,templateCreated:`Plantilla creada`}},system:{title:`Información del sistema`,version:`Versión`,uptime:`Tiempo de actividad`,cpuUsage:`Uso de la CPU`,memoryUsage:`Uso de la memoria`,diskUsage:`Uso del disco`,networkInfo:`Información de la red`,logs:`Registros`,debugMode:`Modo de depuración`,enableDebug:`Activar el registro de depuración`,disableDebug:`Desactivar el registro de depuración`,downloadLogs:`Descargar registros`,clearLogs:`Borrar registros`,dockerInfo:`Información de Docker`,containerName:`Nombre del contenedor`,imageName:`Nombre de la imagen`,platform:`Plataforma`,architecture:`Arquitectura`},sponsors:{sectionTitle:`Independiente y financiado por la comunidad`,tagline:`Bambuddy es gratuito y seguirá siéndolo porque hay quien decide apoyarlo. Sin VC, sin dependencia de la nube.`,viewSupporters:`Ver patrocinadores`,toastPrints:`Has completado {{count}} impresiones con Bambuddy. Bambuddy sigue siendo gratuito gracias a quienes lo apoyan.`,toastCost:`Has rastreado {{total}} de filamento con Bambuddy. Mira quién mantiene el proyecto independiente.`,toastArchives:`{{count}} impresiones archivadas con Bambuddy. Mira quién lo mantiene independiente.`,toastAnniversary:`¡Un año con Bambuddy! Mira quién mantiene el proyecto independiente.`,toastVersionUpdate:`Actualizado a v{{version}}. Bambuddy sigue siendo gratuito gracias a quienes lo apoyan.`},library:{title:`Biblioteca de filamentos`,addFilament:`Añadir filamento`,editFilament:`Editar filamento`,deleteFilament:`Eliminar filamento`,vendor:`Proveedor`,material:`Material`,color:`Color`,kFactor:`Factor K`,temperature:`Temperatura`,noFilaments:`No hay filamentos en la biblioteca`,deleteConfirm:`¿Está seguro de que desea eliminar este filamento?`,importFromPrinter:`Importar desde la impresora`,exportToFile:`Exportar a un archivo`},slice:{title:`Laminar modelo`,action:`Laminar`,actionAll:`Laminar las {{count}} bandejas`,actionAllTitle:`Laminar todas las bandejas en una salida única de varias bandejas (un solo archivo). La selección de filamento cubre cada hueco que defina el proyecto.`,allPlatesToggle:`Laminar las {{count}} bandejas`,slicing:`Laminando…`,printer:`Perfil de impresora`,process:`Perfil de proceso`,filament:`Perfil de filamento`,filamentSlot:`Filamento {{index}} ({{type}})`,selectPreset:`— Seleccione un preajuste —`,loadingPresets:`Cargando preajustes…`,analyzingPlateFilaments:`Analizando los filamentos de la cama…`,analyzingPlateFilamentsHint:`Ejecutando un laminado de vista previa para descubrir qué ranuras del AMS usa esta cama. Después se almacena en caché — volver a abrir es instantáneo.`,previewToast:`Analizando {{name}} — {{elapsed}}`,previewWithProgress:`Analizando {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,notUsedByPlate:`— no usado por esta cama`,noPresetsForSlot:`No hay preajustes disponibles`,otherPrinters:`Otras impresoras`,presetsLoadFailed:`Error al cargar los preajustes. Abra Ajustes → Perfiles para importarlos primero.`,refreshPresets:`Actualizar`,refreshPresetsTitle:`Actualizar preajustes — recuperar los listados más recientes de la nube y los paquetes (úselo tras eliminar un preajuste en Bambu Studio o Bambu Handy)`,allPresetsRequired:`Deben seleccionarse todos los preajustes`,enqueuing:`Enviando el trabajo de laminado…`,queued:`En cola…`,failed:`Error al laminar. Consulte los registros del contenedor auxiliar del laminador.`,startedToast:`Laminando {{name}} en segundo plano…`,queuedToast:`En cola: {{name}} — {{elapsed}}`,runningToast:`Laminando {{name}} — {{elapsed}}`,runningWithProgress:`{{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,runningWithProgressMultiPlate:`Bandeja {{plateIndex}} de {{plateCount}} • {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,completedToast:`{{name}} laminado`,failedTitle:`Error al laminar`,failedToast:`Error al laminar {{name}}: {{detail}}`,tier:{local:`Importado`,cloud:`Bambu Cloud`,orcaCloud:`Orca Cloud`,standard:`Estándar`},cloud:{notAuthenticated:`Inicie sesión en Bambu Cloud (Ajustes → Perfiles → Bambu Cloud) para ver sus preajustes de la nube.`,expired:`La sesión de Bambu Cloud ha caducado — inicie sesión de nuevo para actualizar sus preajustes de la nube.`,unreachable:`Bambu Cloud no es accesible en este momento. Los preajustes locales y estándar siguen funcionando.`},orcaCloud:{notAuthenticated:`Inicia sesión en Orca Cloud (Perfiles → Orca Cloud) para ver tus preajustes Orca.`,expired:`Sesión de Orca Cloud caducada — inicia sesión de nuevo para actualizar tus preajustes Orca.`,unreachable:`Orca Cloud no está disponible ahora. Otros preajustes siguen funcionando.`},bedType:{label:`Cama de impresión`,auto:`Automático (usar el preajuste de proceso)`,coolPlate:`Cool Plate`,coolPlateSuperTack:`Cool Plate SuperTack`,engineering:`Engineering Plate`,highTemp:`High Temp Plate`,texturedPEI:`Textured PEI Plate`,smoothPEI:`Smooth PEI Plate`}},spoolman:{title:`Integración con Spoolman`,enabled:`Spoolman activado`,url:`URL de Spoolman`,connected:`Conectado`,disconnected:`No conectado`,testConnection:`Probar conexión`,sync:`Sincronizar`,syncing:`Sincronizando...`,lastSync:`Última sincronización`,linkToSpoolman:`Vincular a Spoolman`,openInSpoolman:`Abrir en Spoolman`,unlinkSpool:`Desvincular bobina`,unlinkConfirmTitle:`¿Desasignar la bobina?`,unlinkConfirmMessage:`Esto quitará la bobina de esta ranura. Los datos de la bobina en sí permanecerán sin cambios.`,selectSpool:`Seleccionar bobina`,noUnlinkedSpools:`No hay bobinas sin asignar disponibles`,linkSuccess:`Bobina asignada correctamente`,linkFailed:`Error al asignar la bobina`,unlinkSuccess:`Bobina desasignada correctamente`,unlinkFailed:`Error al desasignar la bobina`,linkedSpool:`Bobina asignada`,spoolId:`ID de la bobina`,fillSourceLabel:`(Spoolman)`,weight:`Peso`,remaining:`Restante`,disableWeightSync:`Desactivar la sincronización del peso estimado del AMS`,disableWeightSyncDesc:`No actualizar la capacidad restante a partir de las estimaciones del AMS. Use esto si prefiere el seguimiento del uso de Spoolman a las estimaciones del AMS basadas en porcentajes. Las bobinas nuevas seguirán usando la estimación del AMS como su peso inicial.`,reportPartialUsage:`Informar del uso parcial en las impresiones fallidas`,reportPartialUsageDesc:`Cuando una impresión falla o se cancela, informar del filamento estimado usado hasta ese punto según el progreso de las capas.`},locations:{title:`Ubicaciones de almacenamiento`,subtitle:`Gestione estantes, cajones y otros lugares físicos para sus bobinas`,add:`Añadir ubicación`,addShort:`Añadir`,edit:`Editar ubicación`,name:`Nombre`,spools:`Bobinas`,empty:`Aún no hay ubicaciones de almacenamiento. Cree su primer estante o cajón.`,manage:`Ubicaciones`,createPlaceholder:`p. ej. Estante A, Cajón 1`,nameRequired:`El nombre de la ubicación es obligatorio`,created:`Ubicación creada`,updated:`Ubicación actualizada`,deleted:`Ubicación eliminada`,saveFailed:`No se pudo guardar la ubicación`,deleteFailed:`No se pudo eliminar la ubicación`,deleteBlocked:`Retire todas las bobinas de esta ubicación antes de eliminarla`,confirmDelete:`¿Eliminar «{{name}}»?`,confirmDeleteMessage:`Esta ubicación se eliminará del catálogo. Mueva las bobinas primero.`},inventory:{title:`Inventario de bobinas`,subtitle:`Gestione sus bobinas`,addToInventory:`Añadir al inventario`,addToInventoryPending:`Añadiendo...`,addToInventorySuccess:`Bobina añadida al inventario`,addToInventoryFailed:`No se pudo añadir la bobina al inventario`,unknownSpoolTitle:`Nuevo filamento detectado`,unknownSpoolMessage:`Se ha detectado una bobina con una etiqueta RFID desconocida en {{location}}. ¿Añadirla a su inventario ahora?`,unknownSpoolSlot:`Ranura`,bulk:{selectAllVisible:`Seleccionar todo lo visible`,selectRow:`Seleccionar fila`,selectGroup:`Seleccionar grupo`,selectionCount:`{{count}} seleccionadas`,edit:`Editar`,printLabels:`Imprimir etiquetas`,resetUsage:`Restablecer uso`,restore:`Restaurar`,archive:`Archivar`,delete:`Eliminar`,clearSelection:`Limpiar selección`,editTitle:`Edición masiva de bobinas`,editSubtitle:`Se aplica a {{count}} bobinas seleccionadas. Solo se actualizan los campos marcados.`,editHint:`Escriba en un campo para marcarlo para actualización — solo se envían las filas marcadas. Los campos vacíos no cambian las bobinas (vaciar campos solo se hace por bobina).`,useCustom:`Usar "{{value}}"`,toggleField:`Activar la actualización de este campo`,changeCount:`Se actualizarán {{count}} campos.`,applyPending:`Aplicando...`,applyButton:`Aplicar a {{count}} bobinas`,deleteTitle:`Eliminar bobinas seleccionadas`,archiveTitle:`Archivar bobinas seleccionadas`,restoreTitle:`Restaurar bobinas seleccionadas`,resetUsageTitle:`Restablecer uso de bobinas seleccionadas`,deleteMessage:`¿Eliminar permanentemente {{count}} bobinas? Esto no se puede deshacer.`,archiveMessage:`¿Archivar {{count}} bobinas? Se pueden restaurar más tarde.`,restoreMessage:`¿Restaurar {{count}} bobinas archivadas?`,resetUsageMessage:`¿Restablecer el contador "Total consumido" en {{count}} bobinas? El peso restante se conserva.`,updateSuccess:`{{count}} bobinas actualizadas`,updateFailed:`Actualización masiva fallida`,updatePartial:`{{ok}} bobinas actualizadas, {{failed}} fallidas`,updateAllFailed:`Las {{count}} actualizaciones fallaron — la selección se mantiene para reintentar`,deleteSuccess:`{{count}} bobinas eliminadas`,deleteFailed:`Eliminación masiva fallida`,deletePartial:`{{ok}} bobinas eliminadas, {{failed}} fallidas`,deleteAllFailed:`Las {{count}} eliminaciones fallaron — la selección se mantiene para reintentar`,archiveSuccess:`{{count}} bobinas archivadas`,archiveFailed:`Archivado masivo fallido`,archivePartial:`{{ok}} bobinas archivadas, {{failed}} fallidas`,archiveAllFailed:`Los {{count}} archivados fallaron — la selección se mantiene para reintentar`,restoreSuccess:`{{count}} bobinas restauradas`,restoreFailed:`Restauración masiva fallida`,restorePartial:`{{ok}} bobinas restauradas, {{failed}} fallidas`,restoreAllFailed:`Las {{count}} restauraciones fallaron — la selección se mantiene para reintentar`,invalidHex:`Introduzca 6 caracteres hex (RRGGBB) u 8 (RRGGBBAA). De lo contrario el campo no se aplicará.`},spoolmanMixedContentTitle:`Spoolman no se puede cargar por HTTPS — contenido mixto bloqueado por su navegador`,spoolmanMixedContentBody:`Bambuddy se sirve por HTTPS (mediante su proxy inverso), pero su URL de Spoolman sigue siendo HTTP sin cifrar. Los navegadores bloquean el contenido mixto por seguridad, por lo que la interfaz integrada de Spoolman no se puede mostrar. Spoolman debe ser accesible por HTTPS para que esto funcione.`,spoolmanMixedContentFixReverseProxy:`Ponga Spoolman tras el mismo proxy inverso que Bambuddy (Traefik / Nginx / Caddy) con HTTPS y luego actualice la URL de Spoolman en Ajustes a la nueva dirección HTTPS.`,spoolmanMixedContentFixOpenNewTab:`Como solución alternativa, abra Spoolman en una pestaña nueva del navegador por HTTP — las reglas de contenido mixto solo se aplican a los marcos integrados, por lo que una pestaña independiente sí funciona.`,spoolmanOpenInNewTab:`Abrir Spoolman en una pestaña nueva`,labels:{title:`Imprimir etiquetas de bobinas`,selectedCount:`{{count}} seleccionadas`,pickSpools:`Elija para qué bobinas imprimir etiquetas:`,searchPlaceholder:`Buscar nombre, marca o n.º de ID`,filterByMaterial:`Material:`,allMaterials:`Todos`,selectVisible:`Seleccionar todas las visibles ({{count}})`,deselectVisible:`Deseleccionar las visibles`,clearAll:`Borrar todo`,noSpoolsToShow:`No hay bobinas que mostrar. Ajuste su filtro e inténtelo de nuevo.`,noMatches:`Ninguna bobina coincide con la búsqueda o el filtro actuales.`,printOne:`Imprimir etiqueta para esta bobina`,printLabels:`Imprimir etiquetas…`,bulkTitle:`Elija las bobinas para las que imprimir etiquetas de las {{count}} mostradas actualmente`,noSpoolsTitle:`No hay bobinas que etiquetar`,error:`No se pudieron generar las etiquetas: {{msg}}`,sortBy:{label:`Ordenar:`,id:`Por ID`,color:`Por color`},templates:{amsHolderSmall:{label:`Soporte de AMS — pequeño (74 × 33 mm)`,hint:`Una etiqueta por página; coincide con la etiqueta imprimible del modelo 752566 de MakerWorld (AMS Filament Label Holder).`},amsHolderLarge:{label:`Soporte de AMS — grande (75 × 55 mm)`,hint:`Una etiqueta por página; encaja en la variante con inserto de cartulina del AMS Filament Label Holder. Lo bastante amplia para muestra de color, marca, material, ID y código QR.`},box40x30:{label:`Etiqueta de caja (40 × 30 mm)`,hint:`Una etiqueta por página; tamaño de rollo DK/Brother habitual, adecuado para etiquetas de bolsas de filamento y cajas de almacenamiento.`},box:{label:`Box label (62 × 29 mm)`,hint:`Una etiqueta por página; dimensionada para las etiquetas pequeñas de Brother PT/QL y Dymo.`},averyL7160:{label:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,hint:`Hojas de tamaño UE; 21 etiquetas por página A4.`},avery5160:{label:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,hint:`Hojas de tamaño EE. UU.; 30 etiquetas por página Letter.`}}},csv:{importButton:`Importar CSV`,exportButton:`Exportar CSV`,modalTitle:`Importar bobinas desde CSV`,selectFile:`Elige un archivo CSV o arrástralo aquí`,dragHint:`Encabezado: material (obligatorio), brand, subtype, color_name, rgba, …`,parsing:`Leyendo archivo…`,previewError:`No se pudo leer el archivo CSV`,validCount:`{{count}} válidas`,errorCount:`{{count}} con error`,skippedCount:`{{count}} omitidas`,colRow:`Fila`,colStatus:`Estado`,colColor:`Color`,colorResolved:`Color rellenado desde el catálogo`,colorCrossMaterial:`Color tomado de un material diferente — sin coincidencia exacta en el catálogo`,duplicateExisting:`Ya existe una bobina con este material, marca y color — se importará igualmente como una bobina nueva`,spoolmanHint:`En modo Spoolman, usa la importación/exportación CSV integrada de Spoolman.`,importValidRows:`Importar {{count}} filas válidas`,noValidRows:`Sin filas válidas`,importing:`Importando…`,importSuccess:`{{count}} bobinas importadas`,importError:`Error al importar`,exportError:`Error al exportar`},addSpool:`Añadir bobina`,editSpool:`Editar bobina`,copySpool:`Copiar bobina`,material:`Material`,selectMaterial:`Seleccionar material...`,subtype:`Subtipo`,brand:`Marca`,searchBrand:`Buscar marca...`,useCustomBrand:`Usar "{{brand}}"`,useCustomMaterial:`Usar material personalizado: {{material}}`,colorName:`Nombre del color`,colorNamePlaceholder:`Blanco jade, Rojo fuego...`,color:`Color`,hexColor:`Color hexadecimal`,pickColor:`Elegir color personalizado`,labelWeight:`Peso de la etiqueta`,coreWeight:`Peso de la bobina vacía`,searchSpoolWeight:`Buscar peso de la bobina...`,weightUsed:`Usado`,currentWeight:`Peso restante`,measuredWeight:`Peso medido`,spoolName:`Bobina`,costPerKg:`Coste por kg`,storageLocation:`Ubicación de almacenamiento`,storageLocationPlaceholder:`p. ej. Estante A, Cajón 1`,openInInventory:`Abrir en el inventario`,measuredWeightError:`El peso medido debe estar entre {{min}} g y {{max}} g.`,slicerFilament:`Filamento del laminador`,slicerFilamentName:`Nombre del preajuste del laminador`,slicerPreset:`Preajuste del laminador`,searchPresets:`Buscar preajustes de filamento...`,selectedPreset:`Seleccionado`,noPresetsFound:`No se encontraron preajustes`,tempOverrides:`Anulaciones de temperatura`,note:`Nota`,notePlaceholder:`Cualquier nota adicional sobre esta bobina...`,category:`Categoría`,categoryPlaceholder:`p. ej. Producción, Prototipo, Cliente A`,categoryNone:`Sin categoría`,storageLocationNone:`Sin ubicación establecida`,lowStockThresholdOverride:`Umbral de existencias bajas (esta bobina)`,lowStockThresholdOverrideHelp:`Déjelo en blanco para usar el umbral global ({{global}}%).`,clearRfid:`Borrar etiqueta RFID`,rfidCleared:`Etiqueta RFID borrada`,archive:`Archivar`,restore:`Restaurar`,noSpools:`Aún no hay bobinas. Añada su primera bobina para empezar.`,noAvailableSpools:`No hay bobinas disponibles. Añada una bobina a su inventario o desasigne una de otra ranura primero.`,kProfiles:`Perfiles K`,addKProfile:`Añadir perfil K`,assignSpool:`Asignar bobina`,unassignSpool:`Desasignar`,assignSuccess:`Bobina asignada y ranura del AMS configurada`,assignPendingInsert:`Asignada. La ranura se configurará cuando inserte la bobina.`,assignFailed:`Error al asignar la bobina`,selectSpool:`Seleccione una bobina para asignar a esta ranura`,assigned:`Asignada`,assigning:`Asignando...`,searchSpools:`Buscar bobinas...`,showAllSpools:`Mostrar todas las bobinas`,spoolmanSpools:`Bobinas de Spoolman`,allMaterials:`Todos los materiales`,filterByBrand:`Filtrar por marca...`,showArchived:`Mostrar archivadas`,quickAdd:`Añadir rápido (existencias)`,quantity:`Cantidad`,stock:`Existencias`,configured:`Configurada`,spoolsCreated:`{{count}} bobinas creadas`,spoolsPartiallyCreated:`{{created}} de {{total}} bobinas creadas (algunas fallaron)`,spoolCreated:`Bobina creada`,spoolUpdated:`Bobina actualizada`,spoolDeleted:`Bobina eliminada`,deepLinkSpoolNotFound:`Bobina no encontrada`,deepLinkFetchFailed:`No se pudo cargar la bobina — inténtelo de nuevo`,spoolArchived:`Bobina archivada`,spoolRestored:`Bobina restaurada`,kProfileSaveFailed:`No se pudieron guardar los ajustes del perfil K`,syncWeightSpoolNotFound:`Bobina no encontrada — es posible que se haya eliminado`,syncWeightSpoolmanUnreachable:`Spoolman no es accesible — inténtelo más tarde`,syncWeightFailed:`Error al sincronizar el peso`,spoolmanUnreachable:`Spoolman no es accesible — inténtelo de nuevo más tarde`,deleteSpoolNotFound:`Bobina no encontrada — es posible que ya se haya eliminado`,deleteFailed:`Error al eliminar la bobina`,archiveSpoolNotFound:`Bobina no encontrada — es posible que ya se haya eliminado`,archiveFailed:`Error al archivar la bobina`,restoreSpoolNotFound:`Bobina no encontrada — es posible que ya se haya eliminado`,restoreFailed:`Error al restaurar la bobina`,saveFailed:`Error al guardar los cambios`,tagClearFailed:`Error al borrar la etiqueta`,deleteConfirm:`¿Está seguro de que desea eliminar esta bobina? Esto no se puede deshacer.`,archiveConfirm:`¿Está seguro de que desea archivar esta bobina?`,advancedSettings:`Ajustes avanzados`,filamentInfoTab:`Información del filamento`,paProfileTab:`Perfil PA`,filamentInfo:`Filamento`,additional:`Adicional`,loadingPresets:`Cargando preajustes de la nube...`,cloudConnected:`Nube conectada`,cloudNotConnected:`Nube no conectada (usando los valores predeterminados)`,recentColors:`Recientes`,searchColors:`Buscar colores...`,searchResults:`Resultados de búsqueda`,allColors:`Todos los colores`,commonColors:`Colores comunes`,showLess:`Mostrar menos`,showAll:`Mostrar todos`,noColorsFound:`Ningún color coincide con su búsqueda`,noResults:`No se encontraron coincidencias`,extraColorsLabel:`Colores adicionales`,extraColorsPlaceholder:`EC984C,#6CD4BC,A66EB9,D87694`,extraColorsHint:`Pegue de 2 a 8 paradas hexadecimales, separadas por comas. Se muestra como un degradado.`,extraColorsInvalid:`Se ignoró el hexadecimal no válido: {{tokens}}`,colorEffectLabel:`Efecto`,colorEffect:{none:`Ninguno`,sparkle:`Destellos`,wood:`Madera`,marble:`Mármol`,glow:`Brillante en la oscuridad`,matte:`Mate`,silk:`Seda`,galaxy:`Galaxia`,rainbow:`Arcoíris`,metal:`Metal`,translucent:`Translúcido`,gradient:`Degradado`,dualColor:`Bicolor`,triColor:`Tricolor`,multicolor:`Multicolor`},selectMaterialFirst:`Seleccione primero un material en la pestaña de información del filamento.`,noPrintersConfigured:`No hay impresoras configuradas. Añada impresoras para usar perfiles PA.`,matchingFilter:`Coincidentes`,anyBrand:`Cualquier marca`,anyVariant:`Cualquier variante`,autoSelect:`Selección automática`,matches:`coincidencias`,match:`coincidencia`,noMatches:`Sin coincidencias`,connected:`Conectada`,offline:`Desconectada`,printerOffline:`La impresora está desconectada. Conéctela para ver los perfiles de calibración.`,noKProfilesMatch:`Ningún perfil K coincide con el filamento seleccionado.`,leftNozzle:`Boquilla izquierda`,rightNozzle:`Boquilla derecha`,profilesSelected:`perfil(es) de calibración seleccionado(s)`,totalInventory:`Inventario total`,totalConsumed:`Total consumido`,byMaterial:`Por material`,inPrinter:`En la impresora`,lowStock:`Existencias bajas`,sinceTracking:`Desde que comenzó el seguimiento`,resetConsumedCounter:`Restablecer contador`,resetConsumedCounterTooltip:`Poner a cero el contador de gramos consumidos de esta bobina. El peso restante no cambia.`,resetConsumedCounterConfirm:`¿Restablecer a 0 el contador de gramos consumidos de esta bobina? Las impresiones futuras volverán a contar desde cero. La bobina en sí, su cálculo de peso restante y sus ajustes no cambian.`,resetAllConsumedCounters:`Restablecer todos los contadores`,resetAllConsumedCountersTooltip:`Poner a cero el contador de gramos consumidos de todas las bobinas. Los pesos restantes no cambian.`,resetAllConsumedCountersConfirm:`¿Restablecer a 0 el contador de gramos consumidos de las {{count}} bobinas (incluidas las archivadas)? Esto borra la estadística «Total consumido» para que las impresiones futuras cuenten desde cero. Las bobinas y los pesos restantes no cambian.`,consumedCounterReset:`Contador restablecido`,allConsumedCountersReset:`Contador restablecido para {{count}} bobina(s)`,resetConsumedCounterFailed:`Error al restablecer el contador`,loadedInAms:`Cargada en AMS/ext.`,remaining:`Restante`,weightCheck:`Comprobación de peso`,lastWeighed:`Pesada por última vez`,neverWeighed:`Nunca pesada`,search:`Buscar bobinas...`,showing:`Mostrando`,to:`a`,of:`de`,show:`Mostrar`,spools:`bobinas`,spool:`bobina`,page:`Página`,noSpoolsMatch:`No se encontraron resultados`,noSpoolsMatchDesc:`Pruebe a ajustar su búsqueda o sus filtros para encontrar lo que busca.`,active:`Activas`,archived:`Archivadas`,all:`Todas`,used:`Usada`,new:`Nueva`,clearFilters:`Borrar filtros`,table:`Tabla`,cards:`Tarjetas`,net:`Neto`,groupSimilar:`Agrupar`,groupedSpools:`{{count}} bobinas idénticas`,groupedRows:`filas`,columns:`Columnas`,configureColumns:`Configurar columnas`,configureColumnsDesc:`Arrastre para reordenar las columnas o use las flechas. Conmute la visibilidad con el icono del ojo.`,visible:`visibles`,reset:`Restablecer`,cancel:`Cancelar`,applyChanges:`Aplicar cambios`,moveUp:`Subir`,moveDown:`Bajar`,hideColumn:`Ocultar columna`,showColumn:`Mostrar columna`,linkToSpool:`Vincular a bobina`,tagLinked:`Etiqueta vinculada a la bobina`,tagLinkFailed:`Error al vincular la etiqueta`,tagAlreadyLinked:`La etiqueta ya está vinculada a otra bobina`,unknownTag:`Se detectó una etiqueta RFID desconocida`,usageHistory:`Historial de uso`,noUsageHistory:`Aún no se ha registrado ningún uso`,printName:`Nombre de la impresión`,weightConsumed:`Peso consumido`,clearHistory:`Borrar`,historyCleared:`Historial de uso borrado`,fillSourceLabel:`(Inv.)`,lowStockThresholdError:`El umbral debe estar entre 0,1 y 99,9`,assignMismatchTitle:`Discrepancia de material`,assignMismatchMessage:`El material de la bobina seleccionada "{{spoolMaterial}}" no coincide con el material de la bandeja "{{trayMaterial}}" de {{location}}. ¿Asignar de todos modos?`,assignMismatchConfirm:`Asignar de todos modos`,assignPartialMismatchMessage:`El material de la bobina "{{spoolMaterial}}" es similar pero no coincide exactamente con "{{trayMaterial}}" en {{location}}. ¿Desea continuar?`,assignProfileMismatchMessage:`El perfil de la bobina "{{spoolProfile}}" no coincide con el perfil de la bandeja "{{trayProfile}}" en {{location}}. ¿Desea continuar?`,assignReconfigureNote:`La ranura del AMS se reconfigurará para usar el perfil de la bobina.`,spoolmanFilamentCatalog:`Catálogo de filamentos de Spoolman`,pickFromSpoolmanCatalog:`Elegir del catálogo de Spoolman…`,spoolmanFilamentSelected:`Filamento seleccionado del catálogo de Spoolman`,spoolmanFilamentUnlinked:`Vínculo del catálogo de filamentos borrado`,noSpoolmanFilaments:`No se encontraron filamentos en el catálogo de Spoolman`,spoolmanFilamentColorSwatch:`Color del filamento`,spoolWeightManagedBySpoolman:`El peso de la bobina vacía se gestiona por tipo de filamento en Spoolman`,spoolmanCatalogLoadFailed:`Error al cargar el catálogo de filamentos de Spoolman`},timelapse:{title:`Time-lapse`,create:`Crear time-lapse`,download:`Descargar`,delete:`Eliminar`,preview:`Vista previa`,frameRate:`Velocidad de fotogramas`,quality:`Calidad`,processing:`Procesando...`,noTimelapses:`No hay time-lapses disponibles`},ams:{title:`AMS`,slot:`Ranura`,empty:`Vacía`,emptySlot:`Ranura vacía`,slotEmpty:`Vacía`,slotUnconfigured:`?`,emptySlotReset:`No hay filamento asignado`,unknown:`Desconocido`,humidity:`Humedad`,temperature:`Temperatura`,filamentType:`Tipo de filamento`,filamentColor:`Color`,remaining:`Restante`,history:`Historial del AMS`,noHistory:`No hay historial disponible`,configureSlot:`Configurar ranura`,externalSpool:`Bobina externa`,profile:`Perfil`,kFactor:`Factor K`,fill:`Rellenar`,configure:`Configurar`,used:`usado`,remainingUnit:`restante`},printModal:{title:`Iniciar impresión`,selectPrinter:`Seleccionar impresora`,selectPlate:`Seleccionar cama`,filamentMapping:`Mapeo de filamentos`,totalCost:`Coste total:`,slotRemainingShort:` - quedan {{grams}} g`,printSettings:`Ajustes de impresión`,bedLeveling:`Nivelación de la cama`,flowCalibration:`Calibración del flujo`,vibrationCalibration:`Calibración de vibración`,layerInspection:`Inspección de la primera capa`,timelapse:`Time-lapse`,startPrint:`Iniciar impresión`,addToQueue:`Añadir a la cola`,cancel:`Cancelar`,noPrintersAvailable:`No hay impresoras disponibles`,printerBusy:`La impresora está ocupada`,printerOffline:`La impresora está desconectada`,sameTypeDifferentColor:`Mismo tipo, color distinto`,filamentTypeNotLoaded:`Tipo de filamento no cargado`,openCalendar:`Abrir calendario`,leftNozzle:`I`,rightNozzle:`D`,leftNozzleTooltip:`Boquilla izquierda`,rightNozzleTooltip:`Boquilla derecha`,filamentOverride:`Anulación de filamento`,filamentOverrideHint:`Anule opcionalmente los filamentos para la asignación basada en el modelo. El planificador comparará con los filamentos que ha seleccionado en lugar de los valores originales del 3MF.`,originalFilament:`Original`,overrideWith:`Anular con`,resetToOriginal:`Restablecer al original`,insufficientFilamentTitle:`No hay suficiente filamento`,insufficientFilamentMessage:`Algunas bobinas asignadas tienen menos filamento restante del que necesita esta impresión:`,insufficientFilamentLine:`{{printer}} - {{slot}}: necesita {{required}} g, restante {{remaining}} g`,printAnyway:`Imprimir de todos modos`,forceColorMatch:`Forzar la coincidencia de color`,staggerPrinterStarts:`Escalonar los inicios de las impresoras`,staggerGroupSize:`Tamaño de grupo`,staggerInterval:`Intervalo (min)`,staggerPreview:`{{printers}} impresoras → {{groups}} grupos de {{size}}, iniciando cada {{interval}} min`,staggerLastGroup:`último grupo: {{count}}`,staggerTotal:`total: {{minutes}} min`,staggerToPrinters:`Escalonar en {{count}} impresoras`,gcodeInjection:`Inyectar G-code de impresión automática`},backup:{includesEncryptionKey:`Las copias de seguridad locales incluyen el archivo de clave de cifrado de MFA (DATA_DIR/.mfa_encryption_key) para que un ZIP de copia de seguridad sea autónomo. Trate el ZIP como información sensible — cualquiera que tenga el archivo puede descifrar los secretos de cliente de OIDC y los secretos TOTP que contiene.`,title:`Copia de seguridad y restauración`,createBackup:`Crear copia de seguridad`,restoreBackup:`Restaurar copia de seguridad`,restoreDescription:`Reemplazar todos los datos desde un archivo de copia de seguridad`,downloadBackup:`Descargar copia de seguridad`,uploadBackup:`Subir copia de seguridad`,lastBackup:`Última copia de seguridad`,autoBackup:`Copia de seguridad automática`,backupNow:`Hacer copia de seguridad ahora`,restoreWarning:`Advertencia: restaurar una copia de seguridad sobrescribirá todos los datos actuales.`,includeArchives:`Incluir archivos`,includeSettings:`Incluir ajustes`,includeProfiles:`Incluir perfiles`,backupSuccess:`Copia de seguridad creada correctamente`,restoreSuccess:`Copia de seguridad restaurada correctamente`,backupFailed:`Error en la copia de seguridad`,restoreFailed:`Error en la restauración`,restoreNote:`La impresora virtual se detendrá durante la restauración`,githubBackup:`Copia de seguridad en Git`,enabled:`Activada`,cloudLoginRequired:`Se requiere iniciar sesión en Bambu Cloud. Inicie sesión en Perfiles → Perfiles en la nube para activar la copia de seguridad en GitHub.`,cloudLoginRequiredShort:`Se requiere iniciar sesión en la nube`,githubDescription:`Sincronice automáticamente sus perfiles con un repositorio privado de GitHub para la copia de seguridad y el historial de versiones.`,repoIsPrivate:`El repositorio es privado — es seguro hacer copias de seguridad en él.`,repoIsPublicWarning:`El repositorio es PÚBLICO. Las copias de seguridad de Bambuddy incluyen credenciales de MQTT, tokens de Home Assistant, tokens de Prometheus, su correo de Bambu Cloud y los códigos de acceso de las impresoras mediante los perfiles K. El guardado está bloqueado hasta que haga el repositorio privado en los ajustes de su proveedor.`,repoVisibilityUnknown:`No se pudo determinar la visibilidad del repositorio. Bambuddy se niega a hacer copias de seguridad en cualquier cosa que no se confirme como privada; el guardado se bloqueará.`,repositoryUrl:`URL del repositorio`,repoUrlPlaceholderGitHub:`https://github.com/username/repo-name`,repoUrlPlaceholderGitea:`https://gitea.example.com/username/repo-name`,repoUrlPlaceholderForgejo:`https://forgejo.example.com/username/repo-name`,repoUrlPlaceholderGitLab:`https://gitlab.com/username/repo-name`,allowInsecureHttp:`Permitir HTTP no seguro`,allowInsecureHttpHint:`Actívelo para instancias autoalojadas en redes privadas sin TLS`,personalAccessToken:`Token de acceso personal`,tokenSaved:`(guardado)`,enterNewToken:`Introduzca un nuevo token para actualizar`,tokenHint:`Token de granularidad fina con permiso de lectura/escritura de Contents`,branch:`Rama`,provider:`Proveedor de Git`,providerGitHub:`GitHub`,providerGitLab:`GitLab`,providerGitea:`Gitea`,providerForgejo:`Forgejo`,manualOnly:`Solo manual`,hourly:`Cada hora`,daily:`Diaria`,weekly:`Semanal`,includeInBackup:`Incluir en la copia de seguridad`,kProfiles:`Perfiles K`,kProfilesDescription:`Calibración de avance de presión de las impresoras conectadas`,noPrintersConnected:`No hay impresoras conectadas`,printersConnected:`{{connected}}/{{total}} conectadas`,cloudProfiles:`Perfiles en la nube`,cloudProfilesDescription:`Preajustes de filamento, impresora y proceso de Bambu Cloud`,appSettings:`Ajustes de la aplicación`,appSettingsDescription:`Configuración de Bambuddy (base de datos completa)`,spoolInventory:`Inventario de bobinas`,spoolInventoryDescription:`Bobinas de filamento, historial de uso y seguimiento de costes`,printArchives:`Archivos de impresión`,printArchivesDescription:`Metadatos del historial de impresión (sin archivos gcode/3MF)`,lastBackupAt:`Última copia de seguridad:`,noBackupsYet:`Aún no hay copias de seguridad`,next:`Siguiente:`,startingBackup:`Iniciando la copia de seguridad...`,test:`Probar`,enableBackup:`Activar la copia de seguridad`,testConnection:`Probar conexión`,enterRepoUrl:`Introduzca la URL del repositorio`,enterRepoAndToken:`Introduzca la URL del repositorio y el token de acceso`,repoRequired:`La URL del repositorio es obligatoria`,tokenRequired:`El token de acceso es obligatorio`,githubBackupEnabled:`Copia de seguridad en GitHub activada`,tokenUpdated:`Token actualizado`,settingsSaved:`Ajustes guardados`,failedToSave:`Error al guardar: {{message}}`,backupCompleteFiles:`Copia de seguridad completada - {{count}} archivos actualizados`,backupSkippedNoChanges:`Copia de seguridad omitida - sin cambios`,backupFailed2:`Error en la copia de seguridad: {{message}}`,clearedLogs:`Se borraron {{count}} registros`,failedToClearLogs:`Error al borrar los registros: {{message}}`,history:`Historial`,clear:`Borrar`,date:`Fecha`,status:`Estado`,commit:`Confirmación`,localBackup:`Copia de seguridad local`,localBackupDescription:`Cree una copia de seguridad completa de sus datos de Bambuddy, incluida la base de datos, los archivos, las subidas y todos los archivos.`,downloadBackupLabel:`Descargar copia de seguridad`,completeBackupZip:`Copia de seguridad completa: base de datos + todos los archivos (ZIP)`,download:`Descargar`,preparingBackup:`Preparando la copia de seguridad...`,creatingArchive:`Creando el archivo de copia de seguridad... Esto puede tardar un rato para archivos grandes.`,downloadingFile:`Descargando el archivo de copia de seguridad...`,backupDownloaded:`Copia de seguridad descargada correctamente`,failedToCreateBackup:`Error al crear la copia de seguridad: {{message}}`,restore:`Restaurar`,restoreReplacesAll:`La restauración reemplaza todos los datos.`,restoreReplacesAllDetail:`Su base de datos y archivos actuales se reemplazarán por completo. Se requiere un reinicio tras la restauración.`,restoreConfirmTitle:`Restaurar copia de seguridad`,restoreConfirmMessage:`¿Está seguro de que desea restaurar desde "{{filename}}"? Esto reemplazará por completo su base de datos actual y todos los archivos. La aplicación deberá reiniciarse tras la restauración.`,restoreConfirmButton:`Restaurar copia de seguridad`,uploadingFile:`Subiendo el archivo de copia de seguridad...`,backupRestoredRestart:`Copia de seguridad restaurada. Reinicie Bambuddy.`,failedToRestore:`Error al restaurar la copia de seguridad. Compruebe el formato del archivo.`,reloadNow:`Recargar ahora`,creatingBackup:`Creando copia de seguridad`,restoringBackup:`Restaurando copia de seguridad`,preparing:`Preparando...`,processing:`Procesando...`,doNotClosePage:`No cierre esta página ni navegue a otra. Esta operación puede tardar varios minutos para copias de seguridad grandes.`,restoring:`Restaurando...`,restoreComplete:`Restauración completada`,restoreFailed2:`Error en la restauración`,importSettings:`Importar ajustes desde un archivo de copia de seguridad`,pleaseWaitRestoring:`Espere mientras se restauran sus datos`,selectBackupFile:`Haga clic para seleccionar el archivo de copia de seguridad (.json o .zip)`,duplicateHandling:`Cómo funciona la gestión de duplicados:`,matchPrinters:`Impresoras`,matchPrintersBy:`coincidencia por número de serie`,matchSmartPlugs:`Enchufes inteligentes`,matchSmartPlugsBy:`coincidencia por dirección IP`,matchNotificationProviders:`Proveedores de notificaciones`,matchNotificationProvidersBy:`coincidencia por nombre`,matchFilaments:`Filamentos`,matchFilamentsBy:`coincidencia por nombre + tipo + marca`,matchArchives:`Archivos`,matchArchivesBy:`coincidencia por hash del contenido (siempre se omiten)`,matchPendingUploads:`Subidas pendientes`,matchPendingUploadsBy:`coincidencia por nombre de archivo`,matchSettingsTemplates:`Ajustes y plantillas`,matchSettingsTemplatesBy:`siempre se sobrescriben`,replaceExisting:`Reemplazar los datos existentes`,keepExisting:`Conservar los datos existentes`,overwriteDescription:`Sobrescribir los elementos que ya existen con los datos de la copia de seguridad`,keepDescription:`Restaurar solo los elementos que aún no existen`,overwriteCaution:`Precaución:`,overwriteWarning:`Sobrescribir reemplazará sus configuraciones actuales con los datos de la copia de seguridad. Los códigos de acceso de las impresoras nunca se sobrescriben por seguridad.`,cancel:`Cancelar`,processingBackup:`Procesando el archivo de copia de seguridad...`,itemsRestored:`Elementos restaurados`,itemsSkipped:`Elementos omitidos`,restored:`Restaurados`,skippedAlreadyExist:`Omitidos (ya existen)`,filesCategory:`Archivos (3MF, miniaturas, etc.)`,andMore:`...y {{count}} más`,newApiKeysGenerated:`Nuevas claves API generadas`,keysShownOnce:`Estas claves solo se muestran una vez. ¡Cópielas ahora!`,copy:`Copiar`,noDataFound:`No se encontraron datos para restaurar en el archivo de copia de seguridad.`,close:`Cerrar`,scheduledBackup:`Copias de seguridad programadas`,scheduledBackupDescription:`Cree automáticamente instantáneas de copia de seguridad según una programación. El directorio de salida se puede montar en un NAS o en almacenamiento externo.`,frequency:`Frecuencia`,backupTime:`Hora`,retention:`Retención`,retentionDescription:`Número de copias de seguridad que conservar`,outputPath:`Ruta de salida`,outputPathPlaceholder:`Predeterminada: {{path}}`,outputPathDescription:`Déjelo vacío para la ubicación predeterminada`,runNow:`Ejecutar ahora`,backupFiles:`Archivos de copia de seguridad`,noScheduledBackups:`Aún no hay copias de seguridad`,deleteBackup:`Eliminar`,deleteBackupConfirm:`¿Eliminar este archivo de copia de seguridad?`,backupRunning:`Copia de seguridad en curso...`,scheduledBackupComplete:`Copia de seguridad completada correctamente`,scheduledBackupFailed:`Error en la copia de seguridad`,nextBackup:`Próxima copia de seguridad`,backupSize:`Tamaño`,localTimeHint:`Hora local ({{tz}})`,defaultPathLabel:`Predeterminada:`,categories:{settings:`Ajustes`,notification_providers:`Proveedores de notificaciones`,notification_templates:`Plantillas de notificaciones`,smart_plugs:`Enchufes inteligentes`,printers:`Impresoras`,filaments:`Filamentos`,maintenance_types:`Tipos de mantenimiento`,archives:`Archivos`,projects:`Proyectos`,pending_uploads:`Subidas pendientes`,external_links:`Enlaces externos`,api_keys:`Claves API`}},tags:{title:`Etiquetas`,addTag:`Añadir etiqueta`,editTag:`Editar etiqueta`,deleteTag:`Eliminar etiqueta`,tagName:`Nombre de la etiqueta`,tagColor:`Color de la etiqueta`,noTags:`No hay etiquetas`,deleteConfirm:`¿Está seguro de que desea eliminar esta etiqueta?`,manageTags:`Gestionar etiquetas`},uploadModal:{title:`Subir archivos 3MF`,dragDrop:`Arrastre y suelte archivos .3mf aquí`,or:`o`,browseFiles:`Examinar archivos`,extractionInfo:`El modelo de impresora se extraerá automáticamente de los metadatos del archivo 3MF.`,uploaded:`subidos`,failed:`fallidos`,uploading:`Subiendo...`,upload:`Subir`,uploadFailed:`Error al subir`},editArchive:{title:`Editar archivo`,name:`Nombre`,namePlaceholder:`Nombre de la impresión`,printer:`Impresora`,noPrinter:`Sin impresora`,project:`Proyecto`,noProject:`Sin proyecto`,itemsPrinted:`Elementos impresos`,itemsPrintedHelp:`Número de elementos producidos en este trabajo de impresión`,notes:`Notas`,notesPlaceholder:`Añada notas sobre esta impresión...`,externalLink:`Enlace externo`,externalLinkPlaceholder:`https://printables.com/model/...`,externalLinkHelp:`Enlace a Printables, Thingiverse u otra fuente`,tags:`Etiquetas`,tagsPlaceholder:`Añada etiquetas...`,addMoreTags:`Añada más etiquetas...`,matchingTags:`Coincidentes con "{{query}}"`,existingTags:`Etiquetas existentes`,clickToAdd:`(haga clic para añadir)`,status:`Estado`,failureReason:`Motivo del fallo`,selectReason:`Seleccionar motivo...`,photos:`Fotos del resultado impreso`,photosHelp:`Haga clic en + para añadir fotos de su resultado impreso`,printResult:`Resultado de la impresión`,saving:`Guardando...`,failureReasons:{adhesionFailure:`Fallo de adhesión`,spaghettiDetached:`Espagueti / Desprendido`,layerShift:`Desplazamiento de capa`,cloggedNozzle:`Boquilla obstruida`,filamentRunout:`Agotamiento del filamento`,warping:`Alabeo`,stringing:`Hilos`,underExtrusion:`Subextrusión`,powerFailure:`Corte de corriente`,userCancelled:`Cancelada por el usuario`,other:`Otro`},statuses:{completed:`Completada`,failed:`Fallida`,aborted:`Cancelada`,printing:`Imprimiendo`}},kProfiles:{title:`Perfiles K`,noPrintersConfigured:`No hay impresoras configuradas`,addPrinterInSettings:`Añada una impresora en Ajustes para gestionar perfiles K`,noActivePrinters:`No hay impresoras activas`,enablePrinterConnection:`Active la conexión de una impresora para ver sus perfiles K`,loadingProfiles:`Cargando perfiles K...`,printerOffline:`Impresora desconectada`,printerOfflineDesc:`La impresora seleccionada no está conectada. Enciéndala para ver los perfiles K.`,noMatchingProfiles:`No hay perfiles coincidentes`,noMatchingProfilesDesc:`Ningún perfil coincide con sus criterios de búsqueda`,noKProfiles:`No hay perfiles K`,noKProfilesDesc:`No se encontraron perfiles de avance de presión para la boquilla de {{diameter}} mm`,createFirstProfile:`Crear el primer perfil`,printer:`Impresora`,nozzle:`Boquilla`,refresh:`Actualizar`,addProfile:`Añadir perfil`,export:`Exportar`,import:`Importar`,select:`Seleccionar`,selectAll:`Seleccionar todo`,delete:`Eliminar`,searchPlaceholder:`Buscar por nombre o filamento...`,allExtruders:`Todos los extrusores`,leftOnly:`Solo izquierdo`,rightOnly:`Solo derecho`,allFlow:`Todos los flujos`,hfOnly:`Solo flujo alto`,sOnly:`Solo estándar`,sortName:`Ordenar: nombre`,sortKValue:`Ordenar: valor K`,sortFilament:`Ordenar: filamento`,leftExtruder:`Extrusor izquierdo`,rightExtruder:`Extrusor derecho`,modal:{addTitle:`Añadir perfil K`,editTitle:`Editar perfil K`,profileName:`Nombre del perfil`,profileNamePlaceholder:`Mi perfil de PLA`,kValue:`Valor K`,kValuePlaceholder:`0,020`,kValueHelp:`Rango típico: 0,01 - 0,06 para PLA, 0,02 - 0,10 para PETG`,filament:`Filamento`,selectFilament:`Seleccionar filamento...`,noFilamentsHelp:`No se encontraron filamentos. Cree primero un perfil K en Bambu Studio.`,flowType:`Tipo de flujo`,highFlow:`Flujo alto`,standard:`Estándar`,nozzleSize:`Tamaño de la boquilla`,extruder:`Extrusor`,extruders:`Extrusores`,left:`Izquierdo`,right:`Derecho`,notes:`Notas (almacenadas localmente)`,notesPlaceholder:`Añada notas sobre este perfil...`,notesHelp:`Las notas se guardan en Bambuddy, no en la impresora`,syncing:`Sincronizando con la impresora...`,savingExtruder:`Guardando en el extrusor {{current}}/{{total}}...`,pleaseWait:`Espere`},deleteConfirm:{title:`Eliminar perfil`,cannotUndo:`Esto no se puede deshacer`,message:`¿Está seguro de que desea eliminar "{{name}}" de la impresora?`},bulkDelete:{title:`Eliminar perfiles`,cannotUndo:`Esto no se puede deshacer`,message:`¿Está seguro de que desea eliminar {{count}} perfiles seleccionados de la impresora?`},toast:{profileSaved:`Perfil K guardado`,profilesSaved:`Perfil K guardado en {{count}} extrusores`,selectAtLeastOneExtruder:`Seleccione al menos un extrusor`,profileDeleted:`Perfil K eliminado`,profilesDeleted:`Se eliminaron {{count}} perfiles`,exportedProfiles:`Se exportaron {{count}} perfiles`,importedProfiles:`Se importaron {{count}} de {{total}} perfiles`,noProfilesToExport:`No hay perfiles que exportar`,invalidFileFormat:`Formato de archivo no válido`,failedToParseImport:`Error al analizar el archivo de importación`,failedToSaveBatch:`Error al guardar los perfiles K`,noteSaved:`Nota guardada`,failedToSaveNote:`Error al guardar la nota`},permission:{noRead:`No tiene permiso para actualizar perfiles`,noCreate:`No tiene permiso para añadir perfiles`,noUpdate:`No tiene permiso para actualizar perfiles K`,noDelete:`No tiene permiso para eliminar perfiles K`,noExport:`No tiene permiso para exportar perfiles`,noImport:`No tiene permiso para importar perfiles`}},virtualPrinter:{title:`Impresora virtual`,running:`En ejecución`,stopped:`Detenida`,description:{default:`Active una impresora virtual que aparece en Bambu Studio y OrcaSlicer. Los archivos enviados a esta impresora se archivarán directamente sin imprimir.`,proxy:`Active un proxy que retransmite el tráfico del laminador a una impresora real, permitiendo la impresión remota a través de cualquier red.`},enable:{title:`Activar la impresora virtual`,visibleInSlicer:`Visible como "Bambuddy" en la detección del laminador`,proxyingTo:`Haciendo de proxy hacia {{name}}`,notActive:`No activa`},model:{title:`Modelo de impresora`,description:`Seleccione qué modelo de impresora emular.`,restartWarning:`Cambiar el modelo reiniciará la impresora virtual`},accessCode:{title:`Código de acceso`,isSet:`El código de acceso está establecido`,notSet:`No hay código de acceso establecido - necesario para activarla`,placeholder:`Introduzca un código de 8 caracteres`,placeholderChange:`Introduzca un nuevo código para cambiarlo`,hint:`Debe tener exactamente 8 caracteres. Los laminadores lo usan para autenticarse.`,charCount:`({{count}}/8)`,inheritedFromTarget:`Heredado de la impresora de destino`,derivedFromTargetHint:`Usa el código de acceso de la impresora de destino. El puente reenvía la autenticación del laminador a la impresora real, por lo que los códigos deben coincidir — edita el código en los ajustes de la impresora para cambiarlo.`,reveal:`Mostrar código de acceso`,hide:`Ocultar código de acceso`},targetPrinter:{title:`Impresora de destino`,configured:`Destino del proxy configurado`,notConfigured:`No hay impresora de destino seleccionada - necesaria para el modo proxy`,placeholder:`Seleccionar una impresora...`,hint:`Seleccione la impresora a la que retransmitir el tráfico del laminador. La impresora debe estar en modo LAN.`,noPrinters:`No hay impresoras configuradas. Añada primero una impresora para usar el modo proxy.`},remoteInterface:{title:`Anulación de la interfaz de red`,configured:`Anulación de la interfaz activa`,optional:`Opcional - úsela si la IP detectada automáticamente es incorrecta (p. ej. varias tarjetas de red, Docker, VPN)`,placeholder:`Detección automática (predeterminada)...`,hint:`Anula la dirección IP anunciada mediante SSDP y usada en el certificado TLS. Útil cuando Bambuddy tiene varias interfaces de red.`},mode:{title:`Modo`,archive:`Archivar`,archiveDesc:`Archivar los archivos inmediatamente`,review:`Revisar`,reviewDesc:`Revisar antes de archivar`,queue:`Encolar`,queueDesc:`Archivar y añadir a la cola`,proxy:`Proxy`,proxyDesc:`Retransmitir a una impresora real`},autoDispatch:{title:`Envío automático`,description:`Iniciar automáticamente las impresiones al añadirlas a la cola. Cuando está desactivado, las impresiones esperan al envío manual.`},queueForceColorMatch:{title:`Forzar la coincidencia de color`,description:`Negarse a enviar a una impresora que no tiene cargados el tipo y el color exactos de filamento. Desactivado de forma predeterminada — sin esto, la cola usa la coincidencia solo por modelo y puede elegir una impresora con el color equivocado cargado.`},gcodeInjection:{title:`Inyección de G-code`,description:`Aplica los fragmentos de G-code configurados por modelo en Ajustes a los trabajos de esta IV. Desactivado de forma predeterminada.`},tailscaleDisabled:{title:`Integración con Tailscale`,description:`Actívelo para marcar esta IV como expuesta a través de Tailscale. Muestra la dirección de Tailscale del host para que sepa qué IP pegar en el laminador. El paso de importación de la CA no cambia — este interruptor no tiene ningún efecto sobre los certificados.`},setupRequired:{title:`Configuración necesaria`,description:`La función de impresora virtual requiere configuración adicional del sistema antes de funcionar. Esto incluye el reenvío de puertos, las reglas del cortafuegos y los ajustes específicos de la plataforma.`,readGuide:`Lea la guía de configuración antes de activarla`},archiveNameSource:{title:`Origen del nombre del archivo`,description:`Elija cómo se nombran los archivos nuevos cuando llegan a través de la impresora virtual. «Metadatos» usa el título incrustado por el laminador del 3MF (predeterminado). «Nombre de archivo» usa el nombre de archivo que Bambu Studio envió por FTP. Nota: Bambu Studio sobrescribe el nombre que escribe en el diálogo «enviar a la impresora» con el campo Título del 3MF cuando existe, por lo que ambos modos suelen producir la misma cadena.`,metadata:`Metadatos`,filename:`Nombre de archivo`},caCert:{title:`Certificado del laminador`,description:`Las impresoras virtuales usan un certificado TLS firmado por la CA de Bambuddy. Importe este certificado de CA en el almacén de confianza de su laminador una sola vez para que acepte la conexión — sin necesidad de copiarlo desde la línea de comandos.`,copy:`Copiar`,copied:`Copiado`,download:`Descargar`,fingerprint:`SHA-256`},howItWorks:{title:`Cómo funciona`,step1:`En la misma LAN, las impresoras virtuales aparecen automáticamente en su laminador (Bambu Studio / OrcaSlicer) mediante detección. Desde otras redes, añádalas manualmente por dirección IP y código de acceso.`,step2:`En los modos Archivar, Revisar y Encolar, use el botón «Enviar» de su laminador para subir archivos 3MF a Bambuddy. El laminador mostrará «Impresión correcta» — el archivo se almacena, no se imprime.`,step3:`En el modo Proxy, la impresora virtual retransmite todo el tráfico a una impresora real — las impresiones comienzan inmediatamente como si estuviera conectada directamente.`},status:{title:`Detalles del estado`,printerName:`Nombre de la impresora`,model:`Modelo`,serialNumber:`Número de serie`,mode:`Modo`,pendingFiles:`Archivos pendientes`,targetPrinter:`Impresora de destino`,ftpPort:`Puerto FTP`,mqttPort:`Puerto MQTT`,ftpConnections:`Conexiones FTP`,mqttConnections:`Conexiones MQTT`},toast:{updated:`Ajustes de la impresora virtual actualizados`,failedToUpdate:`Error al actualizar los ajustes`,copyFailed:`Error al copiar — pruebe a seleccionar el texto manualmente`,accessCodeRequired:`Establezca primero un código de acceso`,targetPrinterRequired:`Seleccione primero una impresora de destino`,bindIpRequired:`Establezca primero una IP de enlace`,accessCodeEmpty:`El código de acceso no puede estar vacío`,accessCodeLength:`El código de acceso debe tener exactamente 8 caracteres`,targetCodeChangedRebind:`El código de acceso ahora coincide con la nueva impresora de destino. Vuelve a añadir este dispositivo en tu laminador para usar el nuevo código.`,created:`Impresora virtual creada`,failedToCreate:`Error al crear la impresora virtual`,deleted:`Impresora virtual eliminada`,failedToDelete:`Error al eliminar la impresora virtual`},list:{title:`Impresoras virtuales`,add:`Añadir`,addFirst:`Añadir impresora virtual`,empty:`No hay impresoras virtuales configuradas. Añada una para empezar.`},bindIp:{title:`Interfaz de enlace`,placeholder:`Seleccionar interfaz...`,hint:`Interfaz de red a la que se enlaza esta impresora virtual. Debe ser única por impresora.`},proxy:{accessCodeHint:`En el modo proxy, use el código de acceso de su impresora de destino en el laminador. La conexión se reenvía de forma transparente a la impresora real.`},addDialog:{title:`Añadir impresora virtual`,name:`Nombre`,hint:`Puede configurar el código de acceso, la impresora de destino y otros ajustes después de crearla.`,create:`Crear`},deleteConfirm:{title:`Eliminar impresora virtual`,message:`¿Está seguro de que desea eliminar "{{name}}"? Esto detendrá todos los servicios de esta impresora.`}},modelViewer:{openInSlicer:`Abrir en el laminador`,tabs:{model:`Modelo 3D`,gcode:`Vista previa de G-code`},notAvailable:`no disponible`,notSliced:`no laminado`,plates:`Camas`,allPlates:`Todas las camas`,plateNumber:`Cama {{number}}`,plateCount:`{{count}} cama`,plateCount_other:`{{count}} camas`,objectCount:`{{count}} objeto`,objectCount_other:`{{count}} objetos`,filamentCount:`{{count}} filamento`,filamentCount_other:`{{count}} filamentos`,eta:`Tiempo estimado {{minutes}} min`,noPreview:`No hay vista previa disponible para este archivo`,pagination:{pageOf:`Página {{current}} de {{total}}`,prev:`Anterior`,next:`Siguiente`},errors:{failedToLoad:`Error al cargar el archivo`,noMeshes:`No se encontraron mallas en el archivo 3MF`,unsupportedFormat:`Formato de archivo no compatible`}},maintenanceDescriptions:{lubricateCarbonRods:`Aplique lubricante a las varillas de carbono para un movimiento suave`,lubricateRails:`Aplique lubricante a las guías lineales para un movimiento suave`,cleanNozzle:`Limpie el fusor y la boquilla para evitar obstrucciones`,checkBelts:`Verifique la tensión de las correas para impresiones precisas`,cleanBuildPlate:`Limpie la cama de impresión para una mejor adhesión`,checkExtruder:`Inspeccione los engranajes del extrusor en busca de desgaste`,checkCooling:`Asegúrese de que los ventiladores de refrigeración funcionan correctamente`,generalInspection:`Inspección general de la impresora`,cleanCarbonRods:`Limpie las varillas de carbono para reducir la fricción`,lubricateSteelRods:`Aplique lubricante a las varillas de acero para un movimiento suave`,cleanSteelRods:`Limpie las varillas de acero para reducir la fricción`,cleanLinearRails:`Limpie las guías lineales para eliminar el polvo y los residuos`,checkPtfeTube:`Inspeccione el tubo de PTFE en busca de desgaste o daños`,replaceHepaFilter:`Reemplace el filtro HEPA para la calidad del aire`,replaceCarbonFilter:`Reemplace el filtro de carbón activado`,lubricateLeftNozzleRail:`Lubrique la guía de la boquilla izquierda (serie H2)`},smartPlugs:{offline:`Desconectado`,admin:`Administración`,openPlugAdminPage:`Abrir la página de administración del enchufe`,deleteSmartPlug:`Eliminar enchufe inteligente`,turnOnSmartPlug:`Encender el enchufe inteligente`,turnOffSmartPlug:`Apagar el enchufe inteligente`,turnOn:`Encender`,turnOff:`Apagar`,addSmartPlug:{scanningNetwork:`Escaneando la red...`,chooseEntity:`Elija una entidad...`,connectionFailed:`Error de conexión`,searchEntities:`Buscar entidades...`,searchPowerSensors:`Buscar sensores de potencia...`,searchEnergySensors:`Buscar sensores de energía...`,placeholders:{plugName:`Enchufe del salón`,mqttStateOnValue:`ON, true, 1`,mqttSameAsPower:`Igual que el tema de potencia, o distinto`}},linkedTo:`Vinculado a:`,monitorOnly:`Solo supervisión`,alerts:`Alertas`,scheduleOn:`Encendido a las {{time}}`,scheduleOff:`Apagado a las {{time}}`,on:`Encendido`,off:`Apagado`,power:`Potencia`,kwhToday:`kWh hoy`,settings:`Ajustes`,automationSettings:`Ajustes de automatización`,showInSwitchbar:`Mostrar en la barra de interruptores`,quickAccessSidebar:`Acceso rápido desde la barra lateral`,enabled:`Activada`,enableAutomation:`Activar la automatización para este enchufe`,autoOn:`Encendido automático`,autoOnDescription:`Encender cuando comienza la impresión`,autoOff:`Apagado automático`,autoOffDescription:`Apagar cuando se completa la impresión (una sola vez)`,autoOffPersistent:`Mantener activado`,autoOffPersistentDescription:`Permanecer activado entre impresiones en lugar de una sola vez`,autoOffAfterDrying:`Apagado automático tras el secado`,autoOffAfterDryingDescription:`Apagar cuando se completa el secado del AMS`,delayAfterDryingMinutes:`Retardo de secado (minutos)`,turnOffDelayMode:`Modo de retardo de apagado`,time:`Tiempo`,temp:`Temp.`,delayMinutes:`Retardo (minutos)`,tempThreshold:`Umbral de temperatura (°C)`,tempThresholdDescription:`Se apaga cuando la boquilla se enfría por debajo de esta temperatura`,edit:`Editar`,deleteConfirm:`¿Está seguro de que desea eliminar "{{name}}"? Esto no se puede deshacer.`,turnOnConfirm:`¿Está seguro de que desea encender "{{name}}"?`,turnOffConfirm:`¿Está seguro de que desea apagar "{{name}}"? Esto cortará la corriente al dispositivo conectado.`,failedToTurn:`Error al {{action}} "{{name}}"`,unknown:`Desconocido`,addTitle:`Añadir enchufe inteligente`,editTitle:`Editar enchufe inteligente`,stopScanning:`Detener escaneo`,discoverTasmota:`Detectar dispositivos Tasmota`,foundDevices:`Se encontraron {{count}} dispositivo(s) - haga clic para seleccionar:`,noDevicesFound:`No se encontraron dispositivos Tasmota en su red`,haNotConfigured:`Home Assistant no está configurado. Configúrelo en`,haSettingsPath:`Ajustes → Red → Home Assistant`,selectEntity:`Seleccionar entidad *`,ipAddress:`Dirección IP *`,nameLabel:`Nombre *`,username:`Nombre de usuario`,password:`Contraseña`,authHint:`Déjelo vacío si su dispositivo Tasmota no requiere autenticación`,linkToPrinter:`Vincular a una impresora`,noPrinter:`Sin impresora (solo control manual)`,linkingDescription:`La vinculación activa el encendido/apagado automático cuando las impresiones comienzan/terminan`,powerAlerts:`Alertas de potencia`,alertAbove:`Alertar si supera (W)`,alertBelow:`Alertar si está por debajo (W)`,alertDescription:`Reciba una notificación cuando el consumo de energía cruce estos umbrales. Déjelo vacío para desactivar esa dirección.`,dailySchedule:`Programación diaria`,turnOnAt:`Encender a las`,turnOffAt:`Apagar a las`,scheduleDescription:`Encender/apagar automáticamente el enchufe a estas horas cada día. Déjelo vacío para omitir esa acción.`,showOnPrinterCard:`Mostrar en la tarjeta de la impresora`,displayOnPrinterCard:`Mostrar el botón en la tarjeta de la impresora`,connectedResult:`¡Conectado!`,deviceLabel:`Dispositivo: {{name}} - `,stateLabel:`Estado: {{state}}`,test:`Probar`,delete:`Eliminar`,save:`Guardar`,add:`Añadir`,cancel:`Cancelar`,failedToStartScan:`Error al iniciar el escaneo`,nameRequired:`El nombre es obligatorio`,entityRequired:`La entidad es obligatoria para los enchufes de Home Assistant`,mqttTopicRequired:`Debe configurarse al menos un tema MQTT para la supervisión de potencia, energía o estado`,loadingEntities:`Cargando entidades...`,loading:`Cargando...`,failedToLoadEntities:`Error al cargar las entidades: {{error}}`,noEntitiesMatching:`No se encontraron entidades que coincidan con "{{search}}"`,noEntitiesAvailable:`No hay entidades disponibles`,searchingEntities:`Buscando en todas las entidades ({{count}} encontradas)`,showingEntities:`Mostrando switch, light, input_boolean ({{count}} disponibles)`,energyMonitoringOptional:`Supervisión de energía (opcional)`,energyMonitoringHint:`Busque y seleccione sensores que proporcionen datos de potencia/energía.`,powerSensorW:`Sensor de potencia (W)`,energyTodayKwh:`Energía de hoy (kWh)`,totalEnergyKwh:`Energía total (kWh)`,noMatchingSensors:`No hay sensores coincidentes`,none:`Ninguno`,mqttNotConfigured:`El broker MQTT no está configurado. Establezca la dirección del broker en`,mqttSettingsPath:`Ajustes → Red → Publicación MQTT`,mqttNotConfiguredSuffix:`(no necesita activar la publicación, solo rellenar los datos del broker).`,mqttMonitorOnlyDescription:`Los enchufes MQTT reciben los datos de potencia/energía mediante una suscripción MQTT. El control de encendido/apagado no está disponible - use su broker MQTT o sistema de domótica.`,powerMonitoring:`Supervisión de potencia`,energyMonitoring:`Supervisión de energía`,stateMonitoring:`Supervisión de estado`,optional:`opcional`,topic:`Tema`,jsonPath:`Ruta JSON`,multiplier:`Multiplicador`,onValue:`Valor de ON`,mqttPowerHint:`La ruta JSON extrae el valor de la carga útil JSON (p. ej., "power_l1"). Déjelo vacío si el tema publica valores numéricos sin procesar. @@ -3988,11 +3988,11 @@ void main() { } }`,Die=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new T_(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new Qg({vertexShader:Tie,fragmentShader:Eie,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Kg(new E_(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},Oie=class extends Am{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=typeof XRWebGLBinding<`u`,h=new Die,g={},_=t.getContextAttributes(),v=null,y=null,b=[],x=[],S=new Vm,C=null,w=new r_;w.viewport=new ih;let T=new r_;T.viewport=new ih;let E=[w,T],D=new mne,O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=b[e];return t===void 0&&(t=new c_,b[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=b[e];return t===void 0&&(t=new c_,b[e]=t),t.getGripSpace()},this.getHand=function(e){let t=b[e];return t===void 0&&(t=new c_,b[e]=t),t.getHandSpace()};function A(e){let t=x.indexOf(e.inputSource);if(t===-1)return;let n=b[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function j(){r.removeEventListener(`select`,A),r.removeEventListener(`selectstart`,A),r.removeEventListener(`selectend`,A),r.removeEventListener(`squeeze`,A),r.removeEventListener(`squeezestart`,A),r.removeEventListener(`squeezeend`,A),r.removeEventListener(`end`,j),r.removeEventListener(`inputsourceschange`,M);for(let e=0;e=0&&(x[r]=null,b[r].disconnect(n))}for(let t=0;t=x.length){x.push(n),r=e;break}else if(x[e]===null){x[e]=n,r=e;break}if(r===-1)break}let i=b[r];i&&i.connect(n)}}let N=new Um,P=new Um;function F(e,t,n){N.setFromMatrixPosition(t.matrixWorld),P.setFromMatrixPosition(n.matrixWorld);let r=N.distanceTo(P),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function I(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;h.texture!==null&&(h.depthNear>0&&(t=h.depthNear),h.depthFar>0&&(n=h.depthFar)),D.near=T.near=w.near=t,D.far=T.far=w.far=n,(O!==D.near||k!==D.far)&&(r.updateRenderState({depthNear:D.near,depthFar:D.far}),O=D.near,k=D.far),D.layers.mask=e.layers.mask|6,w.layers.mask=D.layers.mask&3,T.layers.mask=D.layers.mask&5;let i=e.parent,a=D.cameras;I(D,i);for(let e=0;e0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,Wv.copy(o),Wv.x*=-1,Wv.y*=-1,Wv.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(Wv.y*=-1,Wv.z*=-1),e.envMapRotation.value.setFromMatrix4(kie.makeRotationFromEuler(Wv)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function jie(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?Dm(`WebGLRenderer: Texture samplers can not be part of an uniforms group.`):Dm(`WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var Mie=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]),Gv=null;function Nie(){return Gv===null&&(Gv=new Gte(Mie,32,32,vee,em),Gv.minFilter=Jp,Gv.magFilter=Jp,Gv.wrapS=Gp,Gv.wrapT=Gp,Gv.generateMipmaps=!1,Gv.needsUpdate=!0),Gv}var Pie=class{constructor(e={}){let{canvas:t=ete(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1}=e;this.isWebGLRenderer=!0;let f;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);f=n.getContextAttributes().alpha}else f=a;let p=new Set([lm,cm,sm]),m=new Set([Xp,Qp,Zp,rm,tm,nm]),h=new Uint32Array(4),g=new Int32Array(4),_=null,v=null,y=[],b=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let x=this,S=!1;this._outputColorSpace=gm;let C=0,w=0,T=null,E=-1,D=null,O=new ih,k=new ih,A=null,j=new vg(0),M=0,N=t.width,P=t.height,F=1,I=null,L=null,R=new ih(0,0,N,P),z=new ih(0,0,N,P),B=!1,V=new p_,ee=!1,te=!1,ne=new Nh,re=new Um,ie=new ih,H={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ae=!1;function oe(){return T===null?F:1}let U=n;function se(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:c,powerPreference:l,failIfMajorPerformanceCaveat:u};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r181`),t.addEventListener(`webglcontextlost`,Pe,!1),t.addEventListener(`webglcontextrestored`,Fe,!1),t.addEventListener(`webglcontextcreationerror`,Ie,!1),U===null){let t=`webgl2`;if(U=se(t,e),U===null)throw se(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw e(`WebGLRenderer: `+e.message),e}let ce,le,ue,de,fe,pe,me,he,ge,_e,ve,ye,be,xe,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je;function Me(){ce=new Hne(U),ce.init(),ke=new wie(U,ce),le=new Nne(U,ce,e,ke),ue=new Sie(U,ce),le.reversedDepthBuffer&&d&&ue.buffers.depth.setReversed(!0),de=new Gne(U),fe=new lie,pe=new Cie(U,ce,ue,fe,le,ke,de),me=new Fne(x),he=new Vne(x),ge=new One(U),Ae=new jne(U,ge),_e=new Une(U,ge,de,Ae),ve=new qne(U,_e,ge,de),Ee=new Kne(U,le,pe),Ce=new Pne(fe),ye=new cie(x,me,he,ce,le,Ae,Ce),be=new Aie(x,fe),xe=new die,Se=new _ie(ce),Te=new Ane(x,me,he,ue,ve,f,s),we=new bie(x,ve,le),je=new jie(U,de,le,ue),De=new Mne(U,ce,de),Oe=new Wne(U,ce,de),de.programs=ye.programs,x.capabilities=le,x.extensions=ce,x.properties=fe,x.renderLists=xe,x.shadowMap=we,x.state=ue,x.info=de}Me();let Ne=new Oie(x,U);this.xr=Ne,this.getContext=function(){return U},this.getContextAttributes=function(){return U.getContextAttributes()},this.forceContextLoss=function(){let e=ce.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=ce.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return F},this.setPixelRatio=function(e){e!==void 0&&(F=e,this.setSize(N,P,!1))},this.getSize=function(e){return e.set(N,P)},this.setSize=function(e,n,r=!0){if(Ne.isPresenting){Dm(`WebGLRenderer: Can't change size while VR device is presenting.`);return}N=e,P=n,t.width=Math.floor(e*F),t.height=Math.floor(n*F),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(N*F,P*F).floor()},this.setDrawingBufferSize=function(e,n,r){N=e,P=n,F=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(R)},this.setViewport=function(e,t,n,r){e.isVector4?R.set(e.x,e.y,e.z,e.w):R.set(e,t,n,r),ue.viewport(O.copy(R).multiplyScalar(F).round())},this.getScissor=function(e){return e.copy(z)},this.setScissor=function(e,t,n,r){e.isVector4?z.set(e.x,e.y,e.z,e.w):z.set(e,t,n,r),ue.scissor(k.copy(z).multiplyScalar(F).round())},this.getScissorTest=function(){return B},this.setScissorTest=function(e){ue.setScissorTest(B=e)},this.setOpaqueSort=function(e){I=e},this.setTransparentSort=function(e){L=e},this.getClearColor=function(e){return e.copy(Te.getClearColor())},this.setClearColor=function(){Te.setClearColor(...arguments)},this.getClearAlpha=function(){return Te.getClearAlpha()},this.setClearAlpha=function(){Te.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(T!==null){let t=T.texture.format;e=p.has(t)}if(e){let e=T.texture.type,t=m.has(e),n=Te.getClearColor(),r=Te.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(h[0]=i,h[1]=a,h[2]=o,h[3]=r,U.clearBufferuiv(U.COLOR,0,h)):(g[0]=i,g[1]=a,g[2]=o,g[3]=r,U.clearBufferiv(U.COLOR,0,g))}else r|=U.COLOR_BUFFER_BIT}t&&(r|=U.DEPTH_BUFFER_BIT),n&&(r|=U.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),U.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Pe,!1),t.removeEventListener(`webglcontextrestored`,Fe,!1),t.removeEventListener(`webglcontextcreationerror`,Ie,!1),Te.dispose(),xe.dispose(),Se.dispose(),fe.dispose(),me.dispose(),he.dispose(),ve.dispose(),Ae.dispose(),je.dispose(),ye.dispose(),Ne.dispose(),Ne.removeEventListener(`sessionstart`,Ue),Ne.removeEventListener(`sessionend`,We),Ge.stop()};function Pe(e){e.preventDefault(),Em(`WebGLRenderer: Context Lost.`),S=!0}function Fe(){Em(`WebGLRenderer: Context Restored.`),S=!1;let e=de.autoReset,t=we.enabled,n=we.autoUpdate,r=we.needsUpdate,i=we.type;Me(),de.autoReset=e,we.enabled=t,we.autoUpdate=n,we.needsUpdate=r,we.type=i}function Ie(e){Om(`WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function Le(e){let t=e.target;t.removeEventListener(`dispose`,Le),Re(t)}function Re(e){ze(e),fe.remove(e)}function ze(e){let t=fe.get(e).programs;t!==void 0&&(t.forEach(function(e){ye.releaseProgram(e)}),e.isShaderMaterial&&ye.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=H);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=W(e,t,n,r,i);ue.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=_e.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Ae.setup(i,r,s,n,c);let h,g=De;if(c!==null&&(h=ge.get(c),g=Oe,g.setIndex(h)),i.isMesh)r.wireframe===!0?(ue.setLineWidth(r.wireframeLinewidth*oe()),g.setMode(U.LINES)):g.setMode(U.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),ue.setLineWidth(e*oe()),i.isLineSegments?g.setMode(U.LINES):i.isLineLoop?g.setMode(U.LINE_LOOP):g.setMode(U.LINE_STRIP)}else i.isPoints?g.setMode(U.POINTS):i.isSprite&&g.setMode(U.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)km(`WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(ce.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?ge.get(c).bytesPerElement:1,o=fe.get(r).currentProgram.getUniforms();for(let r=0;r{function n(){if(r.forEach(function(e){fe.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}ce.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ve=null;function He(e){Ve&&Ve(e)}function Ue(){Ge.stop()}function We(){Ge.start()}let Ge=new q_;Ge.setAnimationLoop(He),typeof self<`u`&&Ge.setContext(self),this.setAnimationLoop=function(e){Ve=e,Ne.setAnimationLoop(e),e===null?Ge.stop():Ge.start()},Ne.addEventListener(`sessionstart`,Ue),Ne.addEventListener(`sessionend`,We),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){Om(`WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(S===!0)return;if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(t),t=Ne.getCamera()),e.isScene===!0&&e.onBeforeRender(x,e,t,T),v=Se.get(e,b.length),v.init(t),b.push(v),ne.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),V.setFromProjectionMatrix(ne,xm,t.reversedDepth),te=this.localClippingEnabled,ee=Ce.init(this.clippingPlanes,te),_=xe.get(e,y.length),_.init(),y.push(_),Ne.enabled===!0&&Ne.isPresenting===!0){let e=x.xr.getDepthSensingMesh();e!==null&&Ke(e,t,-1/0,x.sortObjects)}Ke(e,t,0,x.sortObjects),_.finish(),x.sortObjects===!0&&_.sort(I,L),ae=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ae&&Te.addToRenderList(_,e),this.info.render.frame++,ee===!0&&Ce.beginShadows();let n=v.state.shadowsArray;we.render(n,e,t),ee===!0&&Ce.endShadows(),this.info.autoReset===!0&&this.info.reset();let r=_.opaque,i=_.transmissive;if(v.setupLights(),t.isArrayCamera){let n=t.cameras;if(i.length>0)for(let t=0,a=n.length;t0&&Je(r,i,e,t),ae&&Te.render(e),qe(_,e,t);T!==null&&w===0&&(pe.updateMultisampleRenderTarget(T),pe.updateRenderTargetMipmap(T)),e.isScene===!0&&e.onAfterRender(x,e,t),Ae.resetDefaultState(),E=-1,D=null,b.pop(),b.length>0?(v=b[b.length-1],ee===!0&&Ce.setGlobalState(x.clippingPlanes,v.state.camera)):v=null,y.pop(),_=y.length>0?y[y.length-1]:null};function Ke(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)v.pushLight(e),e.castShadow&&v.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||V.intersectsSprite(e)){r&&ie.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ne);let t=ve.update(e),i=e.material;i.visible&&_.push(e,t,i,n,ie.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||V.intersectsObject(e))){let t=ve.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ie.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ie.copy(e.boundingSphere.center)),ie.applyMatrix4(e.matrixWorld).applyMatrix4(ne)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Ye(i,t,n),a.length>0&&Ye(a,t,n),o.length>0&&Ye(o,t,n),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function Je(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;v.state.transmissionRenderTarget[r.id]===void 0&&(v.state.transmissionRenderTarget[r.id]=new ah(1,1,{generateMipmaps:!0,type:ce.has(`EXT_color_buffer_half_float`)||ce.has(`EXT_color_buffer_float`)?em:Xp,minFilter:Yp,samples:4,stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Xm.workingColorSpace}));let a=v.state.transmissionRenderTarget[r.id],o=r.viewport||O;a.setSize(o.z*x.transmissionResolutionScale,o.w*x.transmissionResolutionScale);let s=x.getRenderTarget(),c=x.getActiveCubeFace(),l=x.getActiveMipmapLevel();x.setRenderTarget(a),x.getClearColor(j),M=x.getClearAlpha(),M<1&&x.setClearColor(16777215,.5),x.clear(),ae&&Te.render(n);let u=x.toneMapping;x.toneMapping=0;let d=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),v.setupLightsView(r),ee===!0&&Ce.setGlobalState(x.clippingPlanes,r),Ye(e,n,r),pe.updateMultisampleRenderTarget(a),pe.updateRenderTargetMipmap(a),ce.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(T===null||T.isXRRenderTarget===!0)&&(m=x.toneMapping);let h=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=h===void 0?0:h.length,_=fe.get(r),y=v.state.lights;if(ee===!0&&(te===!0||e!==D)){let t=e===D&&r.id===E;Ce.setState(r,e,t)}let b=!1;r.version===_.__version?_.needsLights&&_.lightsStateVersion!==y.state.version?b=!0:_.outputColorSpace===s?i.isBatchedMesh&&_.batching===!1||!i.isBatchedMesh&&_.batching===!0||i.isBatchedMesh&&_.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&_.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&_.instancing===!1||!i.isInstancedMesh&&_.instancing===!0||i.isSkinnedMesh&&_.skinning===!1||!i.isSkinnedMesh&&_.skinning===!0||i.isInstancedMesh&&_.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&_.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&_.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&_.instancingMorph===!1&&i.morphTexture!==null?b=!0:_.envMap===c?r.fog===!0&&_.fog!==a||_.numClippingPlanes!==void 0&&(_.numClippingPlanes!==Ce.numPlanes||_.numIntersection!==Ce.numIntersection)?b=!0:_.vertexAlphas===l&&_.vertexTangents===u&&_.morphTargets===d&&_.morphNormals===f&&_.morphColors===p&&_.toneMapping===m?_.morphTargetsCount!==g&&(b=!0):b=!0:b=!0:b=!0:(b=!0,_.__version=r.version);let S=_.currentProgram;b===!0&&(S=Ze(r,t,i));let C=!1,w=!1,O=!1,k=S.getUniforms(),A=_.uniforms;if(ue.useProgram(S.program)&&(C=!0,w=!0,O=!0),r.id!==E&&(E=r.id,w=!0),C||D!==e){ue.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),k.setValue(U,`projectionMatrix`,e.projectionMatrix),k.setValue(U,`viewMatrix`,e.matrixWorldInverse);let t=k.map.cameraPosition;t!==void 0&&t.setValue(U,re.setFromMatrixPosition(e.matrixWorld)),le.logarithmicDepthBuffer&&k.setValue(U,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&k.setValue(U,`isOrthographic`,e.isOrthographicCamera===!0),D!==e&&(D=e,w=!0,O=!0)}if(i.isSkinnedMesh){k.setOptional(U,i,`bindMatrix`),k.setOptional(U,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),k.setValue(U,`boneTexture`,e.boneTexture,pe))}i.isBatchedMesh&&(k.setOptional(U,i,`batchingTexture`),k.setValue(U,`batchingTexture`,i._matricesTexture,pe),k.setOptional(U,i,`batchingIdTexture`),k.setValue(U,`batchingIdTexture`,i._indirectTexture,pe),k.setOptional(U,i,`batchingColorTexture`),i._colorsTexture!==null&&k.setValue(U,`batchingColorTexture`,i._colorsTexture,pe));let j=n.morphAttributes;if((j.position!==void 0||j.normal!==void 0||j.color!==void 0)&&Ee.update(i,n,S),(w||_.receiveShadow!==i.receiveShadow)&&(_.receiveShadow=i.receiveShadow,k.setValue(U,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(A.envMap.value=c,A.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),r.isMeshStandardMaterial&&r.envMap===null&&t.environment!==null&&(A.envMapIntensity.value=t.environmentIntensity),A.dfgLUT!==void 0&&(A.dfgLUT.value=Nie()),w&&(k.setValue(U,`toneMappingExposure`,x.toneMappingExposure),_.needsLights&&et(A,O),a&&r.fog===!0&&be.refreshFogUniforms(A,a),be.refreshMaterialUniforms(A,r,F,P,v.state.transmissionRenderTarget[e.id]),Av.upload(U,Qe(_),A,pe)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(Av.upload(U,Qe(_),A,pe),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&k.setValue(U,`center`,i.center),k.setValue(U,`modelViewMatrix`,i.modelViewMatrix),k.setValue(U,`normalMatrix`,i.normalMatrix),k.setValue(U,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&pe.useMultisampledRTT(e)===!1?fe.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),k.copy(e.scissor),A=e.scissorTest}else O.copy(R).multiplyScalar(F).floor(),k.copy(z).multiplyScalar(F).floor(),A=B;if(n!==0&&(i=nt),ue.bindFramebuffer(U.FRAMEBUFFER,i)&&r&&ue.drawBuffers(e,i),ue.viewport(O),ue.scissor(k),ue.setScissorTest(A),a){let r=fe.get(e.texture);U.framebufferTexture2D(U.FRAMEBUFFER,U.COLOR_ATTACHMENT0,U.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=t;for(let t=0;t=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&(e.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+s),U.readPixels(t,n,r,i,ke.convert(c),ke.convert(l),a))}finally{let e=T===null?null:fe.get(T).__webglFramebuffer;ue.bindFramebuffer(U.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=fe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){ue.bindFramebuffer(U.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(!le.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!le.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=U.createBuffer();U.bindBuffer(U.PIXEL_PACK_BUFFER,d),U.bufferData(U.PIXEL_PACK_BUFFER,a.byteLength,U.STREAM_READ),e.textures.length>1&&U.readBuffer(U.COLOR_ATTACHMENT0+s),U.readPixels(t,n,r,i,ke.convert(l),ke.convert(u),0);let f=T===null?null:fe.get(T).__webglFramebuffer;ue.bindFramebuffer(U.FRAMEBUFFER,f);let p=U.fenceSync(U.SYNC_GPU_COMMANDS_COMPLETE,0);return U.flush(),await tte(U,p,4),U.bindBuffer(U.PIXEL_PACK_BUFFER,d),U.getBufferSubData(U.PIXEL_PACK_BUFFER,0,a),U.deleteBuffer(d),U.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;pe.setTexture2D(e,0),U.copyTexSubImage2D(U.TEXTURE_2D,n,0,0,o,s,i,a),ue.unbindTexture()};let rt=U.createFramebuffer(),it=U.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=null){a===null&&(i===0?a=0:(km(`WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.`),a=i,i=0));let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=ke.convert(t.format),_=ke.convert(t.type),v;t.isData3DTexture?(pe.setTexture3D(t,0),v=U.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(pe.setTexture2DArray(t,0),v=U.TEXTURE_2D_ARRAY):(pe.setTexture2D(t,0),v=U.TEXTURE_2D),U.pixelStorei(U.UNPACK_FLIP_Y_WEBGL,t.flipY),U.pixelStorei(U.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),U.pixelStorei(U.UNPACK_ALIGNMENT,t.unpackAlignment);let y=U.getParameter(U.UNPACK_ROW_LENGTH),b=U.getParameter(U.UNPACK_IMAGE_HEIGHT),x=U.getParameter(U.UNPACK_SKIP_PIXELS),S=U.getParameter(U.UNPACK_SKIP_ROWS),C=U.getParameter(U.UNPACK_SKIP_IMAGES);U.pixelStorei(U.UNPACK_ROW_LENGTH,h.width),U.pixelStorei(U.UNPACK_IMAGE_HEIGHT,h.height),U.pixelStorei(U.UNPACK_SKIP_PIXELS,l),U.pixelStorei(U.UNPACK_SKIP_ROWS,u),U.pixelStorei(U.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=fe.get(e),r=fe.get(t),h=fe.get(n.__renderTarget),g=fe.get(r.__renderTarget);ue.bindFramebuffer(U.READ_FRAMEBUFFER,h.__webglFramebuffer),ue.bindFramebuffer(U.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;nMath.PI&&(n-=Qv),r<-Math.PI?r+=Qv:r>Math.PI&&(r-=Qv),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=e!=this._spherical.radius}if(Zv.setFromSpherical(this._spherical),Zv.applyQuaternion(this._quatInverse),t.copy(this.target).add(Zv),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=Zv.length();e=this._clampDistance(t*this._scale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),i=!!n}else if(this.object.isOrthographicCamera){let t=new Um(this._mouse.x,this._mouse.y,0);t.unproject(this.object);let n=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=n!==this.object.zoom;let r=new Um(this._mouse.x,this._mouse.y,0);r.unproject(this.object),this.object.position.sub(r).add(t),this.object.updateMatrixWorld(),e=Zv.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(Yv.origin.copy(this.object.position),Yv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Yv.direction))ey||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ey||this._lastTargetPosition.distanceToSquared(this.target)>ey?(this.dispatchEvent(Kv),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e===null?Qv/60/60*this.autoRotateSpeed:Qv/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Zv.setFromMatrixColumn(t,0),Zv.multiplyScalar(-e),this._panOffset.add(Zv)}_panUp(e,t){this.screenSpacePanning===!0?Zv.setFromMatrixColumn(t,1):(Zv.setFromMatrixColumn(t,0),Zv.crossVectors(this.object.up,Zv)),Zv.multiplyScalar(e),this._panOffset.add(Zv)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){let r=this.object.position;Zv.copy(r).sub(this.target);let i=Zv.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Qv*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qv*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Qv*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Qv*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Qv*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Qv*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(Qv*this._rotateDelta.x/t.clientHeight),this._rotateUp(Qv*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t>5&31)/31,a=(e>>10&31)/31)}for(let c=1;c<=3;c++){let l=n+c*12,u=e*3*3+(c-1)*3;p[u]=t.getFloat32(l,!0),p[u+1]=t.getFloat32(l+4,!0),p[u+2]=t.getFloat32(l+8,!0),m[u]=d,m[u+1]=f,m[u+2]=g,o&&(h.setRGB(r,i,a,gm),s[u]=h.r,s[u+1]=h.g,s[u+2]=h.b)}}return f.setAttribute(`position`,new wg(p,3)),f.setAttribute(`normal`,new wg(m,3)),o&&(f.setAttribute(`color`,new wg(s,3)),f.hasColors=!0,f.alpha=d),f}function i(e){let t=new Pg,n=/solid([\s\S]*?)endsolid/g,r=/facet([\s\S]*?)endfacet/g,i=/solid\s(.+)/,a=0,o=RegExp(`vertex[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,`g`),s=RegExp(`normal[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,`g`),c=[],l=[],u=[],d=new Um,f,p=0,m=0,h=0;for(;(f=n.exec(e))!==null;){m=h;let e=f[0],n=(f=i.exec(e))===null?``:f[1];for(u.push(n);(f=r.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=s.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=o.exec(n))!==null;)c.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),l.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let g=m,_=h-m;t.userData.groupNames=u,t.addGroup(g,_,p),p++}return t.setAttribute(`position`,new Dg(c,3)),t.setAttribute(`normal`,new Dg(l,3)),t}function a(e){return typeof e==`string`?e:new TextDecoder().decode(e)}function o(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n{(function(n){typeof e==`object`&&t!==void 0?t.exports=n():typeof define==`function`&&define.amd?define([],n):(typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this).JSZip=n()})(function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var c=typeof u==`function`&&u;if(!s&&c)return c(o,!0);if(a)return a(o,!0);var l=Error(`Cannot find module '`+o+`'`);throw l.code=`MODULE_NOT_FOUND`,l}var d=n[o]={exports:{}};t[o][0].call(d.exports,function(e){var n=t[o][1][e];return i(n||e)},d,d.exports,e,t,n,r)}return n[o].exports}for(var a=typeof u==`function`&&u,o=0;o>2,s=(3&t)<<4|n>>4,c=1>6:64,l=2>4,n=(15&o)<<4|(s=a.indexOf(e.charAt(l++)))>>2,r=(3&s)<<6|(c=a.indexOf(e.charAt(l++))),f[u++]=t,s!==64&&(f[u++]=n),c!==64&&(f[u++]=r);return f}},{"./support":30,"./utils":32}],2:[function(e,t,n){var r=e(`./external`),i=e(`./stream/DataWorker`),a=e(`./stream/Crc32Probe`),o=e(`./stream/DataLengthProbe`);function s(e,t,n,r,i){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=r,this.compressedContent=i}s.prototype={getContentWorker:function(){var e=new i(r.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new o(`data_length`)),t=this;return e.on(`end`,function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw Error(`Bug : uncompressed data size mismatch`)}),e},getCompressedWorker:function(){return new i(r.Promise.resolve(this.compressedContent)).withStreamInfo(`compressedSize`,this.compressedSize).withStreamInfo(`uncompressedSize`,this.uncompressedSize).withStreamInfo(`crc32`,this.crc32).withStreamInfo(`compression`,this.compression)}},s.createWorkerFrom=function(e,t,n){return e.pipe(new a).pipe(new o(`uncompressedSize`)).pipe(t.compressWorker(n)).pipe(new o(`compressedSize`)).withStreamInfo(`compression`,t)},t.exports=s},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,t,n){var r=e(`./stream/GenericWorker`);n.STORE={magic:`\0\0`,compressWorker:function(){return new r(`STORE compression`)},uncompressWorker:function(){return new r(`STORE decompression`)}},n.DEFLATE=e(`./flate`)},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,t,n){var r=e(`./utils`),i=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t){return e!==void 0&&e.length?r.getTypeOf(e)===`string`?function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t.charCodeAt(s))];return-1^e}(0|t,e,e.length,0):function(e,t,n,r){var a=i,o=r+n;e^=-1;for(var s=r;s>>8^a[255&(e^t[s])];return-1^e}(0|t,e,e.length,0):0}},{"./utils":32}],5:[function(e,t,n){n.base64=!1,n.binary=!1,n.dir=!1,n.createFolders=!0,n.date=null,n.compression=null,n.compressionOptions=null,n.comment=null,n.unixPermissions=null,n.dosPermissions=null},{}],6:[function(e,t,n){var r=null;r=typeof Promise<`u`?Promise:e(`lie`),t.exports={Promise:r}},{lie:37}],7:[function(e,t,n){var r=typeof Uint8Array<`u`&&typeof Uint16Array<`u`&&typeof Uint32Array<`u`,i=e(`pako`),a=e(`./utils`),o=e(`./stream/GenericWorker`),s=r?`uint8array`:`array`;function c(e,t){o.call(this,`FlateWorker/`+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}n.magic=`\b\0`,a.inherits(c,o),c.prototype.processChunk=function(e){this.meta=e.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(s,e.data),!1)},c.prototype.flush=function(){o.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},c.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this._pako=null},c.prototype._createPako=function(){this._pako=new i[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}},n.compressWorker=function(e){return new c(`Deflate`,e)},n.uncompressWorker=function(){return new c(`Inflate`,{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,t,n){function r(e,t){var n,r=``;for(n=0;n>>=8;return r}function i(e,t,n,i,o,u){var d,f,p=e.file,m=e.compression,h=u!==s.utf8encode,g=a.transformTo(`string`,u(p.name)),_=a.transformTo(`string`,s.utf8encode(p.name)),v=p.comment,y=a.transformTo(`string`,u(v)),b=a.transformTo(`string`,s.utf8encode(v)),x=_.length!==p.name.length,S=b.length!==v.length,C=``,w=``,T=``,E=p.dir,D=p.date,O={crc32:0,compressedSize:0,uncompressedSize:0};t&&!n||(O.crc32=e.crc32,O.compressedSize=e.compressedSize,O.uncompressedSize=e.uncompressedSize);var k=0;t&&(k|=8),h||!x&&!S||(k|=2048);var A=0,j=0;E&&(A|=16),o===`UNIX`?(j=798,A|=function(e,t){var n=e;return e||(n=t?16893:33204),(65535&n)<<16}(p.unixPermissions,E)):(j=20,A|=function(e){return 63&(e||0)}(p.dosPermissions)),d=D.getUTCHours(),d<<=6,d|=D.getUTCMinutes(),d<<=5,d|=D.getUTCSeconds()/2,f=D.getUTCFullYear()-1980,f<<=4,f|=D.getUTCMonth()+1,f<<=5,f|=D.getUTCDate(),x&&(w=r(1,1)+r(c(g),4)+_,C+=`up`+r(w.length,2)+w),S&&(T=r(1,1)+r(c(y),4)+b,C+=`uc`+r(T.length,2)+T);var M=``;return M+=` -\0`,M+=r(k,2),M+=m.magic,M+=r(d,2),M+=r(f,2),M+=r(O.crc32,4),M+=r(O.compressedSize,4),M+=r(O.uncompressedSize,4),M+=r(g.length,2),M+=r(C.length,2),{fileRecord:l.LOCAL_FILE_HEADER+M+g+C,dirRecord:l.CENTRAL_FILE_HEADER+r(j,2)+M+r(y.length,2)+`\0\0\0\0`+r(A,4)+r(i,4)+g+C+y}}var a=e(`../utils`),o=e(`../stream/GenericWorker`),s=e(`../utf8`),c=e(`../crc32`),l=e(`../signature`);function u(e,t,n,r){o.call(this,`ZipFileWorker`),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=r,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(u,o),u.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,r=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,o.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-r-1))/n:100}}))},u.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=i(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0},u.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=i(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:function(e){return l.DATA_DESCRIPTOR+r(e.crc32,4)+r(e.compressedSize,4)+r(e.uncompressedSize,4)}(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},u.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo(`string`,this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){var r=e(`./Uint8ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var r=e(`./DataReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var r=e(`./ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array;var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var r=e(`../utils`),i=e(`../support`),a=e(`./ArrayReader`),o=e(`./StringReader`),s=e(`./NodeBufferReader`),c=e(`./Uint8ArrayReader`);t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),t!==`string`||i.uint8array?t===`nodebuffer`?new s(e):i.uint8array?new c(r.transformTo(`uint8array`,e)):new a(r.transformTo(`array`,e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER=`PK`,n.CENTRAL_FILE_HEADER=`PK`,n.CENTRAL_DIRECTORY_END=`PK`,n.ZIP64_CENTRAL_DIRECTORY_LOCATOR=`PK\x07`,n.ZIP64_CENTRAL_DIRECTORY_END=`PK`,n.DATA_DESCRIPTOR=`PK\x07\b`},{}],24:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../utils`);function a(e){r.call(this,`ConvertWorker to `+e),this.destType=e}i.inherits(a,r),a.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../crc32`);function a(){r.call(this,`Crc32Probe`),this.withStreamInfo(`crc32`,0)}e(`../utils`).inherits(a,r),a.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataLengthProbe for `+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(a,i),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataWorker`);var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type=``,this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case`string`:e=this.data.substring(this.index,t);break;case`uint8array`:e=this.data.subarray(this.index,t);break;case`array`:case`nodebuffer`:e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function r(e){this.name=e||`default`,this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit(`data`,e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit(`end`),this.cleanUp(),this.isFinished=!0}catch(e){this.emit(`error`,e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit(`error`,e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n `+e:e}},t.exports=r},{}],29:[function(e,t,n){var r=e(`../utils`),i=e(`./ConvertWorker`),a=e(`./GenericWorker`),o=e(`../base64`),s=e(`../support`),c=e(`../external`),l=null;if(s.nodestream)try{l=e(`../nodejs/NodejsStreamOutputAdapter`)}catch{}function u(e,t){return new c.Promise(function(n,i){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on(`data`,function(e,n){a.push(e),t&&t(n)}).on(`error`,function(e){a=[],i(e)}).on(`end`,function(){try{n(function(e,t,n){switch(e){case`blob`:return r.newBlob(r.transformTo(`arraybuffer`,t),n);case`base64`:return o.encode(t);default:return r.transformTo(e,t)}}(c,function(e,t){var n,r=0,i=null,a=0;for(n=0;n`u`)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:`application/zip`}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=i.getBlob(`application/zip`).size===0}catch{n.blob=!1}}}try{n.nodestream=!!e(`readable-stream`).Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var r=e(`./utils`),i=e(`./support`),a=e(`./nodejsUtils`),o=e(`./stream/GenericWorker`),s=Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;s[254]=s[254]=1;function l(){o.call(this,`utf-8 decode`),this.leftOver=null}function u(){o.call(this,`utf-8 encode`)}n.utf8encode=function(e){return i.nodebuffer?a.newBufferFrom(e,`utf-8`):function(e){var t,n,r,a,o,s=e.length,c=0;for(a=0;a>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo(`nodebuffer`,e).toString(`utf-8`):function(e){var t,n,i,a,o=e.length,c=Array(2*o);for(t=n=0;t>10&1023,c[n++]=56320|1023&i)}return c.length!==n&&(c.subarray?c=c.subarray(0,n):c.length=n),r.applyFromCharCode(c)}(e=r.transformTo(i.uint8array?`uint8array`:`array`,e))},r.inherits(l,o),l.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?`uint8array`:`array`,e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+s[e[n]]>t?n:t}(t),c=t;o!==t.length&&(i.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=l,r.inherits(u,o),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var r=e(`./support`),i=e(`./base64`),a=e(`./nodejsUtils`),o=e(`./external`);function s(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),e==0&&(this.dosPermissions=63&this.externalFileAttributes),e==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!==`/`||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||={};e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,l[r++]=56320|1023&i)}return c(l,r)},n.utf8border=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,r){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;n!==0;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){var r,i=e(`../utils/common`),a=e(`./trees`),o=e(`./adler32`),s=e(`./crc32`),c=e(`./messages`),l=0,u=4,d=0,f=-2,p=-1,m=4,h=2,g=8,_=9,v=286,y=30,b=19,x=2*v+1,S=15,C=3,w=258,T=w+C+1,E=42,D=113,O=1,k=2,A=3,j=4;function M(e,t){return e.msg=c[t],t}function N(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),n!==0&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function I(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function L(e,t){e.pending_buf[e.pending++]=t}function R(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function z(e,t){var n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-T?e.strstart-(e.w_size-T):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+w,p=l[a+o-1],m=l[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(l[(n=t)+o]===m&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do;while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ac&&--i!=0);return o<=e.lookahead?o:e.lookahead}function B(e){var t,n,r,a,c,l,u,d,f,p,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-T)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);a+=m}if(e.strm.avail_in===0)break;if(l=e.strm,u=e.window,d=e.strstart+e.lookahead,f=a,p=void 0,p=l.avail_in,f=C)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C)if(r=a._tr_tally(e,e.strstart-e.match_start,e.match_length-C),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=C){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-C,r=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-C),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(B(e),e.lookahead===0&&t===l)return O;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,I(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-T&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):(e.strstart>e.block_start&&(I(e,!1),e.strm.avail_out),O)}),new te(4,4,8,4,V),new te(4,5,16,8,V),new te(4,6,32,32,V),new te(4,4,16,16,ee),new te(8,16,32,32,ee),new te(8,16,128,128,ee),new te(8,32,128,256,ee),new te(32,128,258,1024,ee),new te(32,258,258,4096,ee)],n.deflateInit=function(e,t){return H(e,t,g,15,8,0)},n.deflateInit2=H,n.deflateReset=ie,n.deflateResetKeep=re,n.deflateSetHeader=function(e,t){return e&&e.state&&e.state.wrap===2?(e.state.gzhead=t,d):f},n.deflate=function(e,t){var n,i,o,c;if(!e||!e.state||5>8&255),L(i,i.gzhead.time>>16&255),L(i,i.gzhead.time>>24&255),L(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),L(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(L(i,255&i.gzhead.extra.length),L(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(L(i,0),L(i,0),L(i,0),L(i,0),L(i,0),L(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),L(i,3),i.status=D);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:i.level===6?2:3)<<6,i.strstart!==0&&(p|=32),p+=31-p%31,i.status=D,R(i,p),i.strstart!==0&&(R(i,e.adler>>>16),R(i,65535&e.adler)),e.adler=1}if(i.status===69)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending!==i.pending_buf_size));)L(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(i.status===73)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.gzindex=0,i.status=91)}else i.status=91;if(i.status===91)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.status=103)}else i.status=103;if(i.status===103&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&F(e),i.pending+2<=i.pending_buf_size&&(L(i,255&e.adler),L(i,e.adler>>8&255),e.adler=0,i.status=D)):i.status=D),i.pending!==0){if(F(e),e.avail_out===0)return i.last_flush=-1,d}else if(e.avail_in===0&&N(t)<=N(n)&&t!==u)return M(e,-5);if(i.status===666&&e.avail_in!==0)return M(e,-5);if(e.avail_in!==0||i.lookahead!==0||t!==l&&i.status!==666){var m=i.strategy===2?function(e,t){for(var n;;){if(e.lookahead===0&&(B(e),e.lookahead===0)){if(t===l)return O;break}if(e.match_length=0,n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(I(e,!1),e.strm.avail_out===0)?O:k}(i,t):i.strategy===3?function(e,t){for(var n,r,i,o,s=e.window;;){if(e.lookahead<=w){if(B(e),e.lookahead<=w&&t===l)return O;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=C&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=C?(n=a._tr_tally(e,1,e.match_length-C),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(I(e,!1),e.strm.avail_out===0)?O:k}(i,t):r[i.level].func(i,t);if(m!==A&&m!==j||(i.status=666),m===O||m===A)return e.avail_out===0&&(i.last_flush=-1),d;if(m===k&&(t===1?a._tr_align(i):t!==5&&(a._tr_stored_block(i,0,0,!1),t===3&&(P(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),F(e),e.avail_out===0))return i.last_flush=-1,d}return t===u?i.wrap<=0?1:(i.wrap===2?(L(i,255&e.adler),L(i,e.adler>>8&255),L(i,e.adler>>16&255),L(i,e.adler>>24&255),L(i,255&e.total_in),L(i,e.total_in>>8&255),L(i,e.total_in>>16&255),L(i,e.total_in>>24&255)):(R(i,e.adler>>>16),R(i,65535&e.adler)),F(e),0=n.w_size&&(s===0&&(P(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,t,m-n.w_size,n.w_size,0),t=p,m=n.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=m,e.next_in=0,e.input=t,B(n);n.lookahead>=C;){for(r=n.strstart,a=n.lookahead-(C-1);n.ins_h=(n.ins_h<>>=b=y>>>24,m-=b,(b=y>>>16&255)==0)E[a++]=65535&y;else{if(!(16&b)){if(!(64&b)){y=h[(65535&y)+(p&(1<>>=b,m-=b),m<15&&(p+=T[r++]<>>=b=y>>>24,m-=b,!(16&(b=y>>>16&255))){if(!(64&b)){y=g[(65535&y)+(p&(1<>>=b,m-=b,(b=a-o)>3,p&=(1<<(m-=x<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(p),t.distcode=t.distdyn=new r.Buf32(m),t.sane=1,t.back=-1,u):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,_(e)):d}function y(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(a=o.wsize-o.wnext)&&(a=i),r.arraySet(o.window,t,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,B,2,0),x=b=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg=`incorrect header check`,n.mode=30;break}if((15&b)!=8){e.msg=`unknown compression method`,n.mode=30;break}if(x-=4,F=8+(15&(b>>>=4)),n.wbits===0)n.wbits=F;else if(F>n.wbits){e.msg=`invalid window size`,n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(B[0]=255&b,B[1]=b>>>8&255,n.check=a(n.check,B,2,0)),x=b=0,n.mode=3;case 3:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>8&255,B[2]=b>>>16&255,B[3]=b>>>24&255,n.check=a(n.check,B,4,0)),x=b=0,n.mode=4;case 4:for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>8),512&n.flags&&(B[0]=255&b,B[1]=b>>>8&255,n.check=a(n.check,B,2,0)),x=b=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>>8&255,n.check=a(n.check,B,2,0)),x=b=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(v<(E=n.length)&&(E=v),E&&(n.head&&(F=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),r.arraySet(n.head.extra,p,g,E,F)),512&n.flags&&(n.check=a(n.check,p,E,g)),v-=E,g+=E,n.length-=E),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(v===0)break e;for(E=0;F=p[g+ E++],n.head&&F&&n.length<65536&&(n.head.name+=String.fromCharCode(F)),F&&E>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(v===0)break e;v--,b+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(w(n),n.mode=20,t!==6)break;b>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg=`invalid block type`,n.mode=30}b>>>=2,x-=2;break;case 14:for(b>>>=7&x,x-=7&x;x<32;){if(v===0)break e;v--,b+=p[g++]<>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=30;break}if(n.length=65535&b,x=b=0,n.mode=15,t===6)break e;case 15:n.mode=16;case 16:if(E=n.length){if(v>>=5,x-=5,n.ndist=1+(31&b),b>>>=5,x-=5,n.ncode=4+(15&b),b>>>=4,x-=4,286>>=3,x-=3}for(;n.have<19;)n.lens[V[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},I=s(0,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,I){e.msg=`invalid code lengths set`,n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=k,x-=k,n.lens[n.have++]=j;else{if(j===16){for(R=k+2;x>>=k,x-=k,n.have===0){e.msg=`invalid bit length repeat`,n.mode=30;break}F=n.lens[n.have-1],E=3+(3&b),b>>>=2,x-=2}else if(j===17){for(R=k+3;x>>=k)),b>>>=3,x-=3}else{for(R=k+7;x>>=k)),b>>>=7,x-=7}if(n.have+E>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=30;break}for(;E--;)n.lens[n.have++]=F}}if(n.mode===30)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=30;break}if(n.lenbits=9,L={bits:n.lenbits},I=s(c,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,I){e.msg=`invalid literal/lengths set`,n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},I=s(l,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,I){e.msg=`invalid distances set`,n.mode=30;break}if(n.mode=20,t===6)break e;case 20:n.mode=21;case 21:if(6<=v&&258<=y){e.next_out=_,e.avail_out=y,e.next_in=g,e.avail_in=v,n.hold=b,n.bits=x,o(e,C),_=e.next_out,m=e.output,y=e.avail_out,g=e.next_in,p=e.input,v=e.avail_in,b=n.hold,x=n.bits,n.mode===12&&(n.back=-1);break}for(n.back=0;A=(z=n.lencode[b&(1<>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&z,!(M+(k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,n.length=j,A===0){n.mode=26;break}if(32&A){n.back=-1,n.mode=12;break}if(64&A){e.msg=`invalid literal/length code`,n.mode=30;break}n.extra=15&A,n.mode=22;case 22:if(n.extra){for(R=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;A=(z=n.distcode[b&(1<>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&z,!(M+(k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,64&A){e.msg=`invalid distance code`,n.mode=30;break}n.offset=j,n.extra=15&A,n.mode=24;case 24:if(n.extra){for(R=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=30;break}n.mode=25;case 25:if(y===0)break e;if(E=C-y,n.offset>E){if((E=n.offset-E)>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=30;break}D=E>n.wnext?(E-=n.wnext,n.wsize-E):n.wnext-E,E>n.length&&(E=n.length),O=n.window}else O=m,D=_-n.offset,E=n.length;for(yv?(b=L[R+d[w]],N[P+d[w]]):(b=96,0),p=1<>k)+(m-=p)]=y<<24|b<<16|x|0,m!==0;);for(p=1<>=1;if(p===0?M=0:(M&=p-1,M+=p),w++,--F[C]==0){if(C===E)break;C=t[n+d[w]]}if(D>>7)]}function L(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function R(e,t,n){e.bi_valid>h-n?(e.bi_buf|=t<>h-e.bi_valid,e.bi_valid+=n-h):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function V(e,t,n){var r,i,a=Array(m+1),o=0;for(r=1;r<=m;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];s!==0&&(e[2*i]=B(a[s]++,s))}}function ee(e){var t;for(t=0;t>1;1<=n;n--)re(e,a,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],re(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,a[2*i]=a[2*n]+a[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,a[2*n+1]=a[2*r+1]=i,e.heap[1]=i++,re(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,a,o,s,c=t.dyn_tree,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,g=t.stat_desc.max_length,_=0;for(a=0;a<=m;a++)e.bl_count[a]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n>=7;r>>=1)if(1&n&&e.dyn_ltree[2*t]!==0)return i;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return a;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?se(e,t,n,r):e.strategy===4||s===o?(R(e,2+ +!!r,3),ie(e,T,E)):(R(e,4+ +!!r,3),function(e,t,n,r){var i;for(R(e,t-257,5),R(e,n-1,5),R(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,t===0?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(O[n]+l+1)]++,e.dyn_dtree[2*I(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){R(e,2,3),z(e,_,T),function(e){e.bi_valid===16?(L(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){(function(e,t){if(!e.setImmediate){var n,r,i,a,o=1,s={},c=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n={}.toString.call(e.process)===`[object process]`?function(e){process.nextTick(function(){f(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(``,`*`),e.onmessage=n,t}}()?(a=`setImmediate$`+Math.random()+`$`,e.addEventListener?e.addEventListener(`message`,p,!1):e.attachEvent(`onmessage`,p),function(t){e.postMessage(a+t,`*`)}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){f(e.data)},function(e){i.port2.postMessage(e)}):l&&`onreadystatechange`in l.createElement(`script`)?(r=l.documentElement,function(e){var t=l.createElement(`script`);t.onreadystatechange=function(){f(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(f,0,e)},u.setImmediate=function(e){typeof e!=`function`&&(e=Function(``+e));for(var t=Array(arguments.length-1),r=0;r`u`?e===void 0?this:e:self)}).call(this,typeof global<`u`?global:typeof self<`u`?self:typeof window<`u`?window:{})},{}]},{},[10])(10)})}))(),1);function ny(){return new Promise(e=>setTimeout(e,0))}var ry=2e4,iy=2e4;function Qie(e){let t=new Nh;if(!e)return t;let n=e.trim().split(/\s+/).map(parseFloat);return n.length>=12&&t.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),t}var ay=Qie;async function oy(e,t=0){let n=[],r=e.getElementsByTagName(`mesh`);for(let e=0;e0&&e%ry===0&&await ny()}let c=i.getElementsByTagName(`triangle`);for(let e=0;e0&&e%iy===0&&await ny()}a.length>0&&o.length>0&&n.push({vertices:a,triangles:o,extruder:t})}return n}function sy(e){let t=Array.from(e.attributes).find(e=>{let t=e.name.toLowerCase();return t===`plate_id`||t===`plater_id`||t===`plateid`||t===`platerid`||t.endsWith(`:plate_id`)||t.endsWith(`:plater_id`)});if(!t?.value)return null;let n=Number.parseInt(t.value,10);return Number.isFinite(n)?n:null}async function $ie(e){let t;try{t=await Zie.default.loadAsync(e)}catch{throw Error(`Unsupported file format`)}let n=new Map,r=[],i=new Map,a=new Map,o=new DOMParser;async function s(e){let n=e.startsWith(`/`)?e.slice(1):e,r=t.files[n];if(!r)return null;let i=await r.async(`string`);return o.parseFromString(i,`application/xml`)}let c=new Map,l=new Map,u=new Map,d=new Map,f=t.files[`Metadata/model_settings.config`];if(f)try{let e=await f.async(`string`),t=o.parseFromString(e,`application/xml`),n=t.getElementsByTagName(`object`);for(let e=0;ee.tagName===`metadata`&&e.getAttribute(`key`)===`extruder`);if(i.length>0){let e=i[0].getAttribute(`value`);e&&c.set(r,Math.max(0,parseInt(e,10)-1))}let a=Array.from(t.children).find(e=>e.tagName===`metadata`&&e.getAttribute(`key`)===`name`)?.getAttribute(`value`);a&&u.set(r,a);let o=t.getElementsByTagName(`part`);for(let e=0;ee.tagName===`metadata`&&e.getAttribute(`key`)===`extruder`);if(i.length>0){let e=i[0].getAttribute(`value`);e&&l.set(`${r}:${n}`,Math.max(0,parseInt(e,10)-1))}}}let r=t.getElementsByTagName(`plate`);for(let e=0;ee.startsWith(`Metadata/plate_`)&&e.endsWith(`.json`));for(let e of m){let n=e.match(/^Metadata\/plate_(\d+)\.json$/);if(!n)continue;let r=Number.parseInt(n[1],10);if(Number.isFinite(r))try{let n=await t.files[e].async(`string`),a=JSON.parse(n),o=a.bbox_objects??[];for(let e of o)e?.name&&p.set(e.name,r);if(Array.isArray(a.bbox_all)&&a.bbox_all.length>=4){let[e,t,n,o]=a.bbox_all;[e,t,n,o].every(e=>Number.isFinite(e))&&i.set(r,{minX:e,minY:t,maxX:n,maxY:o})}}catch{}}let h=Object.keys(t.files).find(e=>e===`3D/3dmodel.model`||e.endsWith(`/3dmodel.model`));if(!h){let e=Object.keys(t.files).find(e=>e.endsWith(`.model`));if(e){let t=await s(e);if(t){let e=await oy(t,0);e.length>0&&n.set(`1`,{id:`1`,meshes:e,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:a}}let g=await s(h);if(!g)return{objects:n,buildItems:r,plateBounds:i,plateOffsets:a};let _=g.getElementsByTagName(`object`);for(let e=0;e<_.length;e++){e>0&&await ny();let t=_[e],r=t.getAttribute(`id`);if(!r)continue;let i=sy(t)??d.get(r)??null,a=c.get(r)??-1;if(a<0){let e=t.getAttribute(`p:extruder`)||t.getAttributeNS(`http://schemas.microsoft.com/3dmanufacturing/production/2015/06`,`extruder`)||`1`;a=Math.max(0,parseInt(e,10)-1)}let o=[],u=t.getElementsByTagName(`mesh`);for(let e=0;e0&&e%ry===0&&await ny()}let s=t.getElementsByTagName(`triangle`);for(let e=0;e0&&e%iy===0&&await ny()}n.length>0&&r.length>0&&o.push({vertices:n,triangles:r,extruder:a})}let f=t.getElementsByTagName(`component`);for(let e=0;e0&&n.set(r,{id:r,meshes:o,defaultExtruder:a,plateId:i})}let v=g.getElementsByTagName(`build`);if(v.length>0){let e=v[0].getElementsByTagName(`item`);for(let t=0;t{if(e instanceof Kg)if(e.geometry.dispose(),Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material.dispose()})}function tae(e,t,n){let{objects:r,buildItems:i}=e,a=new s_,o=e=>new D_({color:new vg(n?.[e]||`#00ae42`),shininess:30,flatShading:!1}),s=new Map,c=i.some(e=>e.plateId!=null),l=t==null||!c?i:i.filter(e=>e.plateId===t),u=l.length>0?l:i;if(u.length>0)for(let e of u){let t=r.get(e.objectId);if(t)for(let n of t.meshes){let t=e.extruder??n.extruder,r=[];for(let t=0;t1)for(let e of t)e.dispose()}return a}function ly({url:e,fileType:t,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:a=``}){let{t:o}=W(),s=(0,y.useRef)(null),c=(0,y.useRef)(null),l=(0,y.useRef)(null),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=(0,y.useRef)(null),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(!s.current)return;let r=s.current,i=r.clientWidth,a=r.clientHeight,h=new Wte;h.background=new vg(1710618),l.current=h;let _=new r_(45,i/a,.1,1e4);_.position.set(150,150,150),u.current=_;let y=new Pie({antialias:!0});y.setSize(i,a),y.setPixelRatio(window.devicePixelRatio),r.appendChild(y.domElement),c.current=y;let b=new Iie(_,y.domElement);b.enableDamping=!0,b.dampingFactor=.05,d.current=b;let S=new pne(16777215,.6);h.add(S);let w=new H_(16777215,.8);w.position.set(100,100,100),h.add(w);let T=new H_(16777215,.4);T.position.set(-100,50,-100),h.add(T);let E=Math.max(n.x,n.y),D=new Tne(E,Math.ceil(E/16),4473924,3355443);h.add(D),m.current=D;let O=new Kg(new E_(n.x,n.y),new xg({color:44610,transparent:!0,opacity:.15,side:2}));O.rotation.x=-Math.PI/2,O.position.y=-.5,h.add(O),p.current=O;let k,A=()=>{k=requestAnimationFrame(A),b.update(),y.render(h,_)};A(),g(!0),v(null),x(null),C(null);let j=(t||e.split(`?`)[0].split(`.`).pop()||``).toLowerCase(),M={},N=Ku();N&&(M.Authorization=`Bearer ${N}`),j===`stl`?fetch(e,{headers:M}).then(e=>{if(!e.ok)throw Error(o(`modelViewer.errors.failedToLoad`));return e.arrayBuffer()}).then(e=>{let t=new Xie().parse(e);t.computeVertexNormals(),t.rotateX(-Math.PI/2),C(t)}).catch(e=>{v(e.message),g(!1)}):j===`3mf`?fetch(e,{headers:M}).then(e=>{if(!e.ok)throw Error(o(`modelViewer.errors.failedToLoad`));return e.arrayBuffer()}).then($ie).then(e=>{if(e.objects.size===0)throw Error(o(`modelViewer.errors.noMeshes`));x(e)}).catch(e=>{v(e.message),g(!1)}):(v(o(`modelViewer.errors.unsupportedFormat`)),g(!1));let P=()=>{if(!r)return;let e=r.clientWidth,t=r.clientHeight;e===0||t===0||(_.aspect=e/t,_.updateProjectionMatrix(),y.setSize(e,t))};window.addEventListener(`resize`,P);let F=new ResizeObserver(()=>{P()});return F.observe(r),()=>{window.removeEventListener(`resize`,P),F.disconnect(),cancelAnimationFrame(k),b.dispose(),y.dispose(),r.removeChild(y.domElement),f.current=null,p.current=null,m.current=null}},[e,n,t,o]),(0,y.useEffect)(()=>{if(!l.current||!u.current||!d.current||!b&&!S)return;f.current&&(l.current.remove(f.current),eae(f.current));let e=!!S,t=e?(()=>{let e=new Kg(S,new D_({color:new vg(r?.[0]||`#00ae42`),shininess:30})),t=new s_;return t.add(e),t})():tae(b,i??null,r);f.current=t,l.current.add(t);let a=new sh().setFromObject(t),o=a.getCenter(new Um);t.position.y=-a.min.y;let s=!e&&i!=null&&b.buildItems.length>0?b.plateBounds.get(i):void 0,c=!e&&i!=null?b.plateOffsets.get(i):void 0,h=e||b.buildItems.length===0||i!=null&&!s&&!c,_=h?-o.x:0,v=h?-o.z:0,y=0,x=0;if(!e&&i!=null&&b.buildItems.length>0&&s){let e=new sh().setFromObject(t);y=e.min.x-s.minX,x=e.min.z-s.minY}let C=n.x/2,w=n.y/2;!e&&i!=null&&b.buildItems.length>0&&s?(t.position.x=_-y,t.position.z=v-x):!e&&i!=null&&c?(t.position.x=_+(C-c.offsetX),t.position.z=v+(w-c.offsetY)):h?(t.position.x=_+C,t.position.z=v+w):(t.position.x=_,t.position.z=v),p.current&&(p.current.position.x=C,p.current.position.z=w),m.current&&(m.current.position.x=C,m.current.position.z=w);let T=new sh().setFromObject(t),E=T.getCenter(new Um),D=T.getSize(new Um),O=Math.max(D.x,D.y,D.z)*1.8;u.current.position.set(E.x+O*.7,E.y+O*.5,E.z+O*.7),d.current.target.copy(E),d.current.update(),g(!1)},[b,S,i,r,n]);let w=()=>{u.current&&d.current&&(u.current.position.set(150,150,150),d.current.target.set(0,50,0),d.current.update())},T=e=>{u.current&&u.current.position.multiplyScalar(e)};return(0,K.jsxs)(`div`,{className:`relative ${a}`,children:[(0,K.jsx)(`div`,{ref:s,className:`w-full h-full min-h-[400px]`}),h&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}),_&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(`p`,{className:`text-red-400`,children:_})}),!h&&!_&&(0,K.jsxs)(`div`,{className:`absolute bottom-4 right-4 flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>T(.8),children:(0,K.jsx)(zu,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>T(1.25),children:(0,K.jsx)(Vu,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:w,children:(0,K.jsx)(Al,{className:`w-4 h-4`})})]})]})}var uy={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dy={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fy=1e3,py=1001,my=1002,hy=1003,nae=1004,rae=1005,gy=1006,iae=1007,_y=1008,vy=1009,yy=1014,by=1015,xy=1016,Sy=1020,Cy=1023,wy=1026,aae=1027,Ty=2300,Ey=2301,Dy=2302,Oy=2400,ky=2401,Ay=2402,jy=3e3,My=3001,oae=3200,sae=3201,Ny=`srgb`,Py=`srgb-linear`,Fy=`display-p3`,Iy=`display-p3-linear`,Ly=`linear`,Ry=`srgb`,zy=`rec709`,By=7680,Vy=35044,cae=1035,Hy=2e3,lae=2001,Uy=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t>8&255]+Wy[e>>16&255]+Wy[e>>24&255]+`-`+Wy[t&255]+Wy[t>>8&255]+`-`+Wy[t>>16&15|64]+Wy[t>>24&255]+`-`+Wy[n&63|128]+Wy[n>>8&255]+`-`+Wy[n>>16&255]+Wy[n>>24&255]+Wy[r&255]+Wy[r>>8&255]+Wy[r>>16&255]+Wy[r>>24&255]).toLowerCase()}function Yy(e,t,n){return Math.max(t,Math.min(n,e))}function Xy(e,t){return(e%t+t)%t}function uae(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dae(e,t,n){return e===t?0:(n-e)/(t-e)}function Zy(e,t,n){return(1-n)*e+n*t}function fae(e,t,n,r){return Zy(e,t,1-Math.exp(-n*r))}function pae(e,t=1){return t-Math.abs(Xy(e,t*2)-t)}function mae(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function hae(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function gae(e,t){return e+Math.floor(Math.random()*(t-e+1))}function _ae(e,t){return e+Math.random()*(t-e)}function vae(e){return e*(.5-Math.random())}function yae(e){e!==void 0&&(Gy=e);let t=Gy+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function bae(e){return e*Ky}function xae(e){return e*qy}function Qy(e){return(e&e-1)==0&&e!==0}function Sae(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function $y(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Cae(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function eb(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function tb(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var nb={DEG2RAD:Ky,RAD2DEG:qy,generateUUID:Jy,clamp:Yy,euclideanModulo:Xy,mapLinear:uae,inverseLerp:dae,lerp:Zy,damp:fae,pingpong:pae,smoothstep:mae,smootherstep:hae,randInt:gae,randFloat:_ae,randFloatSpread:vae,seededRandom:yae,degToRad:bae,radToDeg:xae,isPowerOfTwo:Qy,ceilPowerOfTwo:Sae,floorPowerOfTwo:$y,setQuaternionFromProperEuler:Cae,normalize:tb,denormalize:eb},rb=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Yy(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ib=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ab.makeScale(e,t)),this}rotate(e){return this.premultiply(ab.makeRotation(-e)),this}translate(e,t){return this.premultiply(ab.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ab=new ib;function ob(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function sb(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function wae(){let e=sb(`canvas`);return e.style.display=`block`,e}var cb={};function lb(e){e in cb||(cb[e]=!0,console.warn(e))}var ub=new ib().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),db=new ib().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),fb={[Py]:{transfer:Ly,primaries:zy,toReference:e=>e,fromReference:e=>e},[Ny]:{transfer:Ry,primaries:zy,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[Iy]:{transfer:Ly,primaries:`p3`,toReference:e=>e.applyMatrix3(db),fromReference:e=>e.applyMatrix3(ub)},[Fy]:{transfer:Ry,primaries:`p3`,toReference:e=>e.convertSRGBToLinear().applyMatrix3(db),fromReference:e=>e.applyMatrix3(ub).convertLinearToSRGB()}},Tae=new Set([Py,Iy]),pb={enabled:!0,_workingColorSpace:Py,get legacyMode(){return console.warn(`THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.`),!this.enabled},set legacyMode(e){console.warn(`THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.`),this.enabled=!e},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!Tae.has(e))throw Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(this.enabled===!1||t===n||!t||!n)return e;let r=fb[t].toReference,i=fb[n].fromReference;return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return fb[e].primaries},getTransfer:function(e){return e===``?Ly:fb[e].transfer}};function mb(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function hb(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var gb,_b=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{gb===void 0&&(gb=sb(`canvas`)),gb.width=e.width,gb.height=e.height;let n=gb.getContext(`2d`);e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=gb}return t.width>2048||t.height>2048?(console.warn(`THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons`,e),t.toDataURL(`image/jpeg`,.6)):t.toDataURL(`image/png`)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=sb(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case fy:e.x-=Math.floor(e.x);break;case py:e.x=e.x<0?0:1;break;case my:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case fy:e.y-=Math.floor(e.y);break;case py:e.y=e.y<0?0:1;break;case my:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return lb(`THREE.Texture: Property .encoding has been replaced by .colorSpace.`),this.colorSpace===`srgb`?My:jy}set encoding(e){lb(`THREE.Texture: Property .encoding has been replaced by .colorSpace.`),this.colorSpace=e===3001?Ny:``}};bb.DEFAULT_IMAGE=null,bb.DEFAULT_MAPPING=300,bb.DEFAULT_ANISOTROPY=1;var xb=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Yy(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Tb=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Db.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Db.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Eb.copy(this).projectOnVector(e),this.sub(Eb)}reflect(e){return this.sub(Eb.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Yy(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Eb=new Tb,Db=new wb,Ob=class{constructor(e=new Tb(1/0,1/0,1/0),t=new Tb(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ab),Ab.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rb),zb.subVectors(this.max,Rb),Mb.subVectors(e.a,Rb),Nb.subVectors(e.b,Rb),Pb.subVectors(e.c,Rb),Fb.subVectors(Nb,Mb),Ib.subVectors(Pb,Nb),Lb.subVectors(Mb,Pb);let t=[0,-Fb.z,Fb.y,0,-Ib.z,Ib.y,0,-Lb.z,Lb.y,Fb.z,0,-Fb.x,Ib.z,0,-Ib.x,Lb.z,0,-Lb.x,-Fb.y,Fb.x,0,-Ib.y,Ib.x,0,-Lb.y,Lb.x,0];return!Hb(t,Mb,Nb,Pb,zb)||(t=[1,0,0,0,1,0,0,0,1],!Hb(t,Mb,Nb,Pb,zb))?!1:(Bb.crossVectors(Fb,Ib),t=[Bb.x,Bb.y,Bb.z],Hb(t,Mb,Nb,Pb,zb))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ab).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ab).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(kb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kb),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},kb=[new Tb,new Tb,new Tb,new Tb,new Tb,new Tb,new Tb,new Tb],Ab=new Tb,jb=new Ob,Mb=new Tb,Nb=new Tb,Pb=new Tb,Fb=new Tb,Ib=new Tb,Lb=new Tb,Rb=new Tb,zb=new Tb,Bb=new Tb,Vb=new Tb;function Hb(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Vb.fromArray(e,a);let o=i.x*Math.abs(Vb.x)+i.y*Math.abs(Vb.y)+i.z*Math.abs(Vb.z),s=t.dot(Vb),c=n.dot(Vb),l=r.dot(Vb);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Aae=new Ob,Ub=new Tb,Wb=new Tb,Gb=class{constructor(e=new Tb,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Aae.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ub.subVectors(e,this.center);let t=Ub.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Ub,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Wb.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ub.copy(e.center).add(Wb)),this.expandByPoint(Ub.copy(e.center).sub(Wb))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Kb=new Tb,qb=new Tb,Jb=new Tb,Yb=new Tb,Xb=new Tb,Zb=new Tb,Qb=new Tb,$b=class{constructor(e=new Tb,t=new Tb(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Kb)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Kb.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kb.copy(this.origin).addScaledVector(this.direction,t),Kb.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){qb.copy(e).add(t).multiplyScalar(.5),Jb.copy(t).sub(e).normalize(),Yb.copy(this.origin).sub(qb);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Jb),o=Yb.dot(this.direction),s=-Yb.dot(Jb),c=Yb.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(qb).addScaledVector(Jb,d),f}intersectSphere(e,t){Kb.subVectors(e.center,this.origin);let n=Kb.dot(this.direction),r=Kb.dot(Kb)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Kb)!==null}intersectTriangle(e,t,n,r,i){Xb.subVectors(t,e),Zb.subVectors(n,e),Qb.crossVectors(Xb,Zb);let a=this.direction.dot(Qb),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Yb.subVectors(this.origin,e);let s=o*this.direction.dot(Zb.crossVectors(Yb,Zb));if(s<0)return null;let c=o*this.direction.dot(Xb.cross(Yb));if(c<0||s+c>a)return null;let l=-o*Yb.dot(Qb);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ex=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/tx.setFromMatrixColumn(e,0).length(),i=1/tx.setFromMatrixColumn(e,1).length(),a=1/tx.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(jae,e,Mae)}lookAt(e,t,n){let r=this.elements;return ax.subVectors(e,t),ax.lengthSq()===0&&(ax.z=1),ax.normalize(),rx.crossVectors(n,ax),rx.lengthSq()===0&&(Math.abs(n.z)===1?ax.x+=1e-4:ax.z+=1e-4,ax.normalize(),rx.crossVectors(n,ax)),rx.normalize(),ix.crossVectors(ax,rx),r[0]=rx.x,r[4]=ix.x,r[8]=ax.x,r[1]=rx.y,r[5]=ix.y,r[9]=ax.y,r[2]=rx.z,r[6]=ix.z,r[10]=ax.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],I=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*I,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*I,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*I,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=tx.set(r[0],r[1],r[2]).length(),a=tx.set(r[4],r[5],r[6]).length(),o=tx.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],nx.copy(this);let s=1/i,c=1/a,l=1/o;return nx.elements[0]*=s,nx.elements[1]*=s,nx.elements[2]*=s,nx.elements[4]*=c,nx.elements[5]*=c,nx.elements[6]*=c,nx.elements[8]*=l,nx.elements[9]*=l,nx.elements[10]*=l,t.setFromRotationMatrix(nx),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Hy){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===2e3)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===2001)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Hy){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===2e3)p=(a+i)*u,m=-2*u;else if(o===2001)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},tx=new Tb,nx=new ex,jae=new Tb(0,0,0),Mae=new Tb(1,1,1),rx=new Tb,ix=new Tb,ax=new Tb,ox=new ex,sx=new wb,cx=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(Yy(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-Yy(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(Yy(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-Yy(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(Yy(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-Yy(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ox.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ox,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sx.setFromEuler(this),this.setFromQuaternion(sx,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};cx.DEFAULT_ORDER=`XYZ`;var lx=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){vx.subVectors(r,t),yx.subVectors(n,t),bx.subVectors(e,t);let a=vx.dot(vx),o=vx.dot(yx),s=vx.dot(bx),c=yx.dot(yx),l=yx.dot(bx),u=a*c-o*o;if(u===0)return i.set(-2,-1,-1);let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,xx),xx.x>=0&&xx.y>=0&&xx.x+xx.y<=1}static getUV(e,t,n,r,i,a,o,s){return Ox===!1&&(console.warn(`THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().`),Ox=!0),this.getInterpolation(e,t,n,r,i,a,o,s)}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,xx),s.setScalar(0),s.addScaledVector(i,xx.x),s.addScaledVector(a,xx.y),s.addScaledVector(o,xx.z),s}static isFrontFacing(e,t,n,r){return vx.subVectors(n,t),yx.subVectors(e,t),vx.cross(yx).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return vx.subVectors(this.c,this.b),yx.subVectors(this.a,this.b),vx.cross(yx).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getUV(t,n,r,i,a){return Ox===!1&&(console.warn(`THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().`),Ox=!0),e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Sx.subVectors(r,n),Cx.subVectors(i,n),Tx.subVectors(e,n);let s=Sx.dot(Tx),c=Cx.dot(Tx);if(s<=0&&c<=0)return t.copy(n);Ex.subVectors(e,r);let l=Sx.dot(Ex),u=Cx.dot(Ex);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Sx,a);Dx.subVectors(e,i);let f=Sx.dot(Dx),p=Cx.dot(Dx);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(Cx,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return wx.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(wx,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Sx,a).addScaledVector(Cx,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},Ax={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},jx={h:0,s:0,l:0},Mx={h:0,s:0,l:0};function Nx(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Px=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ny){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pb.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=pb.workingColorSpace){return this.r=e,this.g=t,this.b=n,pb.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=pb.workingColorSpace){if(e=Xy(e,1),t=Yy(t,0,1),n=Yy(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Nx(i,r,e+1/3),this.g=Nx(i,r,e),this.b=Nx(i,r,e-1/3)}return pb.toWorkingColorSpace(this,r),this}setStyle(e,t=Ny){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ny){let n=Ax[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mb(e.r),this.g=mb(e.g),this.b=mb(e.b),this}copyLinearToSRGB(e){return this.r=hb(e.r),this.g=hb(e.g),this.b=hb(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ny){return pb.fromWorkingColorSpace(Fx.copy(this),e),Math.round(Yy(Fx.r*255,0,255))*65536+Math.round(Yy(Fx.g*255,0,255))*256+Math.round(Yy(Fx.b*255,0,255))}getHexString(e=Ny){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pb.workingColorSpace){pb.fromWorkingColorSpace(Fx.copy(this),t);let n=Fx.r,r=Fx.g,i=Fx.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},Bae=class extends Ix{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Px(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Lx=new Tb,Rx=new rb,zx=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Vy,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=by,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(`THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.`),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Xx.copy(i).invert(),Zx.copy(e.ray).applyMatrix4(Xx),!(n.boundingBox!==null&&Zx.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Zx)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:fS.clone(),object:e}}function mS(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,eS),e.getVertexPosition(c,tS),e.getVertexPosition(l,nS);let u=Hae(e,t,n,r,eS,tS,nS,dS);if(u){i&&(aS.fromBufferAttribute(i,s),oS.fromBufferAttribute(i,c),sS.fromBufferAttribute(i,l),u.uv=kx.getInterpolation(dS,eS,tS,nS,aS,oS,sS,new rb)),a&&(aS.fromBufferAttribute(a,s),oS.fromBufferAttribute(a,c),sS.fromBufferAttribute(a,l),u.uv1=kx.getInterpolation(dS,eS,tS,nS,aS,oS,sS,new rb),u.uv2=u.uv1),o&&(cS.fromBufferAttribute(o,s),lS.fromBufferAttribute(o,c),uS.fromBufferAttribute(o,l),u.normal=kx.getInterpolation(dS,eS,tS,nS,cS,lS,uS,new Tb),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let e={a:s,b:c,c:l,normal:new Tb,materialIndex:0};kx.getNormal(eS,tS,nS,e.normal),u.face=e}return u}var hS=class e extends Yx{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Hx(c,3)),this.setAttribute(`normal`,new Hx(l,3)),this.setAttribute(`uv`,new Hx(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new Tb;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e=this.index;t--)n=(n<<8)+this.byteAt(t);return this.index+=e,n},readString:function(e){return r.transformTo(`string`,this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC(1980+(e>>25&127),(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(31&e)<<1))}},t.exports=i},{"../utils":32}],19:[function(e,t,n){var r=e(`./Uint8ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,t,n){var r=e(`./DataReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)},i.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero},i.prototype.readAndCheckSignature=function(e){return e===this.readData(4)},i.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./DataReader":18}],21:[function(e,t,n){var r=e(`./ArrayReader`);function i(e){r.call(this,e)}e(`../utils`).inherits(i,r),i.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array;var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t},t.exports=i},{"../utils":32,"./ArrayReader":17}],22:[function(e,t,n){var r=e(`../utils`),i=e(`../support`),a=e(`./ArrayReader`),o=e(`./StringReader`),s=e(`./NodeBufferReader`),c=e(`./Uint8ArrayReader`);t.exports=function(e){var t=r.getTypeOf(e);return r.checkSupport(t),t!==`string`||i.uint8array?t===`nodebuffer`?new s(e):i.uint8array?new c(r.transformTo(`uint8array`,e)):new a(r.transformTo(`array`,e)):new o(e)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,t,n){n.LOCAL_FILE_HEADER=`PK`,n.CENTRAL_FILE_HEADER=`PK`,n.CENTRAL_DIRECTORY_END=`PK`,n.ZIP64_CENTRAL_DIRECTORY_LOCATOR=`PK\x07`,n.ZIP64_CENTRAL_DIRECTORY_END=`PK`,n.DATA_DESCRIPTOR=`PK\x07\b`},{}],24:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../utils`);function a(e){r.call(this,`ConvertWorker to `+e),this.destType=e}i.inherits(a,r),a.prototype.processChunk=function(e){this.push({data:i.transformTo(this.destType,e.data),meta:e.meta})},t.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,t,n){var r=e(`./GenericWorker`),i=e(`../crc32`);function a(){r.call(this,`Crc32Probe`),this.withStreamInfo(`crc32`,0)}e(`../utils`).inherits(a,r),a.prototype.processChunk=function(e){this.streamInfo.crc32=i(e.data,this.streamInfo.crc32||0),this.push(e)},t.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataLengthProbe for `+e),this.propName=e,this.withStreamInfo(e,0)}r.inherits(a,i),a.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}i.prototype.processChunk.call(this,e)},t.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,t,n){var r=e(`../utils`),i=e(`./GenericWorker`);function a(e){i.call(this,`DataWorker`);var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type=``,this._tickScheduled=!1,e.then(function(e){t.dataIsReady=!0,t.data=e,t.max=e&&e.length||0,t.type=r.getTypeOf(e),t.isPaused||t._tickAndRepeat()},function(e){t.error(e)})}r.inherits(a,i),a.prototype.cleanUp=function(){i.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!i.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,r.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(r.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=null,t=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case`string`:e=this.data.substring(this.index,t);break;case`uint8array`:e=this.data.subarray(this.index,t);break;case`array`:case`nodebuffer`:e=this.data.slice(this.index,t)}return this.index=t,this.push({data:e,meta:{percent:this.max?this.index/this.max*100:0}})},t.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,t,n){function r(e){this.name=e||`default`,this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}r.prototype={push:function(e){this.emit(`data`,e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit(`end`),this.cleanUp(),this.isFinished=!0}catch(e){this.emit(`error`,e)}return!0},error:function(e){return!this.isFinished&&(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit(`error`,e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n `+e:e}},t.exports=r},{}],29:[function(e,t,n){var r=e(`../utils`),i=e(`./ConvertWorker`),a=e(`./GenericWorker`),o=e(`../base64`),s=e(`../support`),c=e(`../external`),l=null;if(s.nodestream)try{l=e(`../nodejs/NodejsStreamOutputAdapter`)}catch{}function u(e,t){return new c.Promise(function(n,i){var a=[],s=e._internalType,c=e._outputType,l=e._mimeType;e.on(`data`,function(e,n){a.push(e),t&&t(n)}).on(`error`,function(e){a=[],i(e)}).on(`end`,function(){try{n(function(e,t,n){switch(e){case`blob`:return r.newBlob(r.transformTo(`arraybuffer`,t),n);case`base64`:return o.encode(t);default:return r.transformTo(e,t)}}(c,function(e,t){var n,r=0,i=null,a=0;for(n=0;n`u`)n.blob=!1;else{var r=new ArrayBuffer(0);try{n.blob=new Blob([r],{type:`application/zip`}).size===0}catch{try{var i=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);i.append(r),n.blob=i.getBlob(`application/zip`).size===0}catch{n.blob=!1}}}try{n.nodestream=!!e(`readable-stream`).Readable}catch{n.nodestream=!1}},{"readable-stream":16}],31:[function(e,t,n){for(var r=e(`./utils`),i=e(`./support`),a=e(`./nodejsUtils`),o=e(`./stream/GenericWorker`),s=Array(256),c=0;c<256;c++)s[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;s[254]=s[254]=1;function l(){o.call(this,`utf-8 decode`),this.leftOver=null}function u(){o.call(this,`utf-8 encode`)}n.utf8encode=function(e){return i.nodebuffer?a.newBufferFrom(e,`utf-8`):function(e){var t,n,r,a,o,s=e.length,c=0;for(a=0;a>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t}(e)},n.utf8decode=function(e){return i.nodebuffer?r.transformTo(`nodebuffer`,e).toString(`utf-8`):function(e){var t,n,i,a,o=e.length,c=Array(2*o);for(t=n=0;t>10&1023,c[n++]=56320|1023&i)}return c.length!==n&&(c.subarray?c=c.subarray(0,n):c.length=n),r.applyFromCharCode(c)}(e=r.transformTo(i.uint8array?`uint8array`:`array`,e))},r.inherits(l,o),l.prototype.processChunk=function(e){var t=r.transformTo(i.uint8array?`uint8array`:`array`,e.data);if(this.leftOver&&this.leftOver.length){if(i.uint8array){var a=t;(t=new Uint8Array(a.length+this.leftOver.length)).set(this.leftOver,0),t.set(a,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var o=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+s[e[n]]>t?n:t}(t),c=t;o!==t.length&&(i.uint8array?(c=t.subarray(0,o),this.leftOver=t.subarray(o,t.length)):(c=t.slice(0,o),this.leftOver=t.slice(o,t.length))),this.push({data:n.utf8decode(c),meta:e.meta})},l.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:n.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},n.Utf8DecodeWorker=l,r.inherits(u,o),u.prototype.processChunk=function(e){this.push({data:n.utf8encode(e.data),meta:e.meta})},n.Utf8EncodeWorker=u},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,t,n){var r=e(`./support`),i=e(`./base64`),a=e(`./nodejsUtils`),o=e(`./external`);function s(e){return e}function c(e,t){for(var n=0;n>8;this.dir=!!(16&this.externalFileAttributes),e==0&&(this.dosPermissions=63&this.externalFileAttributes),e==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!==`/`||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t,n,r,i=e.index+this.extraFieldsLength;for(this.extraFields||={};e.index+4>>6:(n<65536?t[o++]=224|n>>>12:(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63),t[o++]=128|n>>>6&63),t[o++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new r.Buf8(e.length),n=0,i=t.length;n>10&1023,l[r++]=56320|1023&i)}return c(l,r)},n.utf8border=function(e,t){var n;for((t||=e.length)>e.length&&(t=e.length),n=t-1;0<=n&&(192&e[n])==128;)n--;return n<0||n===0?t:n+o[e[n]]>t?n:t}},{"./common":41}],43:[function(e,t,n){t.exports=function(e,t,n,r){for(var i=65535&e|0,a=e>>>16&65535|0,o=0;n!==0;){for(n-=o=2e3>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var a=r,o=i+n;e^=-1;for(var s=i;s>>8^a[255&(e^t[s])];return-1^e}},{}],46:[function(e,t,n){var r,i=e(`../utils/common`),a=e(`./trees`),o=e(`./adler32`),s=e(`./crc32`),c=e(`./messages`),l=0,u=4,d=0,f=-2,p=-1,m=4,h=2,g=8,_=9,v=286,y=30,b=19,x=2*v+1,S=15,C=3,w=258,T=w+C+1,E=42,D=113,O=1,k=2,A=3,j=4;function M(e,t){return e.msg=c[t],t}function N(e){return(e<<1)-(4e.avail_out&&(n=e.avail_out),n!==0&&(i.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function I(e,t){a._tr_flush_block(e,0<=e.block_start?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,F(e.strm)}function L(e,t){e.pending_buf[e.pending++]=t}function R(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t}function z(e,t){var n,r,i=e.max_chain_length,a=e.strstart,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-T?e.strstart-(e.w_size-T):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+w,p=l[a+o-1],m=l[a+o];e.prev_length>=e.good_match&&(i>>=2),s>e.lookahead&&(s=e.lookahead);do if(l[(n=t)+o]===m&&l[n+o-1]===p&&l[n]===l[a]&&l[++n]===l[a+1]){a+=2,n++;do;while(l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&l[++a]===l[++n]&&ac&&--i!=0);return o<=e.lookahead?o:e.lookahead}function B(e){var t,n,r,a,c,l,u,d,f,p,m=e.w_size;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=m+(m-T)){for(i.arraySet(e.window,e.window,m,m,0),e.match_start-=m,e.strstart-=m,e.block_start-=m,t=n=e.hash_size;r=e.head[--t],e.head[t]=m<=r?r-m:0,--n;);for(t=n=m;r=e.prev[--t],e.prev[t]=m<=r?r-m:0,--n;);a+=m}if(e.strm.avail_in===0)break;if(l=e.strm,u=e.window,d=e.strstart+e.lookahead,f=a,p=void 0,p=l.avail_in,f=C)for(c=e.strstart-e.insert,e.ins_h=e.window[c],e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C)if(r=a._tr_tally(e,e.strstart-e.match_start,e.match_length-C),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=C){for(e.match_length--;e.strstart++,e.ins_h=(e.ins_h<=C&&(e.ins_h=(e.ins_h<=C&&e.match_length<=e.prev_length){for(i=e.strstart+e.lookahead-C,r=a._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-C),e.lookahead-=e.prev_length-1,e.prev_length-=2;++e.strstart<=i&&(e.ins_h=(e.ins_h<e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(B(e),e.lookahead===0&&t===l)return O;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,I(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-T&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):(e.strstart>e.block_start&&(I(e,!1),e.strm.avail_out),O)}),new te(4,4,8,4,V),new te(4,5,16,8,V),new te(4,6,32,32,V),new te(4,4,16,16,ee),new te(8,16,32,32,ee),new te(8,16,128,128,ee),new te(8,32,128,256,ee),new te(32,128,258,1024,ee),new te(32,258,258,4096,ee)],n.deflateInit=function(e,t){return H(e,t,g,15,8,0)},n.deflateInit2=H,n.deflateReset=ie,n.deflateResetKeep=re,n.deflateSetHeader=function(e,t){return e&&e.state&&e.state.wrap===2?(e.state.gzhead=t,d):f},n.deflate=function(e,t){var n,i,o,c;if(!e||!e.state||5>8&255),L(i,i.gzhead.time>>16&255),L(i,i.gzhead.time>>24&255),L(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),L(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(L(i,255&i.gzhead.extra.length),L(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=s(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(L(i,0),L(i,0),L(i,0),L(i,0),L(i,0),L(i,i.level===9?2:2<=i.strategy||i.level<2?4:0),L(i,3),i.status=D);else{var p=g+(i.w_bits-8<<4)<<8;p|=(2<=i.strategy||i.level<2?0:i.level<6?1:i.level===6?2:3)<<6,i.strstart!==0&&(p|=32),p+=31-p%31,i.status=D,R(i,p),i.strstart!==0&&(R(i,e.adler>>>16),R(i,65535&e.adler)),e.adler=1}if(i.status===69)if(i.gzhead.extra){for(o=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending!==i.pending_buf_size));)L(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(i.status===73)if(i.gzhead.name){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.gzindex=0,i.status=91)}else i.status=91;if(i.status===91)if(i.gzhead.comment){o=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>o&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),F(e),o=i.pending,i.pending===i.pending_buf_size)){c=1;break}c=i.gzindexo&&(e.adler=s(e.adler,i.pending_buf,i.pending-o,o)),c===0&&(i.status=103)}else i.status=103;if(i.status===103&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&F(e),i.pending+2<=i.pending_buf_size&&(L(i,255&e.adler),L(i,e.adler>>8&255),e.adler=0,i.status=D)):i.status=D),i.pending!==0){if(F(e),e.avail_out===0)return i.last_flush=-1,d}else if(e.avail_in===0&&N(t)<=N(n)&&t!==u)return M(e,-5);if(i.status===666&&e.avail_in!==0)return M(e,-5);if(e.avail_in!==0||i.lookahead!==0||t!==l&&i.status!==666){var m=i.strategy===2?function(e,t){for(var n;;){if(e.lookahead===0&&(B(e),e.lookahead===0)){if(t===l)return O;break}if(e.match_length=0,n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(I(e,!1),e.strm.avail_out===0)?O:k}(i,t):i.strategy===3?function(e,t){for(var n,r,i,o,s=e.window;;){if(e.lookahead<=w){if(B(e),e.lookahead<=w&&t===l)return O;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=C&&0e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=C?(n=a._tr_tally(e,1,e.match_length-C),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=a._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(I(e,!1),e.strm.avail_out===0))return O}return e.insert=0,t===u?(I(e,!0),e.strm.avail_out===0?A:j):e.last_lit&&(I(e,!1),e.strm.avail_out===0)?O:k}(i,t):r[i.level].func(i,t);if(m!==A&&m!==j||(i.status=666),m===O||m===A)return e.avail_out===0&&(i.last_flush=-1),d;if(m===k&&(t===1?a._tr_align(i):t!==5&&(a._tr_stored_block(i,0,0,!1),t===3&&(P(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),F(e),e.avail_out===0))return i.last_flush=-1,d}return t===u?i.wrap<=0?1:(i.wrap===2?(L(i,255&e.adler),L(i,e.adler>>8&255),L(i,e.adler>>16&255),L(i,e.adler>>24&255),L(i,255&e.total_in),L(i,e.total_in>>8&255),L(i,e.total_in>>16&255),L(i,e.total_in>>24&255)):(R(i,e.adler>>>16),R(i,65535&e.adler)),F(e),0=n.w_size&&(s===0&&(P(n.head),n.strstart=0,n.block_start=0,n.insert=0),p=new i.Buf8(n.w_size),i.arraySet(p,t,m-n.w_size,n.w_size,0),t=p,m=n.w_size),c=e.avail_in,l=e.next_in,u=e.input,e.avail_in=m,e.next_in=0,e.input=t,B(n);n.lookahead>=C;){for(r=n.strstart,a=n.lookahead-(C-1);n.ins_h=(n.ins_h<>>=b=y>>>24,m-=b,(b=y>>>16&255)==0)E[a++]=65535&y;else{if(!(16&b)){if(!(64&b)){y=h[(65535&y)+(p&(1<>>=b,m-=b),m<15&&(p+=T[r++]<>>=b=y>>>24,m-=b,!(16&(b=y>>>16&255))){if(!(64&b)){y=g[(65535&y)+(p&(1<>>=b,m-=b,(b=a-o)>3,p&=(1<<(m-=x<<3))-1,e.next_in=r,e.next_out=a,e.avail_in=r>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function g(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function _(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=``,t.wrap&&(e.adler=1&t.wrap),t.mode=f,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new r.Buf32(p),t.distcode=t.distdyn=new r.Buf32(m),t.sane=1,t.back=-1,u):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,_(e)):d}function y(e,t){var n,r;return e&&e.state?(r=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=o.wsize?(r.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(i<(a=o.wsize-o.wnext)&&(a=i),r.arraySet(o.window,t,n-i,a,o.wnext),(i-=a)?(r.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=a,o.wnext===o.wsize&&(o.wnext=0),o.whave>>8&255,n.check=a(n.check,B,2,0),x=b=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&b)<<8)+(b>>8))%31){e.msg=`incorrect header check`,n.mode=30;break}if((15&b)!=8){e.msg=`unknown compression method`,n.mode=30;break}if(x-=4,F=8+(15&(b>>>=4)),n.wbits===0)n.wbits=F;else if(F>n.wbits){e.msg=`invalid window size`,n.mode=30;break}n.dmax=1<>8&1),512&n.flags&&(B[0]=255&b,B[1]=b>>>8&255,n.check=a(n.check,B,2,0)),x=b=0,n.mode=3;case 3:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>8&255,B[2]=b>>>16&255,B[3]=b>>>24&255,n.check=a(n.check,B,4,0)),x=b=0,n.mode=4;case 4:for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>8),512&n.flags&&(B[0]=255&b,B[1]=b>>>8&255,n.check=a(n.check,B,2,0)),x=b=0,n.mode=5;case 5:if(1024&n.flags){for(;x<16;){if(v===0)break e;v--,b+=p[g++]<>>8&255,n.check=a(n.check,B,2,0)),x=b=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(v<(E=n.length)&&(E=v),E&&(n.head&&(F=n.head.extra_len-n.length,n.head.extra||(n.head.extra=Array(n.head.extra_len)),r.arraySet(n.head.extra,p,g,E,F)),512&n.flags&&(n.check=a(n.check,p,E,g)),v-=E,g+=E,n.length-=E),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(v===0)break e;for(E=0;F=p[g+ E++],n.head&&F&&n.length<65536&&(n.head.name+=String.fromCharCode(F)),F&&E>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;x<32;){if(v===0)break e;v--,b+=p[g++]<>>=7&x,x-=7&x,n.mode=27;break}for(;x<3;){if(v===0)break e;v--,b+=p[g++]<>>=1)){case 0:n.mode=14;break;case 1:if(w(n),n.mode=20,t!==6)break;b>>>=2,x-=2;break e;case 2:n.mode=17;break;case 3:e.msg=`invalid block type`,n.mode=30}b>>>=2,x-=2;break;case 14:for(b>>>=7&x,x-=7&x;x<32;){if(v===0)break e;v--,b+=p[g++]<>>16^65535)){e.msg=`invalid stored block lengths`,n.mode=30;break}if(n.length=65535&b,x=b=0,n.mode=15,t===6)break e;case 15:n.mode=16;case 16:if(E=n.length){if(v>>=5,x-=5,n.ndist=1+(31&b),b>>>=5,x-=5,n.ncode=4+(15&b),b>>>=4,x-=4,286>>=3,x-=3}for(;n.have<19;)n.lens[V[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,L={bits:n.lenbits},I=s(0,n.lens,0,19,n.lencode,0,n.work,L),n.lenbits=L.bits,I){e.msg=`invalid code lengths set`,n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=k,x-=k,n.lens[n.have++]=j;else{if(j===16){for(R=k+2;x>>=k,x-=k,n.have===0){e.msg=`invalid bit length repeat`,n.mode=30;break}F=n.lens[n.have-1],E=3+(3&b),b>>>=2,x-=2}else if(j===17){for(R=k+3;x>>=k)),b>>>=3,x-=3}else{for(R=k+7;x>>=k)),b>>>=7,x-=7}if(n.have+E>n.nlen+n.ndist){e.msg=`invalid bit length repeat`,n.mode=30;break}for(;E--;)n.lens[n.have++]=F}}if(n.mode===30)break;if(n.lens[256]===0){e.msg=`invalid code -- missing end-of-block`,n.mode=30;break}if(n.lenbits=9,L={bits:n.lenbits},I=s(c,n.lens,0,n.nlen,n.lencode,0,n.work,L),n.lenbits=L.bits,I){e.msg=`invalid literal/lengths set`,n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,L={bits:n.distbits},I=s(l,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,L),n.distbits=L.bits,I){e.msg=`invalid distances set`,n.mode=30;break}if(n.mode=20,t===6)break e;case 20:n.mode=21;case 21:if(6<=v&&258<=y){e.next_out=_,e.avail_out=y,e.next_in=g,e.avail_in=v,n.hold=b,n.bits=x,o(e,C),_=e.next_out,m=e.output,y=e.avail_out,g=e.next_in,p=e.input,v=e.avail_in,b=n.hold,x=n.bits,n.mode===12&&(n.back=-1);break}for(n.back=0;A=(z=n.lencode[b&(1<>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&z,!(M+(k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,n.length=j,A===0){n.mode=26;break}if(32&A){n.back=-1,n.mode=12;break}if(64&A){e.msg=`invalid literal/length code`,n.mode=30;break}n.extra=15&A,n.mode=22;case 22:if(n.extra){for(R=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;A=(z=n.distcode[b&(1<>>16&255,j=65535&z,!((k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>M)])>>>16&255,j=65535&z,!(M+(k=z>>>24)<=x);){if(v===0)break e;v--,b+=p[g++]<>>=M,x-=M,n.back+=M}if(b>>>=k,x-=k,n.back+=k,64&A){e.msg=`invalid distance code`,n.mode=30;break}n.offset=j,n.extra=15&A,n.mode=24;case 24:if(n.extra){for(R=n.extra;x>>=n.extra,x-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg=`invalid distance too far back`,n.mode=30;break}n.mode=25;case 25:if(y===0)break e;if(E=C-y,n.offset>E){if((E=n.offset-E)>n.whave&&n.sane){e.msg=`invalid distance too far back`,n.mode=30;break}D=E>n.wnext?(E-=n.wnext,n.wsize-E):n.wnext-E,E>n.length&&(E=n.length),O=n.window}else O=m,D=_-n.offset,E=n.length;for(yv?(b=L[R+d[w]],N[P+d[w]]):(b=96,0),p=1<>k)+(m-=p)]=y<<24|b<<16|x|0,m!==0;);for(p=1<>=1;if(p===0?M=0:(M&=p-1,M+=p),w++,--F[C]==0){if(C===E)break;C=t[n+d[w]]}if(D>>7)]}function L(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function R(e,t,n){e.bi_valid>h-n?(e.bi_buf|=t<>h-e.bi_valid,e.bi_valid+=n-h):(e.bi_buf|=t<>>=1,n<<=1,0<--t;);return n>>>1}function V(e,t,n){var r,i,a=Array(m+1),o=0;for(r=1;r<=m;r++)a[r]=o=o+n[r-1]<<1;for(i=0;i<=t;i++){var s=e[2*i+1];s!==0&&(e[2*i]=B(a[s]++,s))}}function ee(e){var t;for(t=0;t>1;1<=n;n--)re(e,a,n);for(i=c;n=e.heap[1],e.heap[1]=e.heap[e.heap_len--],re(e,a,1),r=e.heap[1],e.heap[--e.heap_max]=n,e.heap[--e.heap_max]=r,a[2*i]=a[2*n]+a[2*r],e.depth[i]=(e.depth[n]>=e.depth[r]?e.depth[n]:e.depth[r])+1,a[2*n+1]=a[2*r+1]=i,e.heap[1]=i++,re(e,a,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var n,r,i,a,o,s,c=t.dyn_tree,l=t.max_code,u=t.stat_desc.static_tree,d=t.stat_desc.has_stree,f=t.stat_desc.extra_bits,h=t.stat_desc.extra_base,g=t.stat_desc.max_length,_=0;for(a=0;a<=m;a++)e.bl_count[a]=0;for(c[2*e.heap[e.heap_max]+1]=0,n=e.heap_max+1;n>=7;r>>=1)if(1&n&&e.dyn_ltree[2*t]!==0)return i;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return a;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=o&&(o=s)):o=s=n+5,n+4<=o&&t!==-1?se(e,t,n,r):e.strategy===4||s===o?(R(e,2+ +!!r,3),ie(e,T,E)):(R(e,4+ +!!r,3),function(e,t,n,r){var i;for(R(e,t-257,5),R(e,n-1,5),R(e,r-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&n,e.last_lit++,t===0?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(O[n]+l+1)]++,e.dyn_dtree[2*I(t)]++),e.last_lit===e.lit_bufsize-1},n._tr_align=function(e){R(e,2,3),z(e,_,T),function(e){e.bi_valid===16?(L(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{"../utils/common":41}],53:[function(e,t,n){t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=``,this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,n){(function(e){(function(e,t){if(!e.setImmediate){var n,r,i,a,o=1,s={},c=!1,l=e.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(e);u=u&&u.setTimeout?u:e,n={}.toString.call(e.process)===`[object process]`?function(e){process.nextTick(function(){f(e)})}:function(){if(e.postMessage&&!e.importScripts){var t=!0,n=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage(``,`*`),e.onmessage=n,t}}()?(a=`setImmediate$`+Math.random()+`$`,e.addEventListener?e.addEventListener(`message`,p,!1):e.attachEvent(`onmessage`,p),function(t){e.postMessage(a+t,`*`)}):e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){f(e.data)},function(e){i.port2.postMessage(e)}):l&&`onreadystatechange`in l.createElement(`script`)?(r=l.documentElement,function(e){var t=l.createElement(`script`);t.onreadystatechange=function(){f(e),t.onreadystatechange=null,r.removeChild(t),t=null},r.appendChild(t)}):function(e){setTimeout(f,0,e)},u.setImmediate=function(e){typeof e!=`function`&&(e=Function(``+e));for(var t=Array(arguments.length-1),r=0;r`u`?e===void 0?this:e:self)}).call(this,typeof global<`u`?global:typeof self<`u`?self:typeof window<`u`?window:{})},{}]},{},[10])(10)})}))(),1);function ny(){return new Promise(e=>setTimeout(e,0))}var ry=2e4,iy=2e4;function Qie(e){let t=new Nh;if(!e)return t;let n=e.trim().split(/\s+/).map(parseFloat);return n.length>=12&&t.set(n[0],n[1],n[2],n[9],n[3],n[4],n[5],n[10],n[6],n[7],n[8],n[11],0,0,0,1),t}var ay=Qie;async function oy(e,t=0){let n=[],r=e.getElementsByTagName(`mesh`);for(let e=0;e0&&e%ry===0&&await ny()}let c=i.getElementsByTagName(`triangle`);for(let e=0;e0&&e%iy===0&&await ny()}a.length>0&&o.length>0&&n.push({vertices:a,triangles:o,extruder:t})}return n}function sy(e){let t=Array.from(e.attributes).find(e=>{let t=e.name.toLowerCase();return t===`plate_id`||t===`plater_id`||t===`plateid`||t===`platerid`||t.endsWith(`:plate_id`)||t.endsWith(`:plater_id`)});if(!t?.value)return null;let n=Number.parseInt(t.value,10);return Number.isFinite(n)?n:null}async function $ie(e){let t;try{t=await Zie.default.loadAsync(e)}catch{throw Error(`Unsupported file format`)}let n=new Map,r=[],i=new Map,a=new Map,o=new DOMParser;async function s(e){let n=e.startsWith(`/`)?e.slice(1):e,r=t.files[n];if(!r)return null;let i=await r.async(`string`);return o.parseFromString(i,`application/xml`)}let c=new Map,l=new Map,u=new Map,d=new Map,f=t.files[`Metadata/model_settings.config`];if(f)try{let e=await f.async(`string`),t=o.parseFromString(e,`application/xml`),n=t.getElementsByTagName(`object`);for(let e=0;ee.tagName===`metadata`&&e.getAttribute(`key`)===`extruder`);if(i.length>0){let e=i[0].getAttribute(`value`);e&&c.set(r,Math.max(0,parseInt(e,10)-1))}let a=Array.from(t.children).find(e=>e.tagName===`metadata`&&e.getAttribute(`key`)===`name`)?.getAttribute(`value`);a&&u.set(r,a);let o=t.getElementsByTagName(`part`);for(let e=0;ee.tagName===`metadata`&&e.getAttribute(`key`)===`extruder`);if(i.length>0){let e=i[0].getAttribute(`value`);e&&l.set(`${r}:${n}`,Math.max(0,parseInt(e,10)-1))}}}let r=t.getElementsByTagName(`plate`);for(let e=0;ee.startsWith(`Metadata/plate_`)&&e.endsWith(`.json`));for(let e of m){let n=e.match(/^Metadata\/plate_(\d+)\.json$/);if(!n)continue;let r=Number.parseInt(n[1],10);if(Number.isFinite(r))try{let n=await t.files[e].async(`string`),a=JSON.parse(n),o=a.bbox_objects??[];for(let e of o)e?.name&&p.set(e.name,r);if(Array.isArray(a.bbox_all)&&a.bbox_all.length>=4){let[e,t,n,o]=a.bbox_all;[e,t,n,o].every(e=>Number.isFinite(e))&&i.set(r,{minX:e,minY:t,maxX:n,maxY:o})}}catch{}}let h=Object.keys(t.files).find(e=>e===`3D/3dmodel.model`||e.endsWith(`/3dmodel.model`));if(!h){let e=Object.keys(t.files).find(e=>e.endsWith(`.model`));if(e){let t=await s(e);if(t){let e=await oy(t,0);e.length>0&&n.set(`1`,{id:`1`,meshes:e,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i,plateOffsets:a}}let g=await s(h);if(!g)return{objects:n,buildItems:r,plateBounds:i,plateOffsets:a};let _=g.getElementsByTagName(`object`);for(let e=0;e<_.length;e++){e>0&&await ny();let t=_[e],r=t.getAttribute(`id`);if(!r)continue;let i=sy(t)??d.get(r)??null,a=c.get(r)??-1;if(a<0){let e=t.getAttribute(`p:extruder`)||t.getAttributeNS(`http://schemas.microsoft.com/3dmanufacturing/production/2015/06`,`extruder`)||`1`;a=Math.max(0,parseInt(e,10)-1)}let o=[],u=t.getElementsByTagName(`mesh`);for(let e=0;e0&&e%ry===0&&await ny()}let s=t.getElementsByTagName(`triangle`);for(let e=0;e0&&e%iy===0&&await ny()}n.length>0&&r.length>0&&o.push({vertices:n,triangles:r,extruder:a})}let f=t.getElementsByTagName(`component`);for(let e=0;e0&&n.set(r,{id:r,meshes:o,defaultExtruder:a,plateId:i})}let v=g.getElementsByTagName(`build`);if(v.length>0){let e=v[0].getElementsByTagName(`item`);for(let t=0;t{if(e instanceof Kg)if(e.geometry.dispose(),Array.isArray(e.material))for(let t of e.material)t.dispose();else e.material.dispose()})}function tae(e,t,n){let{objects:r,buildItems:i}=e,a=new s_,o=e=>new D_({color:new vg(n?.[e]||`#00ae42`),shininess:30,flatShading:!1}),s=new Map,c=i.some(e=>e.plateId!=null),l=t==null||!c?i:i.filter(e=>e.plateId===t),u=l.length>0?l:i;if(u.length>0)for(let e of u){let t=r.get(e.objectId);if(t)for(let n of t.meshes){let t=e.extruder??n.extruder,r=[];for(let t=0;t1)for(let e of t)e.dispose()}return a}function ly({url:e,fileType:t,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:a=``}){let{t:o}=W(),s=(0,y.useRef)(null),c=(0,y.useRef)(null),l=(0,y.useRef)(null),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=(0,y.useRef)(null),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null);(0,y.useEffect)(()=>{if(!s.current)return;let r=s.current,i=r.clientWidth,a=r.clientHeight,h=new Wte;h.background=new vg(1710618),l.current=h;let _=new r_(45,i/a,.1,1e4);_.position.set(150,150,150),u.current=_;let y=new Pie({antialias:!0});y.setSize(i,a),y.setPixelRatio(window.devicePixelRatio),r.appendChild(y.domElement),c.current=y;let b=new Iie(_,y.domElement);b.enableDamping=!0,b.dampingFactor=.05,d.current=b;let S=new pne(16777215,.6);h.add(S);let w=new H_(16777215,.8);w.position.set(100,100,100),h.add(w);let T=new H_(16777215,.4);T.position.set(-100,50,-100),h.add(T);let E=Math.max(n.x,n.y),D=new Tne(E,Math.ceil(E/16),4473924,3355443);h.add(D),m.current=D;let O=new Kg(new E_(n.x,n.y),new xg({color:44610,transparent:!0,opacity:.15,side:2}));O.rotation.x=-Math.PI/2,O.position.y=-.5,h.add(O),p.current=O;let k,A=()=>{k=requestAnimationFrame(A),b.update(),y.render(h,_)};A(),g(!0),v(null),x(null),C(null);let j=(t||e.split(`?`)[0].split(`.`).pop()||``).toLowerCase(),M={},N=Ku();N&&(M.Authorization=`Bearer ${N}`),j===`stl`?fetch(e,{headers:M}).then(e=>{if(!e.ok)throw Error(o(`modelViewer.errors.failedToLoad`));return e.arrayBuffer()}).then(e=>{let t=new Xie().parse(e);t.computeVertexNormals(),t.rotateX(-Math.PI/2),C(t)}).catch(e=>{v(e.message),g(!1)}):j===`3mf`?fetch(e,{headers:M}).then(e=>{if(!e.ok)throw Error(o(`modelViewer.errors.failedToLoad`));return e.arrayBuffer()}).then($ie).then(e=>{if(e.objects.size===0)throw Error(o(`modelViewer.errors.noMeshes`));x(e)}).catch(e=>{v(e.message),g(!1)}):(v(o(`modelViewer.errors.unsupportedFormat`)),g(!1));let P=()=>{if(!r)return;let e=r.clientWidth,t=r.clientHeight;e===0||t===0||(_.aspect=e/t,_.updateProjectionMatrix(),y.setSize(e,t))};window.addEventListener(`resize`,P);let F=new ResizeObserver(()=>{P()});return F.observe(r),()=>{window.removeEventListener(`resize`,P),F.disconnect(),cancelAnimationFrame(k),b.dispose(),y.dispose(),r.removeChild(y.domElement),f.current=null,p.current=null,m.current=null}},[e,n,t,o]),(0,y.useEffect)(()=>{if(!l.current||!u.current||!d.current||!b&&!S)return;f.current&&(l.current.remove(f.current),eae(f.current));let e=!!S,t=e?(()=>{let e=new Kg(S,new D_({color:new vg(r?.[0]||`#00ae42`),shininess:30})),t=new s_;return t.add(e),t})():tae(b,i??null,r);f.current=t,l.current.add(t);let a=new sh().setFromObject(t),o=a.getCenter(new Um);t.position.y=-a.min.y;let s=!e&&i!=null&&b.buildItems.length>0?b.plateBounds.get(i):void 0,c=!e&&i!=null?b.plateOffsets.get(i):void 0,h=e||b.buildItems.length===0||i!=null&&!s&&!c,_=h?-o.x:0,v=h?-o.z:0,y=0,x=0;if(!e&&i!=null&&b.buildItems.length>0&&s){let e=new sh().setFromObject(t);y=e.min.x-s.minX,x=e.min.z-s.minY}let C=n.x/2,w=n.y/2;!e&&i!=null&&b.buildItems.length>0&&s?(t.position.x=_-y,t.position.z=v-x):!e&&i!=null&&c?(t.position.x=_+(C-c.offsetX),t.position.z=v+(w-c.offsetY)):h?(t.position.x=_+C,t.position.z=v+w):(t.position.x=_,t.position.z=v),p.current&&(p.current.position.x=C,p.current.position.z=w),m.current&&(m.current.position.x=C,m.current.position.z=w);let T=new sh().setFromObject(t),E=T.getCenter(new Um),D=T.getSize(new Um),O=Math.max(D.x,D.y,D.z)*1.8;u.current.position.set(E.x+O*.7,E.y+O*.5,E.z+O*.7),d.current.target.copy(E),d.current.update(),g(!1)},[b,S,i,r,n]);let w=()=>{u.current&&d.current&&(u.current.position.set(150,150,150),d.current.target.set(0,50,0),d.current.update())},T=e=>{u.current&&u.current.position.multiplyScalar(e)};return(0,K.jsxs)(`div`,{className:`relative ${a}`,children:[(0,K.jsx)(`div`,{ref:s,className:`w-full h-full min-h-[400px]`}),h&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}),_&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(`p`,{className:`text-red-400`,children:_})}),!h&&!_&&(0,K.jsxs)(`div`,{className:`absolute bottom-4 right-4 flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>T(.8),children:(0,K.jsx)(zu,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>T(1.25),children:(0,K.jsx)(Vu,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:w,children:(0,K.jsx)(Al,{className:`w-4 h-4`})})]})]})}var uy={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},dy={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},fy=1e3,py=1001,my=1002,hy=1003,nae=1004,rae=1005,gy=1006,iae=1007,_y=1008,vy=1009,yy=1014,by=1015,xy=1016,Sy=1020,Cy=1023,wy=1026,aae=1027,Ty=2300,Ey=2301,Dy=2302,Oy=2400,ky=2401,Ay=2402,jy=3e3,My=3001,oae=3200,sae=3201,Ny=`srgb`,Py=`srgb-linear`,Fy=`display-p3`,Iy=`display-p3-linear`,Ly=`linear`,Ry=`srgb`,zy=`rec709`,By=7680,Vy=35044,cae=1035,Hy=2e3,lae=2001,Uy=class{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}dispatchEvent(e){if(this._listeners===void 0)return;let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t>8&255]+Wy[e>>16&255]+Wy[e>>24&255]+`-`+Wy[t&255]+Wy[t>>8&255]+`-`+Wy[t>>16&15|64]+Wy[t>>24&255]+`-`+Wy[n&63|128]+Wy[n>>8&255]+`-`+Wy[n>>16&255]+Wy[n>>24&255]+Wy[r&255]+Wy[r>>8&255]+Wy[r>>16&255]+Wy[r>>24&255]).toLowerCase()}function Yy(e,t,n){return Math.max(t,Math.min(n,e))}function Xy(e,t){return(e%t+t)%t}function uae(e,t,n,r,i){return r+(e-t)*(i-r)/(n-t)}function dae(e,t,n){return e===t?0:(n-e)/(t-e)}function Zy(e,t,n){return(1-n)*e+n*t}function fae(e,t,n,r){return Zy(e,t,1-Math.exp(-n*r))}function pae(e,t=1){return t-Math.abs(Xy(e,t*2)-t)}function mae(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*(3-2*e))}function hae(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t),e*e*e*(e*(e*6-15)+10))}function gae(e,t){return e+Math.floor(Math.random()*(t-e+1))}function _ae(e,t){return e+Math.random()*(t-e)}function vae(e){return e*(.5-Math.random())}function yae(e){e!==void 0&&(Gy=e);let t=Gy+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function bae(e){return e*Ky}function xae(e){return e*qy}function Qy(e){return(e&e-1)==0&&e!==0}function Sae(e){return 2**Math.ceil(Math.log(e)/Math.LN2)}function $y(e){return 2**Math.floor(Math.log(e)/Math.LN2)}function Cae(e,t,n,r,i){let a=Math.cos,o=Math.sin,s=a(n/2),c=o(n/2),l=a((t+r)/2),u=o((t+r)/2),d=a((t-r)/2),f=o((t-r)/2),p=a((r-t)/2),m=o((r-t)/2);switch(i){case`XYX`:e.set(s*u,c*d,c*f,s*l);break;case`YZY`:e.set(c*f,s*u,c*d,s*l);break;case`ZXZ`:e.set(c*d,c*f,s*u,s*l);break;case`XZX`:e.set(s*u,c*m,c*p,s*l);break;case`YXY`:e.set(c*p,s*u,c*m,s*l);break;case`ZYZ`:e.set(c*m,c*p,s*u,s*l);break;default:console.warn(`THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: `+i)}}function eb(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw Error(`Invalid component type.`)}}function tb(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(e*4294967295);case Uint16Array:return Math.round(e*65535);case Uint8Array:return Math.round(e*255);case Int32Array:return Math.round(e*2147483647);case Int16Array:return Math.round(e*32767);case Int8Array:return Math.round(e*127);default:throw Error(`Invalid component type.`)}}var nb={DEG2RAD:Ky,RAD2DEG:qy,generateUUID:Jy,clamp:Yy,euclideanModulo:Xy,mapLinear:uae,inverseLerp:dae,lerp:Zy,damp:fae,pingpong:pae,smoothstep:mae,smootherstep:hae,randInt:gae,randFloat:_ae,randFloatSpread:vae,seededRandom:yae,degToRad:bae,radToDeg:xae,isPowerOfTwo:Qy,ceilPowerOfTwo:Sae,floorPowerOfTwo:$y,setQuaternionFromProperEuler:Cae,normalize:tb,denormalize:eb},rb=class e{constructor(t=0,n=0){e.prototype.isVector2=!0,this.x=t,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Yy(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let n=Math.cos(t),r=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*n-a*r+e.x,this.y=i*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}},ib=class e{constructor(t,n,r,i,a,o,s,c,l){e.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l)}set(e,t,n,r,i,a,o,s,c){let l=this.elements;return l[0]=e,l[1]=r,l[2]=o,l[3]=t,l[4]=i,l[5]=s,l[6]=n,l[7]=a,l[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[3],s=n[6],c=n[1],l=n[4],u=n[7],d=n[2],f=n[5],p=n[8],m=r[0],h=r[3],g=r[6],_=r[1],v=r[4],y=r[7],b=r[2],x=r[5],S=r[8];return i[0]=a*m+o*_+s*b,i[3]=a*h+o*v+s*x,i[6]=a*g+o*y+s*S,i[1]=c*m+l*_+u*b,i[4]=c*h+l*v+u*x,i[7]=c*g+l*y+u*S,i[2]=d*m+f*_+p*b,i[5]=d*h+f*v+p*x,i[8]=d*g+f*y+p*S,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8];return t*a*l-t*o*c-n*i*l+n*o*s+r*i*c-r*a*s}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=l*a-o*c,d=o*s-l*i,f=c*i-a*s,p=t*u+n*d+r*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);let m=1/p;return e[0]=u*m,e[1]=(r*c-l*n)*m,e[2]=(o*n-r*a)*m,e[3]=d*m,e[4]=(l*t-r*s)*m,e[5]=(r*i-o*t)*m,e[6]=f*m,e[7]=(n*s-c*t)*m,e[8]=(a*t-n*i)*m,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,i,a,o){let s=Math.cos(i),c=Math.sin(i);return this.set(n*s,n*c,-n*(s*a+c*o)+a+e,-r*c,r*s,-r*(-c*a+s*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ab.makeScale(e,t)),this}rotate(e){return this.premultiply(ab.makeRotation(-e)),this}translate(e,t){return this.premultiply(ab.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}},ab=new ib;function ob(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}function sb(e){return document.createElementNS(`http://www.w3.org/1999/xhtml`,e)}function wae(){let e=sb(`canvas`);return e.style.display=`block`,e}var cb={};function lb(e){e in cb||(cb[e]=!0,console.warn(e))}var ub=new ib().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),db=new ib().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),fb={[Py]:{transfer:Ly,primaries:zy,toReference:e=>e,fromReference:e=>e},[Ny]:{transfer:Ry,primaries:zy,toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[Iy]:{transfer:Ly,primaries:`p3`,toReference:e=>e.applyMatrix3(db),fromReference:e=>e.applyMatrix3(ub)},[Fy]:{transfer:Ry,primaries:`p3`,toReference:e=>e.convertSRGBToLinear().applyMatrix3(db),fromReference:e=>e.applyMatrix3(ub).convertLinearToSRGB()}},Tae=new Set([Py,Iy]),pb={enabled:!0,_workingColorSpace:Py,get legacyMode(){return console.warn(`THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.`),!this.enabled},set legacyMode(e){console.warn(`THREE.ColorManagement: .legacyMode=false renamed to .enabled=true in r150.`),this.enabled=!e},get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!Tae.has(e))throw Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,n){if(this.enabled===!1||t===n||!t||!n)return e;let r=fb[t].toReference,i=fb[n].fromReference;return i(r(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return fb[e].primaries},getTransfer:function(e){return e===``?Ly:fb[e].transfer}};function mb(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}function hb(e){return e<.0031308?e*12.92:1.055*e**.41666-.055}var gb,_b=class{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>`u`)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{gb===void 0&&(gb=sb(`canvas`)),gb.width=e.width,gb.height=e.height;let n=gb.getContext(`2d`);e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=gb}return t.width>2048||t.height>2048?(console.warn(`THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons`,e),t.toDataURL(`image/jpeg`,.6)):t.toDataURL(`image/png`)}static sRGBToLinear(e){if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let t=sb(`canvas`);t.width=e.width,t.height=e.height;let n=t.getContext(`2d`);n.drawImage(e,0,0,e.width,e.height);let r=n.getImageData(0,0,e.width,e.height),i=r.data;for(let e=0;e0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:`dispose`})}transformUv(e){if(this.mapping!==300)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case fy:e.x-=Math.floor(e.x);break;case py:e.x=e.x<0?0:1;break;case my:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x-=Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case fy:e.y-=Math.floor(e.y);break;case py:e.y=e.y<0?0:1;break;case my:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y-=Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}get encoding(){return lb(`THREE.Texture: Property .encoding has been replaced by .colorSpace.`),this.colorSpace===`srgb`?My:jy}set encoding(e){lb(`THREE.Texture: Property .encoding has been replaced by .colorSpace.`),this.colorSpace=e===3001?Ny:``}};bb.DEFAULT_IMAGE=null,bb.DEFAULT_MAPPING=300,bb.DEFAULT_ANISOTROPY=1;var xb=class e{constructor(t=0,n=0,r=0,i=1){e.prototype.isVector4=!0,this.x=t,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w===void 0?1:e.w,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*i,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*i,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*i,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*i,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);let t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,i,a=.01,o=.1,s=e.elements,c=s[0],l=s[4],u=s[8],d=s[1],f=s[5],p=s[9],m=s[2],h=s[6],g=s[10];if(Math.abs(l-d)s&&e>_?e_?s=0?1:-1,r=1-t*t;if(r>2**-52){let i=Math.sqrt(r),a=Math.atan2(i,t*n);e=Math.sin(e*a)/i,o=Math.sin(o*a)/i}let i=o*n;if(s=s*e+d*i,c=c*e+f*i,l=l*e+p*i,u=u*e+m*i,e===1-o){let e=1/Math.sqrt(s*s+c*c+l*l+u*u);s*=e,c*=e,l*=e,u*=e}}e[t]=s,e[t+1]=c,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,r,i,a){let o=n[r],s=n[r+1],c=n[r+2],l=n[r+3],u=i[a],d=i[a+1],f=i[a+2],p=i[a+3];return e[t]=o*p+l*u+s*f-c*d,e[t+1]=s*p+l*d+c*u-o*f,e[t+2]=c*p+l*f+o*d-s*u,e[t+3]=l*p-o*u-s*d-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){let n=e._x,r=e._y,i=e._z,a=e._order,o=Math.cos,s=Math.sin,c=o(n/2),l=o(r/2),u=o(i/2),d=s(n/2),f=s(r/2),p=s(i/2);switch(a){case`XYZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`YXZ`:this._x=d*l*u+c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`ZXY`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u-d*f*p;break;case`ZYX`:this._x=d*l*u-c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u+d*f*p;break;case`YZX`:this._x=d*l*u+c*f*p,this._y=c*f*u+d*l*p,this._z=c*l*p-d*f*u,this._w=c*l*u-d*f*p;break;case`XZY`:this._x=d*l*u-c*f*p,this._y=c*f*u-d*l*p,this._z=c*l*p+d*f*u,this._w=c*l*u+d*f*p;break;default:console.warn(`THREE.Quaternion: .setFromEuler() encountered an unknown order: `+a)}return t!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,n=t[0],r=t[4],i=t[8],a=t[1],o=t[5],s=t[9],c=t[2],l=t[6],u=t[10],d=n+o+u;if(d>0){let e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(l-s)*e,this._y=(i-c)*e,this._z=(a-r)*e}else if(n>o&&n>u){let e=2*Math.sqrt(1+n-o-u);this._w=(l-s)/e,this._x=.25*e,this._y=(r+a)/e,this._z=(i+c)/e}else if(o>u){let e=2*Math.sqrt(1+o-n-u);this._w=(i-c)/e,this._x=(r+a)/e,this._y=.25*e,this._z=(s+l)/e}else{let e=2*Math.sqrt(1+u-n-o);this._w=(a-r)/e,this._x=(i+c)/e,this._y=(s+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<2**-52?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Yy(this.dot(e),-1,1)))}rotateTowards(e,t){let n=this.angleTo(e);if(n===0)return this;let r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x*=e,this._y*=e,this._z*=e,this._w*=e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let n=e._x,r=e._y,i=e._z,a=e._w,o=t._x,s=t._y,c=t._z,l=t._w;return this._x=n*l+a*o+r*c-i*s,this._y=r*l+a*s+i*o-n*c,this._z=i*l+a*c+n*s-r*o,this._w=a*l-n*o-r*s-i*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);let n=this._x,r=this._y,i=this._z,a=this._w,o=a*e._w+n*e._x+r*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=n,this._y=r,this._z=i,this;let s=1-o*o;if(s<=2**-52){let e=1-t;return this._w=e*a+t*this._w,this._x=e*n+t*this._x,this._y=e*r+t*this._y,this._z=e*i+t*this._z,this.normalize(),this._onChangeCallback(),this}let c=Math.sqrt(s),l=Math.atan2(c,o),u=Math.sin((1-t)*l)/c,d=Math.sin(t*l)/c;return this._w=a*u+this._w*d,this._x=n*u+this._x*d,this._y=r*u+this._y*d,this._z=i*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){let e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),r=2*Math.PI*Math.random(),i=2*Math.PI*Math.random();return this.set(t*Math.cos(r),n*Math.sin(i),n*Math.cos(i),t*Math.sin(r))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},Tb=class e{constructor(t=0,n=0,r=0){e.prototype.isVector3=!0,this.x=t,this.y=n,this.z=r}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw Error(`index is out of range: `+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error(`index is out of range: `+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Db.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Db.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6]*r,this.y=i[1]*t+i[4]*n+i[7]*r,this.z=i[2]*t+i[5]*n+i[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,n=this.y,r=this.z,i=e.elements,a=1/(i[3]*t+i[7]*n+i[11]*r+i[15]);return this.x=(i[0]*t+i[4]*n+i[8]*r+i[12])*a,this.y=(i[1]*t+i[5]*n+i[9]*r+i[13])*a,this.z=(i[2]*t+i[6]*n+i[10]*r+i[14])*a,this}applyQuaternion(e){let t=this.x,n=this.y,r=this.z,i=e.x,a=e.y,o=e.z,s=e.w,c=2*(a*r-o*n),l=2*(o*t-i*r),u=2*(i*n-a*t);return this.x=t+s*c+a*u-o*l,this.y=n+s*l+o*c-i*u,this.z=r+s*u+i*l-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,n=this.y,r=this.z,i=e.elements;return this.x=i[0]*t+i[4]*n+i[8]*r,this.y=i[1]*t+i[5]*n+i[9]*r,this.z=i[2]*t+i[6]*n+i[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){let n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let n=e.x,r=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=r*s-i*o,this.y=i*a-n*s,this.z=n*o-r*a,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Eb.copy(this).projectOnVector(e),this.sub(Eb)}reflect(e){return this.sub(Eb.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let n=this.dot(e)/t;return Math.acos(Yy(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){let r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=(Math.random()-.5)*2,t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}},Eb=new Tb,Db=new wb,Ob=class{constructor(e=new Tb(1/0,1/0,1/0),t=new Tb(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ab),Ab.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Rb),zb.subVectors(this.max,Rb),Mb.subVectors(e.a,Rb),Nb.subVectors(e.b,Rb),Pb.subVectors(e.c,Rb),Fb.subVectors(Nb,Mb),Ib.subVectors(Pb,Nb),Lb.subVectors(Mb,Pb);let t=[0,-Fb.z,Fb.y,0,-Ib.z,Ib.y,0,-Lb.z,Lb.y,Fb.z,0,-Fb.x,Ib.z,0,-Ib.x,Lb.z,0,-Lb.x,-Fb.y,Fb.x,0,-Ib.y,Ib.x,0,-Lb.y,Lb.x,0];return!Hb(t,Mb,Nb,Pb,zb)||(t=[1,0,0,0,1,0,0,0,1],!Hb(t,Mb,Nb,Pb,zb))?!1:(Bb.crossVectors(Fb,Ib),t=[Bb.x,Bb.y,Bb.z],Hb(t,Mb,Nb,Pb,zb))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ab).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Ab).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(kb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),kb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),kb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),kb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),kb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),kb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),kb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),kb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(kb),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},kb=[new Tb,new Tb,new Tb,new Tb,new Tb,new Tb,new Tb,new Tb],Ab=new Tb,jb=new Ob,Mb=new Tb,Nb=new Tb,Pb=new Tb,Fb=new Tb,Ib=new Tb,Lb=new Tb,Rb=new Tb,zb=new Tb,Bb=new Tb,Vb=new Tb;function Hb(e,t,n,r,i){for(let a=0,o=e.length-3;a<=o;a+=3){Vb.fromArray(e,a);let o=i.x*Math.abs(Vb.x)+i.y*Math.abs(Vb.y)+i.z*Math.abs(Vb.z),s=t.dot(Vb),c=n.dot(Vb),l=r.dot(Vb);if(Math.max(-Math.max(s,c,l),Math.min(s,c,l))>o)return!1}return!0}var Aae=new Ob,Ub=new Tb,Wb=new Tb,Gb=class{constructor(e=new Tb,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){let n=this.center;t===void 0?Aae.setFromPoints(e).getCenter(n):n.copy(t);let r=0;for(let t=0,i=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius*=e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ub.subVectors(e,this.center);let t=Ub.lengthSq();if(t>this.radius*this.radius){let e=Math.sqrt(t),n=(e-this.radius)*.5;this.center.addScaledVector(Ub,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Wb.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ub.copy(e.center).add(Wb)),this.expandByPoint(Ub.copy(e.center).sub(Wb))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}},Kb=new Tb,qb=new Tb,Jb=new Tb,Yb=new Tb,Xb=new Tb,Zb=new Tb,Qb=new Tb,$b=class{constructor(e=new Tb,t=new Tb(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Kb)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);let n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){let t=Kb.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Kb.copy(this.origin).addScaledVector(this.direction,t),Kb.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){qb.copy(e).add(t).multiplyScalar(.5),Jb.copy(t).sub(e).normalize(),Yb.copy(this.origin).sub(qb);let i=e.distanceTo(t)*.5,a=-this.direction.dot(Jb),o=Yb.dot(this.direction),s=-Yb.dot(Jb),c=Yb.lengthSq(),l=Math.abs(1-a*a),u,d,f,p;if(l>0)if(u=a*s-o,d=a*o-s,p=i*l,u>=0)if(d>=-p)if(d<=p){let e=1/l;u*=e,d*=e,f=u*(u+a*d+2*o)+d*(a*u+d+2*s)+c}else d=i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d=-i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;else d<=-p?(u=Math.max(0,-(-a*i+o)),d=u>0?-i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c):d<=p?(u=0,d=Math.min(Math.max(-i,-s),i),f=d*(d+2*s)+c):(u=Math.max(0,-(a*i+o)),d=u>0?i:Math.min(Math.max(-i,-s),i),f=-u*u+d*(d+2*s)+c);else d=a>0?-i:i,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*s)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),r&&r.copy(qb).addScaledVector(Jb,d),f}intersectSphere(e,t){Kb.subVectors(e.center,this.origin);let n=Kb.dot(this.direction),r=Kb.dot(Kb)-n*n,i=e.radius*e.radius;if(r>i)return null;let a=Math.sqrt(i-r),o=n-a,s=n+a;return s<0?null:o<0?this.at(s,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){let t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;let n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){let n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){let t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,i,a,o,s,c=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,r=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,r=(e.min.x-d.x)*c),l>=0?(i=(e.min.y-d.y)*l,a=(e.max.y-d.y)*l):(i=(e.max.y-d.y)*l,a=(e.min.y-d.y)*l),n>a||i>r||((i>n||isNaN(n))&&(n=i),(a=0?(o=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||o>r)||((o>n||n!==n)&&(n=o),(s=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Kb)!==null}intersectTriangle(e,t,n,r,i){Xb.subVectors(t,e),Zb.subVectors(n,e),Qb.crossVectors(Xb,Zb);let a=this.direction.dot(Qb),o;if(a>0){if(r)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Yb.subVectors(this.origin,e);let s=o*this.direction.dot(Zb.crossVectors(Yb,Zb));if(s<0)return null;let c=o*this.direction.dot(Xb.cross(Yb));if(c<0||s+c>a)return null;let l=-o*Yb.dot(Qb);return l<0?null:this.at(l/a,i)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},ex=class e{constructor(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){e.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g)}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){let g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=r,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=c,g[6]=l,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=m,g[15]=h,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new e().fromArray(this.elements)}copy(e){let t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){let t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){let t=this.elements,n=e.elements,r=1/tx.setFromMatrixColumn(e,0).length(),i=1/tx.setFromMatrixColumn(e,1).length(),a=1/tx.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*i,t[5]=n[5]*i,t[6]=n[6]*i,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,n=e.x,r=e.y,i=e.z,a=Math.cos(n),o=Math.sin(n),s=Math.cos(r),c=Math.sin(r),l=Math.cos(i),u=Math.sin(i);if(e.order===`XYZ`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=-s*u,t[8]=c,t[1]=n+r*c,t[5]=e-i*c,t[9]=-o*s,t[2]=i-e*c,t[6]=r+n*c,t[10]=a*s}else if(e.order===`YXZ`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e+i*o,t[4]=r*o-n,t[8]=a*c,t[1]=a*u,t[5]=a*l,t[9]=-o,t[2]=n*o-r,t[6]=i+e*o,t[10]=a*s}else if(e.order===`ZXY`){let e=s*l,n=s*u,r=c*l,i=c*u;t[0]=e-i*o,t[4]=-a*u,t[8]=r+n*o,t[1]=n+r*o,t[5]=a*l,t[9]=i-e*o,t[2]=-a*c,t[6]=o,t[10]=a*s}else if(e.order===`ZYX`){let e=a*l,n=a*u,r=o*l,i=o*u;t[0]=s*l,t[4]=r*c-n,t[8]=e*c+i,t[1]=s*u,t[5]=i*c+e,t[9]=n*c-r,t[2]=-c,t[6]=o*s,t[10]=a*s}else if(e.order===`YZX`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=i-e*u,t[8]=r*u+n,t[1]=u,t[5]=a*l,t[9]=-o*l,t[2]=-c*l,t[6]=n*u+r,t[10]=e-i*u}else if(e.order===`XZY`){let e=a*s,n=a*c,r=o*s,i=o*c;t[0]=s*l,t[4]=-u,t[8]=c*l,t[1]=e*u+i,t[5]=a*l,t[9]=n*u-r,t[2]=r*u-n,t[6]=o*l,t[10]=i*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(jae,e,Mae)}lookAt(e,t,n){let r=this.elements;return ax.subVectors(e,t),ax.lengthSq()===0&&(ax.z=1),ax.normalize(),rx.crossVectors(n,ax),rx.lengthSq()===0&&(Math.abs(n.z)===1?ax.x+=1e-4:ax.z+=1e-4,ax.normalize(),rx.crossVectors(n,ax)),rx.normalize(),ix.crossVectors(ax,rx),r[0]=rx.x,r[4]=ix.x,r[8]=ax.x,r[1]=rx.y,r[5]=ix.y,r[9]=ax.y,r[2]=rx.z,r[6]=ix.z,r[10]=ax.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let n=e.elements,r=t.elements,i=this.elements,a=n[0],o=n[4],s=n[8],c=n[12],l=n[1],u=n[5],d=n[9],f=n[13],p=n[2],m=n[6],h=n[10],g=n[14],_=n[3],v=n[7],y=n[11],b=n[15],x=r[0],S=r[4],C=r[8],w=r[12],T=r[1],E=r[5],D=r[9],O=r[13],k=r[2],A=r[6],j=r[10],M=r[14],N=r[3],P=r[7],F=r[11],I=r[15];return i[0]=a*x+o*T+s*k+c*N,i[4]=a*S+o*E+s*A+c*P,i[8]=a*C+o*D+s*j+c*F,i[12]=a*w+o*O+s*M+c*I,i[1]=l*x+u*T+d*k+f*N,i[5]=l*S+u*E+d*A+f*P,i[9]=l*C+u*D+d*j+f*F,i[13]=l*w+u*O+d*M+f*I,i[2]=p*x+m*T+h*k+g*N,i[6]=p*S+m*E+h*A+g*P,i[10]=p*C+m*D+h*j+g*F,i[14]=p*w+m*O+h*M+g*I,i[3]=_*x+v*T+y*k+b*N,i[7]=_*S+v*E+y*A+b*P,i[11]=_*C+v*D+y*j+b*F,i[15]=_*w+v*O+y*M+b*I,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],n=e[4],r=e[8],i=e[12],a=e[1],o=e[5],s=e[9],c=e[13],l=e[2],u=e[6],d=e[10],f=e[14],p=e[3],m=e[7],h=e[11],g=e[15];return p*(+i*s*u-r*c*u-i*o*d+n*c*d+r*o*f-n*s*f)+m*(+t*s*f-t*c*d+i*a*d-r*a*f+r*c*l-i*s*l)+h*(+t*c*u-t*o*f-i*a*u+n*a*f+i*o*l-n*c*l)+g*(-r*o*l-t*s*u+t*o*d+r*a*u-n*a*d+n*s*l)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){let r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){let e=this.elements,t=e[0],n=e[1],r=e[2],i=e[3],a=e[4],o=e[5],s=e[6],c=e[7],l=e[8],u=e[9],d=e[10],f=e[11],p=e[12],m=e[13],h=e[14],g=e[15],_=u*h*c-m*d*c+m*s*f-o*h*f-u*s*g+o*d*g,v=p*d*c-l*h*c-p*s*f+a*h*f+l*s*g-a*d*g,y=l*m*c-p*u*c+p*o*f-a*m*f-l*o*g+a*u*g,b=p*u*s-l*m*s-p*o*d+a*m*d+l*o*h-a*u*h,x=t*_+n*v+r*y+i*b;if(x===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let S=1/x;return e[0]=_*S,e[1]=(m*d*i-u*h*i-m*r*f+n*h*f+u*r*g-n*d*g)*S,e[2]=(o*h*i-m*s*i+m*r*c-n*h*c-o*r*g+n*s*g)*S,e[3]=(u*s*i-o*d*i-u*r*c+n*d*c+o*r*f-n*s*f)*S,e[4]=v*S,e[5]=(l*h*i-p*d*i+p*r*f-t*h*f-l*r*g+t*d*g)*S,e[6]=(p*s*i-a*h*i-p*r*c+t*h*c+a*r*g-t*s*g)*S,e[7]=(a*d*i-l*s*i+l*r*c-t*d*c-a*r*f+t*s*f)*S,e[8]=y*S,e[9]=(p*u*i-l*m*i-p*n*f+t*m*f+l*n*g-t*u*g)*S,e[10]=(a*m*i-p*o*i+p*n*c-t*m*c-a*n*g+t*o*g)*S,e[11]=(l*o*i-a*u*i-l*n*c+t*u*c+a*n*f-t*o*f)*S,e[12]=b*S,e[13]=(l*m*r-p*u*r+p*n*d-t*m*d-l*n*h+t*u*h)*S,e[14]=(p*o*r-a*m*r-p*n*s+t*m*s+a*n*h-t*o*h)*S,e[15]=(a*u*r-l*o*r+l*n*s-t*u*s-a*n*d+t*o*d)*S,this}scale(e){let t=this.elements,n=e.x,r=e.y,i=e.z;return t[0]*=n,t[4]*=r,t[8]*=i,t[1]*=n,t[5]*=r,t[9]*=i,t[2]*=n,t[6]*=r,t[10]*=i,t[3]*=n,t[7]*=r,t[11]*=i,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let n=Math.cos(t),r=Math.sin(t),i=1-n,a=e.x,o=e.y,s=e.z,c=i*a,l=i*o;return this.set(c*a+n,c*o-r*s,c*s+r*o,0,c*o+r*s,l*o+n,l*s-r*a,0,c*s-r*o,l*s+r*a,i*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,i,a){return this.set(1,n,i,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){let r=this.elements,i=t._x,a=t._y,o=t._z,s=t._w,c=i+i,l=a+a,u=o+o,d=i*c,f=i*l,p=i*u,m=a*l,h=a*u,g=o*u,_=s*c,v=s*l,y=s*u,b=n.x,x=n.y,S=n.z;return r[0]=(1-(m+g))*b,r[1]=(f+y)*b,r[2]=(p-v)*b,r[3]=0,r[4]=(f-y)*x,r[5]=(1-(d+g))*x,r[6]=(h+_)*x,r[7]=0,r[8]=(p+v)*S,r[9]=(h-_)*S,r[10]=(1-(d+m))*S,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){let r=this.elements,i=tx.set(r[0],r[1],r[2]).length(),a=tx.set(r[4],r[5],r[6]).length(),o=tx.set(r[8],r[9],r[10]).length();this.determinant()<0&&(i=-i),e.x=r[12],e.y=r[13],e.z=r[14],nx.copy(this);let s=1/i,c=1/a,l=1/o;return nx.elements[0]*=s,nx.elements[1]*=s,nx.elements[2]*=s,nx.elements[4]*=c,nx.elements[5]*=c,nx.elements[6]*=c,nx.elements[8]*=l,nx.elements[9]*=l,nx.elements[10]*=l,t.setFromRotationMatrix(nx),n.x=i,n.y=a,n.z=o,this}makePerspective(e,t,n,r,i,a,o=Hy){let s=this.elements,c=2*i/(t-e),l=2*i/(n-r),u=(t+e)/(t-e),d=(n+r)/(n-r),f,p;if(o===2e3)f=-(a+i)/(a-i),p=-2*a*i/(a-i);else if(o===2001)f=-a/(a-i),p=-a*i/(a-i);else throw Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: `+o);return s[0]=c,s[4]=0,s[8]=u,s[12]=0,s[1]=0,s[5]=l,s[9]=d,s[13]=0,s[2]=0,s[6]=0,s[10]=f,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(e,t,n,r,i,a,o=Hy){let s=this.elements,c=1/(t-e),l=1/(n-r),u=1/(a-i),d=(t+e)*c,f=(n+r)*l,p,m;if(o===2e3)p=(a+i)*u,m=-2*u;else if(o===2001)p=i*u,m=-1*u;else throw Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: `+o);return s[0]=2*c,s[4]=0,s[8]=0,s[12]=-d,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-f,s[2]=0,s[6]=0,s[10]=m,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(e){let t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){let n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}},tx=new Tb,nx=new ex,jae=new Tb(0,0,0),Mae=new Tb(1,1,1),rx=new Tb,ix=new Tb,ax=new Tb,ox=new ex,sx=new wb,cx=class e{constructor(t=0,n=0,r=0,i=e.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){let r=e.elements,i=r[0],a=r[4],o=r[8],s=r[1],c=r[5],l=r[9],u=r[2],d=r[6],f=r[10];switch(t){case`XYZ`:this._y=Math.asin(Yy(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,f),this._z=Math.atan2(-a,i)):(this._x=Math.atan2(d,c),this._z=0);break;case`YXZ`:this._x=Math.asin(-Yy(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(s,c)):(this._y=Math.atan2(-u,i),this._z=0);break;case`ZXY`:this._x=Math.asin(Yy(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(s,i));break;case`ZYX`:this._y=Math.asin(-Yy(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(s,i)):(this._x=0,this._z=Math.atan2(-a,c));break;case`YZX`:this._z=Math.asin(Yy(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-l,c),this._y=Math.atan2(-u,i)):(this._x=0,this._y=Math.atan2(o,f));break;case`XZY`:this._z=Math.asin(-Yy(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,i)):(this._x=Math.atan2(-l,f),this._y=0);break;default:console.warn(`THREE.Euler: .setFromRotationMatrix() encountered an unknown order: `+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ox.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ox,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return sx.setFromEuler(this),this.setFromQuaternion(sx,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};cx.DEFAULT_ORDER=`XYZ`;var lx=class{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type=`InstancedMesh`,r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type=`BatchedMesh`,r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.visibility=this._visibility,r.active=this._active,r.bounds=this._bounds.map(e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()})),r.maxGeometryCount=this._maxGeometryCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.geometryCount=this._geometryCount,r.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(r.boundingSphere={center:r.boundingSphere.center.toArray(),radius:r.boundingSphere.radius}),this.boundingBox!==null&&(r.boundingBox={min:r.boundingBox.min.toArray(),max:r.boundingBox.max.toArray()}));function i(t,n){return t[n.uuid]===void 0&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=i(e.geometries,this.geometry);let t=this.geometry.parameters;if(t!==void 0&&t.shapes!==void 0){let n=t.shapes;if(Array.isArray(n))for(let t=0,r=n.length;t0){r.children=[];for(let t=0;t0){r.animations=[];for(let t=0;t0&&(n.geometries=t),r.length>0&&(n.materials=r),i.length>0&&(n.textures=i),o.length>0&&(n.images=o),s.length>0&&(n.shapes=s),c.length>0&&(n.skeletons=c),l.length>0&&(n.animations=l),u.length>0&&(n.nodes=u)}return n.object=r,n;function a(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let t=0;t0?r.multiplyScalar(1/Math.sqrt(i)):r.set(0,0,0)}static getBarycoord(e,t,n,r,i){yx.subVectors(r,t),bx.subVectors(n,t),xx.subVectors(e,t);let a=yx.dot(yx),o=yx.dot(bx),s=yx.dot(xx),c=bx.dot(bx),l=bx.dot(xx),u=a*c-o*o;if(u===0)return i.set(-2,-1,-1);let d=1/u,f=(c*s-o*l)*d,p=(a*l-o*s)*d;return i.set(1-f-p,p,f)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,Sx),Sx.x>=0&&Sx.y>=0&&Sx.x+Sx.y<=1}static getUV(e,t,n,r,i,a,o,s){return kx===!1&&(console.warn(`THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().`),kx=!0),this.getInterpolation(e,t,n,r,i,a,o,s)}static getInterpolation(e,t,n,r,i,a,o,s){return this.getBarycoord(e,t,n,r,Sx),s.setScalar(0),s.addScaledVector(i,Sx.x),s.addScaledVector(a,Sx.y),s.addScaledVector(o,Sx.z),s}static isFrontFacing(e,t,n,r){return yx.subVectors(n,t),bx.subVectors(e,t),yx.cross(bx).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return yx.subVectors(this.c,this.b),bx.subVectors(this.a,this.b),yx.cross(bx).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return e.getNormal(this.a,this.b,this.c,t)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,n){return e.getBarycoord(t,this.a,this.b,this.c,n)}getUV(t,n,r,i,a){return kx===!1&&(console.warn(`THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation().`),kx=!0),e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}getInterpolation(t,n,r,i,a){return e.getInterpolation(t,this.a,this.b,this.c,n,r,i,a)}containsPoint(t){return e.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return e.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){let n=this.a,r=this.b,i=this.c,a,o;Cx.subVectors(r,n),wx.subVectors(i,n),Ex.subVectors(e,n);let s=Cx.dot(Ex),c=wx.dot(Ex);if(s<=0&&c<=0)return t.copy(n);Dx.subVectors(e,r);let l=Cx.dot(Dx),u=wx.dot(Dx);if(l>=0&&u<=l)return t.copy(r);let d=s*u-l*c;if(d<=0&&s>=0&&l<=0)return a=s/(s-l),t.copy(n).addScaledVector(Cx,a);Ox.subVectors(e,i);let f=Cx.dot(Ox),p=wx.dot(Ox);if(p>=0&&f<=p)return t.copy(i);let m=f*c-s*p;if(m<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(n).addScaledVector(wx,o);let h=l*p-f*u;if(h<=0&&u-l>=0&&f-p>=0)return Tx.subVectors(i,r),o=(u-l)/(u-l+(f-p)),t.copy(r).addScaledVector(Tx,o);let g=1/(h+m+d);return a=m*g,o=d*g,t.copy(n).addScaledVector(Cx,a).addScaledVector(wx,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}},jx={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Mx={h:0,s:0,l:0},Nx={h:0,s:0,l:0};function Px(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*6*(2/3-n):e}var Fx=class{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){let t=e;t&&t.isColor?this.copy(t):typeof t==`number`?this.setHex(t):typeof t==`string`&&this.setStyle(t)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Ny){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pb.toWorkingColorSpace(this,t),this}setRGB(e,t,n,r=pb.workingColorSpace){return this.r=e,this.g=t,this.b=n,pb.toWorkingColorSpace(this,r),this}setHSL(e,t,n,r=pb.workingColorSpace){if(e=Xy(e,1),t=Yy(t,0,1),n=Yy(n,0,1),t===0)this.r=this.g=this.b=n;else{let r=n<=.5?n*(1+t):n+t-n*t,i=2*n-r;this.r=Px(i,r,e+1/3),this.g=Px(i,r,e),this.b=Px(i,r,e-1/3)}return pb.toWorkingColorSpace(this,r),this}setStyle(e,t=Ny){function n(t){t!==void 0&&parseFloat(t)<1&&console.warn(`THREE.Color: Alpha component of `+e+` will be ignored.`)}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let i,a=r[1],o=r[2];switch(a){case`rgb`:case`rgba`:if(i=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(255,parseInt(i[1],10))/255,Math.min(255,parseInt(i[2],10))/255,Math.min(255,parseInt(i[3],10))/255,t);if(i=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setRGB(Math.min(100,parseInt(i[1],10))/100,Math.min(100,parseInt(i[2],10))/100,Math.min(100,parseInt(i[3],10))/100,t);break;case`hsl`:case`hsla`:if(i=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(i[4]),this.setHSL(parseFloat(i[1])/360,parseFloat(i[2])/100,parseFloat(i[3])/100,t);break;default:console.warn(`THREE.Color: Unknown color model `+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){let n=r[1],i=n.length;if(i===3)return this.setRGB(parseInt(n.charAt(0),16)/15,parseInt(n.charAt(1),16)/15,parseInt(n.charAt(2),16)/15,t);if(i===6)return this.setHex(parseInt(n,16),t);console.warn(`THREE.Color: Invalid hex color `+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ny){let n=jx[e.toLowerCase()];return n===void 0?console.warn(`THREE.Color: Unknown color `+e):this.setHex(n,t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mb(e.r),this.g=mb(e.g),this.b=mb(e.b),this}copyLinearToSRGB(e){return this.r=hb(e.r),this.g=hb(e.g),this.b=hb(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ny){return pb.fromWorkingColorSpace(Ix.copy(this),e),Math.round(Yy(Ix.r*255,0,255))*65536+Math.round(Yy(Ix.g*255,0,255))*256+Math.round(Yy(Ix.b*255,0,255))}getHexString(e=Ny){return(`000000`+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pb.workingColorSpace){pb.fromWorkingColorSpace(Ix.copy(this),t);let n=Ix.r,r=Ix.g,i=Ix.b,a=Math.max(n,r,i),o=Math.min(n,r,i),s,c,l=(o+a)/2;if(o===a)s=0,c=0;else{let e=a-o;switch(c=l<=.5?e/(a+o):e/(2-a-o),a){case n:s=(r-i)/e+(r0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(let t in e){let n=e[t];if(n===void 0){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}let r=this[t];if(r===void 0){console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){let t=e===void 0||typeof e==`string`;t&&(e={textures:{},images:{}});let n={metadata:{version:4.6,type:`Material`,generator:`Material.toJSON`}};n.uuid=this.uuid,n.type=this.type,this.name!==``&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==1&&(n.blending=this.blending),this.side!==0&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==204&&(n.blendSrc=this.blendSrc),this.blendDst!==205&&(n.blendDst=this.blendDst),this.blendEquation!==100&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==3&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==519&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==7680&&(n.stencilFail=this.stencilFail),this.stencilZFail!==7680&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==7680&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!==`round`&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!==`round`&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(e){let t=[];for(let n in e){let r=e[n];delete r.metadata,t.push(r)}return t}if(t){let t=r(e.textures),i=r(e.images);t.length>0&&(n.textures=t),i.length>0&&(n.images=i)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;let t=e.clippingPlanes,n=null;if(t!==null){let e=t.length;n=Array(e);for(let r=0;r!==e;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:`dispose`})}set needsUpdate(e){e===!0&&this.version++}},zae=class extends Lx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type=`MeshBasicMaterial`,this.color=new Fx(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap=`round`,this.wireframeLinejoin=`round`,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}},Rx=new Tb,zx=new rb,Bx=class{constructor(e,t,n=!1){if(Array.isArray(e))throw TypeError(`THREE.BufferAttribute: array should be a Typed Array.`);this.isBufferAttribute=!0,this.name=``,this.array=e,this.itemSize=t,this.count=e===void 0?0:e.length/t,this.normalized=n,this.usage=Vy,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=by,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(`THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.`),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,i=this.itemSize;r0&&(e.userData=this.userData),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}e.data={attributes:{}};let t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});let n=this.attributes;for(let t in n){let r=n[t];e.data.attributes[t]=r.toJSON(e.data)}let r={},i=!1;for(let t in this.morphAttributes){let n=this.morphAttributes[t],a=[];for(let t=0,r=n.length;t0&&(r[t]=a,i=!0)}i&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);let a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));let o=this.boundingSphere;return o!==null&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;let t={};this.name=e.name;let n=e.index;n!==null&&this.setIndex(n.clone(t));let r=e.attributes;for(let e in r){let n=r[e];this.setAttribute(e,n.clone(t))}let i=e.morphAttributes;for(let e in i){let n=[],r=i[e];for(let e=0,i=r.length;e0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e(e.far-e.near)**2))&&(Zx.copy(i).invert(),Qx.copy(e.ray).applyMatrix4(Zx),!(n.boundingBox!==null&&Qx.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Qx)))}_computeIntersections(e,t,n){let r,i=this.geometry,a=this.material,o=i.index,s=i.attributes.position,c=i.attributes.uv,l=i.attributes.uv1,u=i.attributes.normal,d=i.groups,f=i.drawRange;if(o!==null)if(Array.isArray(a))for(let i=0,s=d.length;in.far?null:{distance:l,point:pS.clone(),object:e}}function hS(e,t,n,r,i,a,o,s,c,l){e.getVertexPosition(s,tS),e.getVertexPosition(c,nS),e.getVertexPosition(l,rS);let u=Vae(e,t,n,r,tS,nS,rS,fS);if(u){i&&(oS.fromBufferAttribute(i,s),sS.fromBufferAttribute(i,c),cS.fromBufferAttribute(i,l),u.uv=Ax.getInterpolation(fS,tS,nS,rS,oS,sS,cS,new rb)),a&&(oS.fromBufferAttribute(a,s),sS.fromBufferAttribute(a,c),cS.fromBufferAttribute(a,l),u.uv1=Ax.getInterpolation(fS,tS,nS,rS,oS,sS,cS,new rb),u.uv2=u.uv1),o&&(lS.fromBufferAttribute(o,s),uS.fromBufferAttribute(o,c),dS.fromBufferAttribute(o,l),u.normal=Ax.getInterpolation(fS,tS,nS,rS,lS,uS,dS,new Tb),u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1));let e={a:s,b:c,c:l,normal:new Tb,materialIndex:0};Ax.getNormal(tS,nS,rS,e.normal),u.face=e}return u}var gS=class e extends Xx{constructor(e=1,t=1,n=1,r=1,i=1,a=1){super(),this.type=`BoxGeometry`,this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:i,depthSegments:a};let o=this;r=Math.floor(r),i=Math.floor(i),a=Math.floor(a);let s=[],c=[],l=[],u=[],d=0,f=0;p(`z`,`y`,`x`,-1,-1,n,t,e,a,i,0),p(`z`,`y`,`x`,1,-1,n,t,-e,a,i,1),p(`x`,`z`,`y`,1,1,e,n,t,r,a,2),p(`x`,`z`,`y`,1,-1,e,n,-t,r,a,3),p(`x`,`y`,`z`,1,-1,e,t,n,r,i,4),p(`x`,`y`,`z`,-1,-1,e,t,-n,r,i,5),this.setIndex(s),this.setAttribute(`position`,new Ux(c,3)),this.setAttribute(`normal`,new Ux(l,3)),this.setAttribute(`uv`,new Ux(u,2));function p(e,t,n,r,i,a,p,m,h,g,_){let v=a/h,y=p/g,b=a/2,x=p/2,S=m/2,C=h+1,w=g+1,T=0,E=0,D=new Tb;for(let a=0;a0?1:-1,l.push(D.x,D.y,D.z),u.push(s/h),u.push(1-a/g),T+=1}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},xS=class extends _x{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new ex,this.projectionMatrix=new ex,this.projectionMatrixInverse=new ex,this.coordinateSystem=Hy}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},SS=class extends xS{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=qy*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ky*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return qy*2*Math.atan(Math.tan(Ky*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ky*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},CS=-90,wS=1,Kae=class extends _x{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new SS(CS,wS,e,t);r.layers=this.layers,this.add(r);let i=new SS(CS,wS,e,t);i.layers=this.layers,this.add(i);let a=new SS(CS,wS,e,t);a.layers=this.layers,this.add(a);let o=new SS(CS,wS,e,t);o.layers=this.layers,this.add(o);let s=new SS(CS,wS,e,t);s.layers=this.layers,this.add(s);let c=new SS(CS,wS,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,s),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},TS=class extends bb{constructor(e,t,n,r,i,a,o,s,c,l){e=e===void 0?[]:e,t=t===void 0?301:t,super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},qae=class extends Sb{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];t.encoding!==void 0&&(lb(`THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.`),t.colorSpace=t.encoding===3001?Ny:``),this.texture=new TS(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps===void 0?!1:t.generateMipmaps,this.texture.minFilter=t.minFilter===void 0?gy:t.minFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` +}`,xS=class extends Lx{constructor(e){super(),this.isShaderMaterial=!0,this.type=`ShaderMaterial`,this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Uae,this.fragmentShader=Wae,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=_S(e.uniforms),this.uniformsGroups=Hae(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let r=this.uniforms[n].value;r&&r.isTexture?t.uniforms[n]={type:`t`,value:r.toJSON(e).uuid}:r&&r.isColor?t.uniforms[n]={type:`c`,value:r.getHex()}:r&&r.isVector2?t.uniforms[n]={type:`v2`,value:r.toArray()}:r&&r.isVector3?t.uniforms[n]={type:`v3`,value:r.toArray()}:r&&r.isVector4?t.uniforms[n]={type:`v4`,value:r.toArray()}:r&&r.isMatrix3?t.uniforms[n]={type:`m3`,value:r.toArray()}:r&&r.isMatrix4?t.uniforms[n]={type:`m4`,value:r.toArray()}:t.uniforms[n]={value:r}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;let n={};for(let e in this.extensions)this.extensions[e]===!0&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}},SS=class extends vx{constructor(){super(),this.isCamera=!0,this.type=`Camera`,this.matrixWorldInverse=new ex,this.projectionMatrix=new ex,this.projectionMatrixInverse=new ex,this.coordinateSystem=Hy}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}},CS=class extends SS{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type=`PerspectiveCamera`,this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=qy*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(Ky*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return qy*2*Math.atan(Math.tan(Ky*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,n,r,i,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(Ky*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,i=-.5*r,a=this.view;if(this.view!==null&&this.view.enabled){let e=a.fullWidth,o=a.fullHeight;i+=a.offsetX*r/e,t-=a.offsetY*n/o,r*=a.width/e,n*=a.height/o}let o=this.filmOffset;o!==0&&(i+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(i,i+r,t,t-n,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}},wS=-90,TS=1,Gae=class extends vx{constructor(e,t,n){super(),this.type=`CubeCamera`,this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;let r=new CS(wS,TS,e,t);r.layers=this.layers,this.add(r);let i=new CS(wS,TS,e,t);i.layers=this.layers,this.add(i);let a=new CS(wS,TS,e,t);a.layers=this.layers,this.add(a);let o=new CS(wS,TS,e,t);o.layers=this.layers,this.add(o);let s=new CS(wS,TS,e,t);s.layers=this.layers,this.add(s);let c=new CS(wS,TS,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){let e=this.coordinateSystem,t=this.children.concat(),[n,r,i,a,o,s]=t;for(let e of t)this.remove(e);if(e===2e3)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),i.up.set(0,0,-1),i.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),s.up.set(0,1,0),s.lookAt(0,0,-1);else if(e===2001)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),i.up.set(0,0,1),i.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),s.up.set(0,-1,0),s.lookAt(0,0,-1);else throw Error(`THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: `+e);for(let e of t)this.add(e),e.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();let{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());let[i,a,o,s,c,l]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;let m=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,i),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,o),e.setRenderTarget(n,3,r),e.render(t,s),e.setRenderTarget(n,4,r),e.render(t,c),n.texture.generateMipmaps=m,e.setRenderTarget(n,5,r),e.render(t,l),e.setRenderTarget(u,d,f),e.xr.enabled=p,n.texture.needsPMREMUpdate=!0}},ES=class extends bb{constructor(e,t,n,r,i,a,o,s,c,l){e=e===void 0?[]:e,t=t===void 0?301:t,super(e,t,n,r,i,a,o,s,c,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Kae=class extends Sb{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;let n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];t.encoding!==void 0&&(lb(`THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace.`),t.colorSpace=t.encoding===3001?Ny:``),this.texture=new ES(r,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=t.generateMipmaps===void 0?!1:t.generateMipmaps,this.texture.minFilter=t.minFilter===void 0?gy:t.minFilter}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;let n={uniforms:{tEquirect:{value:null}},vertexShader:` varying vec3 vWorldDirection; @@ -4027,7 +4027,7 @@ void main() { gl_FragColor = texture2D( tEquirect, sampleUV ); } - `},r=new hS(5,5,5),i=new bS({name:`CubemapFromEquirect`,uniforms:gS(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});i.uniforms.tEquirect.value=t;let a=new pS(r,i),o=t.minFilter;return t.minFilter===1008&&(t.minFilter=gy),new Kae(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t,n,r){let i=e.getRenderTarget();for(let i=0;i<6;i++)e.setRenderTarget(this,i),e.clear(t,n,r);e.setRenderTarget(i)}},ES=new Tb,Jae=new Tb,Yae=new ib,DS=class{constructor(e=new Tb(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){let r=ES.subVectors(n,t).cross(Jae.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){let n=e.delta(ES),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let i=-(e.start.dot(this.normal)+this.constant)/r;return i<0||i>1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Yae.getNormalMatrix(e),r=this.coplanarPoint(ES).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},OS=new Gb,kS=new Tb,AS=class{constructor(e=new DS,t=new DS,n=new DS,r=new DS,i=new DS,a=new DS){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Hy){let n=this.planes,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=r[8],p=r[9],m=r[10],h=r[11],g=r[12],_=r[13],v=r[14],y=r[15];if(n[0].setComponents(s-i,d-c,h-f,y-g).normalize(),n[1].setComponents(s+i,d+c,h+f,y+g).normalize(),n[2].setComponents(s+a,d+l,h+p,y+_).normalize(),n[3].setComponents(s-a,d-l,h-p,y-_).normalize(),n[4].setComponents(s-o,d-u,h-m,y-v).normalize(),t===2e3)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===2001)n[5].setComponents(o,u,m,v).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),OS.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),OS.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(OS)}intersectsSprite(e){return OS.center.set(0,0,0),OS.radius=.7071067811865476,OS.applyMatrix4(e.matrixWorld),this.intersectsSphere(OS)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,kS.y=r.normal.y>0?e.max.y:e.min.y,kS.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(kS)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function jS(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Xae(e,t){let n=t.isWebGL2,r=new WeakMap;function i(t,r){let i=t.array,a=t.usage,o=i.byteLength,s=e.createBuffer();e.bindBuffer(r,s),e.bufferData(r,i,a),t.onUploadCallback();let c;if(i instanceof Float32Array)c=e.FLOAT;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute)if(n)c=e.HALF_FLOAT;else throw Error(`THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.`);else c=e.UNSIGNED_SHORT;else if(i instanceof Int16Array)c=e.SHORT;else if(i instanceof Uint32Array)c=e.UNSIGNED_INT;else if(i instanceof Int32Array)c=e.INT;else if(i instanceof Int8Array)c=e.BYTE;else if(i instanceof Uint8Array)c=e.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)c=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+i);return{buffer:s,type:c,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:o}}function a(t,r,i){let a=r.array,o=r._updateRange,s=r.updateRanges;if(e.bindBuffer(i,t),o.count===-1&&s.length===0&&e.bufferSubData(i,0,a),s.length!==0){for(let t=0,r=s.length;t1?null:t.copy(e.start).addScaledVector(n,i)}intersectsLine(e){let t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let n=t||Jae.getNormalMatrix(e),r=this.coplanarPoint(DS).applyMatrix4(e),i=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(i),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}},kS=new Gb,AS=new Tb,jS=class{constructor(e=new OS,t=new OS,n=new OS,r=new OS,i=new OS,a=new OS){this.planes=[e,t,n,r,i,a]}set(e,t,n,r,i,a){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(r),o[4].copy(i),o[5].copy(a),this}copy(e){let t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Hy){let n=this.planes,r=e.elements,i=r[0],a=r[1],o=r[2],s=r[3],c=r[4],l=r[5],u=r[6],d=r[7],f=r[8],p=r[9],m=r[10],h=r[11],g=r[12],_=r[13],v=r[14],y=r[15];if(n[0].setComponents(s-i,d-c,h-f,y-g).normalize(),n[1].setComponents(s+i,d+c,h+f,y+g).normalize(),n[2].setComponents(s+a,d+l,h+p,y+_).normalize(),n[3].setComponents(s-a,d-l,h-p,y-_).normalize(),n[4].setComponents(s-o,d-u,h-m,y-v).normalize(),t===2e3)n[5].setComponents(s+o,d+u,h+m,y+v).normalize();else if(t===2001)n[5].setComponents(o,u,m,v).normalize();else throw Error(`THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: `+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),kS.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{let t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),kS.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(kS)}intersectsSprite(e){return kS.center.set(0,0,0),kS.radius=.7071067811865476,kS.applyMatrix4(e.matrixWorld),this.intersectsSphere(kS)}intersectsSphere(e){let t=this.planes,n=e.center,r=-e.radius;for(let e=0;e<6;e++)if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,AS.y=r.normal.y>0?e.max.y:e.min.y,AS.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(AS)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function MS(){let e=null,t=!1,n=null,r=null;function i(t,a){n(t,a),r=e.requestAnimationFrame(i)}return{start:function(){t!==!0&&n!==null&&(r=e.requestAnimationFrame(i),t=!0)},stop:function(){e.cancelAnimationFrame(r),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function Yae(e,t){let n=t.isWebGL2,r=new WeakMap;function i(t,r){let i=t.array,a=t.usage,o=i.byteLength,s=e.createBuffer();e.bindBuffer(r,s),e.bufferData(r,i,a),t.onUploadCallback();let c;if(i instanceof Float32Array)c=e.FLOAT;else if(i instanceof Uint16Array)if(t.isFloat16BufferAttribute)if(n)c=e.HALF_FLOAT;else throw Error(`THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.`);else c=e.UNSIGNED_SHORT;else if(i instanceof Int16Array)c=e.SHORT;else if(i instanceof Uint32Array)c=e.UNSIGNED_INT;else if(i instanceof Int32Array)c=e.INT;else if(i instanceof Int8Array)c=e.BYTE;else if(i instanceof Uint8Array)c=e.UNSIGNED_BYTE;else if(i instanceof Uint8ClampedArray)c=e.UNSIGNED_BYTE;else throw Error(`THREE.WebGLAttributes: Unsupported buffer data format: `+i);return{buffer:s,type:c,bytesPerElement:i.BYTES_PER_ELEMENT,version:t.version,size:o}}function a(t,r,i){let a=r.array,o=r._updateRange,s=r.updateRanges;if(e.bindBuffer(i,t),o.count===-1&&s.length===0&&e.bufferSubData(i,0,a),s.length!==0){for(let t=0,r=s.length;t #include #include -}`},NS={common:{diffuse:{value:new Px(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ib},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ib}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ib}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ib}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ib},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ib},normalScale:{value:new rb(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ib},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ib}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ib}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ib}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Px(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Px(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0},uvTransform:{value:new ib}},sprite:{diffuse:{value:new Px(16777215)},opacity:{value:1},center:{value:new rb(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ib},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0}}},PS={basic:{uniforms:_S([NS.common,NS.specularmap,NS.envmap,NS.aomap,NS.lightmap,NS.fog]),vertexShader:MS.meshbasic_vert,fragmentShader:MS.meshbasic_frag},lambert:{uniforms:_S([NS.common,NS.specularmap,NS.envmap,NS.aomap,NS.lightmap,NS.emissivemap,NS.bumpmap,NS.normalmap,NS.displacementmap,NS.fog,NS.lights,{emissive:{value:new Px(0)}}]),vertexShader:MS.meshlambert_vert,fragmentShader:MS.meshlambert_frag},phong:{uniforms:_S([NS.common,NS.specularmap,NS.envmap,NS.aomap,NS.lightmap,NS.emissivemap,NS.bumpmap,NS.normalmap,NS.displacementmap,NS.fog,NS.lights,{emissive:{value:new Px(0)},specular:{value:new Px(1118481)},shininess:{value:30}}]),vertexShader:MS.meshphong_vert,fragmentShader:MS.meshphong_frag},standard:{uniforms:_S([NS.common,NS.envmap,NS.aomap,NS.lightmap,NS.emissivemap,NS.bumpmap,NS.normalmap,NS.displacementmap,NS.roughnessmap,NS.metalnessmap,NS.fog,NS.lights,{emissive:{value:new Px(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:MS.meshphysical_vert,fragmentShader:MS.meshphysical_frag},toon:{uniforms:_S([NS.common,NS.aomap,NS.lightmap,NS.emissivemap,NS.bumpmap,NS.normalmap,NS.displacementmap,NS.gradientmap,NS.fog,NS.lights,{emissive:{value:new Px(0)}}]),vertexShader:MS.meshtoon_vert,fragmentShader:MS.meshtoon_frag},matcap:{uniforms:_S([NS.common,NS.bumpmap,NS.normalmap,NS.displacementmap,NS.fog,{matcap:{value:null}}]),vertexShader:MS.meshmatcap_vert,fragmentShader:MS.meshmatcap_frag},points:{uniforms:_S([NS.points,NS.fog]),vertexShader:MS.points_vert,fragmentShader:MS.points_frag},dashed:{uniforms:_S([NS.common,NS.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:MS.linedashed_vert,fragmentShader:MS.linedashed_frag},depth:{uniforms:_S([NS.common,NS.displacementmap]),vertexShader:MS.depth_vert,fragmentShader:MS.depth_frag},normal:{uniforms:_S([NS.common,NS.bumpmap,NS.normalmap,NS.displacementmap,{opacity:{value:1}}]),vertexShader:MS.meshnormal_vert,fragmentShader:MS.meshnormal_frag},sprite:{uniforms:_S([NS.sprite,NS.fog]),vertexShader:MS.sprite_vert,fragmentShader:MS.sprite_frag},background:{uniforms:{uvTransform:{value:new ib},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:MS.background_vert,fragmentShader:MS.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:MS.backgroundCube_vert,fragmentShader:MS.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:MS.cube_vert,fragmentShader:MS.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:MS.equirect_vert,fragmentShader:MS.equirect_frag},distanceRGBA:{uniforms:_S([NS.common,NS.displacementmap,{referencePosition:{value:new Tb},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:MS.distanceRGBA_vert,fragmentShader:MS.distanceRGBA_frag},shadow:{uniforms:_S([NS.lights,NS.fog,{color:{value:new Px(0)},opacity:{value:1}}]),vertexShader:MS.shadow_vert,fragmentShader:MS.shadow_frag}};PS.physical={uniforms:_S([PS.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ib},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ib},clearcoatNormalScale:{value:new rb(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ib},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ib},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ib},sheen:{value:0},sheenColor:{value:new Px(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ib},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ib},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ib},transmissionSamplerSize:{value:new rb},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ib},attenuationDistance:{value:0},attenuationColor:{value:new Px(0)},specularColor:{value:new Px(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ib},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ib},anisotropyVector:{value:new rb},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ib}}]),vertexShader:MS.meshphysical_vert,fragmentShader:MS.meshphysical_frag};var FS={r:0,b:0,g:0};function Qae(e,t,n,r,i,a,o){let s=new Px(0),c=a===!0?0:1,l,u,d=null,f=0,p=null;function m(a,m){let g=!1,_=m.isScene===!0?m.background:null;_&&_.isTexture&&(_=(m.backgroundBlurriness>0?n:t).get(_)),_===null?h(s,c):_&&_.isColor&&(h(_,1),g=!0);let v=e.xr.getEnvironmentBlendMode();v===`additive`?r.buffers.color.setClear(0,0,0,1,o):v===`alpha-blend`&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),_&&(_.isCubeTexture||_.mapping===306)?(u===void 0&&(u=new pS(new hS(1,1,1),new bS({name:`BackgroundCubeMaterial`,uniforms:gS(PS.backgroundCube.uniforms),vertexShader:PS.backgroundCube.vertexShader,fragmentShader:PS.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute(`normal`),u.geometry.deleteAttribute(`uv`),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,u.material.toneMapped=pb.getTransfer(_.colorSpace)!==Ry,(d!==_||f!==_.version||p!==e.toneMapping)&&(u.material.needsUpdate=!0,d=_,f=_.version,p=e.toneMapping),u.layers.enableAll(),a.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new pS(new Zae(2,2),new bS({name:`BackgroundMaterial`,uniforms:gS(PS.background.uniforms),vertexShader:PS.background.vertexShader,fragmentShader:PS.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute(`normal`),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=pb.getTransfer(_.colorSpace)!==Ry,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null))}function h(t,n){t.getRGB(FS,vS(e)),r.buffers.color.setClear(FS.r,FS.g,FS.b,n,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,h(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(s,c)},render:m}}function $ae(e,t,n,r){let i=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:t.get(`OES_vertex_array_object`),o=r.isWebGL2||a!==null,s={},c=g(null),l=c,u=!1;function d(t,r,i,a,s){let c=!1;if(o){let e=h(a,i,r);l!==e&&(l=e,p(l.object)),c=_(t,a,i,s),c&&v(t,a,i,s)}else{let e=r.wireframe===!0;(l.geometry!==a.id||l.program!==i.id||l.wireframe!==e)&&(l.geometry=a.id,l.program=i.id,l.wireframe=e,c=!0)}s!==null&&n.update(s,e.ELEMENT_ARRAY_BUFFER),(c||u)&&(u=!1,w(t,r,i,a),s!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(s).buffer))}function f(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}function p(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function m(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function h(e,t,n){let r=n.wireframe===!0,i=s[e.id];i===void 0&&(i={},s[e.id]=i);let a=i[t.id];a===void 0&&(a={},i[t.id]=a);let o=a[r];return o===void 0&&(o=g(f()),a[r]=o),o}function g(e){let t=[],n=[],r=[];for(let e=0;e=0){let n=i[t],r=a[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;o++}return l.attributesNum!==o||l.index!==r}function v(e,t,n,r){let i={},a=t.attributes,o=0,s=n.getAttributes();for(let t in s)if(s[t].location>=0){let n=a[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,o++}l.attributes=i,l.attributesNum=o,l.index=r}function y(){let e=l.newAttributes;for(let t=0,n=e.length;t=0){let o=c[t];if(o===void 0&&(t===`instanceMatrix`&&i.instanceMatrix&&(o=i.instanceMatrix),t===`instanceColor`&&i.instanceColor&&(o=i.instanceColor)),o!==void 0){let t=o.normalized,c=o.itemSize,l=n.get(o);if(l===void 0)continue;let u=l.buffer,d=l.type,f=l.bytesPerElement,p=r.isWebGL2===!0&&(d===e.INT||d===e.UNSIGNED_INT||o.gpuType===1013);if(o.isInterleavedBufferAttribute){let n=o.data,r=n.stride,l=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let o=typeof WebGL2RenderingContext<`u`&&e.constructor.name===`WebGL2RenderingContext`,s=n.precision===void 0?`highp`:n.precision,c=a(s);c!==s&&(console.warn(`THREE.WebGLRenderer:`,s,`not supported, using`,c,`instead.`),s=c);let l=o||t.has(`WEBGL_draw_buffers`),u=n.logarithmicDepthBuffer===!0,d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),f=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),h=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||t.has(`OES_texture_float`),x=y&&b,S=o?e.getParameter(e.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:a,precision:s,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:h,maxVertexUniforms:g,maxVaryings:_,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:x,maxSamples:S}}function noe(e){let t=this,n=null,r=0,i=!1,a=!1,o=new DS,s=new ib,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0){let o=new qae(a.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener(`dispose`,i),n(o.texture,r.mapping)}else return null}}return r}function i(e){let n=e.target;n.removeEventListener(`dispose`,i);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var ioe=class extends xS{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},IS=4,LS=[.125,.215,.35,.446,.526,.582],RS=20,zS=new ioe,BS=new Px,VS=null,HS=0,US=0,WS=(1+Math.sqrt(5))/2,GS=1/WS,KS=[new Tb(1,1,1),new Tb(-1,1,1),new Tb(1,1,-1),new Tb(-1,1,-1),new Tb(0,WS,GS),new Tb(0,WS,-GS),new Tb(GS,0,WS),new Tb(-GS,0,WS),new Tb(WS,GS,0),new Tb(-WS,GS,0)],qS=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){VS=this._renderer.getRenderTarget(),HS=this._renderer.getActiveCubeFace(),US=this._renderer.getActiveMipmapLevel(),this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ZS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=XS(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?c:0,c,c),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=ZS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=XS());let i=r?this._cubemapMaterial:this._equirectMaterial,a=new pS(this._lodPlanes[0],i),o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;YS(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,zS)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;tRS&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${RS}`);let h=[],g=0;for(let e=0;e_-IS?r-_+IS:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,zS)}};function aoe(e){let t=[],n=[],r=[],i=e,a=e-IS+1+LS.length;for(let o=0;oe-IS?s=LS[o-e+IS-1]:o===0&&(s=0),r.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Yx;h.setAttribute(`position`,new zx(f,3)),h.setAttribute(`uv`,new zx(p,2)),h.setAttribute(`faceIndex`,new zx(m,1)),t.push(h),i>IS&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}function JS(e,t,n){let r=new Sb(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function YS(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function ooe(e,t,n){let r=new Float32Array(RS),i=new Tb(0,1,0);return new bS({name:`SphericalGaussianBlur`,defines:{n:RS,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:QS(),fragmentShader:` +}`},PS={common:{diffuse:{value:new Fx(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ib},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ib}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ib}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ib}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ib},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ib},normalScale:{value:new rb(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ib},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ib}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ib}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ib}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Fx(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Fx(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0},uvTransform:{value:new ib}},sprite:{diffuse:{value:new Fx(16777215)},opacity:{value:1},center:{value:new rb(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ib},alphaMap:{value:null},alphaMapTransform:{value:new ib},alphaTest:{value:0}}},FS={basic:{uniforms:vS([PS.common,PS.specularmap,PS.envmap,PS.aomap,PS.lightmap,PS.fog]),vertexShader:NS.meshbasic_vert,fragmentShader:NS.meshbasic_frag},lambert:{uniforms:vS([PS.common,PS.specularmap,PS.envmap,PS.aomap,PS.lightmap,PS.emissivemap,PS.bumpmap,PS.normalmap,PS.displacementmap,PS.fog,PS.lights,{emissive:{value:new Fx(0)}}]),vertexShader:NS.meshlambert_vert,fragmentShader:NS.meshlambert_frag},phong:{uniforms:vS([PS.common,PS.specularmap,PS.envmap,PS.aomap,PS.lightmap,PS.emissivemap,PS.bumpmap,PS.normalmap,PS.displacementmap,PS.fog,PS.lights,{emissive:{value:new Fx(0)},specular:{value:new Fx(1118481)},shininess:{value:30}}]),vertexShader:NS.meshphong_vert,fragmentShader:NS.meshphong_frag},standard:{uniforms:vS([PS.common,PS.envmap,PS.aomap,PS.lightmap,PS.emissivemap,PS.bumpmap,PS.normalmap,PS.displacementmap,PS.roughnessmap,PS.metalnessmap,PS.fog,PS.lights,{emissive:{value:new Fx(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:NS.meshphysical_vert,fragmentShader:NS.meshphysical_frag},toon:{uniforms:vS([PS.common,PS.aomap,PS.lightmap,PS.emissivemap,PS.bumpmap,PS.normalmap,PS.displacementmap,PS.gradientmap,PS.fog,PS.lights,{emissive:{value:new Fx(0)}}]),vertexShader:NS.meshtoon_vert,fragmentShader:NS.meshtoon_frag},matcap:{uniforms:vS([PS.common,PS.bumpmap,PS.normalmap,PS.displacementmap,PS.fog,{matcap:{value:null}}]),vertexShader:NS.meshmatcap_vert,fragmentShader:NS.meshmatcap_frag},points:{uniforms:vS([PS.points,PS.fog]),vertexShader:NS.points_vert,fragmentShader:NS.points_frag},dashed:{uniforms:vS([PS.common,PS.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:NS.linedashed_vert,fragmentShader:NS.linedashed_frag},depth:{uniforms:vS([PS.common,PS.displacementmap]),vertexShader:NS.depth_vert,fragmentShader:NS.depth_frag},normal:{uniforms:vS([PS.common,PS.bumpmap,PS.normalmap,PS.displacementmap,{opacity:{value:1}}]),vertexShader:NS.meshnormal_vert,fragmentShader:NS.meshnormal_frag},sprite:{uniforms:vS([PS.sprite,PS.fog]),vertexShader:NS.sprite_vert,fragmentShader:NS.sprite_frag},background:{uniforms:{uvTransform:{value:new ib},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:NS.background_vert,fragmentShader:NS.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:NS.backgroundCube_vert,fragmentShader:NS.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:NS.cube_vert,fragmentShader:NS.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:NS.equirect_vert,fragmentShader:NS.equirect_frag},distanceRGBA:{uniforms:vS([PS.common,PS.displacementmap,{referencePosition:{value:new Tb},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:NS.distanceRGBA_vert,fragmentShader:NS.distanceRGBA_frag},shadow:{uniforms:vS([PS.lights,PS.fog,{color:{value:new Fx(0)},opacity:{value:1}}]),vertexShader:NS.shadow_vert,fragmentShader:NS.shadow_frag}};FS.physical={uniforms:vS([FS.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ib},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ib},clearcoatNormalScale:{value:new rb(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ib},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ib},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ib},sheen:{value:0},sheenColor:{value:new Fx(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ib},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ib},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ib},transmissionSamplerSize:{value:new rb},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ib},attenuationDistance:{value:0},attenuationColor:{value:new Fx(0)},specularColor:{value:new Fx(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ib},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ib},anisotropyVector:{value:new rb},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ib}}]),vertexShader:NS.meshphysical_vert,fragmentShader:NS.meshphysical_frag};var IS={r:0,b:0,g:0};function Zae(e,t,n,r,i,a,o){let s=new Fx(0),c=a===!0?0:1,l,u,d=null,f=0,p=null;function m(a,m){let g=!1,_=m.isScene===!0?m.background:null;_&&_.isTexture&&(_=(m.backgroundBlurriness>0?n:t).get(_)),_===null?h(s,c):_&&_.isColor&&(h(_,1),g=!0);let v=e.xr.getEnvironmentBlendMode();v===`additive`?r.buffers.color.setClear(0,0,0,1,o):v===`alpha-blend`&&r.buffers.color.setClear(0,0,0,0,o),(e.autoClear||g)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),_&&(_.isCubeTexture||_.mapping===306)?(u===void 0&&(u=new mS(new gS(1,1,1),new xS({name:`BackgroundCubeMaterial`,uniforms:_S(FS.backgroundCube.uniforms),vertexShader:FS.backgroundCube.vertexShader,fragmentShader:FS.backgroundCube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),u.geometry.deleteAttribute(`normal`),u.geometry.deleteAttribute(`uv`),u.onBeforeRender=function(e,t,n){this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(u.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(u)),u.material.uniforms.envMap.value=_,u.material.uniforms.flipEnvMap.value=_.isCubeTexture&&_.isRenderTargetTexture===!1?-1:1,u.material.uniforms.backgroundBlurriness.value=m.backgroundBlurriness,u.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,u.material.toneMapped=pb.getTransfer(_.colorSpace)!==Ry,(d!==_||f!==_.version||p!==e.toneMapping)&&(u.material.needsUpdate=!0,d=_,f=_.version,p=e.toneMapping),u.layers.enableAll(),a.unshift(u,u.geometry,u.material,0,0,null)):_&&_.isTexture&&(l===void 0&&(l=new mS(new Xae(2,2),new xS({name:`BackgroundMaterial`,uniforms:_S(FS.background.uniforms),vertexShader:FS.background.vertexShader,fragmentShader:FS.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute(`normal`),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=_,l.material.uniforms.backgroundIntensity.value=m.backgroundIntensity,l.material.toneMapped=pb.getTransfer(_.colorSpace)!==Ry,_.matrixAutoUpdate===!0&&_.updateMatrix(),l.material.uniforms.uvTransform.value.copy(_.matrix),(d!==_||f!==_.version||p!==e.toneMapping)&&(l.material.needsUpdate=!0,d=_,f=_.version,p=e.toneMapping),l.layers.enableAll(),a.unshift(l,l.geometry,l.material,0,0,null))}function h(t,n){t.getRGB(IS,yS(e)),r.buffers.color.setClear(IS.r,IS.g,IS.b,n,o)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),c=t,h(s,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,h(s,c)},render:m}}function Qae(e,t,n,r){let i=e.getParameter(e.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:t.get(`OES_vertex_array_object`),o=r.isWebGL2||a!==null,s={},c=g(null),l=c,u=!1;function d(t,r,i,a,s){let c=!1;if(o){let e=h(a,i,r);l!==e&&(l=e,p(l.object)),c=_(t,a,i,s),c&&v(t,a,i,s)}else{let e=r.wireframe===!0;(l.geometry!==a.id||l.program!==i.id||l.wireframe!==e)&&(l.geometry=a.id,l.program=i.id,l.wireframe=e,c=!0)}s!==null&&n.update(s,e.ELEMENT_ARRAY_BUFFER),(c||u)&&(u=!1,w(t,r,i,a),s!==null&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.get(s).buffer))}function f(){return r.isWebGL2?e.createVertexArray():a.createVertexArrayOES()}function p(t){return r.isWebGL2?e.bindVertexArray(t):a.bindVertexArrayOES(t)}function m(t){return r.isWebGL2?e.deleteVertexArray(t):a.deleteVertexArrayOES(t)}function h(e,t,n){let r=n.wireframe===!0,i=s[e.id];i===void 0&&(i={},s[e.id]=i);let a=i[t.id];a===void 0&&(a={},i[t.id]=a);let o=a[r];return o===void 0&&(o=g(f()),a[r]=o),o}function g(e){let t=[],n=[],r=[];for(let e=0;e=0){let n=i[t],r=a[t];if(r===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(r=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(r=e.instanceColor)),n===void 0||n.attribute!==r||r&&n.data!==r.data)return!0;o++}return l.attributesNum!==o||l.index!==r}function v(e,t,n,r){let i={},a=t.attributes,o=0,s=n.getAttributes();for(let t in s)if(s[t].location>=0){let n=a[t];n===void 0&&(t===`instanceMatrix`&&e.instanceMatrix&&(n=e.instanceMatrix),t===`instanceColor`&&e.instanceColor&&(n=e.instanceColor));let r={};r.attribute=n,n&&n.data&&(r.data=n.data),i[t]=r,o++}l.attributes=i,l.attributesNum=o,l.index=r}function y(){let e=l.newAttributes;for(let t=0,n=e.length;t=0){let o=c[t];if(o===void 0&&(t===`instanceMatrix`&&i.instanceMatrix&&(o=i.instanceMatrix),t===`instanceColor`&&i.instanceColor&&(o=i.instanceColor)),o!==void 0){let t=o.normalized,c=o.itemSize,l=n.get(o);if(l===void 0)continue;let u=l.buffer,d=l.type,f=l.bytesPerElement,p=r.isWebGL2===!0&&(d===e.INT||d===e.UNSIGNED_INT||o.gpuType===1013);if(o.isInterleavedBufferAttribute){let n=o.data,r=n.stride,l=o.offset;if(n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.HIGH_FLOAT).precision>0)return`highp`;t=`mediump`}return t===`mediump`&&e.getShaderPrecisionFormat(e.VERTEX_SHADER,e.MEDIUM_FLOAT).precision>0&&e.getShaderPrecisionFormat(e.FRAGMENT_SHADER,e.MEDIUM_FLOAT).precision>0?`mediump`:`lowp`}let o=typeof WebGL2RenderingContext<`u`&&e.constructor.name===`WebGL2RenderingContext`,s=n.precision===void 0?`highp`:n.precision,c=a(s);c!==s&&(console.warn(`THREE.WebGLRenderer:`,s,`not supported, using`,c,`instead.`),s=c);let l=o||t.has(`WEBGL_draw_buffers`),u=n.logarithmicDepthBuffer===!0,d=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),f=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS),p=e.getParameter(e.MAX_TEXTURE_SIZE),m=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE),h=e.getParameter(e.MAX_VERTEX_ATTRIBS),g=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS),_=e.getParameter(e.MAX_VARYING_VECTORS),v=e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),y=f>0,b=o||t.has(`OES_texture_float`),x=y&&b,S=o?e.getParameter(e.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:l,getMaxAnisotropy:i,getMaxPrecision:a,precision:s,logarithmicDepthBuffer:u,maxTextures:d,maxVertexTextures:f,maxTextureSize:p,maxCubemapSize:m,maxAttributes:h,maxVertexUniforms:g,maxVaryings:_,maxFragmentUniforms:v,vertexTextures:y,floatFragmentTextures:b,floatVertexTextures:x,maxSamples:S}}function toe(e){let t=this,n=null,r=0,i=!1,a=!1,o=new OS,s=new ib,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t){let n=e.length!==0||t||r!==0||i;return i=t,r=e.length,n},this.beginShadows=function(){a=!0,u(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(e,t){n=u(e,t,0)},this.setState=function(t,o,s){let d=t.clippingPlanes,f=t.clipIntersection,p=t.clipShadows,m=e.get(t);if(!i||d===null||d.length===0||a&&!p)a?u(null):l();else{let e=a?0:r,t=e*4,i=m.clippingState||null;c.value=i,i=u(d,o,t,s);for(let e=0;e!==t;++e)i[e]=n[e];m.clippingState=i,this.numIntersection=f?this.numPlanes:0,this.numPlanes+=e}};function l(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),t.numPlanes=r,t.numIntersection=0}function u(e,n,r,i){let a=e===null?0:e.length,l=null;if(a!==0){if(l=c.value,i!==!0||l===null){let t=r+a*4,i=n.matrixWorldInverse;s.getNormalMatrix(i),(l===null||l.length0){let o=new Kae(a.height/2);return o.fromEquirectangularTexture(e,r),t.set(r,o),r.addEventListener(`dispose`,i),n(o.texture,r.mapping)}else return null}}return r}function i(e){let n=e.target;n.removeEventListener(`dispose`,i);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function a(){t=new WeakMap}return{get:r,dispose:a}}var roe=class extends SS{constructor(e=-1,t=1,n=1,r=-1,i=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type=`OrthographicCamera`,this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=i,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,i,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=i,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2,i=n-e,a=n+e,o=r+t,s=r-t;if(this.view!==null&&this.view.enabled){let e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;i+=e*this.view.offsetX,a=i+e*this.view.width,o-=t*this.view.offsetY,s=o-t*this.view.height}this.projectionMatrix.makeOrthographic(i,a,o,s,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){let t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}},LS=4,RS=[.125,.215,.35,.446,.526,.582],zS=20,BS=new roe,VS=new Fx,HS=null,US=0,WS=0,GS=(1+Math.sqrt(5))/2,KS=1/GS,qS=[new Tb(1,1,1),new Tb(-1,1,1),new Tb(1,1,-1),new Tb(-1,1,-1),new Tb(0,GS,KS),new Tb(0,GS,-KS),new Tb(KS,0,GS),new Tb(-KS,0,GS),new Tb(GS,KS,0),new Tb(-GS,KS,0)],JS=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100){HS=this._renderer.getRenderTarget(),US=this._renderer.getActiveCubeFace(),WS=this._renderer.getActiveMipmapLevel(),this._setSize(256);let i=this._allocateTargets();return i.depthBuffer=!0,this._sceneToCubeUV(e,n,r,i),t>0&&this._blur(i,0,0,t),this._applyPMREM(i),this._cleanup(i),i}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=QS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ZS(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=2**this._lodMax}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?c:0,c,c),s.setRenderTarget(r),f&&s.render(d,i),s.render(e,i)}d.geometry.dispose(),d.material.dispose(),s.toneMapping=l,s.autoClear=c,e.background=p}_textureToCubeUV(e,t){let n=this._renderer,r=e.mapping===301||e.mapping===302;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=QS()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ZS());let i=r?this._cubemapMaterial:this._equirectMaterial,a=new mS(this._lodPlanes[0],i),o=i.uniforms;o.envMap.value=e;let s=this._cubeSize;XS(t,0,0,3*s,2*s),n.setRenderTarget(t),n.render(a,BS)}_applyPMREM(e){let t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;tzS&&console.warn(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${zS}`);let h=[],g=0;for(let e=0;e_-LS?r-_+LS:0),4*(this._cubeSize-v),3*v,2*v),s.setRenderTarget(t),s.render(l,BS)}};function ioe(e){let t=[],n=[],r=[],i=e,a=e-LS+1+RS.length;for(let o=0;oe-LS?s=RS[o-e+LS-1]:o===0&&(s=0),r.push(s);let c=1/(a-2),l=-c,u=1+c,d=[l,l,u,l,u,u,l,l,u,u,l,u],f=new Float32Array(108),p=new Float32Array(72),m=new Float32Array(36);for(let e=0;e<6;e++){let t=e%3*2/3-1,n=e>2?0:-1,r=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];f.set(r,18*e),p.set(d,12*e);let i=[e,e,e,e,e,e];m.set(i,6*e)}let h=new Xx;h.setAttribute(`position`,new Bx(f,3)),h.setAttribute(`uv`,new Bx(p,2)),h.setAttribute(`faceIndex`,new Bx(m,1)),t.push(h),i>LS&&i--}return{lodPlanes:t,sizeLods:n,sigmas:r}}function YS(e,t,n){let r=new Sb(e,t,n);return r.texture.mapping=306,r.texture.name=`PMREM.cubeUv`,r.scissorTest=!0,r}function XS(e,t,n,r,i){e.viewport.set(t,n,r,i),e.scissor.set(t,n,r,i)}function aoe(e,t,n){let r=new Float32Array(zS),i=new Tb(0,1,0);return new xS({name:`SphericalGaussianBlur`,defines:{n:zS,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${e}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:$S(),fragmentShader:` precision mediump float; precision mediump int; @@ -7480,7 +7480,7 @@ void main() { } } - `,blending:0,depthTest:!1,depthWrite:!1})}function XS(){return new bS({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:QS(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function ZS(){return new xS({name:`EquirectangularToCubeUV`,uniforms:{envMap:{value:null}},vertexShader:$S(),fragmentShader:` precision mediump float; precision mediump int; @@ -7499,7 +7499,7 @@ void main() { gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function ZS(){return new bS({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:QS(),fragmentShader:` + `,blending:0,depthTest:!1,depthWrite:!1})}function QS(){return new xS({name:`CubemapToCubeUV`,uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:$S(),fragmentShader:` precision mediump float; precision mediump int; @@ -7515,7 +7515,7 @@ void main() { gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); } - `,blending:0,depthTest:!1,depthWrite:!1})}function QS(){return` + `,blending:0,depthTest:!1,depthWrite:!1})}function $S(){return` precision mediump float; precision mediump int; @@ -7570,39 +7570,39 @@ void main() { gl_Position = vec4( position, 1.0 ); } - `}function soe(e){let t=new WeakMap,n=null;function r(r){if(r&&r.isTexture){let o=r.mapping,s=o===303||o===304,c=o===301||o===302;if(s||c)if(r.isRenderTargetTexture&&r.needsPMREMUpdate===!0){r.needsPMREMUpdate=!1;let i=t.get(r);return n===null&&(n=new qS(e)),i=s?n.fromEquirectangular(r,i):n.fromCubemap(r,i),t.set(r,i),i.texture}else if(t.has(r))return t.get(r).texture;else{let o=r.image;if(s&&o&&o.height>0||c&&o&&i(o)){n===null&&(n=new qS(e));let i=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,i),r.addEventListener(`dispose`,a),i.texture}else return null}}return r}function i(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function a(e){let n=e.target;n.removeEventListener(`dispose`,a);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function o(){t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function coe(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r;switch(n){case`WEBGL_depth_texture`:r=e.getExtension(`WEBGL_depth_texture`)||e.getExtension(`MOZ_WEBGL_depth_texture`)||e.getExtension(`WEBKIT_WEBGL_depth_texture`);break;case`EXT_texture_filter_anisotropic`:r=e.getExtension(`EXT_texture_filter_anisotropic`)||e.getExtension(`MOZ_EXT_texture_filter_anisotropic`)||e.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`);break;case`WEBGL_compressed_texture_s3tc`:r=e.getExtension(`WEBGL_compressed_texture_s3tc`)||e.getExtension(`MOZ_WEBGL_compressed_texture_s3tc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_s3tc`);break;case`WEBGL_compressed_texture_pvrtc`:r=e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`);break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(e){e.isWebGL2?n(`EXT_color_buffer_float`):(n(`WEBGL_depth_texture`),n(`OES_texture_float`),n(`OES_texture_half_float`),n(`OES_texture_half_float_linear`),n(`OES_standard_derivatives`),n(`OES_element_index_uint`),n(`OES_vertex_array_object`),n(`ANGLE_instanced_arrays`)),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`)},get:function(e){let t=n(e);return t===null&&console.warn(`THREE.WebGLRenderer: `+e+` extension not supported.`),t}}}function loe(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);for(let e in s.morphAttributes){let n=s.morphAttributes[e];for(let e=0,r=n.length;et.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*i),g=new Cb(h,p,m,i);g.type=by,g.needsUpdate=!0;let _=f*4;for(let t=0;t0)return e;let i=t*n,a=aC[i];if(a===void 0&&(a=new Float32Array(i),aC[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function dC(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n0||c&&o&&i(o)){n===null&&(n=new JS(e));let i=s?n.fromEquirectangular(r):n.fromCubemap(r);return t.set(r,i),r.addEventListener(`dispose`,a),i.texture}else return null}}return r}function i(e){let t=0;for(let n=0;n<6;n++)e[n]!==void 0&&t++;return t===6}function a(e){let n=e.target;n.removeEventListener(`dispose`,a);let r=t.get(n);r!==void 0&&(t.delete(n),r.dispose())}function o(){t=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function soe(e){let t={};function n(n){if(t[n]!==void 0)return t[n];let r;switch(n){case`WEBGL_depth_texture`:r=e.getExtension(`WEBGL_depth_texture`)||e.getExtension(`MOZ_WEBGL_depth_texture`)||e.getExtension(`WEBKIT_WEBGL_depth_texture`);break;case`EXT_texture_filter_anisotropic`:r=e.getExtension(`EXT_texture_filter_anisotropic`)||e.getExtension(`MOZ_EXT_texture_filter_anisotropic`)||e.getExtension(`WEBKIT_EXT_texture_filter_anisotropic`);break;case`WEBGL_compressed_texture_s3tc`:r=e.getExtension(`WEBGL_compressed_texture_s3tc`)||e.getExtension(`MOZ_WEBGL_compressed_texture_s3tc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_s3tc`);break;case`WEBGL_compressed_texture_pvrtc`:r=e.getExtension(`WEBGL_compressed_texture_pvrtc`)||e.getExtension(`WEBKIT_WEBGL_compressed_texture_pvrtc`);break;default:r=e.getExtension(n)}return t[n]=r,r}return{has:function(e){return n(e)!==null},init:function(e){e.isWebGL2?n(`EXT_color_buffer_float`):(n(`WEBGL_depth_texture`),n(`OES_texture_float`),n(`OES_texture_half_float`),n(`OES_texture_half_float_linear`),n(`OES_standard_derivatives`),n(`OES_element_index_uint`),n(`OES_vertex_array_object`),n(`ANGLE_instanced_arrays`)),n(`OES_texture_float_linear`),n(`EXT_color_buffer_half_float`),n(`WEBGL_multisampled_render_to_texture`)},get:function(e){let t=n(e);return t===null&&console.warn(`THREE.WebGLRenderer: `+e+` extension not supported.`),t}}}function coe(e,t,n,r){let i={},a=new WeakMap;function o(e){let s=e.target;s.index!==null&&t.remove(s.index);for(let e in s.attributes)t.remove(s.attributes[e]);for(let e in s.morphAttributes){let n=s.morphAttributes[e];for(let e=0,r=n.length;et.maxTextureSize&&(m=Math.ceil(p/t.maxTextureSize),p=t.maxTextureSize);let h=new Float32Array(p*m*4*i),g=new Cb(h,p,m,i);g.type=by,g.needsUpdate=!0;let _=f*4;for(let t=0;t0)return e;let i=t*n,a=oC[i];if(a===void 0&&(a=new Float32Array(i),oC[i]=a),t!==0){r.toArray(a,0);for(let r=1,i=0;r!==t;++r)i+=n,e[r].toArray(a,i)}return a}function fC(e,t){if(e.length!==t.length)return!1;for(let n=0,r=e.length;n`:` `} ${i}: ${n[e]}`)}return r.join(` -`)}function lse(e){let t=pb.getPrimaries(pb.workingColorSpace),n=pb.getPrimaries(e),r;switch(t===n?r=``:t===`p3`&&n===`rec709`?r=`LinearDisplayP3ToLinearSRGB`:t===`rec709`&&n===`p3`&&(r=`LinearSRGBToLinearDisplayP3`),e){case Py:case Iy:return[r,`LinearTransferOETF`];case Ny:case Fy:return[r,`sRGBTransferOETF`];default:return console.warn(`THREE.WebGLProgram: Unsupported color space:`,e),[r,`LinearTransferOETF`]}}function vC(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` +`)}function cse(e){let t=pb.getPrimaries(pb.workingColorSpace),n=pb.getPrimaries(e),r;switch(t===n?r=``:t===`p3`&&n===`rec709`?r=`LinearDisplayP3ToLinearSRGB`:t===`rec709`&&n===`p3`&&(r=`LinearSRGBToLinearDisplayP3`),e){case Py:case Iy:return[r,`LinearTransferOETF`];case Ny:case Fy:return[r,`sRGBTransferOETF`];default:return console.warn(`THREE.WebGLProgram: Unsupported color space:`,e),[r,`LinearTransferOETF`]}}function yC(e,t,n){let r=e.getShaderParameter(t,e.COMPILE_STATUS),i=e.getShaderInfoLog(t).trim();if(r&&i===``)return``;let a=/ERROR: 0:(\d+)/.exec(i);if(a){let r=parseInt(a[1]);return n.toUpperCase()+` `+i+` -`+cse(e.getShaderSource(t),r)}else return i}function use(e,t){let n=lse(t);return`vec4 ${e}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function dse(e,t){let n;switch(t){case 1:n=`Linear`;break;case 2:n=`Reinhard`;break;case 3:n=`OptimizedCineon`;break;case 4:n=`ACESFilmic`;break;case 5:n=`Custom`;break;default:console.warn(`THREE.WebGLProgram: Unsupported toneMapping:`,t),n=`Linear`}return`vec3 `+e+`( vec3 color ) { return `+n+`ToneMapping( color ); }`}function fse(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.normalMapTangentSpace||e.clearcoatNormalMap||e.flatShading||e.shaderID===`physical`?`#extension GL_OES_standard_derivatives : enable`:``,(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?`#extension GL_EXT_frag_depth : enable`:``,e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?`#extension GL_EXT_draw_buffers : require`:``,(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?`#extension GL_EXT_shader_texture_lod : enable`:``].filter(yC).join(` -`)}function pse(e){let t=[];for(let n in e){let r=e[n];r!==!1&&t.push(`#define `+n+` `+r)}return t.join(` -`)}function mse(e,t){let n={},r=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i/gm;function SC(e){return e.replace(hse,_se)}var gse=new Map([[`encodings_fragment`,`colorspace_fragment`],[`encodings_pars_fragment`,`colorspace_pars_fragment`],[`output_fragment`,`opaque_fragment`]]);function _se(e,t){let n=MS[t];if(n===void 0){let e=gse.get(t);if(e!==void 0)n=MS[e],console.warn(`THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return SC(n)}var vse=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function CC(e){return e.replace(vse,yse)}function yse(e,t,n,r){let i=``;for(let e=parseInt(t);e/gm;function CC(e){return e.replace(mse,gse)}var hse=new Map([[`encodings_fragment`,`colorspace_fragment`],[`encodings_pars_fragment`,`colorspace_pars_fragment`],[`output_fragment`,`opaque_fragment`]]);function gse(e,t){let n=NS[t];if(n===void 0){let e=hse.get(t);if(e!==void 0)n=NS[e],console.warn(`THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.`,t,e);else throw Error(`Can not resolve #include <`+t+`>`)}return CC(n)}var _se=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function wC(e){return e.replace(_se,vse)}function vse(e,t,n,r){let i=``;for(let e=parseInt(t);e0&&(g+=` -`),_=[p,`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(yC).join(` +`),_=[p,`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m].filter(bC).join(` `),_.length>0&&(_+=` -`)):(g=[wC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.batching?`#define USE_BATCHING`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors&&n.isWebGL2?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_TEXTURE`:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?`#define USE_LOGDEPTHBUF_EXT`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )`,` attribute vec3 morphTarget0;`,` attribute vec3 morphTarget1;`,` attribute vec3 morphTarget2;`,` attribute vec3 morphTarget3;`,` #ifdef USE_MORPHNORMALS`,` attribute vec3 morphNormal0;`,` attribute vec3 morphNormal1;`,` attribute vec3 morphNormal2;`,` attribute vec3 morphNormal3;`,` #else`,` attribute vec3 morphTarget4;`,` attribute vec3 morphTarget5;`,` attribute vec3 morphTarget6;`,` attribute vec3 morphTarget7;`,` #endif`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` -`].filter(yC).join(` -`),_=[p,wC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?`#define USE_LOGDEPTHBUF_EXT`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:MS.tonemapping_pars_fragment,n.toneMapping===0?``:dse(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,MS.colorspace_pars_fragment,use(`linearToOutputTexel`,n.outputColorSpace),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` -`].filter(yC).join(` -`)),o=SC(o),o=bC(o,n),o=xC(o,n),s=SC(s),s=bC(s,n),s=xC(s,n),o=CC(o),s=CC(s),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(v=`#version 300 es +`)):(g=[TC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.batching?`#define USE_BATCHING`:``,n.instancing?`#define USE_INSTANCING`:``,n.instancingColor?`#define USE_INSTANCING_COLOR`:``,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+u:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.displacementMap?`#define USE_DISPLACEMENTMAP`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.mapUv?`#define MAP_UV `+n.mapUv:``,n.alphaMapUv?`#define ALPHAMAP_UV `+n.alphaMapUv:``,n.lightMapUv?`#define LIGHTMAP_UV `+n.lightMapUv:``,n.aoMapUv?`#define AOMAP_UV `+n.aoMapUv:``,n.emissiveMapUv?`#define EMISSIVEMAP_UV `+n.emissiveMapUv:``,n.bumpMapUv?`#define BUMPMAP_UV `+n.bumpMapUv:``,n.normalMapUv?`#define NORMALMAP_UV `+n.normalMapUv:``,n.displacementMapUv?`#define DISPLACEMENTMAP_UV `+n.displacementMapUv:``,n.metalnessMapUv?`#define METALNESSMAP_UV `+n.metalnessMapUv:``,n.roughnessMapUv?`#define ROUGHNESSMAP_UV `+n.roughnessMapUv:``,n.anisotropyMapUv?`#define ANISOTROPYMAP_UV `+n.anisotropyMapUv:``,n.clearcoatMapUv?`#define CLEARCOATMAP_UV `+n.clearcoatMapUv:``,n.clearcoatNormalMapUv?`#define CLEARCOAT_NORMALMAP_UV `+n.clearcoatNormalMapUv:``,n.clearcoatRoughnessMapUv?`#define CLEARCOAT_ROUGHNESSMAP_UV `+n.clearcoatRoughnessMapUv:``,n.iridescenceMapUv?`#define IRIDESCENCEMAP_UV `+n.iridescenceMapUv:``,n.iridescenceThicknessMapUv?`#define IRIDESCENCE_THICKNESSMAP_UV `+n.iridescenceThicknessMapUv:``,n.sheenColorMapUv?`#define SHEEN_COLORMAP_UV `+n.sheenColorMapUv:``,n.sheenRoughnessMapUv?`#define SHEEN_ROUGHNESSMAP_UV `+n.sheenRoughnessMapUv:``,n.specularMapUv?`#define SPECULARMAP_UV `+n.specularMapUv:``,n.specularColorMapUv?`#define SPECULAR_COLORMAP_UV `+n.specularColorMapUv:``,n.specularIntensityMapUv?`#define SPECULAR_INTENSITYMAP_UV `+n.specularIntensityMapUv:``,n.transmissionMapUv?`#define TRANSMISSIONMAP_UV `+n.transmissionMapUv:``,n.thicknessMapUv?`#define THICKNESSMAP_UV `+n.thicknessMapUv:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.flatShading?`#define FLAT_SHADED`:``,n.skinning?`#define USE_SKINNING`:``,n.morphTargets?`#define USE_MORPHTARGETS`:``,n.morphNormals&&n.flatShading===!1?`#define USE_MORPHNORMALS`:``,n.morphColors&&n.isWebGL2?`#define USE_MORPHCOLORS`:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_TEXTURE`:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_TEXTURE_STRIDE `+n.morphTextureStride:``,n.morphTargetsCount>0&&n.isWebGL2?`#define MORPHTARGETS_COUNT `+n.morphTargetsCount:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.sizeAttenuation?`#define USE_SIZEATTENUATION`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?`#define USE_LOGDEPTHBUF_EXT`:``,`uniform mat4 modelMatrix;`,`uniform mat4 modelViewMatrix;`,`uniform mat4 projectionMatrix;`,`uniform mat4 viewMatrix;`,`uniform mat3 normalMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,`#ifdef USE_INSTANCING`,` attribute mat4 instanceMatrix;`,`#endif`,`#ifdef USE_INSTANCING_COLOR`,` attribute vec3 instanceColor;`,`#endif`,`attribute vec3 position;`,`attribute vec3 normal;`,`attribute vec2 uv;`,`#ifdef USE_UV1`,` attribute vec2 uv1;`,`#endif`,`#ifdef USE_UV2`,` attribute vec2 uv2;`,`#endif`,`#ifdef USE_UV3`,` attribute vec2 uv3;`,`#endif`,`#ifdef USE_TANGENT`,` attribute vec4 tangent;`,`#endif`,`#if defined( USE_COLOR_ALPHA )`,` attribute vec4 color;`,`#elif defined( USE_COLOR )`,` attribute vec3 color;`,`#endif`,`#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )`,` attribute vec3 morphTarget0;`,` attribute vec3 morphTarget1;`,` attribute vec3 morphTarget2;`,` attribute vec3 morphTarget3;`,` #ifdef USE_MORPHNORMALS`,` attribute vec3 morphNormal0;`,` attribute vec3 morphNormal1;`,` attribute vec3 morphNormal2;`,` attribute vec3 morphNormal3;`,` #else`,` attribute vec3 morphTarget4;`,` attribute vec3 morphTarget5;`,` attribute vec3 morphTarget6;`,` attribute vec3 morphTarget7;`,` #endif`,`#endif`,`#ifdef USE_SKINNING`,` attribute vec4 skinIndex;`,` attribute vec4 skinWeight;`,`#endif`,` +`].filter(bC).join(` +`),_=[p,TC(n),`#define SHADER_TYPE `+n.shaderType,`#define SHADER_NAME `+n.shaderName,m,n.useFog&&n.fog?`#define USE_FOG`:``,n.useFog&&n.fogExp2?`#define FOG_EXP2`:``,n.map?`#define USE_MAP`:``,n.matcap?`#define USE_MATCAP`:``,n.envMap?`#define USE_ENVMAP`:``,n.envMap?`#define `+l:``,n.envMap?`#define `+u:``,n.envMap?`#define `+d:``,f?`#define CUBEUV_TEXEL_WIDTH `+f.texelWidth:``,f?`#define CUBEUV_TEXEL_HEIGHT `+f.texelHeight:``,f?`#define CUBEUV_MAX_MIP `+f.maxMip+`.0`:``,n.lightMap?`#define USE_LIGHTMAP`:``,n.aoMap?`#define USE_AOMAP`:``,n.bumpMap?`#define USE_BUMPMAP`:``,n.normalMap?`#define USE_NORMALMAP`:``,n.normalMapObjectSpace?`#define USE_NORMALMAP_OBJECTSPACE`:``,n.normalMapTangentSpace?`#define USE_NORMALMAP_TANGENTSPACE`:``,n.emissiveMap?`#define USE_EMISSIVEMAP`:``,n.anisotropy?`#define USE_ANISOTROPY`:``,n.anisotropyMap?`#define USE_ANISOTROPYMAP`:``,n.clearcoat?`#define USE_CLEARCOAT`:``,n.clearcoatMap?`#define USE_CLEARCOATMAP`:``,n.clearcoatRoughnessMap?`#define USE_CLEARCOAT_ROUGHNESSMAP`:``,n.clearcoatNormalMap?`#define USE_CLEARCOAT_NORMALMAP`:``,n.iridescence?`#define USE_IRIDESCENCE`:``,n.iridescenceMap?`#define USE_IRIDESCENCEMAP`:``,n.iridescenceThicknessMap?`#define USE_IRIDESCENCE_THICKNESSMAP`:``,n.specularMap?`#define USE_SPECULARMAP`:``,n.specularColorMap?`#define USE_SPECULAR_COLORMAP`:``,n.specularIntensityMap?`#define USE_SPECULAR_INTENSITYMAP`:``,n.roughnessMap?`#define USE_ROUGHNESSMAP`:``,n.metalnessMap?`#define USE_METALNESSMAP`:``,n.alphaMap?`#define USE_ALPHAMAP`:``,n.alphaTest?`#define USE_ALPHATEST`:``,n.alphaHash?`#define USE_ALPHAHASH`:``,n.sheen?`#define USE_SHEEN`:``,n.sheenColorMap?`#define USE_SHEEN_COLORMAP`:``,n.sheenRoughnessMap?`#define USE_SHEEN_ROUGHNESSMAP`:``,n.transmission?`#define USE_TRANSMISSION`:``,n.transmissionMap?`#define USE_TRANSMISSIONMAP`:``,n.thicknessMap?`#define USE_THICKNESSMAP`:``,n.vertexTangents&&n.flatShading===!1?`#define USE_TANGENT`:``,n.vertexColors||n.instancingColor?`#define USE_COLOR`:``,n.vertexAlphas?`#define USE_COLOR_ALPHA`:``,n.vertexUv1s?`#define USE_UV1`:``,n.vertexUv2s?`#define USE_UV2`:``,n.vertexUv3s?`#define USE_UV3`:``,n.pointsUvs?`#define USE_POINTS_UV`:``,n.gradientMap?`#define USE_GRADIENTMAP`:``,n.flatShading?`#define FLAT_SHADED`:``,n.doubleSided?`#define DOUBLE_SIDED`:``,n.flipSided?`#define FLIP_SIDED`:``,n.shadowMapEnabled?`#define USE_SHADOWMAP`:``,n.shadowMapEnabled?`#define `+c:``,n.premultipliedAlpha?`#define PREMULTIPLIED_ALPHA`:``,n.numLightProbes>0?`#define USE_LIGHT_PROBES`:``,n.useLegacyLights?`#define LEGACY_LIGHTS`:``,n.decodeVideoTexture?`#define DECODE_VIDEO_TEXTURE`:``,n.logarithmicDepthBuffer?`#define USE_LOGDEPTHBUF`:``,n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?`#define USE_LOGDEPTHBUF_EXT`:``,`uniform mat4 viewMatrix;`,`uniform vec3 cameraPosition;`,`uniform bool isOrthographic;`,n.toneMapping===0?``:`#define TONE_MAPPING`,n.toneMapping===0?``:NS.tonemapping_pars_fragment,n.toneMapping===0?``:use(`toneMapping`,n.toneMapping),n.dithering?`#define DITHERING`:``,n.opaque?`#define OPAQUE`:``,NS.colorspace_pars_fragment,lse(`linearToOutputTexel`,n.outputColorSpace),n.useDepthPacking?`#define DEPTH_PACKING `+n.depthPacking:``,` +`].filter(bC).join(` +`)),o=CC(o),o=xC(o,n),o=SC(o,n),s=CC(s),s=xC(s,n),s=SC(s,n),o=wC(o),s=wC(s),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(v=`#version 300 es `,g=[`precision mediump sampler2DArray;`,`#define attribute in`,`#define varying out`,`#define texture2D texture`].join(` `)+` `+g,_=[`precision mediump sampler2DArray;`,`#define varying in`,n.glslVersion===`300 es`?``:`layout(location = 0) out highp vec4 pc_fragColor;`,n.glslVersion===`300 es`?``:`#define gl_FragColor pc_fragColor`,`#define gl_FragDepthEXT gl_FragDepth`,`#define texture2D texture`,`#define textureCube texture`,`#define texture2DProj textureProj`,`#define texture2DLodEXT textureLod`,`#define texture2DProjLodEXT textureProjLod`,`#define textureCubeLodEXT textureLod`,`#define texture2DGradEXT textureGrad`,`#define texture2DProjGradEXT textureProjGrad`,`#define textureCubeGradEXT textureGrad`].join(` `)+` -`+_);let y=v+g+o,b=v+_+s,x=_C(i,i.VERTEX_SHADER,y),S=_C(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h).trim(),r=i.getShaderInfoLog(x).trim(),a=i.getShaderInfoLog(S).trim(),o=!0,s=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(o=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=vC(i,x,`vertex`),t=vC(i,S,`fragment`);console.error(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` +`+_);let y=v+g+o,b=v+_+s,x=vC(i,i.VERTEX_SHADER,y),S=vC(i,i.FRAGMENT_SHADER,b);i.attachShader(h,x),i.attachShader(h,S),n.index0AttributeName===void 0?n.morphTargets===!0&&i.bindAttribLocation(h,0,`position`):i.bindAttribLocation(h,0,n.index0AttributeName),i.linkProgram(h);function C(t){if(e.debug.checkShaderErrors){let n=i.getProgramInfoLog(h).trim(),r=i.getShaderInfoLog(x).trim(),a=i.getShaderInfoLog(S).trim(),o=!0,s=!0;if(i.getProgramParameter(h,i.LINK_STATUS)===!1)if(o=!1,typeof e.debug.onShaderError==`function`)e.debug.onShaderError(i,h,x,S);else{let e=yC(i,x,`vertex`),t=yC(i,S,`fragment`);console.error(`THREE.WebGLProgram: Shader Error `+i.getError()+` - VALIDATE_STATUS `+i.getProgramParameter(h,i.VALIDATE_STATUS)+` Program Info Log: `+n+` `+e+` -`+t)}else n===``?(r===``||a===``)&&(s=!1):console.warn(`THREE.WebGLProgram: Program Info Log:`,n);s&&(t.diagnostics={runnable:o,programLog:n,vertexShader:{log:r,prefix:g},fragmentShader:{log:a,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new gC(i,h),T=mse(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,ose)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=sse++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var Ese=0,Dse=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Ose(e),t.set(e,n)),n}},Ose=class{constructor(e){this.id=Ese++,this.code=e,this.usedTimes=0}};function kse(e,t,n,r,i,a,o){let s=new lx,c=new Dse,l=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,m={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distanceRGBA`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function h(e){return e===0?`uv`:`uv${e}`}function g(a,s,l,g,_){let v=g.fog,y=_.geometry,b=a.isMeshStandardMaterial?g.environment:null,x=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),S=x&&x.mapping===306?x.image.height:null,C=m[a.type];a.precision!==null&&(p=i.getMaxPrecision(a.precision),p!==a.precision&&console.warn(`THREE.WebGLProgram.getParameters:`,a.precision,`not supported, using`,p,`instead.`));let w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=w===void 0?0:w.length,E=0;y.morphAttributes.position!==void 0&&(E=1),y.morphAttributes.normal!==void 0&&(E=2),y.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=PS[C];D=e.vertexShader,O=e.fragmentShader}else D=a.vertexShader,O=a.fragmentShader,c.update(a),k=c.getVertexShaderID(a),A=c.getFragmentShaderID(a);let j=e.getRenderTarget(),M=_.isInstancedMesh===!0,N=_.isBatchedMesh===!0,P=!!a.map,F=!!a.matcap,I=!!x,L=!!a.aoMap,R=!!a.lightMap,z=!!a.bumpMap,B=!!a.normalMap,V=!!a.displacementMap,ee=!!a.emissiveMap,te=!!a.metalnessMap,ne=!!a.roughnessMap,re=a.anisotropy>0,ie=a.clearcoat>0,H=a.iridescence>0,ae=a.sheen>0,oe=a.transmission>0,U=re&&!!a.anisotropyMap,se=ie&&!!a.clearcoatMap,ce=ie&&!!a.clearcoatNormalMap,le=ie&&!!a.clearcoatRoughnessMap,ue=H&&!!a.iridescenceMap,de=H&&!!a.iridescenceThicknessMap,fe=ae&&!!a.sheenColorMap,pe=ae&&!!a.sheenRoughnessMap,me=!!a.specularMap,he=!!a.specularColorMap,ge=!!a.specularIntensityMap,_e=oe&&!!a.transmissionMap,ve=oe&&!!a.thicknessMap,ye=!!a.gradientMap,be=!!a.alphaMap,xe=a.alphaTest>0,Se=!!a.alphaHash,Ce=!!a.extensions,we=!!y.attributes.uv1,Te=!!y.attributes.uv2,Ee=!!y.attributes.uv3,De=0;return a.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(De=e.toneMapping),{isWebGL2:u,shaderID:C,shaderType:a.type,shaderName:a.name,vertexShader:D,fragmentShader:O,defines:a.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:a.isRawShaderMaterial===!0,glslVersion:a.glslVersion,precision:p,batching:N,instancing:M,instancingColor:M&&_.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Py,map:P,matcap:F,envMap:I,envMapMode:I&&x.mapping,envMapCubeUVHeight:S,aoMap:L,lightMap:R,bumpMap:z,normalMap:B,displacementMap:f&&V,emissiveMap:ee,normalMapObjectSpace:B&&a.normalMapType===1,normalMapTangentSpace:B&&a.normalMapType===0,metalnessMap:te,roughnessMap:ne,anisotropy:re,anisotropyMap:U,clearcoat:ie,clearcoatMap:se,clearcoatNormalMap:ce,clearcoatRoughnessMap:le,iridescence:H,iridescenceMap:ue,iridescenceThicknessMap:de,sheen:ae,sheenColorMap:fe,sheenRoughnessMap:pe,specularMap:me,specularColorMap:he,specularIntensityMap:ge,transmission:oe,transmissionMap:_e,thicknessMap:ve,gradientMap:ye,opaque:a.transparent===!1&&a.blending===1,alphaMap:be,alphaTest:xe,alphaHash:Se,combine:a.combine,mapUv:P&&h(a.map.channel),aoMapUv:L&&h(a.aoMap.channel),lightMapUv:R&&h(a.lightMap.channel),bumpMapUv:z&&h(a.bumpMap.channel),normalMapUv:B&&h(a.normalMap.channel),displacementMapUv:V&&h(a.displacementMap.channel),emissiveMapUv:ee&&h(a.emissiveMap.channel),metalnessMapUv:te&&h(a.metalnessMap.channel),roughnessMapUv:ne&&h(a.roughnessMap.channel),anisotropyMapUv:U&&h(a.anisotropyMap.channel),clearcoatMapUv:se&&h(a.clearcoatMap.channel),clearcoatNormalMapUv:ce&&h(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&h(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ue&&h(a.iridescenceMap.channel),iridescenceThicknessMapUv:de&&h(a.iridescenceThicknessMap.channel),sheenColorMapUv:fe&&h(a.sheenColorMap.channel),sheenRoughnessMapUv:pe&&h(a.sheenRoughnessMap.channel),specularMapUv:me&&h(a.specularMap.channel),specularColorMapUv:he&&h(a.specularColorMap.channel),specularIntensityMapUv:ge&&h(a.specularIntensityMap.channel),transmissionMapUv:_e&&h(a.transmissionMap.channel),thicknessMapUv:ve&&h(a.thicknessMap.channel),alphaMapUv:be&&h(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(B||re),vertexColors:a.vertexColors,vertexAlphas:a.vertexColors===!0&&!!y.attributes.color&&y.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Te,vertexUv3s:Ee,pointsUvs:_.isPoints===!0&&!!y.attributes.uv&&(P||be),fog:!!v,useFog:a.fog===!0,fogExp2:v&&v.isFogExp2,flatShading:a.flatShading===!0,sizeAttenuation:a.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:_.isSkinnedMesh===!0,morphTargets:y.morphAttributes.position!==void 0,morphNormals:y.morphAttributes.normal!==void 0,morphColors:y.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:De,useLegacyLights:e._useLegacyLights,decodeVideoTexture:P&&a.map.isVideoTexture===!0&&pb.getTransfer(a.map.colorSpace)===`srgb`,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===2,flipSided:a.side===1,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:Ce&&a.extensions.derivatives===!0,extensionFragDepth:Ce&&a.extensions.fragDepth===!0,extensionDrawBuffers:Ce&&a.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ce&&a.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has(`EXT_frag_depth`),rendererExtensionDrawBuffers:u||r.has(`WEBGL_draw_buffers`),rendererExtensionShaderTextureLod:u||r.has(`EXT_shader_texture_lod`),rendererExtensionParallelShaderCompile:r.has(`KHR_parallel_shader_compile`),customProgramCacheKey:a.customProgramCacheKey()}}function _(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(v(n,t),y(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function v(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function y(e,t){s.disableAll(),t.isWebGL2&&s.enable(0),t.supportsVertexTextures&&s.enable(1),t.instancing&&s.enable(2),t.instancingColor&&s.enable(3),t.matcap&&s.enable(4),t.envMap&&s.enable(5),t.normalMapObjectSpace&&s.enable(6),t.normalMapTangentSpace&&s.enable(7),t.clearcoat&&s.enable(8),t.iridescence&&s.enable(9),t.alphaTest&&s.enable(10),t.vertexColors&&s.enable(11),t.vertexAlphas&&s.enable(12),t.vertexUv1s&&s.enable(13),t.vertexUv2s&&s.enable(14),t.vertexUv3s&&s.enable(15),t.vertexTangents&&s.enable(16),t.anisotropy&&s.enable(17),t.alphaHash&&s.enable(18),t.batching&&s.enable(19),e.push(s.mask),s.disableAll(),t.fog&&s.enable(0),t.useFog&&s.enable(1),t.flatShading&&s.enable(2),t.logarithmicDepthBuffer&&s.enable(3),t.skinning&&s.enable(4),t.morphTargets&&s.enable(5),t.morphNormals&&s.enable(6),t.morphColors&&s.enable(7),t.premultipliedAlpha&&s.enable(8),t.shadowMapEnabled&&s.enable(9),t.useLegacyLights&&s.enable(10),t.doubleSided&&s.enable(11),t.flipSided&&s.enable(12),t.useDepthPacking&&s.enable(13),t.dithering&&s.enable(14),t.transmission&&s.enable(15),t.sheen&&s.enable(16),t.opaque&&s.enable(17),t.pointsUvs&&s.enable(18),t.decodeVideoTexture&&s.enable(19),e.push(s.mask)}function b(e){let t=m[e.type],n;if(t){let e=PS[t];n=yS.clone(e.uniforms)}else n=e.uniforms;return n}function x(t,n){let r;for(let e=0,t=l.length;e0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function c(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function l(e,t){n.length>1&&n.sort(e||jse),r.length>1&&r.sort(t||TC),i.length>1&&i.sort(t||TC)}function u(){for(let n=t,r=e.length;n=r.length?(i=new EC,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Nse(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new Tb,color:new Px};break;case`SpotLight`:n={position:new Tb,direction:new Tb,color:new Px,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new Tb,color:new Px,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new Tb,skyColor:new Px,groundColor:new Px};break;case`RectAreaLight`:n={color:new Px,position:new Tb,halfWidth:new Tb,halfHeight:new Tb};break}return e[t.id]=n,n}}}function Pse(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb};break;case`SpotLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb};break;case`PointLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Fse=0;function Ise(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Lse(e,t){let n=new Nse,r=Pse(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new Tb);let a=new Tb,o=new ex,s=new ex;function c(a,o){let s=0,c=0,l=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;a.sort(Ise);let x=o===!0?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||e.has(`OES_texture_float_linear`)===!0?(i.rectAreaLTC1=NS.LTC_FLOAT_1,i.rectAreaLTC2=NS.LTC_FLOAT_2):e.has(`OES_texture_half_float_linear`)===!0?(i.rectAreaLTC1=NS.LTC_HALF_1,i.rectAreaLTC2=NS.LTC_HALF_2):console.error(`THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.`)),i.ambient[0]=s,i.ambient[1]=c,i.ambient[2]=l;let S=i.hash;(S.directionalLength!==u||S.pointLength!==d||S.spotLength!==f||S.rectAreaLength!==p||S.hemiLength!==m||S.numDirectionalShadows!==h||S.numPointShadows!==g||S.numSpotShadows!==_||S.numSpotMaps!==v||S.numLightProbes!==b)&&(i.directional.length=u,i.spot.length=f,i.rectArea.length=p,i.point.length=d,i.hemi.length=m,i.directionalShadow.length=h,i.directionalShadowMap.length=h,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=h,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=_+v-y,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=y,i.numLightProbes=b,S.directionalLength=u,S.pointLength=d,S.spotLength=f,S.rectAreaLength=p,S.hemiLength=m,S.numDirectionalShadows=h,S.numPointShadows=g,S.numSpotShadows=_,S.numSpotMaps=v,S.numLightProbes=b,i.version=Fse++)}function l(e,t){let n=0,r=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=a.length?(o=new DC(e,t),a.push(o)):o=a[i],o}function i(){n=new WeakMap}return{get:r,dispose:i}}var zse=class extends Ix{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=oae,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},Bse=class extends Ix{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},Vse=`void main() { +`+t)}else n===``?(r===``||a===``)&&(s=!1):console.warn(`THREE.WebGLProgram: Program Info Log:`,n);s&&(t.diagnostics={runnable:o,programLog:n,vertexShader:{log:r,prefix:g},fragmentShader:{log:a,prefix:_}})}i.deleteShader(x),i.deleteShader(S),w=new _C(i,h),T=pse(i,h)}let w;this.getUniforms=function(){return w===void 0&&C(this),w};let T;this.getAttributes=function(){return T===void 0&&C(this),T};let E=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return E===!1&&(E=i.getProgramParameter(h,ase)),E},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(h),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=ose++,this.cacheKey=t,this.usedTimes=1,this.program=h,this.vertexShader=x,this.fragmentShader=S,this}var Tse=0,Ese=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),i=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(i)===!1&&(a.add(i),i.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let e of t)e.usedTimes--,e.usedTimes===0&&this.shaderCache.delete(e.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache,n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){let t=this.shaderCache,n=t.get(e);return n===void 0&&(n=new Dse(e),t.set(e,n)),n}},Dse=class{constructor(e){this.id=Tse++,this.code=e,this.usedTimes=0}};function Ose(e,t,n,r,i,a,o){let s=new lx,c=new Ese,l=[],u=i.isWebGL2,d=i.logarithmicDepthBuffer,f=i.vertexTextures,p=i.precision,m={MeshDepthMaterial:`depth`,MeshDistanceMaterial:`distanceRGBA`,MeshNormalMaterial:`normal`,MeshBasicMaterial:`basic`,MeshLambertMaterial:`lambert`,MeshPhongMaterial:`phong`,MeshToonMaterial:`toon`,MeshStandardMaterial:`physical`,MeshPhysicalMaterial:`physical`,MeshMatcapMaterial:`matcap`,LineBasicMaterial:`basic`,LineDashedMaterial:`dashed`,PointsMaterial:`points`,ShadowMaterial:`shadow`,SpriteMaterial:`sprite`};function h(e){return e===0?`uv`:`uv${e}`}function g(a,s,l,g,_){let v=g.fog,y=_.geometry,b=a.isMeshStandardMaterial?g.environment:null,x=(a.isMeshStandardMaterial?n:t).get(a.envMap||b),S=x&&x.mapping===306?x.image.height:null,C=m[a.type];a.precision!==null&&(p=i.getMaxPrecision(a.precision),p!==a.precision&&console.warn(`THREE.WebGLProgram.getParameters:`,a.precision,`not supported, using`,p,`instead.`));let w=y.morphAttributes.position||y.morphAttributes.normal||y.morphAttributes.color,T=w===void 0?0:w.length,E=0;y.morphAttributes.position!==void 0&&(E=1),y.morphAttributes.normal!==void 0&&(E=2),y.morphAttributes.color!==void 0&&(E=3);let D,O,k,A;if(C){let e=FS[C];D=e.vertexShader,O=e.fragmentShader}else D=a.vertexShader,O=a.fragmentShader,c.update(a),k=c.getVertexShaderID(a),A=c.getFragmentShaderID(a);let j=e.getRenderTarget(),M=_.isInstancedMesh===!0,N=_.isBatchedMesh===!0,P=!!a.map,F=!!a.matcap,I=!!x,L=!!a.aoMap,R=!!a.lightMap,z=!!a.bumpMap,B=!!a.normalMap,V=!!a.displacementMap,ee=!!a.emissiveMap,te=!!a.metalnessMap,ne=!!a.roughnessMap,re=a.anisotropy>0,ie=a.clearcoat>0,H=a.iridescence>0,ae=a.sheen>0,oe=a.transmission>0,U=re&&!!a.anisotropyMap,se=ie&&!!a.clearcoatMap,ce=ie&&!!a.clearcoatNormalMap,le=ie&&!!a.clearcoatRoughnessMap,ue=H&&!!a.iridescenceMap,de=H&&!!a.iridescenceThicknessMap,fe=ae&&!!a.sheenColorMap,pe=ae&&!!a.sheenRoughnessMap,me=!!a.specularMap,he=!!a.specularColorMap,ge=!!a.specularIntensityMap,_e=oe&&!!a.transmissionMap,ve=oe&&!!a.thicknessMap,ye=!!a.gradientMap,be=!!a.alphaMap,xe=a.alphaTest>0,Se=!!a.alphaHash,Ce=!!a.extensions,we=!!y.attributes.uv1,Te=!!y.attributes.uv2,Ee=!!y.attributes.uv3,De=0;return a.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(De=e.toneMapping),{isWebGL2:u,shaderID:C,shaderType:a.type,shaderName:a.name,vertexShader:D,fragmentShader:O,defines:a.defines,customVertexShaderID:k,customFragmentShaderID:A,isRawShaderMaterial:a.isRawShaderMaterial===!0,glslVersion:a.glslVersion,precision:p,batching:N,instancing:M,instancingColor:M&&_.instanceColor!==null,supportsVertexTextures:f,outputColorSpace:j===null?e.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:Py,map:P,matcap:F,envMap:I,envMapMode:I&&x.mapping,envMapCubeUVHeight:S,aoMap:L,lightMap:R,bumpMap:z,normalMap:B,displacementMap:f&&V,emissiveMap:ee,normalMapObjectSpace:B&&a.normalMapType===1,normalMapTangentSpace:B&&a.normalMapType===0,metalnessMap:te,roughnessMap:ne,anisotropy:re,anisotropyMap:U,clearcoat:ie,clearcoatMap:se,clearcoatNormalMap:ce,clearcoatRoughnessMap:le,iridescence:H,iridescenceMap:ue,iridescenceThicknessMap:de,sheen:ae,sheenColorMap:fe,sheenRoughnessMap:pe,specularMap:me,specularColorMap:he,specularIntensityMap:ge,transmission:oe,transmissionMap:_e,thicknessMap:ve,gradientMap:ye,opaque:a.transparent===!1&&a.blending===1,alphaMap:be,alphaTest:xe,alphaHash:Se,combine:a.combine,mapUv:P&&h(a.map.channel),aoMapUv:L&&h(a.aoMap.channel),lightMapUv:R&&h(a.lightMap.channel),bumpMapUv:z&&h(a.bumpMap.channel),normalMapUv:B&&h(a.normalMap.channel),displacementMapUv:V&&h(a.displacementMap.channel),emissiveMapUv:ee&&h(a.emissiveMap.channel),metalnessMapUv:te&&h(a.metalnessMap.channel),roughnessMapUv:ne&&h(a.roughnessMap.channel),anisotropyMapUv:U&&h(a.anisotropyMap.channel),clearcoatMapUv:se&&h(a.clearcoatMap.channel),clearcoatNormalMapUv:ce&&h(a.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:le&&h(a.clearcoatRoughnessMap.channel),iridescenceMapUv:ue&&h(a.iridescenceMap.channel),iridescenceThicknessMapUv:de&&h(a.iridescenceThicknessMap.channel),sheenColorMapUv:fe&&h(a.sheenColorMap.channel),sheenRoughnessMapUv:pe&&h(a.sheenRoughnessMap.channel),specularMapUv:me&&h(a.specularMap.channel),specularColorMapUv:he&&h(a.specularColorMap.channel),specularIntensityMapUv:ge&&h(a.specularIntensityMap.channel),transmissionMapUv:_e&&h(a.transmissionMap.channel),thicknessMapUv:ve&&h(a.thicknessMap.channel),alphaMapUv:be&&h(a.alphaMap.channel),vertexTangents:!!y.attributes.tangent&&(B||re),vertexColors:a.vertexColors,vertexAlphas:a.vertexColors===!0&&!!y.attributes.color&&y.attributes.color.itemSize===4,vertexUv1s:we,vertexUv2s:Te,vertexUv3s:Ee,pointsUvs:_.isPoints===!0&&!!y.attributes.uv&&(P||be),fog:!!v,useFog:a.fog===!0,fogExp2:v&&v.isFogExp2,flatShading:a.flatShading===!0,sizeAttenuation:a.sizeAttenuation===!0,logarithmicDepthBuffer:d,skinning:_.isSkinnedMesh===!0,morphTargets:y.morphAttributes.position!==void 0,morphNormals:y.morphAttributes.normal!==void 0,morphColors:y.morphAttributes.color!==void 0,morphTargetsCount:T,morphTextureStride:E,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,numLightProbes:s.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:a.dithering,shadowMapEnabled:e.shadowMap.enabled&&l.length>0,shadowMapType:e.shadowMap.type,toneMapping:De,useLegacyLights:e._useLegacyLights,decodeVideoTexture:P&&a.map.isVideoTexture===!0&&pb.getTransfer(a.map.colorSpace)===`srgb`,premultipliedAlpha:a.premultipliedAlpha,doubleSided:a.side===2,flipSided:a.side===1,useDepthPacking:a.depthPacking>=0,depthPacking:a.depthPacking||0,index0AttributeName:a.index0AttributeName,extensionDerivatives:Ce&&a.extensions.derivatives===!0,extensionFragDepth:Ce&&a.extensions.fragDepth===!0,extensionDrawBuffers:Ce&&a.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ce&&a.extensions.shaderTextureLOD===!0,rendererExtensionFragDepth:u||r.has(`EXT_frag_depth`),rendererExtensionDrawBuffers:u||r.has(`WEBGL_draw_buffers`),rendererExtensionShaderTextureLod:u||r.has(`EXT_shader_texture_lod`),rendererExtensionParallelShaderCompile:r.has(`KHR_parallel_shader_compile`),customProgramCacheKey:a.customProgramCacheKey()}}function _(t){let n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),t.defines!==void 0)for(let e in t.defines)n.push(e),n.push(t.defines[e]);return t.isRawShaderMaterial===!1&&(v(n,t),y(n,t),n.push(e.outputColorSpace)),n.push(t.customProgramCacheKey),n.join()}function v(e,t){e.push(t.precision),e.push(t.outputColorSpace),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.mapUv),e.push(t.alphaMapUv),e.push(t.lightMapUv),e.push(t.aoMapUv),e.push(t.bumpMapUv),e.push(t.normalMapUv),e.push(t.displacementMapUv),e.push(t.emissiveMapUv),e.push(t.metalnessMapUv),e.push(t.roughnessMapUv),e.push(t.anisotropyMapUv),e.push(t.clearcoatMapUv),e.push(t.clearcoatNormalMapUv),e.push(t.clearcoatRoughnessMapUv),e.push(t.iridescenceMapUv),e.push(t.iridescenceThicknessMapUv),e.push(t.sheenColorMapUv),e.push(t.sheenRoughnessMapUv),e.push(t.specularMapUv),e.push(t.specularColorMapUv),e.push(t.specularIntensityMapUv),e.push(t.transmissionMapUv),e.push(t.thicknessMapUv),e.push(t.combine),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.numLightProbes),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking)}function y(e,t){s.disableAll(),t.isWebGL2&&s.enable(0),t.supportsVertexTextures&&s.enable(1),t.instancing&&s.enable(2),t.instancingColor&&s.enable(3),t.matcap&&s.enable(4),t.envMap&&s.enable(5),t.normalMapObjectSpace&&s.enable(6),t.normalMapTangentSpace&&s.enable(7),t.clearcoat&&s.enable(8),t.iridescence&&s.enable(9),t.alphaTest&&s.enable(10),t.vertexColors&&s.enable(11),t.vertexAlphas&&s.enable(12),t.vertexUv1s&&s.enable(13),t.vertexUv2s&&s.enable(14),t.vertexUv3s&&s.enable(15),t.vertexTangents&&s.enable(16),t.anisotropy&&s.enable(17),t.alphaHash&&s.enable(18),t.batching&&s.enable(19),e.push(s.mask),s.disableAll(),t.fog&&s.enable(0),t.useFog&&s.enable(1),t.flatShading&&s.enable(2),t.logarithmicDepthBuffer&&s.enable(3),t.skinning&&s.enable(4),t.morphTargets&&s.enable(5),t.morphNormals&&s.enable(6),t.morphColors&&s.enable(7),t.premultipliedAlpha&&s.enable(8),t.shadowMapEnabled&&s.enable(9),t.useLegacyLights&&s.enable(10),t.doubleSided&&s.enable(11),t.flipSided&&s.enable(12),t.useDepthPacking&&s.enable(13),t.dithering&&s.enable(14),t.transmission&&s.enable(15),t.sheen&&s.enable(16),t.opaque&&s.enable(17),t.pointsUvs&&s.enable(18),t.decodeVideoTexture&&s.enable(19),e.push(s.mask)}function b(e){let t=m[e.type],n;if(t){let e=FS[t];n=bS.clone(e.uniforms)}else n=e.uniforms;return n}function x(t,n){let r;for(let e=0,t=l.length;e0?r.push(u):a.transparent===!0?i.push(u):n.push(u)}function c(e,t,a,s,c,l){let u=o(e,t,a,s,c,l);a.transmission>0?r.unshift(u):a.transparent===!0?i.unshift(u):n.unshift(u)}function l(e,t){n.length>1&&n.sort(e||Ase),r.length>1&&r.sort(t||EC),i.length>1&&i.sort(t||EC)}function u(){for(let n=t,r=e.length;n=r.length?(i=new DC,r.push(i)):i=r[n],i}function n(){e=new WeakMap}return{get:t,dispose:n}}function Mse(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={direction:new Tb,color:new Fx};break;case`SpotLight`:n={position:new Tb,direction:new Tb,color:new Fx,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case`PointLight`:n={position:new Tb,color:new Fx,distance:0,decay:0};break;case`HemisphereLight`:n={direction:new Tb,skyColor:new Fx,groundColor:new Fx};break;case`RectAreaLight`:n={color:new Fx,position:new Tb,halfWidth:new Tb,halfHeight:new Tb};break}return e[t.id]=n,n}}}function Nse(){let e={};return{get:function(t){if(e[t.id]!==void 0)return e[t.id];let n;switch(t.type){case`DirectionalLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb};break;case`SpotLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb};break;case`PointLight`:n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new rb,shadowCameraNear:1,shadowCameraFar:1e3};break}return e[t.id]=n,n}}}var Pse=0;function Fse(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+ +!!t.map-!!e.map}function Ise(e,t){let n=new Mse,r=Nse(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let e=0;e<9;e++)i.probe.push(new Tb);let a=new Tb,o=new ex,s=new ex;function c(a,o){let s=0,c=0,l=0;for(let e=0;e<9;e++)i.probe[e].set(0,0,0);let u=0,d=0,f=0,p=0,m=0,h=0,g=0,_=0,v=0,y=0,b=0;a.sort(Fse);let x=o===!0?Math.PI:1;for(let e=0,t=a.length;e0&&(t.isWebGL2||e.has(`OES_texture_float_linear`)===!0?(i.rectAreaLTC1=PS.LTC_FLOAT_1,i.rectAreaLTC2=PS.LTC_FLOAT_2):e.has(`OES_texture_half_float_linear`)===!0?(i.rectAreaLTC1=PS.LTC_HALF_1,i.rectAreaLTC2=PS.LTC_HALF_2):console.error(`THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.`)),i.ambient[0]=s,i.ambient[1]=c,i.ambient[2]=l;let S=i.hash;(S.directionalLength!==u||S.pointLength!==d||S.spotLength!==f||S.rectAreaLength!==p||S.hemiLength!==m||S.numDirectionalShadows!==h||S.numPointShadows!==g||S.numSpotShadows!==_||S.numSpotMaps!==v||S.numLightProbes!==b)&&(i.directional.length=u,i.spot.length=f,i.rectArea.length=p,i.point.length=d,i.hemi.length=m,i.directionalShadow.length=h,i.directionalShadowMap.length=h,i.pointShadow.length=g,i.pointShadowMap.length=g,i.spotShadow.length=_,i.spotShadowMap.length=_,i.directionalShadowMatrix.length=h,i.pointShadowMatrix.length=g,i.spotLightMatrix.length=_+v-y,i.spotLightMap.length=v,i.numSpotLightShadowsWithMaps=y,i.numLightProbes=b,S.directionalLength=u,S.pointLength=d,S.spotLength=f,S.rectAreaLength=p,S.hemiLength=m,S.numDirectionalShadows=h,S.numPointShadows=g,S.numSpotShadows=_,S.numSpotMaps=v,S.numLightProbes=b,i.version=Pse++)}function l(e,t){let n=0,r=0,c=0,l=0,u=0,d=t.matrixWorldInverse;for(let t=0,f=e.length;t=a.length?(o=new OC(e,t),a.push(o)):o=a[i],o}function i(){n=new WeakMap}return{get:r,dispose:i}}var Rse=class extends Lx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type=`MeshDepthMaterial`,this.depthPacking=oae,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}},zse=class extends Lx{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type=`MeshDistanceMaterial`,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}},Bse=`void main() { gl_Position = vec4( position, 1.0 ); -}`,Hse=`uniform sampler2D shadow_pass; +}`,Vse=`uniform sampler2D shadow_pass; uniform vec2 resolution; uniform float radius; #include @@ -7628,7 +7628,7 @@ void main() { squared_mean = squared_mean / samples; float std_dev = sqrt( squared_mean - mean * mean ); gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) ); -}`;function Use(e,t,n){let r=new AS,i=new rb,a=new rb,o=new xb,s=new zse({depthPacking:sae}),c=new Bse,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new bS({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rb},radius:{value:4}},vertexShader:Vse,fragmentShader:Hse}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Yx;m.setAttribute(`position`,new zx(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new pS(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==3&&this.type===3,m=_===3&&this.type!==3;for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/h.x),i.x=a.x*h.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/h.y),i.y=a.y*h.y,d.mapSize.y=a.y)),d.map===null||p===!0||m===!0){let e=this.type===3?{}:{minFilter:hy,magFilter:hy};d.map!==null&&d.map.dispose(),d.map=new Sb(i.x,i.y,e),d.map.texture.name=l.name+`.shadowMap`,d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let g=d.getViewportCount();for(let e=0;e0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(F=parseFloat(/^WebGL (\d)/.exec(I)[1]),P=F>=1);let L=null,R={},z=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),V=new xb().fromArray(z),ee=new xb().fromArray(B);function te(t,n,i,a){let o=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s`u`?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,h,g=new WeakMap,_=!1;try{_=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function v(e,t){return _?new OffscreenCanvas(e,t):sb(`canvas`)}function y(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||t===!0)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let r=t?$y:Math.floor,a=r(i*e.width),o=r(i*e.height);h===void 0&&(h=v(a,o));let s=n?v(a,o):h;return s.width=a,s.height=o,s.getContext(`2d`).drawImage(e,0,0,a,o),console.warn(`THREE.WebGLRenderer: Texture has been resized from (`+e.width+`x`+e.height+`) to (`+a+`x`+o+`).`),s}else return`data`in e&&console.warn(`THREE.WebGLRenderer: Image in DataTexture is too big (`+e.width+`x`+e.height+`).`),e;return e}function b(e){return Qy(e.width)&&Qy(e.height)}function x(e){return s?!1:e.wrapS!==1001||e.wrapT!==1001||e.minFilter!==1003&&e.minFilter!==1006}function S(e,t){return e.generateMipmaps&&t&&e.minFilter!==1003&&e.minFilter!==1006}function C(t){e.generateMipmap(t)}function w(n,r,i,a,o=!1){if(s===!1)return r;if(n!==null){if(e[n]!==void 0)return e[n];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c=r;if(r===e.RED&&(i===e.FLOAT&&(c=e.R32F),i===e.HALF_FLOAT&&(c=e.R16F),i===e.UNSIGNED_BYTE&&(c=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(c=e.R8UI),i===e.UNSIGNED_SHORT&&(c=e.R16UI),i===e.UNSIGNED_INT&&(c=e.R32UI),i===e.BYTE&&(c=e.R8I),i===e.SHORT&&(c=e.R16I),i===e.INT&&(c=e.R32I)),r===e.RG&&(i===e.FLOAT&&(c=e.RG32F),i===e.HALF_FLOAT&&(c=e.RG16F),i===e.UNSIGNED_BYTE&&(c=e.RG8)),r===e.RGBA){let t=o?Ly:pb.getTransfer(a);i===e.FLOAT&&(c=e.RGBA32F),i===e.HALF_FLOAT&&(c=e.RGBA16F),i===e.UNSIGNED_BYTE&&(c=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return(c===e.R16F||c===e.R32F||c===e.RG16F||c===e.RG32F||c===e.RGBA16F||c===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),c}function T(e,t,n){return S(e,n)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===1003||t===1004||t===1005?e.NEAREST:e.LINEAR}function D(e){let t=e.target;t.removeEventListener(`dispose`,D),k(t),t.isVideoTexture&&m.delete(t)}function O(e){let t=e.target;t.removeEventListener(`dispose`,O),j(t)}function k(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=g.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&A(e),Object.keys(i).length===0&&g.delete(n)}r.remove(e)}function A(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=g.get(i);delete a[n.__cacheKey],o.memory.textures--}function j(t){let n=t.texture,i=r.get(t),a=r.get(n);if(a.__webglTexture!==void 0&&(e.deleteTexture(a.__webglTexture),o.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(i.__webglFramebuffer[t]))for(let n=0;n=c&&console.warn(`THREE.WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+c),M+=1,e}function F(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function I(t,i){let a=r.get(t);if(t.isVideoTexture&&pe(t),t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)console.warn(`THREE.WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)console.warn(`THREE.WebGLRenderer: Texture marked for update but image is incomplete`);else{re(a,t,i);return}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function L(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){re(a,t,i);return}n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function R(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){re(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function z(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){ie(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let B={[fy]:e.REPEAT,[py]:e.CLAMP_TO_EDGE,[my]:e.MIRRORED_REPEAT},V={[hy]:e.NEAREST,[nae]:e.NEAREST_MIPMAP_NEAREST,[rae]:e.NEAREST_MIPMAP_LINEAR,[gy]:e.LINEAR,[iae]:e.LINEAR_MIPMAP_NEAREST,[_y]:e.LINEAR_MIPMAP_LINEAR},ee={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function te(n,a,o){if(o?(e.texParameteri(n,e.TEXTURE_WRAP_S,B[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,B[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,B[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,V[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,V[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==1001||a.wrapT!==1001)&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.`),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==1003&&a.minFilter!==1006&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.`)),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ee[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){let o=t.get(`EXT_texture_filter_anisotropic`);if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1||s===!1&&a.type===1016&&t.has(`OES_texture_half_float_linear`)===!1)return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function ne(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,D));let i=n.source,a=g.get(i);a===void 0&&(a={},g.set(i,a));let s=F(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&A(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function re(t,i,o){let c=e.TEXTURE_2D;(i.isDataArrayTexture||i.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),i.isData3DTexture&&(c=e.TEXTURE_3D);let l=ne(t,i),d=i.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+o);let f=r.get(d);if(d.version!==f.__version||l===!0){n.activeTexture(e.TEXTURE0+o);let t=pb.getPrimaries(pb.workingColorSpace),r=i.colorSpace===``?null:pb.getPrimaries(i.colorSpace),p=i.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let m=x(i)&&b(i.image)===!1,h=y(i.image,m,!1,u);h=me(i,h);let g=b(h)||s,_=a.convert(i.format,i.colorSpace),v=a.convert(i.type),E=w(i.internalFormat,_,v,i.colorSpace,i.isVideoTexture);te(c,i,g);let D,O=i.mipmaps,k=s&&i.isVideoTexture!==!0&&E!==36196,A=f.__version===void 0||l===!0,j=T(i,h,g);if(i.isDepthTexture)E=e.DEPTH_COMPONENT,s?E=i.type===1015?e.DEPTH_COMPONENT32F:i.type===1014?e.DEPTH_COMPONENT24:i.type===1020?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:i.type===1015&&console.error(`WebGLRenderer: Floating point depth texture requires WebGL2.`),i.format===1026&&E===e.DEPTH_COMPONENT&&i.type!==1012&&i.type!==1014&&(console.warn(`THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.`),i.type=yy,v=a.convert(i.type)),i.format===1027&&E===e.DEPTH_COMPONENT&&(E=e.DEPTH_STENCIL,i.type!==1020&&(console.warn(`THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.`),i.type=Sy,v=a.convert(i.type))),A&&(k?n.texStorage2D(e.TEXTURE_2D,1,E,h.width,h.height):n.texImage2D(e.TEXTURE_2D,0,E,h.width,h.height,0,_,v,null));else if(i.isDataTexture)if(O.length>0&&g){k&&A&&n.texStorage2D(e.TEXTURE_2D,j,E,O[0].width,O[0].height);for(let t=0,r=O.length;t>=1,r>>=1}}else if(O.length>0&&g){k&&A&&n.texStorage2D(e.TEXTURE_2D,j,E,O[0].width,O[0].height);for(let t=0,r=O.length;t0&&k++,n.texStorage2D(e.TEXTURE_CUBE_MAP,k,E,h[0].width,h[0].height));for(let t=0;t<6;t++)if(m){D?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,v,x,h[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,h[t].width,h[t].height,0,v,x,h[t].data);for(let r=0;r>l),r=Math.max(1,i.height>>l);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,l,p,t,r,i.depth,0,u,d,null):n.texImage2D(c,l,p,t,r,0,u,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),fe(i)?f.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,0,de(i)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,l),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ae(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let i=s===!0?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(r||fe(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===1015?i=e.DEPTH_COMPONENT32F:t.type===1014&&(i=e.DEPTH_COMPONENT24));let r=de(n);fe(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,i,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,i,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,i,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let i=de(n);r&&fe(n)===!1?e.renderbufferStorageMultisample(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):fe(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=n.isWebGLMultipleRenderTargets===!0?n.texture:[n.texture];for(let i=0;i0){l.__webglFramebuffer[t]=[];for(let n=0;n0){l.__webglFramebuffer=[];for(let t=0;t0&&fe(t)===!1){let r=f?c:[c];l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0&&fe(t)===!1){let i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,c=[],l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=t.isWebGLMultipleRenderTargets===!0;if(d)for(let t=0;t0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function pe(e){let t=o.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}function me(e,n){let r=e.colorSpace,i=e.format,a=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||e.format===1035||r!==`srgb-linear`&&r!==``&&(pb.getTransfer(r)===`srgb`?s===!1?t.has(`EXT_sRGB`)===!0&&i===1023?(e.format=cae,e.minFilter=gy,e.generateMipmaps=!1):n=_b.sRGBToLinear(n):(i!==1023||a!==1009)&&console.warn(`THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):console.error(`THREE.WebGLTextures: Unsupported texture color space:`,r)),n}this.allocateTextureUnit=P,this.resetTextureUnits=N,this.setTexture2D=I,this.setTexture2DArray=L,this.setTexture3D=R,this.setTextureCube=z,this.rebindTextures=se,this.setupRenderTarget=ce,this.updateRenderTargetMipmap=le,this.updateMultisampleRenderTarget=ue,this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=H,this.useMultisampledRTT=fe}function Kse(e,t,n){let r=n.isWebGL2;function i(n,i=``){let a,o=pb.getTransfer(i);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return r?e.HALF_FLOAT:(a=t.get(`OES_texture_half_float`),a===null?null:a.HALF_FLOAT_OES);if(n===1021)return e.ALPHA;if(n===1023)return e.RGBA;if(n===1024)return e.LUMINANCE;if(n===1025)return e.LUMINANCE_ALPHA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1035)return a=t.get(`EXT_sRGB`),a===null?null:a.SRGB_ALPHA_EXT;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(o===`srgb`)if(a=t.get(`WEBGL_compressed_texture_s3tc_srgb`),a!==null){if(n===33776)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get(`WEBGL_compressed_texture_s3tc`),a!==null){if(n===33776)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(a=t.get(`WEBGL_compressed_texture_pvrtc`),a!==null){if(n===35840)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196)return a=t.get(`WEBGL_compressed_texture_etc1`),a===null?null:a.COMPRESSED_RGB_ETC1_WEBGL;if(n===37492||n===37496)if(a=t.get(`WEBGL_compressed_texture_etc`),a!==null){if(n===37492)return o===`srgb`?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===37496)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(a=t.get(`WEBGL_compressed_texture_astc`),a!==null){if(n===37808)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(a=t.get(`EXT_texture_compression_bptc`),a!==null){if(n===36492)return o===`srgb`?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(a=t.get(`EXT_texture_compression_rgtc`),a!==null){if(n===36492)return a.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?r?e.UNSIGNED_INT_24_8:(a=t.get(`WEBGL_depth_texture`),a===null?null:a.UNSIGNED_INT_24_8_WEBGL):e[n]===void 0?null:e[n]}return{convert:i}}var qse=class extends SS{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},OC=class extends _x{constructor(){super(),this.isGroup=!0,this.type=`Group`}},Jse={type:`move`},kC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new OC,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new OC,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Tb,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Tb),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new OC,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Tb,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Tb),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Jse)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new OC;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Yse=class extends Uy{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=t.getContextAttributes(),h=null,g=null,_=[],v=[],y=new rb,b=null,x=new SS;x.layers.enable(1),x.viewport=new xb;let S=new SS;S.layers.enable(2),S.viewport=new xb;let C=[x,S],w=new qse;w.layers.enable(1),w.layers.enable(2);let T=null,E=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return t===void 0&&(t=new kC,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return t===void 0&&(t=new kC,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return t===void 0&&(t=new kC,_[e]=t),t.getHandSpace()};function D(e){let t=v.indexOf(e.inputSource);if(t===-1)return;let n=_[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function O(){r.removeEventListener(`select`,D),r.removeEventListener(`selectstart`,D),r.removeEventListener(`selectend`,D),r.removeEventListener(`squeeze`,D),r.removeEventListener(`squeezestart`,D),r.removeEventListener(`squeezeend`,D),r.removeEventListener(`end`,O),r.removeEventListener(`inputsourceschange`,k);for(let e=0;e<_.length;e++){let t=v[e];t!==null&&(v[e]=null,_[e].disconnect(t))}T=null,E=null,e.setRenderTarget(h),f=null,d=null,u=null,r=null,g=null,L.stop(),n.isPresenting=!1,e.setPixelRatio(b),e.setSize(y.width,y.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(h=e.getRenderTarget(),r.addEventListener(`select`,D),r.addEventListener(`selectstart`,D),r.addEventListener(`selectend`,D),r.addEventListener(`squeeze`,D),r.addEventListener(`squeezestart`,D),r.addEventListener(`squeezeend`,D),r.addEventListener(`end`,O),r.addEventListener(`inputsourceschange`,k),m.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(y),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let n={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),g=new Sb(f.framebufferWidth,f.framebufferHeight,{format:Cy,type:vy,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,a=null,o=null;m.depth&&(o=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?aae:wy,a=m.stencil?Sy:yy);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new Sb(d.textureWidth,d.textureHeight,{format:Cy,type:vy,depthTexture:new $S(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let c=e.properties.get(g);c.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),L.setContext(r),L.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function k(e){for(let t=0;t=0&&(v[r]=null,_[r].disconnect(n))}for(let t=0;t=v.length){v.push(n),r=e;break}else if(v[e]===null){v[e]=n,r=e;break}if(r===-1)break}let i=_[r];i&&i.connect(n)}}let A=new Tb,j=new Tb;function M(e,t,n){A.setFromMatrixPosition(t.matrixWorld),j.setFromMatrixPosition(n.matrixWorld);let r=A.distanceTo(j),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=o+m,_=s+m,v=f-h,y=p+(r-h),b=c*s/_*g,x=l*s/_*g;e.projectionMatrix.makePerspective(v,y,b,x,g,_),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}function N(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;w.near=S.near=x.near=e.near,w.far=S.far=x.far=e.far,(T!==w.near||E!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,E=w.far);let t=e.parent,n=w.cameras;N(w,t);for(let e=0;e0&&(r.alphaTest.value=i.alphaTest);let a=t.get(i).envMap;if(a&&(r.envMap.value=a,r.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,r.reflectivity.value=i.reflectivity,r.ior.value=i.ior,r.refractionRatio.value=i.refractionRatio),i.lightMap){r.lightMap.value=i.lightMap;let t=e._useLegacyLights===!0?Math.PI:1;r.lightMapIntensity.value=i.lightMapIntensity*t,n(i.lightMap,r.lightMapTransform)}i.aoMap&&(r.aoMap.value=i.aoMap,r.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,r.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,n(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,n(r.roughnessMap,e.roughnessMapTransform)),t.get(r).envMap&&(e.envMapIntensity.value=r.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Zse(e,t,n,r){let i={},a={},o=[],s=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0){r=n%16;let e=16-r;r!==0&&e-a.boundary<0&&(n+=16-r,i.__offset=n)}n+=a.storage}return r=n%16,r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var AC=class{constructor(e={}){let{canvas:t=wae(),context:n=null,depth:r=!0,stencil:i=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;d=n===null?a:n.getContextAttributes().alpha;let f=new Uint32Array(4),p=new Int32Array(4),m=null,h=null,g=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ny,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;let v=this,y=!1,b=0,x=0,S=null,C=-1,w=null,T=new xb,E=new xb,D=null,O=new Px(0),k=0,A=t.width,j=t.height,M=1,N=null,P=null,F=new xb(0,0,A,j),I=new xb(0,0,A,j),L=!1,R=new AS,z=!1,B=!1,V=null,ee=new ex,te=new rb,ne=new Tb,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ie(){return S===null?M:1}let H=n;function ae(e,n){for(let r=0;r{function n(){if(r.forEach(function(e){le.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}oe.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Re=null;function ze(e){Re&&Re(e)}function Be(){He.stop()}function Ve(){He.start()}let He=new jS;He.setAnimationLoop(ze),typeof self<`u`&&He.setContext(self),this.setAnimationLoop=function(e){Re=e,Ae.setAnimationLoop(e),e===null?He.stop():He.start()},Ae.addEventListener(`sessionstart`,Be),Ae.addEventListener(`sessionend`,Ve),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(y===!0)return;e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(t),t=Ae.getCamera()),e.isScene===!0&&e.onBeforeRender(v,e,t,S),h=ye.get(e,_.length),h.init(),_.push(h),ee.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),R.setFromProjectionMatrix(ee),B=this.localClippingEnabled,z=be.init(this.clippingPlanes,B),m=ve.get(e,g.length),m.init(),g.push(m),Ue(e,t,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(N,P),this.info.render.frame++,z===!0&&be.beginShadows();let n=h.state.shadowsArray;if(xe.render(n,e,t),z===!0&&be.endShadows(),this.info.autoReset===!0&&this.info.reset(),Se.render(m,e),h.setupLights(v._useLegacyLights),t.isArrayCamera){let n=t.cameras;for(let t=0,r=n.length;t0?_[_.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null};function Ue(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)h.pushLight(e),e.castShadow&&h.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||R.intersectsSprite(e)){r&&ne.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ee);let t=he.update(e),i=e.material;i.visible&&m.push(e,t,i,n,ne.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||R.intersectsObject(e))){let t=he.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ne.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ne.copy(e.boundingSphere.center)),ne.applyMatrix4(e.matrixWorld).applyMatrix4(ee)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Ge(i,a,t,n),r&&se.viewport(T.copy(r)),i.length>0&&Ke(i,t,n),a.length>0&&Ke(a,t,n),o.length>0&&Ke(o,t,n),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function Ge(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;let i=U.isWebGL2;V===null&&(V=new Sb(1,1,{generateMipmaps:!0,type:oe.has(`EXT_color_buffer_half_float`)?xy:vy,minFilter:_y,samples:i?4:0})),v.getDrawingBufferSize(te),i?V.setSize(te.x,te.y):V.setSize($y(te.x),$y(te.y));let a=v.getRenderTarget();v.setRenderTarget(V),v.getClearColor(O),k=v.getClearAlpha(),k<1&&v.setClearColor(16777215,.5),v.clear();let o=v.toneMapping;v.toneMapping=0,Ke(e,n,r),ue.updateMultisampleRenderTarget(V),ue.updateRenderTargetMipmap(V);let s=!1;for(let e=0,i=t.length;e0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(S===null||S.isXRRenderTarget===!0)&&(m=v.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,y=le.get(r),b=h.state.lights;if(z===!0&&(B===!0||e!==w)){let t=e===w&&r.id===C;be.setState(r,e,t)}let x=!1;r.version===y.__version?y.needsLights&&y.lightsStateVersion!==b.state.version?x=!0:y.outputColorSpace===s?i.isBatchedMesh&&y.batching===!1||!i.isBatchedMesh&&y.batching===!0||i.isInstancedMesh&&y.instancing===!1||!i.isInstancedMesh&&y.instancing===!0||i.isSkinnedMesh&&y.skinning===!1||!i.isSkinnedMesh&&y.skinning===!0||i.isInstancedMesh&&y.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&y.instancingColor===!1&&i.instanceColor!==null?x=!0:y.envMap===c?r.fog===!0&&y.fog!==a||y.numClippingPlanes!==void 0&&(y.numClippingPlanes!==be.numPlanes||y.numIntersection!==be.numIntersection)?x=!0:y.vertexAlphas===l&&y.vertexTangents===u&&y.morphTargets===d&&y.morphNormals===f&&y.morphColors===p&&y.toneMapping===m?U.isWebGL2===!0&&y.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,y.__version=r.version);let T=y.currentProgram;x===!0&&(T=Je(r,t,i));let E=!1,D=!1,O=!1,k=T.getUniforms(),A=y.uniforms;if(se.useProgram(T.program)&&(E=!0,D=!0,O=!0),r.id!==C&&(C=r.id,D=!0),E||w!==e){k.setValue(H,`projectionMatrix`,e.projectionMatrix),k.setValue(H,`viewMatrix`,e.matrixWorldInverse);let t=k.map.cameraPosition;t!==void 0&&t.setValue(H,ne.setFromMatrixPosition(e.matrixWorld)),U.logarithmicDepthBuffer&&k.setValue(H,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&k.setValue(H,`isOrthographic`,e.isOrthographicCamera===!0),w!==e&&(w=e,D=!0,O=!0)}if(i.isSkinnedMesh){k.setOptional(H,i,`bindMatrix`),k.setOptional(H,i,`bindMatrixInverse`);let e=i.skeleton;e&&(U.floatVertexTextures?(e.boneTexture===null&&e.computeBoneTexture(),k.setValue(H,`boneTexture`,e.boneTexture,ue)):console.warn(`THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.`))}i.isBatchedMesh&&(k.setOptional(H,i,`batchingTexture`),k.setValue(H,`batchingTexture`,i._matricesTexture,ue));let N=n.morphAttributes;if((N.position!==void 0||N.normal!==void 0||N.color!==void 0&&U.isWebGL2===!0)&&Ce.update(i,n,T),(D||y.receiveShadow!==i.receiveShadow)&&(y.receiveShadow=i.receiveShadow,k.setValue(H,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(A.envMap.value=c,A.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),D&&(k.setValue(H,`toneMappingExposure`,v.toneMappingExposure),y.needsLights&&Qe(A,O),a&&r.fog===!0&&_e.refreshFogUniforms(A,a),_e.refreshMaterialUniforms(A,r,M,j,V),gC.upload(H,Ye(y),A,ue)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(gC.upload(H,Ye(y),A,ue),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&k.setValue(H,`center`,i.center),k.setValue(H,`modelViewMatrix`,i.modelViewMatrix),k.setValue(H,`normalMatrix`,i.normalMatrix),k.setValue(H,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&ue.useMultisampledRTT(e)===!1?le.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,T.copy(e.viewport),E.copy(e.scissor),D=e.scissorTest}else T.copy(F).multiplyScalar(M).floor(),E.copy(I).multiplyScalar(M).floor(),D=L;if(se.bindFramebuffer(H.FRAMEBUFFER,i)&&U.drawBuffers&&r&&se.drawBuffers(e,i),se.viewport(T),se.scissor(E),se.setScissorTest(D),a){let r=le.get(e.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=le.get(e.texture),i=t||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}C=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let s=le.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){se.bindFramebuffer(H.FRAMEBUFFER,s);try{let o=e.texture,s=o.format,c=o.type;if(s!==1023&&Ee.convert(s)!==H.getParameter(H.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}let l=c===1016&&(oe.has(`EXT_color_buffer_half_float`)||U.isWebGL2&&oe.has(`EXT_color_buffer_float`));if(c!==1009&&Ee.convert(c)!==H.getParameter(H.IMPLEMENTATION_COLOR_READ_TYPE)&&!(c===1015&&(U.isWebGL2||oe.has(`OES_texture_float`)||oe.has(`WEBGL_color_buffer_float`)))&&!l){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&H.readPixels(t,n,r,i,Ee.convert(s),Ee.convert(c),a)}finally{let e=S===null?null:le.get(S).__webglFramebuffer;se.bindFramebuffer(H.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let r=2**-n,i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);ue.setTexture2D(t,0),H.copyTexSubImage2D(H.TEXTURE_2D,n,0,0,e.x,e.y,i,a),se.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){let i=t.image.width,a=t.image.height,o=Ee.convert(n.format),s=Ee.convert(n.type);ue.setTexture2D(n,0),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,n.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):H.texSubImage2D(H.TEXTURE_2D,r,e.x,e.y,o,s,t.image),r===0&&n.generateMipmaps&&H.generateMipmap(H.TEXTURE_2D),se.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(v.isWebGL1Renderer){console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.`);return}let a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,c=Ee.convert(r.format),l=Ee.convert(r.type),u;if(r.isData3DTexture)ue.setTexture3D(r,0),u=H.TEXTURE_3D;else if(r.isDataArrayTexture)ue.setTexture2DArray(r,0),u=H.TEXTURE_2D_ARRAY;else{console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.`);return}H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,r.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,r.unpackAlignment);let d=H.getParameter(H.UNPACK_ROW_LENGTH),f=H.getParameter(H.UNPACK_IMAGE_HEIGHT),p=H.getParameter(H.UNPACK_SKIP_PIXELS),m=H.getParameter(H.UNPACK_SKIP_ROWS),h=H.getParameter(H.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,g.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,g.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,e.min.x),H.pixelStorei(H.UNPACK_SKIP_ROWS,e.min.y),H.pixelStorei(H.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?H.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g.data):n.isCompressedArrayTexture?(console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.`),H.compressedTexSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,g.data)):H.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g),H.pixelStorei(H.UNPACK_ROW_LENGTH,d),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,f),H.pixelStorei(H.UNPACK_SKIP_PIXELS,p),H.pixelStorei(H.UNPACK_SKIP_ROWS,m),H.pixelStorei(H.UNPACK_SKIP_IMAGES,h),i===0&&r.generateMipmaps&&H.generateMipmap(u),se.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?ue.setTextureCube(e,0):e.isData3DTexture?ue.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ue.setTexture2DArray(e,0):ue.setTexture2D(e,0),se.unbindTexture()},this.resetState=function(){b=0,x=0,S=null,se.reset(),De.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Hy}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===`display-p3`?`display-p3`:`srgb`,t.unpackColorSpace=pb.workingColorSpace===`display-p3-linear`?`display-p3`:`srgb`}get physicallyCorrectLights(){return console.warn(`THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.`),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn(`THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.`),this.useLegacyLights=!e}get outputEncoding(){return console.warn(`THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.`),this.outputColorSpace===`srgb`?My:jy}set outputEncoding(e){console.warn(`THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.`),this.outputColorSpace=e===3001?Ny:Py}get useLegacyLights(){return console.warn(`THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.`),this._useLegacyLights}set useLegacyLights(e){console.warn(`THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.`),this._useLegacyLights=e}},Qse=class extends AC{};Qse.prototype.isWebGL1Renderer=!0;var $se=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new Px(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},ece=class extends _x{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}},tce=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Vy,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Jy()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(`THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.`),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r=n.length&&n.push({start:-1,count:-1,z:-1});let i=n[this.index];r.push(i),this.index++,i.start=e.start,i.count=e.count,i.z=t}reset(){this.list.length=0,this.index=0}},NC=`batchId`,PC=new ex,oce=new ex,sce=new ex,cce=new ex,FC=new AS,IC=new Ob,LC=new Gb,RC=new Tb,zC=new ace,BC=new pS,VC=[];function lce(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a65536?new Uint32Array(i):new Uint16Array(i);t.setIndex(new zx(e,1))}let a=r>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(NC,new zx(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(NC))throw Error(`BatchedMesh: Geometry cannot use attribute "${NC}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(n===NC)continue;if(!e.hasAttribute(n))throw Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ob);let e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},i=null,a=this._reservedRanges,o=this._drawRanges,s=this._bounds;this._geometryCount!==0&&(i=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute(`position`).count:r.vertexCount=t,i===null?r.vertexStart=0:r.vertexStart=i.vertexStart+i.vertexCount;let c=e.getIndex(),l=c!==null;if(l&&(n===-1?r.indexCount=c.count:r.indexCount=n,i===null?r.indexStart=0:r.indexStart=i.indexStart+i.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw Error(`BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let u=this._visibility,d=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;u.push(!0),d.push(!0);let m=this._geometryCount;this._geometryCount++,sce.toArray(p,m*16),f.needsUpdate=!0,a.push(r),o.push({start:l?r.indexStart:r.vertexStart,count:-1}),s.push({boxInitialized:!1,box:new Ob,sphereInitialized:!1,sphere:new Gb});let h=this.geometry.getAttribute(NC);for(let e=0;e=this._geometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw Error(`BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.vertexCount;for(let e in n.attributes){if(e===NC)continue;let r=t.getAttribute(e),i=n.getAttribute(e);lce(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;let n=this._bounds[e],r=n.box,i=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();let t=i.index,a=i.attributes.position,o=this._drawRanges[e];for(let e=o.start,n=o.start+o.count;e=this._geometryCount||n[e]===!1?this:(t.toArray(i,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let n=this._active,r=this._matricesTexture.image.data;return e>=this._geometryCount||n[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let n=this._visibility,r=this._active;return e>=this._geometryCount||r[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,n=this._active;return e>=this._geometryCount||n[e]===!1?!1:t[e]}raycast(e,t){let n=this._visibility,r=this._active,i=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,s=this.geometry;BC.material=this.material,BC.geometry.index=s.index,BC.geometry.attributes=s.attributes,BC.geometry.boundingBox===null&&(BC.geometry.boundingBox=new Ob),BC.geometry.boundingSphere===null&&(BC.geometry.boundingSphere=new Gb);for(let s=0;s({...e})),this._reservedRanges=e._reservedRanges.map(e=>({...e})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=this._visibility,c=this._multiDrawStarts,l=this._multiDrawCounts,u=this._drawRanges,d=this.perObjectFrustumCulled;d&&(cce.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),FC.setFromProjectionMatrix(cce,e.isWebGPURenderer?lae:Hy));let f=0;if(this.sortObjects){oce.copy(this.matrixWorld).invert(),RC.setFromMatrixPosition(n.matrixWorld).applyMatrix4(oce);for(let e=0,t=s.length;es)continue;d.applyMatrix4(this.matrixWorld);let a=e.ray.origin.distanceTo(d);ae.far||t.push({distance:a,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{let n=Math.max(0,a.start),r=Math.min(m.count,a.start+a.count);for(let i=n,a=r-1;is)continue;d.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(d);ne.far||t.push({distance:n,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&hce(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Dy,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};ew.prototype.TimeBufferType=Float32Array,ew.prototype.ValueBufferType=Float32Array,ew.prototype.DefaultInterpolation=Ey;var tw=class extends ew{};tw.prototype.ValueTypeName=`bool`,tw.prototype.ValueBufferType=Array,tw.prototype.DefaultInterpolation=Ty,tw.prototype.InterpolantFactoryMethodLinear=void 0,tw.prototype.InterpolantFactoryMethodSmooth=void 0;var yce=class extends ew{};yce.prototype.ValueTypeName=`color`;var bce=class extends ew{};bce.prototype.ValueTypeName=`number`;var xce=class extends $C{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)wb.slerpFlat(i,0,a,c-o,a,c,s);return i}},nw=class extends ew{InterpolantFactoryMethodLinear(e){return new xce(this.times,this.values,this.getValueSize(),e)}};nw.prototype.ValueTypeName=`quaternion`,nw.prototype.DefaultInterpolation=Ey,nw.prototype.InterpolantFactoryMethodSmooth=void 0;var rw=class extends ew{};rw.prototype.ValueTypeName=`string`,rw.prototype.ValueBufferType=Array,rw.prototype.DefaultInterpolation=Ty,rw.prototype.InterpolantFactoryMethodLinear=void 0,rw.prototype.InterpolantFactoryMethodSmooth=void 0;var Sce=class extends ew{};Sce.prototype.ValueTypeName=`vector`;var Cce=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;te.stopPropagation()),this.domElement.addEventListener(`keyup`,e=>e.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle(`disabled`,e),this.$disable.toggleAttribute(`disabled`,e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?`none`:``,this}hide(){return this.show(!1)}options(e){let t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);let e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}},Hce=class extends _w{constructor(e,t,n){super(e,t,n,`boolean`,`label`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`checkbox`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener(`change`,()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}};function vw(e){let t,n;return(t=e.match(/(#|0x)?([a-f0-9]{6})/i))?n=t[2]:(t=e.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?n=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=e.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(n=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),n?`#`+n:!1}var Uce={isPrimitive:!0,match:e=>typeof e==`string`,fromHexString:vw,toHexString:vw},yw={isPrimitive:!0,match:e=>typeof e==`number`,fromHexString:e=>parseInt(e.substring(1),16),toHexString:e=>`#`+e.toString(16).padStart(6,0)},Wce=[Uce,yw,{isPrimitive:!1,match:e=>Array.isArray(e),fromHexString(e,t,n=1){let r=yw.fromHexString(e);t[0]=(r>>16&255)/255*n,t[1]=(r>>8&255)/255*n,t[2]=(r&255)/255*n},toHexString([e,t,n],r=1){r=255/r;let i=e*r<<16^t*r<<8^n*r<<0;return yw.toHexString(i)}},{isPrimitive:!1,match:e=>Object(e)===e,fromHexString(e,t,n=1){let r=yw.fromHexString(e);t.r=(r>>16&255)/255*n,t.g=(r>>8&255)/255*n,t.b=(r&255)/255*n},toHexString({r:e,g:t,b:n},r=1){r=255/r;let i=e*r<<16^t*r<<8^n*r<<0;return yw.toHexString(i)}}];function Gce(e){return Wce.find(t=>t.match(e))}var Kce=class extends _w{constructor(e,t,n,r){super(e,t,n,`color`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`color`),this.$input.setAttribute(`tabindex`,-1),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$text=document.createElement(`input`),this.$text.setAttribute(`type`,`text`),this.$text.setAttribute(`spellcheck`,`false`),this.$text.setAttribute(`aria-labelledby`,this.$name.id),this.$display=document.createElement(`div`),this.$display.classList.add(`display`),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=Gce(this.initialValue),this._rgbScale=r,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener(`input`,()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener(`blur`,()=>{this._callOnFinishChange()}),this.$text.addEventListener(`input`,()=>{let e=vw(this.$text.value);e&&this._setValueFromHexString(e)}),this.$text.addEventListener(`focus`,()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener(`blur`,()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){let t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}},bw=class extends _w{constructor(e,t,n){super(e,t,n,`function`),this.$button=document.createElement(`button`),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener(`click`,e=>{e.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener(`touchstart`,()=>{},{passive:!0}),this.$disable=this.$button}},qce=class extends _w{constructor(e,t,n,r,i,a){super(e,t,n,`number`),this._initInput(),this.min(r),this.max(i);let o=a!==void 0;this.step(o?a:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){let e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=t*100+`%`}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`text`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),window.matchMedia(`(pointer: coarse)`).matches&&(this.$input.setAttribute(`type`,`number`),this.$input.setAttribute(`step`,`any`)),this.$widget.appendChild(this.$input),this.$disable=this.$input;let e=()=>{let e=parseFloat(this.$input.value);isNaN(e)||(this._stepExplicit&&(e=this._snap(e)),this.setValue(this._clamp(e)))},t=e=>{let t=parseFloat(this.$input.value);isNaN(t)||(this._snapClampSetValue(t+e),this.$input.value=this.getValue())},n=e=>{e.key===`Enter`&&this.$input.blur(),e.code===`ArrowUp`&&(e.preventDefault(),t(this._step*this._arrowKeyMultiplier(e))),e.code===`ArrowDown`&&(e.preventDefault(),t(this._step*this._arrowKeyMultiplier(e)*-1))},r=e=>{this._inputFocused&&(e.preventDefault(),t(this._step*this._normalizeMouseWheel(e)))},i=!1,a,o,s,c,l,u=e=>{a=e.clientX,o=s=e.clientY,i=!0,c=this.getValue(),l=0,window.addEventListener(`mousemove`,d),window.addEventListener(`mouseup`,f)},d=e=>{if(i){let t=e.clientX-a,n=e.clientY-o;Math.abs(n)>5?(e.preventDefault(),this.$input.blur(),i=!1,this._setDraggingStyle(!0,`vertical`)):Math.abs(t)>5&&f()}if(!i){let t=e.clientY-s;l-=t*this._step*this._arrowKeyMultiplier(e),c+l>this._max?l=this._max-c:c+l{this._setDraggingStyle(!1,`vertical`),this._callOnFinishChange(),window.removeEventListener(`mousemove`,d),window.removeEventListener(`mouseup`,f)};this.$input.addEventListener(`input`,e),this.$input.addEventListener(`keydown`,n),this.$input.addEventListener(`wheel`,r,{passive:!1}),this.$input.addEventListener(`mousedown`,u),this.$input.addEventListener(`focus`,()=>{this._inputFocused=!0}),this.$input.addEventListener(`blur`,()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement(`div`),this.$slider.classList.add(`slider`),this.$fill=document.createElement(`div`),this.$fill.classList.add(`fill`),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add(`hasSlider`);let e=(e,t,n,r,i)=>(e-t)/(n-t)*(i-r)+r,t=t=>{let n=this.$slider.getBoundingClientRect(),r=e(t,n.left,n.right,this._min,this._max);this._snapClampSetValue(r)},n=e=>{this._setDraggingStyle(!0),t(e.clientX),window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},r=e=>{t(e.clientX)},i=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)},a=!1,o,s,c=e=>{e.preventDefault(),this._setDraggingStyle(!0),t(e.touches[0].clientX),a=!1},l=e=>{e.touches.length>1||(this._hasScrollBar?(o=e.touches[0].clientX,s=e.touches[0].clientY,a=!0):c(e),window.addEventListener(`touchmove`,u,{passive:!1}),window.addEventListener(`touchend`,d))},u=e=>{if(a){let t=e.touches[0].clientX-o,n=e.touches[0].clientY-s;Math.abs(t)>Math.abs(n)?c(e):(window.removeEventListener(`touchmove`,u),window.removeEventListener(`touchend`,d))}else e.preventDefault(),t(e.touches[0].clientX)},d=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener(`touchmove`,u),window.removeEventListener(`touchend`,d)},f=this._callOnFinishChange.bind(this),p;this.$slider.addEventListener(`mousedown`,n),this.$slider.addEventListener(`touchstart`,l,{passive:!1}),this.$slider.addEventListener(`wheel`,e=>{if(Math.abs(e.deltaX)this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){let e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}},Jce=class extends _w{constructor(e,t,n,r){super(e,t,n,`option`),this.$select=document.createElement(`select`),this.$select.setAttribute(`aria-labelledby`,this.$name.id),this.$display=document.createElement(`div`),this.$display.classList.add(`display`),this.$select.addEventListener(`change`,()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener(`focus`,()=>{this.$display.classList.add(`focus`)}),this.$select.addEventListener(`blur`,()=>{this.$display.classList.remove(`focus`)}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(r)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(e=>{let t=document.createElement(`option`);t.textContent=e,this.$select.appendChild(t)}),this.updateDisplay(),this}updateDisplay(){let e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.textContent=t===-1?e:this._names[t],this}},Yce=class extends _w{constructor(e,t,n){super(e,t,n,`string`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`text`),this.$input.setAttribute(`spellcheck`,`false`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$input.addEventListener(`input`,()=>{this.setValue(this.$input.value)}),this.$input.addEventListener(`keydown`,e=>{e.code===`Enter`&&this.$input.blur()}),this.$input.addEventListener(`blur`,()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}},Xce=`.lil-gui { +}`;function Hse(e,t,n){let r=new jS,i=new rb,a=new rb,o=new xb,s=new Rse({depthPacking:sae}),c=new zse,l={},u=n.maxTextureSize,d={0:1,1:0,2:2},f=new xS({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new rb},radius:{value:4}},vertexShader:Bse,fragmentShader:Vse}),p=f.clone();p.defines.HORIZONTAL_PASS=1;let m=new Xx;m.setAttribute(`position`,new Bx(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let h=new mS(m,f),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1;let _=this.type;this.render=function(t,n,s){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||t.length===0)return;let c=e.getRenderTarget(),l=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),f=e.state;f.setBlending(0),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);let p=_!==3&&this.type===3,m=_===3&&this.type!==3;for(let c=0,l=t.length;cu||i.y>u)&&(i.x>u&&(a.x=Math.floor(u/h.x),i.x=a.x*h.x,d.mapSize.x=a.x),i.y>u&&(a.y=Math.floor(u/h.y),i.y=a.y*h.y,d.mapSize.y=a.y)),d.map===null||p===!0||m===!0){let e=this.type===3?{}:{minFilter:hy,magFilter:hy};d.map!==null&&d.map.dispose(),d.map=new Sb(i.x,i.y,e),d.map.texture.name=l.name+`.shadowMap`,d.camera.updateProjectionMatrix()}e.setRenderTarget(d.map),e.clear();let g=d.getViewportCount();for(let e=0;e0||n.map&&n.alphaTest>0){let e=a.uuid,t=n.uuid,r=l[e];r===void 0&&(r={},l[e]=r);let i=r[t];i===void 0&&(i=a.clone(),r[t]=i),a=i}if(a.visible=n.visible,a.wireframe=n.wireframe,i===3?a.side=n.shadowSide===null?n.side:n.shadowSide:a.side=n.shadowSide===null?d[n.side]:n.shadowSide,a.alphaMap=n.alphaMap,a.alphaTest=n.alphaTest,a.map=n.map,a.clipShadows=n.clipShadows,a.clippingPlanes=n.clippingPlanes,a.clipIntersection=n.clipIntersection,a.displacementMap=n.displacementMap,a.displacementScale=n.displacementScale,a.displacementBias=n.displacementBias,a.wireframeLinewidth=n.wireframeLinewidth,a.linewidth=n.linewidth,r.isPointLight===!0&&a.isMeshDistanceMaterial===!0){let t=e.properties.get(a);t.light=r}return a}function b(n,i,a,o,s){if(n.visible===!1)return;if(n.layers.test(i.layers)&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&s===3)&&(!n.frustumCulled||r.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse,n.matrixWorld);let r=t.update(n),c=n.material;if(Array.isArray(c)){let t=r.groups;for(let l=0,u=t.length;l=2):(F=parseFloat(/^WebGL (\d)/.exec(I)[1]),P=F>=1);let L=null,R={},z=e.getParameter(e.SCISSOR_BOX),B=e.getParameter(e.VIEWPORT),V=new xb().fromArray(z),ee=new xb().fromArray(B);function te(t,n,i,a){let o=new Uint8Array(4),s=e.createTexture();e.bindTexture(t,s),e.texParameteri(t,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(t,e.TEXTURE_MAG_FILTER,e.NEAREST);for(let s=0;s`u`?!1:/OculusBrowser/g.test(navigator.userAgent),m=new WeakMap,h,g=new WeakMap,_=!1;try{_=typeof OffscreenCanvas<`u`&&new OffscreenCanvas(1,1).getContext(`2d`)!==null}catch{}function v(e,t){return _?new OffscreenCanvas(e,t):sb(`canvas`)}function y(e,t,n,r){let i=1;if((e.width>r||e.height>r)&&(i=r/Math.max(e.width,e.height)),i<1||t===!0)if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap){let r=t?$y:Math.floor,a=r(i*e.width),o=r(i*e.height);h===void 0&&(h=v(a,o));let s=n?v(a,o):h;return s.width=a,s.height=o,s.getContext(`2d`).drawImage(e,0,0,a,o),console.warn(`THREE.WebGLRenderer: Texture has been resized from (`+e.width+`x`+e.height+`) to (`+a+`x`+o+`).`),s}else return`data`in e&&console.warn(`THREE.WebGLRenderer: Image in DataTexture is too big (`+e.width+`x`+e.height+`).`),e;return e}function b(e){return Qy(e.width)&&Qy(e.height)}function x(e){return s?!1:e.wrapS!==1001||e.wrapT!==1001||e.minFilter!==1003&&e.minFilter!==1006}function S(e,t){return e.generateMipmaps&&t&&e.minFilter!==1003&&e.minFilter!==1006}function C(t){e.generateMipmap(t)}function w(n,r,i,a,o=!1){if(s===!1)return r;if(n!==null){if(e[n]!==void 0)return e[n];console.warn(`THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '`+n+`'`)}let c=r;if(r===e.RED&&(i===e.FLOAT&&(c=e.R32F),i===e.HALF_FLOAT&&(c=e.R16F),i===e.UNSIGNED_BYTE&&(c=e.R8)),r===e.RED_INTEGER&&(i===e.UNSIGNED_BYTE&&(c=e.R8UI),i===e.UNSIGNED_SHORT&&(c=e.R16UI),i===e.UNSIGNED_INT&&(c=e.R32UI),i===e.BYTE&&(c=e.R8I),i===e.SHORT&&(c=e.R16I),i===e.INT&&(c=e.R32I)),r===e.RG&&(i===e.FLOAT&&(c=e.RG32F),i===e.HALF_FLOAT&&(c=e.RG16F),i===e.UNSIGNED_BYTE&&(c=e.RG8)),r===e.RGBA){let t=o?Ly:pb.getTransfer(a);i===e.FLOAT&&(c=e.RGBA32F),i===e.HALF_FLOAT&&(c=e.RGBA16F),i===e.UNSIGNED_BYTE&&(c=t===`srgb`?e.SRGB8_ALPHA8:e.RGBA8),i===e.UNSIGNED_SHORT_4_4_4_4&&(c=e.RGBA4),i===e.UNSIGNED_SHORT_5_5_5_1&&(c=e.RGB5_A1)}return(c===e.R16F||c===e.R32F||c===e.RG16F||c===e.RG32F||c===e.RGBA16F||c===e.RGBA32F)&&t.get(`EXT_color_buffer_float`),c}function T(e,t,n){return S(e,n)===!0||e.isFramebufferTexture&&e.minFilter!==1003&&e.minFilter!==1006?Math.log2(Math.max(t.width,t.height))+1:e.mipmaps!==void 0&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function E(t){return t===1003||t===1004||t===1005?e.NEAREST:e.LINEAR}function D(e){let t=e.target;t.removeEventListener(`dispose`,D),k(t),t.isVideoTexture&&m.delete(t)}function O(e){let t=e.target;t.removeEventListener(`dispose`,O),j(t)}function k(e){let t=r.get(e);if(t.__webglInit===void 0)return;let n=e.source,i=g.get(n);if(i){let r=i[t.__cacheKey];r.usedTimes--,r.usedTimes===0&&A(e),Object.keys(i).length===0&&g.delete(n)}r.remove(e)}function A(t){let n=r.get(t);e.deleteTexture(n.__webglTexture);let i=t.source,a=g.get(i);delete a[n.__cacheKey],o.memory.textures--}function j(t){let n=t.texture,i=r.get(t),a=r.get(n);if(a.__webglTexture!==void 0&&(e.deleteTexture(a.__webglTexture),o.memory.textures--),t.depthTexture&&t.depthTexture.dispose(),t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++){if(Array.isArray(i.__webglFramebuffer[t]))for(let n=0;n=c&&console.warn(`THREE.WebGLTextures: Trying to use `+e+` texture units while this GPU supports only `+c),M+=1,e}function F(e){let t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.colorSpace),t.join()}function I(t,i){let a=r.get(t);if(t.isVideoTexture&&pe(t),t.isRenderTargetTexture===!1&&t.version>0&&a.__version!==t.version){let e=t.image;if(e===null)console.warn(`THREE.WebGLRenderer: Texture marked for update but no image data found.`);else if(e.complete===!1)console.warn(`THREE.WebGLRenderer: Texture marked for update but image is incomplete`);else{re(a,t,i);return}}n.bindTexture(e.TEXTURE_2D,a.__webglTexture,e.TEXTURE0+i)}function L(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){re(a,t,i);return}n.bindTexture(e.TEXTURE_2D_ARRAY,a.__webglTexture,e.TEXTURE0+i)}function R(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){re(a,t,i);return}n.bindTexture(e.TEXTURE_3D,a.__webglTexture,e.TEXTURE0+i)}function z(t,i){let a=r.get(t);if(t.version>0&&a.__version!==t.version){ie(a,t,i);return}n.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture,e.TEXTURE0+i)}let B={[fy]:e.REPEAT,[py]:e.CLAMP_TO_EDGE,[my]:e.MIRRORED_REPEAT},V={[hy]:e.NEAREST,[nae]:e.NEAREST_MIPMAP_NEAREST,[rae]:e.NEAREST_MIPMAP_LINEAR,[gy]:e.LINEAR,[iae]:e.LINEAR_MIPMAP_NEAREST,[_y]:e.LINEAR_MIPMAP_LINEAR},ee={512:e.NEVER,519:e.ALWAYS,513:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL};function te(n,a,o){if(o?(e.texParameteri(n,e.TEXTURE_WRAP_S,B[a.wrapS]),e.texParameteri(n,e.TEXTURE_WRAP_T,B[a.wrapT]),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,B[a.wrapR]),e.texParameteri(n,e.TEXTURE_MAG_FILTER,V[a.magFilter]),e.texParameteri(n,e.TEXTURE_MIN_FILTER,V[a.minFilter])):(e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),(n===e.TEXTURE_3D||n===e.TEXTURE_2D_ARRAY)&&e.texParameteri(n,e.TEXTURE_WRAP_R,e.CLAMP_TO_EDGE),(a.wrapS!==1001||a.wrapT!==1001)&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.`),e.texParameteri(n,e.TEXTURE_MAG_FILTER,E(a.magFilter)),e.texParameteri(n,e.TEXTURE_MIN_FILTER,E(a.minFilter)),a.minFilter!==1003&&a.minFilter!==1006&&console.warn(`THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.`)),a.compareFunction&&(e.texParameteri(n,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),e.texParameteri(n,e.TEXTURE_COMPARE_FUNC,ee[a.compareFunction])),t.has(`EXT_texture_filter_anisotropic`)===!0){let o=t.get(`EXT_texture_filter_anisotropic`);if(a.magFilter===1003||a.minFilter!==1005&&a.minFilter!==1008||a.type===1015&&t.has(`OES_texture_float_linear`)===!1||s===!1&&a.type===1016&&t.has(`OES_texture_half_float_linear`)===!1)return;(a.anisotropy>1||r.get(a).__currentAnisotropy)&&(e.texParameterf(n,o.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(a.anisotropy,i.getMaxAnisotropy())),r.get(a).__currentAnisotropy=a.anisotropy)}}function ne(t,n){let r=!1;t.__webglInit===void 0&&(t.__webglInit=!0,n.addEventListener(`dispose`,D));let i=n.source,a=g.get(i);a===void 0&&(a={},g.set(i,a));let s=F(n);if(s!==t.__cacheKey){a[s]===void 0&&(a[s]={texture:e.createTexture(),usedTimes:0},o.memory.textures++,r=!0),a[s].usedTimes++;let i=a[t.__cacheKey];i!==void 0&&(a[t.__cacheKey].usedTimes--,i.usedTimes===0&&A(n)),t.__cacheKey=s,t.__webglTexture=a[s].texture}return r}function re(t,i,o){let c=e.TEXTURE_2D;(i.isDataArrayTexture||i.isCompressedArrayTexture)&&(c=e.TEXTURE_2D_ARRAY),i.isData3DTexture&&(c=e.TEXTURE_3D);let l=ne(t,i),d=i.source;n.bindTexture(c,t.__webglTexture,e.TEXTURE0+o);let f=r.get(d);if(d.version!==f.__version||l===!0){n.activeTexture(e.TEXTURE0+o);let t=pb.getPrimaries(pb.workingColorSpace),r=i.colorSpace===``?null:pb.getPrimaries(i.colorSpace),p=i.colorSpace===``||t===r?e.NONE:e.BROWSER_DEFAULT_WEBGL;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,i.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,i.premultiplyAlpha),e.pixelStorei(e.UNPACK_ALIGNMENT,i.unpackAlignment),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,p);let m=x(i)&&b(i.image)===!1,h=y(i.image,m,!1,u);h=me(i,h);let g=b(h)||s,_=a.convert(i.format,i.colorSpace),v=a.convert(i.type),E=w(i.internalFormat,_,v,i.colorSpace,i.isVideoTexture);te(c,i,g);let D,O=i.mipmaps,k=s&&i.isVideoTexture!==!0&&E!==36196,A=f.__version===void 0||l===!0,j=T(i,h,g);if(i.isDepthTexture)E=e.DEPTH_COMPONENT,s?E=i.type===1015?e.DEPTH_COMPONENT32F:i.type===1014?e.DEPTH_COMPONENT24:i.type===1020?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT16:i.type===1015&&console.error(`WebGLRenderer: Floating point depth texture requires WebGL2.`),i.format===1026&&E===e.DEPTH_COMPONENT&&i.type!==1012&&i.type!==1014&&(console.warn(`THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.`),i.type=yy,v=a.convert(i.type)),i.format===1027&&E===e.DEPTH_COMPONENT&&(E=e.DEPTH_STENCIL,i.type!==1020&&(console.warn(`THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.`),i.type=Sy,v=a.convert(i.type))),A&&(k?n.texStorage2D(e.TEXTURE_2D,1,E,h.width,h.height):n.texImage2D(e.TEXTURE_2D,0,E,h.width,h.height,0,_,v,null));else if(i.isDataTexture)if(O.length>0&&g){k&&A&&n.texStorage2D(e.TEXTURE_2D,j,E,O[0].width,O[0].height);for(let t=0,r=O.length;t>=1,r>>=1}}else if(O.length>0&&g){k&&A&&n.texStorage2D(e.TEXTURE_2D,j,E,O[0].width,O[0].height);for(let t=0,r=O.length;t0&&k++,n.texStorage2D(e.TEXTURE_CUBE_MAP,k,E,h[0].width,h[0].height));for(let t=0;t<6;t++)if(m){D?n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,h[t].width,h[t].height,v,x,h[t].data):n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,E,h[t].width,h[t].height,0,v,x,h[t].data);for(let r=0;r>l),r=Math.max(1,i.height>>l);c===e.TEXTURE_3D||c===e.TEXTURE_2D_ARRAY?n.texImage3D(c,l,p,t,r,i.depth,0,u,d,null):n.texImage2D(c,l,p,t,r,0,u,d,null)}n.bindFramebuffer(e.FRAMEBUFFER,t),fe(i)?f.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,0,de(i)):(c===e.TEXTURE_2D||c>=e.TEXTURE_CUBE_MAP_POSITIVE_X&&c<=e.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&e.framebufferTexture2D(e.FRAMEBUFFER,s,c,r.get(o).__webglTexture,l),n.bindFramebuffer(e.FRAMEBUFFER,null)}function ae(t,n,r){if(e.bindRenderbuffer(e.RENDERBUFFER,t),n.depthBuffer&&!n.stencilBuffer){let i=s===!0?e.DEPTH_COMPONENT24:e.DEPTH_COMPONENT16;if(r||fe(n)){let t=n.depthTexture;t&&t.isDepthTexture&&(t.type===1015?i=e.DEPTH_COMPONENT32F:t.type===1014&&(i=e.DEPTH_COMPONENT24));let r=de(n);fe(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,r,i,n.width,n.height):e.renderbufferStorageMultisample(e.RENDERBUFFER,r,i,n.width,n.height)}else e.renderbufferStorage(e.RENDERBUFFER,i,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t)}else if(n.depthBuffer&&n.stencilBuffer){let i=de(n);r&&fe(n)===!1?e.renderbufferStorageMultisample(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):fe(n)?f.renderbufferStorageMultisampleEXT(e.RENDERBUFFER,i,e.DEPTH24_STENCIL8,n.width,n.height):e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t)}else{let t=n.isWebGLMultipleRenderTargets===!0?n.texture:[n.texture];for(let i=0;i0){l.__webglFramebuffer[t]=[];for(let n=0;n0){l.__webglFramebuffer=[];for(let t=0;t0&&fe(t)===!1){let r=f?c:[c];l.__webglMultisampledFramebuffer=e.createFramebuffer(),l.__webglColorRenderbuffer=[],n.bindFramebuffer(e.FRAMEBUFFER,l.__webglMultisampledFramebuffer);for(let n=0;n0)for(let r=0;r0)for(let n=0;n0&&fe(t)===!1){let i=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],a=t.width,o=t.height,s=e.COLOR_BUFFER_BIT,c=[],l=t.stencilBuffer?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT,u=r.get(t),d=t.isWebGLMultipleRenderTargets===!0;if(d)for(let t=0;t0&&t.has(`WEBGL_multisampled_render_to_texture`)===!0&&n.__useRenderToTexture!==!1}function pe(e){let t=o.render.frame;m.get(e)!==t&&(m.set(e,t),e.update())}function me(e,n){let r=e.colorSpace,i=e.format,a=e.type;return e.isCompressedTexture===!0||e.isVideoTexture===!0||e.format===1035||r!==`srgb-linear`&&r!==``&&(pb.getTransfer(r)===`srgb`?s===!1?t.has(`EXT_sRGB`)===!0&&i===1023?(e.format=cae,e.minFilter=gy,e.generateMipmaps=!1):n=_b.sRGBToLinear(n):(i!==1023||a!==1009)&&console.warn(`THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.`):console.error(`THREE.WebGLTextures: Unsupported texture color space:`,r)),n}this.allocateTextureUnit=P,this.resetTextureUnits=N,this.setTexture2D=I,this.setTexture2DArray=L,this.setTexture3D=R,this.setTextureCube=z,this.rebindTextures=se,this.setupRenderTarget=ce,this.updateRenderTargetMipmap=le,this.updateMultisampleRenderTarget=ue,this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=H,this.useMultisampledRTT=fe}function Gse(e,t,n){let r=n.isWebGL2;function i(n,i=``){let a,o=pb.getTransfer(i);if(n===1009)return e.UNSIGNED_BYTE;if(n===1017)return e.UNSIGNED_SHORT_4_4_4_4;if(n===1018)return e.UNSIGNED_SHORT_5_5_5_1;if(n===1010)return e.BYTE;if(n===1011)return e.SHORT;if(n===1012)return e.UNSIGNED_SHORT;if(n===1013)return e.INT;if(n===1014)return e.UNSIGNED_INT;if(n===1015)return e.FLOAT;if(n===1016)return r?e.HALF_FLOAT:(a=t.get(`OES_texture_half_float`),a===null?null:a.HALF_FLOAT_OES);if(n===1021)return e.ALPHA;if(n===1023)return e.RGBA;if(n===1024)return e.LUMINANCE;if(n===1025)return e.LUMINANCE_ALPHA;if(n===1026)return e.DEPTH_COMPONENT;if(n===1027)return e.DEPTH_STENCIL;if(n===1035)return a=t.get(`EXT_sRGB`),a===null?null:a.SRGB_ALPHA_EXT;if(n===1028)return e.RED;if(n===1029)return e.RED_INTEGER;if(n===1030)return e.RG;if(n===1031)return e.RG_INTEGER;if(n===1033)return e.RGBA_INTEGER;if(n===33776||n===33777||n===33778||n===33779)if(o===`srgb`)if(a=t.get(`WEBGL_compressed_texture_s3tc_srgb`),a!==null){if(n===33776)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===33777)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===33778)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===33779)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=t.get(`WEBGL_compressed_texture_s3tc`),a!==null){if(n===33776)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===33777)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===33778)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===33779)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===35840||n===35841||n===35842||n===35843)if(a=t.get(`WEBGL_compressed_texture_pvrtc`),a!==null){if(n===35840)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===35841)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===35842)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===35843)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===36196)return a=t.get(`WEBGL_compressed_texture_etc1`),a===null?null:a.COMPRESSED_RGB_ETC1_WEBGL;if(n===37492||n===37496)if(a=t.get(`WEBGL_compressed_texture_etc`),a!==null){if(n===37492)return o===`srgb`?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(n===37496)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===37808||n===37809||n===37810||n===37811||n===37812||n===37813||n===37814||n===37815||n===37816||n===37817||n===37818||n===37819||n===37820||n===37821)if(a=t.get(`WEBGL_compressed_texture_astc`),a!==null){if(n===37808)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===37809)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===37810)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===37811)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===37812)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===37813)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===37814)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===37815)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===37816)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===37817)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===37818)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===37819)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===37820)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===37821)return o===`srgb`?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===36492||n===36494||n===36495)if(a=t.get(`EXT_texture_compression_bptc`),a!==null){if(n===36492)return o===`srgb`?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===36494)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===36495)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===36283||n===36284||n===36285||n===36286)if(a=t.get(`EXT_texture_compression_rgtc`),a!==null){if(n===36492)return a.COMPRESSED_RED_RGTC1_EXT;if(n===36284)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===36285)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===36286)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===1020?r?e.UNSIGNED_INT_24_8:(a=t.get(`WEBGL_depth_texture`),a===null?null:a.UNSIGNED_INT_24_8_WEBGL):e[n]===void 0?null:e[n]}return{convert:i}}var Kse=class extends CS{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}},kC=class extends vx{constructor(){super(),this.isGroup=!0,this.type=`Group`}},qse={type:`move`},AC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new kC,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new kC,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Tb,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Tb),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new kC,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Tb,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Tb),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){let t=this._hand;if(t)for(let n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:`connected`,data:e}),this}disconnect(e){return this.dispatchEvent({type:`disconnected`,data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,i=null,a=null,o=this._targetRay,s=this._grip,c=this._hand;if(e&&t.session.visibilityState!==`visible-blurred`){if(c&&e.hand){a=!0;for(let r of e.hand.values()){let e=t.getJointPose(r,n),i=this._getHandJoint(c,r);e!==null&&(i.matrix.fromArray(e.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),i.matrixWorldNeedsUpdate=!0,i.jointRadius=e.radius),i.visible=e!==null}let r=c.joints[`index-finger-tip`],i=c.joints[`thumb-tip`],o=r.position.distanceTo(i.position);c.inputState.pinching&&o>.025?(c.inputState.pinching=!1,this.dispatchEvent({type:`pinchend`,handedness:e.handedness,target:this})):!c.inputState.pinching&&o<=.015&&(c.inputState.pinching=!0,this.dispatchEvent({type:`pinchstart`,handedness:e.handedness,target:this}))}else s!==null&&e.gripSpace&&(i=t.getPose(e.gripSpace,n),i!==null&&(s.matrix.fromArray(i.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),s.matrixWorldNeedsUpdate=!0,i.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(i.linearVelocity)):s.hasLinearVelocity=!1,i.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(i.angularVelocity)):s.hasAngularVelocity=!1));o!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&i!==null&&(r=i),r!==null&&(o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,r.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(r.linearVelocity)):o.hasLinearVelocity=!1,r.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(r.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(qse)))}return o!==null&&(o.visible=r!==null),s!==null&&(s.visible=i!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){let n=new kC;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}},Jse=class extends Uy{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,l=null,u=null,d=null,f=null,p=null,m=t.getContextAttributes(),h=null,g=null,_=[],v=[],y=new rb,b=null,x=new CS;x.layers.enable(1),x.viewport=new xb;let S=new CS;S.layers.enable(2),S.viewport=new xb;let C=[x,S],w=new Kse;w.layers.enable(1),w.layers.enable(2);let T=null,E=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=_[e];return t===void 0&&(t=new AC,_[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=_[e];return t===void 0&&(t=new AC,_[e]=t),t.getGripSpace()},this.getHand=function(e){let t=_[e];return t===void 0&&(t=new AC,_[e]=t),t.getHandSpace()};function D(e){let t=v.indexOf(e.inputSource);if(t===-1)return;let n=_[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function O(){r.removeEventListener(`select`,D),r.removeEventListener(`selectstart`,D),r.removeEventListener(`selectend`,D),r.removeEventListener(`squeeze`,D),r.removeEventListener(`squeezestart`,D),r.removeEventListener(`squeezeend`,D),r.removeEventListener(`end`,O),r.removeEventListener(`inputsourceschange`,k);for(let e=0;e<_.length;e++){let t=v[e];t!==null&&(v[e]=null,_[e].disconnect(t))}T=null,E=null,e.setRenderTarget(h),f=null,d=null,u=null,r=null,g=null,L.stop(),n.isPresenting=!1,e.setPixelRatio(b),e.setSize(y.width,y.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return d===null?f:d},this.getBinding=function(){return u},this.getFrame=function(){return p},this.getSession=function(){return r},this.setSession=async function(l){if(r=l,r!==null){if(h=e.getRenderTarget(),r.addEventListener(`select`,D),r.addEventListener(`selectstart`,D),r.addEventListener(`selectend`,D),r.addEventListener(`squeeze`,D),r.addEventListener(`squeezestart`,D),r.addEventListener(`squeezeend`,D),r.addEventListener(`end`,O),r.addEventListener(`inputsourceschange`,k),m.xrCompatible!==!0&&await t.makeXRCompatible(),b=e.getPixelRatio(),e.getSize(y),r.renderState.layers===void 0||e.capabilities.isWebGL2===!1){let n={antialias:r.renderState.layers===void 0?m.antialias:!0,alpha:!0,depth:m.depth,stencil:m.stencil,framebufferScaleFactor:i};f=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:f}),e.setPixelRatio(1),e.setSize(f.framebufferWidth,f.framebufferHeight,!1),g=new Sb(f.framebufferWidth,f.framebufferHeight,{format:Cy,type:vy,colorSpace:e.outputColorSpace,stencilBuffer:m.stencil})}else{let n=null,a=null,o=null;m.depth&&(o=m.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=m.stencil?aae:wy,a=m.stencil?Sy:yy);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};u=new XRWebGLBinding(r,t),d=u.createProjectionLayer(s),r.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),g=new Sb(d.textureWidth,d.textureHeight,{format:Cy,type:vy,depthTexture:new eC(d.textureWidth,d.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:m.stencil,colorSpace:e.outputColorSpace,samples:m.antialias?4:0});let c=e.properties.get(g);c.__ignoreDepthValues=d.ignoreDepthValues}g.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),L.setContext(r),L.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode};function k(e){for(let t=0;t=0&&(v[r]=null,_[r].disconnect(n))}for(let t=0;t=v.length){v.push(n),r=e;break}else if(v[e]===null){v[e]=n,r=e;break}if(r===-1)break}let i=_[r];i&&i.connect(n)}}let A=new Tb,j=new Tb;function M(e,t,n){A.setFromMatrixPosition(t.matrixWorld),j.setFromMatrixPosition(n.matrixWorld);let r=A.distanceTo(j),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();let g=o+m,_=s+m,v=f-h,y=p+(r-h),b=c*s/_*g,x=l*s/_*g;e.projectionMatrix.makePerspective(v,y,b,x,g,_),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}function N(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;w.near=S.near=x.near=e.near,w.far=S.far=x.far=e.far,(T!==w.near||E!==w.far)&&(r.updateRenderState({depthNear:w.near,depthFar:w.far}),T=w.near,E=w.far);let t=e.parent,n=w.cameras;N(w,t);for(let e=0;e0&&(r.alphaTest.value=i.alphaTest);let a=t.get(i).envMap;if(a&&(r.envMap.value=a,r.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,r.reflectivity.value=i.reflectivity,r.ior.value=i.ior,r.refractionRatio.value=i.refractionRatio),i.lightMap){r.lightMap.value=i.lightMap;let t=e._useLegacyLights===!0?Math.PI:1;r.lightMapIntensity.value=i.lightMapIntensity*t,n(i.lightMap,r.lightMapTransform)}i.aoMap&&(r.aoMap.value=i.aoMap,r.aoMapIntensity.value=i.aoMapIntensity,n(i.aoMap,r.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,r){e.metalness.value=r.metalness,r.metalnessMap&&(e.metalnessMap.value=r.metalnessMap,n(r.metalnessMap,e.metalnessMapTransform)),e.roughness.value=r.roughness,r.roughnessMap&&(e.roughnessMap.value=r.roughnessMap,n(r.roughnessMap,e.roughnessMapTransform)),t.get(r).envMap&&(e.envMapIntensity.value=r.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function Xse(e,t,n,r){let i={},a={},o=[],s=n.isWebGL2?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e0){r=n%16;let e=16-r;r!==0&&e-a.boundary<0&&(n+=16-r,i.__offset=n)}n+=a.storage}return r=n%16,r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var jC=class{constructor(e={}){let{canvas:t=wae(),context:n=null,depth:r=!0,stencil:i=!0,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:c=!1,powerPreference:l=`default`,failIfMajorPerformanceCaveat:u=!1}=e;this.isWebGLRenderer=!0;let d;d=n===null?a:n.getContextAttributes().alpha;let f=new Uint32Array(4),p=new Int32Array(4),m=null,h=null,g=[],_=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Ny,this._useLegacyLights=!1,this.toneMapping=0,this.toneMappingExposure=1;let v=this,y=!1,b=0,x=0,S=null,C=-1,w=null,T=new xb,E=new xb,D=null,O=new Fx(0),k=0,A=t.width,j=t.height,M=1,N=null,P=null,F=new xb(0,0,A,j),I=new xb(0,0,A,j),L=!1,R=new jS,z=!1,B=!1,V=null,ee=new ex,te=new rb,ne=new Tb,re={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function ie(){return S===null?M:1}let H=n;function ae(e,n){for(let r=0;r{function n(){if(r.forEach(function(e){le.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}oe.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Re=null;function ze(e){Re&&Re(e)}function Be(){He.stop()}function Ve(){He.start()}let He=new MS;He.setAnimationLoop(ze),typeof self<`u`&&He.setContext(self),this.setAnimationLoop=function(e){Re=e,Ae.setAnimationLoop(e),e===null?He.stop():He.start()},Ae.addEventListener(`sessionstart`,Be),Ae.addEventListener(`sessionend`,Ve),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(y===!0)return;e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),Ae.enabled===!0&&Ae.isPresenting===!0&&(Ae.cameraAutoUpdate===!0&&Ae.updateCamera(t),t=Ae.getCamera()),e.isScene===!0&&e.onBeforeRender(v,e,t,S),h=ye.get(e,_.length),h.init(),_.push(h),ee.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),R.setFromProjectionMatrix(ee),B=this.localClippingEnabled,z=be.init(this.clippingPlanes,B),m=ve.get(e,g.length),m.init(),g.push(m),Ue(e,t,0,v.sortObjects),m.finish(),v.sortObjects===!0&&m.sort(N,P),this.info.render.frame++,z===!0&&be.beginShadows();let n=h.state.shadowsArray;if(xe.render(n,e,t),z===!0&&be.endShadows(),this.info.autoReset===!0&&this.info.reset(),Se.render(m,e),h.setupLights(v._useLegacyLights),t.isArrayCamera){let n=t.cameras;for(let t=0,r=n.length;t0?_[_.length-1]:null,g.pop(),m=g.length>0?g[g.length-1]:null};function Ue(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)h.pushLight(e),e.castShadow&&h.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||R.intersectsSprite(e)){r&&ne.setFromMatrixPosition(e.matrixWorld).applyMatrix4(ee);let t=he.update(e),i=e.material;i.visible&&m.push(e,t,i,n,ne.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||R.intersectsObject(e))){let t=he.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),ne.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),ne.copy(e.boundingSphere.center)),ne.applyMatrix4(e.matrixWorld).applyMatrix4(ee)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a0&&Ge(i,a,t,n),r&&se.viewport(T.copy(r)),i.length>0&&Ke(i,t,n),a.length>0&&Ke(a,t,n),o.length>0&&Ke(o,t,n),se.buffers.depth.setTest(!0),se.buffers.depth.setMask(!0),se.buffers.color.setMask(!0),se.setPolygonOffset(!1)}function Ge(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;let i=U.isWebGL2;V===null&&(V=new Sb(1,1,{generateMipmaps:!0,type:oe.has(`EXT_color_buffer_half_float`)?xy:vy,minFilter:_y,samples:i?4:0})),v.getDrawingBufferSize(te),i?V.setSize(te.x,te.y):V.setSize($y(te.x),$y(te.y));let a=v.getRenderTarget();v.setRenderTarget(V),v.getClearColor(O),k=v.getClearAlpha(),k<1&&v.setClearColor(16777215,.5),v.clear();let o=v.toneMapping;v.toneMapping=0,Ke(e,n,r),ue.updateMultisampleRenderTarget(V),ue.updateRenderTargetMipmap(V);let s=!1;for(let e=0,i=t.length;e0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(S===null||S.isXRRenderTarget===!0)&&(m=v.toneMapping);let g=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,_=g===void 0?0:g.length,y=le.get(r),b=h.state.lights;if(z===!0&&(B===!0||e!==w)){let t=e===w&&r.id===C;be.setState(r,e,t)}let x=!1;r.version===y.__version?y.needsLights&&y.lightsStateVersion!==b.state.version?x=!0:y.outputColorSpace===s?i.isBatchedMesh&&y.batching===!1||!i.isBatchedMesh&&y.batching===!0||i.isInstancedMesh&&y.instancing===!1||!i.isInstancedMesh&&y.instancing===!0||i.isSkinnedMesh&&y.skinning===!1||!i.isSkinnedMesh&&y.skinning===!0||i.isInstancedMesh&&y.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&y.instancingColor===!1&&i.instanceColor!==null?x=!0:y.envMap===c?r.fog===!0&&y.fog!==a||y.numClippingPlanes!==void 0&&(y.numClippingPlanes!==be.numPlanes||y.numIntersection!==be.numIntersection)?x=!0:y.vertexAlphas===l&&y.vertexTangents===u&&y.morphTargets===d&&y.morphNormals===f&&y.morphColors===p&&y.toneMapping===m?U.isWebGL2===!0&&y.morphTargetsCount!==_&&(x=!0):x=!0:x=!0:x=!0:(x=!0,y.__version=r.version);let T=y.currentProgram;x===!0&&(T=Je(r,t,i));let E=!1,D=!1,O=!1,k=T.getUniforms(),A=y.uniforms;if(se.useProgram(T.program)&&(E=!0,D=!0,O=!0),r.id!==C&&(C=r.id,D=!0),E||w!==e){k.setValue(H,`projectionMatrix`,e.projectionMatrix),k.setValue(H,`viewMatrix`,e.matrixWorldInverse);let t=k.map.cameraPosition;t!==void 0&&t.setValue(H,ne.setFromMatrixPosition(e.matrixWorld)),U.logarithmicDepthBuffer&&k.setValue(H,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&k.setValue(H,`isOrthographic`,e.isOrthographicCamera===!0),w!==e&&(w=e,D=!0,O=!0)}if(i.isSkinnedMesh){k.setOptional(H,i,`bindMatrix`),k.setOptional(H,i,`bindMatrixInverse`);let e=i.skeleton;e&&(U.floatVertexTextures?(e.boneTexture===null&&e.computeBoneTexture(),k.setValue(H,`boneTexture`,e.boneTexture,ue)):console.warn(`THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required.`))}i.isBatchedMesh&&(k.setOptional(H,i,`batchingTexture`),k.setValue(H,`batchingTexture`,i._matricesTexture,ue));let N=n.morphAttributes;if((N.position!==void 0||N.normal!==void 0||N.color!==void 0&&U.isWebGL2===!0)&&Ce.update(i,n,T),(D||y.receiveShadow!==i.receiveShadow)&&(y.receiveShadow=i.receiveShadow,k.setValue(H,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(A.envMap.value=c,A.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),D&&(k.setValue(H,`toneMappingExposure`,v.toneMappingExposure),y.needsLights&&Qe(A,O),a&&r.fog===!0&&_e.refreshFogUniforms(A,a),_e.refreshMaterialUniforms(A,r,M,j,V),_C.upload(H,Ye(y),A,ue)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(_C.upload(H,Ye(y),A,ue),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&k.setValue(H,`center`,i.center),k.setValue(H,`modelViewMatrix`,i.modelViewMatrix),k.setValue(H,`normalMatrix`,i.normalMatrix),k.setValue(H,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t0&&ue.useMultisampledRTT(e)===!1?le.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,T.copy(e.viewport),E.copy(e.scissor),D=e.scissorTest}else T.copy(F).multiplyScalar(M).floor(),E.copy(I).multiplyScalar(M).floor(),D=L;if(se.bindFramebuffer(H.FRAMEBUFFER,i)&&U.drawBuffers&&r&&se.drawBuffers(e,i),se.viewport(T),se.scissor(E),se.setScissorTest(D),a){let r=le.get(e.texture);H.framebufferTexture2D(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,H.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=le.get(e.texture),i=t||0;H.framebufferTextureLayer(H.FRAMEBUFFER,H.COLOR_ATTACHMENT0,r.__webglTexture,n||0,i)}C=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let s=le.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(s=s[o]),s){se.bindFramebuffer(H.FRAMEBUFFER,s);try{let o=e.texture,s=o.format,c=o.type;if(s!==1023&&Ee.convert(s)!==H.getParameter(H.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}let l=c===1016&&(oe.has(`EXT_color_buffer_half_float`)||U.isWebGL2&&oe.has(`EXT_color_buffer_float`));if(c!==1009&&Ee.convert(c)!==H.getParameter(H.IMPLEMENTATION_COLOR_READ_TYPE)&&!(c===1015&&(U.isWebGL2||oe.has(`OES_texture_float`)||oe.has(`WEBGL_color_buffer_float`)))&&!l){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&H.readPixels(t,n,r,i,Ee.convert(s),Ee.convert(c),a)}finally{let e=S===null?null:le.get(S).__webglFramebuffer;se.bindFramebuffer(H.FRAMEBUFFER,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){let r=2**-n,i=Math.floor(t.image.width*r),a=Math.floor(t.image.height*r);ue.setTexture2D(t,0),H.copyTexSubImage2D(H.TEXTURE_2D,n,0,0,e.x,e.y,i,a),se.unbindTexture()},this.copyTextureToTexture=function(e,t,n,r=0){let i=t.image.width,a=t.image.height,o=Ee.convert(n.format),s=Ee.convert(n.type);ue.setTexture2D(n,0),H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,n.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,n.unpackAlignment),t.isDataTexture?H.texSubImage2D(H.TEXTURE_2D,r,e.x,e.y,i,a,o,s,t.image.data):t.isCompressedTexture?H.compressedTexSubImage2D(H.TEXTURE_2D,r,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,o,t.mipmaps[0].data):H.texSubImage2D(H.TEXTURE_2D,r,e.x,e.y,o,s,t.image),r===0&&n.generateMipmaps&&H.generateMipmap(H.TEXTURE_2D),se.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,r,i=0){if(v.isWebGL1Renderer){console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.`);return}let a=e.max.x-e.min.x+1,o=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,c=Ee.convert(r.format),l=Ee.convert(r.type),u;if(r.isData3DTexture)ue.setTexture3D(r,0),u=H.TEXTURE_3D;else if(r.isDataArrayTexture)ue.setTexture2DArray(r,0),u=H.TEXTURE_2D_ARRAY;else{console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.`);return}H.pixelStorei(H.UNPACK_FLIP_Y_WEBGL,r.flipY),H.pixelStorei(H.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r.premultiplyAlpha),H.pixelStorei(H.UNPACK_ALIGNMENT,r.unpackAlignment);let d=H.getParameter(H.UNPACK_ROW_LENGTH),f=H.getParameter(H.UNPACK_IMAGE_HEIGHT),p=H.getParameter(H.UNPACK_SKIP_PIXELS),m=H.getParameter(H.UNPACK_SKIP_ROWS),h=H.getParameter(H.UNPACK_SKIP_IMAGES),g=n.isCompressedTexture?n.mipmaps[0]:n.image;H.pixelStorei(H.UNPACK_ROW_LENGTH,g.width),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,g.height),H.pixelStorei(H.UNPACK_SKIP_PIXELS,e.min.x),H.pixelStorei(H.UNPACK_SKIP_ROWS,e.min.y),H.pixelStorei(H.UNPACK_SKIP_IMAGES,e.min.z),n.isDataTexture||n.isData3DTexture?H.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g.data):n.isCompressedArrayTexture?(console.warn(`THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture.`),H.compressedTexSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,g.data)):H.texSubImage3D(u,i,t.x,t.y,t.z,a,o,s,c,l,g),H.pixelStorei(H.UNPACK_ROW_LENGTH,d),H.pixelStorei(H.UNPACK_IMAGE_HEIGHT,f),H.pixelStorei(H.UNPACK_SKIP_PIXELS,p),H.pixelStorei(H.UNPACK_SKIP_ROWS,m),H.pixelStorei(H.UNPACK_SKIP_IMAGES,h),i===0&&r.generateMipmaps&&H.generateMipmap(u),se.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?ue.setTextureCube(e,0):e.isData3DTexture?ue.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?ue.setTexture2DArray(e,0):ue.setTexture2D(e,0),se.unbindTexture()},this.resetState=function(){b=0,x=0,S=null,se.reset(),De.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Hy}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=e===`display-p3`?`display-p3`:`srgb`,t.unpackColorSpace=pb.workingColorSpace===`display-p3-linear`?`display-p3`:`srgb`}get physicallyCorrectLights(){return console.warn(`THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.`),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn(`THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead.`),this.useLegacyLights=!e}get outputEncoding(){return console.warn(`THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.`),this.outputColorSpace===`srgb`?My:jy}set outputEncoding(e){console.warn(`THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead.`),this.outputColorSpace=e===3001?Ny:Py}get useLegacyLights(){return console.warn(`THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.`),this._useLegacyLights}set useLegacyLights(e){console.warn(`THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733.`),this._useLegacyLights=e}},Zse=class extends jC{};Zse.prototype.isWebGL1Renderer=!0;var Qse=class e{constructor(e,t=1,n=1e3){this.isFog=!0,this.name=``,this.color=new Fx(e),this.near=t,this.far=n}clone(){return new e(this.color,this.near,this.far)}toJSON(){return{type:`Fog`,name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}},$se=class extends vx{constructor(){super(),this.isScene=!0,this.type=`Scene`,this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){let t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t}},ece=class{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e===void 0?0:e.length/t,this.usage=Vy,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Jy()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn(`THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.`),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,i=this.stride;r=n.length&&n.push({start:-1,count:-1,z:-1});let i=n[this.index];r.push(i),this.index++,i.start=e.start,i.count=e.count,i.z=t}reset(){this.list.length=0,this.index=0}},PC=`batchId`,FC=new ex,ace=new ex,oce=new ex,sce=new ex,IC=new jS,LC=new Ob,RC=new Gb,zC=new Tb,BC=new ice,VC=new mS,HC=[];function cce(e,t,n=0){let r=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){let i=e.count;for(let a=0;a65536?new Uint32Array(i):new Uint16Array(i);t.setIndex(new Bx(e,1))}let a=r>65536?new Uint32Array(n):new Uint16Array(n);t.setAttribute(PC,new Bx(a,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(PC))throw Error(`BatchedMesh: Geometry cannot use attribute "${PC}"`);let t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw Error(`BatchedMesh: All geometries must consistently have "index".`);for(let n in t.attributes){if(n===PC)continue;if(!e.hasAttribute(n))throw Error(`BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);let r=e.getAttribute(n),i=t.getAttribute(n);if(r.itemSize!==i.itemSize||r.normalized!==i.normalized)throw Error(`BatchedMesh: All attributes must have a consistent itemSize and normalized value.`)}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ob);let e=this._geometryCount,t=this.boundingBox,n=this._active;t.makeEmpty();for(let r=0;r=this._maxGeometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);let r={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1},i=null,a=this._reservedRanges,o=this._drawRanges,s=this._bounds;this._geometryCount!==0&&(i=a[a.length-1]),t===-1?r.vertexCount=e.getAttribute(`position`).count:r.vertexCount=t,i===null?r.vertexStart=0:r.vertexStart=i.vertexStart+i.vertexCount;let c=e.getIndex(),l=c!==null;if(l&&(n===-1?r.indexCount=c.count:r.indexCount=n,i===null?r.indexStart=0:r.indexStart=i.indexStart+i.indexCount),r.indexStart!==-1&&r.indexStart+r.indexCount>this._maxIndexCount||r.vertexStart+r.vertexCount>this._maxVertexCount)throw Error(`BatchedMesh: Reserved space request exceeds the maximum buffer size.`);let u=this._visibility,d=this._active,f=this._matricesTexture,p=this._matricesTexture.image.data;u.push(!0),d.push(!0);let m=this._geometryCount;this._geometryCount++,oce.toArray(p,m*16),f.needsUpdate=!0,a.push(r),o.push({start:l?r.indexStart:r.vertexStart,count:-1}),s.push({boxInitialized:!1,box:new Ob,sphereInitialized:!1,sphere:new Gb});let h=this.geometry.getAttribute(PC);for(let e=0;e=this._geometryCount)throw Error(`BatchedMesh: Maximum geometry count reached.`);this._validateGeometry(t);let n=this.geometry,r=n.getIndex()!==null,i=n.getIndex(),a=t.getIndex(),o=this._reservedRanges[e];if(r&&a.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw Error(`BatchedMesh: Reserved space not large enough for provided geometry.`);let s=o.vertexStart,c=o.vertexCount;for(let e in n.attributes){if(e===PC)continue;let r=t.getAttribute(e),i=n.getAttribute(e);cce(r,i,s);let a=r.itemSize;for(let e=r.count,t=c;e=t.length||t[e]===!1?this:(t[e]=!1,this._visibilityChanged=!0,this)}getBoundingBoxAt(e,t){if(this._active[e]===!1)return this;let n=this._bounds[e],r=n.box,i=this.geometry;if(n.boxInitialized===!1){r.makeEmpty();let t=i.index,a=i.attributes.position,o=this._drawRanges[e];for(let e=o.start,n=o.start+o.count;e=this._geometryCount||n[e]===!1?this:(t.toArray(i,e*16),r.needsUpdate=!0,this)}getMatrixAt(e,t){let n=this._active,r=this._matricesTexture.image.data;return e>=this._geometryCount||n[e]===!1?null:t.fromArray(r,e*16)}setVisibleAt(e,t){let n=this._visibility,r=this._active;return e>=this._geometryCount||r[e]===!1||n[e]===t?this:(n[e]=t,this._visibilityChanged=!0,this)}getVisibleAt(e){let t=this._visibility,n=this._active;return e>=this._geometryCount||n[e]===!1?!1:t[e]}raycast(e,t){let n=this._visibility,r=this._active,i=this._drawRanges,a=this._geometryCount,o=this.matrixWorld,s=this.geometry;VC.material=this.material,VC.geometry.index=s.index,VC.geometry.attributes=s.attributes,VC.geometry.boundingBox===null&&(VC.geometry.boundingBox=new Ob),VC.geometry.boundingSphere===null&&(VC.geometry.boundingSphere=new Gb);for(let s=0;s({...e})),this._reservedRanges=e._reservedRanges.map(e=>({...e})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,t,n,r,i){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;let a=r.getIndex(),o=a===null?1:a.array.BYTES_PER_ELEMENT,s=this._visibility,c=this._multiDrawStarts,l=this._multiDrawCounts,u=this._drawRanges,d=this.perObjectFrustumCulled;d&&(sce.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),IC.setFromProjectionMatrix(sce,e.isWebGPURenderer?lae:Hy));let f=0;if(this.sortObjects){ace.copy(this.matrixWorld).invert(),zC.setFromMatrixPosition(n.matrixWorld).applyMatrix4(ace);for(let e=0,t=s.length;es)continue;d.applyMatrix4(this.matrixWorld);let a=e.ray.origin.distanceTo(d);ae.far||t.push({distance:a,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else{let n=Math.max(0,a.start),r=Math.min(m.count,a.start+a.count);for(let i=n,a=r-1;is)continue;d.applyMatrix4(this.matrixWorld);let n=e.ray.origin.distanceTo(d);ne.far||t.push({distance:n,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){let e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){let n=e[t[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e=i)){let o=t[1];e=i)break seek}a=n,n=0;break linear_scan}break validate_interval}for(;n>>1;et;)--a;if(++a,i!==0||a!==r){i>=a&&(a=Math.max(a,1),i=a-1);let e=this.getValueSize();this.times=n.slice(i,a),this.values=this.values.slice(i*e,a*e)}return this}validate(){let e=!0,t=this.getValueSize();t-Math.floor(t)!==0&&(console.error(`THREE.KeyframeTrack: Invalid value size in track.`,this),e=!1);let n=this.times,r=this.values,i=n.length;i===0&&(console.error(`THREE.KeyframeTrack: Track is empty.`,this),e=!1);let a=null;for(let t=0;t!==i;t++){let r=n[t];if(typeof r==`number`&&isNaN(r)){console.error(`THREE.KeyframeTrack: Time is not a valid number.`,this,t,r),e=!1;break}if(a!==null&&a>r){console.error(`THREE.KeyframeTrack: Out of order keys.`,this,t,r,a),e=!1;break}a=r}if(r!==void 0&&mce(r))for(let t=0,n=r.length;t!==n;++t){let n=r[t];if(isNaN(n)){console.error(`THREE.KeyframeTrack: Value is not a valid number.`,this,t,n),e=!1;break}}return e}optimize(){let e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===Dy,i=e.length-1,a=1;for(let o=1;o0){e[a]=e[i];for(let e=i*n,r=a*n,o=0;o!==n;++o)t[r+o]=t[e+o];++a}return a===e.length?(this.times=e,this.values=t):(this.times=e.slice(0,a),this.values=t.slice(0,a*n)),this}clone(){let e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}};tw.prototype.TimeBufferType=Float32Array,tw.prototype.ValueBufferType=Float32Array,tw.prototype.DefaultInterpolation=Ey;var nw=class extends tw{};nw.prototype.ValueTypeName=`bool`,nw.prototype.ValueBufferType=Array,nw.prototype.DefaultInterpolation=Ty,nw.prototype.InterpolantFactoryMethodLinear=void 0,nw.prototype.InterpolantFactoryMethodSmooth=void 0;var vce=class extends tw{};vce.prototype.ValueTypeName=`color`;var yce=class extends tw{};yce.prototype.ValueTypeName=`number`;var bce=class extends ew{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){let i=this.resultBuffer,a=this.sampleValues,o=this.valueSize,s=(n-t)/(r-t),c=e*o;for(let e=c+o;c!==e;c+=4)wb.slerpFlat(i,0,a,c-o,a,c,s);return i}},rw=class extends tw{InterpolantFactoryMethodLinear(e){return new bce(this.times,this.values,this.getValueSize(),e)}};rw.prototype.ValueTypeName=`quaternion`,rw.prototype.DefaultInterpolation=Ey,rw.prototype.InterpolantFactoryMethodSmooth=void 0;var iw=class extends tw{};iw.prototype.ValueTypeName=`string`,iw.prototype.ValueBufferType=Array,iw.prototype.DefaultInterpolation=Ty,iw.prototype.InterpolantFactoryMethodLinear=void 0,iw.prototype.InterpolantFactoryMethodSmooth=void 0;var xce=class extends tw{};xce.prototype.ValueTypeName=`vector`;var Sce=new class{constructor(e,t,n){let r=this,i=!1,a=0,o=0,s,c=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){o++,i===!1&&r.onStart!==void 0&&r.onStart(e,a,o),i=!0},this.itemEnd=function(e){a++,r.onProgress!==void 0&&r.onProgress(e,a,o),a===o&&(i=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(e){r.onError!==void 0&&r.onError(e)},this.resolveURL=function(e){return s?s(e):e},this.setURLModifier=function(e){return s=e,this},this.addHandler=function(e,t){return c.push(e,t),this},this.removeHandler=function(e){let t=c.indexOf(e);return t!==-1&&c.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=c.length;te.stopPropagation()),this.domElement.addEventListener(`keyup`,e=>e.stopPropagation()),this.parent.children.push(this),this.parent.controllers.push(this),this.parent.$children.appendChild(this.domElement),this._listenCallback=this._listenCallback.bind(this),this.name(r)}name(e){return this._name=e,this.$name.textContent=e,this}onChange(e){return this._onChange=e,this}_callOnChange(){this.parent._callOnChange(this),this._onChange!==void 0&&this._onChange.call(this,this.getValue()),this._changed=!0}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(){this._changed&&(this.parent._callOnFinishChange(this),this._onFinishChange!==void 0&&this._onFinishChange.call(this,this.getValue())),this._changed=!1}reset(){return this.setValue(this.initialValue),this._callOnFinishChange(),this}enable(e=!0){return this.disable(!e)}disable(e=!0){return e===this._disabled?this:(this._disabled=e,this.domElement.classList.toggle(`disabled`,e),this.$disable.toggleAttribute(`disabled`,e),this)}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?`none`:``,this}hide(){return this.show(!1)}options(e){let t=this.parent.add(this.object,this.property,e);return t.name(this._name),this.destroy(),t}min(e){return this}max(e){return this}step(e){return this}decimals(e){return this}listen(e=!0){return this._listening=e,this._listenCallbackID!==void 0&&(cancelAnimationFrame(this._listenCallbackID),this._listenCallbackID=void 0),this._listening&&this._listenCallback(),this}_listenCallback(){this._listenCallbackID=requestAnimationFrame(this._listenCallback);let e=this.save();e!==this._listenPrevValue&&this.updateDisplay(),this._listenPrevValue=e}getValue(){return this.object[this.property]}setValue(e){return this.getValue()!==e&&(this.object[this.property]=e,this._callOnChange(),this.updateDisplay()),this}updateDisplay(){return this}load(e){return this.setValue(e),this._callOnFinishChange(),this}save(){return this.getValue()}destroy(){this.listen(!1),this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.controllers.splice(this.parent.controllers.indexOf(this),1),this.parent.$children.removeChild(this.domElement)}},Vce=class extends vw{constructor(e,t,n){super(e,t,n,`boolean`,`label`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`checkbox`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$widget.appendChild(this.$input),this.$input.addEventListener(`change`,()=>{this.setValue(this.$input.checked),this._callOnFinishChange()}),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.checked=this.getValue(),this}};function yw(e){let t,n;return(t=e.match(/(#|0x)?([a-f0-9]{6})/i))?n=t[2]:(t=e.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/))?n=parseInt(t[1]).toString(16).padStart(2,0)+parseInt(t[2]).toString(16).padStart(2,0)+parseInt(t[3]).toString(16).padStart(2,0):(t=e.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i))&&(n=t[1]+t[1]+t[2]+t[2]+t[3]+t[3]),n?`#`+n:!1}var Hce={isPrimitive:!0,match:e=>typeof e==`string`,fromHexString:yw,toHexString:yw},bw={isPrimitive:!0,match:e=>typeof e==`number`,fromHexString:e=>parseInt(e.substring(1),16),toHexString:e=>`#`+e.toString(16).padStart(6,0)},Uce=[Hce,bw,{isPrimitive:!1,match:e=>Array.isArray(e),fromHexString(e,t,n=1){let r=bw.fromHexString(e);t[0]=(r>>16&255)/255*n,t[1]=(r>>8&255)/255*n,t[2]=(r&255)/255*n},toHexString([e,t,n],r=1){r=255/r;let i=e*r<<16^t*r<<8^n*r<<0;return bw.toHexString(i)}},{isPrimitive:!1,match:e=>Object(e)===e,fromHexString(e,t,n=1){let r=bw.fromHexString(e);t.r=(r>>16&255)/255*n,t.g=(r>>8&255)/255*n,t.b=(r&255)/255*n},toHexString({r:e,g:t,b:n},r=1){r=255/r;let i=e*r<<16^t*r<<8^n*r<<0;return bw.toHexString(i)}}];function Wce(e){return Uce.find(t=>t.match(e))}var Gce=class extends vw{constructor(e,t,n,r){super(e,t,n,`color`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`color`),this.$input.setAttribute(`tabindex`,-1),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$text=document.createElement(`input`),this.$text.setAttribute(`type`,`text`),this.$text.setAttribute(`spellcheck`,`false`),this.$text.setAttribute(`aria-labelledby`,this.$name.id),this.$display=document.createElement(`div`),this.$display.classList.add(`display`),this.$display.appendChild(this.$input),this.$widget.appendChild(this.$display),this.$widget.appendChild(this.$text),this._format=Wce(this.initialValue),this._rgbScale=r,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener(`input`,()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener(`blur`,()=>{this._callOnFinishChange()}),this.$text.addEventListener(`input`,()=>{let e=yw(this.$text.value);e&&this._setValueFromHexString(e)}),this.$text.addEventListener(`focus`,()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener(`blur`,()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){let t=this._format.fromHexString(e);this.setValue(t)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}},xw=class extends vw{constructor(e,t,n){super(e,t,n,`function`),this.$button=document.createElement(`button`),this.$button.appendChild(this.$name),this.$widget.appendChild(this.$button),this.$button.addEventListener(`click`,e=>{e.preventDefault(),this.getValue().call(this.object),this._callOnChange()}),this.$button.addEventListener(`touchstart`,()=>{},{passive:!0}),this.$disable=this.$button}},Kce=class extends vw{constructor(e,t,n,r,i,a){super(e,t,n,`number`),this._initInput(),this.min(r),this.max(i);let o=a!==void 0;this.step(o?a:this._getImplicitStep(),o),this.updateDisplay()}decimals(e){return this._decimals=e,this.updateDisplay(),this}min(e){return this._min=e,this._onUpdateMinMax(),this}max(e){return this._max=e,this._onUpdateMinMax(),this}step(e,t=!0){return this._step=e,this._stepExplicit=t,this}updateDisplay(){let e=this.getValue();if(this._hasSlider){let t=(e-this._min)/(this._max-this._min);t=Math.max(0,Math.min(t,1)),this.$fill.style.width=t*100+`%`}return this._inputFocused||(this.$input.value=this._decimals===void 0?e:e.toFixed(this._decimals)),this}_initInput(){this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`text`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),window.matchMedia(`(pointer: coarse)`).matches&&(this.$input.setAttribute(`type`,`number`),this.$input.setAttribute(`step`,`any`)),this.$widget.appendChild(this.$input),this.$disable=this.$input;let e=()=>{let e=parseFloat(this.$input.value);isNaN(e)||(this._stepExplicit&&(e=this._snap(e)),this.setValue(this._clamp(e)))},t=e=>{let t=parseFloat(this.$input.value);isNaN(t)||(this._snapClampSetValue(t+e),this.$input.value=this.getValue())},n=e=>{e.key===`Enter`&&this.$input.blur(),e.code===`ArrowUp`&&(e.preventDefault(),t(this._step*this._arrowKeyMultiplier(e))),e.code===`ArrowDown`&&(e.preventDefault(),t(this._step*this._arrowKeyMultiplier(e)*-1))},r=e=>{this._inputFocused&&(e.preventDefault(),t(this._step*this._normalizeMouseWheel(e)))},i=!1,a,o,s,c,l,u=e=>{a=e.clientX,o=s=e.clientY,i=!0,c=this.getValue(),l=0,window.addEventListener(`mousemove`,d),window.addEventListener(`mouseup`,f)},d=e=>{if(i){let t=e.clientX-a,n=e.clientY-o;Math.abs(n)>5?(e.preventDefault(),this.$input.blur(),i=!1,this._setDraggingStyle(!0,`vertical`)):Math.abs(t)>5&&f()}if(!i){let t=e.clientY-s;l-=t*this._step*this._arrowKeyMultiplier(e),c+l>this._max?l=this._max-c:c+l{this._setDraggingStyle(!1,`vertical`),this._callOnFinishChange(),window.removeEventListener(`mousemove`,d),window.removeEventListener(`mouseup`,f)};this.$input.addEventListener(`input`,e),this.$input.addEventListener(`keydown`,n),this.$input.addEventListener(`wheel`,r,{passive:!1}),this.$input.addEventListener(`mousedown`,u),this.$input.addEventListener(`focus`,()=>{this._inputFocused=!0}),this.$input.addEventListener(`blur`,()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()})}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement(`div`),this.$slider.classList.add(`slider`),this.$fill=document.createElement(`div`),this.$fill.classList.add(`fill`),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add(`hasSlider`);let e=(e,t,n,r,i)=>(e-t)/(n-t)*(i-r)+r,t=t=>{let n=this.$slider.getBoundingClientRect(),r=e(t,n.left,n.right,this._min,this._max);this._snapClampSetValue(r)},n=e=>{this._setDraggingStyle(!0),t(e.clientX),window.addEventListener(`mousemove`,r),window.addEventListener(`mouseup`,i)},r=e=>{t(e.clientX)},i=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener(`mousemove`,r),window.removeEventListener(`mouseup`,i)},a=!1,o,s,c=e=>{e.preventDefault(),this._setDraggingStyle(!0),t(e.touches[0].clientX),a=!1},l=e=>{e.touches.length>1||(this._hasScrollBar?(o=e.touches[0].clientX,s=e.touches[0].clientY,a=!0):c(e),window.addEventListener(`touchmove`,u,{passive:!1}),window.addEventListener(`touchend`,d))},u=e=>{if(a){let t=e.touches[0].clientX-o,n=e.touches[0].clientY-s;Math.abs(t)>Math.abs(n)?c(e):(window.removeEventListener(`touchmove`,u),window.removeEventListener(`touchend`,d))}else e.preventDefault(),t(e.touches[0].clientX)},d=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener(`touchmove`,u),window.removeEventListener(`touchend`,d)},f=this._callOnFinishChange.bind(this),p;this.$slider.addEventListener(`mousedown`,n),this.$slider.addEventListener(`touchstart`,l,{passive:!1}),this.$slider.addEventListener(`wheel`,e=>{if(Math.abs(e.deltaX)this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){let e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}},qce=class extends vw{constructor(e,t,n,r){super(e,t,n,`option`),this.$select=document.createElement(`select`),this.$select.setAttribute(`aria-labelledby`,this.$name.id),this.$display=document.createElement(`div`),this.$display.classList.add(`display`),this.$select.addEventListener(`change`,()=>{this.setValue(this._values[this.$select.selectedIndex]),this._callOnFinishChange()}),this.$select.addEventListener(`focus`,()=>{this.$display.classList.add(`focus`)}),this.$select.addEventListener(`blur`,()=>{this.$display.classList.remove(`focus`)}),this.$widget.appendChild(this.$select),this.$widget.appendChild(this.$display),this.$disable=this.$select,this.options(r)}options(e){return this._values=Array.isArray(e)?e:Object.values(e),this._names=Array.isArray(e)?e:Object.keys(e),this.$select.replaceChildren(),this._names.forEach(e=>{let t=document.createElement(`option`);t.textContent=e,this.$select.appendChild(t)}),this.updateDisplay(),this}updateDisplay(){let e=this.getValue(),t=this._values.indexOf(e);return this.$select.selectedIndex=t,this.$display.textContent=t===-1?e:this._names[t],this}},Jce=class extends vw{constructor(e,t,n){super(e,t,n,`string`),this.$input=document.createElement(`input`),this.$input.setAttribute(`type`,`text`),this.$input.setAttribute(`spellcheck`,`false`),this.$input.setAttribute(`aria-labelledby`,this.$name.id),this.$input.addEventListener(`input`,()=>{this.setValue(this.$input.value)}),this.$input.addEventListener(`keydown`,e=>{e.code===`Enter`&&this.$input.blur()}),this.$input.addEventListener(`blur`,()=>{this._callOnFinishChange()}),this.$widget.appendChild(this.$input),this.$disable=this.$input,this.updateDisplay()}updateDisplay(){return this.$input.value=this.getValue(),this}},Yce=`.lil-gui { font-family: var(--font-family); font-size: var(--font-size); line-height: 1; @@ -8049,11 +8049,11 @@ void main() { @font-face { font-family: "lil-gui"; src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff"); -}`;function Zce(e){let t=document.createElement(`style`);t.innerHTML=e;let n=document.querySelector(`head link[rel=stylesheet], head style`);n?document.head.insertBefore(t,n):document.head.appendChild(t)}var xw=!1,Sw=class e{constructor({parent:e,autoPlace:t=e===void 0,container:n,width:r,title:i=`Controls`,closeFolders:a=!1,injectStyles:o=!0,touchStyles:s=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement(`div`),this.domElement.classList.add(`lil-gui`),this.$title=document.createElement(`div`),this.$title.classList.add(`title`),this.$title.setAttribute(`role`,`button`),this.$title.setAttribute(`aria-expanded`,!0),this.$title.setAttribute(`tabindex`,0),this.$title.addEventListener(`click`,()=>this.openAnimated(this._closed)),this.$title.addEventListener(`keydown`,e=>{(e.code===`Enter`||e.code===`Space`)&&(e.preventDefault(),this.$title.click())}),this.$title.addEventListener(`touchstart`,()=>{},{passive:!0}),this.$children=document.createElement(`div`),this.$children.classList.add(`children`),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(i),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add(`root`),s&&this.domElement.classList.add(`allow-touch-styles`),!xw&&o&&(Zce(Xce),xw=!0),n?n.appendChild(this.domElement):t&&(this.domElement.classList.add(`autoPlace`),document.body.appendChild(this.domElement)),r&&this.domElement.style.setProperty(`--width`,r+`px`),this._closeFolders=a}add(e,t,n,r,i){if(Object(n)===n)return new Jce(this,e,t,n);let a=e[t];switch(typeof a){case`number`:return new qce(this,e,t,n,r,i);case`boolean`:return new Hce(this,e,t);case`string`:return new Yce(this,e,t);case`function`:return new bw(this,e,t)}console.error(`gui.add failed +}`;function Xce(e){let t=document.createElement(`style`);t.innerHTML=e;let n=document.querySelector(`head link[rel=stylesheet], head style`);n?document.head.insertBefore(t,n):document.head.appendChild(t)}var Sw=!1,Cw=class e{constructor({parent:e,autoPlace:t=e===void 0,container:n,width:r,title:i=`Controls`,closeFolders:a=!1,injectStyles:o=!0,touchStyles:s=!0}={}){if(this.parent=e,this.root=e?e.root:this,this.children=[],this.controllers=[],this.folders=[],this._closed=!1,this._hidden=!1,this.domElement=document.createElement(`div`),this.domElement.classList.add(`lil-gui`),this.$title=document.createElement(`div`),this.$title.classList.add(`title`),this.$title.setAttribute(`role`,`button`),this.$title.setAttribute(`aria-expanded`,!0),this.$title.setAttribute(`tabindex`,0),this.$title.addEventListener(`click`,()=>this.openAnimated(this._closed)),this.$title.addEventListener(`keydown`,e=>{(e.code===`Enter`||e.code===`Space`)&&(e.preventDefault(),this.$title.click())}),this.$title.addEventListener(`touchstart`,()=>{},{passive:!0}),this.$children=document.createElement(`div`),this.$children.classList.add(`children`),this.domElement.appendChild(this.$title),this.domElement.appendChild(this.$children),this.title(i),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add(`root`),s&&this.domElement.classList.add(`allow-touch-styles`),!Sw&&o&&(Xce(Yce),Sw=!0),n?n.appendChild(this.domElement):t&&(this.domElement.classList.add(`autoPlace`),document.body.appendChild(this.domElement)),r&&this.domElement.style.setProperty(`--width`,r+`px`),this._closeFolders=a}add(e,t,n,r,i){if(Object(n)===n)return new qce(this,e,t,n);let a=e[t];switch(typeof a){case`number`:return new Kce(this,e,t,n,r,i);case`boolean`:return new Vce(this,e,t);case`string`:return new Jce(this,e,t);case`function`:return new xw(this,e,t)}console.error(`gui.add failed property:`,t,` object:`,e,` - value:`,a)}addColor(e,t,n=1){return new Kce(this,e,t,n)}addFolder(t){let n=new e({parent:this,title:t});return this.root._closeFolders&&n.close(),n}load(e,t=!0){return e.controllers&&this.controllers.forEach(t=>{t instanceof bw||t._name in e.controllers&&t.load(e.controllers[t._name])}),t&&e.folders&&this.folders.forEach(t=>{t._title in e.folders&&t.load(e.folders[t._title])}),this}save(e=!0){let t={controllers:{},folders:{}};return this.controllers.forEach(e=>{if(!(e instanceof bw)){if(e._name in t.controllers)throw Error(`Cannot save GUI with duplicate property "${e._name}"`);t.controllers[e._name]=e.save()}}),e&&this.folders.forEach(e=>{if(e._title in t.folders)throw Error(`Cannot save GUI with duplicate folder "${e._title}"`);t.folders[e._title]=e.save()}),t}open(e=!0){return this._setClosed(!e),this.$title.setAttribute(`aria-expanded`,!this._closed),this.domElement.classList.toggle(`closed`,this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?`none`:``,this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute(`aria-expanded`,!this._closed),requestAnimationFrame(()=>{let t=this.$children.clientHeight;this.$children.style.height=t+`px`,this.domElement.classList.add(`transition`);let n=e=>{e.target===this.$children&&(this.$children.style.height=``,this.domElement.classList.remove(`transition`),this.$children.removeEventListener(`transitionend`,n))};this.$children.addEventListener(`transitionend`,n);let r=e?this.$children.scrollHeight:0;this.domElement.classList.toggle(`closed`,!e),requestAnimationFrame(()=>{this.$children.style.height=r+`px`})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(e=>e.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}};function Cw(e,t,n,r){return new(n||=Promise)((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}var Qce=class e{constructor(e,t,n,r){this.size=e,this.width=t,this.height=n,this.charLength=r,this.chars=``}static parse(t){let n=t.split(` `),r=n[0],i=r.split(`x`);return new e(r,+i[0],+i[1],+n[1])}get src(){return`data:image/jpeg;base64,`+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}},ww=class{constructor(e,t,n,r){this.src=e,this.gcode=t,this.params=n,this.comment=r}},Tw=class extends ww{constructor(e,t,n,r){super(e,t,n,r),this.params=n}},Ew=class extends ww{constructor(e,t,n,r){super(e,t,void 0,n),this.toolIndex=r}},Dw=class{constructor(e,t,n,r=0){this.layer=e,this.commands=t,this.lineNumber=n,this.height=r}},Ow=class{constructor(e){this.lines=[],this.preamble=new Dw(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){let t=Array.isArray(e)?e:e.split(` -`);this.lines=this.lines.concat(t);let n=this.lines2commands(t);this.groupIntoLayers(n);let r=this.parseMetadata(n.filter((e=>e.comment))).thumbnails;for(let[e,t]of Object.entries(r))this.metadata.thumbnails[e]=t;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((e=>this.parseCommand(e)))}parseCommand(e,t=!0){let n=e.trim().split(`;`),r=n[0],i=t&&n[1]||void 0,a=r.split(/([a-zA-Z])/g).slice(1).map((e=>e.trim())),o=a.length?`${a[0]?.toLowerCase()}${a[1]}`:``,s=this.parseParams(a.slice(2));switch(o){case`g0`:case`g00`:case`g1`:case`g01`:case`g2`:case`g02`:case`g3`:case`g03`:return new Tw(e,o,s,i);case`t0`:return new Ew(e,o,i,0);case`t1`:return new Ew(e,o,i,1);case`t2`:return new Ew(e,o,i,2);case`t3`:return new Ew(e,o,i,3);case`t4`:return new Ew(e,o,i,4);case`t5`:return new Ew(e,o,i,5);case`t6`:return new Ew(e,o,i,6);case`t7`:return new Ew(e,o,i,7);default:return new ww(e,o,s,i)}}parseMove(e){return e.reduce(((e,t)=>{let n=t.charAt(0).toLowerCase();return n!=`x`&&n!=`y`&&n!=`z`&&n!=`e`&&n!=`r`&&n!=`f`&&n!=`i`&&n!=`j`||(e[n]=parseFloat(t.slice(1))),e}),{})}isAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90}parseParams(e){return e.reduce(((e,t,n,r)=>{if(n%2==0)return e;let i=r[n-1];return i=i.toLowerCase(),this.isAlpha(i)&&(e[i]=parseFloat(t)),e}),{})}groupIntoLayers(e){for(let t=0;t0&&(e.x!=null||e.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){let e=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new Dw(this.layers.length,[],t,e))}}this.maxLayer.commands.push(n)}return this.layers}get maxLayer(){return this.layers[this.layers.length-1]??this.preamble}parseMetadata(e){let t={},n;for(let r of e){let e=r.comment;if(!e)continue;let i=e.indexOf(`thumbnail begin`),a=e.indexOf(`thumbnail end`);i>-1?n=Qce.parse(e.slice(i+15).trim()):n&&(a==-1?n.chars+=e.trim():(n.isValid&&(t[n.size]=n),n=void 0))}return{thumbnails:t}}};Ow.prototype.parseGcode=Ow.prototype.parseGCode;var kw={type:`change`},Aw={type:`start`},jw={type:`end`},Mw=new $b,Nw=new DS,$ce=Math.cos(70*nb.DEG2RAD),ele=class extends Uy{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction=`none`,this.enabled=!0,this.target=new Tb,this.cursor=new Tb,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:uy.ROTATE,MIDDLE:uy.DOLLY,RIGHT:uy.PAN},this.touches={ONE:dy.ROTATE,TWO:dy.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener(`keydown`,ie),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener(`keydown`,ie),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(kw),n.update(),i=r.NONE},this.update=function(){let t=new Tb,u=new wb().setFromUnitVectors(e.up,new Tb(0,1,0)),d=u.clone().invert(),f=new Tb,p=new wb,m=new Tb,h=2*Math.PI;return function(g=null){let _=n.object.position;t.copy(_).sub(n.target),t.applyQuaternion(u),o.setFromVector3(t),n.autoRotate&&i===r.NONE&&T(function(e){return e===null?2*Math.PI/60/60*n.autoRotateSpeed:2*Math.PI/60*n.autoRotateSpeed*e}(g)),n.enableDamping?(o.theta+=s.theta*n.dampingFactor,o.phi+=s.phi*n.dampingFactor):(o.theta+=s.theta,o.phi+=s.phi);let v=n.minAzimuthAngle,S=n.maxAzimuthAngle;isFinite(v)&&isFinite(S)&&(v<-Math.PI?v+=h:v>Math.PI&&(v-=h),S<-Math.PI?S+=h:S>Math.PI&&(S-=h),o.theta=v<=S?Math.max(v,Math.min(S,o.theta)):o.theta>(v+S)/2?Math.max(v,o.theta):Math.min(S,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(l,n.dampingFactor):n.target.add(l),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&x||n.object.isOrthographicCamera?o.radius=N(o.radius):o.radius=N(o.radius*c),t.setFromSpherical(o),t.applyQuaternion(d),_.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,l.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),l.set(0,0,0));let C=!1;if(n.zoomToCursor&&x){let r=null;if(n.object.isPerspectiveCamera){let e=t.length();r=N(e*c);let i=e-r;n.object.position.addScaledVector(y,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){let e=new Tb(b.x,b.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),C=!0;let i=new Tb(b.x,b.y,0);i.unproject(n.object),n.object.position.sub(i).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),n.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(Mw.origin.copy(n.object.position),Mw.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(Mw.direction))<$ce?e.lookAt(n.target):(Nw.setFromNormalAndCoplanarPoint(n.object.up,n.target),Mw.intersectPlane(Nw,n.target))))}else n.object.isOrthographicCamera&&(n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),C=!0);return c=1,x=!1,!!(C||f.distanceToSquared(n.object.position)>a||8*(1-p.dot(n.object.quaternion))>a||m.distanceToSquared(n.target)>0)&&(n.dispatchEvent(kw),f.copy(n.object.position),p.copy(n.object.quaternion),m.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener(`contextmenu`,H),n.domElement.removeEventListener(`pointerdown`,ee),n.domElement.removeEventListener(`pointercancel`,ne),n.domElement.removeEventListener(`wheel`,re),n.domElement.removeEventListener(`pointermove`,te),n.domElement.removeEventListener(`pointerup`,ne),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener(`keydown`,ie),n._domElementKeyEvents=null)};let n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},i=r.NONE,a=1e-6,o=new mw,s=new mw,c=1,l=new Tb,u=new rb,d=new rb,f=new rb,p=new rb,m=new rb,h=new rb,g=new rb,_=new rb,v=new rb,y=new Tb,b=new rb,x=!1,S=[],C={};function w(){return .95**n.zoomSpeed}function T(e){s.theta-=e}function E(e){s.phi-=e}let D=function(){let e=new Tb;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),l.add(e)}}(),O=function(){let e=new Tb;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),l.add(e)}}(),k=function(){let e=new Tb;return function(t,r){let i=n.domElement;if(n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),D(2*t*o/i.clientHeight,n.object.matrix),O(2*r*o/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(D(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),O(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}}();function A(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function j(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function M(e){if(!n.zoomToCursor)return;x=!0;let t=n.domElement.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=t.width,o=t.height;b.x=r/a*2-1,b.y=-i/o*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function N(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function P(e){u.set(e.clientX,e.clientY)}function F(e){p.set(e.clientX,e.clientY)}function I(){if(S.length===1)u.set(S[0].pageX,S[0].pageY);else{let e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);u.set(e,t)}}function L(){if(S.length===1)p.set(S[0].pageX,S[0].pageY);else{let e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);p.set(e,t)}}function R(){let e=S[0].pageX-S[1].pageX,t=S[0].pageY-S[1].pageY,n=Math.sqrt(e*e+t*t);g.set(0,n)}function z(e){if(S.length==1)d.set(e.pageX,e.pageY);else{let t=oe(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);d.set(n,r)}f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;T(2*Math.PI*f.x/t.clientHeight),E(2*Math.PI*f.y/t.clientHeight),u.copy(d)}function B(e){if(S.length===1)m.set(e.pageX,e.pageY);else{let t=oe(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}h.subVectors(m,p).multiplyScalar(n.panSpeed),k(h.x,h.y),p.copy(m)}function V(e){let t=oe(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);_.set(0,a),v.set(0,(_.y/g.y)**+n.zoomSpeed),A(v.y),g.copy(_)}function ee(e){!1!==n.enabled&&(S.length===0&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener(`pointermove`,te),n.domElement.addEventListener(`pointerup`,ne)),function(e){S.push(e)}(e),e.pointerType===`touch`?function(e){switch(ae(e),S.length){case 1:switch(n.touches.ONE){case dy.ROTATE:if(!1===n.enableRotate)return;I(),i=r.TOUCH_ROTATE;break;case dy.PAN:if(!1===n.enablePan)return;L(),i=r.TOUCH_PAN;break;default:i=r.NONE}break;case 2:switch(n.touches.TWO){case dy.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&R(),n.enablePan&&L(),i=r.TOUCH_DOLLY_PAN;break;case dy.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&R(),n.enableRotate&&I(),i=r.TOUCH_DOLLY_ROTATE;break;default:i=r.NONE}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(Aw)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case uy.DOLLY:if(!1===n.enableZoom)return;(function(e){M(e),g.set(e.clientX,e.clientY)})(e),i=r.DOLLY;break;case uy.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;F(e),i=r.PAN}else{if(!1===n.enableRotate)return;P(e),i=r.ROTATE}break;case uy.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;P(e),i=r.ROTATE}else{if(!1===n.enablePan)return;F(e),i=r.PAN}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(Aw)}(e))}function te(e){!1!==n.enabled&&(e.pointerType===`touch`?function(e){switch(ae(e),i){case r.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case r.TOUCH_PAN:if(!1===n.enablePan)return;B(e),n.update();break;case r.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;(function(e){n.enableZoom&&V(e),n.enablePan&&B(e)})(e),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;(function(e){n.enableZoom&&V(e),n.enableRotate&&z(e)})(e),n.update();break;default:i=r.NONE}}(e):function(e){switch(i){case r.ROTATE:if(!1===n.enableRotate)return;(function(e){d.set(e.clientX,e.clientY),f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;T(2*Math.PI*f.x/t.clientHeight),E(2*Math.PI*f.y/t.clientHeight),u.copy(d),n.update()})(e);break;case r.DOLLY:if(!1===n.enableZoom)return;(function(e){_.set(e.clientX,e.clientY),v.subVectors(_,g),v.y>0?A(w()):v.y<0&&j(w()),g.copy(_),n.update()})(e);break;case r.PAN:if(!1===n.enablePan)return;(function(e){m.set(e.clientX,e.clientY),h.subVectors(m,p).multiplyScalar(n.panSpeed),k(h.x,h.y),p.copy(m),n.update()})(e)}}(e))}function ne(e){(function(e){delete C[e.pointerId];for(let t=0;t0&&A(w()),n.update()}(e),n.dispatchEvent(jw))}function ie(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?E(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?E(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?T(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?T(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function H(e){!1!==n.enabled&&e.preventDefault()}function ae(e){let t=C[e.pointerId];t===void 0&&(t=new rb,C[e.pointerId]=t),t.set(e.pageX,e.pageY)}function oe(e){return C[(e.pointerId===S[0].pointerId?S[1]:S[0]).pointerId]}n.domElement.addEventListener(`contextmenu`,H),n.domElement.addEventListener(`pointerdown`,ee),n.domElement.addEventListener(`pointercancel`,ne),n.domElement.addEventListener(`wheel`,re,{passive:!1}),this.update()}};NS.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new rb(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},PS.line={uniforms:yS.merge([NS.common,NS.fog,NS.line]),vertexShader:` + value:`,a)}addColor(e,t,n=1){return new Gce(this,e,t,n)}addFolder(t){let n=new e({parent:this,title:t});return this.root._closeFolders&&n.close(),n}load(e,t=!0){return e.controllers&&this.controllers.forEach(t=>{t instanceof xw||t._name in e.controllers&&t.load(e.controllers[t._name])}),t&&e.folders&&this.folders.forEach(t=>{t._title in e.folders&&t.load(e.folders[t._title])}),this}save(e=!0){let t={controllers:{},folders:{}};return this.controllers.forEach(e=>{if(!(e instanceof xw)){if(e._name in t.controllers)throw Error(`Cannot save GUI with duplicate property "${e._name}"`);t.controllers[e._name]=e.save()}}),e&&this.folders.forEach(e=>{if(e._title in t.folders)throw Error(`Cannot save GUI with duplicate folder "${e._title}"`);t.folders[e._title]=e.save()}),t}open(e=!0){return this._setClosed(!e),this.$title.setAttribute(`aria-expanded`,!this._closed),this.domElement.classList.toggle(`closed`,this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?`none`:``,this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute(`aria-expanded`,!this._closed),requestAnimationFrame(()=>{let t=this.$children.clientHeight;this.$children.style.height=t+`px`,this.domElement.classList.add(`transition`);let n=e=>{e.target===this.$children&&(this.$children.style.height=``,this.domElement.classList.remove(`transition`),this.$children.removeEventListener(`transitionend`,n))};this.$children.addEventListener(`transitionend`,n);let r=e?this.$children.scrollHeight:0;this.domElement.classList.toggle(`closed`,!e),requestAnimationFrame(()=>{this.$children.style.height=r+`px`})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(e=>e.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(t=>{e=e.concat(t.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(t=>{e=e.concat(t.foldersRecursive())}),e}};function ww(e,t,n,r){return new(n||=Promise)((function(i,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}c((r=r.apply(e,t||[])).next())}))}var Zce=class e{constructor(e,t,n,r){this.size=e,this.width=t,this.height=n,this.charLength=r,this.chars=``}static parse(t){let n=t.split(` `),r=n[0],i=r.split(`x`);return new e(r,+i[0],+i[1],+n[1])}get src(){return`data:image/jpeg;base64,`+this.chars}get isValid(){return this.chars.length==this.charLength&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(this.chars)}},Tw=class{constructor(e,t,n,r){this.src=e,this.gcode=t,this.params=n,this.comment=r}},Ew=class extends Tw{constructor(e,t,n,r){super(e,t,n,r),this.params=n}},Dw=class extends Tw{constructor(e,t,n,r){super(e,t,void 0,n),this.toolIndex=r}},Ow=class{constructor(e,t,n,r=0){this.layer=e,this.commands=t,this.lineNumber=n,this.height=r}},kw=class{constructor(e){this.lines=[],this.preamble=new Ow(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){let t=Array.isArray(e)?e:e.split(` +`);this.lines=this.lines.concat(t);let n=this.lines2commands(t);this.groupIntoLayers(n);let r=this.parseMetadata(n.filter((e=>e.comment))).thumbnails;for(let[e,t]of Object.entries(r))this.metadata.thumbnails[e]=t;return{layers:this.layers,metadata:this.metadata}}lines2commands(e){return e.map((e=>this.parseCommand(e)))}parseCommand(e,t=!0){let n=e.trim().split(`;`),r=n[0],i=t&&n[1]||void 0,a=r.split(/([a-zA-Z])/g).slice(1).map((e=>e.trim())),o=a.length?`${a[0]?.toLowerCase()}${a[1]}`:``,s=this.parseParams(a.slice(2));switch(o){case`g0`:case`g00`:case`g1`:case`g01`:case`g2`:case`g02`:case`g3`:case`g03`:return new Ew(e,o,s,i);case`t0`:return new Dw(e,o,i,0);case`t1`:return new Dw(e,o,i,1);case`t2`:return new Dw(e,o,i,2);case`t3`:return new Dw(e,o,i,3);case`t4`:return new Dw(e,o,i,4);case`t5`:return new Dw(e,o,i,5);case`t6`:return new Dw(e,o,i,6);case`t7`:return new Dw(e,o,i,7);default:return new Tw(e,o,s,i)}}parseMove(e){return e.reduce(((e,t)=>{let n=t.charAt(0).toLowerCase();return n!=`x`&&n!=`y`&&n!=`z`&&n!=`e`&&n!=`r`&&n!=`f`&&n!=`i`&&n!=`j`||(e[n]=parseFloat(t.slice(1))),e}),{})}isAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122||t>=65&&t<=90}parseParams(e){return e.reduce(((e,t,n,r)=>{if(n%2==0)return e;let i=r[n-1];return i=i.toLowerCase(),this.isAlpha(i)&&(e[i]=parseFloat(t)),e}),{})}groupIntoLayers(e){for(let t=0;t0&&(e.x!=null||e.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){let e=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new Ow(this.layers.length,[],t,e))}}this.maxLayer.commands.push(n)}return this.layers}get maxLayer(){return this.layers[this.layers.length-1]??this.preamble}parseMetadata(e){let t={},n;for(let r of e){let e=r.comment;if(!e)continue;let i=e.indexOf(`thumbnail begin`),a=e.indexOf(`thumbnail end`);i>-1?n=Zce.parse(e.slice(i+15).trim()):n&&(a==-1?n.chars+=e.trim():(n.isValid&&(t[n.size]=n),n=void 0))}return{thumbnails:t}}};kw.prototype.parseGcode=kw.prototype.parseGCode;var Aw={type:`change`},jw={type:`start`},Mw={type:`end`},Nw=new $b,Pw=new OS,Qce=Math.cos(70*nb.DEG2RAD),$ce=class extends Uy{constructor(e,t){super(),this.object=e,this.domElement=t,this.domElement.style.touchAction=`none`,this.enabled=!0,this.target=new Tb,this.cursor=new Tb,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:uy.ROTATE,MIDDLE:uy.DOLLY,RIGHT:uy.PAN},this.touches={ONE:dy.ROTATE,TWO:dy.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this.getPolarAngle=function(){return o.phi},this.getAzimuthalAngle=function(){return o.theta},this.getDistance=function(){return this.object.position.distanceTo(this.target)},this.listenToKeyEvents=function(e){e.addEventListener(`keydown`,ie),this._domElementKeyEvents=e},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener(`keydown`,ie),this._domElementKeyEvents=null},this.saveState=function(){n.target0.copy(n.target),n.position0.copy(n.object.position),n.zoom0=n.object.zoom},this.reset=function(){n.target.copy(n.target0),n.object.position.copy(n.position0),n.object.zoom=n.zoom0,n.object.updateProjectionMatrix(),n.dispatchEvent(Aw),n.update(),i=r.NONE},this.update=function(){let t=new Tb,u=new wb().setFromUnitVectors(e.up,new Tb(0,1,0)),d=u.clone().invert(),f=new Tb,p=new wb,m=new Tb,h=2*Math.PI;return function(g=null){let _=n.object.position;t.copy(_).sub(n.target),t.applyQuaternion(u),o.setFromVector3(t),n.autoRotate&&i===r.NONE&&T(function(e){return e===null?2*Math.PI/60/60*n.autoRotateSpeed:2*Math.PI/60*n.autoRotateSpeed*e}(g)),n.enableDamping?(o.theta+=s.theta*n.dampingFactor,o.phi+=s.phi*n.dampingFactor):(o.theta+=s.theta,o.phi+=s.phi);let v=n.minAzimuthAngle,S=n.maxAzimuthAngle;isFinite(v)&&isFinite(S)&&(v<-Math.PI?v+=h:v>Math.PI&&(v-=h),S<-Math.PI?S+=h:S>Math.PI&&(S-=h),o.theta=v<=S?Math.max(v,Math.min(S,o.theta)):o.theta>(v+S)/2?Math.max(v,o.theta):Math.min(S,o.theta)),o.phi=Math.max(n.minPolarAngle,Math.min(n.maxPolarAngle,o.phi)),o.makeSafe(),!0===n.enableDamping?n.target.addScaledVector(l,n.dampingFactor):n.target.add(l),n.target.sub(n.cursor),n.target.clampLength(n.minTargetRadius,n.maxTargetRadius),n.target.add(n.cursor),n.zoomToCursor&&x||n.object.isOrthographicCamera?o.radius=N(o.radius):o.radius=N(o.radius*c),t.setFromSpherical(o),t.applyQuaternion(d),_.copy(n.target).add(t),n.object.lookAt(n.target),!0===n.enableDamping?(s.theta*=1-n.dampingFactor,s.phi*=1-n.dampingFactor,l.multiplyScalar(1-n.dampingFactor)):(s.set(0,0,0),l.set(0,0,0));let C=!1;if(n.zoomToCursor&&x){let r=null;if(n.object.isPerspectiveCamera){let e=t.length();r=N(e*c);let i=e-r;n.object.position.addScaledVector(y,i),n.object.updateMatrixWorld()}else if(n.object.isOrthographicCamera){let e=new Tb(b.x,b.y,0);e.unproject(n.object),n.object.zoom=Math.max(n.minZoom,Math.min(n.maxZoom,n.object.zoom/c)),n.object.updateProjectionMatrix(),C=!0;let i=new Tb(b.x,b.y,0);i.unproject(n.object),n.object.position.sub(i).add(e),n.object.updateMatrixWorld(),r=t.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),n.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?n.target.set(0,0,-1).transformDirection(n.object.matrix).multiplyScalar(r).add(n.object.position):(Nw.origin.copy(n.object.position),Nw.direction.set(0,0,-1).transformDirection(n.object.matrix),Math.abs(n.object.up.dot(Nw.direction))a||8*(1-p.dot(n.object.quaternion))>a||m.distanceToSquared(n.target)>0)&&(n.dispatchEvent(Aw),f.copy(n.object.position),p.copy(n.object.quaternion),m.copy(n.target),!0)}}(),this.dispose=function(){n.domElement.removeEventListener(`contextmenu`,H),n.domElement.removeEventListener(`pointerdown`,ee),n.domElement.removeEventListener(`pointercancel`,ne),n.domElement.removeEventListener(`wheel`,re),n.domElement.removeEventListener(`pointermove`,te),n.domElement.removeEventListener(`pointerup`,ne),n._domElementKeyEvents!==null&&(n._domElementKeyEvents.removeEventListener(`keydown`,ie),n._domElementKeyEvents=null)};let n=this,r={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},i=r.NONE,a=1e-6,o=new hw,s=new hw,c=1,l=new Tb,u=new rb,d=new rb,f=new rb,p=new rb,m=new rb,h=new rb,g=new rb,_=new rb,v=new rb,y=new Tb,b=new rb,x=!1,S=[],C={};function w(){return .95**n.zoomSpeed}function T(e){s.theta-=e}function E(e){s.phi-=e}let D=function(){let e=new Tb;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),l.add(e)}}(),O=function(){let e=new Tb;return function(t,r){!0===n.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(n.object.up,e)),e.multiplyScalar(t),l.add(e)}}(),k=function(){let e=new Tb;return function(t,r){let i=n.domElement;if(n.object.isPerspectiveCamera){let a=n.object.position;e.copy(a).sub(n.target);let o=e.length();o*=Math.tan(n.object.fov/2*Math.PI/180),D(2*t*o/i.clientHeight,n.object.matrix),O(2*r*o/i.clientHeight,n.object.matrix)}else n.object.isOrthographicCamera?(D(t*(n.object.right-n.object.left)/n.object.zoom/i.clientWidth,n.object.matrix),O(r*(n.object.top-n.object.bottom)/n.object.zoom/i.clientHeight,n.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),n.enablePan=!1)}}();function A(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function j(e){n.object.isPerspectiveCamera||n.object.isOrthographicCamera?c*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),n.enableZoom=!1)}function M(e){if(!n.zoomToCursor)return;x=!0;let t=n.domElement.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=t.width,o=t.height;b.x=r/a*2-1,b.y=-i/o*2+1,y.set(b.x,b.y,1).unproject(n.object).sub(n.object.position).normalize()}function N(e){return Math.max(n.minDistance,Math.min(n.maxDistance,e))}function P(e){u.set(e.clientX,e.clientY)}function F(e){p.set(e.clientX,e.clientY)}function I(){if(S.length===1)u.set(S[0].pageX,S[0].pageY);else{let e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);u.set(e,t)}}function L(){if(S.length===1)p.set(S[0].pageX,S[0].pageY);else{let e=.5*(S[0].pageX+S[1].pageX),t=.5*(S[0].pageY+S[1].pageY);p.set(e,t)}}function R(){let e=S[0].pageX-S[1].pageX,t=S[0].pageY-S[1].pageY,n=Math.sqrt(e*e+t*t);g.set(0,n)}function z(e){if(S.length==1)d.set(e.pageX,e.pageY);else{let t=oe(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);d.set(n,r)}f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;T(2*Math.PI*f.x/t.clientHeight),E(2*Math.PI*f.y/t.clientHeight),u.copy(d)}function B(e){if(S.length===1)m.set(e.pageX,e.pageY);else{let t=oe(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);m.set(n,r)}h.subVectors(m,p).multiplyScalar(n.panSpeed),k(h.x,h.y),p.copy(m)}function V(e){let t=oe(e),r=e.pageX-t.x,i=e.pageY-t.y,a=Math.sqrt(r*r+i*i);_.set(0,a),v.set(0,(_.y/g.y)**+n.zoomSpeed),A(v.y),g.copy(_)}function ee(e){!1!==n.enabled&&(S.length===0&&(n.domElement.setPointerCapture(e.pointerId),n.domElement.addEventListener(`pointermove`,te),n.domElement.addEventListener(`pointerup`,ne)),function(e){S.push(e)}(e),e.pointerType===`touch`?function(e){switch(ae(e),S.length){case 1:switch(n.touches.ONE){case dy.ROTATE:if(!1===n.enableRotate)return;I(),i=r.TOUCH_ROTATE;break;case dy.PAN:if(!1===n.enablePan)return;L(),i=r.TOUCH_PAN;break;default:i=r.NONE}break;case 2:switch(n.touches.TWO){case dy.DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;n.enableZoom&&R(),n.enablePan&&L(),i=r.TOUCH_DOLLY_PAN;break;case dy.DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;n.enableZoom&&R(),n.enableRotate&&I(),i=r.TOUCH_DOLLY_ROTATE;break;default:i=r.NONE}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(jw)}(e):function(e){let t;switch(e.button){case 0:t=n.mouseButtons.LEFT;break;case 1:t=n.mouseButtons.MIDDLE;break;case 2:t=n.mouseButtons.RIGHT;break;default:t=-1}switch(t){case uy.DOLLY:if(!1===n.enableZoom)return;(function(e){M(e),g.set(e.clientX,e.clientY)})(e),i=r.DOLLY;break;case uy.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enablePan)return;F(e),i=r.PAN}else{if(!1===n.enableRotate)return;P(e),i=r.ROTATE}break;case uy.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===n.enableRotate)return;P(e),i=r.ROTATE}else{if(!1===n.enablePan)return;F(e),i=r.PAN}break;default:i=r.NONE}i!==r.NONE&&n.dispatchEvent(jw)}(e))}function te(e){!1!==n.enabled&&(e.pointerType===`touch`?function(e){switch(ae(e),i){case r.TOUCH_ROTATE:if(!1===n.enableRotate)return;z(e),n.update();break;case r.TOUCH_PAN:if(!1===n.enablePan)return;B(e),n.update();break;case r.TOUCH_DOLLY_PAN:if(!1===n.enableZoom&&!1===n.enablePan)return;(function(e){n.enableZoom&&V(e),n.enablePan&&B(e)})(e),n.update();break;case r.TOUCH_DOLLY_ROTATE:if(!1===n.enableZoom&&!1===n.enableRotate)return;(function(e){n.enableZoom&&V(e),n.enableRotate&&z(e)})(e),n.update();break;default:i=r.NONE}}(e):function(e){switch(i){case r.ROTATE:if(!1===n.enableRotate)return;(function(e){d.set(e.clientX,e.clientY),f.subVectors(d,u).multiplyScalar(n.rotateSpeed);let t=n.domElement;T(2*Math.PI*f.x/t.clientHeight),E(2*Math.PI*f.y/t.clientHeight),u.copy(d),n.update()})(e);break;case r.DOLLY:if(!1===n.enableZoom)return;(function(e){_.set(e.clientX,e.clientY),v.subVectors(_,g),v.y>0?A(w()):v.y<0&&j(w()),g.copy(_),n.update()})(e);break;case r.PAN:if(!1===n.enablePan)return;(function(e){m.set(e.clientX,e.clientY),h.subVectors(m,p).multiplyScalar(n.panSpeed),k(h.x,h.y),p.copy(m),n.update()})(e)}}(e))}function ne(e){(function(e){delete C[e.pointerId];for(let t=0;t0&&A(w()),n.update()}(e),n.dispatchEvent(Mw))}function ie(e){!1!==n.enabled&&!1!==n.enablePan&&function(e){let t=!1;switch(e.code){case n.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?E(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(0,n.keyPanSpeed),t=!0;break;case n.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?E(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(0,-n.keyPanSpeed),t=!0;break;case n.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?T(2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(n.keyPanSpeed,0),t=!0;break;case n.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?T(-2*Math.PI*n.rotateSpeed/n.domElement.clientHeight):k(-n.keyPanSpeed,0),t=!0}t&&(e.preventDefault(),n.update())}(e)}function H(e){!1!==n.enabled&&e.preventDefault()}function ae(e){let t=C[e.pointerId];t===void 0&&(t=new rb,C[e.pointerId]=t),t.set(e.pageX,e.pageY)}function oe(e){return C[(e.pointerId===S[0].pointerId?S[1]:S[0]).pointerId]}n.domElement.addEventListener(`contextmenu`,H),n.domElement.addEventListener(`pointerdown`,ee),n.domElement.addEventListener(`pointercancel`,ne),n.domElement.addEventListener(`wheel`,re,{passive:!1}),this.update()}};PS.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new rb(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},FS.line={uniforms:bS.merge([PS.common,PS.fog,PS.line]),vertexShader:` #include #include #include @@ -8440,51 +8440,51 @@ void main() { #include } - `};var Pw=class extends bS{constructor(e){super({type:`LineMaterial`,uniforms:yS.clone(PS.line.uniforms),vertexShader:PS.line.vertexShader,fragmentShader:PS.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE=``,this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}},Fw=new Ob,Iw=new Tb,Lw=class extends kce{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new Hx([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new Hx([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new pw(t,6,1);return this.setAttribute(`instanceStart`,new MC(n,3,0)),this.setAttribute(`instanceEnd`,new MC(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new pw(t,6,1);return this.setAttribute(`instanceColorStart`,new MC(n,3,0)),this.setAttribute(`instanceColorEnd`,new MC(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new fce(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ob);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Fw.setFromBufferAttribute(t),this.boundingBox.union(Fw))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Gb),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;iu&&Vw.z>u)continue;if(Bw.z>u){let e=Bw.z-Vw.z,t=(Bw.z-u)/e;Bw.lerp(Vw,t)}else if(Vw.z>u){let e=Vw.z-Bw.z,t=(Vw.z-u)/e;Vw.lerp(Bw,t)}Bw.applyMatrix4(r),Vw.applyMatrix4(r),Bw.multiplyScalar(1/Bw.w),Vw.multiplyScalar(1/Vw.w),Bw.x*=i.x/2,Bw.y*=i.y/2,Vw.x*=i.x/2,Vw.y*=i.y/2,Gw.start.copy(Bw),Gw.start.z=0,Gw.end.copy(Vw),Gw.end.z=0;let o=Gw.closestPointToPointParameter(Uw,!0);Gw.at(o,Kw);let l=nb.lerp(Bw.z,Vw.z,o),d=l>=-1&&l<=1,f=Uw.distanceTo(Kw)<.5*Zw;if(d&&f){Gw.start.fromBufferAttribute(s,t),Gw.end.fromBufferAttribute(c,t),Gw.start.applyMatrix4(a),Gw.end.applyMatrix4(a);let r=new Tb,i=new Tb;Xw.distanceSqToSegment(Gw.start,Gw.end,i,r),n.push({point:i,pointOnLine:r,distance:Xw.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}(this,r,t)))}},nle=class extends XC{constructor(e,t,n,r,i=4473924,a=8947848){i=new Px(i),a=new Px(a);let o=Math.round(e/t);n=Math.round(n/r)*r/2;let s=[],c=[],l=0;for(let r=-1*(e=o*t/2);r<=e;r+=t){s.push(r,0,-1*n,r,0,n);let e=r===0?i:a;e.toArray(c,l),l+=3,e.toArray(c,l),l+=3,e.toArray(c,l),l+=3,e.toArray(c,l),l+=3}for(let t=-1*n;t<=n;t+=r){s.push(-1*e,0,t,e,0,t);let n=t===0?i:a;n.toArray(c,l),l+=3,n.toArray(c,l),l+=3,n.toArray(c,l),l+=3,n.toArray(c,l),l+=3}let u=new Yx;u.setAttribute(`position`,new Hx(s,3)),u.setAttribute(`color`,new Hx(c,3)),super(u,new HC({vertexColors:!0,toneMapped:!1}))}};function rle(e,t,n,r){let i=new XC(function(e,t,n){e*=.5,t*=.5,n*=.5;let r=new Yx,i=[];return i.push(-e,-t,-n,-e,t,-n,-e,t,-n,e,t,-n,e,t,-n,e,-t,-n,e,-t,-n,-e,-t,-n,-e,-t,n,-e,t,n,-e,t,n,e,t,n,e,t,n,e,-t,n,e,-t,n,-e,-t,n,-e,-t,-n,-e,-t,n,-e,t,-n,-e,t,n,e,t,-n,e,t,n,e,-t,-n,e,-t,n),r.setAttribute(`position`,new Hx(i,3)),r}(e,t,n),new mce({color:new Px(r),dashSize:3,gapSize:1}));return i.computeLineDistances(),i}var $w=function(){var e=0,t=document.createElement(`div`);function n(e){return t.appendChild(e.dom),e}function r(n){for(var r=0;r=a+1e3&&(s.update(1e3*o/(e-a),100),a=e,o=0,l)){var t=performance.memory;l.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){i=this.end()},domElement:t,setMode:r}};$w.Panel=function(e,t,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),s=80*o,c=48*o,l=3*o,u=2*o,d=3*o,f=15*o,p=74*o,m=30*o,h=document.createElement(`canvas`);h.width=s,h.height=c,h.style.cssText=`width:80px;height:48px`;var g=h.getContext(`2d`);return g.font=`bold `+9*o+`px Helvetica,Arial,sans-serif`,g.textBaseline=`top`,g.fillStyle=n,g.fillRect(0,0,s,c),g.fillStyle=t,g.fillText(e,l,u),g.fillRect(d,f,p,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,f,p,m),{dom:h,update:function(c,_){r=Math.min(r,c),i=Math.max(i,c),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,f),g.fillStyle=t,g.fillText(a(c)+` `+e+` (`+a(r)+`-`+a(i)+`)`,l,u),g.drawImage(h,d+o,f,p-o,m,d,f,p-o,m),g.fillRect(d+p-o,f,o,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-o,f,o,a((1-c/_)*m))}}};var ile=$w,eT=class{constructor(e,t){this.openFolders=[],this.watchedObject=e,this.options=t,this.gui=new Sw,this.gui.title(`Dev info`),this.setup()}setup(){this.loadOpenFolders(),this.options&&!this.options.renderer||this.setupRedererFolder(),this.options&&!this.options.camera||this.setupCameraFolder(),this.options&&!this.options.parser||this.setupParserFolder(),this.options&&!this.options.buildVolume||this.setupBuildVolumeFolder(),this.options&&!this.options.devHelpers||this.setupDevHelpers()}reset(){this.gui.destroy(),this.gui=new Sw,this.gui.title(`Dev info`),this.setup()}loadOpenFolders(){this.openFolders=JSON.parse(localStorage.getItem(`dev-gui-open`)||`{}`).open||[]}saveOpenFolders(){this.openFolders=this.gui.foldersRecursive().filter((e=>!e._closed)).map((e=>e._title)),console.log(this.openFolders),localStorage.setItem(`dev-gui-open`,JSON.stringify({open:this.openFolders}))}setupRedererFolder(){let e=this.gui.addFolder(`Render Info`);this.openFolders.includes(`Render Info`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.renderer.info.render,`triangles`).listen(),e.add(this.watchedObject.renderer.info.render,`calls`).listen(),e.add(this.watchedObject.renderer.info.render,`lines`).listen(),e.add(this.watchedObject.renderer.info.render,`points`).listen(),e.add(this.watchedObject.renderer.info.memory,`geometries`).listen(),e.add(this.watchedObject.renderer.info.memory,`textures`).listen(),e.add(this.watchedObject,`_lastRenderTime`).listen()}setupCameraFolder(){let e=this.gui.addFolder(`Camera`);this.openFolders.includes(`Camera`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()}));let t=e.addFolder(`Camera position`);t.add(this.watchedObject.camera.position,`x`).listen(),t.add(this.watchedObject.camera.position,`y`).listen(),t.add(this.watchedObject.camera.position,`z`).listen();let n=e.addFolder(`Camera rotation`);n.add(this.watchedObject.camera.rotation,`x`).listen(),n.add(this.watchedObject.camera.rotation,`y`).listen(),n.add(this.watchedObject.camera.rotation,`z`).listen()}setupParserFolder(){let e=this.gui.addFolder(`Parser`);this.openFolders.includes(`Parser`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.parser,`curZ`).listen(),e.add(this.watchedObject.parser,`maxZ`).listen(),e.add(this.watchedObject.parser,`tolerance`).listen(),e.add(this.watchedObject.parser.layers,`length`).name(`layers.count`).listen(),e.add(this.watchedObject.parser.lines,`length`).name(`lines.count`).listen()}setupBuildVolumeFolder(){let e=this.gui.addFolder(`Build Volume`);this.openFolders.includes(`Build Volume`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.buildVolume,`x`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,`y`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,`z`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()}))}setupDevHelpers(){let e=this.gui.addFolder(`Dev Helpers`);this.openFolders.includes(`Dev Helpers`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject,`_wireframe`).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject,`render`).listen(),e.add(this.watchedObject,`clear`).listen()}},ale=class extends Yx{constructor(e=[new Tb],t=.6,n=.2,r=8){super(),this.type=`ExtrusionGeometry`,this.parameters={points:e,lineWidth:t,lineHeight:n,radialSegments:r,closed:!1};let i=new Tb,a=new Tb,o=new rb,s=[],c=[],l=[],u=[];function d(o){let[l,u,d]=function(t){let n=e[t],r=new Tb,i=new Tb,a=new Tb,o=new Tb;r.copy(n).sub(e[t-1]||n).normalize().add((e[t+1]||n).clone().sub(n).normalize()).normalize();let s=Number.MAX_VALUE,c=Math.abs(r.x),l=Math.abs(r.y),u=Math.abs(r.z);return c<=s&&(s=c,i.set(1,0,0)),l<=s&&(s=l,i.set(0,1,0)),u<=s&&i.set(0,0,1),o.crossVectors(r,i).normalize(),i.crossVectors(r,o),a.crossVectors(r,i),[n,i,a]}(o);for(let e=0;e<=r;e++){let o=e/r*Math.PI*2,f=Math.sin(o),p=-Math.cos(o);a.x=p*u.x+f*d.x,a.y=p*u.y+f*d.y,a.z=p*u.z+f*d.z,a.normalize(),c.push(a.x,a.y,a.z),i.x=l.x+t*a.x*.5,i.y=l.y+t*a.y*.5,i.z=l.z+n*a.z*.5,s.push(i.x,i.y,i.z)}}(function(){for(let t=0;tthis.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)==null||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){let e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){let e=new Vce(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn(`Volumetric rendering is experimental. It may not work as expected or change in the future.`);let e=new Oce(13421772,.3*Math.PI),t=new Dce(16777215,Math.PI,void 0,.001);t.position.set(0,500,500),this.scene.add(e),this.scene.add(t)}}createGroup(e){let t=new OC;return t.name=e,t.quaternion.setFromEuler(new cx(-Math.PI/2,0,0)),this.buildVolume?t.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):t.position.set(-100,0,100),t}render(){let e=performance.now();this.group=this.createGroup(`allLayers`),this.state=tT.initial,this.initScene();for(let e=0;e0?e:1)}))}renderFrameLoop(e){return new Promise((t=>{let n=()=>{this.renderLayerIndex>this.layers.length-1?t():(this.renderFrame(e),requestAnimationFrame(n))};n()}))}renderFrame(e){this.group=this.createGroup(`layer`+this.renderLayerIndex);for(let t=0;tthis.maxLayerIndex)return;let t=this.layers[e],n={extrusion:[],travel:[],z:this.state.z,height:t.height};for(let r of t.commands)if(r.gcode!=`g20`){if(r.gcode.startsWith(`t`)){this.doRenderExtrusion(n,e),n.extrusion=[];let t=r;this.state.t=t.toolIndex}else if([`g0`,`g00`,`g1`,`g01`,`g2`,`g02`,`g3`,`g03`].indexOf(r.gcode)>-1){let t=r,i={x:t.params.x??this.state.x,y:t.params.y??this.state.y,z:t.params.z??this.state.z,r:t.params.r??this.state.r,e:t.params.e??this.state.e,i:t.params.i??this.state.i,j:t.params.j??this.state.j,t:this.state.t};if(e>=this.minLayerIndex){let e=(t.params.e??0)>0||this.nonTravelmoves.indexOf(r.gcode)>-1;(i.x!=this.state.x||i.y!=this.state.y||i.z!=this.state.z)&&(e&&this.renderExtrusion||!e&&this.renderTravel)&&(r.gcode==`g2`||r.gcode==`g3`||r.gcode==`g02`||r.gcode==`g03`?this.addArcSegment(n,this.state,i,e,r.gcode==`g2`||r.gcode==`g02`):this.addLineSegment(n,this.state,i,e))}this.state.x=i.x,this.state.y=i.y,this.state.z=i.z,this.beyondFirstMove||=!0}}else this.setInches();this.doRenderExtrusion(n,e)}doRenderExtrusion(e,t){if(this.renderExtrusion){let n=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){let e=.1+.7*t/this.layers.length;n.getHSL(nT),n=new Px().setHSL(nT.h,nT.s,e)}if(t==this.layers.length-1){let t=this._topLayerColor??n,r=this._lastSegmentColor??t,i=e.extrusion.splice(-3),a=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,t.getHex(),e.height),this.addTubeLine([...a,...i],r.getHex(),e.height)):(this.addLine(e.extrusion,t.getHex()),this.addLine([...a,...i],r.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,n.getHex(),e.height):this.addLine(e.extrusion,n.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn(`Switching units after movement is already made is discouraged and is not supported.`):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new nle(this.buildVolume.x,10,this.buildVolume.y,10));let e=rle(this.buildVolume.x,this.buildVolume.z,this.buildVolume.y,8947848);e.position.setY(this.buildVolume.z/2),this.scene.add(e)}clear(){this.resetState(),this.parser=new Ow(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=tT.initial,(e=this.devGui)==null||e.reset(),this._geometries={}}resize(){let[e,t]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t,!1)}addLineSegment(e,t,n,r){(r?e.extrusion:e.travel).push(t.x,t.y,t.z,n.x,n.y,n.z)}addArcSegment(e,t,n,r,i){let a=r?e.extrusion:e.travel,o=t.x,s=t.y,c=t.z,l=n.x,u=n.y,d=n.z,f=n.r,p=n.i,m=n.j;if(f){let e=l-o,t=u-s,n=Math.sqrt((e/2)**2+(t/2)**2);f=Math.max(f,n);let r=e**2+t**2,a=f**2-r/4,c=Math.sqrt(a/r);(i&&f<0||!i&&f>0)&&(c=-c),p=e/2+t*c,m=t/2-e*c}let h=o==l&&s==u,g=o+p,_=s+m,v=Math.sqrt(p*p+m*m),y=Math.atan2(-m,-p),b=Math.atan2(u-_,l-g),x;h?x=2*Math.PI:(x=i?y-b:b-y,x<0&&(x+=2*Math.PI));let S=v*x/1.8;this.inches&&(S*=25),S<1&&(S=1);let C=x/S;C*=i?-1:1;let w=[];w.push({x:o,y:s,z:c});let T=(c-d)/S,E=o,D=s,O=c,k=y;for(let e=0;e0)return void this.addThickLine(e,t);let r=new Yx;r.setAttribute(`position`,new Hx(e,3)),this.disposables.push(r);let i=new HC({color:t});this.disposables.push(i);let a=new XC(r,i);(n=this.group)==null||n.add(a)}addTubeLine(e,t,n=.2){let r=[],i=[];for(let t=0;t{var r;let i=new ale(e,this.extrusionWidth,this.lineHeight||n,4);(r=this._geometries)[t]||(r[t]=[]),this._geometries[t].push(i)}))}addThickLine(e,t){var n;if(!e.length||!this.lineWidth)return;let r=new Lw;this.disposables.push(r);let i=new Pw({color:t,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(i),r.setPositions(e);let a=new tle(r,i);(n=this.group)==null||n.add(a)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn(`Drag and drop is deprecated as a library feature. See the demo how to implement your own.`),this.canvas.addEventListener(`dragover`,(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),this.canvas.classList.add(`dragging`)})),this.canvas.addEventListener(`dragleave`,(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove(`dragging`)})),this.canvas.addEventListener(`drop`,(e=>Cw(this,void 0,void 0,(function*(){e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove(`dragging`);let t=(e.dataTransfer?.files??[])[0];this.clear(),yield this._readFromStream(t.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(let e in this._geometries){let t=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){let n=this._geometries[e].pop();t.addGeometry(n)}}}createBatchMesh(e){var t;let n=this._geometries[e],r=new pce({color:e,wireframe:this._wireframe});this.disposables.push(r);let i=n.reduce(((e,t)=>3*t.attributes.position.count+e),0),a=new uce(n.length,i,void 0,r);return this.disposables.push(a),(t=this.group)==null||t.add(a),a}_readFromStream(e){return Cw(this,void 0,void 0,(function*(){let t=e.getReader(),n,r=``,i=0;do{console.debug(`reading from stream`),n=yield t.read(),i+=n.value?.length??0;let e=(a=n.value,new TextDecoder(`utf-8`).decode(a)),o=e.lastIndexOf(` -`),s=e.slice(0,o);this.parser.parseGCode(r+s),r=e.slice(o)}while(!n.done);var a;console.debug(`read from stream`,i)}))}initGui(){typeof this.devMode==`boolean`&&!0===this.devMode?this.devGui=new eT(this):typeof this.devMode==`object`&&(this.devGui=new eT(this,this.devMode))}initStats(){this.stats&&(typeof this.devMode==`object`&&(this.statsContainer=this.devMode.statsContainer),(this.statsContainer??document.body).appendChild(this.stats.dom),this.stats.dom.classList.add(`stats`),this.initGui())}};rT.defaultExtrusionColor=new Px(`hotpink`);function iT({gcodeUrl:e,buildVolume:t={x:256,y:256,z:256},filamentColors:n,className:r=``}){let i=(0,y.useRef)(null),a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=(0,y.useRef)(!1),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(0),[g,_]=(0,y.useState)(0);(0,y.useEffect)(()=>{if(!i.current||s.current)return;s.current=!0;let r=i.current,c=r.parentElement?.getBoundingClientRect();c&&(r.width=c.width,r.height=c.height);let u=n&&n.length>1,f=n?.[0]||`#00ae42`,m=new rT({canvas:r,buildVolume:t,backgroundColor:1710618,extrusionColor:u?n:f,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=m;let g={},v=Ku();v&&(g.Authorization=`Bearer ${v}`),fetch(e,{headers:g}).then(async e=>{if(!e.ok)throw e.status===404&&(await e.json().catch(()=>({}))).detail?.includes(`sliced`)?(p(!0),Error(`not_sliced`)):Error(`Failed to load G-code`);return e.text()}).then(e=>{let t=new Set,r=/^(\s*)T(\d+)(\s*;.*)?$/gim,i;for(;(i=r.exec(e))!==null;){let e=parseInt(i[2],10);e<=15&&t.add(e)}let a=new Map,o=Array.from(t).sort((e,t)=>e-t);o.forEach((e,t)=>{a.set(e,t%8)});let s=[];o.forEach((e,t)=>{let r=n?.[e]||`#00ae42`;s[t%8]=r});let c=e.split(` + `};var Fw=class extends xS{constructor(e){super({type:`LineMaterial`,uniforms:bS.clone(FS.line.uniforms),vertexShader:FS.line.vertexShader,fragmentShader:FS.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){!0===e?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){!0===e!==this.dashed&&(this.needsUpdate=!0),!0===e?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(!0===e!==this.alphaToCoverage&&(this.needsUpdate=!0),!0===e?(this.defines.USE_ALPHA_TO_COVERAGE=``,this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}},Iw=new Ob,Lw=new Tb,Rw=class extends Oce{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new Ux([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new Ux([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new mw(t,6,1);return this.setAttribute(`instanceStart`,new NC(n,3,0)),this.setAttribute(`instanceEnd`,new NC(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new mw(t,6,1);return this.setAttribute(`instanceColorStart`,new NC(n,3,0)),this.setAttribute(`instanceColorEnd`,new NC(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new dce(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ob);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Iw.setFromBufferAttribute(t),this.boundingBox.union(Iw))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Gb),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;iu&&Hw.z>u)continue;if(Vw.z>u){let e=Vw.z-Hw.z,t=(Vw.z-u)/e;Vw.lerp(Hw,t)}else if(Hw.z>u){let e=Hw.z-Vw.z,t=(Hw.z-u)/e;Hw.lerp(Vw,t)}Vw.applyMatrix4(r),Hw.applyMatrix4(r),Vw.multiplyScalar(1/Vw.w),Hw.multiplyScalar(1/Hw.w),Vw.x*=i.x/2,Vw.y*=i.y/2,Hw.x*=i.x/2,Hw.y*=i.y/2,Kw.start.copy(Vw),Kw.start.z=0,Kw.end.copy(Hw),Kw.end.z=0;let o=Kw.closestPointToPointParameter(Ww,!0);Kw.at(o,qw);let l=nb.lerp(Vw.z,Hw.z,o),d=l>=-1&&l<=1,f=Ww.distanceTo(qw)<.5*Qw;if(d&&f){Kw.start.fromBufferAttribute(s,t),Kw.end.fromBufferAttribute(c,t),Kw.start.applyMatrix4(a),Kw.end.applyMatrix4(a);let r=new Tb,i=new Tb;Zw.distanceSqToSegment(Kw.start,Kw.end,i,r),n.push({point:i,pointOnLine:r,distance:Zw.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}(this,r,t)))}},tle=class extends ZC{constructor(e,t,n,r,i=4473924,a=8947848){i=new Fx(i),a=new Fx(a);let o=Math.round(e/t);n=Math.round(n/r)*r/2;let s=[],c=[],l=0;for(let r=-1*(e=o*t/2);r<=e;r+=t){s.push(r,0,-1*n,r,0,n);let e=r===0?i:a;e.toArray(c,l),l+=3,e.toArray(c,l),l+=3,e.toArray(c,l),l+=3,e.toArray(c,l),l+=3}for(let t=-1*n;t<=n;t+=r){s.push(-1*e,0,t,e,0,t);let n=t===0?i:a;n.toArray(c,l),l+=3,n.toArray(c,l),l+=3,n.toArray(c,l),l+=3,n.toArray(c,l),l+=3}let u=new Xx;u.setAttribute(`position`,new Ux(s,3)),u.setAttribute(`color`,new Ux(c,3)),super(u,new UC({vertexColors:!0,toneMapped:!1}))}};function nle(e,t,n,r){let i=new ZC(function(e,t,n){e*=.5,t*=.5,n*=.5;let r=new Xx,i=[];return i.push(-e,-t,-n,-e,t,-n,-e,t,-n,e,t,-n,e,t,-n,e,-t,-n,e,-t,-n,-e,-t,-n,-e,-t,n,-e,t,n,-e,t,n,e,t,n,e,t,n,e,-t,n,e,-t,n,-e,-t,n,-e,-t,-n,-e,-t,n,-e,t,-n,-e,t,n,e,t,-n,e,t,n,e,-t,-n,e,-t,n),r.setAttribute(`position`,new Ux(i,3)),r}(e,t,n),new pce({color:new Fx(r),dashSize:3,gapSize:1}));return i.computeLineDistances(),i}var eT=function(){var e=0,t=document.createElement(`div`);function n(e){return t.appendChild(e.dom),e}function r(n){for(var r=0;r=a+1e3&&(s.update(1e3*o/(e-a),100),a=e,o=0,l)){var t=performance.memory;l.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){i=this.end()},domElement:t,setMode:r}};eT.Panel=function(e,t,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),s=80*o,c=48*o,l=3*o,u=2*o,d=3*o,f=15*o,p=74*o,m=30*o,h=document.createElement(`canvas`);h.width=s,h.height=c,h.style.cssText=`width:80px;height:48px`;var g=h.getContext(`2d`);return g.font=`bold `+9*o+`px Helvetica,Arial,sans-serif`,g.textBaseline=`top`,g.fillStyle=n,g.fillRect(0,0,s,c),g.fillStyle=t,g.fillText(e,l,u),g.fillRect(d,f,p,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,f,p,m),{dom:h,update:function(c,_){r=Math.min(r,c),i=Math.max(i,c),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,f),g.fillStyle=t,g.fillText(a(c)+` `+e+` (`+a(r)+`-`+a(i)+`)`,l,u),g.drawImage(h,d+o,f,p-o,m,d,f,p-o,m),g.fillRect(d+p-o,f,o,m),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-o,f,o,a((1-c/_)*m))}}};var rle=eT,tT=class{constructor(e,t){this.openFolders=[],this.watchedObject=e,this.options=t,this.gui=new Cw,this.gui.title(`Dev info`),this.setup()}setup(){this.loadOpenFolders(),this.options&&!this.options.renderer||this.setupRedererFolder(),this.options&&!this.options.camera||this.setupCameraFolder(),this.options&&!this.options.parser||this.setupParserFolder(),this.options&&!this.options.buildVolume||this.setupBuildVolumeFolder(),this.options&&!this.options.devHelpers||this.setupDevHelpers()}reset(){this.gui.destroy(),this.gui=new Cw,this.gui.title(`Dev info`),this.setup()}loadOpenFolders(){this.openFolders=JSON.parse(localStorage.getItem(`dev-gui-open`)||`{}`).open||[]}saveOpenFolders(){this.openFolders=this.gui.foldersRecursive().filter((e=>!e._closed)).map((e=>e._title)),console.log(this.openFolders),localStorage.setItem(`dev-gui-open`,JSON.stringify({open:this.openFolders}))}setupRedererFolder(){let e=this.gui.addFolder(`Render Info`);this.openFolders.includes(`Render Info`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.renderer.info.render,`triangles`).listen(),e.add(this.watchedObject.renderer.info.render,`calls`).listen(),e.add(this.watchedObject.renderer.info.render,`lines`).listen(),e.add(this.watchedObject.renderer.info.render,`points`).listen(),e.add(this.watchedObject.renderer.info.memory,`geometries`).listen(),e.add(this.watchedObject.renderer.info.memory,`textures`).listen(),e.add(this.watchedObject,`_lastRenderTime`).listen()}setupCameraFolder(){let e=this.gui.addFolder(`Camera`);this.openFolders.includes(`Camera`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()}));let t=e.addFolder(`Camera position`);t.add(this.watchedObject.camera.position,`x`).listen(),t.add(this.watchedObject.camera.position,`y`).listen(),t.add(this.watchedObject.camera.position,`z`).listen();let n=e.addFolder(`Camera rotation`);n.add(this.watchedObject.camera.rotation,`x`).listen(),n.add(this.watchedObject.camera.rotation,`y`).listen(),n.add(this.watchedObject.camera.rotation,`z`).listen()}setupParserFolder(){let e=this.gui.addFolder(`Parser`);this.openFolders.includes(`Parser`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.parser,`curZ`).listen(),e.add(this.watchedObject.parser,`maxZ`).listen(),e.add(this.watchedObject.parser,`tolerance`).listen(),e.add(this.watchedObject.parser.layers,`length`).name(`layers.count`).listen(),e.add(this.watchedObject.parser.lines,`length`).name(`lines.count`).listen()}setupBuildVolumeFolder(){let e=this.gui.addFolder(`Build Volume`);this.openFolders.includes(`Build Volume`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject.buildVolume,`x`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,`y`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject.buildVolume,`z`).min(0).max(600).listen().onChange((()=>{this.watchedObject.render()}))}setupDevHelpers(){let e=this.gui.addFolder(`Dev Helpers`);this.openFolders.includes(`Dev Helpers`)||e.close(),e.onOpenClose((()=>{this.saveOpenFolders()})),e.add(this.watchedObject,`_wireframe`).listen().onChange((()=>{this.watchedObject.render()})),e.add(this.watchedObject,`render`).listen(),e.add(this.watchedObject,`clear`).listen()}},ile=class extends Xx{constructor(e=[new Tb],t=.6,n=.2,r=8){super(),this.type=`ExtrusionGeometry`,this.parameters={points:e,lineWidth:t,lineHeight:n,radialSegments:r,closed:!1};let i=new Tb,a=new Tb,o=new rb,s=[],c=[],l=[],u=[];function d(o){let[l,u,d]=function(t){let n=e[t],r=new Tb,i=new Tb,a=new Tb,o=new Tb;r.copy(n).sub(e[t-1]||n).normalize().add((e[t+1]||n).clone().sub(n).normalize()).normalize();let s=Number.MAX_VALUE,c=Math.abs(r.x),l=Math.abs(r.y),u=Math.abs(r.z);return c<=s&&(s=c,i.set(1,0,0)),l<=s&&(s=l,i.set(0,1,0)),u<=s&&i.set(0,0,1),o.crossVectors(r,i).normalize(),i.crossVectors(r,o),a.crossVectors(r,i),[n,i,a]}(o);for(let e=0;e<=r;e++){let o=e/r*Math.PI*2,f=Math.sin(o),p=-Math.cos(o);a.x=p*u.x+f*d.x,a.y=p*u.y+f*d.y,a.z=p*u.z+f*d.z,a.normalize(),c.push(a.x,a.y,a.z),i.x=l.x+t*a.x*.5,i.y=l.y+t*a.y*.5,i.z=l.z+n*a.z*.5,s.push(i.x,i.y,i.z)}}(function(){for(let t=0;tthis.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)==null||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){let e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){let e=new Bce(Math.max(this.buildVolume.x/2,this.buildVolume.y/2)+20);this.scene.add(e)}if(this.buildVolume&&this.drawBuildVolume(),this.renderTubes){console.warn(`Volumetric rendering is experimental. It may not work as expected or change in the future.`);let e=new Dce(13421772,.3*Math.PI),t=new Ece(16777215,Math.PI,void 0,.001);t.position.set(0,500,500),this.scene.add(e),this.scene.add(t)}}createGroup(e){let t=new kC;return t.name=e,t.quaternion.setFromEuler(new cx(-Math.PI/2,0,0)),this.buildVolume?t.position.set(-this.buildVolume.x/2,0,this.buildVolume.y/2):t.position.set(-100,0,100),t}render(){let e=performance.now();this.group=this.createGroup(`allLayers`),this.state=nT.initial,this.initScene();for(let e=0;e0?e:1)}))}renderFrameLoop(e){return new Promise((t=>{let n=()=>{this.renderLayerIndex>this.layers.length-1?t():(this.renderFrame(e),requestAnimationFrame(n))};n()}))}renderFrame(e){this.group=this.createGroup(`layer`+this.renderLayerIndex);for(let t=0;tthis.maxLayerIndex)return;let t=this.layers[e],n={extrusion:[],travel:[],z:this.state.z,height:t.height};for(let r of t.commands)if(r.gcode!=`g20`){if(r.gcode.startsWith(`t`)){this.doRenderExtrusion(n,e),n.extrusion=[];let t=r;this.state.t=t.toolIndex}else if([`g0`,`g00`,`g1`,`g01`,`g2`,`g02`,`g3`,`g03`].indexOf(r.gcode)>-1){let t=r,i={x:t.params.x??this.state.x,y:t.params.y??this.state.y,z:t.params.z??this.state.z,r:t.params.r??this.state.r,e:t.params.e??this.state.e,i:t.params.i??this.state.i,j:t.params.j??this.state.j,t:this.state.t};if(e>=this.minLayerIndex){let e=(t.params.e??0)>0||this.nonTravelmoves.indexOf(r.gcode)>-1;(i.x!=this.state.x||i.y!=this.state.y||i.z!=this.state.z)&&(e&&this.renderExtrusion||!e&&this.renderTravel)&&(r.gcode==`g2`||r.gcode==`g3`||r.gcode==`g02`||r.gcode==`g03`?this.addArcSegment(n,this.state,i,e,r.gcode==`g2`||r.gcode==`g02`):this.addLineSegment(n,this.state,i,e))}this.state.x=i.x,this.state.y=i.y,this.state.z=i.z,this.beyondFirstMove||=!0}}else this.setInches();this.doRenderExtrusion(n,e)}doRenderExtrusion(e,t){if(this.renderExtrusion){let n=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){let e=.1+.7*t/this.layers.length;n.getHSL(rT),n=new Fx().setHSL(rT.h,rT.s,e)}if(t==this.layers.length-1){let t=this._topLayerColor??n,r=this._lastSegmentColor??t,i=e.extrusion.splice(-3),a=e.extrusion.splice(-3);this.renderTubes?(this.addTubeLine(e.extrusion,t.getHex(),e.height),this.addTubeLine([...a,...i],r.getHex(),e.height)):(this.addLine(e.extrusion,t.getHex()),this.addLine([...a,...i],r.getHex()))}else this.renderTubes?this.addTubeLine(e.extrusion,n.getHex(),e.height):this.addLine(e.extrusion,n.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn(`Switching units after movement is already made is discouraged and is not supported.`):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new tle(this.buildVolume.x,10,this.buildVolume.y,10));let e=nle(this.buildVolume.x,this.buildVolume.z,this.buildVolume.y,8947848);e.position.setY(this.buildVolume.z/2),this.scene.add(e)}clear(){this.resetState(),this.parser=new kw(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=nT.initial,(e=this.devGui)==null||e.reset(),this._geometries={}}resize(){let[e,t]=[this.canvas.offsetWidth,this.canvas.offsetHeight];this.camera.aspect=e/t,this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t,!1)}addLineSegment(e,t,n,r){(r?e.extrusion:e.travel).push(t.x,t.y,t.z,n.x,n.y,n.z)}addArcSegment(e,t,n,r,i){let a=r?e.extrusion:e.travel,o=t.x,s=t.y,c=t.z,l=n.x,u=n.y,d=n.z,f=n.r,p=n.i,m=n.j;if(f){let e=l-o,t=u-s,n=Math.sqrt((e/2)**2+(t/2)**2);f=Math.max(f,n);let r=e**2+t**2,a=f**2-r/4,c=Math.sqrt(a/r);(i&&f<0||!i&&f>0)&&(c=-c),p=e/2+t*c,m=t/2-e*c}let h=o==l&&s==u,g=o+p,_=s+m,v=Math.sqrt(p*p+m*m),y=Math.atan2(-m,-p),b=Math.atan2(u-_,l-g),x;h?x=2*Math.PI:(x=i?y-b:b-y,x<0&&(x+=2*Math.PI));let S=v*x/1.8;this.inches&&(S*=25),S<1&&(S=1);let C=x/S;C*=i?-1:1;let w=[];w.push({x:o,y:s,z:c});let T=(c-d)/S,E=o,D=s,O=c,k=y;for(let e=0;e0)return void this.addThickLine(e,t);let r=new Xx;r.setAttribute(`position`,new Ux(e,3)),this.disposables.push(r);let i=new UC({color:t});this.disposables.push(i);let a=new ZC(r,i);(n=this.group)==null||n.add(a)}addTubeLine(e,t,n=.2){let r=[],i=[];for(let t=0;t{var r;let i=new ile(e,this.extrusionWidth,this.lineHeight||n,4);(r=this._geometries)[t]||(r[t]=[]),this._geometries[t].push(i)}))}addThickLine(e,t){var n;if(!e.length||!this.lineWidth)return;let r=new Rw;this.disposables.push(r);let i=new Fw({color:t,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(i),r.setPositions(e);let a=new ele(r,i);(n=this.group)==null||n.add(a)}dispose(){this.disposables.forEach((e=>e.dispose())),this.disposables=[],this.controls.dispose(),this.renderer.dispose(),this.cancelAnimation()}cancelAnimation(){this.animationFrameId!==void 0&&cancelAnimationFrame(this.animationFrameId),this.animationFrameId=void 0}_enableDropHandler(){console.warn(`Drag and drop is deprecated as a library feature. See the demo how to implement your own.`),this.canvas.addEventListener(`dragover`,(e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`),this.canvas.classList.add(`dragging`)})),this.canvas.addEventListener(`dragleave`,(e=>{e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove(`dragging`)})),this.canvas.addEventListener(`drop`,(e=>ww(this,void 0,void 0,(function*(){e.stopPropagation(),e.preventDefault(),this.canvas.classList.remove(`dragging`);let t=(e.dataTransfer?.files??[])[0];this.clear(),yield this._readFromStream(t.stream()),this.render()}))))}batchGeometries(){if(this._geometries)for(let e in this._geometries){let t=this.createBatchMesh(parseInt(e));for(;this._geometries[e].length>0;){let n=this._geometries[e].pop();t.addGeometry(n)}}}createBatchMesh(e){var t;let n=this._geometries[e],r=new fce({color:e,wireframe:this._wireframe});this.disposables.push(r);let i=n.reduce(((e,t)=>3*t.attributes.position.count+e),0),a=new lce(n.length,i,void 0,r);return this.disposables.push(a),(t=this.group)==null||t.add(a),a}_readFromStream(e){return ww(this,void 0,void 0,(function*(){let t=e.getReader(),n,r=``,i=0;do{console.debug(`reading from stream`),n=yield t.read(),i+=n.value?.length??0;let e=(a=n.value,new TextDecoder(`utf-8`).decode(a)),o=e.lastIndexOf(` +`),s=e.slice(0,o);this.parser.parseGCode(r+s),r=e.slice(o)}while(!n.done);var a;console.debug(`read from stream`,i)}))}initGui(){typeof this.devMode==`boolean`&&!0===this.devMode?this.devGui=new tT(this):typeof this.devMode==`object`&&(this.devGui=new tT(this,this.devMode))}initStats(){this.stats&&(typeof this.devMode==`object`&&(this.statsContainer=this.devMode.statsContainer),(this.statsContainer??document.body).appendChild(this.stats.dom),this.stats.dom.classList.add(`stats`),this.initGui())}};iT.defaultExtrusionColor=new Fx(`hotpink`);function aT({gcodeUrl:e,buildVolume:t={x:256,y:256,z:256},filamentColors:n,className:r=``}){let i=(0,y.useRef)(null),a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=(0,y.useRef)(!1),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(0),[g,_]=(0,y.useState)(0);(0,y.useEffect)(()=>{if(!i.current||s.current)return;s.current=!0;let r=i.current,c=r.parentElement?.getBoundingClientRect();c&&(r.width=c.width,r.height=c.height);let u=n&&n.length>1,f=n?.[0]||`#00ae42`,m=new iT({canvas:r,buildVolume:t,backgroundColor:1710618,extrusionColor:u?n:f,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.current=m;let g={},v=Ku();v&&(g.Authorization=`Bearer ${v}`),fetch(e,{headers:g}).then(async e=>{if(!e.ok)throw e.status===404&&(await e.json().catch(()=>({}))).detail?.includes(`sliced`)?(p(!0),Error(`not_sliced`)):Error(`Failed to load G-code`);return e.text()}).then(e=>{let t=new Set,r=/^(\s*)T(\d+)(\s*;.*)?$/gim,i;for(;(i=r.exec(e))!==null;){let e=parseInt(i[2],10);e<=15&&t.add(e)}let a=new Map,o=Array.from(t).sort((e,t)=>e-t);o.forEach((e,t)=>{a.set(e,t%8)});let s=[];o.forEach((e,t)=>{let r=n?.[e]||`#00ae42`;s[t%8]=r});let c=e.split(` `).map(e=>{let t=e.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(t){let n=parseInt(t[2],10);if(n>15)return`; FILTERED: ${e.trim()}`;let r=a.get(n)??0;return`${t[1]}T${r}${t[3]||``}`}return e}).join(` -`);s.length>0&&(m.extrusionColor=s),m.processGCode(c);let u=m.layers?.length||0;_(u),h(u),m.render(),l(!1)}).catch(e=>{e.message!==`not_sliced`&&d(e.message),l(!1)});let y=()=>{if(r.parentElement&&a.current){let e=r.parentElement.getBoundingClientRect();r.width=e.width,r.height=e.height,a.current.resize()}};return window.addEventListener(`resize`,y),()=>{window.removeEventListener(`resize`,y),o.current&&cancelAnimationFrame(o.current),a.current&&=(a.current.dispose(),null),s.current=!1}},[e,(0,y.useMemo)(()=>JSON.stringify(n),[n])]);let v=(0,y.useCallback)(e=>{if(!a.current)return;let t=Math.max(1,Math.min(e,g));h(t),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=t,a.current.render())})},[g]);return(0,K.jsxs)(`div`,{className:`relative flex flex-col h-full ${r}`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsx)(`canvas`,{ref:i,className:`w-full h-full`}),c&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:`Loading G-code...`})]})}),f&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsxs)(`div`,{className:`text-center max-w-sm px-4`,children:[(0,K.jsx)(ec,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium mb-2`,children:`G-code not available`}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:`This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer.`})]})}),u&&!f&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(`div`,{className:`text-center text-red-400`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:u})})})]}),!c&&!u&&!f&&g>0&&(0,K.jsx)(`div`,{className:`mt-4 px-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`button`,{onClick:()=>v(m-1),disabled:m<=1,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)(`input`,{type:`range`,min:1,max:g,value:m,onChange:e=>{v(parseInt(e.target.value,10))},className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green`}),(0,K.jsx)(`button`,{onClick:()=>v(m+1),disabled:m>=g,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray min-w-[80px] text-right`,children:[m,` / `,g]})]})})]})}function ole({printerId:e,filePath:t,filename:n,onClose:r}){let[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),f=n.toLowerCase().split(`.`).pop()||``,p=f===`3mf`||f===`stl`,m=f===`gcode`||f===`3mf`;(0,y.useEffect)(()=>{a(p?`3d`:m?`gcode`:null)},[p,m]),(0,y.useEffect)(()=>{s([]),d(null),p&&(l(!0),Q.getPrinterFilePlates(e,t).then(e=>s(e.plates||[])).catch(()=>s([])).finally(()=>l(!1)))},[t,p,e]);let h=o.length>1,g=u==null?null:o.find(e=>e.index===u)??null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6`,onClick:r,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate flex-1 mr-4`,children:n}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>p&&a(`3d`),disabled:!p,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i===`3d`?`text-bambu-green border-b-2 border-bambu-green`:p?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),`3D Model`,!p&&(0,K.jsx)(`span`,{className:`text-xs`,children:`(not available)`})]}),(0,K.jsxs)(`button`,{onClick:()=>m&&a(`gcode`),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i===`gcode`?`text-bambu-green border-b-2 border-bambu-green`:m?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),`G-code Preview`,!m&&(0,K.jsx)(`span`,{className:`text-xs`,children:`(not sliced)`})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden p-4`,children:i===`3d`&&p?(0,K.jsxs)(`div`,{className:`w-full h-full flex flex-col gap-3`,children:[h&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),`Plates`,c&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${u==null?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:`All Plates`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[o.length,` plate`,o.length===1?``:`s`]})]}),u==null&&(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]}),o.map(n=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(n.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${u===n.index?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[n.has_thumbnail?(0,K.jsx)(`img`,{src:Q.getPrinterFilePlateThumbnail(e,n.index,t),alt:`Plate ${n.index}`,className:`w-10 h-10 rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:n.name||`Plate ${n.index}`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:n.objects.length>0?n.objects.slice(0,2).join(`, `)+(n.objects.length>2?`…`:``):`${n.filaments.length} filament${n.filaments.length===1?``:`s`}`})]}),u===n.index&&(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]},n.index))]}),g&&(0,K.jsxs)(`div`,{className:`mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1`,children:[(0,K.jsxs)(`span`,{children:[`Plate `,g.index]}),g.print_time_seconds!=null&&(0,K.jsxs)(`span`,{children:[`ETA `,Math.round(g.print_time_seconds/60),` min`]}),g.filament_used_grams!=null&&(0,K.jsxs)(`span`,{children:[g.filament_used_grams.toFixed(1),` g`]}),g.filaments.length>0&&(0,K.jsxs)(`span`,{children:[g.filaments.length,` filament`,g.filaments.length===1?``:`s`]})]})]}),(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(ly,{url:Q.getPrinterFileDownloadUrl(e,t),fileType:f,selectedPlateId:u,className:`w-full h-full`})})]}):i===`gcode`&&m?(0,K.jsx)(iT,{gcodeUrl:Q.getPrinterFileGcodeUrl(e,t),className:`w-full h-full`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:`No preview available for this file`})})]})})}function aT(e){if(e===0)return`0 GB`;let t=e/(1024*1024*1024);return t>=1?`${t.toFixed(1)} GB`:`${(e/(1024*1024)).toFixed(0)} MB`}function sle(e,t){if(t)return fc;switch(e.toLowerCase().split(`.`).pop()||``){case`3mf`:return Qs;case`gcode`:return nc;case`mp4`:case`avi`:return ic;case`png`:case`jpg`:case`jpeg`:return Mc;default:return rc}}var cle=[{value:`name-asc`,label:`Name (A-Z)`},{value:`name-desc`,label:`Name (Z-A)`},{value:`size-asc`,label:`Size (smallest)`},{value:`size-desc`,label:`Size (largest)`},{value:`date-asc`,label:`Date (oldest)`},{value:`date-desc`,label:`Date (newest)`}];function lle({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),{showToast:i}=Td(),a=no(),[o,s]=(0,y.useState)(`/`),[c,l]=(0,y.useState)(new Set),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)([]),[m,h]=(0,y.useState)(`name-asc`),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let{data:x,isLoading:S,refetch:C}=q({queryKey:[`printerFiles`,e,o],queryFn:()=>Q.getPrinterFiles(e,o)}),{data:w}=q({queryKey:[`printerStorage`,e],queryFn:()=>Q.getPrinterStorage(e),staleTime:3e4}),T=J({mutationFn:async t=>{for(let n of t)await Q.deletePrinterFile(e,n)},onSuccess:()=>{i(r(`printerFiles.toast.filesDeleted`,{count:f.length})),a.invalidateQueries({queryKey:[`printerFiles`,e]}),l(new Set),p([])},onError:e=>{i(r(`printerFiles.toast.deleteFailed`,{error:e.message}),`error`)}}),E=e=>{s(e),l(new Set)},D=()=>{if(o===`/`)return;let e=o.split(`/`).filter(Boolean);e.pop(),s(e.length?`/`+e.join(`/`):`/`),l(new Set)},O=(e,t)=>{t.stopPropagation(),l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},k=()=>{if(!x?.files)return;let e=x.files.filter(e=>!e.is_directory&&(!u||e.name.toLowerCase().includes(u.toLowerCase()))).map(e=>e.path);l(new Set(e))},A=()=>{l(new Set)},j=async()=>{if(c.size===0)return;let n=Array.from(c);if(n.length===1){Q.downloadPrinterFile(e,n[0]).catch(e=>{console.error(`Printer file download failed:`,e)}),l(new Set);return}_({current:0,total:n.length});try{let r=await Q.downloadPrinterFilesAsZip(e,n),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`${t.replace(/[^a-zA-Z0-9]/g,`_`)}-files.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),i(`Downloaded ${n.length} files as ZIP`),l(new Set)}catch(e){i(`Download failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}finally{_(null)}},M=()=>{c.size!==0&&p(Array.from(c))};return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:n,children:[(0,K.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(wc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`printerFiles.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[w&&(w.used_bytes!=null||w.free_bytes!=null)&&(0,K.jsxs)(`div`,{className:`text-sm text-bambu-gray flex items-center gap-2`,children:[w.used_bytes!=null&&(0,K.jsxs)(`span`,{children:[r(`printerFiles.storageUsed`),` `,aT(w.used_bytes)]}),w.used_bytes!=null&&w.free_bytes!=null&&(0,K.jsx)(`span`,{className:`text-bambu-dark-tertiary`,children:`|`}),w.free_bytes!=null&&(0,K.jsxs)(`span`,{children:[r(`printerFiles.storageFree`),` `,aT(w.free_bytes)]})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:`Close file manager`,"aria-label":`Close file manager`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[[{path:`/`,label:`Root`},{path:`/cache`,label:`Cache`},{path:`/model`,label:`Models`},{path:`/timelapse`,label:`Timelapse`}].map(e=>(0,K.jsx)(`button`,{onClick:()=>{E(e.path),d(``)},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===e.path?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:e.label},e.path)),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:r(`printerFiles.filterPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`relative flex items-center gap-1`,children:[(0,K.jsx)(Po,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),className:`appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer`,title:`Sort files`,"aria-label":`Sort files`,children:cle.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>C(),disabled:S,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${S?`animate-spin`:``}`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0`,children:[(0,K.jsx)(`button`,{onClick:D,disabled:o===`/`,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed`,title:`Go to parent folder`,"aria-label":`Go to parent folder`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`text-bambu-gray font-mono`,children:o})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 min-h-0`,children:S?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):x?.files?.length?(0,K.jsx)(`div`,{className:`space-y-1`,children:[...x.files].filter(e=>!u||e.name.toLowerCase().includes(u.toLowerCase())).sort((e,t)=>{if(e.is_directory&&!t.is_directory)return-1;if(!e.is_directory&&t.is_directory)return 1;switch(m){case`name-asc`:return e.name.localeCompare(t.name);case`name-desc`:return t.name.localeCompare(e.name);case`size-asc`:return e.size-t.size;case`size-desc`:return t.size-e.size;case`date-asc`:return(e.mtime?vf(e.mtime)?.getTime()??0:0)-(t.mtime?vf(t.mtime)?.getTime()??0:0);case`date-desc`:{let n=e.mtime?vf(e.mtime)?.getTime()??0:0;return(t.mtime?vf(t.mtime)?.getTime()??0:0)-n}default:return e.name.localeCompare(t.name)}}).map(e=>{let t=sle(e.name,e.is_directory),n=c.has(e.path);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${n?`bg-bambu-green/20 border border-bambu-green/50`:`hover:bg-bambu-dark-tertiary`}`,onClick:()=>{e.is_directory&&E(e.path)},children:[e.is_directory?null:(0,K.jsx)(`button`,{onClick:t=>O(e.path,t),className:`flex-shrink-0 text-bambu-gray hover:text-white`,children:n?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5`})}),(0,K.jsx)(t,{className:`w-5 h-5 flex-shrink-0 ${e.is_directory?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`flex-1 text-white truncate`,children:e.name}),!e.is_directory&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:Cd(e.size)}),(e.name.toLowerCase().endsWith(`.3mf`)||e.name.toLowerCase().endsWith(`.gcode`)||e.name.toLowerCase().endsWith(`.stl`))&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),b({path:e.path,name:e.name})},className:`p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`,title:`3D View`,children:(0,K.jsx)(Wo,{className:`w-4 h-4`})})]}),e.is_directory&&(0,K.jsx)(ss,{className:`w-4 h-4 text-bambu-gray rotate-180`})]},e.path)})}):(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:`No files in this directory`})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:c.size>0?`${c.size} selected`:u?`${x?.files?.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${x?.files?.length||0} items`:`${x?.files?.length||0} items`}),x?.files?.some(e=>!e.is_directory)&&(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:c.size>0?(0,K.jsxs)(`button`,{onClick:A,className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(au,{className:`w-4 h-4`}),`Deselect All`]}):(0,K.jsxs)(`button`,{onClick:k,className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),`Select All`]})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,disabled:c.size===0||g!==null,onClick:j,children:g?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),g.current,`/`,g.total]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download`,c.size>1?` (${c.size})`:``]})}),(0,K.jsxs)($,{variant:`secondary`,disabled:c.size===0||T.isPending,onClick:M,className:`text-red-400 hover:text-red-300`,children:[T.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),r(`printerFiles.deleteButton`),c.size>1?` (${c.size})`:``]})]})]})]}),f.length>0&&(0,K.jsx)(Ad,{title:f.length>1?r(`printerFiles.deleteFiles`,{count:f.length}):r(`fileManager.deleteFile`),message:f.length>1?r(`printerFiles.deleteFilesConfirm`,{count:f.length}):r(`printerFiles.deleteFileConfirm`,{name:f[0].split(`/`).pop()}),confirmText:r(`common.delete`),variant:`danger`,onConfirm:()=>{T.mutate(f)},onCancel:()=>p([])}),v&&(0,K.jsx)(ole,{printerId:e,filePath:v.path,filename:v.name,onClose:()=>b(null)})]})}function oT({on:e,className:t=`w-5 h-5`}){let n=e?`#facc15`:`none`,r=e?`#78350f`:`currentColor`;return(0,K.jsxs)(`svg`,{viewBox:`0 0 32 32`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:[(0,K.jsxs)(`g`,{stroke:r,opacity:+!!e,children:[(0,K.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,K.jsx)(`line`,{x1:`6.1`,y1:`6.1`,x2:`8.9`,y2:`8.9`}),(0,K.jsx)(`line`,{x1:`25.9`,y1:`6.1`,x2:`23.1`,y2:`8.9`}),(0,K.jsx)(`line`,{x1:`2`,y1:`16`,x2:`6`,y2:`16`}),(0,K.jsx)(`line`,{x1:`30`,y1:`16`,x2:`26`,y2:`16`})]}),(0,K.jsx)(`path`,{d:`M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24`,fill:n,stroke:r}),(0,K.jsx)(`path`,{d:`M12 24h8`,stroke:r}),(0,K.jsx)(`path`,{d:`M12 27h8`,stroke:r}),(0,K.jsx)(`path`,{d:`M13 30h6`,stroke:r})]})}var sT=({className:e})=>(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,children:[(0,K.jsx)(`rect`,{x:`2`,y:`15`,width:`5`,height:`5`,rx:`0.5`}),(0,K.jsx)(`rect`,{x:`9.5`,y:`15`,width:`5`,height:`5`,rx:`0.5`,fill:`currentColor`,opacity:`0.3`}),(0,K.jsx)(`rect`,{x:`17`,y:`15`,width:`5`,height:`5`,rx:`0.5`}),(0,K.jsx)(`path`,{d:`M4 12 C4 6, 14 6, 14 12`}),(0,K.jsx)(`polyline`,{points:`12,10 14,12 12,14`})]});function cT({printerId:e,isOpen:t,onClose:n}){let{t:r}=W(),{showToast:i}=Td(),{hasPermission:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),{data:u}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4,enabled:t}),{data:d,refetch:f}=q({queryKey:[`printableObjects`,e],queryFn:()=>Q.getPrintableObjects(e),enabled:t,refetchInterval:t?5e3:!1}),p=J({mutationFn:t=>Q.skipObjects(e,t),onSuccess:e=>{i(e.message||r(`printers.skipObjects.objectsSkipped`)),s(null),f()},onError:e=>i(e.message||r(`printers.toast.failedToSkipObjects`),`error`)});return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&(c?l(!1):n())},tabIndex:-1,ref:e=>e?.focus(),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/50 z-0`}),(0,K.jsxs)(`div`,{className:`relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sT,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:r(`printers.skipObjects.title`)})]}),(0,K.jsx)(`button`,{onClick:n,className:`p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),d?d.objects.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 px-4 text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:r(`printers.noObjectsFound`)}),(0,K.jsx)(`p`,{className:`text-xs mt-1 opacity-70`,children:r(`printers.objectsLoadedOnPrintStart`)})]}):(0,K.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center`,children:(0,K.jsx)(ol,{className:`w-4 h-4 text-blue-500 dark:text-blue-400`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-blue-600 dark:text-blue-300`,children:r(`printers.skipObjects.matchIdsInfo`)}),(0,K.jsx)(`p`,{className:`text-[10px] text-blue-500/70 dark:text-blue-300/60`,children:r(`printers.skipObjects.printerShowsIds`)})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray`,children:[d.skipped_count,`/`,d.total,` `,r(`printers.skipObjects.skipped`)]})]}),(u?.layer_num??0)<=1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:r(`printers.skipObjects.waitForLayer`,{layer:u?.layer_num??0})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`relative cursor-pointer group`,onClick:()=>l(!0),children:[u?.cover_url?(0,K.jsx)(`img`,{src:Xu(`${u.cover_url}?view=top`),alt:r(`printers.printPreview`),className:`w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600`}):(0,K.jsx)(`div`,{className:`w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-8 h-8 text-gray-300 dark:text-bambu-gray/30`})}),(0,K.jsx)(`div`,{className:`absolute top-2 right-2 p-1 bg-black/60 rounded opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)($c,{className:`w-3.5 h-3.5 text-white`})}),d.objects.length>0&&(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,children:d.objects.map((e,t)=>{let n,r;if(e.x!=null&&e.y!=null&&d.bbox_all){let[t,i,a,o]=d.bbox_all,s=a-t,c=o-i;n=8+(e.x-t)/s*84,r=8+(o-e.y)/c*84,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r))}else if(e.x!=null&&e.y!=null)n=e.x/256*100,r=100-e.y/256*100,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r));else{let e=Math.ceil(Math.sqrt(d.objects.length)),i=Math.floor(t/e),a=t%e,o=Math.ceil(d.objects.length/e);n=15+70/e*a+35/e,r=15+70/o*i+35/o}return(0,K.jsx)(`div`,{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${e.skipped?`bg-red-500 text-white line-through`:`bg-bambu-green text-black`}`,style:{left:`${n}%`,top:`${r}%`,transform:`translate(-50%, -50%)`},title:e.name,children:e.id},e.id)})}),(0,K.jsx)(`div`,{className:`absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm`,children:r(`printers.skipObjects.activeCount`,{count:d.objects.filter(e=>!e.skipped).length})})]})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0 overflow-y-auto`,children:d.objects.map(e=>(0,K.jsxs)(`div`,{className:` +`);s.length>0&&(m.extrusionColor=s),m.processGCode(c);let u=m.layers?.length||0;_(u),h(u),m.render(),l(!1)}).catch(e=>{e.message!==`not_sliced`&&d(e.message),l(!1)});let y=()=>{if(r.parentElement&&a.current){let e=r.parentElement.getBoundingClientRect();r.width=e.width,r.height=e.height,a.current.resize()}};return window.addEventListener(`resize`,y),()=>{window.removeEventListener(`resize`,y),o.current&&cancelAnimationFrame(o.current),a.current&&=(a.current.dispose(),null),s.current=!1}},[e,(0,y.useMemo)(()=>JSON.stringify(n),[n])]);let v=(0,y.useCallback)(e=>{if(!a.current)return;let t=Math.max(1,Math.min(e,g));h(t),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=t,a.current.render())})},[g]);return(0,K.jsxs)(`div`,{className:`relative flex flex-col h-full ${r}`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsx)(`canvas`,{ref:i,className:`w-full h-full`}),c&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:`Loading G-code...`})]})}),f&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsxs)(`div`,{className:`text-center max-w-sm px-4`,children:[(0,K.jsx)(ec,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium mb-2`,children:`G-code not available`}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:`This file hasn't been sliced yet. G-code preview is only available after slicing in Bambu Studio or Orca Slicer.`})]})}),u&&!f&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-bambu-dark/80`,children:(0,K.jsx)(`div`,{className:`text-center text-red-400`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:u})})})]}),!c&&!u&&!f&&g>0&&(0,K.jsx)(`div`,{className:`mt-4 px-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`button`,{onClick:()=>v(m-1),disabled:m<=1,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)(`input`,{type:`range`,min:1,max:g,value:m,onChange:e=>{v(parseInt(e.target.value,10))},className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer accent-bambu-green`}),(0,K.jsx)(`button`,{onClick:()=>v(m+1),disabled:m>=g,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray min-w-[80px] text-right`,children:[m,` / `,g]})]})})]})}function ale({printerId:e,filePath:t,filename:n,onClose:r}){let[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),f=n.toLowerCase().split(`.`).pop()||``,p=f===`3mf`||f===`stl`,m=f===`gcode`||f===`3mf`;(0,y.useEffect)(()=>{a(p?`3d`:m?`gcode`:null)},[p,m]),(0,y.useEffect)(()=>{s([]),d(null),p&&(l(!0),Q.getPrinterFilePlates(e,t).then(e=>s(e.plates||[])).catch(()=>s([])).finally(()=>l(!1)))},[t,p,e]);let h=o.length>1,g=u==null?null:o.find(e=>e.index===u)??null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6`,onClick:r,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate flex-1 mr-4`,children:n}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>p&&a(`3d`),disabled:!p,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i===`3d`?`text-bambu-green border-b-2 border-bambu-green`:p?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),`3D Model`,!p&&(0,K.jsx)(`span`,{className:`text-xs`,children:`(not available)`})]}),(0,K.jsxs)(`button`,{onClick:()=>m&&a(`gcode`),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i===`gcode`?`text-bambu-green border-b-2 border-bambu-green`:m?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),`G-code Preview`,!m&&(0,K.jsx)(`span`,{className:`text-xs`,children:`(not sliced)`})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden p-4`,children:i===`3d`&&p?(0,K.jsxs)(`div`,{className:`w-full h-full flex flex-col gap-3`,children:[h&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),`Plates`,c&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${u==null?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:`All Plates`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[o.length,` plate`,o.length===1?``:`s`]})]}),u==null&&(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]}),o.map(n=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>d(n.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${u===n.index?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[n.has_thumbnail?(0,K.jsx)(`img`,{src:Q.getPrinterFilePlateThumbnail(e,n.index,t),alt:`Plate ${n.index}`,className:`w-10 h-10 rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:n.name||`Plate ${n.index}`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:n.objects.length>0?n.objects.slice(0,2).join(`, `)+(n.objects.length>2?`…`:``):`${n.filaments.length} filament${n.filaments.length===1?``:`s`}`})]}),u===n.index&&(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]},n.index))]}),g&&(0,K.jsxs)(`div`,{className:`mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1`,children:[(0,K.jsxs)(`span`,{children:[`Plate `,g.index]}),g.print_time_seconds!=null&&(0,K.jsxs)(`span`,{children:[`ETA `,Math.round(g.print_time_seconds/60),` min`]}),g.filament_used_grams!=null&&(0,K.jsxs)(`span`,{children:[g.filament_used_grams.toFixed(1),` g`]}),g.filaments.length>0&&(0,K.jsxs)(`span`,{children:[g.filaments.length,` filament`,g.filaments.length===1?``:`s`]})]})]}),(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(ly,{url:Q.getPrinterFileDownloadUrl(e,t),fileType:f,selectedPlateId:u,className:`w-full h-full`})})]}):i===`gcode`&&m?(0,K.jsx)(aT,{gcodeUrl:Q.getPrinterFileGcodeUrl(e,t),className:`w-full h-full`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:`No preview available for this file`})})]})})}function oT(e){if(e===0)return`0 GB`;let t=e/(1024*1024*1024);return t>=1?`${t.toFixed(1)} GB`:`${(e/(1024*1024)).toFixed(0)} MB`}function ole(e,t){if(t)return fc;switch(e.toLowerCase().split(`.`).pop()||``){case`3mf`:return Qs;case`gcode`:return nc;case`mp4`:case`avi`:return ic;case`png`:case`jpg`:case`jpeg`:return Mc;default:return rc}}var sle=[{value:`name-asc`,label:`Name (A-Z)`},{value:`name-desc`,label:`Name (Z-A)`},{value:`size-asc`,label:`Size (smallest)`},{value:`size-desc`,label:`Size (largest)`},{value:`date-asc`,label:`Date (oldest)`},{value:`date-desc`,label:`Date (newest)`}];function cle({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),{showToast:i}=Td(),a=no(),[o,s]=(0,y.useState)(`/`),[c,l]=(0,y.useState)(new Set),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)([]),[m,h]=(0,y.useState)(`name-asc`),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let{data:x,isLoading:S,refetch:C}=q({queryKey:[`printerFiles`,e,o],queryFn:()=>Q.getPrinterFiles(e,o)}),{data:w}=q({queryKey:[`printerStorage`,e],queryFn:()=>Q.getPrinterStorage(e),staleTime:3e4}),T=J({mutationFn:async t=>{for(let n of t)await Q.deletePrinterFile(e,n)},onSuccess:()=>{i(r(`printerFiles.toast.filesDeleted`,{count:f.length})),a.invalidateQueries({queryKey:[`printerFiles`,e]}),l(new Set),p([])},onError:e=>{i(r(`printerFiles.toast.deleteFailed`,{error:e.message}),`error`)}}),E=e=>{s(e),l(new Set)},D=()=>{if(o===`/`)return;let e=o.split(`/`).filter(Boolean);e.pop(),s(e.length?`/`+e.join(`/`):`/`),l(new Set)},O=(e,t)=>{t.stopPropagation(),l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},k=()=>{if(!x?.files)return;let e=x.files.filter(e=>!e.is_directory&&(!u||e.name.toLowerCase().includes(u.toLowerCase()))).map(e=>e.path);l(new Set(e))},A=()=>{l(new Set)},j=async()=>{if(c.size===0)return;let n=Array.from(c);if(n.length===1){Q.downloadPrinterFile(e,n[0]).catch(e=>{console.error(`Printer file download failed:`,e)}),l(new Set);return}_({current:0,total:n.length});try{let r=await Q.downloadPrinterFilesAsZip(e,n),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`${t.replace(/[^a-zA-Z0-9]/g,`_`)}-files.zip`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),i(`Downloaded ${n.length} files as ZIP`),l(new Set)}catch(e){i(`Download failed: ${e instanceof Error?e.message:`Unknown error`}`,`error`)}finally{_(null)}},M=()=>{c.size!==0&&p(Array.from(c))};return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:n,children:[(0,K.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(wc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`printerFiles.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[w&&(w.used_bytes!=null||w.free_bytes!=null)&&(0,K.jsxs)(`div`,{className:`text-sm text-bambu-gray flex items-center gap-2`,children:[w.used_bytes!=null&&(0,K.jsxs)(`span`,{children:[r(`printerFiles.storageUsed`),` `,oT(w.used_bytes)]}),w.used_bytes!=null&&w.free_bytes!=null&&(0,K.jsx)(`span`,{className:`text-bambu-dark-tertiary`,children:`|`}),w.free_bytes!=null&&(0,K.jsxs)(`span`,{children:[r(`printerFiles.storageFree`),` `,oT(w.free_bytes)]})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:`Close file manager`,"aria-label":`Close file manager`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[[{path:`/`,label:`Root`},{path:`/cache`,label:`Cache`},{path:`/model`,label:`Models`},{path:`/timelapse`,label:`Timelapse`}].map(e=>(0,K.jsx)(`button`,{onClick:()=>{E(e.path),d(``)},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===e.path?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:e.label},e.path)),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:r(`printerFiles.filterPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`relative flex items-center gap-1`,children:[(0,K.jsx)(Po,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`select`,{value:m,onChange:e=>h(e.target.value),className:`appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer`,title:`Sort files`,"aria-label":`Sort files`,children:sle.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>C(),disabled:S,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${S?`animate-spin`:``}`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0`,children:[(0,K.jsx)(`button`,{onClick:D,disabled:o===`/`,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed`,title:`Go to parent folder`,"aria-label":`Go to parent folder`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`text-bambu-gray font-mono`,children:o})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 min-h-0`,children:S?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):x?.files?.length?(0,K.jsx)(`div`,{className:`space-y-1`,children:[...x.files].filter(e=>!u||e.name.toLowerCase().includes(u.toLowerCase())).sort((e,t)=>{if(e.is_directory&&!t.is_directory)return-1;if(!e.is_directory&&t.is_directory)return 1;switch(m){case`name-asc`:return e.name.localeCompare(t.name);case`name-desc`:return t.name.localeCompare(e.name);case`size-asc`:return e.size-t.size;case`size-desc`:return t.size-e.size;case`date-asc`:return(e.mtime?vf(e.mtime)?.getTime()??0:0)-(t.mtime?vf(t.mtime)?.getTime()??0:0);case`date-desc`:{let n=e.mtime?vf(e.mtime)?.getTime()??0:0;return(t.mtime?vf(t.mtime)?.getTime()??0:0)-n}default:return e.name.localeCompare(t.name)}}).map(e=>{let t=ole(e.name,e.is_directory),n=c.has(e.path);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${n?`bg-bambu-green/20 border border-bambu-green/50`:`hover:bg-bambu-dark-tertiary`}`,onClick:()=>{e.is_directory&&E(e.path)},children:[e.is_directory?null:(0,K.jsx)(`button`,{onClick:t=>O(e.path,t),className:`flex-shrink-0 text-bambu-gray hover:text-white`,children:n?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5`})}),(0,K.jsx)(t,{className:`w-5 h-5 flex-shrink-0 ${e.is_directory?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`flex-1 text-white truncate`,children:e.name}),!e.is_directory&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:Cd(e.size)}),(e.name.toLowerCase().endsWith(`.3mf`)||e.name.toLowerCase().endsWith(`.gcode`)||e.name.toLowerCase().endsWith(`.stl`))&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),b({path:e.path,name:e.name})},className:`p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`,title:`3D View`,children:(0,K.jsx)(Wo,{className:`w-4 h-4`})})]}),e.is_directory&&(0,K.jsx)(ss,{className:`w-4 h-4 text-bambu-gray rotate-180`})]},e.path)})}):(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:`No files in this directory`})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:c.size>0?`${c.size} selected`:u?`${x?.files?.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())).length||0} of ${x?.files?.length||0} items`:`${x?.files?.length||0} items`}),x?.files?.some(e=>!e.is_directory)&&(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:c.size>0?(0,K.jsxs)(`button`,{onClick:A,className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(au,{className:`w-4 h-4`}),`Deselect All`]}):(0,K.jsxs)(`button`,{onClick:k,className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),`Select All`]})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,disabled:c.size===0||g!==null,onClick:j,children:g?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),g.current,`/`,g.total]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download`,c.size>1?` (${c.size})`:``]})}),(0,K.jsxs)($,{variant:`secondary`,disabled:c.size===0||T.isPending,onClick:M,className:`text-red-400 hover:text-red-300`,children:[T.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),r(`printerFiles.deleteButton`),c.size>1?` (${c.size})`:``]})]})]})]}),f.length>0&&(0,K.jsx)(Ad,{title:f.length>1?r(`printerFiles.deleteFiles`,{count:f.length}):r(`fileManager.deleteFile`),message:f.length>1?r(`printerFiles.deleteFilesConfirm`,{count:f.length}):r(`printerFiles.deleteFileConfirm`,{name:f[0].split(`/`).pop()}),confirmText:r(`common.delete`),variant:`danger`,onConfirm:()=>{T.mutate(f)},onCancel:()=>p([])}),v&&(0,K.jsx)(ale,{printerId:e,filePath:v.path,filename:v.name,onClose:()=>b(null)})]})}function sT({on:e,className:t=`w-5 h-5`}){let n=e?`#facc15`:`none`,r=e?`#78350f`:`currentColor`;return(0,K.jsxs)(`svg`,{viewBox:`0 0 32 32`,fill:`none`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:[(0,K.jsxs)(`g`,{stroke:r,opacity:+!!e,children:[(0,K.jsx)(`line`,{x1:`16`,y1:`2`,x2:`16`,y2:`6`}),(0,K.jsx)(`line`,{x1:`6.1`,y1:`6.1`,x2:`8.9`,y2:`8.9`}),(0,K.jsx)(`line`,{x1:`25.9`,y1:`6.1`,x2:`23.1`,y2:`8.9`}),(0,K.jsx)(`line`,{x1:`2`,y1:`16`,x2:`6`,y2:`16`}),(0,K.jsx)(`line`,{x1:`30`,y1:`16`,x2:`26`,y2:`16`})]}),(0,K.jsx)(`path`,{d:`M12 24v-2.3c0-.9-.4-1.7-1-2.3C9.2 17.6 8 15.4 8 13c0-4.4 3.6-8 8-8s8 3.6 8 8c0 2.4-1.2 4.6-3 6.4-.6.6-1 1.4-1 2.3V24`,fill:n,stroke:r}),(0,K.jsx)(`path`,{d:`M12 24h8`,stroke:r}),(0,K.jsx)(`path`,{d:`M12 27h8`,stroke:r}),(0,K.jsx)(`path`,{d:`M13 30h6`,stroke:r})]})}var cT=({className:e})=>(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e,children:[(0,K.jsx)(`rect`,{x:`2`,y:`15`,width:`5`,height:`5`,rx:`0.5`}),(0,K.jsx)(`rect`,{x:`9.5`,y:`15`,width:`5`,height:`5`,rx:`0.5`,fill:`currentColor`,opacity:`0.3`}),(0,K.jsx)(`rect`,{x:`17`,y:`15`,width:`5`,height:`5`,rx:`0.5`}),(0,K.jsx)(`path`,{d:`M4 12 C4 6, 14 6, 14 12`}),(0,K.jsx)(`polyline`,{points:`12,10 14,12 12,14`})]});function lT({printerId:e,isOpen:t,onClose:n}){let{t:r}=W(),{showToast:i}=Td(),{hasPermission:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),{data:u}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4,enabled:t}),{data:d,refetch:f}=q({queryKey:[`printableObjects`,e],queryFn:()=>Q.getPrintableObjects(e),enabled:t,refetchInterval:t?5e3:!1}),p=J({mutationFn:t=>Q.skipObjects(e,t),onSuccess:e=>{i(e.message||r(`printers.skipObjects.objectsSkipped`)),s(null),f()},onError:e=>i(e.message||r(`printers.toast.failedToSkipObjects`),`error`)});return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,onClick:n,onKeyDown:e=>{e.key===`Escape`&&(c?l(!1):n())},tabIndex:-1,ref:e=>e?.focus(),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/50 z-0`}),(0,K.jsxs)(`div`,{className:`relative z-10 bg-white dark:bg-bambu-dark border border-gray-200 dark:border-bambu-dark-tertiary rounded-xl shadow-2xl w-[560px] max-h-[85vh] flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(cT,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:r(`printers.skipObjects.title`)})]}),(0,K.jsx)(`button`,{onClick:n,className:`p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),d?d.objects.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 px-4 text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:r(`printers.noObjectsFound`)}),(0,K.jsx)(`p`,{className:`text-xs mt-1 opacity-70`,children:r(`printers.objectsLoadedOnPrintStart`)})]}):(0,K.jsxs)(`div`,{className:`flex flex-col overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5 bg-blue-50 dark:bg-blue-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 rounded-lg bg-blue-100 dark:bg-blue-500/20 flex items-center justify-center`,children:(0,K.jsx)(ol,{className:`w-4 h-4 text-blue-500 dark:text-blue-400`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-blue-600 dark:text-blue-300`,children:r(`printers.skipObjects.matchIdsInfo`)}),(0,K.jsx)(`p`,{className:`text-[10px] text-blue-500/70 dark:text-blue-300/60`,children:r(`printers.skipObjects.printerShowsIds`)})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray`,children:[d.skipped_count,`/`,d.total,` `,r(`printers.skipObjects.skipped`)]})]}),(u?.layer_num??0)<=1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-amber-50 dark:bg-amber-500/10 border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:r(`printers.skipObjects.waitForLayer`,{layer:u?.layer_num??0})})]}),(0,K.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`w-52 flex-shrink-0 p-4 border-r border-gray-200 dark:border-bambu-dark-tertiary bg-gray-50 dark:bg-bambu-dark-secondary overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`relative cursor-pointer group`,onClick:()=>l(!0),children:[u?.cover_url?(0,K.jsx)(`img`,{src:Xu(`${u.cover_url}?view=top`),alt:r(`printers.printPreview`),className:`w-full aspect-square object-contain rounded-lg bg-gray-900 dark:bg-gray-900 border border-gray-300 dark:border-gray-600`}):(0,K.jsx)(`div`,{className:`w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-8 h-8 text-gray-300 dark:text-bambu-gray/30`})}),(0,K.jsx)(`div`,{className:`absolute top-2 right-2 p-1 bg-black/60 rounded opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)($c,{className:`w-3.5 h-3.5 text-white`})}),d.objects.length>0&&(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,children:d.objects.map((e,t)=>{let n,r;if(e.x!=null&&e.y!=null&&d.bbox_all){let[t,i,a,o]=d.bbox_all,s=a-t,c=o-i;n=8+(e.x-t)/s*84,r=8+(o-e.y)/c*84,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r))}else if(e.x!=null&&e.y!=null)n=e.x/256*100,r=100-e.y/256*100,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r));else{let e=Math.ceil(Math.sqrt(d.objects.length)),i=Math.floor(t/e),a=t%e,o=Math.ceil(d.objects.length/e);n=15+70/e*a+35/e,r=15+70/o*i+35/o}return(0,K.jsx)(`div`,{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${e.skipped?`bg-red-500 text-white line-through`:`bg-bambu-green text-black`}`,style:{left:`${n}%`,top:`${r}%`,transform:`translate(-50%, -50%)`},title:e.name,children:e.id},e.id)})}),(0,K.jsx)(`div`,{className:`absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm`,children:r(`printers.skipObjects.activeCount`,{count:d.objects.filter(e=>!e.skipped).length})})]})}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0 overflow-y-auto`,children:d.objects.map(e=>(0,K.jsxs)(`div`,{className:` flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0 ${e.skipped?`bg-red-50 dark:bg-red-500/10`:`hover:bg-gray-50 dark:hover:bg-bambu-dark/50`} `,children:[(0,K.jsxs)(`div`,{className:` w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center ${e.skipped?`bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40`:`bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40`} - `,children:[(0,K.jsx)(`span`,{className:`text-lg font-mono font-bold ${e.skipped?`text-red-500 dark:text-red-400`:`text-green-600 dark:text-bambu-green`}`,children:e.id}),(0,K.jsx)(`span`,{className:`text-[8px] uppercase tracking-wider ${e.skipped?`text-red-400/60`:`text-green-500/60 dark:text-bambu-green/60`}`,children:`ID`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`block text-sm truncate ${e.skipped?`text-red-500 dark:text-red-400 line-through`:`text-gray-900 dark:text-white`}`,children:e.name}),e.skipped&&(0,K.jsx)(`span`,{className:`text-[10px] text-red-400/60`,children:r(`printers.willBeSkipped`)})]}),e.skipped?(0,K.jsx)(`span`,{className:`px-4 py-2 text-xs text-red-500 dark:text-red-400/70 bg-red-100 dark:bg-red-500/10 rounded-lg`,children:r(`printers.skipObjects.skipped`)}):(0,K.jsx)(`button`,{onClick:()=>s({id:e.id,name:e.name}),disabled:p.isPending||(u?.layer_num??0)<=1||!a(`printers:control`),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(u?.layer_num??0)<=1||!a(`printers:control`)?`bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed`:`bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30`}`,title:a(`printers:control`)?(u?.layer_num??0)<=1?r(`printers.skipObjects.waitForLayer`,{layer:u?.layer_num??0}):r(`printers.skipObjects.skip`):r(`printers.permission.noControl`),children:r(`printers.skipObjects.skip`)})]},e.id))})]})]}):(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-5 h-5 animate-spin text-bambu-gray`})})]})]}),o&&(0,K.jsx)(Ad,{variant:`warning`,title:r(`printers.skipObjects.confirmTitle`),message:r(`printers.skipObjects.confirmMessage`,{name:o.name}),confirmText:r(`printers.skipObjects.skip`),isLoading:p.isPending,onConfirm:()=>p.mutate([o.id]),onCancel:()=>s(null)}),c&&d&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-60`,onClick:()=>l(!1),children:[(0,K.jsx)(`button`,{onClick:()=>l(!1),className:`absolute top-4 right-4 p-2 text-white/70 hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`relative max-w-[600px] max-h-[80vh] aspect-square`,onClick:e=>e.stopPropagation(),children:[u?.cover_url?(0,K.jsx)(`img`,{src:Xu(`${u.cover_url}?view=top`),alt:r(`printers.printPreview`),className:`w-full h-full object-contain rounded-lg bg-gray-900`}):(0,K.jsx)(`div`,{className:`w-full h-full rounded-lg bg-gray-800 flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-16 h-16 text-gray-500`})}),d.objects.length>0&&(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,children:d.objects.map((e,t)=>{let n,r;if(e.x!=null&&e.y!=null&&d.bbox_all){let[t,i,a,o]=d.bbox_all,s=a-t,c=o-i;n=8+(e.x-t)/s*84,r=8+(o-e.y)/c*84,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r))}else if(e.x!=null&&e.y!=null)n=e.x/256*100,r=100-e.y/256*100,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r));else{let e=Math.ceil(Math.sqrt(d.objects.length)),i=Math.floor(t/e),a=t%e,o=Math.ceil(d.objects.length/e);n=15+70/e*a+35/e,r=15+70/o*i+35/o}return(0,K.jsx)(`div`,{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${e.skipped?`bg-red-500 text-white line-through`:`bg-bambu-green text-black`}`,style:{left:`${n}%`,top:`${r}%`,transform:`translate(-50%, -50%)`},title:e.name,children:e.id},e.id)})}),(0,K.jsx)(`div`,{className:`absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm`,children:r(`printers.skipObjects.activeCount`,{count:d.objects.filter(e=>!e.skipped).length})})]})]})]}):null}function ule({status:e}){return e===`ok`?(0,K.jsx)(ms,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}):e===`failed`?(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`})}function lT({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),i=J({mutationFn:()=>Q.diagnoseCamera(e)});(0,y.useEffect)(()=>{i.mutate()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let a=i.data;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(cu,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:r(`camera.diagnose.modalTitle`,{name:t||``})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-4`,children:[i.isPending&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:r(`camera.diagnose.running`)})]}),i.isError&&(0,K.jsx)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`camera.diagnose.runFailed`,{error:i.error.message})}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{className:`space-y-2`,children:a.stages.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 bg-bambu-dark rounded-lg px-4 py-2.5`,children:[(0,K.jsx)(ule,{status:e.status}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white`,children:r(`camera.diagnose.stage.${e.name}`)}),e.code&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray font-mono`,children:e.code})]}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray tabular-nums flex-shrink-0`,children:[e.duration_ms,` ms`]})]},e.name))}),(0,K.jsx)(`div`,{className:a.overall_status===`ok`?`rounded-lg bg-bambu-green/10 border border-bambu-green/30 px-4 py-3 text-sm text-bambu-green`:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`camera.diagnose.summary.${a.summary_code}`,{defaultValue:r(`camera.diagnose.summary.unknown_failure`)})}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray space-y-0.5`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.protocol`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.protocol}),` • `,(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.port`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.port}),` • `,(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.profile`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.profile})]})})]})]}),(0,K.jsxs)(`div`,{className:`px-6 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>i.mutate(),disabled:i.isPending,className:`px-4 py-2 bg-bambu-dark hover:bg-bambu-dark-tertiary disabled:opacity-50 text-white text-sm rounded-lg transition-colors`,children:r(`camera.diagnose.retry`)}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 bg-bambu-green hover:bg-bambu-green/90 text-white text-sm rounded-lg transition-colors`,children:r(`common.close`)})]})]})})}var dle=`embeddedCameraState_`,uT=5,fle=2e3,ple=3e4,mle=5e3,dT={x:window.innerWidth-420,y:20,width:400,height:300};function hle({printerId:e,printerName:t,viewerIndex:n=0,onClose:r}){let{t:i}=W(),a=no(),{showToast:o}=Td(),{hasPermission:s}=dd(),c=`${dle}${e}`,[l,u]=(0,y.useState)(()=>{try{let e=localStorage.getItem(c);if(e){let t=JSON.parse(e);return{x:Math.min(Math.max(0,t.x),window.innerWidth-100),y:Math.min(Math.max(0,t.y),window.innerHeight-100),width:Math.max(200,Math.min(t.width,window.innerWidth-20)),height:Math.max(150,Math.min(t.height,window.innerHeight-20))}}}catch{}let e=n*30;return{...dT,x:Math.max(0,dT.x-e),y:Math.max(0,dT.y+e)}}),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)({x:0,y:0}),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(1),[w,T]=(0,y.useState)({x:0,y:0}),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)({x:0,y:0}),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(!0),[R,z]=(0,y.useState)(Date.now()),[B,V]=(0,y.useState)(0),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(0),ie=(0,y.useRef)(null),H=(0,y.useRef)(null),ae=(0,y.useRef)(null),oe=(0,y.useRef)(null),U=(0,y.useRef)(null),[se,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(!1),{data:de}=q({queryKey:[`printer`,e],queryFn:()=>Q.getPrinter(e),enabled:e>0}),{data:fe}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4,enabled:e>0}),pe=J({mutationFn:t=>Q.setChamberLight(e,t),onMutate:async t=>{await a.cancelQueries({queryKey:[`printerStatus`,e]});let n=a.getQueryData([`printerStatus`,e]);return a.setQueryData([`printerStatus`,e],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{o(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&a.setQueryData([`printerStatus`,e],r.previousStatus),o(t.message||i(`printers.toast.failedToControlChamberLight`),`error`)}}),me=(fe?.state===`RUNNING`||fe?.state===`PAUSE`)&&(fe?.printable_objects_count??0)>=2;(0,y.useEffect)(()=>{let e=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(l))},500);return()=>clearTimeout(e)},[l,c]);let he=(0,y.useRef)(!1);(0,y.useEffect)(()=>{he.current=!1;let t=`/api/v1/printers/${e}/camera/stop`,n=()=>{if(e>0&&!he.current){he.current=!0;let e={},n=Ku();n&&(e.Authorization=`Bearer ${n}`),fetch(t,{method:`POST`,keepalive:!0,headers:e}).catch(()=>{})}},r=H.current;return()=>{r&&(r.src=``),n(),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current),U.current&&clearInterval(U.current)}},[e]),(0,y.useEffect)(()=>{if(I){let e=setTimeout(()=>L(!1),3e3);return()=>clearTimeout(e)}},[I,R]);let ge=(0,y.useCallback)(()=>{if(B>=uT){te(!1),F(!0);return}let e=Math.min(fle*2**B,ple);te(!0),re(Math.ceil(e/1e3)),oe.current=setInterval(()=>{re(e=>e<=1?(oe.current&&clearInterval(oe.current),0):e-1)},1e3),ae.current=setTimeout(()=>{V(e=>e+1),te(!1),L(!0),F(!1),H.current&&(H.current.src=``),z(Date.now())},e)},[B]);(0,y.useEffect)(()=>{if(I||ee||_){U.current&&=(clearInterval(U.current),null);return}return U.current=setInterval(async()=>{try{let t=await Q.getCameraStatus(e);(t.stalled||!t.active&&!P)&&(U.current&&=(clearInterval(U.current),null),L(!1),ge())}catch{}},mle),()=>{U.current&&=(clearInterval(U.current),null)}},[I,P,ee,_,e,ge]),(0,y.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;x(e),e||(C(1),T({x:0,y:0}))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let _e=()=>{ie.current&&(document.fullscreenElement?document.exitFullscreen():ie.current.requestFullscreen())},ve=()=>{C(e=>Math.min(e+.5,4))},ye=()=>{C(e=>{let t=Math.max(e-.5,1);return t===1&&T({x:0,y:0}),t})},be=e=>{e.preventDefault(),e.deltaY<0?ve():ye()},xe=e=>{S>1&&(e.preventDefault(),D(!0),k({x:e.clientX-w.x,y:e.clientY-w.y}))},Se=(0,y.useCallback)(()=>{if(!ie.current||!H.current)return{x:200,y:150};let e=ie.current.getBoundingClientRect(),t=e.width*(S-1)/2,n=e.height*(S-1)/2;return{x:Math.max(50,t),y:Math.max(50,n)}},[S]),Ce=e=>{if(E&&S>1){let t=e.clientX-O.x,n=e.clientY-O.y,r=Se();T({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},we=()=>{D(!1)},Te=e=>{if(e.length<2)return 0;let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)},Ee=e=>e.length<2?{x:e[0].clientX,y:e[0].clientY}:{x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2},De=e=>{e.touches.length===2?(e.preventDefault(),j(Te(e.touches)),N(Ee(e.touches))):e.touches.length===1&&S>1&&(e.preventDefault(),D(!0),k({x:e.touches[0].clientX-w.x,y:e.touches[0].clientY-w.y}))},Oe=e=>{if(e.touches.length===2&&A!==null){e.preventDefault();let t=Te(e.touches),n=t/A;C(e=>{let t=Math.max(1,Math.min(4,e*n));return t===1&&T({x:0,y:0}),t}),j(t);let r=Ee(e.touches);if(M){let e=Se();T(t=>({x:Math.max(-e.x,Math.min(e.x,t.x+(r.x-M.x))),y:Math.max(-e.y,Math.min(e.y,t.y+(r.y-M.y)))}))}N(r)}else if(e.touches.length===1&&E&&S>1){e.preventDefault();let t=e.touches[0].clientX-O.x,n=e.touches[0].clientY-O.y,r=Se();T({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},ke=e=>{e.touches.length<2&&(j(null),N(null)),e.touches.length===0&&D(!1)},Ae=()=>{C(1),T({x:0,y:0})},je=()=>{L(!1),B{L(!1),F(!1),V(0),te(!1),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current)},Ne=()=>{L(!0),F(!1),V(0),te(!1),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current);let t={},n=Ku();n&&(t.Authorization=`Bearer ${n}`),fetch(`/api/v1/printers/${e}/camera/stop`,{method:`POST`,headers:t}).catch(()=>{}),H.current&&(H.current.src=``),setTimeout(()=>z(Date.now()),100)},Pe=e=>{e.target.closest(`.no-drag`)||(f(!0),g({x:e.clientX-l.x,y:e.clientY-l.y}))},Fe=e=>{if(e.target.closest(`.no-drag`))return;let t=e.touches[0];f(!0),g({x:t.clientX-l.x,y:t.clientY-l.y})},Ie=e=>{e.stopPropagation(),m(!0)},Le=e=>{e.stopPropagation(),m(!0)};(0,y.useEffect)(()=>{let e=e=>{if(d)u(t=>({...t,x:Math.max(0,Math.min(e.clientX-h.x,window.innerWidth-t.width)),y:Math.max(0,Math.min(e.clientY-h.y,window.innerHeight-t.height))}));else if(p&&ie.current){let t=ie.current.getBoundingClientRect();u(n=>({...n,width:Math.max(200,Math.min(e.clientX-t.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(e.clientY-t.top,window.innerHeight-n.y-10))}))}},t=e=>{if(!d&&!p)return;e.preventDefault();let t=e.touches[0];if(d)u(e=>({...e,x:Math.max(0,Math.min(t.clientX-h.x,window.innerWidth-e.width)),y:Math.max(0,Math.min(t.clientY-h.y,window.innerHeight-e.height))}));else if(p&&ie.current){let e=ie.current.getBoundingClientRect();u(n=>({...n,width:Math.max(200,Math.min(t.clientX-e.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(t.clientY-e.top,window.innerHeight-n.y-10))}))}},n=()=>{f(!1),m(!1)};if(d||p)return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n),document.addEventListener(`touchcancel`,n),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.removeEventListener(`touchcancel`,n)}},[d,p,h]);let Re=Xu(`/api/v1/printers/${e}/camera/stream?fps=15&t=${R}`);return(0,K.jsxs)(`div`,{ref:ie,className:`${b?`fixed inset-0 z-[100]`:`fixed z-40 rounded-lg shadow-2xl border border-bambu-dark-tertiary`} bg-bambu-dark-secondary overflow-hidden`,style:b?void 0:{left:l.x,top:l.y,width:_?200:l.width,height:_?40:l.height,cursor:d?`grabbing`:`default`},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing`,onMouseDown:Pe,onTouchStart:Fe,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white truncate`,children:[(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:de?.name||t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 no-drag`,children:[(0,K.jsx)(`button`,{onClick:()=>pe.mutate(!fe?.chamber_light),disabled:!fe?.connected||pe.isPending||!s(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${fe?.chamber_light?`bg-yellow-500/20 hover:bg-yellow-500/30`:`hover:bg-bambu-dark-tertiary`}`,title:s(`printers:control`)?i(`camera.chamberLight`):i(`printers.permission.noControl`),children:(0,K.jsx)(oT,{on:fe?.chamber_light??!1,className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>ce(!0),disabled:!me||!s(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${me&&s(`printers:control`)?`hover:bg-bambu-dark-tertiary`:``}`,title:s(`printers:control`)?i(me?`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):i(`printers.permission.noControl`),children:(0,K.jsx)(sT,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:Ne,disabled:I||ee,className:`p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50`,title:`Refresh stream`,children:(0,K.jsx)(Ol,{className:`w-3.5 h-3.5 text-bambu-gray ${I?`animate-spin`:``}`})}),(0,K.jsx)(`button`,{onClick:()=>ue(!0),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:i(`camera.diagnose.button`),children:(0,K.jsx)(cu,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:_e,className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:b?`Exit fullscreen`:`Fullscreen`,children:b?(0,K.jsx)(il,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,K.jsx)(pc,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:()=>v(!_),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:_?`Expand`:`Minimize`,children:_?(0,K.jsx)($c,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,K.jsx)(rl,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-red-500/20 rounded`,title:`Close`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5 text-bambu-gray hover:text-red-400`})})]})]}),!_&&(0,K.jsxs)(`div`,{className:`relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]`,onWheel:be,onMouseMove:Ce,onMouseUp:we,onMouseLeave:we,onTouchStart:De,onTouchMove:Oe,onTouchEnd:ke,style:{touchAction:`none`},children:[I&&!ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 text-bambu-gray animate-spin`})}),ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/80 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-2`,children:[(0,K.jsx)(Pu,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Reconnecting in `,ne,`s...`]})]})}),P&&!ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-2`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`camera.unavailable`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[(0,K.jsx)(`button`,{onClick:Ne,className:`px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80`,children:i(`camera.retry`)}),(0,K.jsx)(`button`,{onClick:()=>ue(!0),className:`px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white rounded transition-colors`,children:i(`camera.diagnose.button`)})]})]})}),(0,K.jsx)(`img`,{ref:H,src:Re,alt:`Camera stream`,className:`max-w-full max-h-full object-contain select-none`,style:{transform:`scale(${S}) translate(${w.x/S}px, ${w.y/S}px) rotate(${de?.camera_rotation||0}deg)`,...de?.camera_rotation===90||de?.camera_rotation===270?{maxWidth:`100%`,maxHeight:`100%`}:{},cursor:S>1?E?`grabbing`:`grab`:`default`},onError:je,onLoad:Me,onMouseDown:xe,draggable:!1},R),(0,K.jsxs)(`div`,{className:`absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag`,children:[(0,K.jsx)(`button`,{onClick:ye,disabled:S<=1,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom out`,children:(0,K.jsx)(Vu,{className:`w-3.5 h-3.5 text-white`})}),(0,K.jsxs)(`button`,{onClick:Ae,className:`px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]`,title:`Reset zoom`,children:[Math.round(S*100),`%`]}),(0,K.jsx)(`button`,{onClick:ve,disabled:S>=4,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom in`,children:(0,K.jsx)(zu,{className:`w-3.5 h-3.5 text-white`})})]}),!b&&(0,K.jsx)(`div`,{className:`absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors`,onMouseDown:Ie,onTouchStart:Le,title:`Drag to resize`,children:(0,K.jsx)(`svg`,{className:`w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,K.jsx)(`path`,{d:`M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z`})})})]}),(0,K.jsx)(cT,{printerId:e,isOpen:se,onClose:()=>ce(!1)}),le&&(0,K.jsx)(lT,{printerId:e,printerName:de?.name||null,onClose:()=>ue(!1)})]})}function gle({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),i=no(),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(`all`),p=(0,y.useRef)(null),{data:m,isLoading:h,refetch:g}=q({queryKey:[`mqtt-logs`,e],queryFn:()=>Q.getMQTTLogs(e),refetchInterval:1e3}),_=J({mutationFn:()=>Q.enableMQTTLogging(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),v=J({mutationFn:()=>Q.disableMQTTLogging(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),b=J({mutationFn:()=>Q.clearMQTTLogs(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,y.useEffect)(()=>{a&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[m?.logs,a]);let x=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=e=>new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,fractionalSecondDigits:3}),C=(e,t)=>{if(e==null)return``;let n=typeof e==`string`?JSON.parse(e):e,r=JSON.stringify(n,null,t?2:0);return!t&&r.length>100?r.substring(0,100)+`...`:r},w=m?.logging_enabled??!1,T=(0,y.useMemo)(()=>m?.logs??[],[m?.logs]),E=(0,y.useMemo)(()=>T.filter(e=>{if(d!==`all`&&e.direction!==d)return!1;if(l.trim()){let t=l.toLowerCase(),n=e.topic.toLowerCase().includes(t),r=JSON.stringify(e.payload).toLowerCase().includes(t);return n||r}return!0}),[T,l,d]);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`mqttDebug.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w?(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>v.mutate(),disabled:v.isPending,children:[(0,K.jsx)(ou,{className:`w-4 h-4`}),r(`mqttDebug.stopLogging`)]}):(0,K.jsxs)($,{size:`sm`,onClick:()=>_.mutate(),disabled:_.isPending,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),r(`mqttDebug.startLogging`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>b.mutate(),disabled:b.isPending||T.length===0,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),r(`mqttDebug.clearLog`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>g(),disabled:h,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h?`animate-spin`:``}`})}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`rounded border-bambu-dark-tertiary`}),`Auto-scroll`]}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[E.length,`/`,T.length]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:r(`mqttDebug.searchPlaceholder`),value:l,onChange:e=>u(e.target.value),className:`w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),l&&(0,K.jsx)(`button`,{onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>f(`all`),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d===`all`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:r(`mqttDebug.all`)}),(0,K.jsxs)(`button`,{onClick:()=>f(`in`),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d===`in`?`bg-blue-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ao,{className:`w-3 h-3`}),r(`mqttDebug.incoming`)]}),(0,K.jsxs)(`button`,{onClick:()=>f(`out`),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d===`out`?`bg-green-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Io,{className:`w-3 h-3`}),r(`mqttDebug.outgoing`)]})]})]})]}),(0,K.jsx)(`div`,{ref:p,className:`flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]`,children:T.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessages`)}),!w&&(0,K.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.startLoggingHint`)})]}):E.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessagesMatch`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.adjustFilterHint`)})]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:E.map((e,t)=>{let n=s.has(t),i=e.direction===`in`;return(0,K.jsxs)(`div`,{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${n?`bg-bambu-dark-secondary`:``}`,onClick:()=>x(t),children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray shrink-0`,children:S(e.timestamp)}),(0,K.jsx)(`span`,{className:`shrink-0 ${i?`text-blue-400`:`text-green-400`}`,title:r(i?`mqttDebug.incoming`:`mqttDebug.outgoing`),children:i?(0,K.jsx)(Ao,{className:`w-3 h-3`}):(0,K.jsx)(Io,{className:`w-3 h-3`})}),(0,K.jsx)(`span`,{className:`text-purple-400 shrink-0`,children:e.topic})]}),n?(0,K.jsx)(`pre`,{className:`mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs`,children:C(e.payload,!0)}):(0,K.jsx)(`pre`,{className:`mt-1 text-white/80 truncate`,children:C(e.payload,!1)})]},t)})})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:w?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 bg-green-500 rounded-full animate-pulse`}),r(`mqttDebug.loggingActive`)]}):(0,K.jsx)(`span`,{children:r(`mqttDebug.loggingStopped`)})}),(0,K.jsx)($,{variant:`secondary`,onClick:n,children:r(`common.close`)})]})]})})}function fT(e){if(!e)return`/img/printers/default.png`;let t=e.toLowerCase().replace(/\s+/g,``);return t.includes(`x1e`)?`/img/printers/x1e.png`:t.includes(`x1c`)||t.includes(`x1carbon`)||t.includes(`x1`)?`/img/printers/x1c.png`:t.includes(`x2d`)||t===`n6`?`/img/printers/x2d.png`:t.includes(`h2dpro`)||t.includes(`h2d-pro`)?`/img/printers/h2dpro.png`:t.includes(`h2d`)?`/img/printers/h2d.png`:t.includes(`h2c`)?`/img/printers/h2c.png`:t.includes(`h2s`)?`/img/printers/h2d.png`:t.includes(`p2s`)||t.includes(`p1s`)?`/img/printers/p1s.png`:t.includes(`p1p`)?`/img/printers/p1p.png`:t.includes(`a2l`)||t===`n9`?`/img/printers/a2l.png`:t.includes(`a1mini`)?`/img/printers/a1mini.png`:t.includes(`a1`)?`/img/printers/a1.png`:`/img/printers/default.png`}function pT(e){return e>=-50?{labelKey:`printers.wifiSignal.excellent`,color:`text-bambu-green`,bars:4}:e>=-60?{labelKey:`printers.wifiSignal.good`,color:`text-bambu-green`,bars:3}:e>=-70?{labelKey:`printers.wifiSignal.fair`,color:`text-yellow-400`,bars:2}:e>=-80?{labelKey:`printers.wifiSignal.weak`,color:`text-orange-400`,bars:1}:{labelKey:`printers.wifiSignal.veryWeak`,color:`text-red-400`,bars:1}}function mT(e,t,n){return e.filter(e=>{if(e.required_filament_types&&e.required_filament_types.length>0&&t!==void 0&&!e.required_filament_types.every(e=>t.has(e.toUpperCase())))return!1;if(e.filament_overrides&&e.filament_overrides.length>0&&n!==void 0){let t=e.filament_overrides.filter(e=>e.force_color_match===!0),r=e.filament_overrides.filter(e=>e.force_color_match!==!0);if(t.length>0&&!t.every(e=>{let t=(e.type||``).toUpperCase(),r=(e.color||``).replace(`#`,``).toLowerCase().slice(0,6);return n.has(`${t}:${r}`)})||r.length>0&&t.length===0&&!r.some(e=>{let t=(e.type||``).toUpperCase(),r=(e.color||``).replace(`#`,``).toLowerCase().slice(0,6);return n.has(`${t}:${r}`)}))return!1}return!0})}function _le({printerId:e,printerModel:t,loadedFilamentTypes:n,loadedFilaments:r,variant:i=`card`}){let{t:a}=W(),{data:o}=q({queryKey:[`queue`,e,`pending`,t],queryFn:()=>Q.getQueue(e,`pending`,t||void 0),refetchInterval:3e4}),s=o?mT(o,n,r):void 0,c=s?.length||0;if(c===0)return null;let l=s?.[0];return(0,K.jsx)(wi,{to:`/queue`,className:i===`panelExtension`?`block mt-2 border-t border-bambu-dark-tertiary pt-2 pl-1 hover:opacity-90 transition-opacity`:`block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(Zo,{className:`w-5 h-5 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:a(`queue.nextInQueue`)}),(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:l?.archive_name||l?.library_file_name||`File #${l?.archive_id||l?.library_file_id}`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),l?.scheduled_time?wf(l.scheduled_time,`system`,a):a(`time.waiting`)]}),c>1&&(0,K.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded`,children:[`+`,c-1]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`})]})]})})}function hT(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t{var{children:n,width:r,height:i,viewBox:a,className:o,style:s,title:c,desc:l}=e,u=Sle(e,xle),d=a||{width:r,height:i,x:0,y:0},f=gT(`recharts-surface`,o);return y.createElement(`svg`,CT({},ST(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),y.createElement(`title`,null,c),y.createElement(`desc`,null,l),n)}),wle=[`children`,`className`];function TT(){return TT=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=Tle(e,wle),a=gT(`recharts-layer`,r);return y.createElement(`g`,TT({className:a},ST(i),{ref:t}),n)}),DT=(0,y.createContext)(null),Dle=()=>(0,y.useContext)(DT);function OT(e){return function(){return e}}var kT=Math.cos,AT=Math.sin,jT=Math.sqrt,MT=Math.PI;MT/2;var NT=2*MT,PT=Math.PI,FT=2*PT,IT=1e-6,Ole=FT-IT;function LT(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return LT;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tIT)if(!(Math.abs(u*s-c*l)>IT)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((PT-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>IT&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>IT||Math.abs(this._y1-l)>IT)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%FT+FT),d>Ole?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>IT&&this._append`A${n},${n},0,${+(d>=PT)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function Ale(){return new RT}Ale.prototype=RT.prototype;function zT(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new RT(t)}Array.prototype.slice;function BT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function VT(e){this._context=e}VT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function HT(e){return new VT(e)}function UT(e){return e[0]}function WT(e){return e[1]}function GT(e,t){var n=OT(!0),r=null,i=HT,a=null,o=zT(s);e=typeof e==`function`?e:e===void 0?UT:OT(e),t=typeof t==`function`?t:t===void 0?WT:OT(t);function s(s){var c,l=(s=BT(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return GT().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:OT(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:OT(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:OT(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:OT(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:OT(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:OT(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:OT(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var qT=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t);break}this._x0=e,this._y0=t}};function jle(e){return new qT(e,!0)}function Mle(e){return new qT(e,!1)}var JT={draw(e,t){let n=jT(t/MT);e.moveTo(n,0),e.arc(0,0,n,0,NT)}},Nle={draw(e,t){let n=jT(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},YT=jT(1/3),Ple=YT*2,Fle={draw(e,t){let n=jT(t/Ple),r=n*YT;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},Ile={draw(e,t){let n=jT(t),r=-n/2;e.rect(r,r,n,n)}},Lle=.8908130915292852,XT=AT(MT/10)/AT(7*MT/10),Rle=AT(NT/10)*XT,zle=-kT(NT/10)*XT,Ble={draw(e,t){let n=jT(t*Lle),r=Rle*n,i=zle*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=NT*t/5,o=kT(a),s=AT(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},ZT=jT(3),Vle={draw(e,t){let n=-jT(t/(ZT*3));e.moveTo(0,n*2),e.lineTo(-ZT*n,-n),e.lineTo(ZT*n,-n),e.closePath()}},QT=-.5,$T=jT(3)/2,eE=1/jT(12),Hle=(eE/2+1)*3,Ule={draw(e,t){let n=jT(t/Hle),r=n/2,i=n*eE,a=r,o=n*eE+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo(QT*r-$T*i,$T*r+QT*i),e.lineTo(QT*a-$T*o,$T*a+QT*o),e.lineTo(QT*s-$T*c,$T*s+QT*c),e.lineTo(QT*r+$T*i,QT*i-$T*r),e.lineTo(QT*a+$T*o,QT*o-$T*a),e.lineTo(QT*s+$T*c,QT*c-$T*s),e.closePath()}};function Wle(e,t){let n=null,r=zT(i);e=typeof e==`function`?e:OT(e||JT),t=typeof t==`function`?t:OT(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:OT(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:OT(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}function tE(){}function nE(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function rE(e){this._context=e}rE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:nE(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:nE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Gle(e){return new rE(e)}function iE(e){this._context=e}iE.prototype={areaStart:tE,areaEnd:tE,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:nE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Kle(e){return new iE(e)}function aE(e){this._context=e}aE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:nE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function qle(e){return new aE(e)}function oE(e){this._context=e}oE.prototype={areaStart:tE,areaEnd:tE,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function Jle(e){return new oE(e)}function sE(e){return e<0?-1:1}function cE(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(sE(a)+sE(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function lE(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function uE(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function dE(e){this._context=e}dE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:uE(this,this._t0,lE(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,uE(this,lE(this,n=cE(this,e,t)),n);break;default:uE(this,this._t0,n=cE(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function fE(e){this._context=new pE(e)}(fE.prototype=Object.create(dE.prototype)).point=function(e,t){dE.prototype.point.call(this,t,e)};function pE(e){this._context=e}pE.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function Yle(e){return new dE(e)}function Xle(e){return new fE(e)}function mE(e){this._context=e}mE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=hE(e),i=hE(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}};function Qle(e){return new gE(e,.5)}function $le(e){return new gE(e,0)}function eue(e){return new gE(e,1)}function _E(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function tue(e,t){return e[t]}function nue(e){let t=[];return t.key=e,t}function rue(){var e=OT([]),t=vE,n=_E,r=tue;function i(i){var a=Array.from(e.apply(this,arguments),nue),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e===`__proto__`}e.isUnsafeProperty=t})),yE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}e.isDeepKey=t})),bE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}e.toKey=t})),cue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(t).join(`,`);let n=String(e);return n===`0`&&Object.is(Number(e),-0)?`-0`:n}e.toString=t})),xE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=cue(),n=bE();function r(e){if(Array.isArray(e))return e.map(n.toKey);if(typeof e==`symbol`)return[e];e=t.toString(e);let r=[],i=e.length;if(i===0)return r;let a=0,o=``,s=``,c=!1;for(e.charCodeAt(0)===46&&(r.push(``),a++);a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=sue(),n=yE(),r=bE(),i=xE();function a(e,s,c){if(e==null)return c;switch(typeof s){case`string`:{if(t.isUnsafeProperty(s))return c;let r=e[s];return r===void 0?n.isDeepKey(s)?a(e,i.toPath(s),c):c:r}case`number`:case`symbol`:{typeof s==`number`&&(s=r.toKey(s));let t=e[s];return t===void 0?c:t}default:{if(Array.isArray(s))return o(e,s,c);if(s=Object.is(s?.valueOf(),-0)?`-0`:String(s),t.isUnsafeProperty(s))return c;let n=e[s];return n===void 0?c:n}}}function o(e,n,r){if(n.length===0)return r;let i=e;for(let e=0;e{t.exports=SE().get})),uue=4;function CE(e){var t=10**(arguments.length>1&&arguments[1]!==void 0?arguments[1]:uue),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function wE(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+CE(i)+n},``)}var TE=l(lue()),EE=e=>e===0?0:e>0?1:-1,DE=e=>typeof e==`number`&&e!=+e,OE=e=>typeof e==`string`&&e.indexOf(`%`)===e.length-1,kE=e=>(typeof e==`number`||e instanceof Number)&&!DE(e),AE=e=>kE(e)||typeof e==`string`,due=0,jE=e=>{var t=++due;return`${e||``}${t}`},ME=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!kE(e)&&typeof e!=`string`)return n;var i;if(OE(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return DE(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},NE=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):(0,TE.default)(e,t))===n)}var IE=e=>e==null,LE=e=>IE(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function RE(e){return e!=null}function zE(){}var fue=[`type`,`size`,`sizeType`];function BE(){return BE=Object.assign?Object.assign.bind():function(e){for(var t=1;tUE[`symbol${LE(e)}`]||JT,bue=(e,t,n)=>{if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*vue;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},xue=(e,t)=>{UE[`symbol${LE(e)}`]=t},WE=e=>{var{type:t=`circle`,size:n=64,sizeType:r=`area`}=e,i=HE(HE({},gue(e,fue)),{},{type:t,size:n,sizeType:r}),a=`circle`;typeof t==`string`&&(a=t);var o=()=>{var e=yue(a),t=Wle().type(e).size(bue(n,r,a))();if(t!==null)return t},{className:s,cx:c,cy:l}=i,u=ST(i);return kE(c)&&kE(l)&&kE(n)?y.createElement(`path`,BE({},u,{className:gT(`recharts-symbols`,s),transform:`translate(${c}, ${l})`,d:o()})):null};WE.registerSymbol=xue;var GE=e=>`radius`in e&&`startAngle`in e&&`endAngle`in e,KE=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,y.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{_T(e)&&(r[e]=t||(t=>n[e](n,t)))}),r},Sue=(e,t,n)=>r=>(e(t,n,r),null),qE=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];_T(i)&&typeof a==`function`&&(r||={},r[i]=Sue(a,t,n))}),r};function JE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Cue(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function XE(){return XE=Object.assign?Object.assign.bind():function(e){for(var t=1;ts({id:e.id,name:e.name}),disabled:p.isPending||(u?.layer_num??0)<=1||!a(`printers:control`),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(u?.layer_num??0)<=1||!a(`printers:control`)?`bg-gray-100 dark:bg-bambu-dark text-gray-400 dark:text-bambu-gray/50 cursor-not-allowed`:`bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-400 hover:bg-red-200 dark:hover:bg-red-500/30 border border-red-300 dark:border-red-500/30`}`,title:a(`printers:control`)?(u?.layer_num??0)<=1?r(`printers.skipObjects.waitForLayer`,{layer:u?.layer_num??0}):r(`printers.skipObjects.skip`):r(`printers.permission.noControl`),children:r(`printers.skipObjects.skip`)})]},e.id))})]})]}):(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-5 h-5 animate-spin text-bambu-gray`})})]})]}),o&&(0,K.jsx)(Ad,{variant:`warning`,title:r(`printers.skipObjects.confirmTitle`),message:r(`printers.skipObjects.confirmMessage`,{name:o.name}),confirmText:r(`printers.skipObjects.skip`),isLoading:p.isPending,onConfirm:()=>p.mutate([o.id]),onCancel:()=>s(null)}),c&&d&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-60`,onClick:()=>l(!1),children:[(0,K.jsx)(`button`,{onClick:()=>l(!1),className:`absolute top-4 right-4 p-2 text-white/70 hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`relative max-w-[600px] max-h-[80vh] aspect-square`,onClick:e=>e.stopPropagation(),children:[u?.cover_url?(0,K.jsx)(`img`,{src:Xu(`${u.cover_url}?view=top`),alt:r(`printers.printPreview`),className:`w-full h-full object-contain rounded-lg bg-gray-900`}):(0,K.jsx)(`div`,{className:`w-full h-full rounded-lg bg-gray-800 flex items-center justify-center`,children:(0,K.jsx)(Wo,{className:`w-16 h-16 text-gray-500`})}),d.objects.length>0&&(0,K.jsx)(`div`,{className:`absolute inset-0 pointer-events-none`,children:d.objects.map((e,t)=>{let n,r;if(e.x!=null&&e.y!=null&&d.bbox_all){let[t,i,a,o]=d.bbox_all,s=a-t,c=o-i;n=8+(e.x-t)/s*84,r=8+(o-e.y)/c*84,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r))}else if(e.x!=null&&e.y!=null)n=e.x/256*100,r=100-e.y/256*100,n=Math.max(5,Math.min(95,n)),r=Math.max(5,Math.min(95,r));else{let e=Math.ceil(Math.sqrt(d.objects.length)),i=Math.floor(t/e),a=t%e,o=Math.ceil(d.objects.length/e);n=15+70/e*a+35/e,r=15+70/o*i+35/o}return(0,K.jsx)(`div`,{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${e.skipped?`bg-red-500 text-white line-through`:`bg-bambu-green text-black`}`,style:{left:`${n}%`,top:`${r}%`,transform:`translate(-50%, -50%)`},title:e.name,children:e.id},e.id)})}),(0,K.jsx)(`div`,{className:`absolute bottom-2 right-2 px-2 py-1 bg-white/90 dark:bg-black/80 rounded text-[10px] text-gray-700 dark:text-white shadow-sm`,children:r(`printers.skipObjects.activeCount`,{count:d.objects.filter(e=>!e.skipped).length})})]})]})]}):null}function lle({status:e}){return e===`ok`?(0,K.jsx)(ms,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}):e===`failed`?(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`})}function uT({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),i=J({mutationFn:()=>Q.diagnoseCamera(e)});(0,y.useEffect)(()=>{i.mutate()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let a=i.data;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(cu,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:r(`camera.diagnose.modalTitle`,{name:t||``})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-4`,children:[i.isPending&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:r(`camera.diagnose.running`)})]}),i.isError&&(0,K.jsx)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`camera.diagnose.runFailed`,{error:i.error.message})}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ol`,{className:`space-y-2`,children:a.stages.map(e=>(0,K.jsxs)(`li`,{className:`flex items-center gap-3 bg-bambu-dark rounded-lg px-4 py-2.5`,children:[(0,K.jsx)(lle,{status:e.status}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white`,children:r(`camera.diagnose.stage.${e.name}`)}),e.code&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray font-mono`,children:e.code})]}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray tabular-nums flex-shrink-0`,children:[e.duration_ms,` ms`]})]},e.name))}),(0,K.jsx)(`div`,{className:a.overall_status===`ok`?`rounded-lg bg-bambu-green/10 border border-bambu-green/30 px-4 py-3 text-sm text-bambu-green`:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`camera.diagnose.summary.${a.summary_code}`,{defaultValue:r(`camera.diagnose.summary.unknown_failure`)})}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray space-y-0.5`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.protocol`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.protocol}),` • `,(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.port`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.port}),` • `,(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[r(`camera.diagnose.meta.profile`),`: `]}),(0,K.jsx)(`span`,{className:`font-mono`,children:a.profile})]})})]})]}),(0,K.jsxs)(`div`,{className:`px-6 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>i.mutate(),disabled:i.isPending,className:`px-4 py-2 bg-bambu-dark hover:bg-bambu-dark-tertiary disabled:opacity-50 text-white text-sm rounded-lg transition-colors`,children:r(`camera.diagnose.retry`)}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 bg-bambu-green hover:bg-bambu-green/90 text-white text-sm rounded-lg transition-colors`,children:r(`common.close`)})]})]})})}var ule=`embeddedCameraState_`,dT=5,dle=2e3,fle=3e4,ple=5e3,fT={x:window.innerWidth-420,y:20,width:400,height:300};function mle({printerId:e,printerName:t,viewerIndex:n=0,onClose:r}){let{t:i}=W(),a=no(),{showToast:o}=Td(),{hasPermission:s}=dd(),c=`${ule}${e}`,[l,u]=(0,y.useState)(()=>{try{let e=localStorage.getItem(c);if(e){let t=JSON.parse(e);return{x:Math.min(Math.max(0,t.x),window.innerWidth-100),y:Math.min(Math.max(0,t.y),window.innerHeight-100),width:Math.max(200,Math.min(t.width,window.innerWidth-20)),height:Math.max(150,Math.min(t.height,window.innerHeight-20))}}}catch{}let e=n*30;return{...fT,x:Math.max(0,fT.x-e),y:Math.max(0,fT.y+e)}}),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)({x:0,y:0}),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(1),[w,T]=(0,y.useState)({x:0,y:0}),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)({x:0,y:0}),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(!0),[R,z]=(0,y.useState)(Date.now()),[B,V]=(0,y.useState)(0),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(0),ie=(0,y.useRef)(null),H=(0,y.useRef)(null),ae=(0,y.useRef)(null),oe=(0,y.useRef)(null),U=(0,y.useRef)(null),[se,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(!1),{data:de}=q({queryKey:[`printer`,e],queryFn:()=>Q.getPrinter(e),enabled:e>0}),{data:fe}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4,enabled:e>0}),pe=J({mutationFn:t=>Q.setChamberLight(e,t),onMutate:async t=>{await a.cancelQueries({queryKey:[`printerStatus`,e]});let n=a.getQueryData([`printerStatus`,e]);return a.setQueryData([`printerStatus`,e],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{o(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&a.setQueryData([`printerStatus`,e],r.previousStatus),o(t.message||i(`printers.toast.failedToControlChamberLight`),`error`)}}),me=(fe?.state===`RUNNING`||fe?.state===`PAUSE`)&&(fe?.printable_objects_count??0)>=2;(0,y.useEffect)(()=>{let e=setTimeout(()=>{localStorage.setItem(c,JSON.stringify(l))},500);return()=>clearTimeout(e)},[l,c]);let he=(0,y.useRef)(!1);(0,y.useEffect)(()=>{he.current=!1;let t=`/api/v1/printers/${e}/camera/stop`,n=()=>{if(e>0&&!he.current){he.current=!0;let e={},n=Ku();n&&(e.Authorization=`Bearer ${n}`),fetch(t,{method:`POST`,keepalive:!0,headers:e}).catch(()=>{})}},r=H.current;return()=>{r&&(r.src=``),n(),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current),U.current&&clearInterval(U.current)}},[e]),(0,y.useEffect)(()=>{if(I){let e=setTimeout(()=>L(!1),3e3);return()=>clearTimeout(e)}},[I,R]);let ge=(0,y.useCallback)(()=>{if(B>=dT){te(!1),F(!0);return}let e=Math.min(dle*2**B,fle);te(!0),re(Math.ceil(e/1e3)),oe.current=setInterval(()=>{re(e=>e<=1?(oe.current&&clearInterval(oe.current),0):e-1)},1e3),ae.current=setTimeout(()=>{V(e=>e+1),te(!1),L(!0),F(!1),H.current&&(H.current.src=``),z(Date.now())},e)},[B]);(0,y.useEffect)(()=>{if(I||ee||_){U.current&&=(clearInterval(U.current),null);return}return U.current=setInterval(async()=>{try{let t=await Q.getCameraStatus(e);(t.stalled||!t.active&&!P)&&(U.current&&=(clearInterval(U.current),null),L(!1),ge())}catch{}},ple),()=>{U.current&&=(clearInterval(U.current),null)}},[I,P,ee,_,e,ge]),(0,y.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;x(e),e||(C(1),T({x:0,y:0}))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let _e=()=>{ie.current&&(document.fullscreenElement?document.exitFullscreen():ie.current.requestFullscreen())},ve=()=>{C(e=>Math.min(e+.5,4))},ye=()=>{C(e=>{let t=Math.max(e-.5,1);return t===1&&T({x:0,y:0}),t})},be=e=>{e.preventDefault(),e.deltaY<0?ve():ye()},xe=e=>{S>1&&(e.preventDefault(),D(!0),k({x:e.clientX-w.x,y:e.clientY-w.y}))},Se=(0,y.useCallback)(()=>{if(!ie.current||!H.current)return{x:200,y:150};let e=ie.current.getBoundingClientRect(),t=e.width*(S-1)/2,n=e.height*(S-1)/2;return{x:Math.max(50,t),y:Math.max(50,n)}},[S]),Ce=e=>{if(E&&S>1){let t=e.clientX-O.x,n=e.clientY-O.y,r=Se();T({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},we=()=>{D(!1)},Te=e=>{if(e.length<2)return 0;let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)},Ee=e=>e.length<2?{x:e[0].clientX,y:e[0].clientY}:{x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2},De=e=>{e.touches.length===2?(e.preventDefault(),j(Te(e.touches)),N(Ee(e.touches))):e.touches.length===1&&S>1&&(e.preventDefault(),D(!0),k({x:e.touches[0].clientX-w.x,y:e.touches[0].clientY-w.y}))},Oe=e=>{if(e.touches.length===2&&A!==null){e.preventDefault();let t=Te(e.touches),n=t/A;C(e=>{let t=Math.max(1,Math.min(4,e*n));return t===1&&T({x:0,y:0}),t}),j(t);let r=Ee(e.touches);if(M){let e=Se();T(t=>({x:Math.max(-e.x,Math.min(e.x,t.x+(r.x-M.x))),y:Math.max(-e.y,Math.min(e.y,t.y+(r.y-M.y)))}))}N(r)}else if(e.touches.length===1&&E&&S>1){e.preventDefault();let t=e.touches[0].clientX-O.x,n=e.touches[0].clientY-O.y,r=Se();T({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},ke=e=>{e.touches.length<2&&(j(null),N(null)),e.touches.length===0&&D(!1)},Ae=()=>{C(1),T({x:0,y:0})},je=()=>{L(!1),B{L(!1),F(!1),V(0),te(!1),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current)},Ne=()=>{L(!0),F(!1),V(0),te(!1),ae.current&&clearTimeout(ae.current),oe.current&&clearInterval(oe.current);let t={},n=Ku();n&&(t.Authorization=`Bearer ${n}`),fetch(`/api/v1/printers/${e}/camera/stop`,{method:`POST`,headers:t}).catch(()=>{}),H.current&&(H.current.src=``),setTimeout(()=>z(Date.now()),100)},Pe=e=>{e.target.closest(`.no-drag`)||(f(!0),g({x:e.clientX-l.x,y:e.clientY-l.y}))},Fe=e=>{if(e.target.closest(`.no-drag`))return;let t=e.touches[0];f(!0),g({x:t.clientX-l.x,y:t.clientY-l.y})},Ie=e=>{e.stopPropagation(),m(!0)},Le=e=>{e.stopPropagation(),m(!0)};(0,y.useEffect)(()=>{let e=e=>{if(d)u(t=>({...t,x:Math.max(0,Math.min(e.clientX-h.x,window.innerWidth-t.width)),y:Math.max(0,Math.min(e.clientY-h.y,window.innerHeight-t.height))}));else if(p&&ie.current){let t=ie.current.getBoundingClientRect();u(n=>({...n,width:Math.max(200,Math.min(e.clientX-t.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(e.clientY-t.top,window.innerHeight-n.y-10))}))}},t=e=>{if(!d&&!p)return;e.preventDefault();let t=e.touches[0];if(d)u(e=>({...e,x:Math.max(0,Math.min(t.clientX-h.x,window.innerWidth-e.width)),y:Math.max(0,Math.min(t.clientY-h.y,window.innerHeight-e.height))}));else if(p&&ie.current){let e=ie.current.getBoundingClientRect();u(n=>({...n,width:Math.max(200,Math.min(t.clientX-e.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(t.clientY-e.top,window.innerHeight-n.y-10))}))}},n=()=>{f(!1),m(!1)};if(d||p)return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n),document.addEventListener(`touchcancel`,n),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.removeEventListener(`touchcancel`,n)}},[d,p,h]);let Re=Xu(`/api/v1/printers/${e}/camera/stream?fps=15&t=${R}`);return(0,K.jsxs)(`div`,{ref:ie,className:`${b?`fixed inset-0 z-[100]`:`fixed z-40 rounded-lg shadow-2xl border border-bambu-dark-tertiary`} bg-bambu-dark-secondary overflow-hidden`,style:b?void 0:{left:l.x,top:l.y,width:_?200:l.width,height:_?40:l.height,cursor:d?`grabbing`:`default`},children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing`,onMouseDown:Pe,onTouchStart:Fe,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white truncate`,children:[(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:de?.name||t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 no-drag`,children:[(0,K.jsx)(`button`,{onClick:()=>pe.mutate(!fe?.chamber_light),disabled:!fe?.connected||pe.isPending||!s(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${fe?.chamber_light?`bg-yellow-500/20 hover:bg-yellow-500/30`:`hover:bg-bambu-dark-tertiary`}`,title:s(`printers:control`)?i(`camera.chamberLight`):i(`printers.permission.noControl`),children:(0,K.jsx)(sT,{on:fe?.chamber_light??!1,className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>ce(!0),disabled:!me||!s(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${me&&s(`printers:control`)?`hover:bg-bambu-dark-tertiary`:``}`,title:s(`printers:control`)?i(me?`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):i(`printers.permission.noControl`),children:(0,K.jsx)(cT,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:Ne,disabled:I||ee,className:`p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50`,title:`Refresh stream`,children:(0,K.jsx)(Ol,{className:`w-3.5 h-3.5 text-bambu-gray ${I?`animate-spin`:``}`})}),(0,K.jsx)(`button`,{onClick:()=>ue(!0),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:i(`camera.diagnose.button`),children:(0,K.jsx)(cu,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:_e,className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:b?`Exit fullscreen`:`Fullscreen`,children:b?(0,K.jsx)(il,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,K.jsx)(pc,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:()=>v(!_),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:_?`Expand`:`Minimize`,children:_?(0,K.jsx)($c,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,K.jsx)(rl,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-red-500/20 rounded`,title:`Close`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5 text-bambu-gray hover:text-red-400`})})]})]}),!_&&(0,K.jsxs)(`div`,{className:`relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]`,onWheel:be,onMouseMove:Ce,onMouseUp:we,onMouseLeave:we,onTouchStart:De,onTouchMove:Oe,onTouchEnd:ke,style:{touchAction:`none`},children:[I&&!ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 text-bambu-gray animate-spin`})}),ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/80 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-2`,children:[(0,K.jsx)(Pu,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Reconnecting in `,ne,`s...`]})]})}),P&&!ee&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-2`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`camera.unavailable`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[(0,K.jsx)(`button`,{onClick:Ne,className:`px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80`,children:i(`camera.retry`)}),(0,K.jsx)(`button`,{onClick:()=>ue(!0),className:`px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white rounded transition-colors`,children:i(`camera.diagnose.button`)})]})]})}),(0,K.jsx)(`img`,{ref:H,src:Re,alt:`Camera stream`,className:`max-w-full max-h-full object-contain select-none`,style:{transform:`scale(${S}) translate(${w.x/S}px, ${w.y/S}px) rotate(${de?.camera_rotation||0}deg)`,...de?.camera_rotation===90||de?.camera_rotation===270?{maxWidth:`100%`,maxHeight:`100%`}:{},cursor:S>1?E?`grabbing`:`grab`:`default`},onError:je,onLoad:Me,onMouseDown:xe,draggable:!1},R),(0,K.jsxs)(`div`,{className:`absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag`,children:[(0,K.jsx)(`button`,{onClick:ye,disabled:S<=1,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom out`,children:(0,K.jsx)(Vu,{className:`w-3.5 h-3.5 text-white`})}),(0,K.jsxs)(`button`,{onClick:Ae,className:`px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]`,title:`Reset zoom`,children:[Math.round(S*100),`%`]}),(0,K.jsx)(`button`,{onClick:ve,disabled:S>=4,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom in`,children:(0,K.jsx)(zu,{className:`w-3.5 h-3.5 text-white`})})]}),!b&&(0,K.jsx)(`div`,{className:`absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors`,onMouseDown:Ie,onTouchStart:Le,title:`Drag to resize`,children:(0,K.jsx)(`svg`,{className:`w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,K.jsx)(`path`,{d:`M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z`})})})]}),(0,K.jsx)(lT,{printerId:e,isOpen:se,onClose:()=>ce(!1)}),le&&(0,K.jsx)(uT,{printerId:e,printerName:de?.name||null,onClose:()=>ue(!1)})]})}function hle({printerId:e,printerName:t,onClose:n}){let{t:r}=W(),i=no(),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(`all`),p=(0,y.useRef)(null),{data:m,isLoading:h,refetch:g}=q({queryKey:[`mqtt-logs`,e],queryFn:()=>Q.getMQTTLogs(e),refetchInterval:1e3}),_=J({mutationFn:()=>Q.enableMQTTLogging(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),v=J({mutationFn:()=>Q.disableMQTTLogging(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),b=J({mutationFn:()=>Q.clearMQTTLogs(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`mqtt-logs`,e]})}});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,y.useEffect)(()=>{a&&p.current&&(p.current.scrollTop=p.current.scrollHeight)},[m?.logs,a]);let x=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},S=e=>new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,fractionalSecondDigits:3}),C=(e,t)=>{if(e==null)return``;let n=typeof e==`string`?JSON.parse(e):e,r=JSON.stringify(n,null,t?2:0);return!t&&r.length>100?r.substring(0,100)+`...`:r},w=m?.logging_enabled??!1,T=(0,y.useMemo)(()=>m?.logs??[],[m?.logs]),E=(0,y.useMemo)(()=>T.filter(e=>{if(d!==`all`&&e.direction!==d)return!1;if(l.trim()){let t=l.toLowerCase(),n=e.topic.toLowerCase().includes(t),r=JSON.stringify(e.payload).toLowerCase().includes(t);return n||r}return!0}),[T,l,d]);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`mqttDebug.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[w?(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>v.mutate(),disabled:v.isPending,children:[(0,K.jsx)(ou,{className:`w-4 h-4`}),r(`mqttDebug.stopLogging`)]}):(0,K.jsxs)($,{size:`sm`,onClick:()=>_.mutate(),disabled:_.isPending,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),r(`mqttDebug.startLogging`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>b.mutate(),disabled:b.isPending||T.length===0,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),r(`mqttDebug.clearLog`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>g(),disabled:h,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h?`animate-spin`:``}`})}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`rounded border-bambu-dark-tertiary`}),`Auto-scroll`]}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[E.length,`/`,T.length]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:r(`mqttDebug.searchPlaceholder`),value:l,onChange:e=>u(e.target.value),className:`w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),l&&(0,K.jsx)(`button`,{onClick:()=>u(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>f(`all`),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${d===`all`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:r(`mqttDebug.all`)}),(0,K.jsxs)(`button`,{onClick:()=>f(`in`),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${d===`in`?`bg-blue-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ao,{className:`w-3 h-3`}),r(`mqttDebug.incoming`)]}),(0,K.jsxs)(`button`,{onClick:()=>f(`out`),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${d===`out`?`bg-green-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Io,{className:`w-3 h-3`}),r(`mqttDebug.outgoing`)]})]})]})]}),(0,K.jsx)(`div`,{ref:p,className:`flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]`,children:T.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessages`)}),!w&&(0,K.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.startLoggingHint`)})]}):E.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessagesMatch`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.adjustFilterHint`)})]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:E.map((e,t)=>{let n=s.has(t),i=e.direction===`in`;return(0,K.jsxs)(`div`,{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${n?`bg-bambu-dark-secondary`:``}`,onClick:()=>x(t),children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray shrink-0`,children:S(e.timestamp)}),(0,K.jsx)(`span`,{className:`shrink-0 ${i?`text-blue-400`:`text-green-400`}`,title:r(i?`mqttDebug.incoming`:`mqttDebug.outgoing`),children:i?(0,K.jsx)(Ao,{className:`w-3 h-3`}):(0,K.jsx)(Io,{className:`w-3 h-3`})}),(0,K.jsx)(`span`,{className:`text-purple-400 shrink-0`,children:e.topic})]}),n?(0,K.jsx)(`pre`,{className:`mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs`,children:C(e.payload,!0)}):(0,K.jsx)(`pre`,{className:`mt-1 text-white/80 truncate`,children:C(e.payload,!1)})]},t)})})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:w?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 bg-green-500 rounded-full animate-pulse`}),r(`mqttDebug.loggingActive`)]}):(0,K.jsx)(`span`,{children:r(`mqttDebug.loggingStopped`)})}),(0,K.jsx)($,{variant:`secondary`,onClick:n,children:r(`common.close`)})]})]})})}function pT(e){if(!e)return`/img/printers/default.png`;let t=e.toLowerCase().replace(/\s+/g,``);return t.includes(`x1e`)?`/img/printers/x1e.png`:t.includes(`x1c`)||t.includes(`x1carbon`)||t.includes(`x1`)?`/img/printers/x1c.png`:t.includes(`x2d`)||t===`n6`?`/img/printers/x2d.png`:t.includes(`h2dpro`)||t.includes(`h2d-pro`)?`/img/printers/h2dpro.png`:t.includes(`h2d`)?`/img/printers/h2d.png`:t.includes(`h2c`)?`/img/printers/h2c.png`:t.includes(`h2s`)?`/img/printers/h2d.png`:t.includes(`p2s`)||t.includes(`p1s`)?`/img/printers/p1s.png`:t.includes(`p1p`)?`/img/printers/p1p.png`:t.includes(`a2l`)||t===`n9`?`/img/printers/a2l.png`:t.includes(`a1mini`)?`/img/printers/a1mini.png`:t.includes(`a1`)?`/img/printers/a1.png`:`/img/printers/default.png`}function mT(e){return e>=-50?{labelKey:`printers.wifiSignal.excellent`,color:`text-bambu-green`,bars:4}:e>=-60?{labelKey:`printers.wifiSignal.good`,color:`text-bambu-green`,bars:3}:e>=-70?{labelKey:`printers.wifiSignal.fair`,color:`text-yellow-400`,bars:2}:e>=-80?{labelKey:`printers.wifiSignal.weak`,color:`text-orange-400`,bars:1}:{labelKey:`printers.wifiSignal.veryWeak`,color:`text-red-400`,bars:1}}function hT(e,t,n){return e.filter(e=>{if(e.required_filament_types&&e.required_filament_types.length>0&&t!==void 0&&!e.required_filament_types.every(e=>t.has(e.toUpperCase())))return!1;if(e.filament_overrides&&e.filament_overrides.length>0&&n!==void 0){let t=e.filament_overrides.filter(e=>e.force_color_match===!0),r=e.filament_overrides.filter(e=>e.force_color_match!==!0);if(t.length>0&&!t.every(e=>{let t=(e.type||``).toUpperCase(),r=(e.color||``).replace(`#`,``).toLowerCase().slice(0,6);return n.has(`${t}:${r}`)})||r.length>0&&t.length===0&&!r.some(e=>{let t=(e.type||``).toUpperCase(),r=(e.color||``).replace(`#`,``).toLowerCase().slice(0,6);return n.has(`${t}:${r}`)}))return!1}return!0})}function gle({printerId:e,printerModel:t,loadedFilamentTypes:n,loadedFilaments:r,variant:i=`card`}){let{t:a}=W(),{data:o}=q({queryKey:[`queue`,e,`pending`,t],queryFn:()=>Q.getQueue(e,`pending`,t||void 0),refetchInterval:3e4}),s=o?hT(o,n,r):void 0,c=s?.length||0;if(c===0)return null;let l=s?.[0];return(0,K.jsx)(wi,{to:`/queue`,className:i===`panelExtension`?`block mt-2 border-t border-bambu-dark-tertiary pt-2 pl-1 hover:opacity-90 transition-opacity`:`block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(Zo,{className:`w-5 h-5 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:a(`queue.nextInQueue`)}),(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:l?.archive_name||l?.library_file_name||`File #${l?.archive_id||l?.library_file_id}`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),l?.scheduled_time?wf(l.scheduled_time,`system`,a):a(`time.waiting`)]}),c>1&&(0,K.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded`,children:[`+`,c-1]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`})]})]})})}function gT(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t{var{children:n,width:r,height:i,viewBox:a,className:o,style:s,title:c,desc:l}=e,u=xle(e,ble),d=a||{width:r,height:i,x:0,y:0},f=_T(`recharts-surface`,o);return y.createElement(`svg`,wT({},CT(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),y.createElement(`title`,null,c),y.createElement(`desc`,null,l),n)}),Cle=[`children`,`className`];function ET(){return ET=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:n,className:r}=e,i=wle(e,Cle),a=_T(`recharts-layer`,r);return y.createElement(`g`,ET({className:a},CT(i),{ref:t}),n)}),OT=(0,y.createContext)(null),Ele=()=>(0,y.useContext)(OT);function kT(e){return function(){return e}}var AT=Math.cos,jT=Math.sin,MT=Math.sqrt,NT=Math.PI;NT/2;var PT=2*NT,FT=Math.PI,IT=2*FT,LT=1e-6,Dle=IT-LT;function RT(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return RT;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tLT)if(!(Math.abs(u*s-c*l)>LT)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((FT-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>LT&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>LT||Math.abs(this._y1-l)>LT)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%IT+IT),d>Dle?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>LT&&this._append`A${n},${n},0,${+(d>=FT)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};function kle(){return new zT}kle.prototype=zT.prototype;function BT(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new zT(t)}Array.prototype.slice;function VT(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function HT(e){this._context=e}HT.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function UT(e){return new HT(e)}function WT(e){return e[0]}function GT(e){return e[1]}function KT(e,t){var n=kT(!0),r=null,i=UT,a=null,o=BT(s);e=typeof e==`function`?e:e===void 0?WT:kT(e),t=typeof t==`function`?t:t===void 0?GT:kT(t);function s(s){var c,l=(s=VT(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return KT().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:kT(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:kT(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:kT(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:kT(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:kT(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:kT(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:kT(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var JT=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t);break}this._x0=e,this._y0=t}};function Ale(e){return new JT(e,!0)}function jle(e){return new JT(e,!1)}var YT={draw(e,t){let n=MT(t/NT);e.moveTo(n,0),e.arc(0,0,n,0,PT)}},Mle={draw(e,t){let n=MT(t/5)/2;e.moveTo(-3*n,-n),e.lineTo(-n,-n),e.lineTo(-n,-3*n),e.lineTo(n,-3*n),e.lineTo(n,-n),e.lineTo(3*n,-n),e.lineTo(3*n,n),e.lineTo(n,n),e.lineTo(n,3*n),e.lineTo(-n,3*n),e.lineTo(-n,n),e.lineTo(-3*n,n),e.closePath()}},XT=MT(1/3),Nle=XT*2,Ple={draw(e,t){let n=MT(t/Nle),r=n*XT;e.moveTo(0,-n),e.lineTo(r,0),e.lineTo(0,n),e.lineTo(-r,0),e.closePath()}},Fle={draw(e,t){let n=MT(t),r=-n/2;e.rect(r,r,n,n)}},Ile=.8908130915292852,ZT=jT(NT/10)/jT(7*NT/10),Lle=jT(PT/10)*ZT,Rle=-AT(PT/10)*ZT,zle={draw(e,t){let n=MT(t*Ile),r=Lle*n,i=Rle*n;e.moveTo(0,-n),e.lineTo(r,i);for(let t=1;t<5;++t){let a=PT*t/5,o=AT(a),s=jT(a);e.lineTo(s*n,-o*n),e.lineTo(o*r-s*i,s*r+o*i)}e.closePath()}},QT=MT(3),Ble={draw(e,t){let n=-MT(t/(QT*3));e.moveTo(0,n*2),e.lineTo(-QT*n,-n),e.lineTo(QT*n,-n),e.closePath()}},$T=-.5,eE=MT(3)/2,tE=1/MT(12),Vle=(tE/2+1)*3,Hle={draw(e,t){let n=MT(t/Vle),r=n/2,i=n*tE,a=r,o=n*tE+n,s=-a,c=o;e.moveTo(r,i),e.lineTo(a,o),e.lineTo(s,c),e.lineTo($T*r-eE*i,eE*r+$T*i),e.lineTo($T*a-eE*o,eE*a+$T*o),e.lineTo($T*s-eE*c,eE*s+$T*c),e.lineTo($T*r+eE*i,$T*i-eE*r),e.lineTo($T*a+eE*o,$T*o-eE*a),e.lineTo($T*s+eE*c,$T*c-eE*s),e.closePath()}};function Ule(e,t){let n=null,r=BT(i);e=typeof e==`function`?e:kT(e||YT),t=typeof t==`function`?t:kT(t===void 0?64:+t);function i(){let i;if(n||=i=r(),e.apply(this,arguments).draw(n,+t.apply(this,arguments)),i)return n=null,i+``||null}return i.type=function(t){return arguments.length?(e=typeof t==`function`?t:kT(t),i):e},i.size=function(e){return arguments.length?(t=typeof e==`function`?e:kT(+e),i):t},i.context=function(e){return arguments.length?(n=e??null,i):n},i}function nE(){}function rE(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function iE(e){this._context=e}iE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:rE(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:rE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Wle(e){return new iE(e)}function aE(e){this._context=e}aE.prototype={areaStart:nE,areaEnd:nE,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:rE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Gle(e){return new aE(e)}function oE(e){this._context=e}oE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:rE(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Kle(e){return new oE(e)}function sE(e){this._context=e}sE.prototype={areaStart:nE,areaEnd:nE,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function qle(e){return new sE(e)}function cE(e){return e<0?-1:1}function lE(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(cE(a)+cE(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function uE(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function dE(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function fE(e){this._context=e}fE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:dE(this,this._t0,uE(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,dE(this,uE(this,n=lE(this,e,t)),n);break;default:dE(this,this._t0,n=lE(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function pE(e){this._context=new mE(e)}(pE.prototype=Object.create(fE.prototype)).point=function(e,t){fE.prototype.point.call(this,t,e)};function mE(e){this._context=e}mE.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function Jle(e){return new fE(e)}function Yle(e){return new pE(e)}function hE(e){this._context=e}hE.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=gE(e),i=gE(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}break}this._x=e,this._y=t}};function Zle(e){return new _E(e,.5)}function Qle(e){return new _E(e,0)}function $le(e){return new _E(e,1)}function vE(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function eue(e,t){return e[t]}function tue(e){let t=[];return t.key=e,t}function nue(){var e=kT([]),t=yE,n=vE,r=eue;function i(i){var a=Array.from(e.apply(this,arguments),tue),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e===`__proto__`}e.isUnsafeProperty=t})),bE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e.includes(`.`)||e.includes(`[`)||e.includes(`]`)}}e.isDeepKey=t})),xE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}e.toKey=t})),sue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(e==null)return``;if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(t).join(`,`);let n=String(e);return n===`0`&&Object.is(Number(e),-0)?`-0`:n}e.toString=t})),SE=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=sue(),n=xE();function r(e){if(Array.isArray(e))return e.map(n.toKey);if(typeof e==`symbol`)return[e];e=t.toString(e);let r=[],i=e.length;if(i===0)return r;let a=0,o=``,s=``,c=!1;for(e.charCodeAt(0)===46&&(r.push(``),a++);a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=oue(),n=bE(),r=xE(),i=SE();function a(e,s,c){if(e==null)return c;switch(typeof s){case`string`:{if(t.isUnsafeProperty(s))return c;let r=e[s];return r===void 0?n.isDeepKey(s)?a(e,i.toPath(s),c):c:r}case`number`:case`symbol`:{typeof s==`number`&&(s=r.toKey(s));let t=e[s];return t===void 0?c:t}default:{if(Array.isArray(s))return o(e,s,c);if(s=Object.is(s?.valueOf(),-0)?`-0`:String(s),t.isUnsafeProperty(s))return c;let n=e[s];return n===void 0?c:n}}}function o(e,n,r){if(n.length===0)return r;let i=e;for(let e=0;e{t.exports=CE().get})),lue=4;function wE(e){var t=10**(arguments.length>1&&arguments[1]!==void 0?arguments[1]:lue),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function TE(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+wE(i)+n},``)}var EE=l(cue()),DE=e=>e===0?0:e>0?1:-1,OE=e=>typeof e==`number`&&e!=+e,kE=e=>typeof e==`string`&&e.indexOf(`%`)===e.length-1,AE=e=>(typeof e==`number`||e instanceof Number)&&!OE(e),jE=e=>AE(e)||typeof e==`string`,uue=0,ME=e=>{var t=++uue;return`${e||``}${t}`},NE=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!AE(e)&&typeof e!=`string`)return n;var i;if(kE(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return OE(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},PE=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):(0,EE.default)(e,t))===n)}var LE=e=>e==null,RE=e=>LE(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function zE(e){return e!=null}function BE(){}var due=[`type`,`size`,`sizeType`];function VE(){return VE=Object.assign?Object.assign.bind():function(e){for(var t=1;tWE[`symbol${RE(e)}`]||YT,yue=(e,t,n)=>{if(t===`area`)return e;switch(n){case`cross`:return 5*e*e/9;case`diamond`:return .5*e*e/Math.sqrt(3);case`square`:return e*e;case`star`:var r=18*_ue;return 1.25*e*e*(Math.tan(r)-Math.tan(r*2)*Math.tan(r)**2);case`triangle`:return Math.sqrt(3)*e*e/4;case`wye`:return(21-10*Math.sqrt(3))*e*e/8;default:return Math.PI*e*e/4}},bue=(e,t)=>{WE[`symbol${RE(e)}`]=t},GE=e=>{var{type:t=`circle`,size:n=64,sizeType:r=`area`}=e,i=UE(UE({},hue(e,due)),{},{type:t,size:n,sizeType:r}),a=`circle`;typeof t==`string`&&(a=t);var o=()=>{var e=vue(a),t=Ule().type(e).size(yue(n,r,a))();if(t!==null)return t},{className:s,cx:c,cy:l}=i,u=CT(i);return AE(c)&&AE(l)&&AE(n)?y.createElement(`path`,VE({},u,{className:_T(`recharts-symbols`,s),transform:`translate(${c}, ${l})`,d:o()})):null};GE.registerSymbol=bue;var KE=e=>`radius`in e&&`startAngle`in e&&`endAngle`in e,qE=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,y.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{vT(e)&&(r[e]=t||(t=>n[e](n,t)))}),r},xue=(e,t,n)=>r=>(e(t,n,r),null),JE=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];vT(i)&&typeof a==`function`&&(r||={},r[i]=xue(a,t,n))}),r};function YE(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Sue(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function ZE(){return ZE=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var u=t.formatter||i,d=gT({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var f=t.inactive?a:t.color,p=u?u(t.value,t,r):t.value;return y.createElement(`li`,XE({className:d,style:c,key:`legend-item-${r}`},qE(e,t,r)),y.createElement(wT,{width:n,height:n,viewBox:s,style:l,"aria-label":`${p} legend icon`},y.createElement(Mue,{data:t,iconType:o,inactiveColor:a})),y.createElement(`span`,{className:`recharts-legend-item-text`,style:{color:f}},p))})}var Pue=e=>{var t=YE(e,jue),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return y.createElement(`ul`,{className:`recharts-default-legend`,style:a},y.createElement(Nue,XE({},t,{payload:n})))},Fue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){let n=new Map;for(let r=0;r{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){return function(...n){return e.apply(this,n.slice(0,t))}}e.ary=t})),$E=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e}e.identity=t})),Lue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Number.isSafeInteger(e)&&e>=0}e.isLength=t})),eD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Lue();function n(e){return e!=null&&typeof e!=`function`&&t.isLength(e.length)}e.isArrayLike=n})),Rue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`object`&&!!e}e.isObjectLike=t})),zue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=eD(),n=Rue();function r(e){return n.isObjectLike(e)&&t.isArrayLike(e)}e.isArrayLikeObject=r})),Bue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=SE();function n(e){return function(n){return t.get(n,e)}}e.property=n})),tD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}e.isObject=t})),nD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e==null||typeof e!=`object`&&typeof e!=`function`}e.isPrimitive=t})),rD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}e.isEqualsSameValueZero=t})),Vue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=tD(),n=nD(),r=rD();function i(e,t,n){return typeof n==`function`?a(e,t,function e(t,r,i,o,s,c){let l=n(t,r,i,o,s,c);return l===void 0?a(t,r,e,c):!!l},new Map):i(e,t,()=>void 0)}function a(e,n,i,s){if(n===e)return!0;switch(typeof n){case`object`:return o(e,n,i,s);case`function`:return Object.keys(n).length>0?a(e,{...n},i,s):r.isEqualsSameValueZero(e,n);default:return t.isObject(e)?typeof n==`string`?n===``:!0:r.isEqualsSameValueZero(e,n)}}function o(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return c(e,t,r,i);if(t instanceof Map)return s(e,t,r,i);if(t instanceof Set)return l(e,t,r,i);let a=Object.keys(t);if(e==null||n.isPrimitive(e))return a.length===0;if(a.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let o=0;o{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Vue();function n(e,n){return t.isMatchWith(e,n,()=>void 0)}e.isMatch=n})),Hue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}e.getSymbols=t})),aD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}e.getTag=t})),oD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),e.argumentsTag=`[object Arguments]`,e.arrayBufferTag=`[object ArrayBuffer]`,e.arrayTag=`[object Array]`,e.bigInt64ArrayTag=`[object BigInt64Array]`,e.bigUint64ArrayTag=`[object BigUint64Array]`,e.booleanTag=`[object Boolean]`,e.dataViewTag=`[object DataView]`,e.dateTag=`[object Date]`,e.errorTag=`[object Error]`,e.float32ArrayTag=`[object Float32Array]`,e.float64ArrayTag=`[object Float64Array]`,e.functionTag=`[object Function]`,e.int16ArrayTag=`[object Int16Array]`,e.int32ArrayTag=`[object Int32Array]`,e.int8ArrayTag=`[object Int8Array]`,e.mapTag=`[object Map]`,e.numberTag=`[object Number]`,e.objectTag=`[object Object]`,e.regexpTag=`[object RegExp]`,e.setTag=`[object Set]`,e.stringTag=`[object String]`,e.symbolTag=`[object Symbol]`,e.uint16ArrayTag=`[object Uint16Array]`,e.uint32ArrayTag=`[object Uint32Array]`,e.uint8ArrayTag=`[object Uint8Array]`,e.uint8ClampedArrayTag=`[object Uint8ClampedArray]`})),Uue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}e.isTypedArray=t})),sD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Hue(),n=aD(),r=oD(),i=nD(),a=Uue();function o(e,t){return s(e,void 0,e,new Map,t)}function s(e,t,n,r=new Map,o=void 0){let u=o?.(e,t,n,r);if(u!==void 0)return u;if(i.isPrimitive(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let i=0;i{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=sD();function n(e){return t.cloneDeepWithImpl(e,void 0,e,new Map,void 0)}e.cloneDeep=n})),Gue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=iD(),n=Wue();function r(e){return e=n.cloneDeep(e),n=>t.isMatch(n,e)}e.matches=r})),Kue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=sD(),n=aD(),r=oD();function i(e,i){return t.cloneDeepWith(e,(a,o,s,c)=>{let l=i?.(a,o,s,c);if(l!==void 0)return l;if(typeof e==`object`){if(n.getTag(e)===r.objectTag&&typeof e.constructor!=`function`){let n={};return c.set(e,n),t.copyProperties(n,e,s,c),n}switch(Object.prototype.toString.call(e)){case r.numberTag:case r.stringTag:case r.booleanTag:{let n=new e.constructor(e?.valueOf());return t.copyProperties(n,e),n}case r.argumentsTag:{let n={};return t.copyProperties(n,e),n.length=e.length,n[Symbol.iterator]=e[Symbol.iterator],n}default:return}}})}e.cloneDeepWith=i})),que=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Kue();function n(e){return t.cloneDeepWith(e)}e.cloneDeep=n})),cD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=/^(?:0|[1-9]\d*)$/;function n(e,n=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=aD();function n(e){return typeof e==`object`&&!!e&&t.getTag(e)===`[object Arguments]`}e.isArguments=n})),Yue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=yE(),n=cD(),r=Jue(),i=xE();function a(e,a){let o;if(o=Array.isArray(a)?a:typeof a==`string`&&t.isDeepKey(a)&&e?.[a]==null?i.toPath(a):[a],o.length===0)return!1;let s=e;for(let e=0;e{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=iD(),n=bE(),r=que(),i=SE(),a=Yue();function o(e,o){switch(typeof e){case`object`:Object.is(e?.valueOf(),-0)&&(e=`-0`);break;case`number`:e=n.toKey(e);break}return o=r.cloneDeep(o),function(n){let r=i.get(n,e);return r===void 0?a.has(n,e):o===void 0?r===void 0:t.isMatch(r,o)}}e.matchesProperty=o})),Zue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=$E(),n=Bue(),r=Gue(),i=Xue();function a(e){if(e==null)return t.identity;switch(typeof e){case`function`:return e;case`object`:return Array.isArray(e)&&e.length===2?i.matchesProperty(e[0],e[1]):r.matches(e);case`string`:case`symbol`:case`number`:return n.property(e)}}e.iteratee=a})),Que=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Fue(),n=Iue(),r=$E(),i=zue(),a=Zue();function o(e,o=r.identity){return i.isArrayLikeObject(e)?t.uniqBy(Array.from(e),n.ary(a.iteratee(o),1)):[]}e.uniqBy=o})),lD=l(o(((e,t)=>{t.exports=Que().uniqBy}))());function uD(e,t,n){return t===!0?(0,lD.default)(e,n):typeof t==`function`?(0,lD.default)(e,t):e}var $ue=o((e=>{var t=f(),n=Xe();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),ede=o(((e,t)=>{t.exports=$ue()})),dD=(0,y.createContext)(null),fD=ede(),tde=e=>e,pD=()=>{var e=(0,y.useContext)(dD);return e?e.store.dispatch:tde},mD=()=>{},nde=()=>mD,rde=(e,t)=>e===t;function hD(e){var t=(0,y.useContext)(dD),n=(0,y.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:mD,[t,e]);return(0,fD.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:nde,t?t.store.getState:mD,t?t.store.getState:mD,n,rde)}function ide(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function ade(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function ode(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var gD=e=>Array.isArray(e)?e:[e];function sde(e){let t=Array.isArray(e[0])?e[0]:e;return ode(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function cde(e,t){let n=[],{length:r}=e;for(let i=0;i{n=vD(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function fde(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),ide(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=yD,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=gD(c),p=gD(u),m=sde(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=cde(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var bD=fde(yD),pde=Object.assign((e,t=bD)=>{ade(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>pde}),mde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`symbol`?1:e===null?2:e===void 0?3:e===e?0:4}e.compareValues=(e,n,r)=>{if(e!==n){let i=t(e),a=t(n);if(i===a&&i===0){if(en)return r===`desc`?-1:1}return r===`desc`?a-i:i-a}return 0}})),xD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`symbol`||e instanceof Symbol}e.isSymbol=t})),hde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=xD(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(e,i){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||t.isSymbol(e)?!0:typeof e==`string`&&(r.test(e)||!n.test(e))||i!=null&&Object.hasOwn(i,e)}e.isKey=i})),gde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=mde(),n=hde(),r=xE();function i(e,i,a,o){if(e==null)return[];a=o?void 0:a,Array.isArray(e)||(e=Object.values(e)),Array.isArray(i)||(i=i==null?[null]:[i]),i.length===0&&(i=[null]),Array.isArray(a)||(a=a==null?[]:[a]),a=a.map(e=>String(e));let s=(e,t)=>{let n=e;for(let e=0;et==null||e==null?t:typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:s(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?s(t,e):typeof t==`object`?t[e]:t,l=i.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||n.isKey(e)?e:{key:e,path:r.toPath(e)}));return e.map(e=>({original:e,criteria:l.map(t=>c(t,e))})).slice().sort((e,n)=>{for(let r=0;re.original)}e.orderBy=i})),_de=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=cD(),n=eD(),r=tD(),i=rD();function a(e,a,o){return r.isObject(o)&&(typeof a==`number`&&n.isArrayLike(o)&&t.isIndex(a)&&a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=gde(),n=_de(),r=SD();function i(e,...i){let a=i.length;return a>1&&r.isIterateeCall(e,i[0],i[1])?i=[]:a>2&&r.isIterateeCall(i[0],i[1],i[2])&&(i=[i[0]]),t.orderBy(e,n.flatten(i),[`asc`])}e.sortBy=i})),CD=l(o(((e,t)=>{t.exports=vde().sortBy}))()),wD=e=>e.legend.settings,yde=e=>e.legend.size,bde=bD([e=>e.legend.payload,wD],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?(0,CD.default)(r,n):r});function xde(){return hD(bde)}var TD=1;function ED(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=(0,y.useState)({height:0,left:0,top:0,width:0});return[t,(0,y.useCallback)(e=>{if(e!=null){var r=e.getBoundingClientRect(),i={height:r.height,left:r.left,top:r.top,width:r.width};(Math.abs(i.height-t.height)>TD||Math.abs(i.left-t.left)>TD||Math.abs(i.top-t.top)>TD||Math.abs(i.width-t.width)>TD)&&n({height:i.height,left:i.left,top:i.top,width:i.width})}},[t.width,t.height,t.top,t.left,...e])]}function DD(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var OD=typeof Symbol==`function`&&Symbol.observable||`@@observable`,kD=()=>Math.random().toString(36).substring(7).split(``).join(`.`),AD={INIT:`@@redux/INIT${kD()}`,REPLACE:`@@redux/REPLACE${kD()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${kD()}`};function jD(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function MD(e,t,n){if(typeof e!=`function`)throw Error(DD(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(DD(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(DD(1));return n(MD)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(DD(3));return i}function d(e){if(typeof e!=`function`)throw Error(DD(4));if(c)throw Error(DD(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(DD(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!jD(e))throw Error(DD(7));if(e.type===void 0)throw Error(DD(8));if(typeof e.type!=`string`)throw Error(DD(17));if(c)throw Error(DD(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(DD(10));r=e,f({type:AD.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(DD(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[OD](){return this}}}return f({type:AD.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[OD]:m}}function Sde(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:AD.INIT})===void 0)throw Error(DD(12));if(n(void 0,{type:AD.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(DD(13))})}function ND(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function Cde(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(DD(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=PD(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function FD(e){return jD(e)&&`type`in e&&typeof e.type==`string`}var ID=Symbol.for(`immer-nothing`),LD=Symbol.for(`immer-draftable`),RD=Symbol.for(`immer-state`);function zD(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var BD=Object,VD=BD.getPrototypeOf,HD=`constructor`,UD=`prototype`,WD=`configurable`,GD=`enumerable`,KD=`writable`,qD=`value`,JD=e=>!!e&&!!e[RD];function YD(e){return e?ZD(e)||rO(e)||!!e[LD]||!!e[HD]?.[LD]||iO(e)||aO(e):!1}var wde=BD[UD][HD].toString(),XD=new WeakMap;function ZD(e){if(!e||!oO(e))return!1;let t=VD(e);if(t===null||t===BD[UD])return!0;let n=BD.hasOwnProperty.call(t,HD)&&t[HD];if(n===Object)return!0;if(!sO(n))return!1;let r=XD.get(n);return r===void 0&&(r=Function.toString.call(n),XD.set(n,r)),r===wde}function QD(e,t,n=!0){$D(e)===0?(n?Reflect.ownKeys(e):BD.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function $D(e){let t=e[RD];return t?t.type_:rO(e)?1:iO(e)?2:aO(e)?3:0}var eO=(e,t,n=$D(e))=>n===2?e.has(t):BD[UD].hasOwnProperty.call(e,t),tO=(e,t,n=$D(e))=>n===2?e.get(t):e[t],nO=(e,t,n,r=$D(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function Tde(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var rO=Array.isArray,iO=e=>e instanceof Map,aO=e=>e instanceof Set,oO=e=>typeof e==`object`,sO=e=>typeof e==`function`,cO=e=>typeof e==`boolean`;function Ede(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var lO=e=>e.copy_||e.base_,uO=e=>e.modified_?e.copy_:e.base_;function dO(e,t){if(iO(e))return new Map(e);if(aO(e))return new Set(e);if(rO(e))return Array[UD].slice.call(e);let n=ZD(e);if(t===!0||t===`class_only`&&!n){let t=BD.getOwnPropertyDescriptors(e);delete t[RD];let n=Reflect.ownKeys(t);for(let r=0;r1&&BD.defineProperties(e,{set:pO,add:pO,clear:pO,delete:pO}),BD.freeze(e),t&&QD(e,(e,t)=>{fO(t,!0)},!1),e)}function Dde(){zD(2)}var pO={[qD]:Dde};function mO(e){return e===null||!oO(e)?!0:BD.isFrozen(e)}var hO=`MapSet`,gO=`Patches`,_O=`ArrayMethods`,vO={};function yO(e){let t=vO[e];return t||zD(0,e),t}var bO=e=>!!vO[e],xO,SO=()=>xO,Ode=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:bO(hO)?yO(hO):void 0,arrayMethodsPlugin_:bO(_O)?yO(_O):void 0});function CO(e,t){t&&(e.patchPlugin_=yO(gO),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function wO(e){TO(e),e.drafts_.forEach(kde),e.drafts_=null}function TO(e){e===xO&&(xO=e.parent_)}var EO=e=>xO=Ode(xO,e);function kde(e){let t=e[RD];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function DO(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[RD].modified_&&(wO(t),zD(4)),YD(e)&&(e=OO(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[RD].base_,e,t)}else e=OO(t,n);return Ade(t,e,!0),wO(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===ID?void 0:e}function OO(e,t){if(mO(t))return t;let n=t[RD];if(!n)return NO(t,e.handledSet_,e);if(!AO(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);MO(n,e)}return n.copy_}function Ade(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&fO(t,n)}function kO(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var AO=(e,t)=>e.scope_===t,jde=[];function jO(e,t,n,r){let i=lO(e),a=e.type_;if(r!==void 0&&tO(i,r,a)===t){nO(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;QD(i,(e,n)=>{if(JD(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??jde;for(let e of o)nO(i,e,n,a)}function Mde(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!AO(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=uO(i);jO(e,i.draft_??i,a,n),MO(i,r)})}function MO(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}kO(e)}}function Nde(e,t,n){let{scope_:r}=e;if(JD(n)){let i=n[RD];AO(i,r)&&i.callbacks_.push(function(){zO(e),jO(e,n,uO(i),t)})}else YD(n)&&e.callbacks_.push(function(){let i=lO(e);e.type_===3?i.has(n)&&NO(n,r.handledSet_,r):tO(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&NO(tO(e.copy_,t,e.type_),r.handledSet_,r)})}function NO(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||JD(e)||t.has(e)||!YD(e)||mO(e)?e:(t.add(e),QD(e,(r,i)=>{if(JD(i)){let t=i[RD];AO(t,n)&&(nO(e,r,uO(t),e.type_),kO(t))}else YD(i)&&NO(i,t,n)}),e)}function Pde(e,t){let n=rO(e),r={type_:+!!n,scope_:t?t.scope_:SO(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=PO;n&&(i=[r],a=FO);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var PO={get(e,t){if(t===RD)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=lO(e);if(!eO(i,t,e.type_))return Fde(e,i,t);let a=i[t];if(e.finalized_||!YD(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Ede(t))return a;if(a===IO(e.base_,t)){zO(e);let n=e.type_===1?+t:t,r=BO(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in lO(e)},ownKeys(e){return Reflect.ownKeys(lO(e))},set(e,t,n){let r=LO(lO(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=IO(lO(e),t),i=r?.[RD];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(Tde(n,r)&&(n!==void 0||eO(e.base_,t,e.type_)))return!0;zO(e),RO(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Nde(e,t,n),!0)},deleteProperty(e,t){return zO(e),IO(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),RO(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=lO(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[KD]:!0,[WD]:e.type_!==1||t!==`length`,[GD]:r[GD],[qD]:n[t]}},defineProperty(){zD(11)},getPrototypeOf(e){return VD(e.base_)},setPrototypeOf(){zD(12)}},FO={};for(let e in PO){let t=PO[e];FO[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}FO.deleteProperty=function(e,t){return FO.set.call(this,e,t,void 0)},FO.set=function(e,t,n){return PO.set.call(this,e[0],t,n,e[0])};function IO(e,t){let n=e[RD];return(n?lO(n):e)[t]}function Fde(e,t,n){let r=LO(t,n);return r?qD in r?r[qD]:r.get?.call(e.draft_):void 0}function LO(e,t){if(!(t in e))return;let n=VD(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=VD(n)}}function RO(e){e.modified_||(e.modified_=!0,e.parent_&&RO(e.parent_))}function zO(e){e.copy_||=(e.assigned_=new Map,dO(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Ide=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(sO(e)&&!sO(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}sO(t)||zD(6),n!==void 0&&!sO(n)&&zD(7);let r;if(YD(e)){let i=EO(this),a=BO(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?wO(i):TO(i)}return CO(i,n),DO(r,i)}else if(!e||!oO(e)){if(r=t(e),r===void 0&&(r=e),r===ID&&(r=void 0),this.autoFreeze_&&fO(r,!0),n){let t=[],i=[];yO(gO).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else zD(1,e)},this.produceWithPatches=(e,t)=>{if(sO(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},cO(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),cO(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),cO(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){YD(e)||zD(8),JD(e)&&(e=VO(e));let t=EO(this),n=BO(t,e,void 0);return n[RD].isManual_=!0,TO(t),n}finishDraft(e,t){let n=e&&e[RD];(!n||!n.isManual_)&&zD(9);let{scope_:r}=n;return CO(r,t),DO(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=yO(gO).applyPatches_;return JD(e)?r(e,t):this.produce(e,e=>r(e,t))}};function BO(e,t,n,r){let[i,a]=iO(t)?yO(hO).proxyMap_(t,n):aO(t)?yO(hO).proxySet_(t,n):Pde(t,n);return(n?.scope_??SO()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Mde(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function VO(e){return JD(e)||zD(10,e),HO(e)}function HO(e){if(!YD(e)||mO(e))return e;let t=e[RD],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=dO(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=dO(e,!0);return QD(n,(e,t)=>{nO(n,e,HO(t))},r),t&&(t.finalized_=!1),n}var UO=new Ide().produce;function WO(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Lde=WO(),Rde=WO,zde=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?PD:PD.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function GO(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(Ek(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>FD(t)&&t.type===e,n}var KO=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function qO(e){return YD(e)?UO(e,()=>{}):e}function JO(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function Bde(e){return typeof e==`boolean`}var Vde=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new KO;return t&&(Bde(t)?a.push(Lde):a.push(Rde(t.extraArgument))),a},YO=`RTK_autoBatch`,XO=()=>e=>({payload:e,meta:{[YO]:!0}}),ZO=e=>t=>{setTimeout(t,e)},QO=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?window.requestAnimationFrame:ZO(10):e.type===`callback`?e.queueNotification:ZO(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[YO],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Hde=e=>function(t){let{autoBatch:n=!0}=t??{},r=new KO(e);return n&&r.push(QO(typeof n==`object`?n:void 0)),r};function Ude(e){let t=Vde(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(jD(n))c=ND(n);else throw Error(Ek(1));let l;l=typeof r==`function`?r(t):t();let u=PD;i&&(u=zde({trace:!1,...typeof i==`object`&&i}));let d=Hde(Cde(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return MD(c,o,p)}function $O(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(Ek(28));if(r in t)throw Error(Ek(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Wde(e){return typeof e==`function`}function Gde(e,t){let[n,r,i]=$O(t),a;if(Wde(e))a=()=>qO(e());else{let t=qO(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n)if(JD(e)){let r=n(e,t);return r===void 0?e:r}else if(YD(e))return UO(e,e=>n(e,t));else{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}return e},e)}return o.getInitialState=a,o}var Kde=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,qde=(e=21)=>{let t=``,n=e;for(;n--;)t+=Kde[Math.random()*64|0];return t},Jde=Symbol.for(`rtk-slice-createasyncthunk`);function Yde(e,t){return`${e}/${t}`}function Xde({creators:e}={}){let t=e?.asyncThunk?.[Jde];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(Ek(11));let i=(typeof e.reducers==`function`?e.reducers(Qde()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(Ek(12));if(n in o.sliceCaseReducersByType)throw Error(Ek(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:Yde(n,r),createNotation:typeof e.reducers==`function`};efe(a)?nfe(o,a,s,t):$de(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?$O(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return Gde(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=JO(d,r,m)),i}function i(t=l){return JO(JO(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=Zde(a,t,()=>JO(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function Zde(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var ek=Xde();function Qde(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function $de({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!tfe(r))throw Error(Ek(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?GO(e,o):GO(e))}function efe(e){return e._reducerDefinitionType===`asyncThunk`}function tfe(e){return e._reducerDefinitionType===`reducerWithPrepare`}function nfe({type:e,reducerName:t},n,r,i){if(!i)throw Error(Ek(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||tk,pending:s||tk,rejected:c||tk,settled:l||tk})}function tk(){}var rfe=`task`,nk=`listener`,rk=`completed`,ik=`cancelled`,ife=`task-${ik}`,afe=`task-${rk}`,ak=`${nk}-${ik}`,ofe=`${nk}-${rk}`,ok=class{constructor(e){this.code=e,this.message=`${rfe} ${ik} (reason: ${e})`}name=`TaskAbortError`;message},sk=(e,t)=>{if(typeof e!=`function`)throw TypeError(Ek(32))},ck=()=>{},lk=(e,t=ck)=>(e.catch(t),e),uk=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),dk=e=>{if(e.aborted)throw new ok(e.reason)};function fk(e,t){let n=ck;return new Promise((r,i)=>{let a=()=>i(new ok(e.reason));if(e.aborted){a();return}n=uk(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=ck})}var sfe=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof ok?`cancelled`:`rejected`,error:e}}finally{t?.()}},pk=e=>t=>lk(fk(e,t).then(t=>(dk(e),t))),mk=e=>{let t=pk(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:hk}=Object,gk={},_k=`listenerMiddleware`,cfe=(e,t)=>{let n=t=>uk(e,()=>t.abort(e.reason));return(r,i)=>{sk(r,`taskExecutor`);let a=new AbortController;n(a);let o=sfe(async()=>{dk(e),dk(a.signal);let t=await r({pause:pk(a.signal),delay:mk(a.signal),signal:a.signal});return dk(a.signal),t},()=>a.abort(afe));return i?.autoJoin&&t.push(o.catch(ck)),{result:pk(e)(o),cancel(){a.abort(ife)}}}},lfe=(e,t)=>{let n=async(n,r)=>{dk(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await fk(t,Promise.race(a));return dk(t),e}finally{i()}};return(e,t)=>lk(n(e,t))},vk=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=GO(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(Ek(21));return sk(a,`options.listener`),{predicate:i,type:t,effect:a}},yk=hk(e=>{let{type:t,predicate:n,effect:r}=vk(e);return{id:qde(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(Ek(22))}}},{withTypes:()=>yk}),bk=(e,t)=>{let{type:n,effect:r,predicate:i}=vk(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},xk=e=>{e.pending.forEach(e=>{e.abort(ak)})},ufe=(e,t)=>()=>{for(let e of t.keys())xk(e);e.clear()},Sk=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},Ck=hk(GO(`${_k}/add`),{withTypes:()=>Ck}),dfe=GO(`${_k}/removeAll`),wk=hk(GO(`${_k}/remove`),{withTypes:()=>wk}),ffe=(...e)=>{console.error(`${_k}/error`,...e)},Tk=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=ffe}=e;sk(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&xk(e)}),c=e=>s(bk(t,e)??yk(e));hk(c,{withTypes:()=>c});let l=e=>{let n=bk(t,e);return n&&(n.unsubscribe(),e.cancelActive&&xk(n)),!!n};hk(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=lfe(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,hk({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:mk(u.signal),pause:pk(u.signal),extra:a,signal:u.signal,fork:cfe(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(ak),n.delete(e))})},cancel:()=>{u.abort(ak),e.pending.delete(u)},throwIfCancelled:()=>{dk(u.signal)}})))}catch(e){e instanceof ok||Sk(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(ofe),i(e),e.pending.delete(u)}},d=ufe(t,n);return{middleware:e=>n=>r=>{if(!FD(r))return n(r);if(Ck.match(r))return c(r.payload);if(dfe.match(r)){d();return}if(wk.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===gk)throw Error(Ek(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,Sk(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=gk}return s},startListening:c,stopListening:l,clearListeners:d}};function Ek(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Dk=ek({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),{setMargin:pfe,setLayout:mfe,setChartSize:hfe,setScale:gfe}=Dk.actions,_fe=Dk.reducer;function Ok(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function kk(e){return Number.isFinite(e)}function Ak(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function jk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Mk(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:s}=t;if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&kE(e[a]))return Mk(Mk({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&kE(e[o]))return Mk(Mk({},e),{},{[o]:e[o]+(i||0)})}return e},Pk=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,Fk=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},Ik=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:s,isCategorical:c,categoricalDomain:l,tickCount:u,ticks:d,niceTicks:f,axisType:p}=e;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?EE(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return kk(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(RE):c&&l?l.map((e,t)=>{var n=o.map(e);return kk(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(RE):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return kk(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(RE):o.domain().map((e,t)=>{var n=o.map(e);return kk(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(RE)},Sfe=(e,t)=>{if(!t||t.length!==2||!kE(t[0])||!kE(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!kE(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:iue,none:_E,silhouette:aue,wiggle:oue,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},wfe=(e,t,n)=>{var r=Cfe[n]??_E,i=rue().keys(t).value((e,t)=>Number(Nk(e,t,0))).order(vE).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=Nk(e[i],t[r],0);Array.isArray(a)&&a.length===2&&kE(a[0])&&kE(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function Lk(e){return e==null?void 0:String(e)}function Rk(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=e;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!IE(i[t.dataKey])){var s=FE(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=Nk(i,IE(o)?t.dataKey:o),l=t.scale.map(c);return kE(l)?l:null}var zk=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:a,index:o}=e;if(t.type===`category`)return n[o]?n[o].coordinate+r:null;var s=Nk(a,t.dataKey,t.scale.domain()[o]);if(IE(s))return null;var c=t.scale.map(s);return kE(c)?c-i/2+r:null},Tfe=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type===`number`){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},Efe=e=>{var t=e.flat(2).filter(kE);return[Math.min(...t),Math.max(...t)]},Dfe=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],Ofe=(e,t,n)=>{if(e!=null)return Dfe(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var{stackedData:o}=a,s=o.reduce((e,r)=>{var i=Efe(Ok(r,t,n));return!kk(i[0])||!kk(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(s[0],r[0]),Math.max(s[1],r[1])]},[1/0,-1/0]))},Bk=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Vk=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Hk=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=(0,CD.default)(t,e=>e.coordinate),a=1/0,o=1,s=i.length;o{if(t===`horizontal`)return e.chartX;if(t===`vertical`)return e.chartY},Afe=(e,t)=>t===`centric`?e.angle:e.radius,Gk=e=>e.layout.width,Kk=e=>e.layout.height,jfe=e=>e.layout.scale,qk=e=>e.layout.margin,Jk=bD(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Yk=bD(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Xk=`data-recharts-item-index`,Mfe=`data-recharts-item-id`;function Zk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qk(e){for(var t=1;te.brush.height;function Lfe(e){return Yk(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Rfe(e){return Yk(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function zfe(e){return Jk(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+t.height:e,0)}function Bfe(e){return Jk(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+t.height:e,0)}var $k=bD([Gk,Kk,qk,Ife,Lfe,Rfe,zfe,Bfe,wD,yde],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=Qk(Qk({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=xfe(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return Qk(Qk({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Vfe=bD($k,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),eA=bD(Gk,Kk,(e,t)=>({x:0,y:0,width:e,height:t})),Hfe=(0,y.createContext)(null),tA=()=>(0,y.useContext)(Hfe)!=null,nA=e=>e.brush,rA=bD([nA,$k,qk],(e,t,n)=>({height:e.height,x:kE(e.x)?e.x:t.left,y:kE(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:kE(e.width)?e.width:t.width})),Ufe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}e.debounce=t})),Wfe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Ufe();function n(e,n=0,r={}){typeof r!=`object`&&(r={});let{leading:i=!1,trailing:a=!0,maxWait:o}=r,s=[,,];i&&(s[0]=`leading`),a&&(s[1]=`trailing`);let c,l=null,u=t.debounce(function(...t){c=e.apply(this,t),l=null},n,{edges:s}),d=function(...t){return o!=null&&(l===null&&(l=Date.now()),Date.now()-l>=o)?(c=e.apply(this,t),l=Date.now(),u.cancel(),u.schedule(),c):(u.apply(this,t),c)};return d.cancel=u.cancel,d.flush=()=>(u.flush(),c),d}e.debounce=n})),Gfe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Wfe();function n(e,n=0,r={}){let{leading:i=!0,trailing:a=!0}=r;return t.debounce(e,n,{leading:i,maxWait:n,trailing:a})}e.throttle=n})),Kfe=o(((e,t)=>{t.exports=Gfe().throttle})),qfe=!0,iA=function(e,t){var n=[...arguments].slice(2);if(qfe&&typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e))if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}},aA={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},oA=(e,t,n)=>{var{width:r=aA.width,height:i=aA.height,aspect:a,maxHeight:o}=n,s=OE(r)?e:Number(r),c=OE(i)?t:Number(i);return a&&a>0&&(s?c=s/a:c&&(s=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:s,calculatedHeight:c}},Jfe={width:0,height:0,overflow:`visible`},Yfe={width:0,overflowX:`visible`},Xfe={height:0,overflowY:`visible`},Zfe={},Qfe=e=>{var{width:t,height:n}=e,r=OE(t),i=OE(n);return r&&i?Jfe:r?Yfe:i?Xfe:Zfe};function $fe(e){var{width:t,height:n,aspect:r}=e,i=t,a=n;return i===void 0&&a===void 0?(i=aA.width,a=aA.height):i===void 0?i=r&&r>0?void 0:aA.width:a===void 0&&(a=r&&r>0?void 0:aA.height),{width:i,height:a}}var epe=l(Kfe());function sA(){return sA=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return ipe(i)?y.createElement(uA.Provider,{value:i},t):null}var fA=()=>(0,y.useContext)(uA),ape=(0,y.forwardRef)((e,t)=>{var{aspect:n,initialDimension:r=aA.initialDimension,width:i,height:a,minWidth:o=aA.minWidth,minHeight:s,maxHeight:c,children:l,debounce:u=aA.debounce,id:d,className:f,onResize:p,style:m={}}=e,h=(0,y.useRef)(null),g=(0,y.useRef)();g.current=p,(0,y.useImperativeHandle)(t,()=>h.current);var[_,v]=(0,y.useState)({containerWidth:r.width,containerHeight:r.height}),b=(0,y.useCallback)((e,t)=>{v(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,y.useEffect)(()=>{if(h.current==null||typeof ResizeObserver>`u`)return zE;var e=e=>{var t,n=e[0];if(n!=null){var{width:r,height:i}=n.contentRect;b(r,i),(t=g.current)==null||t.call(g,r,i)}};u>0&&(e=(0,epe.default)(e,u,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),{width:n,height:r}=h.current.getBoundingClientRect();return b(n,r),t.observe(h.current),()=>{t.disconnect()}},[b,u]);var{containerWidth:x,containerHeight:S}=_;iA(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var{calculatedWidth:C,calculatedHeight:w}=oA(x,S,{width:i,height:a,aspect:n,maxHeight:c});return iA(C!=null&&C>0||w!=null&&w>0,`The width(%s) and height(%s) of chart should be greater than 0, + H${$E}M${2*o},${i} + A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return y.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${$E/8}h${$E}v${$E*3/4}h${-$E}z`,className:`recharts-legend-icon`});if(y.isValidElement(t.legendIcon)){var l=Eue({},t);return delete l.legendIcon,y.cloneElement(t.legendIcon,l)}return y.createElement(GE,{fill:s,cx:i,cy:i,size:$E,sizeType:`diameter`,type:c})}function Mue(e){var{payload:t,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=e,s={x:0,y:0,width:$E,height:$E},c={display:r===`horizontal`?`inline-block`:`block`,marginRight:10},l={display:`inline-block`,verticalAlign:`middle`,marginRight:4};return t.map((t,r)=>{var u=t.formatter||i,d=_T({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var f=t.inactive?a:t.color,p=u?u(t.value,t,r):t.value;return y.createElement(`li`,ZE({className:d,style:c,key:`legend-item-${r}`},JE(e,t,r)),y.createElement(TT,{width:n,height:n,viewBox:s,style:l,"aria-label":`${p} legend icon`},y.createElement(jue,{data:t,iconType:o,inactiveColor:a})),y.createElement(`span`,{className:`recharts-legend-item-text`,style:{color:f}},p))})}var Nue=e=>{var t=XE(e,Aue),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return y.createElement(`ul`,{className:`recharts-default-legend`,style:a},y.createElement(Mue,ZE({},t,{payload:n})))},Pue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){let n=new Map;for(let r=0;r{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){return function(...n){return e.apply(this,n.slice(0,t))}}e.ary=t})),eD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e}e.identity=t})),Iue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Number.isSafeInteger(e)&&e>=0}e.isLength=t})),tD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Iue();function n(e){return e!=null&&typeof e!=`function`&&t.isLength(e.length)}e.isArrayLike=n})),Lue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`object`&&!!e}e.isObjectLike=t})),Rue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=tD(),n=Lue();function r(e){return n.isObjectLike(e)&&t.isArrayLike(e)}e.isArrayLikeObject=r})),zue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=CE();function n(e){return function(n){return t.get(n,e)}}e.property=n})),nD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}e.isObject=t})),rD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e==null||typeof e!=`object`&&typeof e!=`function`}e.isPrimitive=t})),iD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}e.isEqualsSameValueZero=t})),Bue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=nD(),n=rD(),r=iD();function i(e,t,n){return typeof n==`function`?a(e,t,function e(t,r,i,o,s,c){let l=n(t,r,i,o,s,c);return l===void 0?a(t,r,e,c):!!l},new Map):i(e,t,()=>void 0)}function a(e,n,i,s){if(n===e)return!0;switch(typeof n){case`object`:return o(e,n,i,s);case`function`:return Object.keys(n).length>0?a(e,{...n},i,s):r.isEqualsSameValueZero(e,n);default:return t.isObject(e)?typeof n==`string`?n===``:!0:r.isEqualsSameValueZero(e,n)}}function o(e,t,r,i){if(t==null)return!0;if(Array.isArray(t))return c(e,t,r,i);if(t instanceof Map)return s(e,t,r,i);if(t instanceof Set)return l(e,t,r,i);let a=Object.keys(t);if(e==null||n.isPrimitive(e))return a.length===0;if(a.length===0)return!0;if(i?.has(t))return i.get(t)===e;i?.set(t,e);try{for(let o=0;o{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Bue();function n(e,n){return t.isMatchWith(e,n,()=>void 0)}e.isMatch=n})),Vue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}e.getSymbols=t})),oD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}e.getTag=t})),sD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),e.argumentsTag=`[object Arguments]`,e.arrayBufferTag=`[object ArrayBuffer]`,e.arrayTag=`[object Array]`,e.bigInt64ArrayTag=`[object BigInt64Array]`,e.bigUint64ArrayTag=`[object BigUint64Array]`,e.booleanTag=`[object Boolean]`,e.dataViewTag=`[object DataView]`,e.dateTag=`[object Date]`,e.errorTag=`[object Error]`,e.float32ArrayTag=`[object Float32Array]`,e.float64ArrayTag=`[object Float64Array]`,e.functionTag=`[object Function]`,e.int16ArrayTag=`[object Int16Array]`,e.int32ArrayTag=`[object Int32Array]`,e.int8ArrayTag=`[object Int8Array]`,e.mapTag=`[object Map]`,e.numberTag=`[object Number]`,e.objectTag=`[object Object]`,e.regexpTag=`[object RegExp]`,e.setTag=`[object Set]`,e.stringTag=`[object String]`,e.symbolTag=`[object Symbol]`,e.uint16ArrayTag=`[object Uint16Array]`,e.uint32ArrayTag=`[object Uint32Array]`,e.uint8ArrayTag=`[object Uint8Array]`,e.uint8ClampedArrayTag=`[object Uint8ClampedArray]`})),Hue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}e.isTypedArray=t})),cD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Vue(),n=oD(),r=sD(),i=rD(),a=Hue();function o(e,t){return s(e,void 0,e,new Map,t)}function s(e,t,n,r=new Map,o=void 0){let u=o?.(e,t,n,r);if(u!==void 0)return u;if(i.isPrimitive(e))return e;if(r.has(e))return r.get(e);if(Array.isArray(e)){let t=Array(e.length);r.set(e,t);for(let i=0;i{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=cD();function n(e){return t.cloneDeepWithImpl(e,void 0,e,new Map,void 0)}e.cloneDeep=n})),Wue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=aD(),n=Uue();function r(e){return e=n.cloneDeep(e),n=>t.isMatch(n,e)}e.matches=r})),Gue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=cD(),n=oD(),r=sD();function i(e,i){return t.cloneDeepWith(e,(a,o,s,c)=>{let l=i?.(a,o,s,c);if(l!==void 0)return l;if(typeof e==`object`){if(n.getTag(e)===r.objectTag&&typeof e.constructor!=`function`){let n={};return c.set(e,n),t.copyProperties(n,e,s,c),n}switch(Object.prototype.toString.call(e)){case r.numberTag:case r.stringTag:case r.booleanTag:{let n=new e.constructor(e?.valueOf());return t.copyProperties(n,e),n}case r.argumentsTag:{let n={};return t.copyProperties(n,e),n.length=e.length,n[Symbol.iterator]=e[Symbol.iterator],n}default:return}}})}e.cloneDeepWith=i})),Kue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Gue();function n(e){return t.cloneDeepWith(e)}e.cloneDeep=n})),lD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=/^(?:0|[1-9]\d*)$/;function n(e,n=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=oD();function n(e){return typeof e==`object`&&!!e&&t.getTag(e)===`[object Arguments]`}e.isArguments=n})),Jue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=bE(),n=lD(),r=que(),i=SE();function a(e,a){let o;if(o=Array.isArray(a)?a:typeof a==`string`&&t.isDeepKey(a)&&e?.[a]==null?i.toPath(a):[a],o.length===0)return!1;let s=e;for(let e=0;e{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=aD(),n=xE(),r=Kue(),i=CE(),a=Jue();function o(e,o){switch(typeof e){case`object`:Object.is(e?.valueOf(),-0)&&(e=`-0`);break;case`number`:e=n.toKey(e);break}return o=r.cloneDeep(o),function(n){let r=i.get(n,e);return r===void 0?a.has(n,e):o===void 0?r===void 0:t.isMatch(r,o)}}e.matchesProperty=o})),Xue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=eD(),n=zue(),r=Wue(),i=Yue();function a(e){if(e==null)return t.identity;switch(typeof e){case`function`:return e;case`object`:return Array.isArray(e)&&e.length===2?i.matchesProperty(e[0],e[1]):r.matches(e);case`string`:case`symbol`:case`number`:return n.property(e)}}e.iteratee=a})),Zue=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Pue(),n=Fue(),r=eD(),i=Rue(),a=Xue();function o(e,o=r.identity){return i.isArrayLikeObject(e)?t.uniqBy(Array.from(e),n.ary(a.iteratee(o),1)):[]}e.uniqBy=o})),uD=l(o(((e,t)=>{t.exports=Zue().uniqBy}))());function dD(e,t,n){return t===!0?(0,uD.default)(e,n):typeof t==`function`?(0,uD.default)(e,t):e}var Que=o((e=>{var t=f(),n=Xe();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),$ue=o(((e,t)=>{t.exports=Que()})),fD=(0,y.createContext)(null),pD=$ue(),ede=e=>e,mD=()=>{var e=(0,y.useContext)(fD);return e?e.store.dispatch:ede},hD=()=>{},tde=()=>hD,nde=(e,t)=>e===t;function gD(e){var t=(0,y.useContext)(fD),n=(0,y.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:hD,[t,e]);return(0,pD.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:tde,t?t.store.getState:hD,t?t.store.getState:hD,n,nde)}function rde(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function ide(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function ade(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var _D=e=>Array.isArray(e)?e:[e];function ode(e){let t=Array.isArray(e[0])?e[0]:e;return ade(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function sde(e,t){let n=[],{length:r}=e;for(let i=0;i{n=yD(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function dde(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),rde(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=bD,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=_D(c),p=_D(u),m=ode(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=sde(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var xD=dde(bD),fde=Object.assign((e,t=xD)=>{ide(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>fde}),pde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`symbol`?1:e===null?2:e===void 0?3:e===e?0:4}e.compareValues=(e,n,r)=>{if(e!==n){let i=t(e),a=t(n);if(i===a&&i===0){if(en)return r===`desc`?-1:1}return r===`desc`?a-i:i-a}return 0}})),SD=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof e==`symbol`||e instanceof Symbol}e.isSymbol=t})),mde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=SD(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(e,i){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||t.isSymbol(e)?!0:typeof e==`string`&&(r.test(e)||!n.test(e))||i!=null&&Object.hasOwn(i,e)}e.isKey=i})),hde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=pde(),n=mde(),r=SE();function i(e,i,a,o){if(e==null)return[];a=o?void 0:a,Array.isArray(e)||(e=Object.values(e)),Array.isArray(i)||(i=i==null?[null]:[i]),i.length===0&&(i=[null]),Array.isArray(a)||(a=a==null?[]:[a]),a=a.map(e=>String(e));let s=(e,t)=>{let n=e;for(let e=0;et==null||e==null?t:typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:s(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?s(t,e):typeof t==`object`?t[e]:t,l=i.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||n.isKey(e)?e:{key:e,path:r.toPath(e)}));return e.map(e=>({original:e,criteria:l.map(t=>c(t,e))})).slice().sort((e,n)=>{for(let r=0;re.original)}e.orderBy=i})),gde=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=lD(),n=tD(),r=nD(),i=iD();function a(e,a,o){return r.isObject(o)&&(typeof a==`number`&&n.isArrayLike(o)&&t.isIndex(a)&&a{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=hde(),n=gde(),r=CD();function i(e,...i){let a=i.length;return a>1&&r.isIterateeCall(e,i[0],i[1])?i=[]:a>2&&r.isIterateeCall(i[0],i[1],i[2])&&(i=[i[0]]),t.orderBy(e,n.flatten(i),[`asc`])}e.sortBy=i})),wD=l(o(((e,t)=>{t.exports=_de().sortBy}))()),TD=e=>e.legend.settings,vde=e=>e.legend.size,yde=xD([e=>e.legend.payload,TD],(e,t)=>{var{itemSorter:n}=t,r=e.flat(1);return n?(0,wD.default)(r,n):r});function bde(){return gD(yde)}var ED=1;function DD(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[t,n]=(0,y.useState)({height:0,left:0,top:0,width:0});return[t,(0,y.useCallback)(e=>{if(e!=null){var r=e.getBoundingClientRect(),i={height:r.height,left:r.left,top:r.top,width:r.width};(Math.abs(i.height-t.height)>ED||Math.abs(i.left-t.left)>ED||Math.abs(i.top-t.top)>ED||Math.abs(i.width-t.width)>ED)&&n({height:i.height,left:i.left,top:i.top,width:i.width})}},[t.width,t.height,t.top,t.left,...e])]}function OD(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var kD=typeof Symbol==`function`&&Symbol.observable||`@@observable`,AD=()=>Math.random().toString(36).substring(7).split(``).join(`.`),jD={INIT:`@@redux/INIT${AD()}`,REPLACE:`@@redux/REPLACE${AD()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${AD()}`};function MD(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function ND(e,t,n){if(typeof e!=`function`)throw Error(OD(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(OD(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(OD(1));return n(ND)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(OD(3));return i}function d(e){if(typeof e!=`function`)throw Error(OD(4));if(c)throw Error(OD(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(OD(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!MD(e))throw Error(OD(7));if(e.type===void 0)throw Error(OD(8));if(typeof e.type!=`string`)throw Error(OD(17));if(c)throw Error(OD(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(OD(10));r=e,f({type:jD.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(OD(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[kD](){return this}}}return f({type:jD.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[kD]:m}}function xde(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:jD.INIT})===void 0)throw Error(OD(12));if(n(void 0,{type:jD.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(OD(13))})}function PD(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function Sde(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(OD(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=FD(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function ID(e){return MD(e)&&`type`in e&&typeof e.type==`string`}var LD=Symbol.for(`immer-nothing`),RD=Symbol.for(`immer-draftable`),zD=Symbol.for(`immer-state`);function BD(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var VD=Object,HD=VD.getPrototypeOf,UD=`constructor`,WD=`prototype`,GD=`configurable`,KD=`enumerable`,qD=`writable`,JD=`value`,YD=e=>!!e&&!!e[zD];function XD(e){return e?QD(e)||iO(e)||!!e[RD]||!!e[UD]?.[RD]||aO(e)||oO(e):!1}var Cde=VD[WD][UD].toString(),ZD=new WeakMap;function QD(e){if(!e||!sO(e))return!1;let t=HD(e);if(t===null||t===VD[WD])return!0;let n=VD.hasOwnProperty.call(t,UD)&&t[UD];if(n===Object)return!0;if(!cO(n))return!1;let r=ZD.get(n);return r===void 0&&(r=Function.toString.call(n),ZD.set(n,r)),r===Cde}function $D(e,t,n=!0){eO(e)===0?(n?Reflect.ownKeys(e):VD.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function eO(e){let t=e[zD];return t?t.type_:iO(e)?1:aO(e)?2:oO(e)?3:0}var tO=(e,t,n=eO(e))=>n===2?e.has(t):VD[WD].hasOwnProperty.call(e,t),nO=(e,t,n=eO(e))=>n===2?e.get(t):e[t],rO=(e,t,n,r=eO(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function wde(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var iO=Array.isArray,aO=e=>e instanceof Map,oO=e=>e instanceof Set,sO=e=>typeof e==`object`,cO=e=>typeof e==`function`,lO=e=>typeof e==`boolean`;function Tde(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var uO=e=>e.copy_||e.base_,dO=e=>e.modified_?e.copy_:e.base_;function fO(e,t){if(aO(e))return new Map(e);if(oO(e))return new Set(e);if(iO(e))return Array[WD].slice.call(e);let n=QD(e);if(t===!0||t===`class_only`&&!n){let t=VD.getOwnPropertyDescriptors(e);delete t[zD];let n=Reflect.ownKeys(t);for(let r=0;r1&&VD.defineProperties(e,{set:mO,add:mO,clear:mO,delete:mO}),VD.freeze(e),t&&$D(e,(e,t)=>{pO(t,!0)},!1),e)}function Ede(){BD(2)}var mO={[JD]:Ede};function hO(e){return e===null||!sO(e)?!0:VD.isFrozen(e)}var gO=`MapSet`,_O=`Patches`,vO=`ArrayMethods`,yO={};function bO(e){let t=yO[e];return t||BD(0,e),t}var xO=e=>!!yO[e],SO,CO=()=>SO,Dde=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:xO(gO)?bO(gO):void 0,arrayMethodsPlugin_:xO(vO)?bO(vO):void 0});function wO(e,t){t&&(e.patchPlugin_=bO(_O),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function TO(e){EO(e),e.drafts_.forEach(Ode),e.drafts_=null}function EO(e){e===SO&&(SO=e.parent_)}var DO=e=>SO=Dde(SO,e);function Ode(e){let t=e[zD];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function OO(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[zD].modified_&&(TO(t),BD(4)),XD(e)&&(e=kO(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[zD].base_,e,t)}else e=kO(t,n);return kde(t,e,!0),TO(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===LD?void 0:e}function kO(e,t){if(hO(t))return t;let n=t[zD];if(!n)return PO(t,e.handledSet_,e);if(!jO(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);NO(n,e)}return n.copy_}function kde(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&pO(t,n)}function AO(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var jO=(e,t)=>e.scope_===t,Ade=[];function MO(e,t,n,r){let i=uO(e),a=e.type_;if(r!==void 0&&nO(i,r,a)===t){rO(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;$D(i,(e,n)=>{if(YD(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Ade;for(let e of o)rO(i,e,n,a)}function jde(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!jO(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=dO(i);MO(e,i.draft_??i,a,n),NO(i,r)})}function NO(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}AO(e)}}function Mde(e,t,n){let{scope_:r}=e;if(YD(n)){let i=n[zD];jO(i,r)&&i.callbacks_.push(function(){BO(e),MO(e,n,dO(i),t)})}else XD(n)&&e.callbacks_.push(function(){let i=uO(e);e.type_===3?i.has(n)&&PO(n,r.handledSet_,r):nO(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&PO(nO(e.copy_,t,e.type_),r.handledSet_,r)})}function PO(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||YD(e)||t.has(e)||!XD(e)||hO(e)?e:(t.add(e),$D(e,(r,i)=>{if(YD(i)){let t=i[zD];jO(t,n)&&(rO(e,r,dO(t),e.type_),AO(t))}else XD(i)&&PO(i,t,n)}),e)}function Nde(e,t){let n=iO(e),r={type_:+!!n,scope_:t?t.scope_:CO(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=FO;n&&(i=[r],a=IO);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var FO={get(e,t){if(t===zD)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=uO(e);if(!tO(i,t,e.type_))return Pde(e,i,t);let a=i[t];if(e.finalized_||!XD(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&Tde(t))return a;if(a===LO(e.base_,t)){BO(e);let n=e.type_===1?+t:t,r=VO(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in uO(e)},ownKeys(e){return Reflect.ownKeys(uO(e))},set(e,t,n){let r=RO(uO(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=LO(uO(e),t),i=r?.[zD];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(wde(n,r)&&(n!==void 0||tO(e.base_,t,e.type_)))return!0;BO(e),zO(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Mde(e,t,n),!0)},deleteProperty(e,t){return BO(e),LO(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),zO(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=uO(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[qD]:!0,[GD]:e.type_!==1||t!==`length`,[KD]:r[KD],[JD]:n[t]}},defineProperty(){BD(11)},getPrototypeOf(e){return HD(e.base_)},setPrototypeOf(){BD(12)}},IO={};for(let e in FO){let t=FO[e];IO[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}IO.deleteProperty=function(e,t){return IO.set.call(this,e,t,void 0)},IO.set=function(e,t,n){return FO.set.call(this,e[0],t,n,e[0])};function LO(e,t){let n=e[zD];return(n?uO(n):e)[t]}function Pde(e,t,n){let r=RO(t,n);return r?JD in r?r[JD]:r.get?.call(e.draft_):void 0}function RO(e,t){if(!(t in e))return;let n=HD(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=HD(n)}}function zO(e){e.modified_||(e.modified_=!0,e.parent_&&zO(e.parent_))}function BO(e){e.copy_||=(e.assigned_=new Map,fO(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Fde=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(cO(e)&&!cO(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}cO(t)||BD(6),n!==void 0&&!cO(n)&&BD(7);let r;if(XD(e)){let i=DO(this),a=VO(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?TO(i):EO(i)}return wO(i,n),OO(r,i)}else if(!e||!sO(e)){if(r=t(e),r===void 0&&(r=e),r===LD&&(r=void 0),this.autoFreeze_&&pO(r,!0),n){let t=[],i=[];bO(_O).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}else BD(1,e)},this.produceWithPatches=(e,t)=>{if(cO(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},lO(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),lO(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),lO(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){XD(e)||BD(8),YD(e)&&(e=HO(e));let t=DO(this),n=VO(t,e,void 0);return n[zD].isManual_=!0,EO(t),n}finishDraft(e,t){let n=e&&e[zD];(!n||!n.isManual_)&&BD(9);let{scope_:r}=n;return wO(r,t),OO(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=bO(_O).applyPatches_;return YD(e)?r(e,t):this.produce(e,e=>r(e,t))}};function VO(e,t,n,r){let[i,a]=aO(t)?bO(gO).proxyMap_(t,n):oO(t)?bO(gO).proxySet_(t,n):Nde(t,n);return(n?.scope_??CO()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?jde(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function HO(e){return YD(e)||BD(10,e),UO(e)}function UO(e){if(!XD(e)||hO(e))return e;let t=e[zD],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=fO(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=fO(e,!0);return $D(n,(e,t)=>{rO(n,e,UO(t))},r),t&&(t.finalized_=!1),n}var WO=new Fde().produce;function GO(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Ide=GO(),Lde=GO,Rde=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?FD:FD.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function KO(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(Dk(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>ID(t)&&t.type===e,n}var qO=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function JO(e){return XD(e)?WO(e,()=>{}):e}function YO(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function zde(e){return typeof e==`boolean`}var Bde=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new qO;return t&&(zde(t)?a.push(Ide):a.push(Lde(t.extraArgument))),a},XO=`RTK_autoBatch`,ZO=()=>e=>({payload:e,meta:{[XO]:!0}}),QO=e=>t=>{setTimeout(t,e)},$O=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?window.requestAnimationFrame:QO(10):e.type===`callback`?e.queueNotification:QO(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[XO],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Vde=e=>function(t){let{autoBatch:n=!0}=t??{},r=new qO(e);return n&&r.push($O(typeof n==`object`?n:void 0)),r};function Hde(e){let t=Bde(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(MD(n))c=PD(n);else throw Error(Dk(1));let l;l=typeof r==`function`?r(t):t();let u=FD;i&&(u=Rde({trace:!1,...typeof i==`object`&&i}));let d=Vde(Sde(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return ND(c,o,p)}function ek(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(Dk(28));if(r in t)throw Error(Dk(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Ude(e){return typeof e==`function`}function Wde(e,t){let[n,r,i]=ek(t),a;if(Ude(e))a=()=>JO(e());else{let t=JO(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n)if(YD(e)){let r=n(e,t);return r===void 0?e:r}else if(XD(e))return WO(e,e=>n(e,t));else{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}return e},e)}return o.getInitialState=a,o}var Gde=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,Kde=(e=21)=>{let t=``,n=e;for(;n--;)t+=Gde[Math.random()*64|0];return t},qde=Symbol.for(`rtk-slice-createasyncthunk`);function Jde(e,t){return`${e}/${t}`}function Yde({creators:e}={}){let t=e?.asyncThunk?.[qde];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(Dk(11));let i=(typeof e.reducers==`function`?e.reducers(Zde()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(Dk(12));if(n in o.sliceCaseReducersByType)throw Error(Dk(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:Jde(n,r),createNotation:typeof e.reducers==`function`};$de(a)?tfe(o,a,s,t):Qde(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?ek(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return Wde(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=YO(d,r,m)),i}function i(t=l){return YO(YO(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=Xde(a,t,()=>YO(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function Xde(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var tk=Yde();function Zde(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function Qde({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!efe(r))throw Error(Dk(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?KO(e,o):KO(e))}function $de(e){return e._reducerDefinitionType===`asyncThunk`}function efe(e){return e._reducerDefinitionType===`reducerWithPrepare`}function tfe({type:e,reducerName:t},n,r,i){if(!i)throw Error(Dk(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||nk,pending:s||nk,rejected:c||nk,settled:l||nk})}function nk(){}var nfe=`task`,rk=`listener`,ik=`completed`,ak=`cancelled`,rfe=`task-${ak}`,ife=`task-${ik}`,ok=`${rk}-${ak}`,afe=`${rk}-${ik}`,sk=class{constructor(e){this.code=e,this.message=`${nfe} ${ak} (reason: ${e})`}name=`TaskAbortError`;message},ck=(e,t)=>{if(typeof e!=`function`)throw TypeError(Dk(32))},lk=()=>{},uk=(e,t=lk)=>(e.catch(t),e),dk=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),fk=e=>{if(e.aborted)throw new sk(e.reason)};function pk(e,t){let n=lk;return new Promise((r,i)=>{let a=()=>i(new sk(e.reason));if(e.aborted){a();return}n=dk(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=lk})}var ofe=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof sk?`cancelled`:`rejected`,error:e}}finally{t?.()}},mk=e=>t=>uk(pk(e,t).then(t=>(fk(e),t))),hk=e=>{let t=mk(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:gk}=Object,_k={},vk=`listenerMiddleware`,sfe=(e,t)=>{let n=t=>dk(e,()=>t.abort(e.reason));return(r,i)=>{ck(r,`taskExecutor`);let a=new AbortController;n(a);let o=ofe(async()=>{fk(e),fk(a.signal);let t=await r({pause:mk(a.signal),delay:hk(a.signal),signal:a.signal});return fk(a.signal),t},()=>a.abort(ife));return i?.autoJoin&&t.push(o.catch(lk)),{result:mk(e)(o),cancel(){a.abort(rfe)}}}},cfe=(e,t)=>{let n=async(n,r)=>{fk(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await pk(t,Promise.race(a));return fk(t),e}finally{i()}};return(e,t)=>uk(n(e,t))},yk=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=KO(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(Dk(21));return ck(a,`options.listener`),{predicate:i,type:t,effect:a}},bk=gk(e=>{let{type:t,predicate:n,effect:r}=yk(e);return{id:Kde(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(Dk(22))}}},{withTypes:()=>bk}),xk=(e,t)=>{let{type:n,effect:r,predicate:i}=yk(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},Sk=e=>{e.pending.forEach(e=>{e.abort(ok)})},lfe=(e,t)=>()=>{for(let e of t.keys())Sk(e);e.clear()},Ck=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},wk=gk(KO(`${vk}/add`),{withTypes:()=>wk}),ufe=KO(`${vk}/removeAll`),Tk=gk(KO(`${vk}/remove`),{withTypes:()=>Tk}),dfe=(...e)=>{console.error(`${vk}/error`,...e)},Ek=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=dfe}=e;ck(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&Sk(e)}),c=e=>s(xk(t,e)??bk(e));gk(c,{withTypes:()=>c});let l=e=>{let n=xk(t,e);return n&&(n.unsubscribe(),e.cancelActive&&Sk(n)),!!n};gk(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=cfe(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,gk({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:hk(u.signal),pause:mk(u.signal),extra:a,signal:u.signal,fork:sfe(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(ok),n.delete(e))})},cancel:()=>{u.abort(ok),e.pending.delete(u)},throwIfCancelled:()=>{fk(u.signal)}})))}catch(e){e instanceof sk||Ck(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(afe),i(e),e.pending.delete(u)}},d=lfe(t,n);return{middleware:e=>n=>r=>{if(!ID(r))return n(r);if(wk.match(r))return c(r.payload);if(ufe.match(r)){d();return}if(Tk.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===_k)throw Error(Dk(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,Ck(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=_k}return s},startListening:c,stopListening:l,clearListeners:d}};function Dk(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var Ok=tk({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),{setMargin:ffe,setLayout:pfe,setChartSize:mfe,setScale:hfe}=Ok.actions,gfe=Ok.reducer;function kk(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function Ak(e){return Number.isFinite(e)}function jk(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function Mk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Nk(e){for(var t=1;t{if(t&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:s}=t;if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&AE(e[a]))return Nk(Nk({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&AE(e[o]))return Nk(Nk({},e),{},{[o]:e[o]+(i||0)})}return e},Fk=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,Ik=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},Lk=(e,t,n)=>{if(!e)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:s,isCategorical:c,categoricalDomain:l,tickCount:u,ticks:d,niceTicks:f,axisType:p}=e;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?DE(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return Ak(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(zE):c&&l?l.map((e,t)=>{var n=o.map(e);return Ak(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(zE):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return Ak(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(zE):o.domain().map((e,t)=>{var n=o.map(e);return Ak(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(zE)},xfe=(e,t)=>{if(!t||t.length!==2||!AE(t[0])||!AE(t[1]))return e;var n=Math.min(t[0],t[1]),r=Math.max(t[0],t[1]),i=[e[0],e[1]];return(!AE(e[0])||e[0]r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:rue,none:vE,silhouette:iue,wiggle:aue,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},Cfe=(e,t,n)=>{var r=Sfe[n]??vE,i=nue().keys(t).value((e,t)=>Number(Pk(e,t,0))).order(yE).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=Pk(e[i],t[r],0);Array.isArray(a)&&a.length===2&&AE(a[0])&&AE(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function Rk(e){return e==null?void 0:String(e)}function zk(e){var{axis:t,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=e;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!LE(i[t.dataKey])){var s=IE(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=Pk(i,LE(o)?t.dataKey:o),l=t.scale.map(c);return AE(l)?l:null}var Bk=e=>{var{axis:t,ticks:n,offset:r,bandSize:i,entry:a,index:o}=e;if(t.type===`category`)return n[o]?n[o].coordinate+r:null;var s=Pk(a,t.dataKey,t.scale.domain()[o]);if(LE(s))return null;var c=t.scale.map(s);return AE(c)?c-i/2+r:null},wfe=e=>{var{numericAxis:t}=e,n=t.scale.domain();if(t.type===`number`){var r=Math.min(n[0],n[1]),i=Math.max(n[0],n[1]);return r<=0&&i>=0?0:i<0?i:r}return n[0]},Tfe=e=>{var t=e.flat(2).filter(AE);return[Math.min(...t),Math.max(...t)]},Efe=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],Dfe=(e,t,n)=>{if(e!=null)return Efe(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var{stackedData:o}=a,s=o.reduce((e,r)=>{var i=Tfe(kk(r,t,n));return!Ak(i[0])||!Ak(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(s[0],r[0]),Math.max(s[1],r[1])]},[1/0,-1/0]))},Vk=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Hk=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Uk=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=(0,wD.default)(t,e=>e.coordinate),a=1/0,o=1,s=i.length;o{if(t===`horizontal`)return e.chartX;if(t===`vertical`)return e.chartY},kfe=(e,t)=>t===`centric`?e.angle:e.radius,Kk=e=>e.layout.width,qk=e=>e.layout.height,Afe=e=>e.layout.scale,Jk=e=>e.layout.margin,Yk=xD(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Xk=xD(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),Zk=`data-recharts-item-index`,jfe=`data-recharts-item-id`;function Qk(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $k(e){for(var t=1;te.brush.height;function Ife(e){return Xk(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Lfe(e){return Xk(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Rfe(e){return Yk(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+t.height:e,0)}function zfe(e){return Yk(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+t.height:e,0)}var eA=xD([Kk,qk,Jk,Ffe,Ife,Lfe,Rfe,zfe,TD,vde],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=$k($k({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=bfe(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return $k($k({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Bfe=xD(eA,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),tA=xD(Kk,qk,(e,t)=>({x:0,y:0,width:e,height:t})),Vfe=(0,y.createContext)(null),nA=()=>(0,y.useContext)(Vfe)!=null,rA=e=>e.brush,iA=xD([rA,eA,Jk],(e,t,n)=>({height:e.height,x:AE(e.x)?e.x:t.left,y:AE(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:AE(e.width)?e.width:t.width})),Hfe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}e.debounce=t})),Ufe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Hfe();function n(e,n=0,r={}){typeof r!=`object`&&(r={});let{leading:i=!1,trailing:a=!0,maxWait:o}=r,s=[,,];i&&(s[0]=`leading`),a&&(s[1]=`trailing`);let c,l=null,u=t.debounce(function(...t){c=e.apply(this,t),l=null},n,{edges:s}),d=function(...t){return o!=null&&(l===null&&(l=Date.now()),Date.now()-l>=o)?(c=e.apply(this,t),l=Date.now(),u.cancel(),u.schedule(),c):(u.apply(this,t),c)};return d.cancel=u.cancel,d.flush=()=>(u.flush(),c),d}e.debounce=n})),Wfe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Ufe();function n(e,n=0,r={}){let{leading:i=!0,trailing:a=!0}=r;return t.debounce(e,n,{leading:i,maxWait:n,trailing:a})}e.throttle=n})),Gfe=o(((e,t)=>{t.exports=Wfe().throttle})),Kfe=!0,aA=function(e,t){var n=[...arguments].slice(2);if(Kfe&&typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e))if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}},oA={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},sA=(e,t,n)=>{var{width:r=oA.width,height:i=oA.height,aspect:a,maxHeight:o}=n,s=kE(r)?e:Number(r),c=kE(i)?t:Number(i);return a&&a>0&&(s?c=s/a:c&&(s=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:s,calculatedHeight:c}},qfe={width:0,height:0,overflow:`visible`},Jfe={width:0,overflowX:`visible`},Yfe={height:0,overflowY:`visible`},Xfe={},Zfe=e=>{var{width:t,height:n}=e,r=kE(t),i=kE(n);return r&&i?qfe:r?Jfe:i?Yfe:Xfe};function Qfe(e){var{width:t,height:n,aspect:r}=e,i=t,a=n;return i===void 0&&a===void 0?(i=oA.width,a=oA.height):i===void 0?i=r&&r>0?void 0:oA.width:a===void 0&&(a=r&&r>0?void 0:oA.height),{width:i,height:a}}var $fe=l(Gfe());function cA(){return cA=Object.assign?Object.assign.bind():function(e){for(var t=1;t({width:n,height:r}),[n,r]);return rpe(i)?y.createElement(dA.Provider,{value:i},t):null}var pA=()=>(0,y.useContext)(dA),ipe=(0,y.forwardRef)((e,t)=>{var{aspect:n,initialDimension:r=oA.initialDimension,width:i,height:a,minWidth:o=oA.minWidth,minHeight:s,maxHeight:c,children:l,debounce:u=oA.debounce,id:d,className:f,onResize:p,style:m={}}=e,h=(0,y.useRef)(null),g=(0,y.useRef)();g.current=p,(0,y.useImperativeHandle)(t,()=>h.current);var[_,v]=(0,y.useState)({containerWidth:r.width,containerHeight:r.height}),b=(0,y.useCallback)((e,t)=>{v(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,y.useEffect)(()=>{if(h.current==null||typeof ResizeObserver>`u`)return BE;var e=e=>{var t,n=e[0];if(n!=null){var{width:r,height:i}=n.contentRect;b(r,i),(t=g.current)==null||t.call(g,r,i)}};u>0&&(e=(0,$fe.default)(e,u,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),{width:n,height:r}=h.current.getBoundingClientRect();return b(n,r),t.observe(h.current),()=>{t.disconnect()}},[b,u]);var{containerWidth:x,containerHeight:S}=_;aA(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var{calculatedWidth:C,calculatedHeight:w}=sA(x,S,{width:i,height:a,aspect:n,maxHeight:c});return aA(C!=null&&C>0||w!=null&&w>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the - height and width.`,C,w,i,a,o,s,n),y.createElement(`div`,{id:d?`${d}`:void 0,className:gT(`recharts-responsive-container`,f),style:lA(lA({},m),{},{width:i,height:a,minWidth:o,minHeight:s,maxHeight:c}),ref:h},y.createElement(`div`,{style:Qfe({width:i,height:a})},y.createElement(dA,{width:C,height:w},l)))}),pA=(0,y.forwardRef)((e,t)=>{var n=fA();if(Ak(n.width)&&Ak(n.height))return e.children;var{width:r,height:i}=$fe({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:a,calculatedHeight:o}=oA(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return kE(a)&&kE(o)?y.createElement(dA,{width:a,height:o},e.children):y.createElement(ape,sA({},e,{width:r,height:i,ref:t}))});function mA(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var hA=()=>{var e=tA(),t=hD(Vfe),n=hD(rA),r=hD(nA)?.padding;return!e||!n||!r?t:{width:n.width-r.left-r.right,height:n.height-r.top-r.bottom,x:r.left,y:r.top}},ope={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},gA=()=>hD($k)??ope,_A=()=>hD(Gk),vA=()=>hD(Kk),spe=()=>hD(e=>e.layout.margin),yA=e=>e.layout.layoutType,bA=()=>hD(yA),xA=()=>{var e=bA();if(e===`horizontal`||e===`vertical`)return e},SA=e=>{var t=e.layout.layoutType;if(t===`centric`||t===`radial`)return t},cpe=()=>bA()!==void 0,CA=e=>{var t=pD(),n=tA(),{width:r,height:i}=e,a=fA(),o=r,s=i;return a&&(o=a.width>0?a.width:r,s=a.height>0?a.height:i),(0,y.useEffect)(()=>{!n&&Ak(o)&&Ak(s)&&t(hfe({width:o,height:s}))},[t,n,o,s]),null},wA=Symbol.for(`immer-nothing`),TA=Symbol.for(`immer-draftable`),EA=Symbol.for(`immer-state`);function DA(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var OA=Object.getPrototypeOf;function kA(e){return!!e&&!!e[EA]}function AA(e){return e?MA(e)||Array.isArray(e)||!!e[TA]||!!e.constructor?.[TA]||LA(e)||RA(e):!1}var lpe=Object.prototype.constructor.toString(),jA=new WeakMap;function MA(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;if(n===Object)return!0;if(typeof n!=`function`)return!1;let r=jA.get(n);return r===void 0&&(r=Function.toString.call(n),jA.set(n,r)),r===lpe}function NA(e,t,n=!0){PA(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function PA(e){let t=e[EA];return t?t.type_:Array.isArray(e)?1:LA(e)?2:RA(e)?3:0}function FA(e,t){return PA(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function IA(e,t,n){let r=PA(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function upe(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function LA(e){return e instanceof Map}function RA(e){return e instanceof Set}function zA(e){return e.copy_||e.base_}function BA(e,t){if(LA(e))return new Map(e);if(RA(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=MA(e);if(t===!0||t===`class_only`&&!n){let t=Object.getOwnPropertyDescriptors(e);delete t[EA];let n=Reflect.ownKeys(t);for(let r=0;r1&&Object.defineProperties(e,{set:HA,add:HA,clear:HA,delete:HA}),Object.freeze(e),t&&Object.values(e).forEach(e=>VA(e,!0)),e)}function dpe(){DA(2)}var HA={value:dpe};function UA(e){return typeof e!=`object`||!e?!0:Object.isFrozen(e)}var fpe={};function WA(e){let t=fpe[e];return t||DA(0,e),t}var GA;function KA(){return GA}function ppe(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function qA(e,t){t&&(WA(`Patches`),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function JA(e){YA(e),e.drafts_.forEach(mpe),e.drafts_=null}function YA(e){e===GA&&(GA=e.parent_)}function XA(e){return GA=ppe(GA,e)}function mpe(e){let t=e[EA];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function ZA(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[EA].modified_&&(JA(t),DA(4)),AA(e)&&(e=QA(t,e),t.parent_||ej(t,e)),t.patches_&&WA(`Patches`).generateReplacementPatches_(n[EA].base_,e,t.patches_,t.inversePatches_)):e=QA(t,n,[]),JA(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===wA?void 0:e}function QA(e,t,n){if(UA(t))return t;let r=e.immer_.shouldUseStrictIteration(),i=t[EA];if(!i)return NA(t,(r,a)=>$A(e,i,t,r,a,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return ej(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let t=i.copy_,a=t,o=!1;i.type_===3&&(a=new Set(t),t.clear(),o=!0),NA(a,(r,a)=>$A(e,i,t,r,a,n,o),r),ej(e,t,!1),n&&e.patches_&&WA(`Patches`).generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function $A(e,t,n,r,i,a,o){if(i==null||typeof i!=`object`&&!o)return;let s=UA(i);if(!(s&&!o)){if(kA(i)){let o=QA(e,i,a&&t&&t.type_!==3&&!FA(t.assigned_,r)?a.concat(r):void 0);if(IA(n,r,o),kA(o))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(AA(i)&&!s){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&s)return;QA(e,i),(!t||!t.scope_.parent_)&&typeof r!=`symbol`&&(LA(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&ej(e,i)}}}function ej(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&VA(t,n)}function hpe(e,t){let n=Array.isArray(e),r={type_:+!!n,scope_:t?t.scope_:KA(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=r,a=tj;n&&(i=[r],a=nj);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,s}var tj={get(e,t){if(t===EA)return e;let n=zA(e);if(!FA(n,t))return gpe(e,n,t);let r=n[t];return e.finalized_||!AA(r)?r:r===rj(e.base_,t)?(aj(e),e.copy_[t]=oj(r,e)):r},has(e,t){return t in zA(e)},ownKeys(e){return Reflect.ownKeys(zA(e))},set(e,t,n){let r=_pe(zA(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=rj(zA(e),t),i=r?.[EA];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(upe(n,r)&&(n!==void 0||FA(e.base_,t)))return!0;aj(e),ij(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_[t]=!0,!0)},deleteProperty(e,t){return rj(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,aj(e),ij(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=zA(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!==`length`,enumerable:r.enumerable,value:n[t]}},defineProperty(){DA(11)},getPrototypeOf(e){return OA(e.base_)},setPrototypeOf(){DA(12)}},nj={};NA(tj,(e,t)=>{nj[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),nj.deleteProperty=function(e,t){return nj.set.call(this,e,t,void 0)},nj.set=function(e,t,n){return tj.set.call(this,e[0],t,n,e[0])};function rj(e,t){let n=e[EA];return(n?zA(n):e)[t]}function gpe(e,t,n){let r=_pe(t,n);return r?`value`in r?r.value:r.get?.call(e.draft_):void 0}function _pe(e,t){if(!(t in e))return;let n=OA(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=OA(n)}}function ij(e){e.modified_||(e.modified_=!0,e.parent_&&ij(e.parent_))}function aj(e){e.copy_||=BA(e.base_,e.scope_.immer_.useStrictShallowCopy_)}var vpe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,t,n)=>{if(typeof e==`function`&&typeof t!=`function`){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}typeof t!=`function`&&DA(6),n!==void 0&&typeof n!=`function`&&DA(7);let r;if(AA(e)){let i=XA(this),a=oj(e,void 0),o=!0;try{r=t(a),o=!1}finally{o?JA(i):YA(i)}return qA(i,n),ZA(r,i)}else if(!e||typeof e!=`object`){if(r=t(e),r===void 0&&(r=e),r===wA&&(r=void 0),this.autoFreeze_&&VA(r,!0),n){let t=[],i=[];WA(`Patches`).generateReplacementPatches_(e,r,t,i),n(t,i)}return r}else DA(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e==`function`)return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},typeof e?.autoFreeze==`boolean`&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy==`boolean`&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration==`boolean`&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){AA(e)||DA(8),kA(e)&&(e=ype(e));let t=XA(this),n=oj(e,void 0);return n[EA].isManual_=!0,YA(t),n}finishDraft(e,t){let n=e&&e[EA];(!n||!n.isManual_)&&DA(9);let{scope_:r}=n;return qA(r,t),ZA(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=WA(`Patches`).applyPatches_;return kA(e)?r(e,t):this.produce(e,e=>r(e,t))}};function oj(e,t){let n=LA(e)?WA(`MapSet`).proxyMap_(e,t):RA(e)?WA(`MapSet`).proxySet_(e,t):hpe(e,t);return(t?t.scope_:KA()).drafts_.push(n),n}function ype(e){return kA(e)||DA(10,e),bpe(e)}function bpe(e){if(!AA(e)||UA(e))return e;let t=e[EA],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=BA(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=BA(e,!0);return NA(n,(e,t)=>{IA(n,e,bpe(t))},r),t&&(t.finalized_=!1),n}new vpe().produce;function sj(e){return e}var xpe=ek({name:`legend`,initialState:{settings:{layout:`horizontal`,align:`center`,verticalAlign:`middle`,itemSorter:`value`},size:{width:0,height:0},payload:[]},reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(sj(t.payload))},prepare:XO()},replaceLegendPayload:{reducer(e,t){var{prev:n,next:r}=t.payload,i=VO(e).payload.indexOf(sj(n));i>-1&&(e.payload[i]=sj(r))},prepare:XO()},removeLegendPayload:{reducer(e,t){var n=VO(e).payload.indexOf(sj(t.payload));n>-1&&e.payload.splice(n,1)},prepare:XO()}}}),{setLegendSize:Spe,setLegendSettings:Cpe,addLegendPayload:wpe,replaceLegendPayload:Tpe,removeLegendPayload:Epe}=xpe.actions,Dpe=xpe.reducer,Ope=[`contextPayload`];function cj(){return cj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(Cpe(e))},[t,e]),null}function Rpe(e){var t=pD();return(0,y.useEffect)(()=>(t(Spe(e)),()=>{t(Spe({width:0,height:0}))}),[t,e]),null}function zpe(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var Bpe={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function dj(e){var t=YE(e,Bpe),n=xde(),r=Dle(),i=spe(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,u]=ED([n]),d=_A(),f=vA();if(d==null||f==null)return null;var p=d-(i?.left||0)-(i?.right||0),m=zpe(t.layout,o,a,p),h=c?s:uj(uj({position:`absolute`,width:m?.width||a||`auto`,height:m?.height||o||`auto`},Ipe(s,t,i,d,f,l)),s),g=c??r;return g==null||n==null?null:(0,Op.createPortal)(y.createElement(`div`,{className:`recharts-legend-wrapper`,style:h,ref:u},y.createElement(Lpe,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&y.createElement(Rpe,{width:l.width,height:l.height}),y.createElement(Fpe,cj({},t,m,{margin:i,chartWidth:d,chartHeight:f,contextPayload:n}))),g)}dj.displayName=`Legend`;function fj(){return fj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=hj.separator,contentStyle:n,itemStyle:r,labelStyle:i=hj.labelStyle,payload:a,formatter:o,itemSorter:s,wrapperClassName:c,labelClassName:l,label:u,labelFormatter:d,accessibilityLayer:f=hj.accessibilityLayer}=e,p=()=>{if(a&&a.length){var e={padding:0,margin:0},n=(s?(0,CD.default)(a,s):a).map((e,n)=>{if(e.type===`none`)return null;var i=e.formatter||o||Wpe,{value:s,name:c}=e,l=s,u=c;if(i){var d=i(s,c,e,n,a);if(Array.isArray(d))[l,u]=d;else if(d!=null)l=d;else return null}var f=mj(mj({},hj.itemStyle),{},{color:e.color||hj.itemStyle.color},r);return y.createElement(`li`,{className:`recharts-tooltip-item`,key:`tooltip-item-${n}`,style:f},AE(u)?y.createElement(`span`,{className:`recharts-tooltip-item-name`},u):null,AE(u)?y.createElement(`span`,{className:`recharts-tooltip-item-separator`},t):null,y.createElement(`span`,{className:`recharts-tooltip-item-value`},l),y.createElement(`span`,{className:`recharts-tooltip-item-unit`},e.unit||``))});return y.createElement(`ul`,{className:`recharts-tooltip-item-list`,style:e},n)}return null},m=mj(mj({},hj.contentStyle),n),h=mj({margin:0},i),g=!IE(u),_=g?u:``,v=gT(`recharts-default-tooltip`,c),b=gT(`recharts-tooltip-label`,l);g&&d&&a!=null&&(_=d(u,a));var x=f?{role:`status`,"aria-live":`assertive`}:{};return y.createElement(`div`,fj({className:v,style:m},x),y.createElement(`p`,{className:b,style:h},y.isValidElement(_)?_:`${_}`),p())},gj=`recharts-tooltip-wrapper`,Kpe={visibility:`hidden`};function qpe(e){var{coordinate:t,translateX:n,translateY:r}=e;return gT(gj,{[`${gj}-right`]:kE(n)&&t&&kE(t.x)&&n>=t.x,[`${gj}-left`]:kE(n)&&t&&kE(t.x)&&n=t.y,[`${gj}-top`]:kE(r)&&t&&kE(t.y)&&r0?i:0),d=n[r]+i;if(t[r])return o[r]?u:d;var f=c[r];return f==null?0:o[r]?Math.max(uf+l?Math.max(u,f):Math.max(d,f)}function Jpe(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`}}function Ype(e){var{allowEscapeViewBox:t,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:s,useTranslate3d:c,viewBox:l}=e,u,d,f;return s.height>0&&s.width>0&&n?(d=_j({allowEscapeViewBox:t,coordinate:n,key:`x`,offset:i,position:a,reverseDirection:o,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=_j({allowEscapeViewBox:t,coordinate:n,key:`y`,offset:r,position:a,reverseDirection:o,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),u=Jpe({translateX:d,translateY:f,useTranslate3d:c})):u=Kpe,{cssProperties:u,cssClasses:qpe({translateX:d,translateY:f,coordinate:n})}}function vj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function yj(e){for(var t=1;t{e.key===`Escape`&&this.setState({dismissed:!0,dismissedAtCoordinate:{x:this.props.coordinate?.x??0,y:this.props.coordinate?.y??0}})})}componentDidMount(){document.addEventListener(`keydown`,this.handleKeyDown)}componentWillUnmount(){document.removeEventListener(`keydown`,this.handleKeyDown)}componentDidUpdate(){this.state.dismissed&&(this.props.coordinate?.x!==this.state.dismissedAtCoordinate.x||this.props.coordinate?.y!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:t,animationDuration:n,animationEasing:r,children:i,coordinate:a,hasPayload:o,isAnimationActive:s,offset:c,position:l,reverseDirection:u,useTranslate3d:d,viewBox:f,wrapperStyle:p,lastBoundingBox:m,innerRef:h,hasPortalFromProps:g}=this.props,{cssClasses:_,cssProperties:v}=Ype({allowEscapeViewBox:t,coordinate:a,offsetLeft:typeof c==`number`?c:c.x,offsetTop:typeof c==`number`?c:c.y,position:l,reverseDirection:u,tooltipBox:{height:m.height,width:m.width},useTranslate3d:d,viewBox:f}),b=yj(yj({},g?{}:yj(yj({transition:s&&e?`transform ${n}ms ${r}`:void 0},v),{},{pointerEvents:`none`,visibility:!this.state.dismissed&&e&&o?`visible`:`hidden`,position:`absolute`,top:0,left:0})),{},{visibility:!this.state.dismissed&&e&&o?`visible`:`hidden`},p);return y.createElement(`div`,{xmlns:`http://www.w3.org/1999/xhtml`,tabIndex:-1,className:_,style:b,ref:h},i)}},xj=()=>hD(e=>e.rootProps.accessibilityLayer)??!0;function Sj(){return Sj=Object.assign?Object.assign.bind():function(e){for(var t=1;tkk(e.x)&&kk(e.y),Dj=e=>e.base!=null&&Ej(e.base)&&Ej(e),Oj=e=>e.x,kj=e=>e.y,nme=(e,t)=>{if(typeof e==`function`)return e;var n=`curve${LE(e)}`;if((n===`curveMonotone`||n===`curveBump`)&&t){var r=Tj[`${n}${t===`vertical`?`Y`:`X`}`];if(r)return r}return Tj[n]||HT},Aj={connectNulls:!1,type:`linear`},rme=e=>{var{type:t=Aj.type,points:n=[],baseLine:r,layout:i,connectNulls:a=Aj.connectNulls}=e,o=nme(t,i),s=a?n.filter(Ej):n;if(Array.isArray(r)){var c,l=n.map((e,t)=>wj(wj({},e),{},{base:r[t]}));return c=i===`vertical`?KT().y(kj).x1(Oj).x0(e=>e.base.x):KT().x(Oj).y1(kj).y0(e=>e.base.y),c.defined(Dj).curve(o)(a?l.filter(Dj):l)}return(i===`vertical`&&kE(r)?KT().y(kj).x1(Oj).x0(r):kE(r)?KT().x(Oj).y1(kj).y0(r):GT().x(Oj).y(kj)).defined(Ej).curve(o)(s)},jj=e=>{var{className:t,points:n,path:r,pathRef:i}=e,a=bA();if((!n||!n.length)&&!r)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||a,connectNulls:e.connectNulls},s=n&&n.length?rme(o):r;return y.createElement(`path`,Sj({},bT(e),KE(e),{className:gT(`recharts-curve`,t),d:s===null?void 0:s,ref:i}))},ime=[`x`,`y`,`top`,`left`,`width`,`height`,`className`];function Mj(){return Mj=Object.assign?Object.assign.bind():function(e){for(var t=1;t`M${e},${i}v${r}M${a},${t}h${n}`,fme=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:s}=e,c=lme(e,ime),l=ame({x:t,y:n,top:r,left:i,width:a,height:o},c);return!kE(t)||!kE(n)||!kE(a)||!kE(o)||!kE(r)||!kE(i)?null:y.createElement(`path`,Mj({},ST(l),{className:gT(`recharts-cross`,s),d:dme(t,n,a,o,r,i)}))};function pme(e,t,n,r){var i=r/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?t.x-i:n.left+.5,y:e===`horizontal`?n.top+.5:t.y-i,width:e===`horizontal`?r:n.width-1,height:e===`horizontal`?n.height-1:r}}function Pj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fj(e){for(var t=1;te.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`),Ij=(e,t,n)=>e.map(e=>`${_me(e)} ${t}ms ${n}`).join(`,`),vme=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((e,t)=>e.filter(e=>t.includes(e))),Lj=(e,t)=>Object.keys(t).reduce((n,r)=>Fj(Fj({},n),{},{[r]:e(r,t[r])}),{});function Rj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zj(e){for(var t=1;te+(t-e)*n,Vj=e=>{var{from:t,to:n}=e;return t!==n},Hj=(e,t,n)=>{var r=Lj((t,n)=>{if(Vj(n)){var[r,i]=e(n.from,n.to,n.velocity);return zj(zj({},n),{},{from:r,velocity:i})}return n},t);return n<1?Lj((e,t)=>Vj(t)&&r[e]!=null?zj(zj({},t),{},{velocity:Bj(t.velocity,r[e].velocity,n),from:Bj(t.from,r[e].from,n)}):t,t):Hj(e,r,n-1)};function Sme(e,t,n,r,i,a){var o,s=r.reduce((n,r)=>zj(zj({},n),{},{[r]:{from:e[r],velocity:0,to:t[r]}}),{}),c=()=>Lj((e,t)=>t.from,s),l=()=>!Object.values(s).filter(Vj).length,u=null,d=r=>{o||=r;var f=(r-o)/n.dt;s=Hj(n,s,f),i(zj(zj(zj({},e),t),c())),o=r,l()||(u=a.setTimeout(d))};return()=>(u=a.setTimeout(d),()=>{var e;(e=u)==null||e()})}function Cme(e,t,n,r,i,a,o){var s=null,c=i.reduce((n,r)=>{var i=e[r],a=t[r];return i==null||a==null?n:zj(zj({},n),{},{[r]:[i,a]})},{}),l,u=i=>{l||=i;var d=(i-l)/r,f=Lj((e,t)=>Bj(...t,n(d)),c);if(a(zj(zj(zj({},e),t),f)),d<1)s=o.setTimeout(u);else{var p=Lj((e,t)=>Bj(...t,n(1)),c);a(zj(zj(zj({},e),t),p))}};return()=>(s=o.setTimeout(u),()=>{var e;(e=s)==null||e()})}var wme=(e,t,n,r,i,a)=>{var o=vme(e,t);return n==null?()=>(i(zj(zj({},e),t)),()=>{}):n.isStepper===!0?Sme(e,t,n,o,i,a):Cme(e,t,n,r,o,i,a)},Uj=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],Tme=(e,t)=>e.map((e,n)=>e*t**n).reduce((e,t)=>e+t),Wj=(e,t)=>n=>Tme(Uj(e,t),n),Eme=(e,t)=>n=>Tme([...Uj(e,t).map((e,t)=>e*t).slice(1),0],n),Dme=e=>{var t,n=e.split(`(`);if(n.length!==2||n[0]!==`cubic-bezier`)return null;var r=(t=n[1])==null||(t=t.split(`)`)[0])==null?void 0:t.split(`,`);if(r==null||r.length!==4)return null;var i=r.map(e=>parseFloat(e));return[i[0],i[1],i[2],i[3]]},Ome=function(){var e=[...arguments];if(e.length===1)switch(e[0]){case`linear`:return[0,0,1,1];case`ease`:return[.25,.1,.25,1];case`ease-in`:return[.42,0,1,1];case`ease-out`:return[.42,0,.58,1];case`ease-in-out`:return[0,0,.58,1];default:var t=Dme(e[0]);if(t)return t}return e.length===4?e:[0,0,1,1]},kme=(e,t,n,r)=>{var i=Wj(e,n),a=Wj(t,r),o=Eme(e,n),s=e=>e>1?1:e<0?0:e,c=e=>{for(var t=e>1?1:e,n=t,r=0;r<8;++r){var c=i(n)-t,l=o(n);if(Math.abs(c-t)<1e-4||l<1e-4)return a(n);n=s(n-c/l)}return a(n)};return c.isStepper=!1,c},Gj=function(){return kme(...Ome(...arguments))},Ame=function(){var{stiff:e=100,damping:t=8,dt:n=17}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=(r,i,a)=>{var o=a+(-(r-i)*e-a*t)*n/1e3,s=a*n/1e3+r;return Math.abs(s-i)<1e-4&&Math.abs(o)<1e-4?[i,0]:[s,o]};return r.isStepper=!0,r.dt=n,r},jme=e=>{if(typeof e==`string`)switch(e){case`ease`:case`ease-in-out`:case`ease-out`:case`ease-in`:case`linear`:return Gj(e);case`spring`:return Ame();default:if(e.split(`(`)[0]===`cubic-bezier`)return Gj(e)}return typeof e==`function`?e:null};function Mme(e){var t,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var[s,...c]=o;if(typeof s==`number`){i=e.setTimeout(a.bind(null,c),s);return}a(s),i=e.setTimeout(a.bind(null,c));return}typeof o==`string`&&(t=o,n(t)),typeof o==`object`&&(t=o,n(t)),typeof o==`function`&&o()}};return{stop:()=>{r=!0},start:e=>{r=!1,i&&=(i(),null),a(e)},subscribe:e=>(n=e,()=>{n=()=>null}),getTimeoutController:()=>e}}var Nme=class{setTimeout(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=performance.now(),r=null,i=a=>{a-n>=t?e(a):typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(i))};return r=requestAnimationFrame(i),()=>{r!=null&&cancelAnimationFrame(r)}}};function Pme(){return Mme(new Nme)}var Fme=(0,y.createContext)(Pme);function Ime(e,t){var n=(0,y.useContext)(Fme);return(0,y.useMemo)(()=>t??n(e),[e,t,n])}var Kj={devToolsEnabled:!0,isSsr:!(typeof window<`u`&&window.document&&window.document.createElement&&window.setTimeout)},Lme={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},qj={t:0},Jj={t:1};function Yj(e){var t=YE(e,Lme),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:s,onAnimationStart:c,children:l}=t,u=n===`auto`?!Kj.isSsr:n,d=Ime(t.animationId,t.animationManager),[f,p]=(0,y.useState)(u?qj:Jj),m=(0,y.useRef)(null);return(0,y.useEffect)(()=>{u||p(Jj)},[u]),(0,y.useEffect)(()=>{if(!u||!r)return zE;var e=wme(qj,Jj,jme(a),i,p,d.getTimeoutController());return d.start([c,o,()=>{m.current=e()},i,s]),()=>{d.stop(),m.current&&m.current(),s()}},[u,r,i,a,o,c,s,d]),l(f.t)}function Xj(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`animation-`,n=(0,y.useRef)(jE(t)),r=(0,y.useRef)(e);return r.current!==e&&(n.current=jE(t),r.current=e),n.current}var Rme=[`radius`],zme=[`radius`],Bme,Vme,Hme,Ume,Wme,Gme,Kme,qme,Jme,Yme;function Zj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qj(e){for(var t=1;t{var a=CE(n),o=CE(r),s=Math.min(Math.abs(a)/2,Math.abs(o)/2),c=o>=0?1:-1,l=a>=0?1:-1,u=+(o>=0&&a>=0||o<0&&a<0),d;if(s>0&&Array.isArray(i)){for(var f=[0,0,0,0],p=0,m=4;ps?s:h}d=wE(Bme||=tM([`M`,`,`,``]),e,t+c*f[0]),f[0]>0&&(d+=wE(Vme||=tM([`A `,`,`,`,0,0,`,`,`,`,`,``]),f[0],f[0],u,e+l*f[0],t)),d+=wE(Hme||=tM([`L `,`,`,``]),e+n-l*f[1],t),f[1]>0&&(d+=wE(Ume||=tM([`A `,`,`,`,0,0,`,`, - `,`,`,``]),f[1],f[1],u,e+n,t+c*f[1])),d+=wE(Wme||=tM([`L `,`,`,``]),e+n,t+r-c*f[2]),f[2]>0&&(d+=wE(Gme||=tM([`A `,`,`,`,0,0,`,`, - `,`,`,``]),f[2],f[2],u,e+n-l*f[2],t+r)),d+=wE(Kme||=tM([`L `,`,`,``]),e+l*f[3],t+r),f[3]>0&&(d+=wE(qme||=tM([`A `,`,`,`,0,0,`,`, - `,`,`,``]),f[3],f[3],u,e,t+r-c*f[3])),d+=`Z`}else if(s>0&&i===+i&&i>0){var g=Math.min(s,i);d=wE(Jme||=tM(`M .,. + height and width.`,C,w,i,a,o,s,n),y.createElement(`div`,{id:d?`${d}`:void 0,className:_T(`recharts-responsive-container`,f),style:uA(uA({},m),{},{width:i,height:a,minWidth:o,minHeight:s,maxHeight:c}),ref:h},y.createElement(`div`,{style:Zfe({width:i,height:a})},y.createElement(fA,{width:C,height:w},l)))}),mA=(0,y.forwardRef)((e,t)=>{var n=pA();if(jk(n.width)&&jk(n.height))return e.children;var{width:r,height:i}=Qfe({width:e.width,height:e.height,aspect:e.aspect}),{calculatedWidth:a,calculatedHeight:o}=sA(void 0,void 0,{width:r,height:i,aspect:e.aspect,maxHeight:e.maxHeight});return AE(a)&&AE(o)?y.createElement(fA,{width:a,height:o},e.children):y.createElement(ipe,cA({},e,{width:r,height:i,ref:t}))});function hA(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}var gA=()=>{var e=nA(),t=gD(Bfe),n=gD(iA),r=gD(rA)?.padding;return!e||!n||!r?t:{width:n.width-r.left-r.right,height:n.height-r.top-r.bottom,x:r.left,y:r.top}},ape={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},_A=()=>gD(eA)??ape,vA=()=>gD(Kk),yA=()=>gD(qk),ope=()=>gD(e=>e.layout.margin),bA=e=>e.layout.layoutType,xA=()=>gD(bA),SA=()=>{var e=xA();if(e===`horizontal`||e===`vertical`)return e},CA=e=>{var t=e.layout.layoutType;if(t===`centric`||t===`radial`)return t},spe=()=>xA()!==void 0,wA=e=>{var t=mD(),n=nA(),{width:r,height:i}=e,a=pA(),o=r,s=i;return a&&(o=a.width>0?a.width:r,s=a.height>0?a.height:i),(0,y.useEffect)(()=>{!n&&jk(o)&&jk(s)&&t(mfe({width:o,height:s}))},[t,n,o,s]),null},TA=Symbol.for(`immer-nothing`),EA=Symbol.for(`immer-draftable`),DA=Symbol.for(`immer-state`);function OA(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var kA=Object.getPrototypeOf;function AA(e){return!!e&&!!e[DA]}function jA(e){return e?NA(e)||Array.isArray(e)||!!e[EA]||!!e.constructor?.[EA]||RA(e)||zA(e):!1}var cpe=Object.prototype.constructor.toString(),MA=new WeakMap;function NA(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);if(t===null||t===Object.prototype)return!0;let n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;if(n===Object)return!0;if(typeof n!=`function`)return!1;let r=MA.get(n);return r===void 0&&(r=Function.toString.call(n),MA.set(n,r)),r===cpe}function PA(e,t,n=!0){FA(e)===0?(n?Reflect.ownKeys(e):Object.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function FA(e){let t=e[DA];return t?t.type_:Array.isArray(e)?1:RA(e)?2:zA(e)?3:0}function IA(e,t){return FA(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function LA(e,t,n){let r=FA(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function lpe(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}function RA(e){return e instanceof Map}function zA(e){return e instanceof Set}function BA(e){return e.copy_||e.base_}function VA(e,t){if(RA(e))return new Map(e);if(zA(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=NA(e);if(t===!0||t===`class_only`&&!n){let t=Object.getOwnPropertyDescriptors(e);delete t[DA];let n=Reflect.ownKeys(t);for(let r=0;r1&&Object.defineProperties(e,{set:UA,add:UA,clear:UA,delete:UA}),Object.freeze(e),t&&Object.values(e).forEach(e=>HA(e,!0)),e)}function upe(){OA(2)}var UA={value:upe};function WA(e){return typeof e!=`object`||!e?!0:Object.isFrozen(e)}var dpe={};function GA(e){let t=dpe[e];return t||OA(0,e),t}var KA;function qA(){return KA}function fpe(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function JA(e,t){t&&(GA(`Patches`),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function YA(e){XA(e),e.drafts_.forEach(ppe),e.drafts_=null}function XA(e){e===KA&&(KA=e.parent_)}function ZA(e){return KA=fpe(KA,e)}function ppe(e){let t=e[DA];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function QA(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[DA].modified_&&(YA(t),OA(4)),jA(e)&&(e=$A(t,e),t.parent_||tj(t,e)),t.patches_&&GA(`Patches`).generateReplacementPatches_(n[DA].base_,e,t.patches_,t.inversePatches_)):e=$A(t,n,[]),YA(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===TA?void 0:e}function $A(e,t,n){if(WA(t))return t;let r=e.immer_.shouldUseStrictIteration(),i=t[DA];if(!i)return PA(t,(r,a)=>ej(e,i,t,r,a,n),r),t;if(i.scope_!==e)return t;if(!i.modified_)return tj(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let t=i.copy_,a=t,o=!1;i.type_===3&&(a=new Set(t),t.clear(),o=!0),PA(a,(r,a)=>ej(e,i,t,r,a,n,o),r),tj(e,t,!1),n&&e.patches_&&GA(`Patches`).generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function ej(e,t,n,r,i,a,o){if(i==null||typeof i!=`object`&&!o)return;let s=WA(i);if(!(s&&!o)){if(AA(i)){let o=$A(e,i,a&&t&&t.type_!==3&&!IA(t.assigned_,r)?a.concat(r):void 0);if(LA(n,r,o),AA(o))e.canAutoFreeze_=!1;else return}else o&&n.add(i);if(jA(i)&&!s){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1||t&&t.base_&&t.base_[r]===i&&s)return;$A(e,i),(!t||!t.scope_.parent_)&&typeof r!=`symbol`&&(RA(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&tj(e,i)}}}function tj(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&HA(t,n)}function mpe(e,t){let n=Array.isArray(e),r={type_:+!!n,scope_:t?t.scope_:qA(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=r,a=nj;n&&(i=[r],a=rj);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,s}var nj={get(e,t){if(t===DA)return e;let n=BA(e);if(!IA(n,t))return hpe(e,n,t);let r=n[t];return e.finalized_||!jA(r)?r:r===ij(e.base_,t)?(oj(e),e.copy_[t]=sj(r,e)):r},has(e,t){return t in BA(e)},ownKeys(e){return Reflect.ownKeys(BA(e))},set(e,t,n){let r=gpe(BA(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=ij(BA(e),t),i=r?.[DA];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(lpe(n,r)&&(n!==void 0||IA(e.base_,t)))return!0;oj(e),aj(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_[t]=!0,!0)},deleteProperty(e,t){return ij(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,oj(e),aj(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=BA(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!==`length`,enumerable:r.enumerable,value:n[t]}},defineProperty(){OA(11)},getPrototypeOf(e){return kA(e.base_)},setPrototypeOf(){OA(12)}},rj={};PA(nj,(e,t)=>{rj[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),rj.deleteProperty=function(e,t){return rj.set.call(this,e,t,void 0)},rj.set=function(e,t,n){return nj.set.call(this,e[0],t,n,e[0])};function ij(e,t){let n=e[DA];return(n?BA(n):e)[t]}function hpe(e,t,n){let r=gpe(t,n);return r?`value`in r?r.value:r.get?.call(e.draft_):void 0}function gpe(e,t){if(!(t in e))return;let n=kA(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=kA(n)}}function aj(e){e.modified_||(e.modified_=!0,e.parent_&&aj(e.parent_))}function oj(e){e.copy_||=VA(e.base_,e.scope_.immer_.useStrictShallowCopy_)}var _pe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,t,n)=>{if(typeof e==`function`&&typeof t!=`function`){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}typeof t!=`function`&&OA(6),n!==void 0&&typeof n!=`function`&&OA(7);let r;if(jA(e)){let i=ZA(this),a=sj(e,void 0),o=!0;try{r=t(a),o=!1}finally{o?YA(i):XA(i)}return JA(i,n),QA(r,i)}else if(!e||typeof e!=`object`){if(r=t(e),r===void 0&&(r=e),r===TA&&(r=void 0),this.autoFreeze_&&HA(r,!0),n){let t=[],i=[];GA(`Patches`).generateReplacementPatches_(e,r,t,i),n(t,i)}return r}else OA(1,e)},this.produceWithPatches=(e,t)=>{if(typeof e==`function`)return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},typeof e?.autoFreeze==`boolean`&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy==`boolean`&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),typeof e?.useStrictIteration==`boolean`&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){jA(e)||OA(8),AA(e)&&(e=vpe(e));let t=ZA(this),n=sj(e,void 0);return n[DA].isManual_=!0,XA(t),n}finishDraft(e,t){let n=e&&e[DA];(!n||!n.isManual_)&&OA(9);let{scope_:r}=n;return JA(r,t),QA(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=GA(`Patches`).applyPatches_;return AA(e)?r(e,t):this.produce(e,e=>r(e,t))}};function sj(e,t){let n=RA(e)?GA(`MapSet`).proxyMap_(e,t):zA(e)?GA(`MapSet`).proxySet_(e,t):mpe(e,t);return(t?t.scope_:qA()).drafts_.push(n),n}function vpe(e){return AA(e)||OA(10,e),ype(e)}function ype(e){if(!jA(e)||WA(e))return e;let t=e[DA],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=VA(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=VA(e,!0);return PA(n,(e,t)=>{LA(n,e,ype(t))},r),t&&(t.finalized_=!1),n}new _pe().produce;function cj(e){return e}var bpe=tk({name:`legend`,initialState:{settings:{layout:`horizontal`,align:`center`,verticalAlign:`middle`,itemSorter:`value`},size:{width:0,height:0},payload:[]},reducers:{setLegendSize(e,t){e.size.width=t.payload.width,e.size.height=t.payload.height},setLegendSettings(e,t){e.settings.align=t.payload.align,e.settings.layout=t.payload.layout,e.settings.verticalAlign=t.payload.verticalAlign,e.settings.itemSorter=t.payload.itemSorter},addLegendPayload:{reducer(e,t){e.payload.push(cj(t.payload))},prepare:ZO()},replaceLegendPayload:{reducer(e,t){var{prev:n,next:r}=t.payload,i=HO(e).payload.indexOf(cj(n));i>-1&&(e.payload[i]=cj(r))},prepare:ZO()},removeLegendPayload:{reducer(e,t){var n=HO(e).payload.indexOf(cj(t.payload));n>-1&&e.payload.splice(n,1)},prepare:ZO()}}}),{setLegendSize:xpe,setLegendSettings:Spe,addLegendPayload:Cpe,replaceLegendPayload:wpe,removeLegendPayload:Tpe}=bpe.actions,Epe=bpe.reducer,Dpe=[`contextPayload`];function lj(){return lj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{t(Spe(e))},[t,e]),null}function Lpe(e){var t=mD();return(0,y.useEffect)(()=>(t(xpe(e)),()=>{t(xpe({width:0,height:0}))}),[t,e]),null}function Rpe(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var zpe={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function fj(e){var t=XE(e,zpe),n=bde(),r=Ele(),i=ope(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,u]=DD([n]),d=vA(),f=yA();if(d==null||f==null)return null;var p=d-(i?.left||0)-(i?.right||0),m=Rpe(t.layout,o,a,p),h=c?s:dj(dj({position:`absolute`,width:m?.width||a||`auto`,height:m?.height||o||`auto`},Fpe(s,t,i,d,f,l)),s),g=c??r;return g==null||n==null?null:(0,Op.createPortal)(y.createElement(`div`,{className:`recharts-legend-wrapper`,style:h,ref:u},y.createElement(Ipe,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&y.createElement(Lpe,{width:l.width,height:l.height}),y.createElement(Ppe,lj({},t,m,{margin:i,chartWidth:d,chartHeight:f,contextPayload:n}))),g)}fj.displayName=`Legend`;function pj(){return pj=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{separator:t=gj.separator,contentStyle:n,itemStyle:r,labelStyle:i=gj.labelStyle,payload:a,formatter:o,itemSorter:s,wrapperClassName:c,labelClassName:l,label:u,labelFormatter:d,accessibilityLayer:f=gj.accessibilityLayer}=e,p=()=>{if(a&&a.length){var e={padding:0,margin:0},n=(s?(0,wD.default)(a,s):a).map((e,n)=>{if(e.type===`none`)return null;var i=e.formatter||o||Upe,{value:s,name:c}=e,l=s,u=c;if(i){var d=i(s,c,e,n,a);if(Array.isArray(d))[l,u]=d;else if(d!=null)l=d;else return null}var f=hj(hj({},gj.itemStyle),{},{color:e.color||gj.itemStyle.color},r);return y.createElement(`li`,{className:`recharts-tooltip-item`,key:`tooltip-item-${n}`,style:f},jE(u)?y.createElement(`span`,{className:`recharts-tooltip-item-name`},u):null,jE(u)?y.createElement(`span`,{className:`recharts-tooltip-item-separator`},t):null,y.createElement(`span`,{className:`recharts-tooltip-item-value`},l),y.createElement(`span`,{className:`recharts-tooltip-item-unit`},e.unit||``))});return y.createElement(`ul`,{className:`recharts-tooltip-item-list`,style:e},n)}return null},m=hj(hj({},gj.contentStyle),n),h=hj({margin:0},i),g=!LE(u),_=g?u:``,v=_T(`recharts-default-tooltip`,c),b=_T(`recharts-tooltip-label`,l);g&&d&&a!=null&&(_=d(u,a));var x=f?{role:`status`,"aria-live":`assertive`}:{};return y.createElement(`div`,pj({className:v,style:m},x),y.createElement(`p`,{className:b,style:h},y.isValidElement(_)?_:`${_}`),p())},_j=`recharts-tooltip-wrapper`,Gpe={visibility:`hidden`};function Kpe(e){var{coordinate:t,translateX:n,translateY:r}=e;return _T(_j,{[`${_j}-right`]:AE(n)&&t&&AE(t.x)&&n>=t.x,[`${_j}-left`]:AE(n)&&t&&AE(t.x)&&n=t.y,[`${_j}-top`]:AE(r)&&t&&AE(t.y)&&r0?i:0),d=n[r]+i;if(t[r])return o[r]?u:d;var f=c[r];return f==null?0:o[r]?Math.max(uf+l?Math.max(u,f):Math.max(d,f)}function qpe(e){var{translateX:t,translateY:n,useTranslate3d:r}=e;return{transform:r?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`}}function Jpe(e){var{allowEscapeViewBox:t,coordinate:n,offsetTop:r,offsetLeft:i,position:a,reverseDirection:o,tooltipBox:s,useTranslate3d:c,viewBox:l}=e,u,d,f;return s.height>0&&s.width>0&&n?(d=vj({allowEscapeViewBox:t,coordinate:n,key:`x`,offset:i,position:a,reverseDirection:o,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=vj({allowEscapeViewBox:t,coordinate:n,key:`y`,offset:r,position:a,reverseDirection:o,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),u=qpe({translateX:d,translateY:f,useTranslate3d:c})):u=Gpe,{cssProperties:u,cssClasses:Kpe({translateX:d,translateY:f,coordinate:n})}}function yj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function bj(e){for(var t=1;t{e.key===`Escape`&&this.setState({dismissed:!0,dismissedAtCoordinate:{x:this.props.coordinate?.x??0,y:this.props.coordinate?.y??0}})})}componentDidMount(){document.addEventListener(`keydown`,this.handleKeyDown)}componentWillUnmount(){document.removeEventListener(`keydown`,this.handleKeyDown)}componentDidUpdate(){this.state.dismissed&&(this.props.coordinate?.x!==this.state.dismissedAtCoordinate.x||this.props.coordinate?.y!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:t,animationDuration:n,animationEasing:r,children:i,coordinate:a,hasPayload:o,isAnimationActive:s,offset:c,position:l,reverseDirection:u,useTranslate3d:d,viewBox:f,wrapperStyle:p,lastBoundingBox:m,innerRef:h,hasPortalFromProps:g}=this.props,{cssClasses:_,cssProperties:v}=Jpe({allowEscapeViewBox:t,coordinate:a,offsetLeft:typeof c==`number`?c:c.x,offsetTop:typeof c==`number`?c:c.y,position:l,reverseDirection:u,tooltipBox:{height:m.height,width:m.width},useTranslate3d:d,viewBox:f}),b=bj(bj({},g?{}:bj(bj({transition:s&&e?`transform ${n}ms ${r}`:void 0},v),{},{pointerEvents:`none`,visibility:!this.state.dismissed&&e&&o?`visible`:`hidden`,position:`absolute`,top:0,left:0})),{},{visibility:!this.state.dismissed&&e&&o?`visible`:`hidden`},p);return y.createElement(`div`,{xmlns:`http://www.w3.org/1999/xhtml`,tabIndex:-1,className:_,style:b,ref:h},i)}},Sj=()=>gD(e=>e.rootProps.accessibilityLayer)??!0;function Cj(){return Cj=Object.assign?Object.assign.bind():function(e){for(var t=1;tAk(e.x)&&Ak(e.y),Oj=e=>e.base!=null&&Dj(e.base)&&Dj(e),kj=e=>e.x,Aj=e=>e.y,tme=(e,t)=>{if(typeof e==`function`)return e;var n=`curve${RE(e)}`;if((n===`curveMonotone`||n===`curveBump`)&&t){var r=Ej[`${n}${t===`vertical`?`Y`:`X`}`];if(r)return r}return Ej[n]||UT},jj={connectNulls:!1,type:`linear`},nme=e=>{var{type:t=jj.type,points:n=[],baseLine:r,layout:i,connectNulls:a=jj.connectNulls}=e,o=tme(t,i),s=a?n.filter(Dj):n;if(Array.isArray(r)){var c,l=n.map((e,t)=>Tj(Tj({},e),{},{base:r[t]}));return c=i===`vertical`?qT().y(Aj).x1(kj).x0(e=>e.base.x):qT().x(kj).y1(Aj).y0(e=>e.base.y),c.defined(Oj).curve(o)(a?l.filter(Oj):l)}return(i===`vertical`&&AE(r)?qT().y(Aj).x1(kj).x0(r):AE(r)?qT().x(kj).y1(Aj).y0(r):KT().x(kj).y(Aj)).defined(Dj).curve(o)(s)},Mj=e=>{var{className:t,points:n,path:r,pathRef:i}=e,a=xA();if((!n||!n.length)&&!r)return null;var o={type:e.type,points:e.points,baseLine:e.baseLine,layout:e.layout||a,connectNulls:e.connectNulls},s=n&&n.length?nme(o):r;return y.createElement(`path`,Cj({},xT(e),qE(e),{className:_T(`recharts-curve`,t),d:s===null?void 0:s,ref:i}))},rme=[`x`,`y`,`top`,`left`,`width`,`height`,`className`];function Nj(){return Nj=Object.assign?Object.assign.bind():function(e){for(var t=1;t`M${e},${i}v${r}M${a},${t}h${n}`,dme=e=>{var{x:t=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:s}=e,c=cme(e,rme),l=ime({x:t,y:n,top:r,left:i,width:a,height:o},c);return!AE(t)||!AE(n)||!AE(a)||!AE(o)||!AE(r)||!AE(i)?null:y.createElement(`path`,Nj({},CT(l),{className:_T(`recharts-cross`,s),d:ume(t,n,a,o,r,i)}))};function fme(e,t,n,r){var i=r/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?t.x-i:n.left+.5,y:e===`horizontal`?n.top+.5:t.y-i,width:e===`horizontal`?r:n.width-1,height:e===`horizontal`?n.height-1:r}}function Fj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ij(e){for(var t=1;te.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`),Lj=(e,t,n)=>e.map(e=>`${gme(e)} ${t}ms ${n}`).join(`,`),_me=(e,t)=>[Object.keys(e),Object.keys(t)].reduce((e,t)=>e.filter(e=>t.includes(e))),Rj=(e,t)=>Object.keys(t).reduce((n,r)=>Ij(Ij({},n),{},{[r]:e(r,t[r])}),{});function zj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Bj(e){for(var t=1;te+(t-e)*n,Hj=e=>{var{from:t,to:n}=e;return t!==n},Uj=(e,t,n)=>{var r=Rj((t,n)=>{if(Hj(n)){var[r,i]=e(n.from,n.to,n.velocity);return Bj(Bj({},n),{},{from:r,velocity:i})}return n},t);return n<1?Rj((e,t)=>Hj(t)&&r[e]!=null?Bj(Bj({},t),{},{velocity:Vj(t.velocity,r[e].velocity,n),from:Vj(t.from,r[e].from,n)}):t,t):Uj(e,r,n-1)};function xme(e,t,n,r,i,a){var o,s=r.reduce((n,r)=>Bj(Bj({},n),{},{[r]:{from:e[r],velocity:0,to:t[r]}}),{}),c=()=>Rj((e,t)=>t.from,s),l=()=>!Object.values(s).filter(Hj).length,u=null,d=r=>{o||=r;var f=(r-o)/n.dt;s=Uj(n,s,f),i(Bj(Bj(Bj({},e),t),c())),o=r,l()||(u=a.setTimeout(d))};return()=>(u=a.setTimeout(d),()=>{var e;(e=u)==null||e()})}function Sme(e,t,n,r,i,a,o){var s=null,c=i.reduce((n,r)=>{var i=e[r],a=t[r];return i==null||a==null?n:Bj(Bj({},n),{},{[r]:[i,a]})},{}),l,u=i=>{l||=i;var d=(i-l)/r,f=Rj((e,t)=>Vj(...t,n(d)),c);if(a(Bj(Bj(Bj({},e),t),f)),d<1)s=o.setTimeout(u);else{var p=Rj((e,t)=>Vj(...t,n(1)),c);a(Bj(Bj(Bj({},e),t),p))}};return()=>(s=o.setTimeout(u),()=>{var e;(e=s)==null||e()})}var Cme=(e,t,n,r,i,a)=>{var o=_me(e,t);return n==null?()=>(i(Bj(Bj({},e),t)),()=>{}):n.isStepper===!0?xme(e,t,n,o,i,a):Sme(e,t,n,r,o,i,a)},Wj=(e,t)=>[0,3*e,3*t-6*e,3*e-3*t+1],wme=(e,t)=>e.map((e,n)=>e*t**n).reduce((e,t)=>e+t),Gj=(e,t)=>n=>wme(Wj(e,t),n),Tme=(e,t)=>n=>wme([...Wj(e,t).map((e,t)=>e*t).slice(1),0],n),Eme=e=>{var t,n=e.split(`(`);if(n.length!==2||n[0]!==`cubic-bezier`)return null;var r=(t=n[1])==null||(t=t.split(`)`)[0])==null?void 0:t.split(`,`);if(r==null||r.length!==4)return null;var i=r.map(e=>parseFloat(e));return[i[0],i[1],i[2],i[3]]},Dme=function(){var e=[...arguments];if(e.length===1)switch(e[0]){case`linear`:return[0,0,1,1];case`ease`:return[.25,.1,.25,1];case`ease-in`:return[.42,0,1,1];case`ease-out`:return[.42,0,.58,1];case`ease-in-out`:return[0,0,.58,1];default:var t=Eme(e[0]);if(t)return t}return e.length===4?e:[0,0,1,1]},Ome=(e,t,n,r)=>{var i=Gj(e,n),a=Gj(t,r),o=Tme(e,n),s=e=>e>1?1:e<0?0:e,c=e=>{for(var t=e>1?1:e,n=t,r=0;r<8;++r){var c=i(n)-t,l=o(n);if(Math.abs(c-t)<1e-4||l<1e-4)return a(n);n=s(n-c/l)}return a(n)};return c.isStepper=!1,c},Kj=function(){return Ome(...Dme(...arguments))},kme=function(){var{stiff:e=100,damping:t=8,dt:n=17}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=(r,i,a)=>{var o=a+(-(r-i)*e-a*t)*n/1e3,s=a*n/1e3+r;return Math.abs(s-i)<1e-4&&Math.abs(o)<1e-4?[i,0]:[s,o]};return r.isStepper=!0,r.dt=n,r},Ame=e=>{if(typeof e==`string`)switch(e){case`ease`:case`ease-in-out`:case`ease-out`:case`ease-in`:case`linear`:return Kj(e);case`spring`:return kme();default:if(e.split(`(`)[0]===`cubic-bezier`)return Kj(e)}return typeof e==`function`?e:null};function jme(e){var t,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var[s,...c]=o;if(typeof s==`number`){i=e.setTimeout(a.bind(null,c),s);return}a(s),i=e.setTimeout(a.bind(null,c));return}typeof o==`string`&&(t=o,n(t)),typeof o==`object`&&(t=o,n(t)),typeof o==`function`&&o()}};return{stop:()=>{r=!0},start:e=>{r=!1,i&&=(i(),null),a(e)},subscribe:e=>(n=e,()=>{n=()=>null}),getTimeoutController:()=>e}}var Mme=class{setTimeout(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=performance.now(),r=null,i=a=>{a-n>=t?e(a):typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(i))};return r=requestAnimationFrame(i),()=>{r!=null&&cancelAnimationFrame(r)}}};function Nme(){return jme(new Mme)}var Pme=(0,y.createContext)(Nme);function Fme(e,t){var n=(0,y.useContext)(Pme);return(0,y.useMemo)(()=>t??n(e),[e,t,n])}var qj={devToolsEnabled:!0,isSsr:!(typeof window<`u`&&window.document&&window.document.createElement&&window.setTimeout)},Ime={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},Jj={t:0},Yj={t:1};function Xj(e){var t=XE(e,Ime),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:s,onAnimationStart:c,children:l}=t,u=n===`auto`?!qj.isSsr:n,d=Fme(t.animationId,t.animationManager),[f,p]=(0,y.useState)(u?Jj:Yj),m=(0,y.useRef)(null);return(0,y.useEffect)(()=>{u||p(Yj)},[u]),(0,y.useEffect)(()=>{if(!u||!r)return BE;var e=Cme(Jj,Yj,Ame(a),i,p,d.getTimeoutController());return d.start([c,o,()=>{m.current=e()},i,s]),()=>{d.stop(),m.current&&m.current(),s()}},[u,r,i,a,o,c,s,d]),l(f.t)}function Zj(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`animation-`,n=(0,y.useRef)(ME(t)),r=(0,y.useRef)(e);return r.current!==e&&(n.current=ME(t),r.current=e),n.current}var Lme=[`radius`],Rme=[`radius`],zme,Bme,Vme,Hme,Ume,Wme,Gme,Kme,qme,Jme;function Qj(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $j(e){for(var t=1;t{var a=wE(n),o=wE(r),s=Math.min(Math.abs(a)/2,Math.abs(o)/2),c=o>=0?1:-1,l=a>=0?1:-1,u=+(o>=0&&a>=0||o<0&&a<0),d;if(s>0&&Array.isArray(i)){for(var f=[0,0,0,0],p=0,m=4;ps?s:h}d=TE(zme||=nM([`M`,`,`,``]),e,t+c*f[0]),f[0]>0&&(d+=TE(Bme||=nM([`A `,`,`,`,0,0,`,`,`,`,`,``]),f[0],f[0],u,e+l*f[0],t)),d+=TE(Vme||=nM([`L `,`,`,``]),e+n-l*f[1],t),f[1]>0&&(d+=TE(Hme||=nM([`A `,`,`,`,0,0,`,`, + `,`,`,``]),f[1],f[1],u,e+n,t+c*f[1])),d+=TE(Ume||=nM([`L `,`,`,``]),e+n,t+r-c*f[2]),f[2]>0&&(d+=TE(Wme||=nM([`A `,`,`,`,0,0,`,`, + `,`,`,``]),f[2],f[2],u,e+n-l*f[2],t+r)),d+=TE(Gme||=nM([`L `,`,`,``]),e+l*f[3],t+r),f[3]>0&&(d+=TE(Kme||=nM([`A `,`,`,`,0,0,`,`, + `,`,`,``]),f[3],f[3],u,e,t+r-c*f[3])),d+=`Z`}else if(s>0&&i===+i&&i>0){var g=Math.min(s,i);d=TE(qme||=nM(`M .,. A .,.,0,0,.,.,. L .,. A .,.,0,0,.,.,. L .,. A .,.,0,0,.,.,. L .,. - A .,.,0,0,.,.,. Z`.split(`.`)),e,t+c*g,g,g,u,e+l*g,t,e+n-l*g,t,g,g,u,e+n,t+c*g,e+n,t+r-c*g,g,g,u,e+n-l*g,t+r,e+l*g,t+r,g,g,u,e,t+r-c*g)}else d=wE(Yme||=tM([`M `,`,`,` h `,` v `,` h `,` Z`]),e,t,n,r,-n);return d},rM={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},iM=e=>{var t=YE(e,rM),n=(0,y.useRef)(null),[r,i]=(0,y.useState)(-1);(0,y.useEffect)(()=>{if(n.current&&n.current.getTotalLength)try{var e=n.current.getTotalLength();e&&i(e)}catch{}},[]);var{x:a,y:o,width:s,height:c,radius:l,className:u}=t,{animationEasing:d,animationDuration:f,animationBegin:p,isAnimationActive:m,isUpdateAnimationActive:h}=t,g=(0,y.useRef)(s),_=(0,y.useRef)(c),v=(0,y.useRef)(a),b=(0,y.useRef)(o),x=Xj((0,y.useMemo)(()=>({x:a,y:o,width:s,height:c,radius:l}),[a,o,s,c,l]),`rectangle-`);if(a!==+a||o!==+o||s!==+s||c!==+c||s===0||c===0)return null;var S=gT(`recharts-rectangle`,u);if(!h){var C=ST(t),{radius:w}=C,T=eM(C,Rme);return y.createElement(`path`,$j({},T,{x:CE(a),y:CE(o),width:CE(s),height:CE(c),radius:typeof l==`number`?l:void 0,className:S,d:nM(a,o,s,c,l)}))}var E=g.current,D=_.current,O=v.current,k=b.current,A=`0px ${r===-1?1:r}px`,j=`${r}px 0px`,M=Ij([`strokeDasharray`],f,typeof d==`string`?d:rM.animationEasing);return y.createElement(Yj,{animationId:x,key:x,canBegin:r>0,duration:f,easing:d,isActive:h,begin:p},e=>{var r=PE(E,s,e),i=PE(D,c,e),u=PE(O,a,e),d=PE(k,o,e);n.current&&(g.current=r,_.current=i,v.current=u,b.current=d);var f=m?e>0?{transition:M,strokeDasharray:j}:{strokeDasharray:A}:{strokeDasharray:j},p=ST(t),{radius:h}=p,x=eM(p,zme);return y.createElement(`path`,$j({},x,{radius:typeof l==`number`?l:void 0,className:S,d:nM(u,d,r,i,l),ref:n,style:Qj(Qj({},f),t.style)}))})};function aM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oM(e){for(var t=1;te*180/Math.PI,cM=(e,t,n,r)=>({x:e+Math.cos(-sM*r)*n,y:t+Math.sin(-sM*r)*n}),lM=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0,width:0,height:0,brushBottom:0};return Math.min(Math.abs(e-(n.left||0)-(n.right||0)),Math.abs(t-(n.top||0)-(n.bottom||0)))/2},ihe=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return Math.sqrt((n-i)**2+(r-a)**2)},ahe=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:a}=t,o=ihe({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var s=(n-i)/o,c=Math.acos(s);return r>a&&(c=2*Math.PI-c),{radius:o,angle:rhe(c),angleInRadian:c}},ohe=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:t-a*360,endAngle:n-a*360}},she=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),a=Math.floor(r/360);return e+Math.min(i,a)*360},che=(e,t)=>{var{chartX:n,chartY:r}=e,{radius:i,angle:a}=ahe({x:n,y:r},t),{innerRadius:o,outerRadius:s}=t;if(is||i===0)return null;var{startAngle:c,endAngle:l}=ohe(t),u=a,d;if(c<=l){for(;u>l;)u-=360;for(;u=c&&u<=l}else{for(;u>c;)u-=360;for(;u=l&&u<=c}return d?oM(oM({},t),{},{radius:i,angle:she(u,t)}):null};function uM(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:a}=e;return{points:[cM(t,n,r,i),cM(t,n,r,a)],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var lhe,uhe,dhe,fhe,phe,mhe,hhe;function dM(){return dM=Object.assign?Object.assign.bind():function(e){for(var t=1;tEE(t-e)*Math.min(Math.abs(t-e),359.999),pM=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:s,cornerIsExternal:c}=e,l=s*(o?1:-1)+r,u=Math.asin(s/l)/sM,d=c?i:i+a*u,f=cM(t,n,l,d),p=cM(t,n,r,d),m=c?i-a*u:i;return{center:f,circleTangency:p,lineTangency:cM(t,n,l*Math.cos(u*sM),m),theta:u}},mM=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=e,s=ghe(a,o),c=a+s,l=cM(t,n,i,a),u=cM(t,n,i,c),d=wE(lhe||=fM([`M `,`,`,` + A .,.,0,0,.,.,. Z`.split(`.`)),e,t+c*g,g,g,u,e+l*g,t,e+n-l*g,t,g,g,u,e+n,t+c*g,e+n,t+r-c*g,g,g,u,e+n-l*g,t+r,e+l*g,t+r,g,g,u,e,t+r-c*g)}else d=TE(Jme||=nM([`M `,`,`,` h `,` v `,` h `,` Z`]),e,t,n,r,-n);return d},iM={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},aM=e=>{var t=XE(e,iM),n=(0,y.useRef)(null),[r,i]=(0,y.useState)(-1);(0,y.useEffect)(()=>{if(n.current&&n.current.getTotalLength)try{var e=n.current.getTotalLength();e&&i(e)}catch{}},[]);var{x:a,y:o,width:s,height:c,radius:l,className:u}=t,{animationEasing:d,animationDuration:f,animationBegin:p,isAnimationActive:m,isUpdateAnimationActive:h}=t,g=(0,y.useRef)(s),_=(0,y.useRef)(c),v=(0,y.useRef)(a),b=(0,y.useRef)(o),x=Zj((0,y.useMemo)(()=>({x:a,y:o,width:s,height:c,radius:l}),[a,o,s,c,l]),`rectangle-`);if(a!==+a||o!==+o||s!==+s||c!==+c||s===0||c===0)return null;var S=_T(`recharts-rectangle`,u);if(!h){var C=CT(t),{radius:w}=C,T=tM(C,Lme);return y.createElement(`path`,eM({},T,{x:wE(a),y:wE(o),width:wE(s),height:wE(c),radius:typeof l==`number`?l:void 0,className:S,d:rM(a,o,s,c,l)}))}var E=g.current,D=_.current,O=v.current,k=b.current,A=`0px ${r===-1?1:r}px`,j=`${r}px 0px`,M=Lj([`strokeDasharray`],f,typeof d==`string`?d:iM.animationEasing);return y.createElement(Xj,{animationId:x,key:x,canBegin:r>0,duration:f,easing:d,isActive:h,begin:p},e=>{var r=FE(E,s,e),i=FE(D,c,e),u=FE(O,a,e),d=FE(k,o,e);n.current&&(g.current=r,_.current=i,v.current=u,b.current=d);var f=m?e>0?{transition:M,strokeDasharray:j}:{strokeDasharray:A}:{strokeDasharray:j},p=CT(t),{radius:h}=p,x=tM(p,Rme);return y.createElement(`path`,eM({},x,{radius:typeof l==`number`?l:void 0,className:S,d:rM(u,d,r,i,l),ref:n,style:$j($j({},f),t.style)}))})};function oM(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sM(e){for(var t=1;te*180/Math.PI,lM=(e,t,n,r)=>({x:e+Math.cos(-cM*r)*n,y:t+Math.sin(-cM*r)*n}),uM=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{top:0,right:0,bottom:0,left:0,width:0,height:0,brushBottom:0};return Math.min(Math.abs(e-(n.left||0)-(n.right||0)),Math.abs(t-(n.top||0)-(n.bottom||0)))/2},rhe=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return Math.sqrt((n-i)**2+(r-a)**2)},ihe=(e,t)=>{var{x:n,y:r}=e,{cx:i,cy:a}=t,o=rhe({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var s=(n-i)/o,c=Math.acos(s);return r>a&&(c=2*Math.PI-c),{radius:o,angle:nhe(c),angleInRadian:c}},ahe=e=>{var{startAngle:t,endAngle:n}=e,r=Math.floor(t/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:t-a*360,endAngle:n-a*360}},ohe=(e,t)=>{var{startAngle:n,endAngle:r}=t,i=Math.floor(n/360),a=Math.floor(r/360);return e+Math.min(i,a)*360},she=(e,t)=>{var{chartX:n,chartY:r}=e,{radius:i,angle:a}=ihe({x:n,y:r},t),{innerRadius:o,outerRadius:s}=t;if(is||i===0)return null;var{startAngle:c,endAngle:l}=ahe(t),u=a,d;if(c<=l){for(;u>l;)u-=360;for(;u=c&&u<=l}else{for(;u>c;)u-=360;for(;u=l&&u<=c}return d?sM(sM({},t),{},{radius:i,angle:ohe(u,t)}):null};function dM(e){var{cx:t,cy:n,radius:r,startAngle:i,endAngle:a}=e;return{points:[lM(t,n,r,i),lM(t,n,r,a)],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var che,lhe,uhe,dhe,fhe,phe,mhe;function fM(){return fM=Object.assign?Object.assign.bind():function(e){for(var t=1;tDE(t-e)*Math.min(Math.abs(t-e),359.999),mM=e=>{var{cx:t,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:s,cornerIsExternal:c}=e,l=s*(o?1:-1)+r,u=Math.asin(s/l)/cM,d=c?i:i+a*u,f=lM(t,n,l,d),p=lM(t,n,r,d),m=c?i-a*u:i;return{center:f,circleTangency:p,lineTangency:lM(t,n,l*Math.cos(u*cM),m),theta:u}},hM=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=e,s=hhe(a,o),c=a+s,l=lM(t,n,i,a),u=lM(t,n,i,c),d=TE(che||=pM([`M `,`,`,` A `,`,`,`,0, `,`,`,`, `,`,`,` - `]),l.x,l.y,i,i,+(Math.abs(s)>180),+(a>c),u.x,u.y);if(r>0){var f=cM(t,n,r,a),p=cM(t,n,r,c);d+=wE(uhe||=fM([`L `,`,`,` + `]),l.x,l.y,i,i,+(Math.abs(s)>180),+(a>c),u.x,u.y);if(r>0){var f=lM(t,n,r,a),p=lM(t,n,r,c);d+=TE(lhe||=pM([`L `,`,`,` A `,`,`,`,0, `,`,`,`, - `,`,`,` Z`]),p.x,p.y,r,r,+(Math.abs(s)>180),+(a<=c),f.x,f.y)}else d+=wE(dhe||=fM([`L `,`,`,` Z`]),t,n);return d},_he=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:s,startAngle:c,endAngle:l}=e,u=EE(l-c),{circleTangency:d,lineTangency:f,theta:p}=pM({cx:t,cy:n,radius:i,angle:c,sign:u,cornerRadius:a,cornerIsExternal:s}),{circleTangency:m,lineTangency:h,theta:g}=pM({cx:t,cy:n,radius:i,angle:l,sign:-u,cornerRadius:a,cornerIsExternal:s}),_=s?Math.abs(c-l):Math.abs(c-l)-p-g;if(_<0)return o?wE(fhe||=fM([`M `,`,`,` + `,`,`,` Z`]),p.x,p.y,r,r,+(Math.abs(s)>180),+(a<=c),f.x,f.y)}else d+=TE(uhe||=pM([`L `,`,`,` Z`]),t,n);return d},ghe=e=>{var{cx:t,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:s,startAngle:c,endAngle:l}=e,u=DE(l-c),{circleTangency:d,lineTangency:f,theta:p}=mM({cx:t,cy:n,radius:i,angle:c,sign:u,cornerRadius:a,cornerIsExternal:s}),{circleTangency:m,lineTangency:h,theta:g}=mM({cx:t,cy:n,radius:i,angle:l,sign:-u,cornerRadius:a,cornerIsExternal:s}),_=s?Math.abs(c-l):Math.abs(c-l)-p-g;if(_<0)return o?TE(dhe||=pM([`M `,`,`,` a`,`,`,`,0,0,1,`,`,0 a`,`,`,`,0,0,1,`,`,0 - `]),f.x,f.y,a,a,a*2,a,a,-a*2):mM({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:l});var v=wE(phe||=fM([`M `,`,`,` + `]),f.x,f.y,a,a,a*2,a,a,-a*2):hM({cx:t,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:l});var v=TE(fhe||=pM([`M `,`,`,` A`,`,`,`,0,0,`,`,`,`,`,` A`,`,`,`,0,`,`,`,`,`,`,`,` A`,`,`,`,0,0,`,`,`,`,`,` - `]),f.x,f.y,a,a,+(u<0),d.x,d.y,i,i,+(_>180),+(u<0),m.x,m.y,a,a,+(u<0),h.x,h.y);if(r>0){var{circleTangency:y,lineTangency:b,theta:x}=pM({cx:t,cy:n,radius:r,angle:c,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),{circleTangency:S,lineTangency:C,theta:w}=pM({cx:t,cy:n,radius:r,angle:l,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),T=s?Math.abs(c-l):Math.abs(c-l)-x-w;if(T<0&&a===0)return`${v}L${t},${n}Z`;v+=wE(mhe||=fM([`L`,`,`,` + `]),f.x,f.y,a,a,+(u<0),d.x,d.y,i,i,+(_>180),+(u<0),m.x,m.y,a,a,+(u<0),h.x,h.y);if(r>0){var{circleTangency:y,lineTangency:b,theta:x}=mM({cx:t,cy:n,radius:r,angle:c,sign:u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),{circleTangency:S,lineTangency:C,theta:w}=mM({cx:t,cy:n,radius:r,angle:l,sign:-u,isExternal:!0,cornerRadius:a,cornerIsExternal:s}),T=s?Math.abs(c-l):Math.abs(c-l)-x-w;if(T<0&&a===0)return`${v}L${t},${n}Z`;v+=TE(phe||=pM([`L`,`,`,` A`,`,`,`,0,0,`,`,`,`,`,` A`,`,`,`,0,`,`,`,`,`,`,`,` - A`,`,`,`,0,0,`,`,`,`,`,`Z`]),C.x,C.y,a,a,+(u<0),S.x,S.y,r,r,+(T>180),+(u>0),y.x,y.y,a,a,+(u<0),b.x,b.y)}else v+=wE(hhe||=fM([`L`,`,`,`Z`]),t,n);return v},vhe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},hM=e=>{var t=YE(e,vhe),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u,className:d}=t;if(a0&&Math.abs(l-u)<360?_he({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(m,p/2),forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u}):mM({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:l,endAngle:u});return y.createElement(`path`,dM({},ST(t),{className:f,d:h}))};function yhe(e,t,n){if(e===`horizontal`)return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e===`vertical`)return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(GE(t)){if(e===`centric`){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:s}=t,c=cM(r,i,a,s),l=cM(r,i,o,s);return[{x:c.x,y:c.y},{x:l.x,y:l.y}]}return uM(t)}}var bhe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=xD();function n(e){return t.isSymbol(e)?NaN:Number(e)}e.toNumber=n})),xhe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=bhe();function n(e){return e?(e=t.toNumber(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}e.toFinite=n})),She=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=SD(),n=xhe();function r(e,r,i){i&&typeof i!=`number`&&t.isIterateeCall(e,r,i)&&(r=i=void 0),e=n.toFinite(e),r===void 0?(r=e,e=0):r=n.toFinite(r),i=i===void 0?e{t.exports=She().range}));function gM(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function whe(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function _M(e){let t,n,r;e.length===2?(t=e===gM||e===whe?e:The,n=e,r=e):(t=gM,n=(t,n)=>gM(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function The(){return 0}function vM(e){return e===null?NaN:+e}function*Ehe(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var yM=_M(gM),bM=yM.right;yM.left,_M(vM).center;var xM=class extends Map{constructor(e,t=khe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(SM(this,e))}has(e){return super.has(SM(this,e))}set(e,t){return super.set(Dhe(this,e),t)}delete(e){return super.delete(Ohe(this,e))}};function SM({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Dhe({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Ohe({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function khe(e){return typeof e==`object`&&e?e.valueOf():e}function Ahe(e=gM){if(e===gM)return CM;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function CM(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et))}var jhe=Math.sqrt(50),Mhe=Math.sqrt(10),Nhe=Math.sqrt(2);function wM(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=jhe?10:a>=Mhe?5:a>=Nhe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}function kM(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function AM(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?CM:Ahe(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));AM(e,t,u,d,i)}let a=e[t],o=n,s=r;for(jM(e,n,t),i(e[r],a)>0&&jM(e,n,r);o0;)--s}i(e[n],a)===0?jM(e,n,s):(++s,jM(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function jM(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Phe(e,t,n){if(e=Float64Array.from(Ehe(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return kM(e);if(t>=1)return OM(e);var r,i=(r-1)*t,a=Math.floor(i),o=OM(AM(e,a).subarray(0,a+1));return o+(kM(e.subarray(a+1))-o)*(i-a)}}function Fhe(e,t,n=vM){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function Ihe(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ZM(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ZM(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=zhe.exec(e))?new $M(t[1],t[2],t[3],1):(t=Bhe.exec(e))?new $M(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vhe.exec(e))?ZM(t[1],t[2],t[3],t[4]):(t=Hhe.exec(e))?ZM(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Uhe.exec(e))?aN(t[1],t[2]/100,t[3]/100,1):(t=Whe.exec(e))?aN(t[1],t[2]/100,t[3]/100,t[4]):KM.hasOwnProperty(e)?XM(KM[e]):e===`transparent`?new $M(NaN,NaN,NaN,0):null}function XM(e){return new $M(e>>16&255,e>>8&255,e&255,1)}function ZM(e,t,n,r){return r<=0&&(e=t=n=NaN),new $M(e,t,n,r)}function qhe(e){return e instanceof BM||(e=YM(e)),e?(e=e.rgb(),new $M(e.r,e.g,e.b,e.opacity)):new $M}function QM(e,t,n,r){return arguments.length===1?qhe(e):new $M(e,t,n,r??1)}function $M(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}RM($M,QM,zM(BM,{brighter(e){return e=e==null?HM:HM**+e,new $M(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?VM:VM**+e,new $M(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $M(rN(this.r),rN(this.g),rN(this.b),nN(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:eN,formatHex:eN,formatHex8:Jhe,formatRgb:tN,toString:tN}));function eN(){return`#${iN(this.r)}${iN(this.g)}${iN(this.b)}`}function Jhe(){return`#${iN(this.r)}${iN(this.g)}${iN(this.b)}${iN((isNaN(this.opacity)?1:this.opacity)*255)}`}function tN(){let e=nN(this.opacity);return`${e===1?`rgb(`:`rgba(`}${rN(this.r)}, ${rN(this.g)}, ${rN(this.b)}${e===1?`)`:`, ${e})`}`}function nN(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rN(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function iN(e){return e=rN(e),(e<16?`0`:``)+e.toString(16)}function aN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new sN(e,t,n,r)}function oN(e){if(e instanceof sN)return new sN(e.h,e.s,e.l,e.opacity);if(e instanceof BM||(e=YM(e)),!e)return new sN;if(e instanceof sN)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new sN(o,s,c,e.opacity)}function Yhe(e,t,n,r){return arguments.length===1?oN(e):new sN(e,t,n,r??1)}function sN(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}RM(sN,Yhe,zM(BM,{brighter(e){return e=e==null?HM:HM**+e,new sN(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?VM:VM**+e,new sN(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new $M(uN(e>=240?e-240:e+120,i,r),uN(e,i,r),uN(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new sN(cN(this.h),lN(this.s),lN(this.l),nN(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=nN(this.opacity);return`${e===1?`hsl(`:`hsla(`}${cN(this.h)}, ${lN(this.s)*100}%, ${lN(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function cN(e){return e=(e||0)%360,e<0?e+360:e}function lN(e){return Math.max(0,Math.min(1,e||0))}function uN(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var dN=e=>()=>e;function Xhe(e,t){return function(n){return e+n*t}}function Zhe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Qhe(e){return(e=+e)==1?fN:function(t,n){return n-t?Zhe(t,n,e):dN(isNaN(t)?n:t)}}function fN(e,t){var n=t-e;return n?Xhe(e,n):dN(isNaN(e)?t:e)}var pN=(function e(t){var n=Qhe(t);function r(e,t){var r=n((e=QM(e)).r,(t=QM(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=fN(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function $he(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:mN(r,i)})),n=gN.lastIndex;return nt&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function uge(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?dge:uge,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),mN))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,yN),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=vN,u()},d.clamp=function(e){return arguments.length?(o=e?!0:xN,u()):o!==xN},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function TN(){return wN()(xN,xN)}function fge(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function EN(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function DN(e){return e=EN(Math.abs(e)),e?e[1]:NaN}function pge(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function mge(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var hge=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ON(e){if(!(t=hge.exec(e)))throw Error(`invalid format: `+e);var t;return new kN({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}ON.prototype=kN.prototype;function kN(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}kN.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function gge(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var AN;function _ge(e,t){var n=EN(e,t);if(!n)return AN=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(AN=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+EN(e,Math.max(0,t+a-1))[0]}function jN(e,t){var n=EN(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var MN={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:fge,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>jN(e*100,t),r:jN,s:_ge,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function NN(e){return e}var PN=Array.prototype.map,FN=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function vge(e){var t=e.grouping===void 0||e.thousands===void 0?NN:pge(PN.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?NN:mge(PN.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=ON(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):MN[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=MN[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=gge(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&AN!==void 0?FN[8+AN/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(DN(t)/3)))*3,r=10**-n,i=l((e=ON(e),e.type=`f`,e),{suffix:FN[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var IN,LN,RN;yge({thousands:`,`,grouping:[3],currency:[`$`,``]});function yge(e){return IN=vge(e),LN=IN.format,RN=IN.formatPrefix,IN}function bge(e){return Math.max(0,-DN(Math.abs(e)))}function xge(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(DN(t)/3)))*3-DN(Math.abs(e)))}function Sge(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,DN(t)-DN(e))+1}function zN(e,t,n,r){var i=DM(e,t,n),a;switch(r=ON(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=xge(i,o))&&(r.precision=a),RN(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=Sge(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=bge(i))&&(r.precision=a-(r.type===`%`)*2);break}return LN(r)}function BN(e){var t=e.domain;return e.ticks=function(e){var n=t();return TM(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return zN(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=EM(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function VN(){var e=TN();return e.copy=function(){return CN(e,VN())},MM.apply(e,arguments),BN(e)}function HN(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,yN),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return HN(e).unknown(t)},e=arguments.length?Array.from(e,yN):[0,1],BN(n)}function UN(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return ae**+t}function Dge(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function KN(e){return(t,n)=>-e(-t,n)}function qN(e){let t=e(WN,GN),n=t.domain,r=10,i,a;function o(){return i=Dge(r),a=Ege(r),n()[0]<0?(i=KN(i),a=KN(a),e(Cge,wge)):e(WN,GN),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s0){for(;l<=u;++l)for(d=1;ds)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(fs)break;m.push(f)}m.length*2{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=ON(n)).precision==null&&(n.trim=!0),n=LN(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*rn(UN(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function JN(){let e=qN(wN()).domain([1,10]);return e.copy=()=>CN(e,JN()).base(e.base()),MM.apply(e,arguments),e}function YN(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function XN(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function ZN(e){var t=1,n=e(YN(t),XN(t));return n.constant=function(n){return arguments.length?e(YN(t=+n),XN(t)):t},BN(n)}function QN(){var e=ZN(wN());return e.copy=function(){return CN(e,QN()).constant(e.constant())},MM.apply(e,arguments)}function $N(e){return function(t){return t<0?-((-t)**+e):t**+e}}function Oge(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function kge(e){return e<0?-e*e:e*e}function eP(e){var t=e(xN,xN),n=1;function r(){return n===1?e(xN,xN):n===.5?e(Oge,kge):e($N(n),$N(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},BN(t)}function tP(){var e=eP(wN());return e.copy=function(){return CN(e,tP()).exponent(e.exponent())},MM.apply(e,arguments),e}function Age(){return tP.apply(null,arguments).exponent(.5)}function nP(e){return Math.sign(e)*e*e}function jge(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function rP(){var e=TN(),t=[0,1],n=!1,r;function i(t){var i=jge(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(nP(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,yN)).map(nP)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return rP(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},MM.apply(i,arguments),BN(i)}function iP(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r0?n[i-1]:e[0],i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return aP().domain([e,t]).range(i).unknown(a)},MM.apply(BN(o),arguments)}function oP(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[bM(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return oP().domain(e).range(t).unknown(n)},MM.apply(i,arguments)}var sP=new Date,cP=new Date;function lP(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(slP(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(sP.setTime(+t),cP.setTime(+r),e(sP),e(cP),Math.floor(n(sP,cP))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var uP=lP(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);uP.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?lP(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):uP),uP.range;var dP=1e3,fP=dP*60,pP=fP*60,mP=pP*24,hP=mP*7,gP=mP*30,_P=mP*365,vP=lP(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*dP)},(e,t)=>(t-e)/dP,e=>e.getUTCSeconds());vP.range;var yP=lP(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*dP)},(e,t)=>{e.setTime(+e+t*fP)},(e,t)=>(t-e)/fP,e=>e.getMinutes());yP.range;var bP=lP(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*fP)},(e,t)=>(t-e)/fP,e=>e.getUTCMinutes());bP.range;var xP=lP(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*dP-e.getMinutes()*fP)},(e,t)=>{e.setTime(+e+t*pP)},(e,t)=>(t-e)/pP,e=>e.getHours());xP.range;var SP=lP(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*pP)},(e,t)=>(t-e)/pP,e=>e.getUTCHours());SP.range;var CP=lP(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*fP)/mP,e=>e.getDate()-1);CP.range;var wP=lP(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/mP,e=>e.getUTCDate()-1);wP.range;var TP=lP(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/mP,e=>Math.floor(e/mP));TP.range;function EP(e){return lP(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*fP)/hP)}var DP=EP(0),OP=EP(1),Mge=EP(2),Nge=EP(3),kP=EP(4),Pge=EP(5),Fge=EP(6);DP.range,OP.range,Mge.range,Nge.range,kP.range,Pge.range,Fge.range;function AP(e){return lP(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/hP)}var jP=AP(0),MP=AP(1),Ige=AP(2),Lge=AP(3),NP=AP(4),Rge=AP(5),zge=AP(6);jP.range,MP.range,Ige.range,Lge.range,NP.range,Rge.range,zge.range;var PP=lP(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());PP.range;var FP=lP(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());FP.range;var IP=lP(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());IP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:lP(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),IP.range;var LP=lP(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());LP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:lP(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),LP.range;function RP(e,t,n,r,i,a){let o=[[vP,1,dP],[vP,5,5*dP],[vP,15,15*dP],[vP,30,30*dP],[a,1,fP],[a,5,5*fP],[a,15,15*fP],[a,30,30*fP],[i,1,pP],[i,3,3*pP],[i,6,6*pP],[i,12,12*pP],[r,1,mP],[r,2,2*mP],[n,1,hP],[t,1,gP],[t,3,3*gP],[e,1,_P]];function s(e,t,n){let r=te).right(o,i);if(a===o.length)return e.every(DM(t/_P,n/_P,r));if(a===0)return uP.every(Math.max(DM(t,n,r),1));let[s,c]=o[i/o[a-1][2]53)return null;`w`in r||(r.w=1),`Z`in r?(a=BP(VP(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?MP.ceil(a):MP(a),a=wP.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=zP(VP(r.y,0,1)),o=a.getDay(),a=o>4||o===0?OP.ceil(a):OP(a),a=CP.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else (`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?BP(VP(r.y,0,1)).getUTCDay():zP(VP(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,BP(r)):zP(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Gge?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function N(e){return o[e.getDay()]}function P(e){return a[e.getDay()]}function F(e){return c[e.getMonth()]}function I(e){return s[e.getMonth()]}function L(e){return i[+(e.getHours()>=12)]}function R(e){return 1+~~(e.getMonth()/3)}function z(e){return o[e.getUTCDay()]}function B(e){return a[e.getUTCDay()]}function V(e){return c[e.getUTCMonth()]}function ee(e){return s[e.getUTCMonth()]}function te(e){return i[+(e.getUTCHours()>=12)]}function ne(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var Gge={"-":``,_:` `,0:`0`},HP=/^\s*\d+/,Kge=/^%/,qge=/[\\^$*+?|[\]().{}]/g;function UP(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a[e.toLowerCase(),t]))}function Yge(e,t,n){var r=HP.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Xge(e,t,n){var r=HP.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Zge(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Qge(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function $ge(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function KP(e,t,n){var r=HP.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function qP(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function e_e(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function t_e(e,t,n){var r=HP.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function n_e(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function JP(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function r_e(e,t,n){var r=HP.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function YP(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function i_e(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function a_e(e,t,n){var r=HP.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function o_e(e,t,n){var r=HP.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function s_e(e,t,n){var r=HP.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function c_e(e,t,n){var r=Kge.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function l_e(e,t,n){var r=HP.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function u_e(e,t,n){var r=HP.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function XP(e,t){return UP(e.getDate(),t,2)}function d_e(e,t){return UP(e.getHours(),t,2)}function f_e(e,t){return UP(e.getHours()%12||12,t,2)}function p_e(e,t){return UP(1+CP.count(IP(e),e),t,3)}function ZP(e,t){return UP(e.getMilliseconds(),t,3)}function m_e(e,t){return ZP(e,t)+`000`}function h_e(e,t){return UP(e.getMonth()+1,t,2)}function g_e(e,t){return UP(e.getMinutes(),t,2)}function __e(e,t){return UP(e.getSeconds(),t,2)}function v_e(e){var t=e.getDay();return t===0?7:t}function y_e(e,t){return UP(DP.count(IP(e)-1,e),t,2)}function QP(e){var t=e.getDay();return t>=4||t===0?kP(e):kP.ceil(e)}function b_e(e,t){return e=QP(e),UP(kP.count(IP(e),e)+(IP(e).getDay()===4),t,2)}function x_e(e){return e.getDay()}function S_e(e,t){return UP(OP.count(IP(e)-1,e),t,2)}function C_e(e,t){return UP(e.getFullYear()%100,t,2)}function w_e(e,t){return e=QP(e),UP(e.getFullYear()%100,t,2)}function T_e(e,t){return UP(e.getFullYear()%1e4,t,4)}function E_e(e,t){var n=e.getDay();return e=n>=4||n===0?kP(e):kP.ceil(e),UP(e.getFullYear()%1e4,t,4)}function D_e(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+UP(t/60|0,`0`,2)+UP(t%60,`0`,2)}function $P(e,t){return UP(e.getUTCDate(),t,2)}function O_e(e,t){return UP(e.getUTCHours(),t,2)}function k_e(e,t){return UP(e.getUTCHours()%12||12,t,2)}function A_e(e,t){return UP(1+wP.count(LP(e),e),t,3)}function eF(e,t){return UP(e.getUTCMilliseconds(),t,3)}function j_e(e,t){return eF(e,t)+`000`}function M_e(e,t){return UP(e.getUTCMonth()+1,t,2)}function N_e(e,t){return UP(e.getUTCMinutes(),t,2)}function P_e(e,t){return UP(e.getUTCSeconds(),t,2)}function F_e(e){var t=e.getUTCDay();return t===0?7:t}function I_e(e,t){return UP(jP.count(LP(e)-1,e),t,2)}function tF(e){var t=e.getUTCDay();return t>=4||t===0?NP(e):NP.ceil(e)}function L_e(e,t){return e=tF(e),UP(NP.count(LP(e),e)+(LP(e).getUTCDay()===4),t,2)}function R_e(e){return e.getUTCDay()}function z_e(e,t){return UP(MP.count(LP(e)-1,e),t,2)}function B_e(e,t){return UP(e.getUTCFullYear()%100,t,2)}function V_e(e,t){return e=tF(e),UP(e.getUTCFullYear()%100,t,2)}function H_e(e,t){return UP(e.getUTCFullYear()%1e4,t,4)}function U_e(e,t){var n=e.getUTCDay();return e=n>=4||n===0?NP(e):NP.ceil(e),UP(e.getUTCFullYear()%1e4,t,4)}function W_e(){return`+0000`}function nF(){return`%`}function rF(e){return+e}function iF(e){return Math.floor(e/1e3)}var aF,oF,sF;G_e({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function G_e(e){return aF=Wge(e),oF=aF.format,aF.parse,sF=aF.utcFormat,aF.utcParse,aF}function K_e(e){return new Date(e)}function q_e(e){return e instanceof Date?+e:+new Date(+e)}function cF(e,t,n,r,i,a,o,s,c,l){var u=TN(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>Phe(e,r/t))},n.copy=function(){return hF(t).domain(e)},NM.apply(n,arguments)}function gF(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=xN,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*eIM,scaleDiverging:()=>_F,scaleDivergingLog:()=>vF,scaleDivergingPow:()=>bF,scaleDivergingSqrt:()=>Z_e,scaleDivergingSymlog:()=>yF,scaleIdentity:()=>HN,scaleImplicit:()=>PM,scaleLinear:()=>VN,scaleLog:()=>JN,scaleOrdinal:()=>FM,scalePoint:()=>Lhe,scalePow:()=>tP,scaleQuantile:()=>iP,scaleQuantize:()=>aP,scaleRadial:()=>rP,scaleSequential:()=>dF,scaleSequentialLog:()=>fF,scaleSequentialPow:()=>mF,scaleSequentialQuantile:()=>hF,scaleSequentialSqrt:()=>X_e,scaleSequentialSymlog:()=>pF,scaleSqrt:()=>Age,scaleSymlog:()=>QN,scaleThreshold:()=>oP,scaleTime:()=>J_e,scaleUtc:()=>Y_e,tickFormat:()=>zN}),SF=e=>e.chartData,CF=bD([SF],e=>{var t=e.chartData==null?0:e.chartData.length-1;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),wF=(e,t,n,r)=>r?CF(e):SF(e),TF=(e,t,n)=>n?CF(e):SF(e);function EF(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(kk(t)&&kk(n))return!0}return!1}function DF(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function OF(e,t){if(t&&typeof e!=`function`&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,a;if(kk(n))i=n;else if(typeof n==`function`)return;if(kk(r))a=r;else if(typeof r==`function`)return;var o=[i,a];if(EF(o))return o}}function Q_e(e,t,n){if(!(!n&&t==null)){if(typeof e==`function`&&t!=null)try{var r=e(t,n);if(EF(r))return DF(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,a]=e,o,s;if(i===`auto`)t!=null&&(o=Math.min(...t));else if(kE(i))o=i;else if(typeof i==`function`)try{t!=null&&(o=i(t?.[0]))}catch{}else if(typeof i==`string`&&Bk.test(i)){var c=Bk.exec(i);if(c==null||c[1]==null||t==null)o=void 0;else{var l=+c[1];o=t[0]-l}}else o=t?.[0];if(a===`auto`)t!=null&&(s=Math.max(...t));else if(kE(a))s=a;else if(typeof a==`function`)try{t!=null&&(s=a(t?.[1]))}catch{}else if(typeof a==`string`&&Vk.test(a)){var u=Vk.exec(a);if(u==null||u[1]==null||t==null)s=void 0;else{var d=+u[1];s=t[1]+d}}else s=t?.[1];var f=[o,s];if(EF(f))return t==null?f:DF(f,t,n)}}}var kF=l(o(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||en)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tr?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,j=r.s==i.s?1:-1,M=r.d,N=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=N.length,T=M.length,g=new A(j),_=g.d=[],u=0;N[u]==(M[u]||0);)++u;if(N[u]>(M[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,N=N[0],x++;(u1&&(N=e(N,d),M=e(M,d),O=N.length,T=M.length),w=O,v=M.slice(0,O),y=v.length;y=f/2&&++E;do d=0,c=t(N,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(N,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),rh||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function j(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=j,i.config=i.set=M,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=j(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))());function AF(e){return e===0?1:Math.floor(new kF.default(e).abs().log(10).toNumber())+1}function jF(e,t,n){for(var r=new kF.default(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var MF=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},NF=(e,t,n)=>{if(e.lte(0))return new kF.default(0);var r=AF(e.toNumber()),i=new kF.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new kF.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new kF.default(s.toNumber()):new kF.default(Math.ceil(s.toNumber()))},$_e=(e,t,n)=>{var r=new kF.default(1),i=new kF.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new kF.default(10).pow(AF(e)-1),i=new kF.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new kF.default(Math.floor(e)))}else e===0?i=new kF.default(Math.floor((t-1)/2)):n||(i=new kF.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(n-1)))return{step:new kF.default(0),tickMin:new kF.default(0),tickMax:new kF.default(0)};var a=NF(new kF.default(t).sub(e).div(n-1),r,i),o;e<=0&&t>=0?o=new kF.default(0):(o=new kF.default(e).add(t).div(2),o=o.sub(new kF.default(o).mod(a)));var s=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new kF.default(t).sub(o).div(a).toNumber()),l=s+c+1;return l>n?PF(e,t,n,r,i+1):(l0?c+(n-l):c,s=t>0?s:s+(n-l)),{step:a,tickMin:o.sub(new kF.default(s).mul(a)),tickMax:o.add(new kF.default(c).mul(a))})},eve=function(e){var[t,n]=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(r,2),[o,s]=MF([t,n]);if(o===-1/0||s===1/0){var c=s===1/0?[o,...Array(r-1).fill(1/0)]:[...Array(r-1).fill(-1/0),s];return t>n?c.reverse():c}if(o===s)return $_e(o,r,i);var{step:l,tickMin:u,tickMax:d}=PF(o,s,a,i,0),f=jF(u,d.add(new kF.default(.1).mul(l)),l);return t>n?f.reverse():f},tve=function(e,t){var[n,r]=e,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=MF([n,r]);if(a===-1/0||o===1/0)return[n,r];if(a===o)return[a];var s=Math.max(t,2),c=NF(new kF.default(o).sub(a).div(s-1),i,0),l=[...jF(new kF.default(a),new kF.default(o),c),o];return i===!1&&(l=l.map(e=>Math.round(e))),n>r?l.reverse():l},FF=e=>e.rootProps.maxBarSize,nve=e=>e.rootProps.barGap,IF=e=>e.rootProps.barCategoryGap,rve=e=>e.rootProps.barSize,LF=e=>e.rootProps.stackOffset,RF=e=>e.rootProps.reverseStackOrder,zF=e=>e.options.chartName,BF=e=>e.rootProps.syncId,VF=e=>e.rootProps.syncMethod,HF=e=>e.options.eventEmitter,ive=e=>e.rootProps.baseValue,UF={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},WF={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:UF.axis},GF={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:UF.axis},KF=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function qF(e,t,n){if(n!==`auto`)return n;if(e!=null)return Pk(e,t)?`category`:`number`}function JF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function YF(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},SA],(e,t)=>{if(e!=null)return e;var n=qF(t,`angleAxis`,XF.type)??`category`;return YF(YF({},XF),{},{type:n})}),$F=bD([(e,t)=>e.polarAxis.radiusAxis[t],SA],(e,t)=>{if(e!=null)return e;var n=qF(t,`radiusAxis`,ZF.type)??`category`;return YF(YF({},ZF),{},{type:n})}),eI=e=>e.polarOptions,tI=bD([Gk,Kk,$k],lM),nI=bD([eI,tI],(e,t)=>{if(e!=null)return ME(e.innerRadius,t,0)}),rI=bD([eI,tI],(e,t)=>{if(e!=null)return ME(e.outerRadius,t,t*.8)}),iI=bD([eI],e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]});bD([QF,iI],KF);var aI=bD([tI,nI,rI],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});bD([$F,aI],KF);var oI=bD([yA,eI,nI,rI,Gk,Kk],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var{cx:o,cy:s,startAngle:c,endAngle:l}=t;return{cx:ME(o,i,i/2),cy:ME(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),sI=(e,t)=>t,cI=(e,t,n)=>n;function lI(e){return e?.id}function uI(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return e.forEach(e=>{var t=e.data??r;if(!(t==null||t.length===0)){var n=lI(e);t.forEach((t,r)=>{var s=a==null||i?r:String(Nk(t,a,null)),c=Nk(t,e.dataKey,0),l=o.has(s)?o.get(s):{};Object.assign(l,{[n]:c}),o.set(s,l)})}}),Array.from(o.values())}function dI(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var fI=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function pI(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function cve(e,t){if(e.length===t.length){for(var n=0;n{var t=yA(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},hI=e=>e.tooltip.settings.axisId;function lve(e){if(e in xF)return xF[e]();var t=`scale${LE(e)}`;if(t in xF)return xF[t]()}function gI(e){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i;break;default:break}}return r}}}}function _I(e,t,n){if(typeof e==`function`)return gI(e.copy().domain(t).range(n));if(e!=null){var r=lve(e);if(r!=null)return r.domain(t).range(n),gI(r)}}var vI=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!EF(t)){for(var n,r,i=0;ir)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}},yI=l(Che());function bI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xI(e){for(var t=1;te.cartesianAxis.xAxis[t],TI=(e,t)=>wI(e,t)??CI,EI={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:SI,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`left`,padding:{top:0,bottom:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`number`,unit:void 0,width:60},DI=(e,t)=>e.cartesianAxis.yAxis[t],OI=(e,t)=>DI(e,t)??EI,pve={domain:[0,`auto`],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:``,range:[64,64],scale:`auto`,type:`number`,unit:``},kI=(e,t)=>e.cartesianAxis.zAxis[t]??pve,AI=(e,t,n)=>{switch(t){case`xAxis`:return TI(e,n);case`yAxis`:return OI(e,n);case`zAxis`:return kI(e,n);case`angleAxis`:return QF(e,n);case`radiusAxis`:return $F(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},mve=(e,t,n)=>{switch(t){case`xAxis`:return TI(e,n);case`yAxis`:return OI(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},jI=(e,t,n)=>{switch(t){case`xAxis`:return TI(e,n);case`yAxis`:return OI(e,n);case`angleAxis`:return QF(e,n);case`radiusAxis`:return $F(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},MI=e=>e.graphicalItems.cartesianItems.some(e=>e.type===`bar`)||e.graphicalItems.polarItems.some(e=>e.type===`radialBar`);function NI(e,t){return n=>{switch(e){case`xAxis`:return`xAxisId`in n&&n.xAxisId===t;case`yAxis`:return`yAxisId`in n&&n.yAxisId===t;case`zAxis`:return`zAxisId`in n&&n.zAxisId===t;case`angleAxis`:return`angleAxisId`in n&&n.angleAxisId===t;case`radiusAxis`:return`radiusAxisId`in n&&n.radiusAxisId===t;default:return!1}}}var PI=e=>e.graphicalItems.cartesianItems,hve=bD([sI,cI],NI),FI=(e,t,n)=>e.filter(n).filter(e=>t?.includeHidden===!0?!0:!e.hide),II=bD([PI,AI,hve],FI,{memoizeOptions:{resultEqualityCheck:pI}}),LI=bD([II],e=>e.filter(e=>e.type===`area`||e.type===`bar`).filter(dI)),RI=e=>e.filter(e=>!(`stackId`in e)||e.stackId===void 0),gve=bD([II],RI),zI=e=>e.map(e=>e.data).filter(Boolean).flat(1),_ve=bD([II],zI,{memoizeOptions:{resultEqualityCheck:pI}}),BI=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},VI=bD([_ve,wF],BI),HI=(e,t,n)=>t?.dataKey==null?n.length>0?n.map(e=>e.dataKey).flatMap(t=>e.map(e=>({value:Nk(e,t)}))):e.map(e=>({value:e})):e.map(e=>({value:Nk(e,t.dataKey)})),UI=bD([VI,AI,II],HI);function WI(e,t){switch(e){case`xAxis`:return t.direction===`x`;case`yAxis`:return t.direction===`y`;default:return!1}}function GI(e){if(AE(e)||e instanceof Date){var t=Number(e);if(kk(t))return t}}function KI(e){if(Array.isArray(e)){var t=[GI(e[0]),GI(e[1])];return EF(t)?t:void 0}var n=GI(e);if(n!=null)return[n,n]}function qI(e){return e.map(GI).filter(RE)}function vve(e,t,n){return!n||typeof t!=`number`||DE(t)||!n.length?[]:qI(n.flatMap(n=>{var r=Nk(e,n.dataKey),i,a;if(Array.isArray(r)?[i,a]=r:i=a=r,!(!kk(i)||!kk(a)))return[t-i,t+a]}))}var JI=e=>jI(e,mI(e),hI(e)),YI=bD([JI],e=>e?.dataKey),yve=bD([LI,wF,JI],uI),XI=(e,t,n,r)=>{var i=t.reduce((e,t)=>{if(t.stackId==null)return e;var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},{});return Object.fromEntries(Object.entries(i).map(t=>{var[i,a]=t,o=r?[...a].reverse():a;return[i,{stackedData:wfe(e,o.map(lI),n),graphicalItems:o}]}))},ZI=bD([yve,LI,LF,RF],XI),QI=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=t;if(r==null&&n!==`zAxis`){var o=Ofe(e,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},bve=bD([AI],e=>e.allowDataOverflow),$I=e=>{if(e==null||!(`domain`in e))return SI;if(e.domain!=null)return e.domain;if(`ticks`in e&&e.ticks!=null){if(e.type===`number`){var t=qI(e.ticks);return[Math.min(...t),Math.max(...t)]}if(e.type===`category`)return e.ticks.map(String)}return e?.domain??SI},eL=bD([AI],$I),tL=bD([eL,bve],OF),xve=bD([ZI,SF,sI,tL],QI,{memoizeOptions:{resultEqualityCheck:fI}}),nL=e=>e.errorBars,Sve=(e,t,n)=>e.flatMap(e=>t[e.id]).filter(Boolean).filter(e=>WI(n,e)),rL=function(){var e=[...arguments].filter(Boolean);if(e.length!==0){var t=e.flat();return[Math.min(...t),Math.max(...t)]}},iL=(e,t,n,r,i)=>{var a,o;if(n.length>0&&e.forEach(e=>{n.forEach(n=>{var s=r[n.id]?.filter(e=>WI(i,e)),c=Nk(e,t.dataKey??n.dataKey),l=vve(e,c,s);if(l.length>=2){var u=Math.min(...l),d=Math.max(...l);(a==null||uo)&&(o=d)}var f=KI(c);f!=null&&(a=a==null?f[0]:Math.min(a,f[0]),o=o==null?f[1]:Math.max(o,f[1]))})}),t?.dataKey!=null&&e.forEach(e=>{var n=KI(Nk(e,t.dataKey));n!=null&&(a=a==null?n[0]:Math.min(a,n[0]),o=o==null?n[1]:Math.max(o,n[1]))}),kk(a)&&kk(o))return[a,o]},Cve=bD([VI,AI,gve,nL,sI],iL,{memoizeOptions:{resultEqualityCheck:fI}});function wve(e){var{value:t}=e;if(AE(t)||t instanceof Date)return t}var Tve=(e,t,n)=>{var r=e.map(wve).filter(e=>e!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&NE(r))?(0,yI.default)(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},aL=e=>e.referenceElements.dots,oL=(e,t,n)=>e.filter(e=>e.ifOverflow===`extendDomain`).filter(e=>t===`xAxis`?e.xAxisId===n:e.yAxisId===n),Eve=bD([aL,sI,cI],oL),sL=e=>e.referenceElements.areas,Dve=bD([sL,sI,cI],oL),cL=e=>e.referenceElements.lines,Ove=bD([cL,sI,cI],oL),lL=(e,t)=>{if(e!=null){var n=qI(e.map(e=>t===`xAxis`?e.x:e.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},kve=bD(Eve,sI,lL),uL=(e,t)=>{if(e!=null){var n=qI(e.flatMap(e=>[t===`xAxis`?e.x1:e.y1,t===`xAxis`?e.x2:e.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Ave=bD([Dve,sI],uL);function jve(e){if(e.x!=null)return qI([e.x]);var t=e.segment?.map(e=>e.x);return t==null||t.length===0?[]:qI(t)}function Mve(e){if(e.y!=null)return qI([e.y]);var t=e.segment?.map(e=>e.y);return t==null||t.length===0?[]:qI(t)}var dL=(e,t)=>{if(e!=null){var n=e.flatMap(e=>t===`xAxis`?jve(e):Mve(e));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Nve=bD(kve,bD([Ove,sI],dL),Ave,(e,t,n)=>rL(e,n,t)),fL=(e,t,n,r,i,a,o,s)=>n??Q_e(t,o===`vertical`&&s===`xAxis`||o===`horizontal`&&s===`yAxis`?rL(r,a,i):rL(a,i),e.allowDataOverflow),Pve=bD([AI,eL,tL,xve,Cve,Nve,yA,sI],fL,{memoizeOptions:{resultEqualityCheck:fI}}),Fve=[0,1],pL=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var{dataKey:s,type:c}=e,l=Pk(t,a);return l&&s==null?(0,yI.default)(0,n?.length??0):c===`category`?Tve(r,e,l):i===`expand`?Fve:o}},mL=bD([AI,yA,VI,UI,LF,sI,Pve],pL);function Ive(e){return e in xF}var hL=(e,t,n)=>{if(e!=null){var{scale:r,type:i}=e;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`){var a=`scale${LE(r)}`;return Ive(a)?a:`point`}}},gL=bD([AI,MI,zF],hL);function _L(e,t,n,r){if(!(n==null||r==null))return typeof e.scale==`function`?_I(e.scale,n,r):_I(t,n,r)}var vL=(e,t,n)=>{var r=$I(t);if(!(n!==`auto`&&n!==`linear`)){if(t!=null&&t.tickCount&&Array.isArray(r)&&(r[0]===`auto`||r[1]===`auto`)&&EF(e))return eve(e,t.tickCount,t.allowDecimals);if(t!=null&&t.tickCount&&t.type===`number`&&EF(e))return tve(e,t.tickCount,t.allowDecimals)}},yL=bD([mL,jI,gL],vL),bL=(e,t,n,r)=>{if(r!==`angleAxis`&&e?.type===`number`&&EF(t)&&Array.isArray(n)&&n.length>0){var i=t[0],a=n[0]??0,o=t[1],s=n[n.length-1]??0;return[Math.min(i,a),Math.max(o,s)]}return t},Lve=bD([AI,mL,yL,sI],bL),xL=bD(bD(UI,AI,(e,t)=>{if(!(!t||t.type!==`number`)){var n=1/0,r=Array.from(qI(e.map(e=>e.value))).sort((e,t)=>e-t),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var s=0;si,(e,t,n,r,i)=>{if(!kk(e))return 0;var a=t===`vertical`?r.height:r.width;if(i===`gap`)return e*a/2;if(i===`no-gap`){var o=ME(n,e*a),s=e*a/2;return s-o-(s-o)/a*o}return 0}),Rve=(e,t,n)=>{var r=TI(e,t);return r==null||typeof r.padding!=`string`?0:xL(e,`xAxis`,t,n,r.padding)},zve=(e,t,n)=>{var r=OI(e,t);return r==null||typeof r.padding!=`string`?0:xL(e,`yAxis`,t,n,r.padding)},Bve=bD(TI,Rve,(e,t)=>{if(e==null)return{left:0,right:0};var{padding:n}=e;return typeof n==`string`?{left:t,right:t}:{left:(n.left??0)+t,right:(n.right??0)+t}}),Vve=bD(OI,zve,(e,t)=>{if(e==null)return{top:0,bottom:0};var{padding:n}=e;return typeof n==`string`?{top:t,bottom:t}:{top:(n.top??0)+t,bottom:(n.bottom??0)+t}}),Hve=bD([$k,Bve,rA,nA,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),Uve=bD([$k,yA,Vve,rA,nA,(e,t,n)=>n],(e,t,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:t===`horizontal`?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),SL=(e,t,n,r)=>{switch(t){case`xAxis`:return Hve(e,n,r);case`yAxis`:return Uve(e,n,r);case`zAxis`:return kI(e,n)?.range;case`angleAxis`:return iI(e);case`radiusAxis`:return aI(e,n);default:return}},CL=bD([AI,SL],KF),wL=bD([AI,gL,bD([gL,Lve],vI),CL],_L);bD([II,nL,sI],Sve);function TL(e,t){return e.idt.id)}var EL=(e,t)=>t,DL=(e,t,n)=>n,Wve=bD(Jk,EL,DL,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(TL)),Gve=bD(Yk,EL,DL,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(TL)),OL=(e,t)=>({width:e.width,height:t.height}),Kve=(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height}),kL=bD($k,TI,OL),qve=(e,t,n)=>{switch(t){case`top`:return e.top;case`bottom`:return n-e.bottom;default:return 0}},Jve=(e,t,n)=>{switch(t){case`left`:return e.left;case`right`:return n-e.right;default:return 0}},Yve=bD(Kk,$k,Wve,EL,DL,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=OL(t,n);o??=qve(t,r,e);var c=r===`top`&&!i||r===`bottom`&&i;a[n.id]=o-Number(c)*s.height,o+=(c?-1:1)*s.height}),a}),Xve=bD(Gk,$k,Gve,EL,DL,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=Kve(t,n);o??=Jve(t,r,e);var c=r===`left`&&!i||r===`right`&&i;a[n.id]=o-Number(c)*s.width,o+=(c?-1:1)*s.width}),a}),Zve=bD([$k,TI,(e,t)=>{var n=TI(e,t);if(n!=null)return Yve(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),Qve=bD([$k,OI,(e,t)=>{var n=OI(e,t);if(n!=null)return Xve(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),AL=bD($k,OI,(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height})),jL=(e,t,n)=>{switch(t){case`xAxis`:return kL(e,n).width;case`yAxis`:return AL(e,n).height;default:return}},ML=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,s=Pk(e,r),c=t.map(e=>e.value);if(o&&s&&a===`category`&&i&&NE(c))return c}},NL=bD([yA,UI,AI,sI],ML),PL=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n;if(Pk(e,r)&&(i===`number`||a!==`auto`))return t.map(e=>e.value)}},FL=bD([yA,UI,jI,sI],PL),IL=bD([yA,mve,gL,wL,NL,FL,SL,yL,sI],(e,t,n,r,i,a,o,s,c)=>{if(t!=null){var l=Pk(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:l,niceTicks:s,range:o,realScaleType:n,scale:r}}}),LL=bD([yA,jI,gL,wL,yL,SL,NL,FL,sI],(e,t,n,r,i,a,o,s,c)=>{if(!(t==null||r==null)){var l=Pk(e,c),{type:u,ticks:d,tickCount:f}=t,p=n===`scaleBand`&&typeof r.bandwidth==`function`?r.bandwidth()/2:2,m=u===`category`&&r.bandwidth?r.bandwidth()/p:0;m=c===`angleAxis`&&a!=null&&a.length>=2?EE(a[0]-a[1])*2*m:m;var h=d||i;return h?h.map((e,t)=>{var n=o?o.indexOf(e):e,i=r.map(n);return kk(i)?{index:t,coordinate:i+m,value:e,offset:m}:null}).filter(RE):l&&s?s.map((e,t)=>{var n=r.map(e);return kk(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(RE):r.ticks?r.ticks(f).map((e,t)=>{var n=r.map(e);return kk(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(RE):r.domain().map((e,t)=>{var n=r.map(e);return kk(n)?{coordinate:n+m,value:o?o[e]:e,index:t,offset:m}:null}).filter(RE)}}),RL=bD([yA,jI,wL,SL,NL,FL,sI],(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var s=Pk(e,o),{tickCount:c}=t,l=0;return l=o===`angleAxis`&&r?.length>=2?EE(r[0]-r[1])*2*l:l,s&&a?a.map((e,t)=>{var r=n.map(e);return kk(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(RE):n.ticks?n.ticks(c).map((e,t)=>{var r=n.map(e);return kk(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(RE):n.domain().map((e,t)=>{var r=n.map(e);return kk(r)?{coordinate:r+l,value:i?i[e]:e,index:t,offset:l}:null}).filter(RE)}}),zL=bD(AI,wL,(e,t)=>{if(!(e==null||t==null))return xI(xI({},e),{},{scale:t})});bD((e,t,n)=>kI(e,n),bD([AI,gL,mL,CL],_L),(e,t)=>{if(!(e==null||t==null))return xI(xI({},e),{},{scale:t})});var $ve=bD([yA,Jk,Yk],(e,t,n)=>{switch(e){case`horizontal`:return t.some(e=>e.reversed)?`right-to-left`:`left-to-right`;case`vertical`:return n.some(e=>e.reversed)?`bottom-to-top`:`top-to-bottom`;case`centric`:case`radial`:return`left-to-right`;default:return}}),BL=e=>e.options.defaultTooltipEventType,VL=e=>e.options.validateTooltipEventTypes;function HL(e,t,n){if(e==null)return t;var r=e?`axis`:`item`;return n==null?t:n.includes(r)?r:t}function UL(e,t){return HL(t,BL(e),VL(e))}function eye(e){return hD(t=>UL(t,e))}var WL=(e,t)=>{var n,r=Number(t);if(!(DE(r)||t==null))return r>=0?e==null||(n=e[r])==null?void 0:n.value:void 0},tye=e=>e.tooltip.settings,GL={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},KL=ek({name:`tooltip`,initialState:{itemInteraction:{click:GL,hover:GL},axisInteraction:{click:GL,hover:GL},keyboardInteraction:GL,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:`hover`,axisId:0,active:!1,defaultIndex:void 0}},reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(sj(t.payload))},prepare:XO()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=VO(e).tooltipItemPayloads.indexOf(sj(n));i>-1&&(e.tooltipItemPayloads[i]=sj(r))},prepare:XO()},removeTooltipEntrySettings:{reducer(e,t){var n=VO(e).tooltipItemPayloads.indexOf(sj(t.payload));n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:XO()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:nye,replaceTooltipEntrySettings:rye,removeTooltipEntrySettings:iye,setTooltipSettingsState:aye,setActiveMouseOverItemIndex:qL,mouseLeaveItem:oye,mouseLeaveChart:JL,setActiveClickItemIndex:sye,setMouseOverAxisIndex:YL,setMouseClickAxisIndex:cye,setSyncInteraction:XL,setKeyboardInteraction:ZL}=KL.actions,lye=KL.reducer;function QL(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function $L(e){for(var t=1;t{if(t==null)return GL;var i=pye(e,t,n);if(i==null)return GL;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(mye(i)){if(a)return $L($L({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return $L($L({},GL),{},{coordinate:i.coordinate})};function hye(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function gye(e,t){var n=hye(e),r=t[0],i=t[1];return n===void 0?!1:n>=Math.min(r,i)&&n<=Math.max(r,i)}function _ye(e,t,n){if(n==null||t==null)return!0;var r=Nk(e,t);return r==null||!EF(n)?!0:gye(r,n)}var tR=(e,t,n,r)=>{var i=e?.index;if(i==null)return null;var a=Number(i);if(!kk(a))return i;var o=0,s=1/0;t.length>0&&(s=t.length-1);var c=Math.max(o,Math.min(a,s)),l=t[c];return l==null||_ye(l,n,r)?String(c):null},nR=(e,t,n,r,i,a,o)=>{if(a!=null){var s=o[0]?.getPosition(a);if(s!=null)return s;var c=i?.[Number(a)];if(c)switch(n){case`horizontal`:return{x:c.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:c.coordinate}}}},rR=(e,t,n,r)=>{if(t===`axis`)return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i=n===`hover`?e.itemInteraction.hover.graphicalItemId:e.itemInteraction.click.graphicalItemId;if(i==null&&r!=null){var a=e.tooltipItemPayloads[0];return a==null?[]:[a]}return e.tooltipItemPayloads.filter(e=>e.settings?.graphicalItemId===i)},iR=e=>e.options.tooltipPayloadSearcher,aR=e=>e.tooltip;function oR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sR(e){for(var t=1;t{if(!(t==null||a==null)){var{chartData:s,computedData:c,dataStartIndex:l,dataEndIndex:u}=n;return e.reduce((e,n)=>{var{dataDefinedOnItem:d,settings:f}=n,p=xye(d,s),m=Array.isArray(p)?Ok(p,l,u):p,h=f?.dataKey??r,g=f?.nameKey,_=r&&Array.isArray(m)&&!Array.isArray(m[0])&&o===`axis`?FE(m,r,i):a(m,t,c,g);return Array.isArray(_)?_.forEach(t=>{var n=sR(sR({},f),{},{name:t.name,unit:t.unit,color:void 0,fill:void 0});e.push(Uk({tooltipEntrySettings:n,dataKey:t.dataKey,payload:t.payload,value:Nk(t.payload,t.dataKey),name:t.name}))}):e.push(Uk({tooltipEntrySettings:f,dataKey:h,payload:_,value:Nk(_,h),name:Nk(_,g)??f?.name})),e},[])}},lR=bD([JI,MI,zF],hL),uR=bD([bD([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),JI,bD([mI,hI],NI)],FI,{memoizeOptions:{resultEqualityCheck:pI}}),Sye=bD([uR],e=>e.filter(dI)),dR=bD([bD([uR],zI,{memoizeOptions:{resultEqualityCheck:pI}}),SF],BI),Cye=bD([Sye,SF,JI],uI),fR=bD([dR,JI,uR],HI),pR=bD([JI],$I),mR=bD([pR,bD([JI],e=>e.allowDataOverflow)],OF),wye=bD([bD([Cye,bD([uR],e=>e.filter(dI)),LF,RF],XI),SF,mI,mR],QI),Tye=bD([dR,JI,bD([uR],RI),nL,mI],iL,{memoizeOptions:{resultEqualityCheck:fI}}),Eye=bD([bD([aL,mI,hI],oL),mI],lL),Dye=bD([bD([sL,mI,hI],oL),mI],uL),hR=bD([JI,yA,dR,fR,LF,mI,bD([JI,pR,mR,wye,Tye,bD([Eye,bD([bD([cL,mI,hI],oL),mI],dL),Dye],rL),yA,mI],fL)],pL),Oye=bD([JI,hR,bD([hR,JI,lR],vL),mI],bL),gR=e=>SL(e,mI(e),hI(e),!1),_R=bD([JI,gR],KF),vR=bD([JI,lR,Oye,_R],_L),yR=bD([yA,JI,lR,vR,gR,bD([yA,fR,JI,mI],ML),bD([yA,fR,JI,mI],PL),mI],(e,t,n,r,i,a,o,s)=>{if(t){var{type:c}=t,l=Pk(e,s);if(r){var u=n===`scaleBand`&&r.bandwidth?r.bandwidth()/2:2,d=c===`category`&&r.bandwidth?r.bandwidth()/u:0;return d=s===`angleAxis`&&i!=null&&i?.length>=2?EE(i[0]-i[1])*2*d:d,l&&o?o.map((e,t)=>{var n=r.map(e);return kk(n)?{coordinate:n+d,value:e,index:t,offset:d}:null}).filter(RE):r.domain().map((e,t)=>{var n=r.map(e);return kk(n)?{coordinate:n+d,value:a?a[e]:e,index:t,offset:d}:null}).filter(RE)}}}),bR=bD([BL,VL,tye],(e,t,n)=>HL(n.shared,e,t)),xR=e=>e.tooltip.settings.trigger,SR=e=>e.tooltip.settings.defaultIndex,CR=bD([aR,bR,xR,SR],eR),wR=bD([CR,dR,YI,hR],tR),TR=bD([yR,wR],WL),ER=bD([CR],e=>{if(e)return e.dataKey}),kye=bD([CR],e=>{if(e)return e.graphicalItemId}),DR=bD([aR,bR,xR,SR],rR),Aye=bD([CR,bD([Gk,Kk,yA,$k,yR,SR,DR],nR)],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),jye=bD([CR],e=>e?.active??!1),Mye=bD([bD([DR,wR,SF,YI,TR,iR,bR],cR)],e=>{if(e!=null){var t=e.map(e=>e.payload).filter(e=>e!=null);return Array.from(new Set(t))}});function OR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function kR(e){for(var t=1;thD(JI),Lye=()=>{var e=Iye(),t=hD(yR),n=hD(vR);return Hk(!e||!n?void 0:kR(kR({},e),{},{scale:n}),t)};function AR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function jR(e){for(var t=1;t{var i=t.find(e=>e&&e.index===n);if(i){if(e===`horizontal`)return{x:i.coordinate,y:r.chartY};if(e===`vertical`)return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},Hye=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`centric`){var a=i.coordinate,{radius:o}=r;return jR(jR(jR({},r),cM(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var s=i.coordinate,{angle:c}=r;return jR(jR(jR({},r),cM(r.cx,r.cy,s,c)),{},{angle:c,radius:s})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function Uye(e,t){var{chartX:n,chartY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var MR=(e,t,n,r,i)=>{var a=t?.length??0;if(a<=1||e==null)return 0;if(r===`angleAxis`&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var o=0;o0?n[o-1]?.coordinate:n[a-1]?.coordinate,c=n[o]?.coordinate,l=o>=a-1?n[0]?.coordinate:n[o+1]?.coordinate,u=void 0;if(!(s==null||c==null||l==null))if(EE(c-s)!==EE(l-c)){var d=[];if(EE(l-c)===EE(i[1]-i[0])){u=l;var f=c+i[1]-i[0];d[0]=Math.min(f,(f+s)/2),d[1]=Math.max(f,(f+s)/2)}else{u=s;var p=l+i[1]-i[0];d[0]=Math.min(c,(p+c)/2),d[1]=Math.max(c,(p+c)/2)}var m=[Math.min(c,(u+c)/2),Math.max(c,(u+c)/2)];if(e>m[0]&&e<=m[1]||e>=d[0]&&e<=d[1])return n[o]?.index}else{var h=Math.min(s,l),g=Math.max(s,l);if(e>(h+c)/2&&e<=(g+c)/2)return n[o]?.index}}else if(t)for(var _=0;_(v.coordinate+b.coordinate)/2||_>0&&_(v.coordinate+b.coordinate)/2&&e<=(v.coordinate+y.coordinate)/2)return v.index}}return-1},NR=()=>hD(zF),PR=(e,t)=>t,FR=(e,t,n)=>n,IR=(e,t,n,r)=>r,Wye=bD(yR,e=>(0,CD.default)(e,e=>e.coordinate)),LR=bD([aR,PR,FR,IR],eR),RR=bD([LR,dR,YI,hR],tR),Gye=(e,t,n)=>{if(t!=null){var r=aR(e);return t===`axis`?n===`hover`?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n===`hover`?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},zR=bD([aR,PR,FR,IR],rR),BR=bD([Gk,Kk,yA,$k,yR,IR,zR],nR),Kye=bD([LR,BR],(e,t)=>e.coordinate??t),VR=bD([yR,RR],WL),qye=bD([zR,RR,SF,YI,VR,iR,PR],cR),Jye=bD([LR,RR],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),Yye=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&Uye(e,o)){var s=MR(kfe(e,t),a,i,n,r),c=Vye(t,i,s,e);return{activeIndex:String(s),activeCoordinate:c}}},Xye=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var s=che(e,n);if(s){var c=MR(Afe(s,t),o,a,r,i),l=Hye(t,a,c,s);return{activeIndex:String(c),activeCoordinate:l}}}},Zye=(e,t,n,r,i,a,o,s)=>{if(!(!e||!t||!r||!i||!a))return t===`horizontal`||t===`vertical`?Yye(e,t,r,i,a,o,s):Xye(e,t,n,r,i,a,o)},Qye=bD(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),$ye=bD(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(e=>parseInt(e,10)).concat(Object.values(UF));return Array.from(new Set(t)).sort((e,t)=>e-t)},{memoizeOptions:{resultEqualityCheck:cve}});function HR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function UR(e){for(var t=1;tUR(UR({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),{})},ibe=new Set(Object.values(UF));function abe(e){return ibe.has(e)}var WR=ek({name:`zIndex`,initialState:rbe,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:XO()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(--e.zIndexMap[n].consumers,e.zIndexMap[n].consumers<=0&&!abe(n)&&delete e.zIndexMap[n])},prepare:XO()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=sj(r):e.zIndexMap[n].element=sj(r):e.zIndexMap[n]={consumers:0,element:i?void 0:sj(r),panoramaElement:i?sj(r):void 0}},prepare:XO()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:XO()}}}),{registerZIndexPortal:obe,unregisterZIndexPortal:sbe,registerZIndexPortalElement:cbe,unregisterZIndexPortalElement:lbe}=WR.actions,ube=WR.reducer;function GR(e){var{zIndex:t,children:n}=e,r=cpe()&&t!==void 0&&t!==0,i=tA(),a=pD();(0,y.useLayoutEffect)(()=>r?(a(obe({zIndex:t})),()=>{a(sbe({zIndex:t}))}):zE,[a,t,r]);var o=hD(e=>Qye(e,t,i));return r?o?(0,Op.createPortal)(n,o):null:n}function KR(){return KR=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,y.useContext)(YR),vbe=l(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!DE(n))return e[n]}},ez=ek({name:`options`,initialState:{chartName:``,tooltipPayloadSearcher:()=>void 0,eventEmitter:void 0,defaultTooltipEventType:`axis`},reducers:{createEventEmitter:e=>{e.eventEmitter??=Symbol(`rechartsEventEmitter`)}}}),ybe=ez.reducer,{createEventEmitter:bbe}=ez.actions;function xbe(e){return e.tooltip.syncInteraction}var tz=ek({name:`chartData`,initialState:{chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},reducers:{setChartData(e,t){if(e.chartData=sj(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:nz,setDataStartEndIndexes:Sbe,setComputedData:Cbe}=tz.actions,wbe=tz.reducer,Tbe=[`x`,`y`];function rz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iz(e){for(var t=1;t{if(e==null)return zE;var s=(s,c,l)=>{if(t!==l&&e===s){if(r===`index`){var u;if(o&&c!=null&&(u=c.payload)!=null&&u.coordinate&&c.payload.sourceViewBox){var d=c.payload.coordinate,{x:f,y:p}=d,m=kbe(d,Tbe),{x:h,y:g,width:_,height:v}=c.payload.sourceViewBox,y=iz(iz({},m),{},{x:o.x+(_?(f-h)/_:0)*o.width,y:o.y+(v?(p-g)/v:0)*o.height});n(iz(iz({},c),{},{payload:iz(iz({},c.payload),{},{coordinate:y})}))}else n(c);return}if(i!=null){var b;typeof r==`function`?b=i[r(i,{activeTooltipIndex:c.payload.index==null?void 0:Number(c.payload.index),isTooltipActive:c.payload.active,activeIndex:c.payload.index==null?void 0:Number(c.payload.index),activeLabel:c.payload.label,activeDataKey:c.payload.dataKey,activeCoordinate:c.payload.coordinate})]:r===`value`&&(b=i.find(e=>String(e.value)===c.payload.label));var{coordinate:x}=c.payload;if(b==null||c.payload.active===!1||x==null||o==null){n(XL({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:S,y:C}=x,w=Math.min(S,o.x+o.width),T=Math.min(C,o.y+o.height),E={x:a===`horizontal`?b.coordinate:w,y:a===`horizontal`?T:b.coordinate};n(XL({active:c.payload.active,coordinate:E,dataKey:c.payload.dataKey,index:String(b.index),label:c.payload.label,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:c.payload.graphicalItemId}))}}};return XR.on(ZR,s),()=>{XR.off(ZR,s)}},[hD(e=>e.rootProps.className),n,t,e,r,i,a,o])}function Mbe(){var e=hD(BF),t=hD(HF),n=pD();(0,y.useEffect)(()=>{if(e==null)return zE;var r=(r,i,a)=>{t!==a&&e===r&&n(Sbe(i))};return XR.on(QR,r),()=>{XR.off(QR,r)}},[n,t,e])}function Nbe(){var e=pD();(0,y.useEffect)(()=>{e(bbe())},[e]),jbe(),Mbe()}function Pbe(e,t,n,r,i,a){var o=hD(n=>Gye(n,e,t)),s=hD(HF),c=hD(BF),l=hD(VF),u=hD(xbe)?.active,d=hA();(0,y.useEffect)(()=>{if(!u&&c!=null&&s!=null){var e=XL({active:a,coordinate:n,dataKey:o,index:i,label:typeof r==`number`?String(r):r,sourceViewBox:d,graphicalItemId:void 0});XR.emit(ZR,c,e,s)}},[u,n,o,i,r,s,c,l,a,d])}function az(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oz(e){for(var t=1;t{S(aye({shared:g,trigger:_,axisId:x,active:n,defaultIndex:C}))},[S,g,_,x,n,C]);var w=hA(),T=xj(),E=eye(g),{activeIndex:D,isActive:O}=hD(e=>Jye(e,E,_,C))??{},k=hD(e=>qye(e,E,_,C)),A=hD(e=>VR(e,E,_,C)),j=hD(e=>Kye(e,E,_,C)),M=k,N=_be(),P=n??O??!1,[F,I]=ED([M,P]),L=E===`axis`?A:void 0;Pbe(E,_,j,L,D,P);var R=b??N;if(R==null||w==null||E==null)return null;var z=M??sz;P||(z=sz),s&&z.length&&(z=uD(z.filter(e=>e.value!=null&&(e.hide!==!0||t.includeHidden)),u,Rbe));var B=z.length>0,V=y.createElement(Qpe,{allowEscapeViewBox:r,animationDuration:i,animationEasing:a,isAnimationActive:c,active:P,coordinate:j,hasPayload:B,offset:l,position:d,reverseDirection:f,useTranslate3d:p,viewBox:w,wrapperStyle:m,lastBoundingBox:F,innerRef:I,hasPortalFromProps:!!b},zbe(o,oz(oz({},t),{},{payload:z,label:L,active:P,activeIndex:D,coordinate:j,accessibilityLayer:T})));return y.createElement(y.Fragment,null,(0,Op.createPortal)(V,R),P&&y.createElement(gbe,{cursor:h,tooltipEventType:E,coordinate:j,payload:z,index:D}))}var lz=e=>null;lz.displayName=`Cell`;function Vbe(e,t,n){return(t=Hbe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Hbe(e){var t=Ube(e,`string`);return typeof t==`symbol`?t:t+``}function Ube(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Wbe=class{constructor(e){Vbe(this,`cache`,new Map),this.maxSize=e}get(e){var t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};function uz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Gbe(e){for(var t=1;t{try{var n=document.getElementById(pz);n||(n=document.createElement(`span`),n.setAttribute(`id`,pz),n.setAttribute(`aria-hidden`,`true`),document.body.appendChild(n)),Object.assign(n.style,Ybe,t),n.textContent=`${e}`;var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},hz=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||Kj.isSsr)return{width:0,height:0};if(!dz.enableCache)return mz(e,t);var n=Xbe(e,t),r=fz.get(n);if(r)return r;var i=mz(e,t);return fz.set(n,i),i},gz;function Zbe(e,t,n){return(t=Qbe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qbe(e){var t=$be(e,`string`);return typeof t==`symbol`?t:t+``}function $be(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var _z=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,vz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,exe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,txe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,nxe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},rxe=[`cm`,`mm`,`pt`,`pc`,`in`,`Q`,`px`];function ixe(e){return rxe.includes(e)}var yz=`NaN`;function axe(e,t){return e*nxe[t]}var bz=class e{static parse(t){var[,n,r]=txe.exec(t)??[];return n==null?e.NaN:new e(parseFloat(n),r??``)}constructor(e,t){this.num=e,this.unit=t,this.num=e,this.unit=t,DE(e)&&(this.unit=``),t!==``&&!exe.test(t)&&(this.num=NaN,this.unit=``),ixe(t)&&(this.num=axe(e,t),this.unit=`px`)}add(t){return this.unit===t.unit?new e(this.num+t.num,this.unit):new e(NaN,``)}subtract(t){return this.unit===t.unit?new e(this.num-t.num,this.unit):new e(NaN,``)}multiply(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num/t.num,this.unit||t.unit)}toString(){return`${this.num}${this.unit}`}isNaN(){return DE(this.num)}};gz=bz,Zbe(bz,`NaN`,new gz(NaN,``));function xz(e){if(e==null||e.includes(yz))return yz;for(var t=e;t.includes(`*`)||t.includes(`/`);){var[,n,r,i]=_z.exec(t)??[],a=bz.parse(n??``),o=bz.parse(i??``),s=r===`*`?a.multiply(o):a.divide(o);if(s.isNaN())return yz;t=t.replace(_z,s.toString())}for(;t.includes(`+`)||/.-\d+(?:\.\d+)?/.test(t);){var[,c,l,u]=vz.exec(t)??[],d=bz.parse(c??``),f=bz.parse(u??``),p=l===`+`?d.add(f):d.subtract(f);if(p.isNaN())return yz;t=t.replace(vz,p.toString())}return t}var Sz=/\(([^()]*)\)/;function oxe(e){for(var t=e,n;(n=Sz.exec(t))!=null;){var[,r]=n;t=t.replace(Sz,xz(r))}return t}function sxe(e){var t=e.replace(/\s+/g,``);return t=oxe(t),t=xz(t),t}function cxe(e){try{return sxe(e)}catch{return yz}}function Cz(e){var t=cxe(e.slice(5,-1));return t===yz?``:t}var lxe=[`x`,`y`,`lineHeight`,`capHeight`,`fill`,`scaleToFit`,`textAnchor`,`verticalAnchor`],uxe=[`dx`,`dy`,`angle`,`className`,`breakAll`];function wz(){return wz=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];return IE(t)||(i=n?t.toString().split(``):t.toString().split(Ez)),{wordsWithComputedWidth:i.map(e=>({word:e,width:hz(e,r).width})),spaceWidth:n?0:hz(`\xA0`,r).width}}catch{return null}};function fxe(e){return e===`start`||e===`middle`||e===`end`||e===`inherit`}var Oz=(e,t,n,r)=>e.reduce((e,i)=>{var{word:a,width:o}=i,s=e[e.length-1];if(s&&o!=null&&(t==null||r||s.width+o+ne.reduce((e,t)=>e.width>t.width?e:t),pxe=`…`,Az=(e,t,n,r,i,a,o,s)=>{var c=Dz({breakAll:n,style:r,children:e.slice(0,t)+pxe});if(!c)return[!1,[]];var l=Oz(c.wordsWithComputedWidth,a,o,s);return[l.length>i||kz(l).width>Number(a),l]},mxe=(e,t,n,r,i)=>{var{maxLines:a,children:o,style:s,breakAll:c}=e,l=kE(a),u=String(o),d=Oz(t,r,n,i);if(!l||i||!(d.length>a||kz(d).width>Number(r)))return d;for(var f=0,p=u.length-1,m=0,h;f<=p&&m<=u.length-1;){var g=Math.floor((f+p)/2),[_,v]=Az(u,g-1,c,s,a,r,n,i),[y]=Az(u,g,c,s,a,r,n,i);if(!_&&!y&&(f=g+1),_&&y&&(p=g-1),!_&&y){h=v;break}m++}return h||d},jz=e=>[{words:IE(e)?[]:e.toString().split(Ez),width:void 0}],hxe=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=e;if((t||n)&&!Kj.isSsr){var s,c,l=Dz({breakAll:a,children:r,style:i});if(l){var{wordsWithComputedWidth:u,spaceWidth:d}=l;s=u,c=d}else return jz(r);return mxe({breakAll:a,children:r,maxLines:o,style:i},s,c,t,!!n)}return jz(r)},Mz=`#808080`,gxe={angle:0,breakAll:!1,capHeight:`0.71em`,fill:Mz,lineHeight:`1em`,scaleToFit:!1,textAnchor:`start`,verticalAnchor:`end`,x:0,y:0},Nz=(0,y.forwardRef)((e,t)=>{var n=YE(e,gxe),{x:r,y:i,lineHeight:a,capHeight:o,fill:s,scaleToFit:c,textAnchor:l,verticalAnchor:u}=n,d=Tz(n,lxe),f=(0,y.useMemo)(()=>hxe({breakAll:d.breakAll,children:d.children,maxLines:d.maxLines,scaleToFit:c,style:d.style,width:d.width}),[d.breakAll,d.children,d.maxLines,c,d.style,d.width]),{dx:p,dy:m,angle:h,className:g,breakAll:_}=d,v=Tz(d,uxe);if(!AE(r)||!AE(i)||f.length===0)return null;var b=Number(r)+(kE(p)?p:0),x=Number(i)+(kE(m)?m:0);if(!kk(b)||!kk(x))return null;var S;switch(u){case`start`:S=Cz(`calc(${o})`);break;case`middle`:S=Cz(`calc(${(f.length-1)/2} * -${a} + (${o} / 2))`);break;default:S=Cz(`calc(${f.length-1} * -${a})`);break}var C=[],w=f[0];if(c&&w!=null){var T=w.width,{width:E}=d;C.push(`scale(${kE(E)&&kE(T)?E/T:1})`)}return h&&C.push(`rotate(${h}, ${b}, ${x})`),C.length&&(v.transform=C.join(` `)),y.createElement(`text`,wz({},ST(v),{ref:t,x:b,y:x,className:gT(`recharts-text`,g),textAnchor:l,fill:s.includes(`url`)?Mz:s}),f.map((e,t)=>{var n=e.words.join(_?``:` `);return y.createElement(`tspan`,{x:b,dy:t===0?S:a,key:`${n}-${t}`},n)}))});Nz.displayName=`Text`;function Pz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fz(e){for(var t=1;t{var{viewBox:t,position:n,offset:r=0,parentViewBox:i,clamp:a}=e,{x:o,y:s,height:c,upperWidth:l,lowerWidth:u}=mA(t),d=o,f=o+(l-u)/2,p=(d+f)/2,m=(l+u)/2,h=d+l/2,g=c>=0?1:-1,_=g*r,v=g>0?`end`:`start`,y=g>0?`start`:`end`,b=l>=0?1:-1,x=b*r,S=b>0?`end`:`start`,C=b>0?`start`:`end`,w=i;if(n===`top`){var T={x:d+l/2,y:s-_,horizontalAnchor:`middle`,verticalAnchor:v};return a&&w&&(T.height=Math.max(s-w.y,0),T.width=l),T}if(n===`bottom`){var E={x:f+u/2,y:s+c+_,horizontalAnchor:`middle`,verticalAnchor:y};return a&&w&&(E.height=Math.max(w.y+w.height-(s+c),0),E.width=u),E}if(n===`left`){var D={x:p-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`};return a&&w&&(D.width=Math.max(D.x-w.x,0),D.height=c),D}if(n===`right`){var O={x:p+m+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`};return a&&w&&(O.width=Math.max(w.x+w.width-O.x,0),O.height=c),O}var k=a&&w?{width:m,height:c}:{};return n===`insideLeft`?Fz({x:p+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`},k):n===`insideRight`?Fz({x:p+m-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`},k):n===`insideTop`?Fz({x:d+l/2,y:s+_,horizontalAnchor:`middle`,verticalAnchor:y},k):n===`insideBottom`?Fz({x:f+u/2,y:s+c-_,horizontalAnchor:`middle`,verticalAnchor:v},k):n===`insideTopLeft`?Fz({x:d+x,y:s+_,horizontalAnchor:C,verticalAnchor:y},k):n===`insideTopRight`?Fz({x:d+l-x,y:s+_,horizontalAnchor:S,verticalAnchor:y},k):n===`insideBottomLeft`?Fz({x:f+x,y:s+c-_,horizontalAnchor:C,verticalAnchor:v},k):n===`insideBottomRight`?Fz({x:f+u-x,y:s+c-_,horizontalAnchor:S,verticalAnchor:v},k):n&&typeof n==`object`&&(kE(n.x)||OE(n.x))&&(kE(n.y)||OE(n.y))?Fz({x:o+ME(n.x,m),y:s+ME(n.y,c),horizontalAnchor:`end`,verticalAnchor:`end`},k):Fz({x:h,y:s+c/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},k)},xxe=[`labelRef`],Sxe=[`content`];function Iz(e,t){if(e==null)return{};var n,r,i=Cxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:s}=e,c=(0,y.useMemo)(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return y.createElement(Bz.Provider,{value:c},s)},Hz=()=>{var e=(0,y.useContext)(Bz),t=hA();return e||(t?mA(t):void 0)},Dxe=(0,y.createContext)(null),Oxe=()=>{var e=(0,y.useContext)(Dxe),t=hD(oI);return e||t},kxe=e=>{var{value:t,formatter:n}=e,r=IE(e.children)?t:e.children;return typeof n==`function`?n(r):r},Uz=e=>e!=null&&typeof e==`function`,Axe=(e,t)=>EE(t-e)*Math.min(Math.abs(t-e),360),jxe=(e,t,n,r,i)=>{var{offset:a,className:o}=e,{cx:s,cy:c,innerRadius:l,outerRadius:u,startAngle:d,endAngle:f,clockWise:p}=i,m=(l+u)/2,h=Axe(d,f),g=h>=0?1:-1,_,v;switch(t){case`insideStart`:_=d+g*a,v=p;break;case`insideEnd`:_=f-g*a,v=!p;break;case`end`:_=f+g*a,v=p;break;default:throw Error(`Unsupported position ${t}`)}v=h<=0?v:!v;var b=cM(s,c,m,_),x=cM(s,c,m,_+(v?1:-1)*359),S=`M${b.x},${b.y} + A`,`,`,`,0,0,`,`,`,`,`,`Z`]),C.x,C.y,a,a,+(u<0),S.x,S.y,r,r,+(T>180),+(u>0),y.x,y.y,a,a,+(u<0),b.x,b.y)}else v+=TE(mhe||=pM([`L`,`,`,`Z`]),t,n);return v},_he={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},gM=e=>{var t=XE(e,_he),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u,className:d}=t;if(a0&&Math.abs(l-u)<360?ghe({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(m,p/2),forceCornerRadius:s,cornerIsExternal:c,startAngle:l,endAngle:u}):hM({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:l,endAngle:u});return y.createElement(`path`,fM({},CT(t),{className:f,d:h}))};function vhe(e,t,n){if(e===`horizontal`)return[{x:t.x,y:n.top},{x:t.x,y:n.top+n.height}];if(e===`vertical`)return[{x:n.left,y:t.y},{x:n.left+n.width,y:t.y}];if(KE(t)){if(e===`centric`){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:s}=t,c=lM(r,i,a,s),l=lM(r,i,o,s);return[{x:c.x,y:c.y},{x:l.x,y:l.y}]}return dM(t)}}var yhe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=SD();function n(e){return t.isSymbol(e)?NaN:Number(e)}e.toNumber=n})),bhe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=yhe();function n(e){return e?(e=t.toNumber(e),e===1/0||e===-1/0?(e<0?-1:1)*Number.MAX_VALUE:e===e?e:0):e===0?e:0}e.toFinite=n})),xhe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=CD(),n=bhe();function r(e,r,i){i&&typeof i!=`number`&&t.isIterateeCall(e,r,i)&&(r=i=void 0),e=n.toFinite(e),r===void 0?(r=e,e=0):r=n.toFinite(r),i=i===void 0?e{t.exports=xhe().range}));function _M(e,t){return e==null||t==null?NaN:et?1:e>=t?0:NaN}function Che(e,t){return e==null||t==null?NaN:te?1:t>=e?0:NaN}function vM(e){let t,n,r;e.length===2?(t=e===_M||e===Che?e:whe,n=e,r=e):(t=_M,n=(t,n)=>_M(e(t),n),r=(t,n)=>e(t)-n);function i(e,r,i=0,a=e.length){if(i>>1;n(e[t],r)<0?i=t+1:a=t}while(i>>1;n(e[t],r)<=0?i=t+1:a=t}while(in&&r(e[o-1],t)>-r(e[o],t)?o-1:o}return{left:i,center:o,right:a}}function whe(){return 0}function yM(e){return e===null?NaN:+e}function*The(e,t){if(t===void 0)for(let t of e)t!=null&&(t=+t)>=t&&(yield t);else{let n=-1;for(let r of e)(r=t(r,++n,e))!=null&&(r=+r)>=r&&(yield r)}}var bM=vM(_M),xM=bM.right;bM.left,vM(yM).center;var SM=class extends Map{constructor(e,t=Ohe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(let[t,n]of e)this.set(t,n)}get(e){return super.get(CM(this,e))}has(e){return super.has(CM(this,e))}set(e,t){return super.set(Ehe(this,e),t)}delete(e){return super.delete(Dhe(this,e))}};function CM({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):n}function Ehe({_intern:e,_key:t},n){let r=t(n);return e.has(r)?e.get(r):(e.set(r,n),n)}function Dhe({_intern:e,_key:t},n){let r=t(n);return e.has(r)&&(n=e.get(r),e.delete(r)),n}function Ohe(e){return typeof e==`object`&&e?e.valueOf():e}function khe(e=_M){if(e===_M)return wM;if(typeof e!=`function`)throw TypeError(`compare is not a function`);return(t,n)=>{let r=e(t,n);return r||r===0?r:(e(n,n)===0)-(e(t,t)===0)}}function wM(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(et))}var Ahe=Math.sqrt(50),jhe=Math.sqrt(10),Mhe=Math.sqrt(2);function TM(e,t,n){let r=(t-e)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/10**i,o=a>=Ahe?10:a>=jhe?5:a>=Mhe?2:1,s,c,l;return i<0?(l=10**-i/o,s=Math.round(e*l),c=Math.round(t*l),s/lt&&--c,l=-l):(l=10**i*o,s=Math.round(e/l),c=Math.round(t/l),s*lt&&--c),c0))return[];if(e===t)return[e];let r=t=i))return[];let s=a-i+1,c=Array(s);if(r)if(o<0)for(let e=0;e=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n=i)&&(n=i)}return n}function AM(e,t){let n;if(t===void 0)for(let t of e)t!=null&&(n>t||n===void 0&&t>=t)&&(n=t);else{let r=-1;for(let i of e)(i=t(i,++r,e))!=null&&(n>i||n===void 0&&i>=i)&&(n=i)}return n}function jM(e,t,n=0,r=1/0,i){if(t=Math.floor(t),n=Math.floor(Math.max(0,n)),r=Math.floor(Math.min(e.length-1,r)),!(n<=t&&t<=r))return e;for(i=i===void 0?wM:khe(i);r>n;){if(r-n>600){let a=r-n+1,o=t-n+1,s=Math.log(a),c=.5*Math.exp(2*s/3),l=.5*Math.sqrt(s*c*(a-c)/a)*(o-a/2<0?-1:1),u=Math.max(n,Math.floor(t-o*c/a+l)),d=Math.min(r,Math.floor(t+(a-o)*c/a+l));jM(e,t,u,d,i)}let a=e[t],o=n,s=r;for(MM(e,n,t),i(e[r],a)>0&&MM(e,n,r);o0;)--s}i(e[n],a)===0?MM(e,n,s):(++s,MM(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}return e}function MM(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}function Nhe(e,t,n){if(e=Float64Array.from(The(e,n)),!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return AM(e);if(t>=1)return kM(e);var r,i=(r-1)*t,a=Math.floor(i),o=kM(jM(e,a).subarray(0,a+1));return o+(AM(e.subarray(a+1))-o)*(i-a)}}function Phe(e,t,n=yM){if(!(!(r=e.length)||isNaN(t=+t))){if(t<=0||r<2)return+n(e[0],0,e);if(t>=1)return+n(e[r-1],r-1,e);var r,i=(r-1)*t,a=Math.floor(i),o=+n(e[a],a,e);return o+(+n(e[a+1],a+1,e)-o)*(i-a)}}function Fhe(e,t,n){e=+e,t=+t,n=(i=arguments.length)<2?(t=e,e=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((t-e)/n))|0,a=Array(i);++r>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?QM(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?QM(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Rhe.exec(e))?new eN(t[1],t[2],t[3],1):(t=zhe.exec(e))?new eN(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Bhe.exec(e))?QM(t[1],t[2],t[3],t[4]):(t=Vhe.exec(e))?QM(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Hhe.exec(e))?oN(t[1],t[2]/100,t[3]/100,1):(t=Uhe.exec(e))?oN(t[1],t[2]/100,t[3]/100,t[4]):qM.hasOwnProperty(e)?ZM(qM[e]):e===`transparent`?new eN(NaN,NaN,NaN,0):null}function ZM(e){return new eN(e>>16&255,e>>8&255,e&255,1)}function QM(e,t,n,r){return r<=0&&(e=t=n=NaN),new eN(e,t,n,r)}function Khe(e){return e instanceof VM||(e=XM(e)),e?(e=e.rgb(),new eN(e.r,e.g,e.b,e.opacity)):new eN}function $M(e,t,n,r){return arguments.length===1?Khe(e):new eN(e,t,n,r??1)}function eN(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}zM(eN,$M,BM(VM,{brighter(e){return e=e==null?UM:UM**+e,new eN(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?HM:HM**+e,new eN(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new eN(iN(this.r),iN(this.g),iN(this.b),rN(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:tN,formatHex:tN,formatHex8:qhe,formatRgb:nN,toString:nN}));function tN(){return`#${aN(this.r)}${aN(this.g)}${aN(this.b)}`}function qhe(){return`#${aN(this.r)}${aN(this.g)}${aN(this.b)}${aN((isNaN(this.opacity)?1:this.opacity)*255)}`}function nN(){let e=rN(this.opacity);return`${e===1?`rgb(`:`rgba(`}${iN(this.r)}, ${iN(this.g)}, ${iN(this.b)}${e===1?`)`:`, ${e})`}`}function rN(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function iN(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function aN(e){return e=iN(e),(e<16?`0`:``)+e.toString(16)}function oN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new cN(e,t,n,r)}function sN(e){if(e instanceof cN)return new cN(e.h,e.s,e.l,e.opacity);if(e instanceof VM||(e=XM(e)),!e)return new cN;if(e instanceof cN)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n0&&c<1?0:o,new cN(o,s,c,e.opacity)}function Jhe(e,t,n,r){return arguments.length===1?sN(e):new cN(e,t,n,r??1)}function cN(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}zM(cN,Jhe,BM(VM,{brighter(e){return e=e==null?UM:UM**+e,new cN(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?HM:HM**+e,new cN(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new eN(dN(e>=240?e-240:e+120,i,r),dN(e,i,r),dN(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new cN(lN(this.h),uN(this.s),uN(this.l),rN(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=rN(this.opacity);return`${e===1?`hsl(`:`hsla(`}${lN(this.h)}, ${uN(this.s)*100}%, ${uN(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function lN(e){return e=(e||0)%360,e<0?e+360:e}function uN(e){return Math.max(0,Math.min(1,e||0))}function dN(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var fN=e=>()=>e;function Yhe(e,t){return function(n){return e+n*t}}function Xhe(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Zhe(e){return(e=+e)==1?pN:function(t,n){return n-t?Xhe(t,n,e):fN(isNaN(t)?n:t)}}function pN(e,t){var n=t-e;return n?Yhe(e,n):fN(isNaN(e)?t:e)}var mN=(function e(t){var n=Zhe(t);function r(e,t){var r=n((e=$M(e)).r,(t=$M(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=pN(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function Qhe(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;in&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:hN(r,i)})),n=_N.lastIndex;return nt&&(n=e,e=t,t=n),function(n){return Math.max(e,Math.min(t,n))}}function lge(e,t,n){var r=e[0],i=e[1],a=t[0],o=t[1];return i2?uge:lge,c=l=null,d}function d(i){return i==null||isNaN(i=+i)?a:(c||=s(e.map(r),t,n))(r(o(i)))}return d.invert=function(n){return o(i((l||=s(t,e.map(r),hN))(n)))},d.domain=function(t){return arguments.length?(e=Array.from(t,bN),u()):e.slice()},d.range=function(e){return arguments.length?(t=Array.from(e),u()):t.slice()},d.rangeRound=function(e){return t=Array.from(e),n=yN,u()},d.clamp=function(e){return arguments.length?(o=e?!0:SN,u()):o!==SN},d.interpolate=function(e){return arguments.length?(n=e,u()):n},d.unknown=function(e){return arguments.length?(a=e,d):a},function(e,t){return r=e,i=t,u()}}function EN(){return TN()(SN,SN)}function dge(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString(`en`).replace(/,/g,``):e.toString(10)}function DN(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf(`e`),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function ON(e){return e=DN(Math.abs(e)),e?e[1]:NaN}function fge(e,t){return function(n,r){for(var i=n.length,a=[],o=0,s=e[0],c=0;i>0&&s>0&&(c+s+1>r&&(s=Math.max(1,r-c)),a.push(n.substring(i-=s,i+s)),!((c+=s+1)>r));)s=e[o=(o+1)%e.length];return a.reverse().join(t)}}function pge(e){return function(t){return t.replace(/[0-9]/g,function(t){return e[+t]})}}var mge=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function kN(e){if(!(t=mge.exec(e)))throw Error(`invalid format: `+e);var t;return new AN({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}kN.prototype=AN.prototype;function AN(e){this.fill=e.fill===void 0?` `:e.fill+``,this.align=e.align===void 0?`>`:e.align+``,this.sign=e.sign===void 0?`-`:e.sign+``,this.symbol=e.symbol===void 0?``:e.symbol+``,this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?``:e.type+``}AN.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?`0`:``)+(this.width===void 0?``:Math.max(1,this.width|0))+(this.comma?`,`:``)+(this.precision===void 0?``:`.`+Math.max(0,this.precision|0))+(this.trim?`~`:``)+this.type};function hge(e){out:for(var t=e.length,n=1,r=-1,i;n0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(i+1):e}var jN;function gge(e,t){var n=DN(e,t);if(!n)return jN=void 0,e.toPrecision(t);var r=n[0],i=n[1],a=i-(jN=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+Array(a-o+1).join(`0`):a>0?r.slice(0,a)+`.`+r.slice(a):`0.`+Array(1-a).join(`0`)+DN(e,Math.max(0,t+a-1))[0]}function MN(e,t){var n=DN(e,t);if(!n)return e+``;var r=n[0],i=n[1];return i<0?`0.`+Array(-i).join(`0`)+r:r.length>i+1?r.slice(0,i+1)+`.`+r.slice(i+1):r+Array(i-r.length+2).join(`0`)}var NN={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+``,d:dge,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>MN(e*100,t),r:MN,s:gge,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function PN(e){return e}var FN=Array.prototype.map,IN=[`y`,`z`,`a`,`f`,`p`,`n`,`µ`,`m`,``,`k`,`M`,`G`,`T`,`P`,`E`,`Z`,`Y`];function _ge(e){var t=e.grouping===void 0||e.thousands===void 0?PN:fge(FN.call(e.grouping,Number),e.thousands+``),n=e.currency===void 0?``:e.currency[0]+``,r=e.currency===void 0?``:e.currency[1]+``,i=e.decimal===void 0?`.`:e.decimal+``,a=e.numerals===void 0?PN:pge(FN.call(e.numerals,String)),o=e.percent===void 0?`%`:e.percent+``,s=e.minus===void 0?`−`:e.minus+``,c=e.nan===void 0?`NaN`:e.nan+``;function l(e,l){e=kN(e);var u=e.fill,d=e.align,f=e.sign,p=e.symbol,m=e.zero,h=e.width,g=e.comma,_=e.precision,v=e.trim,y=e.type;y===`n`?(g=!0,y=`g`):NN[y]||(_===void 0&&(_=12),v=!0,y=`g`),(m||u===`0`&&d===`=`)&&(m=!0,u=`0`,d=`=`);var b=(l&&l.prefix!==void 0?l.prefix:``)+(p===`$`?n:p===`#`&&/[boxX]/.test(y)?`0`+y.toLowerCase():``),x=(p===`$`?r:/[%p]/.test(y)?o:``)+(l&&l.suffix!==void 0?l.suffix:``),S=NN[y],C=/[defgprs%]/.test(y);_=_===void 0?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,_)):Math.max(0,Math.min(20,_));function w(e){var n=b,r=x,o,l,p;if(y===`c`)r=S(e)+r,e=``;else{e=+e;var w=e<0||1/e<0;if(e=isNaN(e)?c:S(Math.abs(e),_),v&&(e=hge(e)),w&&+e==0&&f!==`+`&&(w=!1),n=(w?f===`(`?f:s:f===`-`||f===`(`?``:f)+n,r=(y===`s`&&!isNaN(e)&&jN!==void 0?IN[8+jN/3]:``)+r+(w&&f===`(`?`)`:``),C){for(o=-1,l=e.length;++op||p>57){r=(p===46?i+e.slice(o+1):e.slice(o))+r,e=e.slice(0,o);break}}}g&&!m&&(e=t(e,1/0));var T=n.length+e.length+r.length,E=T>1)+n+e+r+E.slice(T);break;default:e=E+n+e+r;break}return a(e)}return w.toString=function(){return e+``},w}function u(e,t){var n=Math.max(-8,Math.min(8,Math.floor(ON(t)/3)))*3,r=10**-n,i=l((e=kN(e),e.type=`f`,e),{suffix:IN[8+n/3]});return function(e){return i(r*e)}}return{format:l,formatPrefix:u}}var LN,RN,zN;vge({thousands:`,`,grouping:[3],currency:[`$`,``]});function vge(e){return LN=_ge(e),RN=LN.format,zN=LN.formatPrefix,LN}function yge(e){return Math.max(0,-ON(Math.abs(e)))}function bge(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ON(t)/3)))*3-ON(Math.abs(e)))}function xge(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,ON(t)-ON(e))+1}function BN(e,t,n,r){var i=OM(e,t,n),a;switch(r=kN(r??`,f`),r.type){case`s`:var o=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(a=bge(i,o))&&(r.precision=a),zN(r,o);case``:case`e`:case`g`:case`p`:case`r`:r.precision==null&&!isNaN(a=xge(i,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=a-(r.type===`e`));break;case`f`:case`%`:r.precision==null&&!isNaN(a=yge(i))&&(r.precision=a-(r.type===`%`)*2);break}return RN(r)}function VN(e){var t=e.domain;return e.ticks=function(e){var n=t();return EM(n[0],n[n.length-1],e??10)},e.tickFormat=function(e,n){var r=t();return BN(r[0],r[r.length-1],e??10,n)},e.nice=function(n){n??=10;var r=t(),i=0,a=r.length-1,o=r[i],s=r[a],c,l,u=10;for(s0;){if(l=DM(o,s,n),l===c)return r[i]=o,r[a]=s,t(r);if(l>0)o=Math.floor(o/l)*l,s=Math.ceil(s/l)*l;else if(l<0)o=Math.ceil(o*l)/l,s=Math.floor(s*l)/l;else break;c=l}return e},e}function HN(){var e=EN();return e.copy=function(){return wN(e,HN())},NM.apply(e,arguments),VN(e)}function UN(e){var t;function n(e){return e==null||isNaN(e=+e)?t:e}return n.invert=n,n.domain=n.range=function(t){return arguments.length?(e=Array.from(t,bN),n):e.slice()},n.unknown=function(e){return arguments.length?(t=e,n):t},n.copy=function(){return UN(e).unknown(t)},e=arguments.length?Array.from(e,bN):[0,1],VN(n)}function WN(e,t){e=e.slice();var n=0,r=e.length-1,i=e[n],a=e[r],o;return ae**+t}function Ege(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function qN(e){return(t,n)=>-e(-t,n)}function JN(e){let t=e(GN,KN),n=t.domain,r=10,i,a;function o(){return i=Ege(r),a=Tge(r),n()[0]<0?(i=qN(i),a=qN(a),e(Sge,Cge)):e(GN,KN),t}return t.base=function(e){return arguments.length?(r=+e,o()):r},t.domain=function(e){return arguments.length?(n(e),o()):n()},t.ticks=e=>{let t=n(),o=t[0],s=t[t.length-1],c=s0){for(;l<=u;++l)for(d=1;ds)break;m.push(f)}}else for(;l<=u;++l)for(d=r-1;d>=1;--d)if(f=l>0?d/a(-l):d*a(l),!(fs)break;m.push(f)}m.length*2{if(e??=10,n??=r===10?`s`:`,`,typeof n!=`function`&&(!(r%1)&&(n=kN(n)).precision==null&&(n.trim=!0),n=RN(n)),e===1/0)return n;let o=Math.max(1,r*e/t.ticks().length);return e=>{let t=e/a(Math.round(i(e)));return t*rn(WN(n(),{floor:e=>a(Math.floor(i(e))),ceil:e=>a(Math.ceil(i(e)))})),t}function YN(){let e=JN(TN()).domain([1,10]);return e.copy=()=>wN(e,YN()).base(e.base()),NM.apply(e,arguments),e}function XN(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function ZN(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function QN(e){var t=1,n=e(XN(t),ZN(t));return n.constant=function(n){return arguments.length?e(XN(t=+n),ZN(t)):t},VN(n)}function $N(){var e=QN(TN());return e.copy=function(){return wN(e,$N()).constant(e.constant())},NM.apply(e,arguments)}function eP(e){return function(t){return t<0?-((-t)**+e):t**+e}}function Dge(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function Oge(e){return e<0?-e*e:e*e}function tP(e){var t=e(SN,SN),n=1;function r(){return n===1?e(SN,SN):n===.5?e(Dge,Oge):e(eP(n),eP(1/n))}return t.exponent=function(e){return arguments.length?(n=+e,r()):n},VN(t)}function nP(){var e=tP(TN());return e.copy=function(){return wN(e,nP()).exponent(e.exponent())},NM.apply(e,arguments),e}function kge(){return nP.apply(null,arguments).exponent(.5)}function rP(e){return Math.sign(e)*e*e}function Age(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function iP(){var e=EN(),t=[0,1],n=!1,r;function i(t){var i=Age(e(t));return isNaN(i)?r:n?Math.round(i):i}return i.invert=function(t){return e.invert(rP(t))},i.domain=function(t){return arguments.length?(e.domain(t),i):e.domain()},i.range=function(n){return arguments.length?(e.range((t=Array.from(n,bN)).map(rP)),i):t.slice()},i.rangeRound=function(e){return i.range(e).round(!0)},i.round=function(e){return arguments.length?(n=!!e,i):n},i.clamp=function(t){return arguments.length?(e.clamp(t),i):e.clamp()},i.unknown=function(e){return arguments.length?(r=e,i):r},i.copy=function(){return iP(e.domain(),t).round(n).clamp(e.clamp()).unknown(r)},NM.apply(i,arguments),VN(i)}function aP(){var e=[],t=[],n=[],r;function i(){var r=0,i=Math.max(1,t.length);for(n=Array(i-1);++r0?n[i-1]:e[0],i=n?[r[n-1],t]:[r[o-1],r[o]]},o.unknown=function(e){return arguments.length&&(a=e),o},o.thresholds=function(){return r.slice()},o.copy=function(){return oP().domain([e,t]).range(i).unknown(a)},NM.apply(VN(o),arguments)}function sP(){var e=[.5],t=[0,1],n,r=1;function i(i){return i!=null&&i<=i?t[xM(e,i,0,r)]:n}return i.domain=function(n){return arguments.length?(e=Array.from(n),r=Math.min(e.length,t.length-1),i):e.slice()},i.range=function(n){return arguments.length?(t=Array.from(n),r=Math.min(e.length,t.length-1),i):t.slice()},i.invertExtent=function(n){var r=t.indexOf(n);return[e[r-1],e[r]]},i.unknown=function(e){return arguments.length?(n=e,i):n},i.copy=function(){return sP().domain(e).range(t).unknown(n)},NM.apply(i,arguments)}var cP=new Date,lP=new Date;function uP(e,t,n,r){function i(t){return e(t=arguments.length===0?new Date:new Date(+t)),t}return i.floor=t=>(e(t=new Date(+t)),t),i.ceil=n=>(e(n=new Date(n-1)),t(n,1),e(n),n),i.round=e=>{let t=i(e),n=i.ceil(e);return e-t(t(e=new Date(+e),n==null?1:Math.floor(n)),e),i.range=(n,r,a)=>{let o=[];if(n=i.ceil(n),a=a==null?1:Math.floor(a),!(n0))return o;let s;do o.push(s=new Date(+n)),t(n,a),e(n);while(suP(t=>{if(t>=t)for(;e(t),!n(t);)t.setTime(t-1)},(e,r)=>{if(e>=e)if(r<0)for(;++r<=0;)for(;t(e,-1),!n(e););else for(;--r>=0;)for(;t(e,1),!n(e););}),n&&(i.count=(t,r)=>(cP.setTime(+t),lP.setTime(+r),e(cP),e(lP),Math.floor(n(cP,lP))),i.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?i.filter(r?t=>r(t)%e===0:t=>i.count(0,t)%e===0):i)),i}var dP=uP(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);dP.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?uP(t=>{t.setTime(Math.floor(t/e)*e)},(t,n)=>{t.setTime(+t+n*e)},(t,n)=>(n-t)/e):dP),dP.range;var fP=1e3,pP=fP*60,mP=pP*60,hP=mP*24,gP=hP*7,_P=hP*30,vP=hP*365,yP=uP(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*fP)},(e,t)=>(t-e)/fP,e=>e.getUTCSeconds());yP.range;var bP=uP(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*fP)},(e,t)=>{e.setTime(+e+t*pP)},(e,t)=>(t-e)/pP,e=>e.getMinutes());bP.range;var xP=uP(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*pP)},(e,t)=>(t-e)/pP,e=>e.getUTCMinutes());xP.range;var SP=uP(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*fP-e.getMinutes()*pP)},(e,t)=>{e.setTime(+e+t*mP)},(e,t)=>(t-e)/mP,e=>e.getHours());SP.range;var CP=uP(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*mP)},(e,t)=>(t-e)/mP,e=>e.getUTCHours());CP.range;var wP=uP(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*pP)/hP,e=>e.getDate()-1);wP.range;var TP=uP(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/hP,e=>e.getUTCDate()-1);TP.range;var EP=uP(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/hP,e=>Math.floor(e/hP));EP.range;function DP(e){return uP(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(e,t)=>{e.setDate(e.getDate()+t*7)},(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*pP)/gP)}var OP=DP(0),kP=DP(1),jge=DP(2),Mge=DP(3),AP=DP(4),Nge=DP(5),Pge=DP(6);OP.range,kP.range,jge.range,Mge.range,AP.range,Nge.range,Pge.range;function jP(e){return uP(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t*7)},(e,t)=>(t-e)/gP)}var MP=jP(0),NP=jP(1),Fge=jP(2),Ige=jP(3),PP=jP(4),Lge=jP(5),Rge=jP(6);MP.range,NP.range,Fge.range,Ige.range,PP.range,Lge.range,Rge.range;var FP=uP(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());FP.range;var IP=uP(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());IP.range;var LP=uP(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());LP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:uP(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)}),LP.range;var RP=uP(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());RP.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:uP(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)}),RP.range;function zP(e,t,n,r,i,a){let o=[[yP,1,fP],[yP,5,5*fP],[yP,15,15*fP],[yP,30,30*fP],[a,1,pP],[a,5,5*pP],[a,15,15*pP],[a,30,30*pP],[i,1,mP],[i,3,3*mP],[i,6,6*mP],[i,12,12*mP],[r,1,hP],[r,2,2*hP],[n,1,gP],[t,1,_P],[t,3,3*_P],[e,1,vP]];function s(e,t,n){let r=te).right(o,i);if(a===o.length)return e.every(OM(t/vP,n/vP,r));if(a===0)return dP.every(Math.max(OM(t,n,r),1));let[s,c]=o[i/o[a-1][2]53)return null;`w`in r||(r.w=1),`Z`in r?(a=VP(HP(r.y,0,1)),o=a.getUTCDay(),a=o>4||o===0?NP.ceil(a):NP(a),a=TP.offset(a,(r.V-1)*7),r.y=a.getUTCFullYear(),r.m=a.getUTCMonth(),r.d=a.getUTCDate()+(r.w+6)%7):(a=BP(HP(r.y,0,1)),o=a.getDay(),a=o>4||o===0?kP.ceil(a):kP(a),a=wP.offset(a,(r.V-1)*7),r.y=a.getFullYear(),r.m=a.getMonth(),r.d=a.getDate()+(r.w+6)%7)}else (`W`in r||`U`in r)&&(`w`in r||(r.w=`u`in r?r.u%7:+(`W`in r)),o=`Z`in r?VP(HP(r.y,0,1)).getUTCDay():BP(HP(r.y,0,1)).getDay(),r.m=0,r.d=`W`in r?(r.w+6)%7+r.W*7-(o+5)%7:r.w+r.U*7-(o+6)%7);return`Z`in r?(r.H+=r.Z/100|0,r.M+=r.Z%100,VP(r)):BP(r)}}function w(e,t,n,r){for(var i=0,a=t.length,o=n.length,s,c;i=o)return-1;if(s=t.charCodeAt(i++),s===37){if(s=t.charAt(i++),c=x[s in Wge?t.charAt(i++):s],!c||(r=c(e,n,r))<0)return-1}else if(s!=n.charCodeAt(r++))return-1}return r}function T(e,t,n){var r=l.exec(t.slice(n));return r?(e.p=u.get(r[0].toLowerCase()),n+r[0].length):-1}function E(e,t,n){var r=p.exec(t.slice(n));return r?(e.w=m.get(r[0].toLowerCase()),n+r[0].length):-1}function D(e,t,n){var r=d.exec(t.slice(n));return r?(e.w=f.get(r[0].toLowerCase()),n+r[0].length):-1}function O(e,t,n){var r=_.exec(t.slice(n));return r?(e.m=v.get(r[0].toLowerCase()),n+r[0].length):-1}function k(e,t,n){var r=h.exec(t.slice(n));return r?(e.m=g.get(r[0].toLowerCase()),n+r[0].length):-1}function A(e,n,r){return w(e,t,n,r)}function j(e,t,r){return w(e,n,t,r)}function M(e,t,n){return w(e,r,t,n)}function N(e){return o[e.getDay()]}function P(e){return a[e.getDay()]}function F(e){return c[e.getMonth()]}function I(e){return s[e.getMonth()]}function L(e){return i[+(e.getHours()>=12)]}function R(e){return 1+~~(e.getMonth()/3)}function z(e){return o[e.getUTCDay()]}function B(e){return a[e.getUTCDay()]}function V(e){return c[e.getUTCMonth()]}function ee(e){return s[e.getUTCMonth()]}function te(e){return i[+(e.getUTCHours()>=12)]}function ne(e){return 1+~~(e.getUTCMonth()/3)}return{format:function(e){var t=S(e+=``,y);return t.toString=function(){return e},t},parse:function(e){var t=C(e+=``,!1);return t.toString=function(){return e},t},utcFormat:function(e){var t=S(e+=``,b);return t.toString=function(){return e},t},utcParse:function(e){var t=C(e+=``,!0);return t.toString=function(){return e},t}}}var Wge={"-":``,_:` `,0:`0`},UP=/^\s*\d+/,Gge=/^%/,Kge=/[\\^$*+?|[\]().{}]/g;function WP(e,t,n){var r=e<0?`-`:``,i=(r?-e:e)+``,a=i.length;return r+(a[e.toLowerCase(),t]))}function Jge(e,t,n){var r=UP.exec(t.slice(n,n+1));return r?(e.w=+r[0],n+r[0].length):-1}function Yge(e,t,n){var r=UP.exec(t.slice(n,n+1));return r?(e.u=+r[0],n+r[0].length):-1}function Xge(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.U=+r[0],n+r[0].length):-1}function Zge(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.V=+r[0],n+r[0].length):-1}function Qge(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.W=+r[0],n+r[0].length):-1}function qP(e,t,n){var r=UP.exec(t.slice(n,n+4));return r?(e.y=+r[0],n+r[0].length):-1}function JP(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function $ge(e,t,n){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(n,n+6));return r?(e.Z=r[1]?0:-(r[2]+(r[3]||`00`)),n+r[0].length):-1}function e_e(e,t,n){var r=UP.exec(t.slice(n,n+1));return r?(e.q=r[0]*3-3,n+r[0].length):-1}function t_e(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.m=r[0]-1,n+r[0].length):-1}function YP(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.d=+r[0],n+r[0].length):-1}function n_e(e,t,n){var r=UP.exec(t.slice(n,n+3));return r?(e.m=0,e.d=+r[0],n+r[0].length):-1}function XP(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.H=+r[0],n+r[0].length):-1}function r_e(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.M=+r[0],n+r[0].length):-1}function i_e(e,t,n){var r=UP.exec(t.slice(n,n+2));return r?(e.S=+r[0],n+r[0].length):-1}function a_e(e,t,n){var r=UP.exec(t.slice(n,n+3));return r?(e.L=+r[0],n+r[0].length):-1}function o_e(e,t,n){var r=UP.exec(t.slice(n,n+6));return r?(e.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function s_e(e,t,n){var r=Gge.exec(t.slice(n,n+1));return r?n+r[0].length:-1}function c_e(e,t,n){var r=UP.exec(t.slice(n));return r?(e.Q=+r[0],n+r[0].length):-1}function l_e(e,t,n){var r=UP.exec(t.slice(n));return r?(e.s=+r[0],n+r[0].length):-1}function ZP(e,t){return WP(e.getDate(),t,2)}function u_e(e,t){return WP(e.getHours(),t,2)}function d_e(e,t){return WP(e.getHours()%12||12,t,2)}function f_e(e,t){return WP(1+wP.count(LP(e),e),t,3)}function QP(e,t){return WP(e.getMilliseconds(),t,3)}function p_e(e,t){return QP(e,t)+`000`}function m_e(e,t){return WP(e.getMonth()+1,t,2)}function h_e(e,t){return WP(e.getMinutes(),t,2)}function g_e(e,t){return WP(e.getSeconds(),t,2)}function __e(e){var t=e.getDay();return t===0?7:t}function v_e(e,t){return WP(OP.count(LP(e)-1,e),t,2)}function $P(e){var t=e.getDay();return t>=4||t===0?AP(e):AP.ceil(e)}function y_e(e,t){return e=$P(e),WP(AP.count(LP(e),e)+(LP(e).getDay()===4),t,2)}function b_e(e){return e.getDay()}function x_e(e,t){return WP(kP.count(LP(e)-1,e),t,2)}function S_e(e,t){return WP(e.getFullYear()%100,t,2)}function C_e(e,t){return e=$P(e),WP(e.getFullYear()%100,t,2)}function w_e(e,t){return WP(e.getFullYear()%1e4,t,4)}function T_e(e,t){var n=e.getDay();return e=n>=4||n===0?AP(e):AP.ceil(e),WP(e.getFullYear()%1e4,t,4)}function E_e(e){var t=e.getTimezoneOffset();return(t>0?`-`:(t*=-1,`+`))+WP(t/60|0,`0`,2)+WP(t%60,`0`,2)}function eF(e,t){return WP(e.getUTCDate(),t,2)}function D_e(e,t){return WP(e.getUTCHours(),t,2)}function O_e(e,t){return WP(e.getUTCHours()%12||12,t,2)}function k_e(e,t){return WP(1+TP.count(RP(e),e),t,3)}function tF(e,t){return WP(e.getUTCMilliseconds(),t,3)}function A_e(e,t){return tF(e,t)+`000`}function j_e(e,t){return WP(e.getUTCMonth()+1,t,2)}function M_e(e,t){return WP(e.getUTCMinutes(),t,2)}function N_e(e,t){return WP(e.getUTCSeconds(),t,2)}function P_e(e){var t=e.getUTCDay();return t===0?7:t}function F_e(e,t){return WP(MP.count(RP(e)-1,e),t,2)}function nF(e){var t=e.getUTCDay();return t>=4||t===0?PP(e):PP.ceil(e)}function I_e(e,t){return e=nF(e),WP(PP.count(RP(e),e)+(RP(e).getUTCDay()===4),t,2)}function L_e(e){return e.getUTCDay()}function R_e(e,t){return WP(NP.count(RP(e)-1,e),t,2)}function z_e(e,t){return WP(e.getUTCFullYear()%100,t,2)}function B_e(e,t){return e=nF(e),WP(e.getUTCFullYear()%100,t,2)}function V_e(e,t){return WP(e.getUTCFullYear()%1e4,t,4)}function H_e(e,t){var n=e.getUTCDay();return e=n>=4||n===0?PP(e):PP.ceil(e),WP(e.getUTCFullYear()%1e4,t,4)}function U_e(){return`+0000`}function rF(){return`%`}function iF(e){return+e}function aF(e){return Math.floor(e/1e3)}var oF,sF,cF;W_e({dateTime:`%x, %X`,date:`%-m/%-d/%Y`,time:`%-I:%M:%S %p`,periods:[`AM`,`PM`],days:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],shortDays:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],months:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],shortMonths:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`]});function W_e(e){return oF=Uge(e),sF=oF.format,oF.parse,cF=oF.utcFormat,oF.utcParse,oF}function G_e(e){return new Date(e)}function K_e(e){return e instanceof Date?+e:+new Date(+e)}function lF(e,t,n,r,i,a,o,s,c,l){var u=EN(),d=u.invert,f=u.domain,p=l(`.%L`),m=l(`:%S`),h=l(`%I:%M`),g=l(`%I %p`),_=l(`%a %d`),v=l(`%b %d`),y=l(`%B`),b=l(`%Y`);function x(e){return(c(e)t(r/(e.length-1)))},n.quantiles=function(t){return Array.from({length:t+1},(n,r)=>Nhe(e,r/t))},n.copy=function(){return gF(t).domain(e)},PM.apply(n,arguments)}function _F(){var e=0,t=.5,n=1,r=1,i,a,o,s,c,l=SN,u,d=!1,f;function p(e){return isNaN(e=+e)?f:(e=.5+((e=+u(e))-a)*(r*eLM,scaleDiverging:()=>vF,scaleDivergingLog:()=>yF,scaleDivergingPow:()=>xF,scaleDivergingSqrt:()=>X_e,scaleDivergingSymlog:()=>bF,scaleIdentity:()=>UN,scaleImplicit:()=>FM,scaleLinear:()=>HN,scaleLog:()=>YN,scaleOrdinal:()=>IM,scalePoint:()=>Ihe,scalePow:()=>nP,scaleQuantile:()=>aP,scaleQuantize:()=>oP,scaleRadial:()=>iP,scaleSequential:()=>fF,scaleSequentialLog:()=>pF,scaleSequentialPow:()=>hF,scaleSequentialQuantile:()=>gF,scaleSequentialSqrt:()=>Y_e,scaleSequentialSymlog:()=>mF,scaleSqrt:()=>kge,scaleSymlog:()=>$N,scaleThreshold:()=>sP,scaleTime:()=>q_e,scaleUtc:()=>J_e,tickFormat:()=>BN}),CF=e=>e.chartData,wF=xD([CF],e=>{var t=e.chartData==null?0:e.chartData.length-1;return{chartData:e.chartData,computedData:e.computedData,dataEndIndex:t,dataStartIndex:0}}),TF=(e,t,n,r)=>r?wF(e):CF(e),EF=(e,t,n)=>n?wF(e):CF(e);function DF(e){if(Array.isArray(e)&&e.length===2){var[t,n]=e;if(Ak(t)&&Ak(n))return!0}return!1}function OF(e,t,n){return n?e:[Math.min(e[0],t[0]),Math.max(e[1],t[1])]}function kF(e,t){if(t&&typeof e!=`function`&&Array.isArray(e)&&e.length===2){var[n,r]=e,i,a;if(Ak(n))i=n;else if(typeof n==`function`)return;if(Ak(r))a=r;else if(typeof r==`function`)return;var o=[i,a];if(DF(o))return o}}function Z_e(e,t,n){if(!(!n&&t==null)){if(typeof e==`function`&&t!=null)try{var r=e(t,n);if(DF(r))return OF(r,t,n)}catch{}if(Array.isArray(e)&&e.length===2){var[i,a]=e,o,s;if(i===`auto`)t!=null&&(o=Math.min(...t));else if(AE(i))o=i;else if(typeof i==`function`)try{t!=null&&(o=i(t?.[0]))}catch{}else if(typeof i==`string`&&Vk.test(i)){var c=Vk.exec(i);if(c==null||c[1]==null||t==null)o=void 0;else{var l=+c[1];o=t[0]-l}}else o=t?.[0];if(a===`auto`)t!=null&&(s=Math.max(...t));else if(AE(a))s=a;else if(typeof a==`function`)try{t!=null&&(s=a(t?.[1]))}catch{}else if(typeof a==`string`&&Hk.test(a)){var u=Hk.exec(a);if(u==null||u[1]==null||t==null)s=void 0;else{var d=+u[1];s=t[1]+d}}else s=t?.[1];var f=[o,s];if(DF(f))return t==null?f:OF(f,t,n)}}}var AF=l(o(((e,t)=>{(function(e){var n=1e9,r={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:`2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286`},i=!0,a=`[DecimalError] `,o=a+`Invalid argument: `,s=a+`Exponent out of range: `,c=Math.floor,l=Math.pow,u=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,d,f=1e7,p=7,m=9007199254740991,h=c(m/p),g={};g.absoluteValue=g.abs=function(){var e=new this.constructor(this);return e.s&&=1,e},g.comparedTo=g.cmp=function(e){var t,n,r,i,a=this;if(e=new a.constructor(e),a.s!==e.s)return a.s||-e.s;if(a.e!==e.e)return a.e>e.e^a.s<0?1:-1;for(r=a.d.length,i=e.d.length,t=0,n=re.d[t]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1},g.decimalPlaces=g.dp=function(){var e=this,t=e.d.length-1,n=(t-e.e)*p;if(t=e.d[t],t)for(;t%10==0;t/=10)n--;return n<0?0:n},g.dividedBy=g.div=function(e){return b(this,new this.constructor(e))},g.dividedToIntegerBy=g.idiv=function(e){var t=this,n=t.constructor;return D(b(t,new n(e),0,1),n.precision)},g.equals=g.eq=function(e){return!this.cmp(e)},g.exponent=function(){return S(this)},g.greaterThan=g.gt=function(e){return this.cmp(e)>0},g.greaterThanOrEqualTo=g.gte=function(e){return this.cmp(e)>=0},g.isInteger=g.isint=function(){return this.e>this.d.length-2},g.isNegative=g.isneg=function(){return this.s<0},g.isPositive=g.ispos=function(){return this.s>0},g.isZero=function(){return this.s===0},g.lessThan=g.lt=function(e){return this.cmp(e)<0},g.lessThanOrEqualTo=g.lte=function(e){return this.cmp(e)<1},g.logarithm=g.log=function(e){var t,n=this,r=n.constructor,o=r.precision,s=o+5;if(e===void 0)e=new r(10);else if(e=new r(e),e.s<1||e.eq(d))throw Error(a+`NaN`);if(n.s<1)throw Error(a+(n.s?`NaN`:`-Infinity`));return n.eq(d)?new r(0):(i=!1,t=b(T(n,s),T(e,s),s),i=!0,D(t,o))},g.minus=g.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?O(t,e):_(t,(e.s=-e.s,e))},g.modulo=g.mod=function(e){var t,n=this,r=n.constructor,o=r.precision;if(e=new r(e),!e.s)throw Error(a+`NaN`);return n.s?(i=!1,t=b(n,e,0,1).times(e),i=!0,n.minus(t)):D(new r(n),o)},g.naturalExponential=g.exp=function(){return x(this)},g.naturalLogarithm=g.ln=function(){return T(this)},g.negated=g.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e},g.plus=g.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?_(t,e):O(t,(e.s=-e.s,e))},g.precision=g.sd=function(e){var t,n,r,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(o+e);if(t=S(i)+1,r=i.d.length-1,n=r*p+1,r=i.d[r],r){for(;r%10==0;r/=10)n--;for(r=i.d[0];r>=10;r/=10)n++}return e&&t>n?t:n},g.squareRoot=g.sqrt=function(){var e,t,n,r,o,s,l,u=this,d=u.constructor;if(u.s<1){if(!u.s)return new d(0);throw Error(a+`NaN`)}for(e=S(u),i=!1,o=Math.sqrt(+u),o==0||o==1/0?(t=y(u.d),(t.length+e)%2==0&&(t+=`0`),o=Math.sqrt(t),e=c((e+1)/2)-(e<0||e%2),o==1/0?t=`5e`+e:(t=o.toExponential(),t=t.slice(0,t.indexOf(`e`)+1)+e),r=new d(t)):r=new d(o.toString()),n=d.precision,o=l=n+3;;)if(s=r,r=s.plus(b(u,s,l+2)).times(.5),y(s.d).slice(0,l)===(t=y(r.d)).slice(0,l)){if(t=t.slice(l-3,l+1),o==l&&t==`4999`){if(D(s,n+1,0),s.times(s).eq(u)){r=s;break}}else if(t!=`9999`)break;l+=4}return i=!0,D(r,n)},g.times=g.mul=function(e){var t,n,r,a,o,s,c,l,u,d=this,p=d.constructor,m=d.d,h=(e=new p(e)).d;if(!d.s||!e.s)return new p(0);for(e.s*=d.s,n=d.e+e.e,l=m.length,u=h.length,l=0;){for(t=0,a=l+r;a>r;)c=o[a]+h[r]*m[a-r-1]+t,o[a--]=c%f|0,t=c/f|0;o[a]=(o[a]+t)%f|0}for(;!o[--s];)o.pop();return t?++n:o.shift(),e.d=o,e.e=n,i?D(e,p.precision):e},g.toDecimalPlaces=g.todp=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(v(e,0,n),t===void 0?t=i.rounding:v(t,0,8),D(r,e+S(r)+1,t))},g.toExponential=function(e,t){var r,i=this,a=i.constructor;return e===void 0?r=k(i,!0):(v(e,0,n),t===void 0?t=a.rounding:v(t,0,8),i=D(new a(i),e+1,t),r=k(i,!0,e+1)),r},g.toFixed=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?k(a):(v(e,0,n),t===void 0?t=o.rounding:v(t,0,8),i=D(new o(a),e+S(a)+1,t),r=k(i.abs(),!1,e+S(i)+1),a.isneg()&&!a.isZero()?`-`+r:r)},g.toInteger=g.toint=function(){var e=this,t=e.constructor;return D(new t(e),S(e)+1,t.rounding)},g.toNumber=function(){return+this},g.toPower=g.pow=function(e){var t,n,r,o,s,l,u=this,f=u.constructor,h=12,g=+(e=new f(e));if(!e.s)return new f(d);if(u=new f(u),!u.s){if(e.s<1)throw Error(a+`Infinity`);return u}if(u.eq(d))return u;if(r=f.precision,e.eq(d))return D(u,r);if(t=e.e,n=e.d.length-1,l=t>=n,s=u.s,!l){if(s<0)throw Error(a+`NaN`)}else if((n=g<0?-g:g)<=m){for(o=new f(d),t=Math.ceil(r/p+4),i=!1;n%2&&(o=o.times(u),A(o.d,t)),n=c(n/2),n!==0;)u=u.times(u),A(u.d,t);return i=!0,e.s<0?new f(d).div(o):D(o,r)}return s=s<0&&e.d[Math.max(t,n)]&1?-1:1,u.s=1,i=!1,o=e.times(T(u,r+h)),i=!0,o=x(o),o.s=s,o},g.toPrecision=function(e,t){var r,i,a=this,o=a.constructor;return e===void 0?(r=S(a),i=k(a,r<=o.toExpNeg||r>=o.toExpPos)):(v(e,1,n),t===void 0?t=o.rounding:v(t,0,8),a=D(new o(a),e,t),r=S(a),i=k(a,e<=r||r<=o.toExpNeg,e)),i},g.toSignificantDigits=g.tosd=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(v(e,1,n),t===void 0?t=i.rounding:v(t,0,8)),D(new i(r),e,t)},g.toString=g.valueOf=g.val=g.toJSON=function(){var e=this,t=S(e),n=e.constructor;return k(e,t<=n.toExpNeg||t>=n.toExpPos)};function _(e,t){var n,r,a,o,s,c,l,u,d=e.constructor,m=d.precision;if(!e.s||!t.s)return t.s||(t=new d(e)),i?D(t,m):t;if(l=e.d,u=t.d,s=e.e,a=t.e,l=l.slice(),o=s-a,o){for(o<0?(r=l,o=-o,c=u.length):(r=u,a=s,c=l.length),s=Math.ceil(m/p),c=s>c?s+1:c+1,o>c&&(o=c,r.length=1),r.reverse();o--;)r.push(0);r.reverse()}for(c=l.length,o=u.length,c-o<0&&(o=c,r=u,u=l,l=r),n=0;o;)n=(l[--o]=l[o]+u[o]+n)/f|0,l[o]%=f;for(n&&(l.unshift(n),++a),c=l.length;l[--c]==0;)l.pop();return t.d=l,t.e=a,i?D(t,m):t}function v(e,t,n){if(e!==~~e||en)throw Error(o+e)}function y(e){var t,n,r,i=e.length-1,a=``,o=e[0];if(i>0){for(a+=o,t=1;tr?1:-1;else for(i=a=0;it[i]?1:-1;break}return a}function n(e,t,n){for(var r=0;n--;)e[n]-=r,r=+(e[n]1;)e.shift()}return function(r,i,o,s){var c,l,u,d,m,h,g,_,v,y,b,x,C,w,T,E,O,k,A=r.constructor,j=r.s==i.s?1:-1,M=r.d,N=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(a+`Division by zero`);for(l=r.e-i.e,O=N.length,T=M.length,g=new A(j),_=g.d=[],u=0;N[u]==(M[u]||0);)++u;if(N[u]>(M[u]||0)&&--l,x=o==null?o=A.precision:s?o+(S(r)-S(i))+1:o,x<0)return new A(0);if(x=x/p+2|0,u=0,O==1)for(d=0,N=N[0],x++;(u1&&(N=e(N,d),M=e(M,d),O=N.length,T=M.length),w=O,v=M.slice(0,O),y=v.length;y=f/2&&++E;do d=0,c=t(N,v,O,y),c<0?(b=v[0],O!=y&&(b=b*f+(v[1]||0)),d=b/E|0,d>1?(d>=f&&(d=f-1),m=e(N,d),h=m.length,y=v.length,c=t(m,v,h,y),c==1&&(d--,n(m,O16)throw Error(s+S(e));if(!e.s)return new m(d);for(t==null?(i=!1,u=h):u=t,c=new m(.03125);e.abs().gte(.1);)e=e.times(c),p+=5;for(r=Math.log(l(2,p))/Math.LN10*2+5|0,u+=r,n=a=o=new m(d),m.precision=u;;){if(a=D(a.times(e),u),n=n.times(++f),c=o.plus(b(a,n,u)),y(c.d).slice(0,u)===y(o.d).slice(0,u)){for(;p--;)o=D(o.times(o),u);return m.precision=h,t==null?(i=!0,D(o,h)):o}o=c}}function S(e){for(var t=e.e*p,n=e.d[0];n>=10;n/=10)t++;return t}function C(e,t,n){if(t>e.LN10.sd())throw i=!0,n&&(e.precision=n),Error(a+`LN10 precision limit exceeded`);return D(new e(e.LN10),t)}function w(e){for(var t=``;e--;)t+=`0`;return t}function T(e,t){var n,r,o,s,c,l,u,f,p,m=1,h=10,g=e,_=g.d,v=g.constructor,x=v.precision;if(g.s<1)throw Error(a+(g.s?`NaN`:`-Infinity`));if(g.eq(d))return new v(0);if(t==null?(i=!1,f=x):f=t,g.eq(10))return t??(i=!0),C(v,f);if(f+=h,v.precision=f,n=y(_),r=n.charAt(0),s=S(g),Math.abs(s)<0x5543df729c000){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)g=g.times(e),n=y(g.d),r=n.charAt(0),m++;s=S(g),r>1?(g=new v(`0.`+n),s++):g=new v(r+`.`+n.slice(1))}else return u=C(v,f+2,x).times(s+``),g=T(new v(r+`.`+n.slice(1)),f-h).plus(u),v.precision=x,t==null?(i=!0,D(g,x)):g;for(l=c=g=b(g.minus(d),g.plus(d),f),p=D(g.times(g),f),o=3;;){if(c=D(c.times(p),f),u=l.plus(b(c,new v(o),f)),y(u.d).slice(0,f)===y(l.d).slice(0,f))return l=l.times(2),s!==0&&(l=l.plus(C(v,f+2,x).times(s+``))),l=b(l,new v(m),f),v.precision=x,t==null?(i=!0,D(l,x)):l;l=u,o+=2}}function E(e,t){var n,r,a;for((n=t.indexOf(`.`))>-1&&(t=t.replace(`.`,``)),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length),r=0;t.charCodeAt(r)===48;)++r;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(r,a),t){if(a-=r,n=n-r-1,e.e=c(n/p),e.d=[],r=(n+1)%p,n<0&&(r+=p),rh||e.e<-h))throw Error(s+n)}else e.s=0,e.e=0,e.d=[0];return e}function D(e,t,n){var r,a,o,u,d,m,g,_,v=e.d;for(u=1,o=v[0];o>=10;o/=10)u++;if(r=t-u,r<0)r+=p,a=t,g=v[_=0];else{if(_=Math.ceil((r+1)/p),o=v.length,_>=o)return e;for(g=o=v[_],u=1;o>=10;o/=10)u++;r%=p,a=r-p+u}if(n!==void 0&&(o=l(10,u-a-1),d=g/o%10|0,m=t<0||v[_+1]!==void 0||g%o,m=n<4?(d||m)&&(n==0||n==(e.s<0?3:2)):d>5||d==5&&(n==4||m||n==6&&(r>0?a>0?g/l(10,u-a):0:v[_-1])%10&1||n==(e.s<0?8:7))),t<1||!v[0])return m?(o=S(e),v.length=1,t=t-o-1,v[0]=l(10,(p-t%p)%p),e.e=c(-t/p)||0):(v.length=1,v[0]=e.e=e.s=0),e;if(r==0?(v.length=_,o=1,_--):(v.length=_+1,o=l(10,p-r),v[_]=a>0?(g/l(10,u-a)%l(10,a)|0)*o:0),m)for(;;)if(_==0){(v[0]+=o)==f&&(v[0]=1,++e.e);break}else{if(v[_]+=o,v[_]!=f)break;v[_--]=0,o=1}for(r=v.length;v[--r]===0;)v.pop();if(i&&(e.e>h||e.e<-h))throw Error(s+S(e));return e}function O(e,t){var n,r,a,o,s,c,l,u,d,m,h=e.constructor,g=h.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new h(e),i?D(t,g):t;if(l=e.d,m=t.d,r=t.e,u=e.e,l=l.slice(),s=u-r,s){for(d=s<0,d?(n=l,s=-s,c=m.length):(n=m,r=u,c=l.length),a=Math.max(Math.ceil(g/p),c)+2,s>a&&(s=a,n.length=1),n.reverse(),a=s;a--;)n.push(0);n.reverse()}else{for(a=l.length,c=m.length,d=a0;--a)l[c++]=0;for(a=m.length;a>s;){if(l[--a]0?a=a.charAt(0)+`.`+a.slice(1)+w(r):o>1&&(a=a.charAt(0)+`.`+a.slice(1)),a=a+(i<0?`e`:`e+`)+i):i<0?(a=`0.`+w(-i-1)+a,n&&(r=n-o)>0&&(a+=w(r))):i>=o?(a+=w(i+1-o),n&&(r=n-i-1)>0&&(a=a+`.`+w(r))):((r=i+1)0&&(i+1===o&&(a+=`.`),a+=w(r))),e.s<0?`-`+a:a}function A(e,t){if(e.length>t)return e.length=t,!0}function j(e){var t,n,r;function i(e){var t=this;if(!(t instanceof i))return new i(e);if(t.constructor=i,e instanceof i){t.s=e.s,t.e=e.e,t.d=(e=e.d)?e.slice():e;return}if(typeof e==`number`){if(e*0!=0)throw Error(o+e);if(e>0)t.s=1;else if(e<0)e=-e,t.s=-1;else{t.s=0,t.e=0,t.d=[0];return}if(e===~~e&&e<1e7){t.e=0,t.d=[e];return}return E(t,e.toString())}else if(typeof e!=`string`)throw Error(o+e);if(e.charCodeAt(0)===45?(e=e.slice(1),t.s=-1):t.s=1,u.test(e))E(t,e);else throw Error(o+e)}if(i.prototype=g,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.clone=j,i.config=i.set=M,e===void 0&&(e={}),e)for(r=[`precision`,`rounding`,`toExpNeg`,`toExpPos`,`LN10`],t=0;t=s[t+1]&&i<=s[t+2])this[r]=i;else throw Error(o+r+`: `+i);if((i=e[r=`LN10`])!==void 0)if(i==Math.LN10)this[r]=new this(i);else throw Error(o+r+`: `+i);return this}r=j(r),r.default=r.Decimal=r,d=new r(1),typeof define==`function`&&define.amd?define(function(){return r}):t!==void 0&&t.exports?t.exports=r:(e||=typeof self<`u`&&self&&self.self==self?self:Function(`return this`)(),e.Decimal=r)})(e)}))());function jF(e){return e===0?1:Math.floor(new AF.default(e).abs().log(10).toNumber())+1}function MF(e,t,n){for(var r=new AF.default(e),i=0,a=[];r.lt(t)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var NF=e=>{var[t,n]=e,[r,i]=[t,n];return t>n&&([r,i]=[n,t]),[r,i]},PF=(e,t,n)=>{if(e.lte(0))return new AF.default(0);var r=jF(e.toNumber()),i=new AF.default(10).pow(r),a=e.div(i),o=r===1?.1:.05,s=new AF.default(Math.ceil(a.div(o).toNumber())).add(n).mul(o).mul(i);return t?new AF.default(s.toNumber()):new AF.default(Math.ceil(s.toNumber()))},Q_e=(e,t,n)=>{var r=new AF.default(1),i=new AF.default(e);if(!i.isint()&&n){var a=Math.abs(e);a<1?(r=new AF.default(10).pow(jF(e)-1),i=new AF.default(Math.floor(i.div(r).toNumber())).mul(r)):a>1&&(i=new AF.default(Math.floor(e)))}else e===0?i=new AF.default(Math.floor((t-1)/2)):n||(i=new AF.default(Math.floor(e)));for(var o=Math.floor((t-1)/2),s=[],c=0;c4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(n-1)))return{step:new AF.default(0),tickMin:new AF.default(0),tickMax:new AF.default(0)};var a=PF(new AF.default(t).sub(e).div(n-1),r,i),o;e<=0&&t>=0?o=new AF.default(0):(o=new AF.default(e).add(t).div(2),o=o.sub(new AF.default(o).mod(a)));var s=Math.ceil(o.sub(e).div(a).toNumber()),c=Math.ceil(new AF.default(t).sub(o).div(a).toNumber()),l=s+c+1;return l>n?FF(e,t,n,r,i+1):(l0?c+(n-l):c,s=t>0?s:s+(n-l)),{step:a,tickMin:o.sub(new AF.default(s).mul(a)),tickMax:o.add(new AF.default(c).mul(a))})},$_e=function(e){var[t,n]=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,a=Math.max(r,2),[o,s]=NF([t,n]);if(o===-1/0||s===1/0){var c=s===1/0?[o,...Array(r-1).fill(1/0)]:[...Array(r-1).fill(-1/0),s];return t>n?c.reverse():c}if(o===s)return Q_e(o,r,i);var{step:l,tickMin:u,tickMax:d}=FF(o,s,a,i,0),f=MF(u,d.add(new AF.default(.1).mul(l)),l);return t>n?f.reverse():f},eve=function(e,t){var[n,r]=e,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[a,o]=NF([n,r]);if(a===-1/0||o===1/0)return[n,r];if(a===o)return[a];var s=Math.max(t,2),c=PF(new AF.default(o).sub(a).div(s-1),i,0),l=[...MF(new AF.default(a),new AF.default(o),c),o];return i===!1&&(l=l.map(e=>Math.round(e))),n>r?l.reverse():l},IF=e=>e.rootProps.maxBarSize,tve=e=>e.rootProps.barGap,LF=e=>e.rootProps.barCategoryGap,nve=e=>e.rootProps.barSize,RF=e=>e.rootProps.stackOffset,zF=e=>e.rootProps.reverseStackOrder,BF=e=>e.options.chartName,VF=e=>e.rootProps.syncId,HF=e=>e.rootProps.syncMethod,UF=e=>e.options.eventEmitter,rve=e=>e.rootProps.baseValue,WF={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},GF={allowDecimals:!1,allowDuplicatedCategory:!0,allowDataOverflow:!1,angle:0,angleAxisId:0,axisLine:!0,axisLineType:`polygon`,cx:0,cy:0,hide:!1,includeHidden:!1,label:!1,orientation:`outer`,reversed:!1,scale:`auto`,tick:!0,tickLine:!0,tickSize:8,type:`auto`,zIndex:WF.axis},KF={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!0,angle:0,axisLine:!0,includeHidden:!1,hide:!1,label:!1,orientation:`right`,radiusAxisId:0,reversed:!1,scale:`auto`,stroke:`#ccc`,tick:!0,tickCount:5,tickLine:!0,type:`auto`,zIndex:WF.axis},qF=(e,t)=>{if(!(!e||!t))return e!=null&&e.reversed?[t[1],t[0]]:t};function JF(e,t,n){if(n!==`auto`)return n;if(e!=null)return Fk(e,t)?`category`:`number`}function YF(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function XF(e){for(var t=1;t{if(t!=null)return e.polarAxis.angleAxis[t]},CA],(e,t)=>{if(e!=null)return e;var n=JF(t,`angleAxis`,ZF.type)??`category`;return XF(XF({},ZF),{},{type:n})}),eI=xD([(e,t)=>e.polarAxis.radiusAxis[t],CA],(e,t)=>{if(e!=null)return e;var n=JF(t,`radiusAxis`,QF.type)??`category`;return XF(XF({},QF),{},{type:n})}),tI=e=>e.polarOptions,nI=xD([Kk,qk,eA],uM),rI=xD([tI,nI],(e,t)=>{if(e!=null)return NE(e.innerRadius,t,0)}),iI=xD([tI,nI],(e,t)=>{if(e!=null)return NE(e.outerRadius,t,t*.8)}),aI=xD([tI],e=>{if(e==null)return[0,0];var{startAngle:t,endAngle:n}=e;return[t,n]});xD([$F,aI],qF);var oI=xD([nI,rI,iI],(e,t,n)=>{if(!(e==null||t==null||n==null))return[t,n]});xD([eI,oI],qF);var sI=xD([bA,tI,rI,iI,Kk,qk],(e,t,n,r,i,a)=>{if(!(e!==`centric`&&e!==`radial`||t==null||n==null||r==null)){var{cx:o,cy:s,startAngle:c,endAngle:l}=t;return{cx:NE(o,i,i/2),cy:NE(s,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:l,clockWise:!1}}}),cI=(e,t)=>t,lI=(e,t,n)=>n;function uI(e){return e?.id}function dI(e,t,n){var{chartData:r=[]}=t,{allowDuplicatedCategory:i,dataKey:a}=n,o=new Map;return e.forEach(e=>{var t=e.data??r;if(!(t==null||t.length===0)){var n=uI(e);t.forEach((t,r)=>{var s=a==null||i?r:String(Pk(t,a,null)),c=Pk(t,e.dataKey,0),l=o.has(s)?o.get(s):{};Object.assign(l,{[n]:c}),o.set(s,l)})}}),Array.from(o.values())}function fI(e){return`stackId`in e&&e.stackId!=null&&e.dataKey!=null}var pI=(e,t)=>e===t?!0:e==null||t==null?!1:e[0]===t[0]&&e[1]===t[1];function mI(e,t){return Array.isArray(e)&&Array.isArray(t)&&e.length===0&&t.length===0?!0:e===t}function sve(e,t){if(e.length===t.length){for(var n=0;n{var t=bA(e);return t===`horizontal`?`xAxis`:t===`vertical`?`yAxis`:t===`centric`?`angleAxis`:`radiusAxis`},gI=e=>e.tooltip.settings.axisId;function cve(e){if(e in SF)return SF[e]();var t=`scale${RE(e)}`;if(t in SF)return SF[t]()}function _I(e){var t=e.ticks,n=e.bandwidth,r=e.range(),i=[Math.min(...r),Math.max(...r)];return{domain:()=>e.domain(),range:function(e){function t(){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(()=>i),rangeMin:()=>i[0],rangeMax:()=>i[1],isInRange(e){var t=i[0],n=i[1];return t<=n?e>=t&&e<=n:e>=n&&e<=t},bandwidth:n?()=>n.call(e):void 0,ticks:t?n=>t.call(e,n):void 0,map:(t,n)=>{var r=e(t);if(r!=null){if(e.bandwidth&&n!=null&&n.position){var i=e.bandwidth();switch(n.position){case`middle`:r+=i/2;break;case`end`:r+=i;break;default:break}}return r}}}}function vI(e,t,n){if(typeof e==`function`)return _I(e.copy().domain(t).range(n));if(e!=null){var r=cve(e);if(r!=null)return r.domain(t).range(n),_I(r)}}var yI=(e,t)=>{if(t!=null)switch(e){case`linear`:if(!DF(t)){for(var n,r,i=0;ir)&&(r=a))}return n!==void 0&&r!==void 0?[n,r]:void 0}return t;default:return t}},bI=l(She());function xI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function SI(e){for(var t=1;te.cartesianAxis.xAxis[t],EI=(e,t)=>TI(e,t)??wI,DI={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:CI,hide:!0,id:0,includeHidden:!1,interval:`preserveEnd`,minTickGap:5,mirror:!1,name:void 0,orientation:`left`,padding:{top:0,bottom:0},reversed:!1,scale:`auto`,tick:!0,tickCount:5,tickFormatter:void 0,ticks:void 0,type:`number`,unit:void 0,width:60},OI=(e,t)=>e.cartesianAxis.yAxis[t],kI=(e,t)=>OI(e,t)??DI,fve={domain:[0,`auto`],includeHidden:!1,reversed:!1,allowDataOverflow:!1,allowDuplicatedCategory:!1,dataKey:void 0,id:0,name:``,range:[64,64],scale:`auto`,type:`number`,unit:``},AI=(e,t)=>e.cartesianAxis.zAxis[t]??fve,jI=(e,t,n)=>{switch(t){case`xAxis`:return EI(e,n);case`yAxis`:return kI(e,n);case`zAxis`:return AI(e,n);case`angleAxis`:return $F(e,n);case`radiusAxis`:return eI(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},pve=(e,t,n)=>{switch(t){case`xAxis`:return EI(e,n);case`yAxis`:return kI(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},MI=(e,t,n)=>{switch(t){case`xAxis`:return EI(e,n);case`yAxis`:return kI(e,n);case`angleAxis`:return $F(e,n);case`radiusAxis`:return eI(e,n);default:throw Error(`Unexpected axis type: ${t}`)}},NI=e=>e.graphicalItems.cartesianItems.some(e=>e.type===`bar`)||e.graphicalItems.polarItems.some(e=>e.type===`radialBar`);function PI(e,t){return n=>{switch(e){case`xAxis`:return`xAxisId`in n&&n.xAxisId===t;case`yAxis`:return`yAxisId`in n&&n.yAxisId===t;case`zAxis`:return`zAxisId`in n&&n.zAxisId===t;case`angleAxis`:return`angleAxisId`in n&&n.angleAxisId===t;case`radiusAxis`:return`radiusAxisId`in n&&n.radiusAxisId===t;default:return!1}}}var FI=e=>e.graphicalItems.cartesianItems,mve=xD([cI,lI],PI),II=(e,t,n)=>e.filter(n).filter(e=>t?.includeHidden===!0?!0:!e.hide),LI=xD([FI,jI,mve],II,{memoizeOptions:{resultEqualityCheck:mI}}),RI=xD([LI],e=>e.filter(e=>e.type===`area`||e.type===`bar`).filter(fI)),zI=e=>e.filter(e=>!(`stackId`in e)||e.stackId===void 0),hve=xD([LI],zI),BI=e=>e.map(e=>e.data).filter(Boolean).flat(1),gve=xD([LI],BI,{memoizeOptions:{resultEqualityCheck:mI}}),VI=(e,t)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=t;return e.length>0?e:n.slice(r,i+1)},HI=xD([gve,TF],VI),UI=(e,t,n)=>t?.dataKey==null?n.length>0?n.map(e=>e.dataKey).flatMap(t=>e.map(e=>({value:Pk(e,t)}))):e.map(e=>({value:e})):e.map(e=>({value:Pk(e,t.dataKey)})),WI=xD([HI,jI,LI],UI);function GI(e,t){switch(e){case`xAxis`:return t.direction===`x`;case`yAxis`:return t.direction===`y`;default:return!1}}function KI(e){if(jE(e)||e instanceof Date){var t=Number(e);if(Ak(t))return t}}function qI(e){if(Array.isArray(e)){var t=[KI(e[0]),KI(e[1])];return DF(t)?t:void 0}var n=KI(e);if(n!=null)return[n,n]}function JI(e){return e.map(KI).filter(zE)}function _ve(e,t,n){return!n||typeof t!=`number`||OE(t)||!n.length?[]:JI(n.flatMap(n=>{var r=Pk(e,n.dataKey),i,a;if(Array.isArray(r)?[i,a]=r:i=a=r,!(!Ak(i)||!Ak(a)))return[t-i,t+a]}))}var YI=e=>MI(e,hI(e),gI(e)),XI=xD([YI],e=>e?.dataKey),vve=xD([RI,TF,YI],dI),ZI=(e,t,n,r)=>{var i=t.reduce((e,t)=>{if(t.stackId==null)return e;var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},{});return Object.fromEntries(Object.entries(i).map(t=>{var[i,a]=t,o=r?[...a].reverse():a;return[i,{stackedData:Cfe(e,o.map(uI),n),graphicalItems:o}]}))},QI=xD([vve,RI,RF,zF],ZI),$I=(e,t,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=t;if(r==null&&n!==`zAxis`){var o=Dfe(e,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},yve=xD([jI],e=>e.allowDataOverflow),eL=e=>{if(e==null||!(`domain`in e))return CI;if(e.domain!=null)return e.domain;if(`ticks`in e&&e.ticks!=null){if(e.type===`number`){var t=JI(e.ticks);return[Math.min(...t),Math.max(...t)]}if(e.type===`category`)return e.ticks.map(String)}return e?.domain??CI},tL=xD([jI],eL),nL=xD([tL,yve],kF),bve=xD([QI,CF,cI,nL],$I,{memoizeOptions:{resultEqualityCheck:pI}}),rL=e=>e.errorBars,xve=(e,t,n)=>e.flatMap(e=>t[e.id]).filter(Boolean).filter(e=>GI(n,e)),iL=function(){var e=[...arguments].filter(Boolean);if(e.length!==0){var t=e.flat();return[Math.min(...t),Math.max(...t)]}},aL=(e,t,n,r,i)=>{var a,o;if(n.length>0&&e.forEach(e=>{n.forEach(n=>{var s=r[n.id]?.filter(e=>GI(i,e)),c=Pk(e,t.dataKey??n.dataKey),l=_ve(e,c,s);if(l.length>=2){var u=Math.min(...l),d=Math.max(...l);(a==null||uo)&&(o=d)}var f=qI(c);f!=null&&(a=a==null?f[0]:Math.min(a,f[0]),o=o==null?f[1]:Math.max(o,f[1]))})}),t?.dataKey!=null&&e.forEach(e=>{var n=qI(Pk(e,t.dataKey));n!=null&&(a=a==null?n[0]:Math.min(a,n[0]),o=o==null?n[1]:Math.max(o,n[1]))}),Ak(a)&&Ak(o))return[a,o]},Sve=xD([HI,jI,hve,rL,cI],aL,{memoizeOptions:{resultEqualityCheck:pI}});function Cve(e){var{value:t}=e;if(jE(t)||t instanceof Date)return t}var wve=(e,t,n)=>{var r=e.map(Cve).filter(e=>e!=null);return n&&(t.dataKey==null||t.allowDuplicatedCategory&&PE(r))?(0,bI.default)(0,e.length):t.allowDuplicatedCategory?r:Array.from(new Set(r))},oL=e=>e.referenceElements.dots,sL=(e,t,n)=>e.filter(e=>e.ifOverflow===`extendDomain`).filter(e=>t===`xAxis`?e.xAxisId===n:e.yAxisId===n),Tve=xD([oL,cI,lI],sL),cL=e=>e.referenceElements.areas,Eve=xD([cL,cI,lI],sL),lL=e=>e.referenceElements.lines,Dve=xD([lL,cI,lI],sL),uL=(e,t)=>{if(e!=null){var n=JI(e.map(e=>t===`xAxis`?e.x:e.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Ove=xD(Tve,cI,uL),dL=(e,t)=>{if(e!=null){var n=JI(e.flatMap(e=>[t===`xAxis`?e.x1:e.y1,t===`xAxis`?e.x2:e.y2]));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},kve=xD([Eve,cI],dL);function Ave(e){if(e.x!=null)return JI([e.x]);var t=e.segment?.map(e=>e.x);return t==null||t.length===0?[]:JI(t)}function jve(e){if(e.y!=null)return JI([e.y]);var t=e.segment?.map(e=>e.y);return t==null||t.length===0?[]:JI(t)}var fL=(e,t)=>{if(e!=null){var n=e.flatMap(e=>t===`xAxis`?Ave(e):jve(e));if(n.length!==0)return[Math.min(...n),Math.max(...n)]}},Mve=xD(Ove,xD([Dve,cI],fL),kve,(e,t,n)=>iL(e,n,t)),pL=(e,t,n,r,i,a,o,s)=>n??Z_e(t,o===`vertical`&&s===`xAxis`||o===`horizontal`&&s===`yAxis`?iL(r,a,i):iL(a,i),e.allowDataOverflow),Nve=xD([jI,tL,nL,bve,Sve,Mve,bA,cI],pL,{memoizeOptions:{resultEqualityCheck:pI}}),Pve=[0,1],mL=(e,t,n,r,i,a,o)=>{if(!((e==null||n==null||n.length===0)&&o===void 0)){var{dataKey:s,type:c}=e,l=Fk(t,a);return l&&s==null?(0,bI.default)(0,n?.length??0):c===`category`?wve(r,e,l):i===`expand`?Pve:o}},hL=xD([jI,bA,HI,WI,RF,cI,Nve],mL);function Fve(e){return e in SF}var gL=(e,t,n)=>{if(e!=null){var{scale:r,type:i}=e;if(r===`auto`)return i===`category`&&n&&(n.indexOf(`LineChart`)>=0||n.indexOf(`AreaChart`)>=0||n.indexOf(`ComposedChart`)>=0&&!t)?`point`:i===`category`?`band`:`linear`;if(typeof r==`string`){var a=`scale${RE(r)}`;return Fve(a)?a:`point`}}},_L=xD([jI,NI,BF],gL);function vL(e,t,n,r){if(!(n==null||r==null))return typeof e.scale==`function`?vI(e.scale,n,r):vI(t,n,r)}var yL=(e,t,n)=>{var r=eL(t);if(!(n!==`auto`&&n!==`linear`)){if(t!=null&&t.tickCount&&Array.isArray(r)&&(r[0]===`auto`||r[1]===`auto`)&&DF(e))return $_e(e,t.tickCount,t.allowDecimals);if(t!=null&&t.tickCount&&t.type===`number`&&DF(e))return eve(e,t.tickCount,t.allowDecimals)}},bL=xD([hL,MI,_L],yL),xL=(e,t,n,r)=>{if(r!==`angleAxis`&&e?.type===`number`&&DF(t)&&Array.isArray(n)&&n.length>0){var i=t[0],a=n[0]??0,o=t[1],s=n[n.length-1]??0;return[Math.min(i,a),Math.max(o,s)]}return t},Ive=xD([jI,hL,bL,cI],xL),SL=xD(xD(WI,jI,(e,t)=>{if(!(!t||t.type!==`number`)){var n=1/0,r=Array.from(JI(e.map(e=>e.value))).sort((e,t)=>e-t),i=r[0],a=r[r.length-1];if(i==null||a==null)return 1/0;var o=a-i;if(o===0)return 1/0;for(var s=0;si,(e,t,n,r,i)=>{if(!Ak(e))return 0;var a=t===`vertical`?r.height:r.width;if(i===`gap`)return e*a/2;if(i===`no-gap`){var o=NE(n,e*a),s=e*a/2;return s-o-(s-o)/a*o}return 0}),Lve=(e,t,n)=>{var r=EI(e,t);return r==null||typeof r.padding!=`string`?0:SL(e,`xAxis`,t,n,r.padding)},Rve=(e,t,n)=>{var r=kI(e,t);return r==null||typeof r.padding!=`string`?0:SL(e,`yAxis`,t,n,r.padding)},zve=xD(EI,Lve,(e,t)=>{if(e==null)return{left:0,right:0};var{padding:n}=e;return typeof n==`string`?{left:t,right:t}:{left:(n.left??0)+t,right:(n.right??0)+t}}),Bve=xD(kI,Rve,(e,t)=>{if(e==null)return{top:0,bottom:0};var{padding:n}=e;return typeof n==`string`?{top:t,bottom:t}:{top:(n.top??0)+t,bottom:(n.bottom??0)+t}}),Vve=xD([eA,zve,iA,rA,(e,t,n)=>n],(e,t,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[e.left+t.left,e.left+e.width-t.right]}),Hve=xD([eA,bA,Bve,iA,rA,(e,t,n)=>n],(e,t,n,r,i,a)=>{var{padding:o}=i;return a?[r.height-o.bottom,o.top]:t===`horizontal`?[e.top+e.height-n.bottom,e.top+n.top]:[e.top+n.top,e.top+e.height-n.bottom]}),CL=(e,t,n,r)=>{switch(t){case`xAxis`:return Vve(e,n,r);case`yAxis`:return Hve(e,n,r);case`zAxis`:return AI(e,n)?.range;case`angleAxis`:return aI(e);case`radiusAxis`:return oI(e,n);default:return}},wL=xD([jI,CL],qF),TL=xD([jI,_L,xD([_L,Ive],yI),wL],vL);xD([LI,rL,cI],xve);function EL(e,t){return e.idt.id)}var DL=(e,t)=>t,OL=(e,t,n)=>n,Uve=xD(Yk,DL,OL,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(EL)),Wve=xD(Xk,DL,OL,(e,t,n)=>e.filter(e=>e.orientation===t).filter(e=>e.mirror===n).sort(EL)),kL=(e,t)=>({width:e.width,height:t.height}),Gve=(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height}),AL=xD(eA,EI,kL),Kve=(e,t,n)=>{switch(t){case`top`:return e.top;case`bottom`:return n-e.bottom;default:return 0}},qve=(e,t,n)=>{switch(t){case`left`:return e.left;case`right`:return n-e.right;default:return 0}},Jve=xD(qk,eA,Uve,DL,OL,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=kL(t,n);o??=Kve(t,r,e);var c=r===`top`&&!i||r===`bottom`&&i;a[n.id]=o-Number(c)*s.height,o+=(c?-1:1)*s.height}),a}),Yve=xD(Kk,eA,Wve,DL,OL,(e,t,n,r,i)=>{var a={},o;return n.forEach(n=>{var s=Gve(t,n);o??=qve(t,r,e);var c=r===`left`&&!i||r===`right`&&i;a[n.id]=o-Number(c)*s.width,o+=(c?-1:1)*s.width}),a}),Xve=xD([eA,EI,(e,t)=>{var n=EI(e,t);if(n!=null)return Jve(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:e.left,y:0}:{x:e.left,y:i}}}),Zve=xD([eA,kI,(e,t)=>{var n=kI(e,t);if(n!=null)return Yve(e,n.orientation,n.mirror)},(e,t)=>t],(e,t,n,r)=>{if(t!=null){var i=n?.[r];return i==null?{x:0,y:e.top}:{x:i,y:e.top}}}),jL=xD(eA,kI,(e,t)=>({width:typeof t.width==`number`?t.width:60,height:e.height})),ML=(e,t,n)=>{switch(t){case`xAxis`:return AL(e,n).width;case`yAxis`:return jL(e,n).height;default:return}},NL=(e,t,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,s=Fk(e,r),c=t.map(e=>e.value);if(o&&s&&a===`category`&&i&&PE(c))return c}},PL=xD([bA,WI,jI,cI],NL),FL=(e,t,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n;if(Fk(e,r)&&(i===`number`||a!==`auto`))return t.map(e=>e.value)}},IL=xD([bA,WI,MI,cI],FL),LL=xD([bA,pve,_L,TL,PL,IL,CL,bL,cI],(e,t,n,r,i,a,o,s,c)=>{if(t!=null){var l=Fk(e,c);return{angle:t.angle,interval:t.interval,minTickGap:t.minTickGap,orientation:t.orientation,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:l,niceTicks:s,range:o,realScaleType:n,scale:r}}}),RL=xD([bA,MI,_L,TL,bL,CL,PL,IL,cI],(e,t,n,r,i,a,o,s,c)=>{if(!(t==null||r==null)){var l=Fk(e,c),{type:u,ticks:d,tickCount:f}=t,p=n===`scaleBand`&&typeof r.bandwidth==`function`?r.bandwidth()/2:2,m=u===`category`&&r.bandwidth?r.bandwidth()/p:0;m=c===`angleAxis`&&a!=null&&a.length>=2?DE(a[0]-a[1])*2*m:m;var h=d||i;return h?h.map((e,t)=>{var n=o?o.indexOf(e):e,i=r.map(n);return Ak(i)?{index:t,coordinate:i+m,value:e,offset:m}:null}).filter(zE):l&&s?s.map((e,t)=>{var n=r.map(e);return Ak(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(zE):r.ticks?r.ticks(f).map((e,t)=>{var n=r.map(e);return Ak(n)?{coordinate:n+m,value:e,index:t,offset:m}:null}).filter(zE):r.domain().map((e,t)=>{var n=r.map(e);return Ak(n)?{coordinate:n+m,value:o?o[e]:e,index:t,offset:m}:null}).filter(zE)}}),zL=xD([bA,MI,TL,CL,PL,IL,cI],(e,t,n,r,i,a,o)=>{if(!(t==null||n==null||r==null||r[0]===r[1])){var s=Fk(e,o),{tickCount:c}=t,l=0;return l=o===`angleAxis`&&r?.length>=2?DE(r[0]-r[1])*2*l:l,s&&a?a.map((e,t)=>{var r=n.map(e);return Ak(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(zE):n.ticks?n.ticks(c).map((e,t)=>{var r=n.map(e);return Ak(r)?{coordinate:r+l,value:e,index:t,offset:l}:null}).filter(zE):n.domain().map((e,t)=>{var r=n.map(e);return Ak(r)?{coordinate:r+l,value:i?i[e]:e,index:t,offset:l}:null}).filter(zE)}}),BL=xD(jI,TL,(e,t)=>{if(!(e==null||t==null))return SI(SI({},e),{},{scale:t})});xD((e,t,n)=>AI(e,n),xD([jI,_L,hL,wL],vL),(e,t)=>{if(!(e==null||t==null))return SI(SI({},e),{},{scale:t})});var Qve=xD([bA,Yk,Xk],(e,t,n)=>{switch(e){case`horizontal`:return t.some(e=>e.reversed)?`right-to-left`:`left-to-right`;case`vertical`:return n.some(e=>e.reversed)?`bottom-to-top`:`top-to-bottom`;case`centric`:case`radial`:return`left-to-right`;default:return}}),VL=e=>e.options.defaultTooltipEventType,HL=e=>e.options.validateTooltipEventTypes;function UL(e,t,n){if(e==null)return t;var r=e?`axis`:`item`;return n==null?t:n.includes(r)?r:t}function WL(e,t){return UL(t,VL(e),HL(e))}function $ve(e){return gD(t=>WL(t,e))}var GL=(e,t)=>{var n,r=Number(t);if(!(OE(r)||t==null))return r>=0?e==null||(n=e[r])==null?void 0:n.value:void 0},eye=e=>e.tooltip.settings,KL={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},qL=tk({name:`tooltip`,initialState:{itemInteraction:{click:KL,hover:KL},axisInteraction:{click:KL,hover:KL},keyboardInteraction:KL,syncInteraction:{active:!1,index:null,dataKey:void 0,label:void 0,coordinate:void 0,sourceViewBox:void 0,graphicalItemId:void 0},tooltipItemPayloads:[],settings:{shared:void 0,trigger:`hover`,axisId:0,active:!1,defaultIndex:void 0}},reducers:{addTooltipEntrySettings:{reducer(e,t){e.tooltipItemPayloads.push(cj(t.payload))},prepare:ZO()},replaceTooltipEntrySettings:{reducer(e,t){var{prev:n,next:r}=t.payload,i=HO(e).tooltipItemPayloads.indexOf(cj(n));i>-1&&(e.tooltipItemPayloads[i]=cj(r))},prepare:ZO()},removeTooltipEntrySettings:{reducer(e,t){var n=HO(e).tooltipItemPayloads.indexOf(cj(t.payload));n>-1&&e.tooltipItemPayloads.splice(n,1)},prepare:ZO()},setTooltipSettingsState(e,t){e.settings=t.payload},setActiveMouseOverItemIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.itemInteraction.hover.active=!0,e.itemInteraction.hover.index=t.payload.activeIndex,e.itemInteraction.hover.dataKey=t.payload.activeDataKey,e.itemInteraction.hover.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.hover.coordinate=t.payload.activeCoordinate},mouseLeaveChart(e){e.itemInteraction.hover.active=!1,e.axisInteraction.hover.active=!1},mouseLeaveItem(e){e.itemInteraction.hover.active=!1},setActiveClickItemIndex(e,t){e.syncInteraction.active=!1,e.itemInteraction.click.active=!0,e.keyboardInteraction.active=!1,e.itemInteraction.click.index=t.payload.activeIndex,e.itemInteraction.click.dataKey=t.payload.activeDataKey,e.itemInteraction.click.graphicalItemId=t.payload.activeGraphicalItemId,e.itemInteraction.click.coordinate=t.payload.activeCoordinate},setMouseOverAxisIndex(e,t){e.syncInteraction.active=!1,e.axisInteraction.hover.active=!0,e.keyboardInteraction.active=!1,e.axisInteraction.hover.index=t.payload.activeIndex,e.axisInteraction.hover.dataKey=t.payload.activeDataKey,e.axisInteraction.hover.coordinate=t.payload.activeCoordinate},setMouseClickAxisIndex(e,t){e.syncInteraction.active=!1,e.keyboardInteraction.active=!1,e.axisInteraction.click.active=!0,e.axisInteraction.click.index=t.payload.activeIndex,e.axisInteraction.click.dataKey=t.payload.activeDataKey,e.axisInteraction.click.coordinate=t.payload.activeCoordinate},setSyncInteraction(e,t){e.syncInteraction=t.payload},setKeyboardInteraction(e,t){e.keyboardInteraction.active=t.payload.active,e.keyboardInteraction.index=t.payload.activeIndex,e.keyboardInteraction.coordinate=t.payload.activeCoordinate}}}),{addTooltipEntrySettings:tye,replaceTooltipEntrySettings:nye,removeTooltipEntrySettings:rye,setTooltipSettingsState:iye,setActiveMouseOverItemIndex:JL,mouseLeaveItem:aye,mouseLeaveChart:YL,setActiveClickItemIndex:oye,setMouseOverAxisIndex:XL,setMouseClickAxisIndex:sye,setSyncInteraction:ZL,setKeyboardInteraction:QL}=qL.actions,cye=qL.reducer;function $L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function eR(e){for(var t=1;t{if(t==null)return KL;var i=fye(e,t,n);if(i==null)return KL;if(i.active)return i;if(e.keyboardInteraction.active)return e.keyboardInteraction;if(e.syncInteraction.active&&e.syncInteraction.index!=null)return e.syncInteraction;var a=e.settings.active===!0;if(pye(i)){if(a)return eR(eR({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return eR(eR({},KL),{},{coordinate:i.coordinate})};function mye(e){if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(e instanceof Date){var t=e.valueOf();return Number.isFinite(t)?t:void 0}var n=Number(e);return Number.isFinite(n)?n:void 0}function hye(e,t){var n=mye(e),r=t[0],i=t[1];return n===void 0?!1:n>=Math.min(r,i)&&n<=Math.max(r,i)}function gye(e,t,n){if(n==null||t==null)return!0;var r=Pk(e,t);return r==null||!DF(n)?!0:hye(r,n)}var nR=(e,t,n,r)=>{var i=e?.index;if(i==null)return null;var a=Number(i);if(!Ak(a))return i;var o=0,s=1/0;t.length>0&&(s=t.length-1);var c=Math.max(o,Math.min(a,s)),l=t[c];return l==null||gye(l,n,r)?String(c):null},rR=(e,t,n,r,i,a,o)=>{if(a!=null){var s=o[0]?.getPosition(a);if(s!=null)return s;var c=i?.[Number(a)];if(c)switch(n){case`horizontal`:return{x:c.coordinate,y:(r.top+t)/2};default:return{x:(r.left+e)/2,y:c.coordinate}}}},iR=(e,t,n,r)=>{if(t===`axis`)return e.tooltipItemPayloads;if(e.tooltipItemPayloads.length===0)return[];var i=n===`hover`?e.itemInteraction.hover.graphicalItemId:e.itemInteraction.click.graphicalItemId;if(i==null&&r!=null){var a=e.tooltipItemPayloads[0];return a==null?[]:[a]}return e.tooltipItemPayloads.filter(e=>e.settings?.graphicalItemId===i)},aR=e=>e.options.tooltipPayloadSearcher,oR=e=>e.tooltip;function sR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cR(e){for(var t=1;t{if(!(t==null||a==null)){var{chartData:s,computedData:c,dataStartIndex:l,dataEndIndex:u}=n;return e.reduce((e,n)=>{var{dataDefinedOnItem:d,settings:f}=n,p=bye(d,s),m=Array.isArray(p)?kk(p,l,u):p,h=f?.dataKey??r,g=f?.nameKey,_=r&&Array.isArray(m)&&!Array.isArray(m[0])&&o===`axis`?IE(m,r,i):a(m,t,c,g);return Array.isArray(_)?_.forEach(t=>{var n=cR(cR({},f),{},{name:t.name,unit:t.unit,color:void 0,fill:void 0});e.push(Wk({tooltipEntrySettings:n,dataKey:t.dataKey,payload:t.payload,value:Pk(t.payload,t.dataKey),name:t.name}))}):e.push(Wk({tooltipEntrySettings:f,dataKey:h,payload:_,value:Pk(_,h),name:Pk(_,g)??f?.name})),e},[])}},uR=xD([YI,NI,BF],gL),dR=xD([xD([e=>e.graphicalItems.cartesianItems,e=>e.graphicalItems.polarItems],(e,t)=>[...e,...t]),YI,xD([hI,gI],PI)],II,{memoizeOptions:{resultEqualityCheck:mI}}),xye=xD([dR],e=>e.filter(fI)),fR=xD([xD([dR],BI,{memoizeOptions:{resultEqualityCheck:mI}}),CF],VI),Sye=xD([xye,CF,YI],dI),pR=xD([fR,YI,dR],UI),mR=xD([YI],eL),hR=xD([mR,xD([YI],e=>e.allowDataOverflow)],kF),Cye=xD([xD([Sye,xD([dR],e=>e.filter(fI)),RF,zF],ZI),CF,hI,hR],$I),wye=xD([fR,YI,xD([dR],zI),rL,hI],aL,{memoizeOptions:{resultEqualityCheck:pI}}),Tye=xD([xD([oL,hI,gI],sL),hI],uL),Eye=xD([xD([cL,hI,gI],sL),hI],dL),gR=xD([YI,bA,fR,pR,RF,hI,xD([YI,mR,hR,Cye,wye,xD([Tye,xD([xD([lL,hI,gI],sL),hI],fL),Eye],iL),bA,hI],pL)],mL),Dye=xD([YI,gR,xD([gR,YI,uR],yL),hI],xL),_R=e=>CL(e,hI(e),gI(e),!1),vR=xD([YI,_R],qF),yR=xD([YI,uR,Dye,vR],vL),bR=xD([bA,YI,uR,yR,_R,xD([bA,pR,YI,hI],NL),xD([bA,pR,YI,hI],FL),hI],(e,t,n,r,i,a,o,s)=>{if(t){var{type:c}=t,l=Fk(e,s);if(r){var u=n===`scaleBand`&&r.bandwidth?r.bandwidth()/2:2,d=c===`category`&&r.bandwidth?r.bandwidth()/u:0;return d=s===`angleAxis`&&i!=null&&i?.length>=2?DE(i[0]-i[1])*2*d:d,l&&o?o.map((e,t)=>{var n=r.map(e);return Ak(n)?{coordinate:n+d,value:e,index:t,offset:d}:null}).filter(zE):r.domain().map((e,t)=>{var n=r.map(e);return Ak(n)?{coordinate:n+d,value:a?a[e]:e,index:t,offset:d}:null}).filter(zE)}}}),xR=xD([VL,HL,eye],(e,t,n)=>UL(n.shared,e,t)),SR=e=>e.tooltip.settings.trigger,CR=e=>e.tooltip.settings.defaultIndex,wR=xD([oR,xR,SR,CR],tR),TR=xD([wR,fR,XI,gR],nR),ER=xD([bR,TR],GL),DR=xD([wR],e=>{if(e)return e.dataKey}),Oye=xD([wR],e=>{if(e)return e.graphicalItemId}),OR=xD([oR,xR,SR,CR],iR),kye=xD([wR,xD([Kk,qk,bA,eA,bR,CR,OR],rR)],(e,t)=>e!=null&&e.coordinate?e.coordinate:t),Aye=xD([wR],e=>e?.active??!1),jye=xD([xD([OR,TR,CF,XI,ER,aR,xR],lR)],e=>{if(e!=null){var t=e.map(e=>e.payload).filter(e=>e!=null);return Array.from(new Set(t))}});function kR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function AR(e){for(var t=1;tgD(YI),Iye=()=>{var e=Fye(),t=gD(bR),n=gD(yR);return Uk(!e||!n?void 0:AR(AR({},e),{},{scale:n}),t)};function jR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function MR(e){for(var t=1;t{var i=t.find(e=>e&&e.index===n);if(i){if(e===`horizontal`)return{x:i.coordinate,y:r.chartY};if(e===`vertical`)return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},Vye=(e,t,n,r)=>{var i=t.find(e=>e&&e.index===n);if(i){if(e===`centric`){var a=i.coordinate,{radius:o}=r;return MR(MR(MR({},r),lM(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var s=i.coordinate,{angle:c}=r;return MR(MR(MR({},r),lM(r.cx,r.cy,s,c)),{},{angle:c,radius:s})}return{angle:0,clockWise:!1,cx:0,cy:0,endAngle:0,innerRadius:0,outerRadius:0,radius:0,startAngle:0,x:0,y:0}};function Hye(e,t){var{chartX:n,chartY:r}=e;return n>=t.left&&n<=t.left+t.width&&r>=t.top&&r<=t.top+t.height}var NR=(e,t,n,r,i)=>{var a=t?.length??0;if(a<=1||e==null)return 0;if(r===`angleAxis`&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var o=0;o0?n[o-1]?.coordinate:n[a-1]?.coordinate,c=n[o]?.coordinate,l=o>=a-1?n[0]?.coordinate:n[o+1]?.coordinate,u=void 0;if(!(s==null||c==null||l==null))if(DE(c-s)!==DE(l-c)){var d=[];if(DE(l-c)===DE(i[1]-i[0])){u=l;var f=c+i[1]-i[0];d[0]=Math.min(f,(f+s)/2),d[1]=Math.max(f,(f+s)/2)}else{u=s;var p=l+i[1]-i[0];d[0]=Math.min(c,(p+c)/2),d[1]=Math.max(c,(p+c)/2)}var m=[Math.min(c,(u+c)/2),Math.max(c,(u+c)/2)];if(e>m[0]&&e<=m[1]||e>=d[0]&&e<=d[1])return n[o]?.index}else{var h=Math.min(s,l),g=Math.max(s,l);if(e>(h+c)/2&&e<=(g+c)/2)return n[o]?.index}}else if(t)for(var _=0;_(v.coordinate+b.coordinate)/2||_>0&&_(v.coordinate+b.coordinate)/2&&e<=(v.coordinate+y.coordinate)/2)return v.index}}return-1},PR=()=>gD(BF),FR=(e,t)=>t,IR=(e,t,n)=>n,LR=(e,t,n,r)=>r,Uye=xD(bR,e=>(0,wD.default)(e,e=>e.coordinate)),RR=xD([oR,FR,IR,LR],tR),zR=xD([RR,fR,XI,gR],nR),Wye=(e,t,n)=>{if(t!=null){var r=oR(e);return t===`axis`?n===`hover`?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n===`hover`?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},BR=xD([oR,FR,IR,LR],iR),VR=xD([Kk,qk,bA,eA,bR,LR,BR],rR),Gye=xD([RR,VR],(e,t)=>e.coordinate??t),HR=xD([bR,zR],GL),Kye=xD([BR,zR,CF,XI,HR,aR,FR],lR),qye=xD([RR,zR],(e,t)=>({isActive:e.active&&t!=null,activeIndex:t})),Jye=(e,t,n,r,i,a,o)=>{if(!(!e||!n||!r||!i)&&Hye(e,o)){var s=NR(Ofe(e,t),a,i,n,r),c=Bye(t,i,s,e);return{activeIndex:String(s),activeCoordinate:c}}},Yye=(e,t,n,r,i,a,o)=>{if(!(!e||!r||!i||!a||!n)){var s=she(e,n);if(s){var c=NR(kfe(s,t),o,a,r,i),l=Vye(t,a,c,s);return{activeIndex:String(c),activeCoordinate:l}}}},Xye=(e,t,n,r,i,a,o,s)=>{if(!(!e||!t||!r||!i||!a))return t===`horizontal`||t===`vertical`?Jye(e,t,r,i,a,o,s):Yye(e,t,n,r,i,a,o)},Zye=xD(e=>e.zIndex.zIndexMap,(e,t)=>t,(e,t,n)=>n,(e,t,n)=>{if(t!=null){var r=e[t];if(r!=null)return n?r.panoramaElement:r.element}}),Qye=xD(e=>e.zIndex.zIndexMap,e=>{var t=Object.keys(e).map(e=>parseInt(e,10)).concat(Object.values(WF));return Array.from(new Set(t)).sort((e,t)=>e-t)},{memoizeOptions:{resultEqualityCheck:sve}});function UR(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function WR(e){for(var t=1;tWR(WR({},e),{},{[t]:{element:void 0,panoramaElement:void 0,consumers:0}}),{})},rbe=new Set(Object.values(WF));function ibe(e){return rbe.has(e)}var GR=tk({name:`zIndex`,initialState:nbe,reducers:{registerZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]?e.zIndexMap[n].consumers+=1:e.zIndexMap[n]={consumers:1,element:void 0,panoramaElement:void 0}},prepare:ZO()},unregisterZIndexPortal:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(--e.zIndexMap[n].consumers,e.zIndexMap[n].consumers<=0&&!ibe(n)&&delete e.zIndexMap[n])},prepare:ZO()},registerZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n,element:r,isPanorama:i}=t.payload;e.zIndexMap[n]?i?e.zIndexMap[n].panoramaElement=cj(r):e.zIndexMap[n].element=cj(r):e.zIndexMap[n]={consumers:0,element:i?void 0:cj(r),panoramaElement:i?cj(r):void 0}},prepare:ZO()},unregisterZIndexPortalElement:{reducer:(e,t)=>{var{zIndex:n}=t.payload;e.zIndexMap[n]&&(t.payload.isPanorama?e.zIndexMap[n].panoramaElement=void 0:e.zIndexMap[n].element=void 0)},prepare:ZO()}}}),{registerZIndexPortal:abe,unregisterZIndexPortal:obe,registerZIndexPortalElement:sbe,unregisterZIndexPortalElement:cbe}=GR.actions,lbe=GR.reducer;function KR(e){var{zIndex:t,children:n}=e,r=spe()&&t!==void 0&&t!==0,i=nA(),a=mD();(0,y.useLayoutEffect)(()=>r?(a(abe({zIndex:t})),()=>{a(obe({zIndex:t}))}):BE,[a,t,r]);var o=gD(e=>Zye(e,t,i));return r?o?(0,Op.createPortal)(n,o):null:n}function qR(){return qR=Object.assign?Object.assign.bind():function(e){for(var t=1;t(0,y.useContext)(XR),_be=l(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i{if(t&&Array.isArray(e)){var n=Number.parseInt(t,10);if(!OE(n))return e[n]}},tz=tk({name:`options`,initialState:{chartName:``,tooltipPayloadSearcher:()=>void 0,eventEmitter:void 0,defaultTooltipEventType:`axis`},reducers:{createEventEmitter:e=>{e.eventEmitter??=Symbol(`rechartsEventEmitter`)}}}),vbe=tz.reducer,{createEventEmitter:ybe}=tz.actions;function bbe(e){return e.tooltip.syncInteraction}var nz=tk({name:`chartData`,initialState:{chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},reducers:{setChartData(e,t){if(e.chartData=cj(t.payload),t.payload==null){e.dataStartIndex=0,e.dataEndIndex=0;return}t.payload.length>0&&e.dataEndIndex!==t.payload.length-1&&(e.dataEndIndex=t.payload.length-1)},setComputedData(e,t){e.computedData=t.payload},setDataStartEndIndexes(e,t){var{startIndex:n,endIndex:r}=t.payload;n!=null&&(e.dataStartIndex=n),r!=null&&(e.dataEndIndex=r)}}}),{setChartData:rz,setDataStartEndIndexes:xbe,setComputedData:Sbe}=nz.actions,Cbe=nz.reducer,wbe=[`x`,`y`];function iz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function az(e){for(var t=1;t{if(e==null)return BE;var s=(s,c,l)=>{if(t!==l&&e===s){if(r===`index`){var u;if(o&&c!=null&&(u=c.payload)!=null&&u.coordinate&&c.payload.sourceViewBox){var d=c.payload.coordinate,{x:f,y:p}=d,m=Obe(d,wbe),{x:h,y:g,width:_,height:v}=c.payload.sourceViewBox,y=az(az({},m),{},{x:o.x+(_?(f-h)/_:0)*o.width,y:o.y+(v?(p-g)/v:0)*o.height});n(az(az({},c),{},{payload:az(az({},c.payload),{},{coordinate:y})}))}else n(c);return}if(i!=null){var b;typeof r==`function`?b=i[r(i,{activeTooltipIndex:c.payload.index==null?void 0:Number(c.payload.index),isTooltipActive:c.payload.active,activeIndex:c.payload.index==null?void 0:Number(c.payload.index),activeLabel:c.payload.label,activeDataKey:c.payload.dataKey,activeCoordinate:c.payload.coordinate})]:r===`value`&&(b=i.find(e=>String(e.value)===c.payload.label));var{coordinate:x}=c.payload;if(b==null||c.payload.active===!1||x==null||o==null){n(ZL({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:S,y:C}=x,w=Math.min(S,o.x+o.width),T=Math.min(C,o.y+o.height),E={x:a===`horizontal`?b.coordinate:w,y:a===`horizontal`?T:b.coordinate};n(ZL({active:c.payload.active,coordinate:E,dataKey:c.payload.dataKey,index:String(b.index),label:c.payload.label,sourceViewBox:c.payload.sourceViewBox,graphicalItemId:c.payload.graphicalItemId}))}}};return ZR.on(QR,s),()=>{ZR.off(QR,s)}},[gD(e=>e.rootProps.className),n,t,e,r,i,a,o])}function jbe(){var e=gD(VF),t=gD(UF),n=mD();(0,y.useEffect)(()=>{if(e==null)return BE;var r=(r,i,a)=>{t!==a&&e===r&&n(xbe(i))};return ZR.on($R,r),()=>{ZR.off($R,r)}},[n,t,e])}function Mbe(){var e=mD();(0,y.useEffect)(()=>{e(ybe())},[e]),Abe(),jbe()}function Nbe(e,t,n,r,i,a){var o=gD(n=>Wye(n,e,t)),s=gD(UF),c=gD(VF),l=gD(HF),u=gD(bbe)?.active,d=gA();(0,y.useEffect)(()=>{if(!u&&c!=null&&s!=null){var e=ZL({active:a,coordinate:n,dataKey:o,index:i,label:typeof r==`number`?String(r):r,sourceViewBox:d,graphicalItemId:void 0});ZR.emit(QR,c,e,s)}},[u,n,o,i,r,s,c,l,a,d])}function oz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function sz(e){for(var t=1;t{S(iye({shared:g,trigger:_,axisId:x,active:n,defaultIndex:C}))},[S,g,_,x,n,C]);var w=gA(),T=Sj(),E=$ve(g),{activeIndex:D,isActive:O}=gD(e=>qye(e,E,_,C))??{},k=gD(e=>Kye(e,E,_,C)),A=gD(e=>HR(e,E,_,C)),j=gD(e=>Gye(e,E,_,C)),M=k,N=gbe(),P=n??O??!1,[F,I]=DD([M,P]),L=E===`axis`?A:void 0;Nbe(E,_,j,L,D,P);var R=b??N;if(R==null||w==null||E==null)return null;var z=M??cz;P||(z=cz),s&&z.length&&(z=dD(z.filter(e=>e.value!=null&&(e.hide!==!0||t.includeHidden)),u,Lbe));var B=z.length>0,V=y.createElement(Zpe,{allowEscapeViewBox:r,animationDuration:i,animationEasing:a,isAnimationActive:c,active:P,coordinate:j,hasPayload:B,offset:l,position:d,reverseDirection:f,useTranslate3d:p,viewBox:w,wrapperStyle:m,lastBoundingBox:F,innerRef:I,hasPortalFromProps:!!b},Rbe(o,sz(sz({},t),{},{payload:z,label:L,active:P,activeIndex:D,coordinate:j,accessibilityLayer:T})));return y.createElement(y.Fragment,null,(0,Op.createPortal)(V,R),P&&y.createElement(hbe,{cursor:h,tooltipEventType:E,coordinate:j,payload:z,index:D}))}var uz=e=>null;uz.displayName=`Cell`;function Bbe(e,t,n){return(t=Vbe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Vbe(e){var t=Hbe(e,`string`);return typeof t==`symbol`?t:t+``}function Hbe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ube=class{constructor(e){Bbe(this,`cache`,new Map),this.maxSize=e}get(e){var t=this.cache.get(e);return t!==void 0&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){var n=this.cache.keys().next().value;n!=null&&this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}size(){return this.cache.size}};function dz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Wbe(e){for(var t=1;t{try{var n=document.getElementById(mz);n||(n=document.createElement(`span`),n.setAttribute(`id`,mz),n.setAttribute(`aria-hidden`,`true`),document.body.appendChild(n)),Object.assign(n.style,Jbe,t),n.textContent=`${e}`;var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},gz=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||qj.isSsr)return{width:0,height:0};if(!fz.enableCache)return hz(e,t);var n=Ybe(e,t),r=pz.get(n);if(r)return r;var i=hz(e,t);return pz.set(n,i),i},_z;function Xbe(e,t,n){return(t=Zbe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zbe(e){var t=Qbe(e,`string`);return typeof t==`symbol`?t:t+``}function Qbe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var vz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,yz=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,$be=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,exe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,txe={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},nxe=[`cm`,`mm`,`pt`,`pc`,`in`,`Q`,`px`];function rxe(e){return nxe.includes(e)}var bz=`NaN`;function ixe(e,t){return e*txe[t]}var xz=class e{static parse(t){var[,n,r]=exe.exec(t)??[];return n==null?e.NaN:new e(parseFloat(n),r??``)}constructor(e,t){this.num=e,this.unit=t,this.num=e,this.unit=t,OE(e)&&(this.unit=``),t!==``&&!$be.test(t)&&(this.num=NaN,this.unit=``),rxe(t)&&(this.num=ixe(e,t),this.unit=`px`)}add(t){return this.unit===t.unit?new e(this.num+t.num,this.unit):new e(NaN,``)}subtract(t){return this.unit===t.unit?new e(this.num-t.num,this.unit):new e(NaN,``)}multiply(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num*t.num,this.unit||t.unit)}divide(t){return this.unit!==``&&t.unit!==``&&this.unit!==t.unit?new e(NaN,``):new e(this.num/t.num,this.unit||t.unit)}toString(){return`${this.num}${this.unit}`}isNaN(){return OE(this.num)}};_z=xz,Xbe(xz,`NaN`,new _z(NaN,``));function Sz(e){if(e==null||e.includes(bz))return bz;for(var t=e;t.includes(`*`)||t.includes(`/`);){var[,n,r,i]=vz.exec(t)??[],a=xz.parse(n??``),o=xz.parse(i??``),s=r===`*`?a.multiply(o):a.divide(o);if(s.isNaN())return bz;t=t.replace(vz,s.toString())}for(;t.includes(`+`)||/.-\d+(?:\.\d+)?/.test(t);){var[,c,l,u]=yz.exec(t)??[],d=xz.parse(c??``),f=xz.parse(u??``),p=l===`+`?d.add(f):d.subtract(f);if(p.isNaN())return bz;t=t.replace(yz,p.toString())}return t}var Cz=/\(([^()]*)\)/;function axe(e){for(var t=e,n;(n=Cz.exec(t))!=null;){var[,r]=n;t=t.replace(Cz,Sz(r))}return t}function oxe(e){var t=e.replace(/\s+/g,``);return t=axe(t),t=Sz(t),t}function sxe(e){try{return oxe(e)}catch{return bz}}function wz(e){var t=sxe(e.slice(5,-1));return t===bz?``:t}var cxe=[`x`,`y`,`lineHeight`,`capHeight`,`fill`,`scaleToFit`,`textAnchor`,`verticalAnchor`],lxe=[`dx`,`dy`,`angle`,`className`,`breakAll`];function Tz(){return Tz=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{children:t,breakAll:n,style:r}=e;try{var i=[];return LE(t)||(i=n?t.toString().split(``):t.toString().split(Dz)),{wordsWithComputedWidth:i.map(e=>({word:e,width:gz(e,r).width})),spaceWidth:n?0:gz(`\xA0`,r).width}}catch{return null}};function dxe(e){return e===`start`||e===`middle`||e===`end`||e===`inherit`}var kz=(e,t,n,r)=>e.reduce((e,i)=>{var{word:a,width:o}=i,s=e[e.length-1];if(s&&o!=null&&(t==null||r||s.width+o+ne.reduce((e,t)=>e.width>t.width?e:t),fxe=`…`,jz=(e,t,n,r,i,a,o,s)=>{var c=Oz({breakAll:n,style:r,children:e.slice(0,t)+fxe});if(!c)return[!1,[]];var l=kz(c.wordsWithComputedWidth,a,o,s);return[l.length>i||Az(l).width>Number(a),l]},pxe=(e,t,n,r,i)=>{var{maxLines:a,children:o,style:s,breakAll:c}=e,l=AE(a),u=String(o),d=kz(t,r,n,i);if(!l||i||!(d.length>a||Az(d).width>Number(r)))return d;for(var f=0,p=u.length-1,m=0,h;f<=p&&m<=u.length-1;){var g=Math.floor((f+p)/2),[_,v]=jz(u,g-1,c,s,a,r,n,i),[y]=jz(u,g,c,s,a,r,n,i);if(!_&&!y&&(f=g+1),_&&y&&(p=g-1),!_&&y){h=v;break}m++}return h||d},Mz=e=>[{words:LE(e)?[]:e.toString().split(Dz),width:void 0}],mxe=e=>{var{width:t,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=e;if((t||n)&&!qj.isSsr){var s,c,l=Oz({breakAll:a,children:r,style:i});if(l){var{wordsWithComputedWidth:u,spaceWidth:d}=l;s=u,c=d}else return Mz(r);return pxe({breakAll:a,children:r,maxLines:o,style:i},s,c,t,!!n)}return Mz(r)},Nz=`#808080`,hxe={angle:0,breakAll:!1,capHeight:`0.71em`,fill:Nz,lineHeight:`1em`,scaleToFit:!1,textAnchor:`start`,verticalAnchor:`end`,x:0,y:0},Pz=(0,y.forwardRef)((e,t)=>{var n=XE(e,hxe),{x:r,y:i,lineHeight:a,capHeight:o,fill:s,scaleToFit:c,textAnchor:l,verticalAnchor:u}=n,d=Ez(n,cxe),f=(0,y.useMemo)(()=>mxe({breakAll:d.breakAll,children:d.children,maxLines:d.maxLines,scaleToFit:c,style:d.style,width:d.width}),[d.breakAll,d.children,d.maxLines,c,d.style,d.width]),{dx:p,dy:m,angle:h,className:g,breakAll:_}=d,v=Ez(d,lxe);if(!jE(r)||!jE(i)||f.length===0)return null;var b=Number(r)+(AE(p)?p:0),x=Number(i)+(AE(m)?m:0);if(!Ak(b)||!Ak(x))return null;var S;switch(u){case`start`:S=wz(`calc(${o})`);break;case`middle`:S=wz(`calc(${(f.length-1)/2} * -${a} + (${o} / 2))`);break;default:S=wz(`calc(${f.length-1} * -${a})`);break}var C=[],w=f[0];if(c&&w!=null){var T=w.width,{width:E}=d;C.push(`scale(${AE(E)&&AE(T)?E/T:1})`)}return h&&C.push(`rotate(${h}, ${b}, ${x})`),C.length&&(v.transform=C.join(` `)),y.createElement(`text`,Tz({},CT(v),{ref:t,x:b,y:x,className:_T(`recharts-text`,g),textAnchor:l,fill:s.includes(`url`)?Nz:s}),f.map((e,t)=>{var n=e.words.join(_?``:` `);return y.createElement(`tspan`,{x:b,dy:t===0?S:a,key:`${n}-${t}`},n)}))});Pz.displayName=`Text`;function Fz(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Iz(e){for(var t=1;t{var{viewBox:t,position:n,offset:r=0,parentViewBox:i,clamp:a}=e,{x:o,y:s,height:c,upperWidth:l,lowerWidth:u}=hA(t),d=o,f=o+(l-u)/2,p=(d+f)/2,m=(l+u)/2,h=d+l/2,g=c>=0?1:-1,_=g*r,v=g>0?`end`:`start`,y=g>0?`start`:`end`,b=l>=0?1:-1,x=b*r,S=b>0?`end`:`start`,C=b>0?`start`:`end`,w=i;if(n===`top`){var T={x:d+l/2,y:s-_,horizontalAnchor:`middle`,verticalAnchor:v};return a&&w&&(T.height=Math.max(s-w.y,0),T.width=l),T}if(n===`bottom`){var E={x:f+u/2,y:s+c+_,horizontalAnchor:`middle`,verticalAnchor:y};return a&&w&&(E.height=Math.max(w.y+w.height-(s+c),0),E.width=u),E}if(n===`left`){var D={x:p-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`};return a&&w&&(D.width=Math.max(D.x-w.x,0),D.height=c),D}if(n===`right`){var O={x:p+m+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`};return a&&w&&(O.width=Math.max(w.x+w.width-O.x,0),O.height=c),O}var k=a&&w?{width:m,height:c}:{};return n===`insideLeft`?Iz({x:p+x,y:s+c/2,horizontalAnchor:C,verticalAnchor:`middle`},k):n===`insideRight`?Iz({x:p+m-x,y:s+c/2,horizontalAnchor:S,verticalAnchor:`middle`},k):n===`insideTop`?Iz({x:d+l/2,y:s+_,horizontalAnchor:`middle`,verticalAnchor:y},k):n===`insideBottom`?Iz({x:f+u/2,y:s+c-_,horizontalAnchor:`middle`,verticalAnchor:v},k):n===`insideTopLeft`?Iz({x:d+x,y:s+_,horizontalAnchor:C,verticalAnchor:y},k):n===`insideTopRight`?Iz({x:d+l-x,y:s+_,horizontalAnchor:S,verticalAnchor:y},k):n===`insideBottomLeft`?Iz({x:f+x,y:s+c-_,horizontalAnchor:C,verticalAnchor:v},k):n===`insideBottomRight`?Iz({x:f+u-x,y:s+c-_,horizontalAnchor:S,verticalAnchor:v},k):n&&typeof n==`object`&&(AE(n.x)||kE(n.x))&&(AE(n.y)||kE(n.y))?Iz({x:o+NE(n.x,m),y:s+NE(n.y,c),horizontalAnchor:`end`,verticalAnchor:`end`},k):Iz({x:h,y:s+c/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},k)},bxe=[`labelRef`],xxe=[`content`];function Lz(e,t){if(e==null)return{};var n,r,i=Sxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:s}=e,c=(0,y.useMemo)(()=>({x:t,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[t,n,r,i,a,o]);return y.createElement(Vz.Provider,{value:c},s)},Uz=()=>{var e=(0,y.useContext)(Vz),t=gA();return e||(t?hA(t):void 0)},Exe=(0,y.createContext)(null),Dxe=()=>{var e=(0,y.useContext)(Exe),t=gD(sI);return e||t},Oxe=e=>{var{value:t,formatter:n}=e,r=LE(e.children)?t:e.children;return typeof n==`function`?n(r):r},Wz=e=>e!=null&&typeof e==`function`,kxe=(e,t)=>DE(t-e)*Math.min(Math.abs(t-e),360),Axe=(e,t,n,r,i)=>{var{offset:a,className:o}=e,{cx:s,cy:c,innerRadius:l,outerRadius:u,startAngle:d,endAngle:f,clockWise:p}=i,m=(l+u)/2,h=kxe(d,f),g=h>=0?1:-1,_,v;switch(t){case`insideStart`:_=d+g*a,v=p;break;case`insideEnd`:_=f-g*a,v=!p;break;case`end`:_=f+g*a,v=p;break;default:throw Error(`Unsupported position ${t}`)}v=h<=0?v:!v;var b=lM(s,c,m,_),x=lM(s,c,m,_+(v?1:-1)*359),S=`M${b.x},${b.y} A${m},${m},0,1,${+!v}, - ${x.x},${x.y}`,C=IE(e.id)?jE(`recharts-radial-line-`):e.id;return y.createElement(`text`,zz({},r,{dominantBaseline:`central`,className:gT(`recharts-radial-bar-label`,o)}),y.createElement(`defs`,null,y.createElement(`path`,{id:C,d:S})),y.createElement(`textPath`,{xlinkHref:`#${C}`},n))},Mxe=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:s,endAngle:c}=e,l=(s+c)/2;if(n===`outside`){var{x:u,y:d}=cM(r,i,o+t,l);return{x:u,y:d,textAnchor:u>=r?`start`:`end`,verticalAnchor:`middle`}}if(n===`center`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`middle`};if(n===`centerTop`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`start`};if(n===`centerBottom`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`end`};var{x:f,y:p}=cM(r,i,(a+o)/2,l);return{x:f,y:p,textAnchor:`middle`,verticalAnchor:`middle`}},Wz=e=>e!=null&&`cx`in e&&kE(e.cx),Nxe={angle:0,offset:5,zIndex:UF.label,position:`middle`,textBreakAll:!1};function Pxe(e){if(!Wz(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function Gz(e){var t=YE(e,Nxe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:s,className:c=``,textBreakAll:l,labelRef:u}=t,d=Oxe(),f=Hz(),p=n==null?i===`center`?f:d??f:Wz(n)?n:mA(n),m,h,g=Pxe(p);if(!p||IE(a)&&IE(o)&&!(0,y.isValidElement)(s)&&typeof s!=`function`)return null;var _=Rz(Rz({},t),{},{viewBox:p});if((0,y.isValidElement)(s)){var{labelRef:v}=_;return(0,y.cloneElement)(s,Iz(_,xxe))}if(typeof s==`function`){var{content:b}=_;if(m=(0,y.createElement)(s,Iz(_,Sxe)),(0,y.isValidElement)(m))return m}else m=kxe(t);var x=ST(t);if(Wz(p)){if(i===`insideStart`||i===`insideEnd`||i===`end`)return jxe(t,i,m,x,p);h=Mxe(p,t.offset,t.position)}else{if(!g)return null;var S=bxe({viewBox:g,position:i,offset:t.offset,parentViewBox:Wz(r)?void 0:r,clamp:!0});h=Rz(Rz({x:S.x,y:S.y,textAnchor:S.horizontalAnchor,verticalAnchor:S.verticalAnchor},S.width===void 0?{}:{width:S.width}),S.height===void 0?{}:{height:S.height})}return y.createElement(GR,{zIndex:t.zIndex},y.createElement(Nz,zz({ref:u,className:gT(`recharts-label`,c)},x,h,{textAnchor:fxe(x.textAnchor)?x.textAnchor:h.textAnchor,breakAll:l}),m))}Gz.displayName=`Label`;var Fxe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?y.createElement(Gz,zz({key:`label-implicit`},r)):AE(e)?y.createElement(Gz,zz({key:`label-implicit`,value:e},r)):(0,y.isValidElement)(e)?e.type===Gz?(0,y.cloneElement)(e,Rz({key:`label-implicit`},r)):y.createElement(Gz,zz({key:`label-implicit`,content:e},r)):Uz(e)?y.createElement(Gz,zz({key:`label-implicit`,content:e},r)):e&&typeof e==`object`?y.createElement(Gz,zz({},e,{key:`label-implicit`},r)):null};function Kz(e){var{label:t,labelRef:n}=e;return Fxe(t,Hz(),n)||null}var Ixe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e[e.length-1]}e.last=t})),Lxe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Array.isArray(e)?e:Array.from(e)}e.toArray=t})),Rxe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Ixe(),n=Lxe(),r=eD();function i(e){if(r.isArrayLike(e))return t.last(n.toArray(e))}e.last=i})),zxe=l(o(((e,t)=>{t.exports=Rxe().last}))()),Bxe=[`valueAccessor`],Vxe=[`dataKey`,`clockWise`,`id`,`textBreakAll`,`zIndex`];function qz(){return qz=Object.assign?Object.assign.bind():function(e){for(var t=1;tArray.isArray(e.value)?(0,zxe.default)(e.value):e.value,Yz=(0,y.createContext)(void 0),Xz=Yz.Provider,Zz=(0,y.createContext)(void 0),Wxe=Zz.Provider;function Gxe(){return(0,y.useContext)(Yz)}function Kxe(){return(0,y.useContext)(Zz)}function Qz(e){var{valueAccessor:t=Uxe}=e,n=Jz(e,Bxe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:s}=n,c=Jz(n,Vxe),l=Gxe(),u=Kxe(),d=l||u;return!d||!d.length?null:y.createElement(GR,{zIndex:s??UF.label},y.createElement(ET,{className:`recharts-label-list`},d.map((e,i)=>{var s=IE(r)?t(e,i):Nk(e.payload,r),l=IE(a)?{}:{id:`${a}-${i}`};return y.createElement(Gz,qz({key:`label-${i}`},ST(e),c,l,{fill:n.fill??e.fill,parentViewBox:e.parentViewBox,value:s,textBreakAll:o,viewBox:e.viewBox,index:i,zIndex:0}))})))}Qz.displayName=`LabelList`;function $z(e){var{label:t}=e;return t?t===!0?y.createElement(Qz,{key:`labelList-implicit`}):y.isValidElement(t)||Uz(t)?y.createElement(Qz,{key:`labelList-implicit`,content:t}):typeof t==`object`?y.createElement(Qz,qz({key:`labelList-implicit`},t,{type:String(t.type)})):null:null}function eB(){return eB=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,a=gT(`recharts-dot`,i);return kE(t)&&kE(n)&&kE(r)?y.createElement(`circle`,eB({},bT(e),KE(e),{className:a,cx:t,cy:n,r})):null},nB=e=>e.graphicalItems.polarItems,rB=bD([nB,AI,bD([sI,cI],NI)],FI),iB=bD([bD([rB],zI),CF],BI),qxe=bD([iB,AI,rB],HI);bD([iB,AI,rB],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:Nk(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:Nk(e,t.dataKey),errorDomain:[]})));var aB=()=>void 0,oB=bD([AI,yA,iB,qxe,LF,sI,bD([AI,eL,tL,aB,bD([iB,AI,rB,nL,sI],iL),aB,yA,sI],fL)],pL);bD([gL,bD([AI,oB,bD([oB,jI,gL],vL),sI],bL)],vI);var sB=ek({name:`polarAxis`,initialState:{radiusAxis:{},angleAxis:{}},reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=sj(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=sj(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:Jxe,removeRadiusAxis:Yxe,addAngleAxis:Xxe,removeAngleAxis:Zxe}=sB.actions,Qxe=sB.reducer;function cB(e){return e&&typeof e==`object`&&`className`in e&&typeof e.className==`string`?e.className:``}function lB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function uB(e){for(var t=1;tt],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),nSe=[],fB=(e,t,n)=>n?.length===0?nSe:n,pB=bD([CF,dB,fB],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>uB(uB({},t.presentationProps),e.props))),i!=null)return i}}),rSe=bD([pB,dB,fB],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=Nk(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:Wk(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),iSe=bD([pB,dB,fB,$k],(e,t,n,r)=>{if(!(t==null||e==null))return aCe({offset:r,pieSettings:t,displayedData:e,cells:n})}),aSe=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.suspense_list`),d=Symbol.for(`react.memo`),f=Symbol.for(`react.lazy`),p=Symbol.for(`react.view_transition`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case l:case u:case p:return e;default:switch(e&&=e.$$typeof,e){case s:case c:case f:case d:return e;case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),oSe=o(((e,t)=>{t.exports=aSe()}))(),mB=e=>typeof e==`string`?e:e?e.displayName||e.name||`Component`:``,hB=null,gB=null,_B=e=>{if(e===hB&&Array.isArray(gB))return gB;var t=[];return y.Children.forEach(e,e=>{IE(e)||((0,oSe.isFragment)(e)?t=t.concat(_B(e.props.children)):t.push(e))}),gB=t,hB=e,t};function vB(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(e=>mB(e)):[mB(t)],_B(e).forEach(e=>{var t=(0,TE.default)(e,`type.displayName`)||(0,TE.default)(e,`type.name`);t&&r.indexOf(t)!==-1&&n.push(e)}),n}var yB=e=>e&&typeof e==`object`&&`clipDot`in e?!!e.clipDot:!0,sSe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(typeof e!=`object`||!e)return!1;if(Object.getPrototypeOf(e)===null)return!0;if(Object.prototype.toString.call(e)!==`[object Object]`){let t=e[Symbol.toStringTag];return t==null||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable?!1:e.toString()===`[object ${t}]`}let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}e.isPlainObject=t})),cSe=o(((e,t)=>{t.exports=sSe().isPlainObject})),lSe,uSe,dSe,fSe,pSe;function bB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function xB(e){for(var t=1;t{var a=n-r,o=wE(lSe||=CB([`M `,`,`,``]),e,t);return o+=wE(uSe||=CB([`L `,`,`,``]),e+n,t),o+=wE(dSe||=CB([`L `,`,`,``]),e+n-a/2,t+i),o+=wE(fSe||=CB([`L `,`,`,``]),e+n-a/2-r,t+i),o+=wE(pSe||=CB([`L `,`,`,` Z`]),e,t),o},_Se={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},vSe=e=>{var t=YE(e,_Se),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:s}=t,{animationEasing:c,animationDuration:l,animationBegin:u,isUpdateAnimationActive:d}=t,f=(0,y.useRef)(null),[p,m]=(0,y.useState)(-1),h=(0,y.useRef)(i),g=(0,y.useRef)(a),_=(0,y.useRef)(o),v=(0,y.useRef)(n),b=(0,y.useRef)(r),x=Xj(e,`trapezoid-`);if((0,y.useEffect)(()=>{if(f.current&&f.current.getTotalLength)try{var e=f.current.getTotalLength();e&&m(e)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var S=gT(`recharts-trapezoid`,s);if(!d)return y.createElement(`g`,null,y.createElement(`path`,SB({},ST(t),{className:S,d:wB(n,r,i,a,o)})));var C=h.current,w=g.current,T=_.current,E=v.current,D=b.current,O=`0px ${p===-1?1:p}px`,k=`${p}px 0px`,A=Ij([`strokeDasharray`],l,c);return y.createElement(Yj,{animationId:x,key:x,canBegin:p>0,duration:l,easing:c,isActive:d,begin:u},e=>{var s=PE(C,i,e),c=PE(w,a,e),l=PE(T,o,e),u=PE(E,n,e),d=PE(D,r,e);f.current&&(h.current=s,g.current=c,_.current=l,v.current=u,b.current=d);var p=e>0?{transition:A,strokeDasharray:k}:{strokeDasharray:O};return y.createElement(`path`,SB({},ST(t),{className:S,d:wB(u,d,s,c,l),ref:f,style:xB(xB({},p),t.style)}))})},ySe=l(cSe()),bSe=[`option`,`shapeType`,`activeClassName`];function xSe(e,t){if(e==null)return{};var n,r,i=SSe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var r=pD();return(i,a)=>o=>{e?.(i,a,o),r(qL({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},AB=e=>{var t=pD();return(n,r)=>i=>{e?.(n,r,i),t(oye())}},jB=(e,t,n)=>{var r=pD();return(i,a)=>o=>{e?.(i,a,o),r(sye({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function MB(e){var{tooltipEntrySettings:t}=e,n=pD(),r=tA(),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r||(i.current===null?n(nye(t)):i.current!==t&&n(rye({prev:i.current,next:t})),i.current=t)},[t,n,r]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(iye(i.current)),null)},[n]),null}function NB(e){var{legendPayload:t}=e,n=pD(),r=tA(),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r||(i.current===null?n(wpe(t)):i.current!==t&&n(Tpe({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(Epe(i.current)),null)},[n]),null}function kSe(e){var{legendPayload:t}=e,n=pD(),r=hD(yA),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r!==`centric`&&r!==`radial`||(i.current===null?n(wpe(t)):i.current!==t&&n(Tpe({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(Epe(i.current)),null)},[n]),null}var ASe=y.useId??(()=>{var[e]=y.useState(()=>jE(`uid-`));return e});function jSe(e,t){var n=ASe();return t||(e?`${e}-${n}`:n)}var MSe=(0,y.createContext)(void 0),PB=e=>{var{id:t,type:n,children:r}=e,i=jSe(`recharts-${n}`,t);return y.createElement(MSe.Provider,{value:i},r(i))},FB=ek({name:`graphicalItems`,initialState:{cartesianItems:[],polarItems:[]},reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(sj(t.payload))},prepare:XO()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=VO(e).cartesianItems.indexOf(sj(n));i>-1&&(e.cartesianItems[i]=sj(r))},prepare:XO()},removeCartesianGraphicalItem:{reducer(e,t){var n=VO(e).cartesianItems.indexOf(sj(t.payload));n>-1&&e.cartesianItems.splice(n,1)},prepare:XO()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(sj(t.payload))},prepare:XO()},removePolarGraphicalItem:{reducer(e,t){var n=VO(e).polarItems.indexOf(sj(t.payload));n>-1&&e.polarItems.splice(n,1)},prepare:XO()}}}),{addCartesianGraphicalItem:NSe,replaceCartesianGraphicalItem:PSe,removeCartesianGraphicalItem:FSe,addPolarGraphicalItem:ISe,removePolarGraphicalItem:LSe}=FB.actions,RSe=FB.reducer,IB=(0,y.memo)(e=>{var t=pD(),n=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{n.current===null?t(NSe(e)):n.current!==e&&t(PSe({prev:n.current,next:e})),n.current=e},[t,e]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(FSe(n.current)),null)},[t]),null});function zSe(e){var t=pD();return(0,y.useLayoutEffect)(()=>(t(ISe(e)),()=>{t(LSe(e))}),[t,e]),null}var BSe=[`key`],VSe=[`onMouseEnter`,`onClick`,`onMouseLeave`],HSe=[`id`],USe=[`id`];function LB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function RB(e){for(var t=1;tvB(e.children,lz),[e.children]),n=hD(n=>rSe(n,e.id,t));return n==null?null:y.createElement(kSe,{legendPayload:n})}var YSe=y.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:r.map(e=>e.tooltipPayload),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:Wk(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return y.createElement(MB,{tooltipEntrySettings:d})}),XSe=(e,t)=>e>t?`start`:eME(typeof t==`function`?t(e):t,n,n*.8),QSe=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=lM(a,o);return{cx:i+ME(e.cx,a,a/2),cy:r+ME(e.cy,o,o/2),innerRadius:ME(e.innerRadius,s,0),outerRadius:ZSe(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},$Se=(e,t)=>EE(t-e)*Math.min(Math.abs(t-e),360),eCe=(e,t)=>{if(y.isValidElement(e))return y.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=gT(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=BB(t,BSe);return y.createElement(jj,zB({},i,{type:`linear`,className:n}))},tCe=(e,t,n)=>{if(y.isValidElement(e))return y.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),y.isValidElement(r)))return r;var i=gT(`recharts-pie-label-text`,cB(e));return y.createElement(Nz,zB({},t,{alignmentBaseline:`middle`,className:i}),r)};function nCe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=bT(n),c=xT(i),l=xT(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=cM(e.cx,e.cy,e.outerRadius+u,n),d=RB(RB(RB(RB({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:XSe(r.x,e.cx)},r),f=RB(RB(RB(RB({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[cM(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return y.createElement(GR,{zIndex:UF.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},y.createElement(ET,null,a&&eCe(a,f),tCe(i,d,Nk(e,o))))});return y.createElement(ET,{className:`recharts-pie-labels`},d)}function rCe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?y.createElement($z,{label:i}):y.createElement(nCe,{sectors:t,props:n,showLabels:r})}function iCe(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=hD(wR),c=hD(ER),l=hD(kye),{onMouseEnter:u,onClick:d,onMouseLeave:f}=i,p=BB(i,VSe),m=kB(u,i.dataKey,o),h=AB(f),g=jB(d,i.dataKey,o);return t==null||t.length===0?null:y.createElement(y.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,_=n&&f?n:s?r:null,v=RB(RB({},e),{},{stroke:e.stroke,tabIndex:-1,[Xk]:u,[Mfe]:o});return y.createElement(ET,zB({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},qE(p,e,u),{onMouseEnter:m(e,u),onMouseLeave:h(e,u),onClick:g(e,u)}),y.createElement(OB,zB({option:a??_,index:u,shapeType:`sector`,isActive:f},v)))}))}function aCe(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=$Se(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>Nk(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=p-h*d-g,v=n.reduce((e,t)=>{var n=Nk(t,c,0);return e+(kE(n)?n:0)},0),y;if(v>0){var b;y=n.map((e,n)=>{var s=Nk(e,c,0),p=Nk(e,l,n),h=QSe(t,i,e),g=(kE(s)?s:0)/v,y,x=RB(RB({},e),r&&r[n]&&r[n].props);y=n?b.endAngle+EE(f)*m*(s===0?0:1):o;var S=y+EE(f)*((s===0?0:d)+g*_),C=(y+S)/2,w=(h.innerRadius+h.outerRadius)/2,T=[{name:p,value:s,payload:x,dataKey:c,type:u,graphicalItemId:t.id}],E=cM(h.cx,h.cy,w,C);return b=RB(RB(RB(RB({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:T,midAngle:C,middleRadius:w,tooltipPosition:E},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:S,payload:x,paddingAngle:EE(f)*m}),b})}return y}function oCe(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,y.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return y.createElement(Wxe,{value:t?i:void 0},r)}function sCe(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=Xj(t,`recharts-pie-`),m=n.current,[h,g]=(0,y.useState)(!1),_=(0,y.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,y.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return y.createElement(oCe,{showLabels:!h,sectors:i},y.createElement(Yj,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,TE.default)(t,`paddingAngle`,0):0;if(r){var s=PE(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=RB(RB({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=PE(0,l-u,e),f=RB(RB({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,y.createElement(ET,null,y.createElement(iCe,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),y.createElement(rCe,{showLabels:!h,sectors:i,props:t}),t.children)}var cCe={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:UF.area};function lCe(e){var{id:t}=e,n=BB(e,HSe),{hide:r,className:i,rootTabIndex:a}=e,o=(0,y.useMemo)(()=>vB(e.children,lz),[e.children]),s=hD(e=>iSe(e,t,o)),c=(0,y.useRef)(null),l=gT(`recharts-pie`,i);return r||s==null?(c.current=null,y.createElement(ET,{tabIndex:a,className:l})):y.createElement(GR,{zIndex:e.zIndex},y.createElement(YSe,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t}),y.createElement(ET,{tabIndex:a,className:l},y.createElement(sCe,{props:RB(RB({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function VB(e){var t=YE(e,cCe),{id:n}=t,r=BB(t,USe),i=bT(r);return y.createElement(PB,{id:n,type:`pie`},e=>y.createElement(y.Fragment,null,y.createElement(zSe,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),y.createElement(JSe,zB({},r,{id:e})),y.createElement(lCe,zB({},r,{id:e}))))}VB.displayName=`Pie`;var uCe=[`points`];function HB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function UB(e){for(var t=1;t{var s=UB(UB(UB({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return y.createElement(gCe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),y.createElement(GR,{zIndex:l},y.createElement(ET,WB({className:r},p),f))}function KB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function qB(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),Gk,Kk],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),YB=()=>hD(MCe),NCe=()=>hD(Mye);function XB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ZB(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=ZB(ZB(ZB({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),xT(i)),KE(i)),c=(0,y.isValidElement)(i)?(0,y.cloneElement)(i,s):typeof i==`function`?i(s):y.createElement(tB,s);return y.createElement(ET,{className:`recharts-active-dot`,clipPath:o},c)};function QB(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=UF.activeDot}=e,s=hD(wR),c=NCe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return IE(l)?null:y.createElement(GR,{zIndex:o},y.createElement(LCe,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var $B=(e,t,n)=>{var r=n??e;if(!IE(r))return ME(r,t,0)},RCe=(e,t,n)=>{var r={},i=e.filter(dI),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var[r,i]=e;return{stackId:r,dataKeys:i.map(e=>e.dataKey),barSize:$B(t,n,i[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:$B(t,n,e.barSize)}));return[...s,...c]};function eV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function tV(e){for(var t=1;te+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:((n-d)/2>>0)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=ME(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m>>=0);var h=kk(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var UCe=(e,t,n,r,i,a,o)=>{var s=IE(o)?t:o,c=HCe(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>tV(tV({},e),{},{position:tV(tV({},e.position),{},{offset:e.position.offset-i/2})}))),c},WCe=(e,t)=>{var n=lI(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(e=>e.key===n)}}}},GCe=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function KCe(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&kk(e.zIndex)?e.zIndex:t}var nV=e=>{var{chartData:t}=e,n=pD(),r=tA();return(0,y.useEffect)(()=>r?()=>{}:(n(nz(t)),()=>{n(nz(void 0))}),[t,n,r]),null},rV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},iV=ek({name:`brush`,initialState:rV,reducers:{setBrushSettings(e,t){return t.payload==null?rV:t.payload}}}),{setBrushSettings:qCe}=iV.actions,JCe=iV.reducer,YCe=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},XCe=e=>{var{x1:t,y1:n,x2:r,y2:i}=e;return YCe({x:t,y:n},{x:r,y:i})};function ZCe(e){return(e%180+180)%180}var QCe=function(e){var{width:t,height:n}=e,r=ZCe(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=VO(e).dots.findIndex(e=>e===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=VO(e).areas.findIndex(e=>e===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(sj(t.payload))},removeLine:(e,t)=>{var n=VO(e).lines.findIndex(e=>e===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:$Ce,removeDot:ewe,addArea:twe,removeArea:nwe,addLine:rwe,removeLine:iwe}=aV.actions,awe=aV.reducer,oV=(0,y.createContext)(void 0),owe=e=>{var{children:t}=e,[n]=(0,y.useState)(`${jE(`recharts`)}-clip`),r=YB();if(r==null)return null;var{x:i,y:a,width:o,height:s}=r;return y.createElement(oV.Provider,{value:n},y.createElement(`defs`,null,y.createElement(`clipPath`,{id:n},y.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},swe=()=>(0,y.useContext)(oV),cwe=class{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var{position:n}=t;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var{position:n,fallback:r}=t,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var{x:t,y:n}=e,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function sV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cV(e){for(var t=1;t{var n;if(y.isValidElement(e))n=y.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!kk(t.x1)||!kk(t.y1)||!kk(t.x2)||!kk(t.y2))return null;n=y.createElement(`line`,lV({},t,{className:`recharts-reference-line-line`}))}return n},pwe=(e,t,n,r,i,a)=>{var{x:o,width:s}=a,c=i.map(e,{position:n});if(!kk(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},mwe=(e,t,n,r,i,a)=>{var{y:o,height:s}=a,c=i.map(e,{position:n});if(!kk(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},hwe=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},gwe=(e,t,n,r,i,a,o)=>{var{x:s,y:c,segment:l,ifOverflow:u}=o,d=AE(s);return AE(c)?pwe(c,u,r,a,t,n):d?mwe(s,u,r,i,e,n):l!=null&&l.length===2?hwe(l,u,r,new cwe({x:e,y:t})):null};function _we(e){var t=pD();return(0,y.useEffect)(()=>(t(rwe(e)),()=>{t(iwe(e))})),null}function vwe(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:a}=e,o=tA(),s=swe(),c=hD(e=>TI(e,t)),l=hD(e=>OI(e,n)),u=hD(e=>wL(e,`xAxis`,t,o)),d=hD(e=>wL(e,`yAxis`,n,o)),f=hA();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=gwe(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var{x:g,y:_}=m,{x:v,y:b}=h,x=cV(cV({clipPath:a===`hidden`?`url(#${s})`:void 0},ST(e)),{},{x1:g,y1:_,x2:v,y2:b}),S=XCe({x1:g,y1:_,x2:v,y2:b});return y.createElement(GR,{zIndex:e.zIndex},y.createElement(ET,{className:gT(`recharts-reference-line`,i)},fwe(r,x),y.createElement(Vz,lV({},S,{lowerWidth:S.width,upperWidth:S.width}),y.createElement(Kz,{label:e.label}),e.children)))}var ywe={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:UF.line};function uV(e){var t=YE(e,ywe);return y.createElement(y.Fragment,null,y.createElement(_we,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),y.createElement(vwe,t))}uV.displayName=`ReferenceLine`;function dV(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function Swe(e,t){return dV(e,t+1)}function Cwe(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:s}=t,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:dV(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||fV(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function wwe(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var{start:o,end:s}=t,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||fV(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=mV(mV({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=mV(mV({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&fV(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=mV(mV({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function kwe(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,{start:c,end:l}=t;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=mV(mV({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&fV(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=mV(mV({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=mV(mV({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=mV(mV({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&fV(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=mV(mV({},a),{},{isShow:!0}))},h=0;h{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?bwe(hz(i,{fontSize:t,letterSpacing:n}),m,d):hz(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?EE(_.coordinate-g.coordinate):1,y=xwe(a,v,p);return c===`equidistantPreserveStart`?Cwe(v,y,h,i,o):c===`equidistantPreserveEnd`?wwe(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?kwe(v,y,h,i,o,c===`preserveStartEnd`):Owe(v,y,h,i,o),f.filter(e=>e.isShow))}var Awe=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var s=n?n.getBoundingClientRect().width:0,c=i+a,l=o+c+s+(n?r:0);return Math.round(l)}return 0},jwe=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`];function Mwe(e,t){if(e==null)return{};var n,r,i=Nwe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:s,padding:c,tickTextProps:l,orientation:u,mirror:d,x:f,y:p,width:m,height:h,tickSize:g,tickMargin:_,fontSize:v,letterSpacing:b,getTicksConfig:x,events:S,axisType:C}=e,w=hV(vV(vV({},x),{},{ticks:n}),v,b),T=zwe(u,d),E=Bwe(u,d),D=bT(x),O=xT(r),k={};typeof i==`object`&&(k=i);var A=vV(vV({},D),{},{fill:`none`},k),j=w.map(e=>vV({entry:e},Rwe(e,f,p,m,h,u,g,d,_))),M=j.map(e=>{var{entry:t,line:n}=e;return y.createElement(ET,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},i&&y.createElement(`line`,gV({},A,n,{className:gT(`recharts-cartesian-axis-tick-line`,(0,TE.default)(i,`className`))})))}),N=j.map((e,t)=>{var{entry:n,tick:i}=e,u=vV(vV({},vV(vV(vV(vV({verticalAnchor:E},D),{},{textAnchor:T,stroke:`none`,fill:a},i),{},{index:t,payload:n,visibleTicksCount:w.length,tickFormatter:o,padding:c},l),{},{angle:l?.angle??D.angle??0})),O);return y.createElement(ET,gV({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},qE(S,n,t)),r&&y.createElement(Vwe,{option:r,tickProps:u,value:`${typeof o==`function`?o(n.value,t):n.value}${s||``}`}))});return y.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},N.length>0&&y.createElement(GR,{zIndex:UF.label},y.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},N)),M.length>0&&y.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},M))}),Uwe=(0,y.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:s,axisType:c}=e,l=Mwe(e,jwe),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),m=(0,y.useRef)(null);(0,y.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>Awe({ticks:m.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var h=(0,y.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);m.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==u||a!==f)&&(d(i),p(a))}}},[u,f]);return o||r!=null&&r<=0||i!=null&&i<=0?null:y.createElement(GR,{zIndex:e.zIndex},y.createElement(ET,{className:gT(`recharts-cartesian-axis`,a)},y.createElement(Lwe,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:bT(e)}),y.createElement(Hwe,{ref:h,axisType:c,events:l,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:f,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y}),y.createElement(Vz,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},y.createElement(Kz,{label:e.label,labelRef:e.labelRef}),e.children)))}),bV=y.forwardRef((e,t)=>{var n=YE(e,yV);return y.createElement(Uwe,gV({},n,{ref:t}))});bV.displayName=`CartesianAxis`;var Wwe=[`x1`,`y1`,`x2`,`y2`,`key`],Gwe=[`offset`],Kwe=[`xAxisId`,`yAxisId`],qwe=[`xAxisId`,`yAxisId`];function xV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function SV(e){for(var t=1;t{var{fill:t}=e;if(!t||t===`none`)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return y.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function TV(e){var{option:t,lineItemProps:n}=e,r;if(y.isValidElement(t))r=y.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var{x1:i,y1:a,x2:o,y2:s,key:c}=n,l=bT(wV(n,Wwe))??{},{offset:u}=l,d=wV(l,Gwe);r=y.createElement(`line`,CV({},d,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function $we(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=wV(e,Kwe),c=i.map((e,i)=>{var a=SV(SV({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${i}`,index:i});return y.createElement(TV,{key:`line-${i}`,option:r,lineItemProps:a})});return y.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},c)}function eTe(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=wV(e,qwe),c=i.map((e,i)=>{var a=SV(SV({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${i}`,index:i});return y.createElement(TV,{option:r,lineItemProps:a,key:`line-${i}`})});return y.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},c)}function tTe(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:c=!0}=e;if(!c||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return y.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return y.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function nTe(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:c}=e;if(!t||!n||!n.length)return null;var l=c.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,t)=>{var c=l[t+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=t%n.length;return y.createElement(`rect`,{key:`react-${t}`,x:e,y:a,width:u,height:s,stroke:`none`,fill:n[d],fillOpacity:r,className:`recharts-cartesian-grid-bg`})});return y.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},u)}var rTe=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return Fk(hV(SV(SV(SV({},yV),n),{},{ticks:Ik(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},iTe=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return Fk(hV(SV(SV(SV({},yV),n),{},{ticks:Ik(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},aTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:UF.grid};function EV(e){var t=_A(),n=vA(),r=gA(),i=SV(SV({},YE(e,aTe)),{},{x:kE(e.x)?e.x:r.left,y:kE(e.y)?e.y:r.top,width:kE(e.width)?e.width:r.width,height:kE(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:c,width:l,height:u,syncWithTicks:d,horizontalValues:f,verticalValues:p}=i,m=tA(),h=hD(e=>IL(e,`xAxis`,a,m)),g=hD(e=>IL(e,`yAxis`,o,m));if(!Ak(l)||!Ak(u)||!kE(s)||!kE(c))return null;var _=i.verticalCoordinatesGenerator||rTe,v=i.horizontalCoordinatesGenerator||iTe,{horizontalPoints:b,verticalPoints:x}=i;if((!b||!b.length)&&typeof v==`function`){var S=f&&f.length,C=v({yAxis:g?SV(SV({},g),{},{ticks:S?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},S?!0:d);iA(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(b=C)}if((!x||!x.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?SV(SV({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);iA(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(x=T)}return y.createElement(GR,{zIndex:i.zIndex},y.createElement(`g`,{className:`recharts-cartesian-grid`},y.createElement(Qwe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),y.createElement(tTe,CV({},i,{horizontalPoints:b})),y.createElement(nTe,CV({},i,{verticalPoints:x})),y.createElement($we,CV({},i,{offset:r,horizontalPoints:b,xAxis:h,yAxis:g})),y.createElement(eTe,CV({},i,{offset:r,verticalPoints:x,xAxis:h,yAxis:g}))))}EV.displayName=`CartesianGrid`;var DV=ek({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(e=>e.dataKey===r.dataKey&&e.direction===r.direction?i:e))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(e=>e.dataKey!==r.dataKey||e.direction!==r.direction))}}}),{addErrorBar:oTe,replaceErrorBar:sTe,removeErrorBar:cTe}=DV.actions,lTe=DV.reducer,uTe=[`children`];function dTe(e,t){if(e==null)return{};var n,r,i=fTe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function mTe(e){var{children:t}=e,n=dTe(e,uTe);return y.createElement(pTe.Provider,{value:n},t)}function OV(e,t){var n=hD(t=>TI(t,e)),r=hD(e=>OI(e,t)),i=n?.allowDataOverflow??CI.allowDataOverflow,a=r?.allowDataOverflow??EI.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function kV(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=YB(),{needClipX:a,needClipY:o,needClip:s}=OV(t,n);if(!s||!i)return null;var{x:c,y:l,width:u,height:d}=i;return y.createElement(`clipPath`,{id:`clipPath-${r}`},y.createElement(`rect`,{x:a?c:c-u/2,y:o?l:l-d/2,width:a?u:u*2,height:o?d:d*2}))}var hTe=(e,t,n,r)=>zL(e,`xAxis`,t,r),gTe=(e,t,n,r)=>RL(e,`xAxis`,t,r),_Te=(e,t,n,r)=>zL(e,`yAxis`,n,r),vTe=(e,t,n,r)=>RL(e,`yAxis`,n,r),yTe=bD([yA,hTe,_Te,gTe,vTe],(e,t,n,r,i)=>Pk(e,`xAxis`)?Hk(t,r,!1):Hk(n,i,!1)),bTe=(e,t,n,r,i)=>i;function xTe(e){return e.type===`line`}var STe=bD([yA,hTe,_Te,gTe,vTe,bD([PI,bTe],(e,t)=>e.filter(xTe).find(e=>e.id===t)),yTe,wF],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return dEe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function CTe(e){var t=xT(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var wTe=o((e=>{var t=f();t.useSyncExternalStore,t.useRef,t.useEffect,t.useMemo,t.useDebugValue}));o(((e,t)=>{t.exports=wTe()}))();function TTe(e){e()}function ETe(){let e=null,t=null;return{clear(){e=null,t=null},notify(){TTe(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){let t=[],n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0,i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var DTe={notify(){},get:()=>[]};function OTe(e,t){let n,r=DTe,i=0,a=!1;function o(e){u();let t=r.subscribe(e),n=!1;return()=>{n||(n=!0,t(),d())}}function s(){r.notify()}function c(){m.onStateChange&&m.onStateChange()}function l(){return a}function u(){i++,n||(n=t?t.addNestedSub(c):e.subscribe(c),r=ETe())}function d(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=DTe)}function f(){a||(a=!0,u())}function p(){a&&(a=!1,d())}let m={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:c,isSubscribed:l,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return m}var kTe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,ATe=typeof navigator<`u`&&navigator.product===`ReactNative`,jTe=kTe||ATe?y.useLayoutEffect:y.useEffect;function MTe(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}function NTe(e,t){if(MTe(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;r({store:i,subscription:OTe(i),getServerState:r?()=>r:void 0}),[i,r]),o=y.useMemo(()=>i.getState(),[i]);jTe(()=>{let{subscription:e}=a;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),o!==i.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[a,o]);let s=n||LTe;return y.createElement(s.Provider,{value:a},t)}var zTe=RTe,BTe=new Set([`axisLine`,`tickLine`,`activeBar`,`activeDot`,`activeLabel`,`activeShape`,`allowEscapeViewBox`,`background`,`cursor`,`dot`,`label`,`line`,`margin`,`padding`,`position`,`shape`,`style`,`tick`,`wrapperStyle`,`radius`]);function VTe(e,t){return e==null&&t==null?!0:typeof e==`number`&&typeof t==`number`?e===t||e!==e&&t!==t:e===t}function AV(e,t){for(var n of new Set([...Object.keys(e),...Object.keys(t)]))if(BTe.has(n)){if(e[n]==null&&t[n]==null)continue;if(!NTe(e[n],t[n]))return!1}else if(!VTe(e[n],t[n]))return!1;return!0}var HTe=[`id`],UTe=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],WTe=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function jV(){return jV=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Wk(n,t),payload:e}]},ZTe=y.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:zE,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Wk(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return y.createElement(MB,{tooltipEntrySettings:d})}),QTe=(e,t)=>`${t}px ${e-t}px`;function $Te(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i{var r=n.reduce((e,t)=>e+t);if(!r)return QTe(t,e);for(var i=Math.floor(e/r),a=e%r,o=t-e,s=[],c=0,l=0;ca){s=[...n.slice(0,c),a-l];break}}var f=s.length%2==0?[0,o]:[o];return[...$Te(n,i),...s,...f].map(e=>`${e}px`).join(`, `)};function tEe(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=bT(NV(r,HTe));return y.createElement(GB,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function nEe(e){var{showLabels:t,children:n,points:r}=e,i=(0,y.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return MV(MV({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return y.createElement(Xz,{value:t?i:void 0},n)}function rEe(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=MV(MV({},ST(NV(a,UTe))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return y.createElement(y.Fragment,null,r?.length>1&&y.createElement(OB,jV({shapeType:`curve`,option:u},d,{pathRef:n})),y.createElement(tEe,{points:r,clipPathId:t,props:a}))}function iEe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function aEe(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Xj(o,`recharts-line-`),b=(0,y.useRef)(v),[x,S]=(0,y.useState)(!1),C=!x,w=(0,y.useCallback)(()=>{typeof h==`function`&&h(),S(!1)},[h]),T=(0,y.useCallback)(()=>{typeof g==`function`&&g(),S(!0)},[g]),E=iEe(r.current),D=(0,y.useRef)(0);b.current!==v&&(D.current=a.current,b.current=v);var O=D.current;return y.createElement(nEe,{points:o,showLabels:C},n.children,y.createElement(Yj,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=PE(O,E+O,e),u=Math.min(l,E),d=c?s?eEe(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):QTe(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return MV(MV({},t),{},{x:PE(i.x,t.x,e),y:PE(i.y,t.y,e)})}return f?MV(MV({},t),{},{x:PE(p*2,t.x,e),y:PE(m/2,t.y,e)}):MV(MV({},t),{},{x:t.x,y:t.y})});return i.current=g,y.createElement(rEe,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return y.createElement(rEe,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),y.createElement($z,{label:n.label}))}function oEe(e){var{clipPathId:t,props:n}=e,r=(0,y.useRef)(null),i=(0,y.useRef)(0),a=(0,y.useRef)(null);return y.createElement(aEe,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var sEe=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:Nk(e.payload,t)}),cEe=class extends y.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:s,width:c,height:l,id:u,needClip:d,zIndex:f}=this.props;if(e)return null;var p=gT(`recharts-line`,r),m=u,{r:h,strokeWidth:g}=CTe(t),_=yB(t),v=h*2+g,b=d?`url(#clipPath-${_?``:`dots-`}${m})`:void 0;return y.createElement(GR,{zIndex:f},y.createElement(ET,{className:p},d&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:m,xAxisId:i,yAxisId:a}),!_&&y.createElement(`clipPath`,{id:`clipPath-dots-${m}`},y.createElement(`rect`,{x:s-v/2,y:o-v/2,width:c+v,height:l+v}))),y.createElement(mTe,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:sEe,errorBarOffset:0},y.createElement(oEe,{props:this.props,clipPathId:m}))),y.createElement(QB,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},lEe={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:UF.line,type:`linear`};function uEe(e){var t=YE(e,lEe),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=NV(t,WTe),{needClip:_}=OV(p,m),v=YB(),b=bA(),x=tA(),S=hD(e=>STe(e,p,m,x,h));if(b!==`horizontal`&&b!==`vertical`||S==null||v==null)return null;var{height:C,width:w,x:T,y:E}=v;return y.createElement(cEe,jV({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:S,layout:b,height:C,width:w,left:T,top:E,needClip:_}))}function dEe(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=Nk(e,o);if(t===`horizontal`)return{x:Rk({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(IE(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=IE(l)?null:n.scale.map(l),d=Rk({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function fEe(e){var t=YE(e,lEe),n=tA();return y.createElement(PB,{id:t.id,type:`line`},e=>y.createElement(y.Fragment,null,y.createElement(NB,{legendPayload:XTe(t)}),y.createElement(ZTe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(IB,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),y.createElement(uEe,jV({},t,{id:e}))))}var PV=y.memo(fEe,AV);PV.displayName=`Line`;function FV(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function IV(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var pEe=(e,t,n)=>zL(e,`xAxis`,FV(e,t),n),mEe=(e,t,n)=>RL(e,`xAxis`,FV(e,t),n),LV=(e,t,n)=>zL(e,`yAxis`,IV(e,t),n),RV=(e,t,n)=>RL(e,`yAxis`,IV(e,t),n),hEe=bD([yA,pEe,LV,mEe,RV],(e,t,n,r,i)=>Pk(e,`xAxis`)?Hk(t,r,!1):Hk(n,i,!1)),zV=bD([PI,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),BV=e=>Pk(yA(e),`xAxis`)?`yAxis`:`xAxis`,gEe=(e,t)=>BV(e)===`yAxis`?IV(e,t):FV(e,t),_Ee=bD([yA,pEe,LV,mEe,RV,bD([zV,(e,t,n)=>ZI(e,BV(e),gEe(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=lI(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),TF,hEe,zV,ive],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return IEe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),vEe=[`id`],yEe=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function VV(){return VV=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:GV(r,i),value:Wk(n,t),payload:e}]},TEe=y.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:zE,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Wk(o,t),hide:s,type:l,color:GV(r,a),unit:c,graphicalItemId:u}};return y.createElement(MB,{tooltipEntrySettings:d})});function EEe(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=bT(r);return y.createElement(GB,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function DEe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return WV(WV({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return y.createElement(Xz,{value:t?i:void 0},n)}function KV(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=HV(a,vEe),p=bT(f),m=ST(f);return y.createElement(y.Fragment,null,t?.length>1&&y.createElement(ET,{clipPath:r?`url(#clipPath-${i})`:void 0},y.createElement(jj,VV({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&y.createElement(jj,VV({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&y.createElement(jj,VV({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),y.createElement(EEe,{points:t,props:f,clipPathId:i}))}function OEe(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!kk(a)||!kk(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return kE(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),kE(c)?y.createElement(`rect`,{x:0,y:ae.y||0));return kE(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),kE(c)?y.createElement(`rect`,{x:a({points:o,baseLine:s}),[o,s]),`recharts-area-`),h=xA(),[g,_]=(0,y.useState)(!1),v=!g,b=(0,y.useCallback)(()=>{typeof p==`function`&&p(),_(!1)},[p]),x=(0,y.useCallback)(()=>{typeof f==`function`&&f(),_(!0)},[f]);if(h==null)return null;var S=i.current,C=a.current;return y.createElement(DEe,{showLabels:v,points:o},r.children,y.createElement(Yj,{animationId:m,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:b,onAnimationStart:x,key:m},e=>{if(S){var l=S.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(S[r]){var i=S[r];return WV(WV({},t),{},{x:PE(i.x,t.x,e),y:PE(i.y,t.y,e)})}return t}),d=kE(s)?PE(C,s,e):IE(s)||DE(s)?PE(C,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(C)&&C[r]){var i=C[r];return WV(WV({},t),{},{x:PE(i.x,t.x,e),y:PE(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=d),y.createElement(KV,{points:u,baseLine:d,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),y.createElement(ET,null,c&&y.createElement(`defs`,null,y.createElement(`clipPath`,{id:`animationClipPath-${n}`},y.createElement(AEe,{alpha:e,points:o,baseLine:s,layout:h,strokeWidth:r.strokeWidth}))),y.createElement(ET,{clipPath:`url(#animationClipPath-${n})`},y.createElement(KV,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),y.createElement($z,{label:r.label}))}function MEe(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,y.useRef)(null),a=(0,y.useRef)();return y.createElement(jEe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var NEe=class extends y.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:i,left:a,needClip:o,xAxisId:s,yAxisId:c,width:l,height:u,id:d,baseLine:f,zIndex:p}=this.props;if(e)return null;var m=gT(`recharts-area`,r),h=d,{r:g,strokeWidth:_}=CTe(t),v=yB(t),b=g*2+_,x=o?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return y.createElement(GR,{zIndex:p},y.createElement(ET,{className:m},o&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:h,xAxisId:s,yAxisId:c}),!v&&y.createElement(`clipPath`,{id:`clipPath-dots-${h}`},y.createElement(`rect`,{x:a-b/2,y:i-b/2,width:l+b,height:u+b}))),y.createElement(MEe,{needClip:o,clipPathId:h,props:this.props})),y.createElement(QB,{points:n,mainColor:GV(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}),this.props.isRange&&Array.isArray(f)&&y.createElement(QB,{points:f,mainColor:GV(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}))}},qV={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:UF.area};function PEe(e){var t=YE(e,qV),{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,connectNulls:o,dot:s,fill:c,fillOpacity:l,hide:u,isAnimationActive:d,legendType:f,stroke:p,xAxisId:m,yAxisId:h}=t,g=HV(t,yEe),_=bA(),v=NR(),{needClip:b}=OV(m,h),x=tA(),{points:S,isRange:C,baseLine:w}=hD(t=>_Ee(t,e.id,x))??{},T=YB();if(_!==`horizontal`&&_!==`vertical`||T==null||v!==`AreaChart`&&v!==`ComposedChart`)return null;var{height:E,width:D,x:O,y:k}=T;return!S||!S.length?null:y.createElement(NEe,VV({},g,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:w,connectNulls:o,dot:s,fill:c,fillOpacity:l,height:E,hide:u,layout:_,isAnimationActive:d===`auto`?!Kj.isSsr:d,isRange:C,legendType:f,needClip:b,points:S,stroke:p,width:D,left:O,top:k,xAxisId:m,yAxisId:h}))}var FEe=(e,t,n,r,i)=>{var a=n??t;if(kE(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function IEe(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=FEe(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=Nk(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&Nk(e,r)==null;return g?{x:Rk({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:Rk({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function LEe(e){var t=YE(e,qV),n=tA();return y.createElement(PB,{id:t.id,type:`area`},e=>y.createElement(y.Fragment,null,y.createElement(NB,{legendPayload:wEe(t)}),y.createElement(TEe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(IB,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Lk(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),y.createElement(PEe,VV({},t,{id:e}))))}var JV=y.memo(LEe,AV);JV.displayName=`Area`;var REe=!0,YV=`Invariant failed`;function zEe(e,t){if(!e){if(REe)throw Error(YV);var n=typeof t==`function`?t():t,r=n?`${YV}: ${n}`:YV;throw Error(r)}}function XV(){return XV=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(kE(e))return e;var i=kE(n)||IE(n);return i?e(n,r):(!i&&zEe(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},VEe=(e,t,n)=>n,QV=bD([PI,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),HEe=bD([QV],e=>e?.maxBarSize),UEe=(e,t,n,r)=>r,WEe=bD([yA,PI,FV,IV,VEe],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),GEe=(e,t,n)=>{var r=yA(e),i=FV(e,t),a=IV(e,t);if(!(i==null||a==null))return r===`horizontal`?ZI(e,`yAxis`,a,n):ZI(e,`xAxis`,i,n)},KEe=bD([WEe,rve,(e,t)=>{var n=yA(e),r=FV(e,t),i=IV(e,t);if(!(r==null||i==null))return n===`horizontal`?jL(e,`xAxis`,r):jL(e,`yAxis`,i)}],RCe),qEe=(e,t,n)=>{var r=QV(e,t);if(r==null)return 0;var i=FV(e,t),a=IV(e,t);if(i==null||a==null)return 0;var o=yA(e),s=FF(e),{maxBarSize:c}=r,l=IE(c)?s:c,u,d;return o===`horizontal`?(u=zL(e,`xAxis`,i,n),d=RL(e,`xAxis`,i,n)):(u=zL(e,`yAxis`,a,n),d=RL(e,`yAxis`,a,n)),Hk(u,d,!0)??l??0},$V=(e,t,n)=>{var r=yA(e),i=FV(e,t),a=IV(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=zL(e,`xAxis`,i,n),s=RL(e,`xAxis`,i,n)):(o=zL(e,`yAxis`,a,n),s=RL(e,`yAxis`,a,n)),Hk(o,s)}},JEe=bD([$k,eA,(e,t,n)=>{var r=FV(e,t);if(r!=null)return zL(e,`xAxis`,r,n)},(e,t,n)=>{var r=IV(e,t);if(r!=null)return zL(e,`yAxis`,r,n)},(e,t,n)=>{var r=FV(e,t);if(r!=null)return RL(e,`xAxis`,r,n)},(e,t,n)=>{var r=IV(e,t);if(r!=null)return RL(e,`yAxis`,r,n)},bD([bD([KEe,FF,nve,IF,qEe,$V,HEe],UCe),QV],GCe),yA,TF,$V,bD([GEe,QV],WCe),QV,UEe],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var{chartData:p,dataStartIndex:m,dataEndIndex:h}=c;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var{data:g}=d,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return SDe({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),YEe=[`index`];function eH(){return eH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=(0,y.useContext)(tH);if(t!=null)return t.stackId;if(e!=null)return Lk(e)},$Ee=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,eDe=e=>{var t=(0,y.useContext)(tH);if(t!=null){var{stackId:n}=t;return`url(#${$Ee(n,e)})`}},nH=e=>{var{index:t}=e,n=XEe(e,YEe),r=eDe(t);return y.createElement(ET,eH({className:`recharts-bar-stack-layer`,clipPath:r},n))},tDe=[`onMouseEnter`,`onMouseLeave`,`onClick`],nDe=[`value`,`background`,`tooltipPosition`],rDe=[`id`],iDe=[`onMouseEnter`,`onClick`,`onMouseLeave`];function rH(){return rH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Wk(n,t),payload:e}]},uDe=y.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:void 0,getPosition:zE,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Wk(a,t),hide:o,type:c,color:i,unit:s,graphicalItemId:l}};return y.createElement(MB,{tooltipEntrySettings:u})});function dDe(e){var t=hD(wR),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:s,onClick:c}=a,l=oH(a,tDe),u=kB(o,r,a.id),d=AB(s),f=jB(c,r,a.id);if(!i||n==null)return null;var p=xT(i);return y.createElement(GR,{zIndex:KCe(i,UF.barBackground)},n.map((e,n)=>{var{value:a,background:o,tooltipPosition:s}=e,c=oH(e,nDe);if(!o)return null;var m=u(e,n),h=d(e,n),g=f(e,n),_=aH(aH(aH(aH(aH({option:i,isActive:String(n)===t},c),{},{fill:`#eee`},o),p),qE(l,e,n)),{},{onMouseEnter:m,onMouseLeave:h,onClick:g,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return y.createElement(ZV,rH({key:`background-bar-${n}`},_))}))}function fDe(e){var{showLabels:t,children:n,rects:r}=e,i=r?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return aH(aH({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return y.createElement(Xz,{value:t?i:void 0},n)}function pDe(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,s=hD(wR),c=hD(ER),l=n&&String(a)===s&&(c==null||o===c),u=l?n:t;return l?y.createElement(GR,{zIndex:UF.activeBar},y.createElement(nH,{index:a},y.createElement(ZV,rH({},r,{name:String(r.name)},i,{isActive:l,option:u,index:a,dataKey:o})))):y.createElement(ZV,rH({},r,{name:String(r.name)},i,{isActive:l,option:u,index:a,dataKey:o}))}function mDe(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return y.createElement(ZV,rH({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function hDe(e){var{data:t,props:n}=e,r=bT(n)??{},{id:i}=r,a=oH(r,rDe),{shape:o,dataKey:s,activeBar:c}=n,{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=oH(n,iDe),p=kB(l,s,i),m=AB(d),h=jB(u,s,i);return t?y.createElement(y.Fragment,null,t.map((e,t)=>y.createElement(nH,rH({index:t,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},qE(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),c?y.createElement(pDe,{shape:o,activeBar:c,baseProps:a,entry:e,index:t,dataKey:s}):y.createElement(mDe,{shape:o,baseProps:a,entry:e,index:t,dataKey:s})))):null}function gDe(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,onAnimationEnd:l,onAnimationStart:u}=t,d=n.current,f=Xj(t,`recharts-bar-`),[p,m]=(0,y.useState)(!1),h=!p,g=(0,y.useCallback)(()=>{typeof l==`function`&&l(),m(!1)},[l]),_=(0,y.useCallback)(()=>{typeof u==`function`&&u(),m(!0)},[u]);return y.createElement(fDe,{showLabels:h,rects:r},y.createElement(Yj,{animationId:f,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:g,onAnimationStart:_,key:f},e=>{var a=e===1?r:r?.map((t,n)=>{var r=d&&d[n];if(r)return aH(aH({},t),{},{x:PE(r.x,t.x,e),y:PE(r.y,t.y,e),width:PE(r.width,t.width,e),height:PE(r.height,t.height,e)});if(i===`horizontal`){var a=PE(0,t.height,e),o=PE(t.stackedBarStart,t.y,e);return aH(aH({},t),{},{y:o,height:a})}var s=PE(0,t.width,e),c=PE(t.stackedBarStart,t.x,e);return aH(aH({},t),{},{width:s,x:c})});return e>0&&(n.current=a??null),a==null?null:y.createElement(ET,null,y.createElement(hDe,{props:t,data:a}))}),y.createElement($z,{label:t.label}),t.children)}function _De(e){var t=(0,y.useRef)(null);return y.createElement(gDe,{previousRectanglesRef:t,props:e})}var sH=0,vDe=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:Nk(e,t)}},yDe=class extends y.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:i,yAxisId:a,needClip:o,background:s,id:c}=this.props;if(e||t==null)return null;var l=gT(`recharts-bar`,r),u=c;return y.createElement(ET,{className:l,id:c},o&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:u,xAxisId:i,yAxisId:a})),y.createElement(ET,{className:`recharts-bar-rectangles`,clipPath:o?`url(#clipPath-${u})`:void 0},y.createElement(dDe,{data:t,dataKey:n,background:s,allOtherBarProps:this.props}),y.createElement(_De,this.props)))}},bDe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:sH,xAxisId:0,yAxisId:0,zIndex:UF.bar};function xDe(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u}=e,{needClip:d}=OV(t,n),f=bA(),p=tA(),m=vB(e.children,lz),h=hD(t=>JEe(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,y.createElement(mTe,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:vDe,errorBarOffset:g},y.createElement(yDe,rH({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function SDe(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:s,xAxisTicks:c,yAxisTicks:l,stackedData:u,displayedData:d,offset:f,cells:p,parentViewBox:m,dataStartIndex:h}=e,g=t===`horizontal`?s:o,_=u?g.scale.domain():null,v=Tfe({numericAxis:g}),y=g.scale.map(v);return d.map((e,d)=>{var g,b,x,S,C,w;if(u){var T=u[d+h];if(T==null)return null;g=Sfe(T,_)}else g=Nk(e,n),Array.isArray(g)||(g=[v,g]);var E=BEe(r,sH)(g[1],d);if(t===`horizontal`){var D=s.scale.map(g[0]),O=s.scale.map(g[1]);if(D==null||O==null)return null;b=zk({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:e,index:d}),x=O??D??void 0,S=i.size;var k=D-O;if(C=DE(k)?0:k,w={x:b,y:f.top,width:S,height:f.height},Math.abs(E)>0&&Math.abs(C)0&&Math.abs(S)y.createElement(y.Fragment,null,y.createElement(NB,{legendPayload:lDe(t)}),y.createElement(uDe,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(IB,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r}),y.createElement(GR,{zIndex:t.zIndex},y.createElement(xDe,rH({},t,{id:e})))))}var cH=y.memo(CDe,AV);cH.displayName=`Bar`;var wDe=[`domain`,`range`],TDe=[`domain`,`range`];function lH(e,t){if(e==null)return{};var n,r,i=EDe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(o!=null)return mH(mH({},a),{},{type:o})},[a,o]);return(0,y.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(xCe(s)):n.current!==s&&t(SCe({prev:n.current,next:s})),n.current=s)},[s,t]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(CCe(n.current)),null)},[t]),null}var FDe=e=>{var{xAxisId:t,className:n}=e,r=hD(eA),i=tA(),a=`xAxis`,o=hD(e=>LL(e,a,t,i)),s=hD(e=>kL(e,t)),c=hD(e=>Zve(e,t)),l=hD(e=>wI(e,t));if(s==null||c==null||l==null)return null;var{dangerouslySetInnerHTML:u,ticks:d,scale:f}=e,p=hH(e,ODe),{id:m,scale:h}=l,g=hH(l,kDe);return y.createElement(bV,fH({},p,g,{x:c.x,y:c.y,width:s.width,height:s.height,className:gT(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a}))},IDe={allowDataOverflow:CI.allowDataOverflow,allowDecimals:CI.allowDecimals,allowDuplicatedCategory:CI.allowDuplicatedCategory,angle:CI.angle,axisLine:yV.axisLine,height:CI.height,hide:!1,includeHidden:CI.includeHidden,interval:CI.interval,label:!1,minTickGap:CI.minTickGap,mirror:CI.mirror,orientation:CI.orientation,padding:CI.padding,reversed:CI.reversed,scale:CI.scale,tick:CI.tick,tickCount:CI.tickCount,tickLine:yV.tickLine,tickSize:yV.tickSize,type:CI.type,xAxisId:0},gH=y.memo(e=>{var t=YE(e,IDe);return y.createElement(y.Fragment,null,y.createElement(PDe,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit}),y.createElement(FDe,t))},dH);gH.displayName=`XAxis`;var LDe=[`type`],RDe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],zDe=[`id`,`scale`];function _H(){return _H=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return yH(yH({},a),{},{type:o})},[o,a]);return(0,y.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(wCe(s)):n.current!==s&&t(TCe({prev:n.current,next:s})),n.current=s)},[s,t]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(ECe(n.current)),null)},[t]),null}function GDe(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=hD(eA),c=tA(),l=pD(),u=`yAxis`,d=hD(e=>AL(e,t)),f=hD(e=>Qve(e,t)),p=hD(e=>LL(e,u,t,c)),m=hD(e=>DI(e,t));if((0,y.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||Uz(i)||(0,y.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(ACe({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;var{dangerouslySetInnerHTML:h,ticks:g,scale:_}=e,v=bH(e,RDe),{id:b,scale:x}=m,S=bH(m,zDe);return y.createElement(bV,_H({},v,S,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:gT(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u}))}var KDe={allowDataOverflow:EI.allowDataOverflow,allowDecimals:EI.allowDecimals,allowDuplicatedCategory:EI.allowDuplicatedCategory,angle:EI.angle,axisLine:yV.axisLine,hide:!1,includeHidden:EI.includeHidden,interval:EI.interval,label:!1,minTickGap:EI.minTickGap,mirror:EI.mirror,orientation:EI.orientation,padding:EI.padding,reversed:EI.reversed,scale:EI.scale,tick:EI.tick,tickCount:EI.tickCount,tickLine:yV.tickLine,tickSize:yV.tickSize,type:EI.type,width:EI.width,yAxisId:0},xH=y.memo(e=>{var t=YE(e,KDe);return y.createElement(y.Fragment,null,y.createElement(WDe,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter}),y.createElement(GDe,t))},dH);xH.displayName=`YAxis`;var SH=bD([(e,t)=>t,yA,oI,mI,_R,yR,Wye,$k],Zye),CH=e=>{var t=e.currentTarget.getBoundingClientRect(),n=t.width/e.currentTarget.offsetWidth,r=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/n),chartY:Math.round((e.clientY-t.top)/r)}},wH=GO(`mouseClick`),TH=Tk();TH.startListening({actionCreator:wH,effect:(e,t)=>{var n=e.payload,r=SH(t.getState(),CH(n));r?.activeIndex!=null&&t.dispatch(cye({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var EH=GO(`mouseMove`),DH=Tk(),OH=null;DH.startListening({actionCreator:EH,effect:(e,t)=>{var n=e.payload;OH!==null&&cancelAnimationFrame(OH);var r=CH(n);OH=requestAnimationFrame(()=>{var e=t.getState();if(UL(e,e.tooltip.settings.shared)===`axis`){var n=SH(e,r);n?.activeIndex==null?t.dispatch(JL()):t.dispatch(YL({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}OH=null})}});function qDe(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<>`:t}var kH={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},AH=ek({name:`rootProps`,initialState:kH,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??kH.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),JDe=AH.reducer,{updateOptions:YDe}=AH.actions,jH=ek({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:XDe}=jH.actions,ZDe=jH.reducer,MH=GO(`keyDown`),NH=GO(`focus`),PH=Tk();PH.startListening({actionCreator:MH,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip,i=e.payload;if(!(i!==`ArrowRight`&&i!==`ArrowLeft`&&i!==`Enter`)){var a=tR(r,dR(n),YI(n),hR(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var s=yR(n);if(i===`Enter`){var c=BR(n,`axis`,`hover`,String(r.index));t.dispatch(ZL({active:!r.active,activeIndex:r.index,activeCoordinate:c}));return}var l=$ve(n)===`left-to-right`?1:-1,u=o+(i===`ArrowRight`?1:-1)*l;if(!(s==null||u>=s.length||u<0)){var d=BR(n,`axis`,`hover`,String(u));t.dispatch(ZL({active:!0,activeIndex:u.toString(),activeCoordinate:d}))}}}}}}),PH.startListening({actionCreator:NH,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;if(!r.active&&r.index==null){var i=`0`,a=BR(n,`axis`,`hover`,String(i));t.dispatch(ZL({active:!0,activeIndex:i,activeCoordinate:a}))}}}});var FH=GO(`externalEvent`),IH=Tk(),LH=new Map;IH.startListening({actionCreator:FH,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){r.persist();var i=r.type,a=LH.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var e=t.getState();n({activeCoordinate:Aye(e),activeDataKey:ER(e),activeIndex:wR(e),activeLabel:TR(e),activeTooltipIndex:wR(e),isTooltipActive:jye(e)},r)}finally{LH.delete(i)}});LH.set(i,o)}}});var QDe=bD([bD([aR],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),RH=GO(`touchMove`),zH=Tk();zH.startListening({actionCreator:RH,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){var r=t.getState(),i=UL(r,r.tooltip.settings.shared);if(i===`axis`){var a=n.touches[0];if(a==null)return;var o=SH(r,CH({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&t.dispatch(YL({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i===`item`){var s=n.touches[0];if(document.elementFromPoint==null||s==null)return;var c=document.elementFromPoint(s.clientX,s.clientY);if(!c||!c.getAttribute)return;var l=c.getAttribute(Xk),u=c.getAttribute(`data-recharts-item-id`)??void 0,d=uR(r).find(e=>e.id===u);if(l==null||d==null||u==null)return;var{dataKey:f}=d,p=QDe(r,l,u);t.dispatch(qL({activeDataKey:f,activeIndex:l,activeCoordinate:p,activeGraphicalItemId:u}))}}}});var $De=ND({brush:JCe,cartesianAxis:jCe,chartData:wbe,errorBars:lTe,graphicalItems:RSe,layout:_fe,legend:Dpe,options:ybe,polarAxis:Qxe,polarOptions:ZDe,referenceElements:awe,rootProps:JDe,tooltip:lye,zIndex:ube}),eOe=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Ude({reducer:$De,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([TH.middleware,DH.middleware,PH.middleware,IH.middleware,zH.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(QO({type:`raf`}))},devTools:Kj.devToolsEnabled&&{serialize:{replacer:qDe},name:`recharts-${t}`}})};function BH(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=tA(),a=(0,y.useRef)(null);if(i)return n;a.current??=eOe(t,r);var o=dD;return y.createElement(zTe,{context:o,store:a.current},n)}function tOe(e){var{layout:t,margin:n}=e,r=pD(),i=tA();return(0,y.useEffect)(()=>{i||(r(mfe(t)),r(pfe(n)))},[r,i,t,n]),null}var VH=(0,y.memo)(tOe,AV);function HH(e){var t=pD();return(0,y.useEffect)(()=>{t(YDe(e))},[t,e]),null}function UH(e){var{zIndex:t,isPanorama:n}=e,r=(0,y.useRef)(null),i=pD();return(0,y.useLayoutEffect)(()=>(r.current&&i(cbe({zIndex:t,element:r.current,isPanorama:n})),()=>{i(lbe({zIndex:t,isPanorama:n}))}),[i,t,n]),y.createElement(`g`,{tabIndex:-1,ref:r})}function WH(e){var{children:t,isPanorama:n}=e,r=hD($ye);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return y.createElement(y.Fragment,null,i.map(e=>y.createElement(UH,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>y.createElement(UH,{key:e,zIndex:e,isPanorama:n})))}var nOe=[`children`];function rOe(e,t){if(e==null)return{};var n,r,i=iOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=_A(),r=vA(),i=xj();if(!Ak(n)||!Ak(r))return null;var{children:a,otherAttributes:o,title:s,desc:c}=e,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),y.createElement(wT,GH({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:aOe,ref:t}),a)}),sOe=e=>{var{children:t}=e,n=hD(rA);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return y.createElement(wT,{width:r,height:i,x:o,y:a},t)},KH=(0,y.forwardRef)((e,t)=>{var{children:n}=e,r=rOe(e,nOe);return tA()?y.createElement(sOe,null,y.createElement(WH,{isPanorama:!0},n)):y.createElement(oOe,GH({ref:t},r),y.createElement(WH,{isPanorama:!1},n))});function cOe(){var e=pD(),[t,n]=(0,y.useState)(null),r=hD(jfe);return(0,y.useEffect)(()=>{if(t!=null){var n=t.getBoundingClientRect().width/t.offsetWidth;kk(n)&&n!==r&&e(gfe(n))}},[t,e,r]),n}function qH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lOe(e){for(var t=1;t(Nbe(),null);function YH(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var mOe=(0,y.forwardRef)((e,t)=>{var n=(0,y.useRef)(null),[r,i]=(0,y.useState)({containerWidth:YH(e.style?.width),containerHeight:YH(e.style?.height)}),a=(0,y.useCallback)((e,t)=>{i(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),o=(0,y.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null&&typeof ResizeObserver<`u`){var{width:r,height:i}=e.getBoundingClientRect();a(r,i);var o=new ResizeObserver(e=>{var t=e[0];if(t!=null){var{width:n,height:r}=t.contentRect;a(n,r)}});o.observe(e),n.current=o}},[t,a]);return(0,y.useEffect)(()=>()=>{n.current?.disconnect()},[a]),y.createElement(y.Fragment,null,y.createElement(CA,{width:r.containerWidth,height:r.containerHeight}),y.createElement(`div`,JH({ref:o},e)))}),hOe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e,[i,a]=(0,y.useState)({containerWidth:YH(n),containerHeight:YH(r)}),o=(0,y.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,y.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var{width:n,height:r}=e.getBoundingClientRect();o(n,r)}},[t,o]);return y.createElement(y.Fragment,null,y.createElement(CA,{width:i.containerWidth,height:i.containerHeight}),y.createElement(`div`,JH({ref:s},e)))}),gOe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e;return y.createElement(y.Fragment,null,y.createElement(CA,{width:n,height:r}),y.createElement(`div`,JH({ref:t},e)))}),_Oe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e;return typeof n==`string`||typeof r==`string`?y.createElement(hOe,JH({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?y.createElement(gOe,JH({},e,{width:n,height:r,ref:t})):y.createElement(y.Fragment,null,y.createElement(CA,{width:n,height:r}),y.createElement(`div`,JH({ref:t},e)))});function vOe(e){return e?mOe:_Oe}var yOe=(0,y.forwardRef)((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:c,onMouseEnter:l,onMouseLeave:u,onMouseMove:d,onMouseUp:f,onTouchEnd:p,onTouchMove:m,onTouchStart:h,style:g,width:_,responsive:v,dispatchTouchEvents:b=!0}=e,x=(0,y.useRef)(null),S=pD(),[C,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=cOe(),O=fA(),k=O?.width>0?O.width:_,A=O?.height>0?O.height:i,j=(0,y.useCallback)(e=>{D(e),typeof t==`function`&&t(e),w(e),E(e),e!=null&&(x.current=e)},[D,t,w,E]),M=(0,y.useCallback)(e=>{S(wH(e)),S(FH({handler:a,reactEvent:e}))},[S,a]),N=(0,y.useCallback)(e=>{S(EH(e)),S(FH({handler:l,reactEvent:e}))},[S,l]),P=(0,y.useCallback)(e=>{S(JL()),S(FH({handler:u,reactEvent:e}))},[S,u]),F=(0,y.useCallback)(e=>{S(EH(e)),S(FH({handler:d,reactEvent:e}))},[S,d]),I=(0,y.useCallback)(()=>{S(NH())},[S]),L=(0,y.useCallback)(e=>{S(MH(e.key))},[S]),R=(0,y.useCallback)(e=>{S(FH({handler:o,reactEvent:e}))},[S,o]),z=(0,y.useCallback)(e=>{S(FH({handler:s,reactEvent:e}))},[S,s]),B=(0,y.useCallback)(e=>{S(FH({handler:c,reactEvent:e}))},[S,c]),V=(0,y.useCallback)(e=>{S(FH({handler:f,reactEvent:e}))},[S,f]),ee=(0,y.useCallback)(e=>{S(FH({handler:h,reactEvent:e}))},[S,h]),te=(0,y.useCallback)(e=>{b&&S(RH(e)),S(FH({handler:m,reactEvent:e}))},[S,b,m]),ne=(0,y.useCallback)(e=>{S(FH({handler:p,reactEvent:e}))},[S,p]),re=vOe(v);return y.createElement(YR.Provider,{value:C},y.createElement(DT.Provider,{value:T},y.createElement(re,{width:k??g?.width,height:A??g?.height,className:gT(`recharts-wrapper`,r),style:lOe({position:`relative`,cursor:`default`,width:k,height:A},g),onClick:M,onContextMenu:R,onDoubleClick:z,onFocus:I,onKeyDown:L,onMouseDown:B,onMouseEnter:N,onMouseLeave:P,onMouseMove:F,onMouseUp:V,onTouchEnd:ne,onTouchMove:te,onTouchStart:ee,ref:j},y.createElement(pOe,null),n)))}),bOe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function xOe(e,t){if(e==null)return{};var n,r,i=SOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:a,className:o,style:s,compact:c,title:l,desc:u}=e,d=bT(xOe(e,bOe));return c?y.createElement(y.Fragment,null,y.createElement(CA,{width:n,height:r}),y.createElement(KH,{otherAttributes:d,title:l,desc:u},a)):y.createElement(yOe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},y.createElement(KH,{otherAttributes:d,title:l,desc:u,ref:t},y.createElement(owe,null,a)))});function ZH(){return ZH=Object.assign?Object.assign.bind():function(e){for(var t=1;ty.createElement(QH,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:wOe,tooltipPayloadSearcher:$R,categoricalChartProps:e,ref:t})),TOe=[`axis`,`item`],eU=(0,y.forwardRef)((e,t)=>y.createElement(QH,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:TOe,tooltipPayloadSearcher:$R,categoricalChartProps:e,ref:t}));function EOe(e){var t=pD();return(0,y.useEffect)(()=>{t(XDe(e))},[t,e]),null}var DOe=[`layout`];function tU(){return tU=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=YE(e,FOe);return y.createElement(AOe,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:POe,tooltipPayloadSearcher:$R,categoricalChartProps:n,ref:t})}),IOe=[`axis`],oU=(0,y.forwardRef)((e,t)=>y.createElement(QH,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:IOe,tooltipPayloadSearcher:$R,categoricalChartProps:e,ref:t})),sU=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}];function LOe({isOpen:e,onClose:t,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o=`humidity`,thresholds:s}){let{t:c}=W(),[l,u]=(0,y.useState)(`24h`),[d,f]=(0,y.useState)(o),{data:p}=q({queryKey:[`settings`],queryFn:Q.getSettings}),m=p?.time_format||`system`;(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let h=sU.find(e=>e.value===l)?.hours||24,{data:g,isLoading:_,error:v}=q({queryKey:[`ams-history`,n,i,h],queryFn:()=>Q.getAMSHistory(n,i,h),enabled:e,refetchInterval:6e4});if(!e)return null;let b=g?.data.map(e=>({time:(vf(e.recorded_at)||new Date).getTime(),humidity:e.humidity,temperature:e.temperature}))||[],x=Date.now()-h*60*60*1e3,S=Date.now(),C=[...b];if(C.length>0){let e=C[0];e.time>x&&C.unshift({...e,time:x});let t=C[C.length-1];t.time{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`},M=j(C.map(e=>e.humidity)),N=j(C.map(e=>e.temperature)),P=({trend:e})=>e===`up`?(0,K.jsx)(Su,{className:`w-4 h-4 text-red-400`}):e===`down`?(0,K.jsx)(xu,{className:`w-4 h-4 text-green-400`}):(0,K.jsx)(al,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),F=e=>e==null?`#9ca3af`:e<=w?`#22a352`:e<=T?`#d4a017`:`#c62828`,I=e=>e==null?`#9ca3af`:e<=E?`#22a352`:e<=D?`#d4a017`:`#c62828`,L=`var(--bg-secondary)`,R=`var(--bg-primary)`,z=`var(--border-color)`,B=`var(--text-primary)`,V=`var(--text-secondary)`,ee=`var(--text-muted)`;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:L},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:z},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold`,style:{color:B},children:[a,` `,c(`common.history`,`History`)]}),(0,K.jsx)(`p`,{className:`text-sm`,style:{color:V},children:r})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:V},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,K.jsxs)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:R},children:[(0,K.jsxs)(`button`,{onClick:()=>f(`humidity`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${d===`humidity`?`bg-blue-600 text-white`:``}`,style:d===`humidity`?void 0:{color:V},children:[(0,K.jsx)(Us,{className:`w-4 h-4`}),c(`common.humidity`,`Humidity`)]}),(0,K.jsxs)(`button`,{onClick:()=>f(`temperature`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${d===`temperature`?`bg-orange-600 text-white`:``}`,style:d===`temperature`?void 0:{color:V},children:[(0,K.jsx)(vu,{className:`w-4 h-4`}),c(`common.temperature`,`Temperature`)]})]}),(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:R},children:sU.map(e=>(0,K.jsx)(`button`,{onClick:()=>u(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${l===e.value?`bg-bambu-green text-white`:``}`,style:l===e.value?void 0:{color:V},children:e.label},e.value))})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:d===`humidity`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:F(k)},children:k==null?`—`:`${k}%`}),(0,K.jsx)(P,{trend:M})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:B},children:g?.avg_humidity==null?`—`:`${g.avg_humidity}%`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-green-500`,children:g?.min_humidity==null?`—`:`${g.min_humidity}%`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:g?.max_humidity==null?`—`:`${g.max_humidity}%`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:I(A)},children:A==null?`—`:`${A}°C`}),(0,K.jsx)(P,{trend:N})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:B},children:g?.avg_temperature==null?`—`:`${g.avg_temperature}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-blue-500`,children:g?.min_temperature==null?`—`:`${g.min_temperature}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:g?.max_temperature==null?`—`:`${g.max_temperature}°C`})]})]})}),(0,K.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:R},children:_?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:c(`common.loading`,`Loading...`)}):v?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center text-red-500`,children:c(`common.error`,`Error loading data`)}):C.length===0?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:c(`common.noData`,`No data available for this time range`)}):(0,K.jsx)(pA,{width:`100%`,height:300,children:(0,K.jsxs)($H,{data:C,children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:z}),(0,K.jsx)(gH,{dataKey:`time`,type:`number`,domain:[Date.now()-h*60*60*1e3,Date.now()],tickFormatter:e=>{let t=new Date(e);return h>24?t.toLocaleDateString([],{day:`numeric`,month:`short`}):t.toLocaleTimeString([],_f({hour:`2-digit`,minute:`2-digit`},m))},stroke:ee,tick:{fontSize:12}}),(0,K.jsx)(xH,{stroke:ee,tick:{fontSize:12},domain:d===`humidity`?[0,100]:[`auto`,`auto`],tickFormatter:e=>d===`humidity`?`${e}%`:`${e}°C`}),(0,K.jsx)(cz,{contentStyle:{backgroundColor:L,border:`1px solid ${z}`,borderRadius:`8px`,color:B},labelFormatter:e=>new Date(e).toLocaleString(void 0,_f({year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},m)),formatter:e=>[d===`humidity`?`${e??0}%`:`${e??0}°C`,d===`humidity`?`Humidity`:`Temperature`]}),(0,K.jsx)(dj,{}),d===`humidity`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uV,{y:w,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,K.jsx)(uV,{y:T,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(uV,{y:E,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,K.jsx)(uV,{y:D,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}),(0,K.jsx)(PV,{type:`monotone`,dataKey:d,name:d===`humidity`?`Humidity`:`Temperature`,stroke:d===`humidity`?`#3b82f6`:`#f97316`,strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0})]})})}),(0,K.jsx)(`div`,{className:`text-xs text-center`,style:{color:V},children:c(`amsHistory.recordingInfo`,`Data is recorded every 5 minutes while the printer is connected`)})]})]})})}function cU({checked:e,onChange:t,disabled:n}){return(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:n,onClick:r=>{r.preventDefault(),r.stopPropagation(),n||t(!e)},className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?`bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50`:e?`bg-bambu-green cursor-pointer`:`bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80`}`,children:(0,K.jsx)(`span`,{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${e?`translate-x-4`:`translate-x-0`}`})})}function ROe(e,t,n){let r=n===1||e>=128,i=e>=128?e-128:e,a=String.fromCharCode(65+i);return r?`HT·${t+1}`:`${a}·${t+1}`}function zOe(e){let t=(e||``).replace(`#`,``).slice(0,6);if(t.length!==6)return`#FFFFFF`;let n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);return[n,r,i].some(Number.isNaN)?`#FFFFFF`:(.2126*n+.7152*r+.0722*i)/255>.55?`#1A1A1A`:`#FFFFFF`}function BOe({group:e,trayCountByAms:t,innerBg:n,textPrimary:r,textSecondary:i,showExtruderBadge:a,extruderLabel:o}){let s=Of(e.trayColor||void 0),c=zOe(e.trayColor),l=c===`#FFFFFF`?`rgba(0,0,0,0.45)`:`rgba(255,255,255,0.7)`,u=e.members.length;return(0,K.jsxs)(`div`,{className:`relative flex flex-col items-center`,children:[a&&(0,K.jsx)(`span`,{className:`absolute -top-1 -left-1 z-10 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shadow`,style:{backgroundColor:r,color:n},"aria-label":o,title:o,children:o}),(0,K.jsxs)(`svg`,{viewBox:`-100 -100 200 200`,className:`w-44 h-44`,children:[(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`95`,fill:`none`,stroke:i,strokeOpacity:`0.25`,strokeWidth:`1`}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`92`,fill:s}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:n}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:`none`,stroke:i,strokeOpacity:`0.3`,strokeWidth:`1`}),(0,K.jsx)(`text`,{x:`0`,y:`-4`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`14`,fontWeight:`700`,fill:r,children:e.displayName||`—`}),(0,K.jsx)(`text`,{x:`0`,y:`16`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`11`,fontWeight:`500`,fill:i,children:`${u}× ↻`}),e.members.map((e,n)=>{let r=(n*360/u-90)*Math.PI/180,i=76*Math.cos(r),a=76*Math.sin(r),o=ROe(e.amsId,e.slotIdx,t.get(e.amsId)??4),s=Math.max(22,o.length*7+8);return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{x:i-s/2,y:a-9,width:s,height:18,rx:9,ry:9,fill:l}),(0,K.jsx)(`text`,{x:i,y:a,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`12`,fontWeight:`700`,fill:c,children:o})]},`${e.amsId}-${e.slotIdx}`)})]})]})}function VOe({isOpen:e,state:t,amsUnits:n,amsExtruderMap:r,isDualNozzle:i,canToggle:a,pending:o,onToggle:s,onClose:c}){let{t:l}=W();if((0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,c]),!e)return null;let u=`var(--bg-secondary)`,d=`var(--border-color)`,f=`var(--text-primary)`,p=`var(--text-secondary)`,m=(()=>{if(!i||!r)return!1;let e=new Set;for(let t of n||[]){let n=r[String(t.id)];if(n!==void 0&&(e.add(Number(n)),e.size>1))return!0}return!1})(),h=Qf(n,r,m),g=new Map((n||[]).map(e=>[e.id,e.tray.length])),_=h.filter(e=>e.members.length>=2),v=t===!0,b=t===null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:c,"data-testid":`ams-backup-modal`,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-2xl max-h-[90vh] overflow-hidden shadow-xl flex flex-col`,style:{backgroundColor:u},onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`ams-backup-modal-title`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:d},children:[(0,K.jsx)(`h2`,{id:`ams-backup-modal-title`,className:`text-base font-semibold`,style:{color:f},children:l(`printers.amsBackup.modalTitle`)}),(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`p-1 rounded-md transition-colors hover:bg-black/10`,style:{color:p},"aria-label":l(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:d,backgroundColor:`var(--bg-primary)`},children:[(0,K.jsxs)(`div`,{className:`min-w-0 mr-3`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,style:{color:f},children:l(b?`printers.amsBackup.stateUnknown`:v?`printers.amsBackup.stateOn`:`printers.amsBackup.stateOff`)}),(0,K.jsx)(`p`,{className:`text-xs mt-0.5`,style:{color:p},children:l(`printers.amsBackup.modalHelp`)})]}),(0,K.jsx)(cU,{checked:v,onChange:s,disabled:!a||b||o})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-6`,children:_.length===0?(0,K.jsx)(`p`,{className:`text-sm text-center py-8`,style:{color:p},children:l(`printers.amsBackup.modalNoPairs`)}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6 justify-items-center`,children:_.map(e=>(0,K.jsx)(BOe,{group:e,trayCountByAms:g,innerBg:u,textPrimary:f,textSecondary:p,showExtruderBadge:m,extruderLabel:e.extruder===0?l(`printers.amsBackup.extruderRightShort`):l(`printers.amsBackup.extruderLeftShort`)},e.key))})})]})})}var lU=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}],uU={nozzle:`#fb923c`,nozzle_2:`#f97316`,bed:`#60a5fa`,chamber:`#34d399`},HOe={nozzle:`#fed7aa`,nozzle_2:`#fdba74`,bed:`#bfdbfe`,chamber:`#a7f3d0`};function UOe({isOpen:e,onClose:t,printerId:n,printerName:r,initialKind:i=`nozzle`,availableKinds:a=[`nozzle`,`bed`,`chamber`]}){let{t:o}=W(),[s,c]=(0,y.useState)(`24h`),[l,u]=(0,y.useState)(i);(0,y.useEffect)(()=>{u(i)},[i]);let{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings}),f=d?.time_format||`system`;(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let p=lU.find(e=>e.value===s)?.hours||24,{data:m,isLoading:h,error:g}=q({queryKey:[`printer-sensor-history`,n,p,a.join(`,`)],queryFn:()=>Q.getPrinterSensorHistory(n,p,a),enabled:e,refetchInterval:6e4});if(!e)return null;let _=m?.series.find(e=>e.sensor_kind===l),v=(_?.data||[]).map(e=>({time:(vf(e.recorded_at)||new Date).getTime(),value:e.value,target:e.target})),b=Date.now()-p*60*60*1e3,x=Date.now(),S=[...v];if(S.length>0){let e=S[0];e.time>b&&S.unshift({...e,time:b});let t=S[S.length-1];t.time{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`})(S.map(e=>e.value)),D=({trend:e})=>e===`up`?(0,K.jsx)(Su,{className:`w-4 h-4 text-red-400`}):e===`down`?(0,K.jsx)(xu,{className:`w-4 h-4 text-green-400`}):(0,K.jsx)(al,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),O=`var(--bg-secondary)`,k=`var(--bg-primary)`,A=`var(--border-color)`,j=`var(--text-primary)`,M=`var(--text-secondary)`,N=`var(--text-muted)`,P=e=>{switch(e){case`nozzle`:return o(`printers.heaterHistory.nozzle`,`Nozzle`);case`nozzle_2`:return o(`printers.heaterHistory.nozzle2`,`Nozzle 2`);case`bed`:return o(`printers.heaterHistory.bed`,`Bed`);case`chamber`:return o(`printers.heaterHistory.chamber`,`Chamber`)}},F=({k:e})=>e===`nozzle`||e===`nozzle_2`?(0,K.jsx)(ac,{className:`w-4 h-4`}):e===`bed`?(0,K.jsx)(ou,{className:`w-4 h-4`}):(0,K.jsx)(Wo,{className:`w-4 h-4`});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:O},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:A},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,style:{color:j},children:o(`printers.heaterHistory.title`,`Heater History`)}),(0,K.jsx)(`p`,{className:`text-sm`,style:{color:M},children:r})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:M},"aria-label":o(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:k},children:a.map(e=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${l===e?`text-white`:``}`,style:l===e?{backgroundColor:uU[e]}:{color:M},children:[(0,K.jsx)(F,{k:e}),P(e)]},e))}),(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:k},children:lU.map(e=>(0,K.jsx)(`button`,{onClick:()=>c(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${s===e.value?`bg-bambu-green text-white`:``}`,style:s===e.value?void 0:{color:M},children:e.label},e.value))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:uU[l]},children:w==null?`—`:`${Math.round(w)}°C`}),(0,K.jsx)(D,{trend:E})]}),T!=null&&T>0&&(0,K.jsxs)(`p`,{className:`text-xs mt-1`,style:{color:M},children:[o(`common.target`,`Target`),`: `,Math.round(T),`°C`]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.avg_value==null?`—`:`${_.avg_value}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.min_value==null?`—`:`${Math.round(_.min_value)}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.max_value==null?`—`:`${Math.round(_.max_value)}°C`})]})]}),(0,K.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:h?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:M},children:o(`common.loading`,`Loading...`)}):g?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center text-red-400`,children:o(`printers.heaterHistory.error`,`Failed to load history`)}):S.length===0?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:M},children:o(`printers.heaterHistory.empty`,`No data recorded yet`)}):(0,K.jsx)(pA,{width:`100%`,height:300,children:(0,K.jsxs)($H,{data:S,margin:{top:5,right:10,left:0,bottom:5},children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:A}),(0,K.jsx)(gH,{dataKey:`time`,type:`number`,domain:[b,x],tickFormatter:e=>new Date(e).toLocaleTimeString([],_f({hour:`2-digit`,minute:`2-digit`},f)),stroke:N,fontSize:11}),(0,K.jsx)(xH,{stroke:N,fontSize:11,domain:[0,`auto`],tickFormatter:e=>`${Math.round(e)}°`}),(0,K.jsx)(cz,{contentStyle:{backgroundColor:O,border:`1px solid ${A}`,borderRadius:6,color:j},labelFormatter:e=>new Date(e).toLocaleString(void 0,_f({month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},f)),formatter:e=>e==null?`—`:`${Math.round(Number(e))}°C`}),(0,K.jsx)(dj,{}),(0,K.jsx)(PV,{type:`monotone`,dataKey:`value`,name:o(`common.current`,`Current`),stroke:uU[l],strokeWidth:2,dot:!1,isAnimationActive:!1}),(0,K.jsx)(PV,{type:`stepAfter`,dataKey:`target`,name:o(`common.target`,`Target`),stroke:HOe[l],strokeDasharray:`4 4`,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})]})]})})}function dU({data:e,children:t,disabled:n,className:r=``,spoolman:i,inventory:a,configureSlot:o,actions:s}){let{t:c}=W(),l=$n(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(`top`),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),x=(0,y.useRef)(null),S=(0,y.useRef)(null),C=(0,y.useRef)(null),w=()=>{let t=e.trayUuid;t&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(t).then(()=>{_(!0),setTimeout(()=>_(!1),2e3)}).catch(()=>{T(t)}):T(t))},T=e=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`),_(!0),setTimeout(()=>_(!1),2e3)}catch{console.error(`Failed to copy to clipboard`)}document.body.removeChild(t)};(0,y.useLayoutEffect)(()=>{if(!u){h(null);return}let e=()=>{if(!x.current||!S.current)return;let e=x.current.getBoundingClientRect(),t=S.current.offsetHeight,n=S.current.offsetWidth,r=e.top-56,i=window.innerHeight-e.bottom,a=rr?`bottom`:`top`,o=e.left+e.width/2,s=Math.max(8,Math.min(o-n/2,window.innerWidth-n-8)),c=a===`top`?e.top-t-8:e.bottom+8;p(a),h({top:c,left:s})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[u]);let E=()=>{n||(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>d(!0),80))},D=()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>d(!1),100)};(0,y.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]);let O=e=>e<=15?`#ef4444`:e<=30?`#f97316`:e<=50?`#eab308`:`#22c55e`,k=e.colorHex?`#${e.colorHex.replace(`#`,``)}`:null,A=a?.assignedSpool?.remainingWeightGrams??null;return(0,K.jsxs)(`div`,{ref:x,"data-testid":`filament-slot`,className:`relative ${r}`,onMouseEnter:E,onMouseLeave:D,children:[t,u&&(0,Op.createPortal)((0,K.jsxs)(`div`,{ref:S,className:`fixed z-[60]`,style:{top:m?.top??-9999,left:m?.left??-9999,maxWidth:`calc(100vw - 24px)`,visibility:m?`visible`:`hidden`},onMouseEnter:E,onMouseLeave:D,children:[(0,K.jsxs)(`div`,{className:` + ${x.x},${x.y}`,C=LE(e.id)?ME(`recharts-radial-line-`):e.id;return y.createElement(`text`,Bz({},r,{dominantBaseline:`central`,className:_T(`recharts-radial-bar-label`,o)}),y.createElement(`defs`,null,y.createElement(`path`,{id:C,d:S})),y.createElement(`textPath`,{xlinkHref:`#${C}`},n))},jxe=(e,t,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:s,endAngle:c}=e,l=(s+c)/2;if(n===`outside`){var{x:u,y:d}=lM(r,i,o+t,l);return{x:u,y:d,textAnchor:u>=r?`start`:`end`,verticalAnchor:`middle`}}if(n===`center`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`middle`};if(n===`centerTop`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`start`};if(n===`centerBottom`)return{x:r,y:i,textAnchor:`middle`,verticalAnchor:`end`};var{x:f,y:p}=lM(r,i,(a+o)/2,l);return{x:f,y:p,textAnchor:`middle`,verticalAnchor:`middle`}},Gz=e=>e!=null&&`cx`in e&&AE(e.cx),Mxe={angle:0,offset:5,zIndex:WF.label,position:`middle`,textBreakAll:!1};function Nxe(e){if(!Gz(e))return e;var{cx:t,cy:n,outerRadius:r}=e,i=r*2;return{x:t-r,y:n-r,width:i,upperWidth:i,lowerWidth:i,height:i}}function Kz(e){var t=XE(e,Mxe),{viewBox:n,parentViewBox:r,position:i,value:a,children:o,content:s,className:c=``,textBreakAll:l,labelRef:u}=t,d=Dxe(),f=Uz(),p=n==null?i===`center`?f:d??f:Gz(n)?n:hA(n),m,h,g=Nxe(p);if(!p||LE(a)&&LE(o)&&!(0,y.isValidElement)(s)&&typeof s!=`function`)return null;var _=zz(zz({},t),{},{viewBox:p});if((0,y.isValidElement)(s)){var{labelRef:v}=_;return(0,y.cloneElement)(s,Lz(_,bxe))}if(typeof s==`function`){var{content:b}=_;if(m=(0,y.createElement)(s,Lz(_,xxe)),(0,y.isValidElement)(m))return m}else m=Oxe(t);var x=CT(t);if(Gz(p)){if(i===`insideStart`||i===`insideEnd`||i===`end`)return Axe(t,i,m,x,p);h=jxe(p,t.offset,t.position)}else{if(!g)return null;var S=yxe({viewBox:g,position:i,offset:t.offset,parentViewBox:Gz(r)?void 0:r,clamp:!0});h=zz(zz({x:S.x,y:S.y,textAnchor:S.horizontalAnchor,verticalAnchor:S.verticalAnchor},S.width===void 0?{}:{width:S.width}),S.height===void 0?{}:{height:S.height})}return y.createElement(KR,{zIndex:t.zIndex},y.createElement(Pz,Bz({ref:u,className:_T(`recharts-label`,c)},x,h,{textAnchor:dxe(x.textAnchor)?x.textAnchor:h.textAnchor,breakAll:l}),m))}Kz.displayName=`Label`;var Pxe=(e,t,n)=>{if(!e)return null;var r={viewBox:t,labelRef:n};return e===!0?y.createElement(Kz,Bz({key:`label-implicit`},r)):jE(e)?y.createElement(Kz,Bz({key:`label-implicit`,value:e},r)):(0,y.isValidElement)(e)?e.type===Kz?(0,y.cloneElement)(e,zz({key:`label-implicit`},r)):y.createElement(Kz,Bz({key:`label-implicit`,content:e},r)):Wz(e)?y.createElement(Kz,Bz({key:`label-implicit`,content:e},r)):e&&typeof e==`object`?y.createElement(Kz,Bz({},e,{key:`label-implicit`},r)):null};function qz(e){var{label:t,labelRef:n}=e;return Pxe(t,Uz(),n)||null}var Fxe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return e[e.length-1]}e.last=t})),Ixe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return Array.isArray(e)?e:Array.from(e)}e.toArray=t})),Lxe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Fxe(),n=Ixe(),r=tD();function i(e){if(r.isArrayLike(e))return t.last(n.toArray(e))}e.last=i})),Rxe=l(o(((e,t)=>{t.exports=Lxe().last}))()),zxe=[`valueAccessor`],Bxe=[`dataKey`,`clockWise`,`id`,`textBreakAll`,`zIndex`];function Jz(){return Jz=Object.assign?Object.assign.bind():function(e){for(var t=1;tArray.isArray(e.value)?(0,Rxe.default)(e.value):e.value,Xz=(0,y.createContext)(void 0),Zz=Xz.Provider,Qz=(0,y.createContext)(void 0),Uxe=Qz.Provider;function Wxe(){return(0,y.useContext)(Xz)}function Gxe(){return(0,y.useContext)(Qz)}function $z(e){var{valueAccessor:t=Hxe}=e,n=Yz(e,zxe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:s}=n,c=Yz(n,Bxe),l=Wxe(),u=Gxe(),d=l||u;return!d||!d.length?null:y.createElement(KR,{zIndex:s??WF.label},y.createElement(DT,{className:`recharts-label-list`},d.map((e,i)=>{var s=LE(r)?t(e,i):Pk(e.payload,r),l=LE(a)?{}:{id:`${a}-${i}`};return y.createElement(Kz,Jz({key:`label-${i}`},CT(e),c,l,{fill:n.fill??e.fill,parentViewBox:e.parentViewBox,value:s,textBreakAll:o,viewBox:e.viewBox,index:i,zIndex:0}))})))}$z.displayName=`LabelList`;function eB(e){var{label:t}=e;return t?t===!0?y.createElement($z,{key:`labelList-implicit`}):y.isValidElement(t)||Wz(t)?y.createElement($z,{key:`labelList-implicit`,content:t}):typeof t==`object`?y.createElement($z,Jz({key:`labelList-implicit`},t,{type:String(t.type)})):null:null}function tB(){return tB=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{cx:t,cy:n,r,className:i}=e,a=_T(`recharts-dot`,i);return AE(t)&&AE(n)&&AE(r)?y.createElement(`circle`,tB({},xT(e),qE(e),{className:a,cx:t,cy:n,r})):null},rB=e=>e.graphicalItems.polarItems,iB=xD([rB,jI,xD([cI,lI],PI)],II),aB=xD([xD([iB],BI),wF],VI),Kxe=xD([aB,jI,iB],UI);xD([aB,jI,iB],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:Pk(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:Pk(e,t.dataKey),errorDomain:[]})));var oB=()=>void 0,sB=xD([jI,bA,aB,Kxe,RF,cI,xD([jI,tL,nL,oB,xD([aB,jI,iB,rL,cI],aL),oB,bA,cI],pL)],mL);xD([_L,xD([jI,sB,xD([sB,MI,_L],yL),cI],xL)],yI);var cB=tk({name:`polarAxis`,initialState:{radiusAxis:{},angleAxis:{}},reducers:{addRadiusAxis(e,t){e.radiusAxis[t.payload.id]=cj(t.payload)},removeRadiusAxis(e,t){delete e.radiusAxis[t.payload.id]},addAngleAxis(e,t){e.angleAxis[t.payload.id]=cj(t.payload)},removeAngleAxis(e,t){delete e.angleAxis[t.payload.id]}}}),{addRadiusAxis:qxe,removeRadiusAxis:Jxe,addAngleAxis:Yxe,removeAngleAxis:Xxe}=cB.actions,Zxe=cB.reducer;function lB(e){return e&&typeof e==`object`&&`className`in e&&typeof e.className==`string`?e.className:``}function uB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function dB(e){for(var t=1;tt],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),tSe=[],pB=(e,t,n)=>n?.length===0?tSe:n,mB=xD([wF,fB,pB],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>dB(dB({},t.presentationProps),e.props))),i!=null)return i}}),nSe=xD([mB,fB,pB],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=Pk(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:Gk(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),rSe=xD([mB,fB,pB,eA],(e,t,n,r)=>{if(!(t==null||e==null))return iCe({offset:r,pieSettings:t,displayedData:e,cells:n})}),iSe=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.suspense_list`),d=Symbol.for(`react.memo`),f=Symbol.for(`react.lazy`),p=Symbol.for(`react.view_transition`);function m(e){if(typeof e==`object`&&e){var m=e.$$typeof;switch(m){case t:switch(e=e.type,e){case r:case a:case i:case l:case u:case p:return e;default:switch(e&&=e.$$typeof,e){case s:case c:case f:case d:return e;case o:return e;default:return m}}case n:return m}}}e.isFragment=function(e){return m(e)===r}})),aSe=o(((e,t)=>{t.exports=iSe()}))(),hB=e=>typeof e==`string`?e:e?e.displayName||e.name||`Component`:``,gB=null,_B=null,vB=e=>{if(e===gB&&Array.isArray(_B))return _B;var t=[];return y.Children.forEach(e,e=>{LE(e)||((0,aSe.isFragment)(e)?t=t.concat(vB(e.props.children)):t.push(e))}),_B=t,gB=e,t};function yB(e,t){var n=[],r=[];return r=Array.isArray(t)?t.map(e=>hB(e)):[hB(t)],vB(e).forEach(e=>{var t=(0,EE.default)(e,`type.displayName`)||(0,EE.default)(e,`type.name`);t&&r.indexOf(t)!==-1&&n.push(e)}),n}var bB=e=>e&&typeof e==`object`&&`clipDot`in e?!!e.clipDot:!0,oSe=o((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){if(typeof e!=`object`||!e)return!1;if(Object.getPrototypeOf(e)===null)return!0;if(Object.prototype.toString.call(e)!==`[object Object]`){let t=e[Symbol.toStringTag];return t==null||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable?!1:e.toString()===`[object ${t}]`}let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}e.isPlainObject=t})),sSe=o(((e,t)=>{t.exports=oSe().isPlainObject})),cSe,lSe,uSe,dSe,fSe;function xB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function SB(e){for(var t=1;t{var a=n-r,o=TE(cSe||=wB([`M `,`,`,``]),e,t);return o+=TE(lSe||=wB([`L `,`,`,``]),e+n,t),o+=TE(uSe||=wB([`L `,`,`,``]),e+n-a/2,t+i),o+=TE(dSe||=wB([`L `,`,`,``]),e+n-a/2-r,t+i),o+=TE(fSe||=wB([`L `,`,`,` Z`]),e,t),o},gSe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:`ease`},_Se=e=>{var t=XE(e,gSe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:s}=t,{animationEasing:c,animationDuration:l,animationBegin:u,isUpdateAnimationActive:d}=t,f=(0,y.useRef)(null),[p,m]=(0,y.useState)(-1),h=(0,y.useRef)(i),g=(0,y.useRef)(a),_=(0,y.useRef)(o),v=(0,y.useRef)(n),b=(0,y.useRef)(r),x=Zj(e,`trapezoid-`);if((0,y.useEffect)(()=>{if(f.current&&f.current.getTotalLength)try{var e=f.current.getTotalLength();e&&m(e)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var S=_T(`recharts-trapezoid`,s);if(!d)return y.createElement(`g`,null,y.createElement(`path`,CB({},CT(t),{className:S,d:TB(n,r,i,a,o)})));var C=h.current,w=g.current,T=_.current,E=v.current,D=b.current,O=`0px ${p===-1?1:p}px`,k=`${p}px 0px`,A=Lj([`strokeDasharray`],l,c);return y.createElement(Xj,{animationId:x,key:x,canBegin:p>0,duration:l,easing:c,isActive:d,begin:u},e=>{var s=FE(C,i,e),c=FE(w,a,e),l=FE(T,o,e),u=FE(E,n,e),d=FE(D,r,e);f.current&&(h.current=s,g.current=c,_.current=l,v.current=u,b.current=d);var p=e>0?{transition:A,strokeDasharray:k}:{strokeDasharray:O};return y.createElement(`path`,CB({},CT(t),{className:S,d:TB(u,d,s,c,l),ref:f,style:SB(SB({},p),t.style)}))})},vSe=l(sSe()),ySe=[`option`,`shapeType`,`activeClassName`];function bSe(e,t){if(e==null)return{};var n,r,i=xSe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var r=mD();return(i,a)=>o=>{e?.(i,a,o),r(JL({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},jB=e=>{var t=mD();return(n,r)=>i=>{e?.(n,r,i),t(aye())}},MB=(e,t,n)=>{var r=mD();return(i,a)=>o=>{e?.(i,a,o),r(oye({activeIndex:String(a),activeDataKey:t,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function NB(e){var{tooltipEntrySettings:t}=e,n=mD(),r=nA(),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r||(i.current===null?n(tye(t)):i.current!==t&&n(nye({prev:i.current,next:t})),i.current=t)},[t,n,r]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(rye(i.current)),null)},[n]),null}function PB(e){var{legendPayload:t}=e,n=mD(),r=nA(),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r||(i.current===null?n(Cpe(t)):i.current!==t&&n(wpe({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(Tpe(i.current)),null)},[n]),null}function OSe(e){var{legendPayload:t}=e,n=mD(),r=gD(bA),i=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{r!==`centric`&&r!==`radial`||(i.current===null?n(Cpe(t)):i.current!==t&&n(wpe({prev:i.current,next:t})),i.current=t)},[n,r,t]),(0,y.useLayoutEffect)(()=>()=>{i.current&&=(n(Tpe(i.current)),null)},[n]),null}var kSe=y.useId??(()=>{var[e]=y.useState(()=>ME(`uid-`));return e});function ASe(e,t){var n=kSe();return t||(e?`${e}-${n}`:n)}var jSe=(0,y.createContext)(void 0),FB=e=>{var{id:t,type:n,children:r}=e,i=ASe(`recharts-${n}`,t);return y.createElement(jSe.Provider,{value:i},r(i))},IB=tk({name:`graphicalItems`,initialState:{cartesianItems:[],polarItems:[]},reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(cj(t.payload))},prepare:ZO()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:n,next:r}=t.payload,i=HO(e).cartesianItems.indexOf(cj(n));i>-1&&(e.cartesianItems[i]=cj(r))},prepare:ZO()},removeCartesianGraphicalItem:{reducer(e,t){var n=HO(e).cartesianItems.indexOf(cj(t.payload));n>-1&&e.cartesianItems.splice(n,1)},prepare:ZO()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(cj(t.payload))},prepare:ZO()},removePolarGraphicalItem:{reducer(e,t){var n=HO(e).polarItems.indexOf(cj(t.payload));n>-1&&e.polarItems.splice(n,1)},prepare:ZO()}}}),{addCartesianGraphicalItem:MSe,replaceCartesianGraphicalItem:NSe,removeCartesianGraphicalItem:PSe,addPolarGraphicalItem:FSe,removePolarGraphicalItem:ISe}=IB.actions,LSe=IB.reducer,LB=(0,y.memo)(e=>{var t=mD(),n=(0,y.useRef)(null);return(0,y.useLayoutEffect)(()=>{n.current===null?t(MSe(e)):n.current!==e&&t(NSe({prev:n.current,next:e})),n.current=e},[t,e]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(PSe(n.current)),null)},[t]),null});function RSe(e){var t=mD();return(0,y.useLayoutEffect)(()=>(t(FSe(e)),()=>{t(ISe(e))}),[t,e]),null}var zSe=[`key`],BSe=[`onMouseEnter`,`onClick`,`onMouseLeave`],VSe=[`id`],HSe=[`id`];function RB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function zB(e){for(var t=1;tyB(e.children,uz),[e.children]),n=gD(n=>nSe(n,e.id,t));return n==null?null:y.createElement(OSe,{legendPayload:n})}var JSe=y.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:r.map(e=>e.tooltipPayload),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:Gk(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return y.createElement(NB,{tooltipEntrySettings:d})}),YSe=(e,t)=>e>t?`start`:eNE(typeof t==`function`?t(e):t,n,n*.8),ZSe=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=uM(a,o);return{cx:i+NE(e.cx,a,a/2),cy:r+NE(e.cy,o,o/2),innerRadius:NE(e.innerRadius,s,0),outerRadius:XSe(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},QSe=(e,t)=>DE(t-e)*Math.min(Math.abs(t-e),360),$Se=(e,t)=>{if(y.isValidElement(e))return y.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=_T(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=VB(t,zSe);return y.createElement(Mj,BB({},i,{type:`linear`,className:n}))},eCe=(e,t,n)=>{if(y.isValidElement(e))return y.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),y.isValidElement(r)))return r;var i=_T(`recharts-pie-label-text`,lB(e));return y.createElement(Pz,BB({},t,{alignmentBaseline:`middle`,className:i}),r)};function tCe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=xT(n),c=ST(i),l=ST(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=lM(e.cx,e.cy,e.outerRadius+u,n),d=zB(zB(zB(zB({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:YSe(r.x,e.cx)},r),f=zB(zB(zB(zB({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[lM(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return y.createElement(KR,{zIndex:WF.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},y.createElement(DT,null,a&&$Se(a,f),eCe(i,d,Pk(e,o))))});return y.createElement(DT,{className:`recharts-pie-labels`},d)}function nCe(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?y.createElement(eB,{label:i}):y.createElement(tCe,{sectors:t,props:n,showLabels:r})}function rCe(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=gD(TR),c=gD(DR),l=gD(Oye),{onMouseEnter:u,onClick:d,onMouseLeave:f}=i,p=VB(i,BSe),m=AB(u,i.dataKey,o),h=jB(f),g=MB(d,i.dataKey,o);return t==null||t.length===0?null:y.createElement(y.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,_=n&&f?n:s?r:null,v=zB(zB({},e),{},{stroke:e.stroke,tabIndex:-1,[Zk]:u,[jfe]:o});return y.createElement(DT,BB({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},JE(p,e,u),{onMouseEnter:m(e,u),onMouseLeave:h(e,u),onClick:g(e,u)}),y.createElement(kB,BB({option:a??_,index:u,shapeType:`sector`,isActive:f},v)))}))}function iCe(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=QSe(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>Pk(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=p-h*d-g,v=n.reduce((e,t)=>{var n=Pk(t,c,0);return e+(AE(n)?n:0)},0),y;if(v>0){var b;y=n.map((e,n)=>{var s=Pk(e,c,0),p=Pk(e,l,n),h=ZSe(t,i,e),g=(AE(s)?s:0)/v,y,x=zB(zB({},e),r&&r[n]&&r[n].props);y=n?b.endAngle+DE(f)*m*(s===0?0:1):o;var S=y+DE(f)*((s===0?0:d)+g*_),C=(y+S)/2,w=(h.innerRadius+h.outerRadius)/2,T=[{name:p,value:s,payload:x,dataKey:c,type:u,graphicalItemId:t.id}],E=lM(h.cx,h.cy,w,C);return b=zB(zB(zB(zB({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:T,midAngle:C,middleRadius:w,tooltipPosition:E},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:S,payload:x,paddingAngle:DE(f)*m}),b})}return y}function aCe(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,y.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return y.createElement(Uxe,{value:t?i:void 0},r)}function oCe(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=Zj(t,`recharts-pie-`),m=n.current,[h,g]=(0,y.useState)(!1),_=(0,y.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,y.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return y.createElement(aCe,{showLabels:!h,sectors:i},y.createElement(Xj,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,EE.default)(t,`paddingAngle`,0):0;if(r){var s=FE(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=zB(zB({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=FE(0,l-u,e),f=zB(zB({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,y.createElement(DT,null,y.createElement(rCe,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),y.createElement(nCe,{showLabels:!h,sectors:i,props:t}),t.children)}var sCe={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:WF.area};function cCe(e){var{id:t}=e,n=VB(e,VSe),{hide:r,className:i,rootTabIndex:a}=e,o=(0,y.useMemo)(()=>yB(e.children,uz),[e.children]),s=gD(e=>rSe(e,t,o)),c=(0,y.useRef)(null),l=_T(`recharts-pie`,i);return r||s==null?(c.current=null,y.createElement(DT,{tabIndex:a,className:l})):y.createElement(KR,{zIndex:e.zIndex},y.createElement(JSe,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t}),y.createElement(DT,{tabIndex:a,className:l},y.createElement(oCe,{props:zB(zB({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function HB(e){var t=XE(e,sCe),{id:n}=t,r=VB(t,HSe),i=xT(r);return y.createElement(FB,{id:n,type:`pie`},e=>y.createElement(y.Fragment,null,y.createElement(RSe,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),y.createElement(qSe,BB({},r,{id:e})),y.createElement(cCe,BB({},r,{id:e}))))}HB.displayName=`Pie`;var lCe=[`points`];function UB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function WB(e){for(var t=1;t{var s=WB(WB(WB({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return y.createElement(hCe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),y.createElement(KR,{zIndex:l},y.createElement(DT,GB({className:r},p),f))}function qB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function JB(e){for(var t=1;t({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),Kk,qk],(e,t,n)=>{if(!(!e||t==null||n==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,n-e.top-e.bottom)}}),XB=()=>gD(jCe),MCe=()=>gD(jye);function ZB(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function QB(e){for(var t=1;t{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=QB(QB(QB({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),ST(i)),qE(i)),c=(0,y.isValidElement)(i)?(0,y.cloneElement)(i,s):typeof i==`function`?i(s):y.createElement(nB,s);return y.createElement(DT,{className:`recharts-active-dot`,clipPath:o},c)};function $B(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=WF.activeDot}=e,s=gD(TR),c=MCe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return LE(l)?null:y.createElement(KR,{zIndex:o},y.createElement(ICe,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var eV=(e,t,n)=>{var r=n??e;if(!LE(r))return NE(r,t,0)},LCe=(e,t,n)=>{var r={},i=e.filter(fI),a=e.filter(e=>e.stackId==null),o=i.reduce((e,t)=>{var n=e[t.stackId];return n??=[],n.push(t),e[t.stackId]=n,e},r),s=Object.entries(o).map(e=>{var[r,i]=e;return{stackId:r,dataKeys:i.map(e=>e.dataKey),barSize:eV(t,n,i[0]?.barSize)}}),c=a.map(e=>({stackId:void 0,dataKeys:[e.dataKey].filter(e=>e!=null),barSize:eV(t,n,e.barSize)}));return[...s,...c]};function tV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function nV(e){for(var t=1;te+(t.barSize||0),0);d+=(a-1)*o,d>=n&&(d-=(a-1)*o,o=0),d>=n&&u>0&&(l=!0,u*=.9,d=a*u);var f={offset:((n-d)/2>>0)-o,size:0};s=r.reduce((e,t)=>{var n={stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:f.offset+f.size+o,size:l?u:t.barSize??0}},r=[...e,n];return f=n.position,r},c)}else{var p=NE(t,n,0,!0);n-2*p-(a-1)*o<=0&&(o=0);var m=(n-2*p-(a-1)*o)/a;m>1&&(m>>=0);var h=Ak(i)?Math.min(m,i):m;s=r.reduce((e,t,n)=>[...e,{stackId:t.stackId,dataKeys:t.dataKeys,position:{offset:p+(m+o)*n+(m-h)/2,size:h}}],c)}return s}}var HCe=(e,t,n,r,i,a,o)=>{var s=LE(o)?t:o,c=VCe(n,r,i===a?a:i,e,s);return i!==a&&c!=null&&(c=c.map(e=>nV(nV({},e),{},{position:nV(nV({},e.position),{},{offset:e.position.offset-i/2})}))),c},UCe=(e,t)=>{var n=uI(t);if(!(!e||n==null||t==null)){var{stackId:r}=t;if(r!=null){var i=e[r];if(i){var{stackedData:a}=i;if(a)return a.find(e=>e.key===n)}}}},WCe=(e,t)=>{if(!(e==null||t==null)){var n=e.find(e=>e.stackId===t.stackId&&t.dataKey!=null&&e.dataKeys.includes(t.dataKey));if(n!=null)return n.position}};function GCe(e,t){return e&&typeof e==`object`&&`zIndex`in e&&typeof e.zIndex==`number`&&Ak(e.zIndex)?e.zIndex:t}var rV=e=>{var{chartData:t}=e,n=mD(),r=nA();return(0,y.useEffect)(()=>r?()=>{}:(n(rz(t)),()=>{n(rz(void 0))}),[t,n,r]),null},iV={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},aV=tk({name:`brush`,initialState:iV,reducers:{setBrushSettings(e,t){return t.payload==null?iV:t.payload}}}),{setBrushSettings:KCe}=aV.actions,qCe=aV.reducer,JCe=(e,t)=>{var{x:n,y:r}=e,{x:i,y:a}=t;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},YCe=e=>{var{x1:t,y1:n,x2:r,y2:i}=e;return JCe({x:t,y:n},{x:r,y:i})};function XCe(e){return(e%180+180)%180}var ZCe=function(e){var{width:t,height:n}=e,r=XCe(arguments.length>1&&arguments[1]!==void 0?arguments[1]:0)*Math.PI/180,i=Math.atan(n/t),a=r>i&&r{e.dots.push(t.payload)},removeDot:(e,t)=>{var n=HO(e).dots.findIndex(e=>e===t.payload);n!==-1&&e.dots.splice(n,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var n=HO(e).areas.findIndex(e=>e===t.payload);n!==-1&&e.areas.splice(n,1)},addLine:(e,t)=>{e.lines.push(cj(t.payload))},removeLine:(e,t)=>{var n=HO(e).lines.findIndex(e=>e===t.payload);n!==-1&&e.lines.splice(n,1)}}}),{addDot:QCe,removeDot:$Ce,addArea:ewe,removeArea:twe,addLine:nwe,removeLine:rwe}=oV.actions,iwe=oV.reducer,sV=(0,y.createContext)(void 0),awe=e=>{var{children:t}=e,[n]=(0,y.useState)(`${ME(`recharts`)}-clip`),r=XB();if(r==null)return null;var{x:i,y:a,width:o,height:s}=r;return y.createElement(sV.Provider,{value:n},y.createElement(`defs`,null,y.createElement(`clipPath`,{id:n},y.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},owe=()=>(0,y.useContext)(sV),swe=class{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var{position:n}=t;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var{position:n,fallback:r}=t,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var{x:t,y:n}=e,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function cV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function lV(e){for(var t=1;t{var n;if(y.isValidElement(e))n=y.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!Ak(t.x1)||!Ak(t.y1)||!Ak(t.x2)||!Ak(t.y2))return null;n=y.createElement(`line`,uV({},t,{className:`recharts-reference-line-line`}))}return n},fwe=(e,t,n,r,i,a)=>{var{x:o,width:s}=a,c=i.map(e,{position:n});if(!Ak(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},pwe=(e,t,n,r,i,a)=>{var{y:o,height:s}=a,c=i.map(e,{position:n});if(!Ak(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},mwe=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},hwe=(e,t,n,r,i,a,o)=>{var{x:s,y:c,segment:l,ifOverflow:u}=o,d=jE(s);return jE(c)?fwe(c,u,r,a,t,n):d?pwe(s,u,r,i,e,n):l!=null&&l.length===2?mwe(l,u,r,new swe({x:e,y:t})):null};function gwe(e){var t=mD();return(0,y.useEffect)(()=>(t(nwe(e)),()=>{t(rwe(e))})),null}function _we(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:a}=e,o=nA(),s=owe(),c=gD(e=>EI(e,t)),l=gD(e=>kI(e,n)),u=gD(e=>TL(e,`xAxis`,t,o)),d=gD(e=>TL(e,`yAxis`,n,o)),f=gA();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=hwe(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var{x:g,y:_}=m,{x:v,y:b}=h,x=lV(lV({clipPath:a===`hidden`?`url(#${s})`:void 0},CT(e)),{},{x1:g,y1:_,x2:v,y2:b}),S=YCe({x1:g,y1:_,x2:v,y2:b});return y.createElement(KR,{zIndex:e.zIndex},y.createElement(DT,{className:_T(`recharts-reference-line`,i)},dwe(r,x),y.createElement(Hz,uV({},S,{lowerWidth:S.width,upperWidth:S.width}),y.createElement(qz,{label:e.label}),e.children)))}var vwe={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:WF.line};function dV(e){var t=XE(e,vwe);return y.createElement(y.Fragment,null,y.createElement(gwe,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),y.createElement(_we,t))}dV.displayName=`ReferenceLine`;function fV(e,t){if(t<1)return[];if(t===1)return e;for(var n=[],r=0;re*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function xwe(e,t){return fV(e,t+1)}function Swe(e,t,n,r,i){for(var a=(r||[]).slice(),{start:o,end:s}=t,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:fV(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||pV(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function Cwe(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var{start:o,end:s}=t,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||pV(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=hV(hV({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=hV(hV({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&pV(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=hV(hV({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function Owe(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,{start:c,end:l}=t;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=hV(hV({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&pV(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=hV(hV({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=hV(hV({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=hV(hV({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&pV(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=hV(hV({},a),{},{isShow:!0}))},h=0;h{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?ywe(gz(i,{fontSize:t,letterSpacing:n}),m,d):gz(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?DE(_.coordinate-g.coordinate):1,y=bwe(a,v,p);return c===`equidistantPreserveStart`?Swe(v,y,h,i,o):c===`equidistantPreserveEnd`?Cwe(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?Owe(v,y,h,i,o,c===`preserveStartEnd`):Dwe(v,y,h,i,o),f.filter(e=>e.isShow))}var kwe=e=>{var{ticks:t,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=e,o=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>o&&(o=t.width)}});var s=n?n.getBoundingClientRect().width:0,c=i+a,l=o+c+s+(n?r:0);return Math.round(l)}return 0},Awe=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`];function jwe(e,t){if(e==null)return{};var n,r,i=Mwe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:s,padding:c,tickTextProps:l,orientation:u,mirror:d,x:f,y:p,width:m,height:h,tickSize:g,tickMargin:_,fontSize:v,letterSpacing:b,getTicksConfig:x,events:S,axisType:C}=e,w=gV(yV(yV({},x),{},{ticks:n}),v,b),T=Rwe(u,d),E=zwe(u,d),D=xT(x),O=ST(r),k={};typeof i==`object`&&(k=i);var A=yV(yV({},D),{},{fill:`none`},k),j=w.map(e=>yV({entry:e},Lwe(e,f,p,m,h,u,g,d,_))),M=j.map(e=>{var{entry:t,line:n}=e;return y.createElement(DT,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},i&&y.createElement(`line`,_V({},A,n,{className:_T(`recharts-cartesian-axis-tick-line`,(0,EE.default)(i,`className`))})))}),N=j.map((e,t)=>{var{entry:n,tick:i}=e,u=yV(yV({},yV(yV(yV(yV({verticalAnchor:E},D),{},{textAnchor:T,stroke:`none`,fill:a},i),{},{index:t,payload:n,visibleTicksCount:w.length,tickFormatter:o,padding:c},l),{},{angle:l?.angle??D.angle??0})),O);return y.createElement(DT,_V({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},JE(S,n,t)),r&&y.createElement(Bwe,{option:r,tickProps:u,value:`${typeof o==`function`?o(n.value,t):n.value}${s||``}`}))});return y.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${C}-ticks`},N.length>0&&y.createElement(KR,{zIndex:WF.label},y.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${C}-tick-labels`,ref:t},N)),M.length>0&&y.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${C}-tick-lines`},M))}),Hwe=(0,y.forwardRef)((e,t)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:s,axisType:c}=e,l=jwe(e,Awe),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),m=(0,y.useRef)(null);(0,y.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>kwe({ticks:m.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var h=(0,y.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);m.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==u||a!==f)&&(d(i),p(a))}}},[u,f]);return o||r!=null&&r<=0||i!=null&&i<=0?null:y.createElement(KR,{zIndex:e.zIndex},y.createElement(DT,{className:_T(`recharts-cartesian-axis`,a)},y.createElement(Iwe,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:xT(e)}),y.createElement(Vwe,{ref:h,axisType:c,events:l,fontSize:u,getTicksConfig:e,height:e.height,letterSpacing:f,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y}),y.createElement(Hz,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},y.createElement(qz,{label:e.label,labelRef:e.labelRef}),e.children)))}),xV=y.forwardRef((e,t)=>{var n=XE(e,bV);return y.createElement(Hwe,_V({},n,{ref:t}))});xV.displayName=`CartesianAxis`;var Uwe=[`x1`,`y1`,`x2`,`y2`,`key`],Wwe=[`offset`],Gwe=[`xAxisId`,`yAxisId`],Kwe=[`xAxisId`,`yAxisId`];function SV(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function CV(e){for(var t=1;t{var{fill:t}=e;if(!t||t===`none`)return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:s}=e;return y.createElement(`rect`,{x:r,y:i,ry:s,width:a,height:o,stroke:`none`,fill:t,fillOpacity:n,className:`recharts-cartesian-grid-bg`})};function EV(e){var{option:t,lineItemProps:n}=e,r;if(y.isValidElement(t))r=y.cloneElement(t,n);else if(typeof t==`function`)r=t(n);else{var{x1:i,y1:a,x2:o,y2:s,key:c}=n,l=xT(TV(n,Uwe))??{},{offset:u}=l,d=TV(l,Wwe);r=y.createElement(`line`,wV({},d,{x1:i,y1:a,x2:o,y2:s,fill:`none`,key:c}))}return r}function Qwe(e){var{x:t,width:n,horizontal:r=!0,horizontalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=TV(e,Gwe),c=i.map((e,i)=>{var a=CV(CV({},s),{},{x1:t,y1:e,x2:t+n,y2:e,key:`line-${i}`,index:i});return y.createElement(EV,{key:`line-${i}`,option:r,lineItemProps:a})});return y.createElement(`g`,{className:`recharts-cartesian-grid-horizontal`},c)}function $we(e){var{y:t,height:n,vertical:r=!0,verticalPoints:i}=e;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=e,s=TV(e,Kwe),c=i.map((e,i)=>{var a=CV(CV({},s),{},{x1:e,y1:t,x2:e,y2:t+n,key:`line-${i}`,index:i});return y.createElement(EV,{option:r,lineItemProps:a,key:`line-${i}`})});return y.createElement(`g`,{className:`recharts-cartesian-grid-vertical`},c)}function eTe(e){var{horizontalFill:t,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:s,horizontal:c=!0}=e;if(!c||!t||!t.length||s==null)return null;var l=s.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,s)=>{var c=l[s+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=s%t.length;return y.createElement(`rect`,{key:`react-${s}`,y:e,x:r,height:u,width:a,stroke:`none`,fill:t[d],fillOpacity:n,className:`recharts-cartesian-grid-bg`})});return y.createElement(`g`,{className:`recharts-cartesian-gridstripes-horizontal`},u)}function tTe(e){var{vertical:t=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:s,verticalPoints:c}=e;if(!t||!n||!n.length)return null;var l=c.map(e=>Math.round(e+i-i)).sort((e,t)=>e-t);i!==l[0]&&l.unshift(0);var u=l.map((e,t)=>{var c=l[t+1],u=c==null?i+o-e:c-e;if(u<=0)return null;var d=t%n.length;return y.createElement(`rect`,{key:`react-${t}`,x:e,y:a,width:u,height:s,stroke:`none`,fill:n[d],fillOpacity:r,className:`recharts-cartesian-grid-bg`})});return y.createElement(`g`,{className:`recharts-cartesian-gridstripes-vertical`},u)}var nTe=(e,t)=>{var{xAxis:n,width:r,height:i,offset:a}=e;return Ik(gV(CV(CV(CV({},bV),n),{},{ticks:Lk(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,t)},rTe=(e,t)=>{var{yAxis:n,width:r,height:i,offset:a}=e;return Ik(gV(CV(CV(CV({},bV),n),{},{ticks:Lk(n,!0),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,t)},iTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:`#ccc`,fill:`none`,verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:WF.grid};function DV(e){var t=vA(),n=yA(),r=_A(),i=CV(CV({},XE(e,iTe)),{},{x:AE(e.x)?e.x:r.left,y:AE(e.y)?e.y:r.top,width:AE(e.width)?e.width:r.width,height:AE(e.height)?e.height:r.height}),{xAxisId:a,yAxisId:o,x:s,y:c,width:l,height:u,syncWithTicks:d,horizontalValues:f,verticalValues:p}=i,m=nA(),h=gD(e=>LL(e,`xAxis`,a,m)),g=gD(e=>LL(e,`yAxis`,o,m));if(!jk(l)||!jk(u)||!AE(s)||!AE(c))return null;var _=i.verticalCoordinatesGenerator||nTe,v=i.horizontalCoordinatesGenerator||rTe,{horizontalPoints:b,verticalPoints:x}=i;if((!b||!b.length)&&typeof v==`function`){var S=f&&f.length,C=v({yAxis:g?CV(CV({},g),{},{ticks:S?f:g.ticks}):void 0,width:t??l,height:n??u,offset:r},S?!0:d);aA(Array.isArray(C),`horizontalCoordinatesGenerator should return Array but instead it returned [${typeof C}]`),Array.isArray(C)&&(b=C)}if((!x||!x.length)&&typeof _==`function`){var w=p&&p.length,T=_({xAxis:h?CV(CV({},h),{},{ticks:w?p:h.ticks}):void 0,width:t??l,height:n??u,offset:r},w?!0:d);aA(Array.isArray(T),`verticalCoordinatesGenerator should return Array but instead it returned [${typeof T}]`),Array.isArray(T)&&(x=T)}return y.createElement(KR,{zIndex:i.zIndex},y.createElement(`g`,{className:`recharts-cartesian-grid`},y.createElement(Zwe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),y.createElement(eTe,wV({},i,{horizontalPoints:b})),y.createElement(tTe,wV({},i,{verticalPoints:x})),y.createElement(Qwe,wV({},i,{offset:r,horizontalPoints:b,xAxis:h,yAxis:g})),y.createElement($we,wV({},i,{offset:r,verticalPoints:x,xAxis:h,yAxis:g}))))}DV.displayName=`CartesianGrid`;var aTe=tk({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]||(e[n]=[]),e[n].push(r)},replaceErrorBar:(e,t)=>{var{itemId:n,prev:r,next:i}=t.payload;e[n]&&(e[n]=e[n].map(e=>e.dataKey===r.dataKey&&e.direction===r.direction?i:e))},removeErrorBar:(e,t)=>{var{itemId:n,errorBar:r}=t.payload;e[n]&&(e[n]=e[n].filter(e=>e.dataKey!==r.dataKey||e.direction!==r.direction))}}}),{addErrorBar:oTe,replaceErrorBar:sTe,removeErrorBar:cTe}=aTe.actions,lTe=aTe.reducer,uTe=[`children`];function dTe(e,t){if(e==null)return{};var n,r,i=fTe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function mTe(e){var{children:t}=e,n=dTe(e,uTe);return y.createElement(pTe.Provider,{value:n},t)}function OV(e,t){var n=gD(t=>EI(t,e)),r=gD(e=>kI(e,t)),i=n?.allowDataOverflow??wI.allowDataOverflow,a=r?.allowDataOverflow??DI.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function kV(e){var{xAxisId:t,yAxisId:n,clipPathId:r}=e,i=XB(),{needClipX:a,needClipY:o,needClip:s}=OV(t,n);if(!s||!i)return null;var{x:c,y:l,width:u,height:d}=i;return y.createElement(`clipPath`,{id:`clipPath-${r}`},y.createElement(`rect`,{x:a?c:c-u/2,y:o?l:l-d/2,width:a?u:u*2,height:o?d:d*2}))}var hTe=(e,t,n,r)=>BL(e,`xAxis`,t,r),gTe=(e,t,n,r)=>zL(e,`xAxis`,t,r),_Te=(e,t,n,r)=>BL(e,`yAxis`,n,r),vTe=(e,t,n,r)=>zL(e,`yAxis`,n,r),yTe=xD([bA,hTe,_Te,gTe,vTe],(e,t,n,r,i)=>Fk(e,`xAxis`)?Uk(t,r,!1):Uk(n,i,!1)),bTe=(e,t,n,r,i)=>i;function xTe(e){return e.type===`line`}var STe=xD([bA,hTe,_Te,gTe,vTe,xD([FI,bTe],(e,t)=>e.filter(xTe).find(e=>e.id===t)),yTe,TF],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return dEe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function CTe(e){var t=ST(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var wTe=o((e=>{var t=f();t.useSyncExternalStore,t.useRef,t.useEffect,t.useMemo,t.useDebugValue}));o(((e,t)=>{t.exports=wTe()}))();function TTe(e){e()}function ETe(){let e=null,t=null;return{clear(){e=null,t=null},notify(){TTe(()=>{let t=e;for(;t;)t.callback(),t=t.next})},get(){let t=[],n=e;for(;n;)t.push(n),n=n.next;return t},subscribe(n){let r=!0,i=t={callback:n,next:null,prev:t};return i.prev?i.prev.next=i:e=i,function(){!r||e===null||(r=!1,i.next?i.next.prev=i.prev:t=i.prev,i.prev?i.prev.next=i.next:e=i.next)}}}}var DTe={notify(){},get:()=>[]};function OTe(e,t){let n,r=DTe,i=0,a=!1;function o(e){u();let t=r.subscribe(e),n=!1;return()=>{n||(n=!0,t(),d())}}function s(){r.notify()}function c(){m.onStateChange&&m.onStateChange()}function l(){return a}function u(){i++,n||(n=t?t.addNestedSub(c):e.subscribe(c),r=ETe())}function d(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=DTe)}function f(){a||(a=!0,u())}function p(){a&&(a=!1,d())}let m={addNestedSub:o,notifyNestedSubs:s,handleChangeWrapper:c,isSubscribed:l,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>r};return m}var kTe=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,ATe=typeof navigator<`u`&&navigator.product===`ReactNative`,jTe=kTe||ATe?y.useLayoutEffect:y.useEffect;function MTe(e,t){return e===t?e!==0||t!==0||1/e==1/t:e!==e&&t!==t}function NTe(e,t){if(MTe(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r=0;r({store:i,subscription:OTe(i),getServerState:r?()=>r:void 0}),[i,r]),o=y.useMemo(()=>i.getState(),[i]);jTe(()=>{let{subscription:e}=a;return e.onStateChange=e.notifyNestedSubs,e.trySubscribe(),o!==i.getState()&&e.notifyNestedSubs(),()=>{e.tryUnsubscribe(),e.onStateChange=void 0}},[a,o]);let s=n||LTe;return y.createElement(s.Provider,{value:a},t)}var zTe=RTe,BTe=new Set([`axisLine`,`tickLine`,`activeBar`,`activeDot`,`activeLabel`,`activeShape`,`allowEscapeViewBox`,`background`,`cursor`,`dot`,`label`,`line`,`margin`,`padding`,`position`,`shape`,`style`,`tick`,`wrapperStyle`,`radius`]);function VTe(e,t){return e==null&&t==null?!0:typeof e==`number`&&typeof t==`number`?e===t||e!==e&&t!==t:e===t}function AV(e,t){for(var n of new Set([...Object.keys(e),...Object.keys(t)]))if(BTe.has(n)){if(e[n]==null&&t[n]==null)continue;if(!NTe(e[n],t[n]))return!1}else if(!VTe(e[n],t[n]))return!1;return!0}var HTe=[`id`],UTe=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],WTe=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function jV(){return jV=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Gk(n,t),payload:e}]},ZTe=y.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:BE,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Gk(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return y.createElement(NB,{tooltipEntrySettings:d})}),QTe=(e,t)=>`${t}px ${e-t}px`;function $Te(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i{var r=n.reduce((e,t)=>e+t);if(!r)return QTe(t,e);for(var i=Math.floor(e/r),a=e%r,o=t-e,s=[],c=0,l=0;ca){s=[...n.slice(0,c),a-l];break}}var f=s.length%2==0?[0,o]:[o];return[...$Te(n,i),...s,...f].map(e=>`${e}px`).join(`, `)};function tEe(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=xT(NV(r,HTe));return y.createElement(KB,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function nEe(e){var{showLabels:t,children:n,points:r}=e,i=(0,y.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return MV(MV({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return y.createElement(Zz,{value:t?i:void 0},n)}function rEe(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=MV(MV({},CT(NV(a,UTe))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return y.createElement(y.Fragment,null,r?.length>1&&y.createElement(kB,jV({shapeType:`curve`,option:u},d,{pathRef:n})),y.createElement(tEe,{points:r,clipPathId:t,props:a}))}function iEe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function aEe(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Zj(o,`recharts-line-`),b=(0,y.useRef)(v),[x,S]=(0,y.useState)(!1),C=!x,w=(0,y.useCallback)(()=>{typeof h==`function`&&h(),S(!1)},[h]),T=(0,y.useCallback)(()=>{typeof g==`function`&&g(),S(!0)},[g]),E=iEe(r.current),D=(0,y.useRef)(0);b.current!==v&&(D.current=a.current,b.current=v);var O=D.current;return y.createElement(nEe,{points:o,showLabels:C},n.children,y.createElement(Xj,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=FE(O,E+O,e),u=Math.min(l,E),d=c?s?eEe(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):QTe(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return MV(MV({},t),{},{x:FE(i.x,t.x,e),y:FE(i.y,t.y,e)})}return f?MV(MV({},t),{},{x:FE(p*2,t.x,e),y:FE(m/2,t.y,e)}):MV(MV({},t),{},{x:t.x,y:t.y})});return i.current=g,y.createElement(rEe,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return y.createElement(rEe,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),y.createElement(eB,{label:n.label}))}function oEe(e){var{clipPathId:t,props:n}=e,r=(0,y.useRef)(null),i=(0,y.useRef)(0),a=(0,y.useRef)(null);return y.createElement(aEe,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var sEe=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:Pk(e.payload,t)}),cEe=class extends y.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:s,width:c,height:l,id:u,needClip:d,zIndex:f}=this.props;if(e)return null;var p=_T(`recharts-line`,r),m=u,{r:h,strokeWidth:g}=CTe(t),_=bB(t),v=h*2+g,b=d?`url(#clipPath-${_?``:`dots-`}${m})`:void 0;return y.createElement(KR,{zIndex:f},y.createElement(DT,{className:p},d&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:m,xAxisId:i,yAxisId:a}),!_&&y.createElement(`clipPath`,{id:`clipPath-dots-${m}`},y.createElement(`rect`,{x:s-v/2,y:o-v/2,width:c+v,height:l+v}))),y.createElement(mTe,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:sEe,errorBarOffset:0},y.createElement(oEe,{props:this.props,clipPathId:m}))),y.createElement($B,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},lEe={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:WF.line,type:`linear`};function uEe(e){var t=XE(e,lEe),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=NV(t,WTe),{needClip:_}=OV(p,m),v=XB(),b=xA(),x=nA(),S=gD(e=>STe(e,p,m,x,h));if(b!==`horizontal`&&b!==`vertical`||S==null||v==null)return null;var{height:C,width:w,x:T,y:E}=v;return y.createElement(cEe,jV({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:S,layout:b,height:C,width:w,left:T,top:E,needClip:_}))}function dEe(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=Pk(e,o);if(t===`horizontal`)return{x:zk({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(LE(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=LE(l)?null:n.scale.map(l),d=zk({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function fEe(e){var t=XE(e,lEe),n=nA();return y.createElement(FB,{id:t.id,type:`line`},e=>y.createElement(y.Fragment,null,y.createElement(PB,{legendPayload:XTe(t)}),y.createElement(ZTe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(LB,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),y.createElement(uEe,jV({},t,{id:e}))))}var PV=y.memo(fEe,AV);PV.displayName=`Line`;function FV(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function IV(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var pEe=(e,t,n)=>BL(e,`xAxis`,FV(e,t),n),LV=(e,t,n)=>zL(e,`xAxis`,FV(e,t),n),RV=(e,t,n)=>BL(e,`yAxis`,IV(e,t),n),zV=(e,t,n)=>zL(e,`yAxis`,IV(e,t),n),mEe=xD([bA,pEe,RV,LV,zV],(e,t,n,r,i)=>Fk(e,`xAxis`)?Uk(t,r,!1):Uk(n,i,!1)),BV=xD([FI,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),VV=e=>Fk(bA(e),`xAxis`)?`yAxis`:`xAxis`,hEe=(e,t)=>VV(e)===`yAxis`?IV(e,t):FV(e,t),gEe=xD([bA,pEe,RV,LV,zV,xD([BV,(e,t,n)=>QI(e,VV(e),hEe(e,t),n)],(e,t)=>{if(!(e==null||t==null)){var{stackId:n}=e,r=uI(e);if(!(n==null||r==null)){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),EF,mEe,BV,rve],(e,t,n,r,i,a,o,s,c,l)=>{var{chartData:u,dataStartIndex:d,dataEndIndex:f}=o;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var{data:p}=c,m=p&&p.length>0?p:u?.slice(d,f+1);if(m!=null)return FEe({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:d,areaSettings:c,stackedData:a,displayedData:m,chartBaseValue:l,bandSize:s})}}),_Ee=[`id`],vEe=[`activeDot`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`fill`,`fillOpacity`,`hide`,`isAnimationActive`,`legendType`,`stroke`,`xAxisId`,`yAxisId`];function HV(){return HV=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,stroke:r,fill:i,legendType:a,hide:o}=e;return[{inactive:o,dataKey:t,type:a,color:KV(r,i),value:Gk(n,t),payload:e}]},wEe=y.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:BE,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:Gk(o,t),hide:s,type:l,color:KV(r,a),unit:c,graphicalItemId:u}};return y.createElement(NB,{tooltipEntrySettings:d})});function TEe(e){var{clipPathId:t,points:n,props:r}=e,{needClip:i,dot:a,dataKey:o}=r,s=xT(r);return y.createElement(KB,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function EEe(e){var{showLabels:t,children:n,points:r}=e,i=r.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return GV(GV({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return y.createElement(Zz,{value:t?i:void 0},n)}function qV(e){var{points:t,baseLine:n,needClip:r,clipPathId:i,props:a}=e,{layout:o,type:s,stroke:c,connectNulls:l,isRange:u}=a,{id:d}=a,f=UV(a,_Ee),p=xT(f),m=CT(f);return y.createElement(y.Fragment,null,t?.length>1&&y.createElement(DT,{clipPath:r?`url(#clipPath-${i})`:void 0},y.createElement(Mj,HV({},m,{id:d,points:t,connectNulls:l,type:s,baseLine:n,layout:o,stroke:`none`,className:`recharts-area-area`})),c!==`none`&&y.createElement(Mj,HV({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:t})),c!==`none`&&u&&y.createElement(Mj,HV({},p,{className:`recharts-area-curve`,layout:o,type:s,connectNulls:l,fill:`none`,points:n}))),y.createElement(TEe,{points:t,props:f,clipPathId:i}))}function DEe(e){var{alpha:t,baseLine:n,points:r,strokeWidth:i}=e,a=r[0]?.y,o=r[r.length-1]?.y;if(!Ak(a)||!Ak(o))return null;var s=t*Math.abs(a-o),c=Math.max(...r.map(e=>e.x||0));return AE(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),AE(c)?y.createElement(`rect`,{x:0,y:ae.y||0));return AE(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),AE(c)?y.createElement(`rect`,{x:a({points:o,baseLine:s}),[o,s]),`recharts-area-`),h=SA(),[g,_]=(0,y.useState)(!1),v=!g,b=(0,y.useCallback)(()=>{typeof p==`function`&&p(),_(!1)},[p]),x=(0,y.useCallback)(()=>{typeof f==`function`&&f(),_(!0)},[f]);if(h==null)return null;var S=i.current,C=a.current;return y.createElement(EEe,{showLabels:v,points:o},r.children,y.createElement(Xj,{animationId:m,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:b,onAnimationStart:x,key:m},e=>{if(S){var l=S.length/o.length,u=e===1?o:o.map((t,n)=>{var r=Math.floor(n*l);if(S[r]){var i=S[r];return GV(GV({},t),{},{x:FE(i.x,t.x,e),y:FE(i.y,t.y,e)})}return t}),d=AE(s)?FE(C,s,e):LE(s)||OE(s)?FE(C,0,e):s.map((t,n)=>{var r=Math.floor(n*l);if(Array.isArray(C)&&C[r]){var i=C[r];return GV(GV({},t),{},{x:FE(i.x,t.x,e),y:FE(i.y,t.y,e)})}return t});return e>0&&(i.current=u,a.current=d),y.createElement(qV,{points:u,baseLine:d,needClip:t,clipPathId:n,props:r})}return e>0&&(i.current=o,a.current=s),y.createElement(DT,null,c&&y.createElement(`defs`,null,y.createElement(`clipPath`,{id:`animationClipPath-${n}`},y.createElement(kEe,{alpha:e,points:o,baseLine:s,layout:h,strokeWidth:r.strokeWidth}))),y.createElement(DT,{clipPath:`url(#animationClipPath-${n})`},y.createElement(qV,{points:o,baseLine:s,needClip:t,clipPathId:n,props:r})))}),y.createElement(eB,{label:r.label}))}function jEe(e){var{needClip:t,clipPathId:n,props:r}=e,i=(0,y.useRef)(null),a=(0,y.useRef)();return y.createElement(AEe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var MEe=class extends y.PureComponent{render(){var{hide:e,dot:t,points:n,className:r,top:i,left:a,needClip:o,xAxisId:s,yAxisId:c,width:l,height:u,id:d,baseLine:f,zIndex:p}=this.props;if(e)return null;var m=_T(`recharts-area`,r),h=d,{r:g,strokeWidth:_}=CTe(t),v=bB(t),b=g*2+_,x=o?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return y.createElement(KR,{zIndex:p},y.createElement(DT,{className:m},o&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:h,xAxisId:s,yAxisId:c}),!v&&y.createElement(`clipPath`,{id:`clipPath-dots-${h}`},y.createElement(`rect`,{x:a-b/2,y:i-b/2,width:l+b,height:u+b}))),y.createElement(jEe,{needClip:o,clipPathId:h,props:this.props})),y.createElement($B,{points:n,mainColor:KV(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}),this.props.isRange&&Array.isArray(f)&&y.createElement($B,{points:f,mainColor:KV(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:x}))}},JV={activeDot:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,xAxisId:0,yAxisId:0,zIndex:WF.area};function NEe(e){var t=XE(e,JV),{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,connectNulls:o,dot:s,fill:c,fillOpacity:l,hide:u,isAnimationActive:d,legendType:f,stroke:p,xAxisId:m,yAxisId:h}=t,g=UV(t,vEe),_=xA(),v=PR(),{needClip:b}=OV(m,h),x=nA(),{points:S,isRange:C,baseLine:w}=gD(t=>gEe(t,e.id,x))??{},T=XB();if(_!==`horizontal`&&_!==`vertical`||T==null||v!==`AreaChart`&&v!==`ComposedChart`)return null;var{height:E,width:D,x:O,y:k}=T;return!S||!S.length?null:y.createElement(MEe,HV({},g,{activeDot:n,animationBegin:r,animationDuration:i,animationEasing:a,baseLine:w,connectNulls:o,dot:s,fill:c,fillOpacity:l,height:E,hide:u,layout:_,isAnimationActive:d===`auto`?!qj.isSsr:d,isRange:C,legendType:f,needClip:b,points:S,stroke:p,width:D,left:O,top:k,xAxisId:m,yAxisId:h}))}var PEe=(e,t,n,r,i)=>{var a=n??t;if(AE(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function FEe(e){var{areaSettings:{connectNulls:t,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:s,yAxis:c,displayedData:l,dataStartIndex:u,xAxisTicks:d,yAxisTicks:f,bandSize:p}=e,m=i&&i.length,h=PEe(a,o,n,s,c),g=a===`horizontal`,_=!1,v=l.map((e,n)=>{var a;if(m)a=i[u+n];else{var o=Pk(e,r);Array.isArray(o)?(a=o,_=!0):a=[h,o]}var l=a?.[1]??null,v=l==null||m&&!t&&Pk(e,r)==null;return g?{x:zk({axis:s,ticks:d,bandSize:p,entry:e,index:n}),y:v?null:c.scale.map(l)??null,value:a,payload:e}:{x:v?null:s.scale.map(l)??null,y:zk({axis:c,ticks:f,bandSize:p,entry:e,index:n}),value:a,payload:e}});return{points:v,baseLine:(m||_?v.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return g?{x:e.x,y:t!=null&&e.y!=null?c.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:s.scale.map(t)??null,y:e.y,payload:e.payload}}):g?c.scale.map(h):s.scale.map(h))??0,isRange:_}}function IEe(e){var t=XE(e,JV),n=nA();return y.createElement(FB,{id:t.id,type:`area`},e=>y.createElement(y.Fragment,null,y.createElement(PB,{legendPayload:CEe(t)}),y.createElement(wEe,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(LB,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:Rk(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),y.createElement(NEe,HV({},t,{id:e}))))}var YV=y.memo(IEe,AV);YV.displayName=`Area`;var LEe=!0,XV=`Invariant failed`;function REe(e,t){if(!e){if(LEe)throw Error(XV);var n=typeof t==`function`?t():t,r=n?`${XV}: ${n}`:XV;throw Error(r)}}function ZV(){return ZV=Object.assign?Object.assign.bind():function(e){for(var t=1;t1&&arguments[1]!==void 0?arguments[1]:0;return(n,r)=>{if(AE(e))return e;var i=AE(n)||LE(n);return i?e(n,r):(!i&&REe(!1,`minPointSize callback function received a value with type of ${typeof n}. Currently only numbers or null/undefined are supported.`),t)}},BEe=(e,t,n)=>n,$V=xD([FI,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`bar`).find(e=>e.id===t)),VEe=xD([$V],e=>e?.maxBarSize),HEe=(e,t,n,r)=>r,UEe=xD([bA,FI,FV,IV,BEe],(e,t,n,r,i)=>t.filter(t=>e===`horizontal`?t.xAxisId===n:t.yAxisId===r).filter(e=>e.isPanorama===i).filter(e=>e.hide===!1).filter(e=>e.type===`bar`)),WEe=(e,t,n)=>{var r=bA(e),i=FV(e,t),a=IV(e,t);if(!(i==null||a==null))return r===`horizontal`?QI(e,`yAxis`,a,n):QI(e,`xAxis`,i,n)},GEe=xD([UEe,nve,(e,t)=>{var n=bA(e),r=FV(e,t),i=IV(e,t);if(!(r==null||i==null))return n===`horizontal`?ML(e,`xAxis`,r):ML(e,`yAxis`,i)}],LCe),KEe=(e,t,n)=>{var r=$V(e,t);if(r==null)return 0;var i=FV(e,t),a=IV(e,t);if(i==null||a==null)return 0;var o=bA(e),s=IF(e),{maxBarSize:c}=r,l=LE(c)?s:c,u,d;return o===`horizontal`?(u=BL(e,`xAxis`,i,n),d=zL(e,`xAxis`,i,n)):(u=BL(e,`yAxis`,a,n),d=zL(e,`yAxis`,a,n)),Uk(u,d,!0)??l??0},eH=(e,t,n)=>{var r=bA(e),i=FV(e,t),a=IV(e,t);if(!(i==null||a==null)){var o,s;return r===`horizontal`?(o=BL(e,`xAxis`,i,n),s=zL(e,`xAxis`,i,n)):(o=BL(e,`yAxis`,a,n),s=zL(e,`yAxis`,a,n)),Uk(o,s)}},qEe=xD([eA,tA,(e,t,n)=>{var r=FV(e,t);if(r!=null)return BL(e,`xAxis`,r,n)},(e,t,n)=>{var r=IV(e,t);if(r!=null)return BL(e,`yAxis`,r,n)},(e,t,n)=>{var r=FV(e,t);if(r!=null)return zL(e,`xAxis`,r,n)},(e,t,n)=>{var r=IV(e,t);if(r!=null)return zL(e,`yAxis`,r,n)},xD([xD([GEe,IF,tve,LF,KEe,eH,VEe],HCe),$V],WCe),bA,EF,eH,xD([WEe,$V],UCe),$V,HEe],(e,t,n,r,i,a,o,s,c,l,u,d,f)=>{var{chartData:p,dataStartIndex:m,dataEndIndex:h}=c;if(!(d==null||o==null||t==null||s!==`horizontal`&&s!==`vertical`||n==null||r==null||i==null||a==null||l==null)){var{data:g}=d,_=g!=null&&g.length>0?g:p?.slice(m,h+1);if(_!=null)return xDe({layout:s,barSettings:d,pos:o,parentViewBox:t,bandSize:l,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:u,displayedData:_,offset:e,cells:f,dataStartIndex:m})}}),JEe=[`index`];function tH(){return tH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var t=(0,y.useContext)(nH);if(t!=null)return t.stackId;if(e!=null)return Rk(e)},QEe=(e,t)=>`recharts-bar-stack-clip-path-${e}-${t}`,$Ee=e=>{var t=(0,y.useContext)(nH);if(t!=null){var{stackId:n}=t;return`url(#${QEe(n,e)})`}},rH=e=>{var{index:t}=e,n=YEe(e,JEe),r=$Ee(t);return y.createElement(DT,tH({className:`recharts-bar-stack-layer`,clipPath:r},n))},eDe=[`onMouseEnter`,`onMouseLeave`,`onClick`],tDe=[`value`,`background`,`tooltipPosition`],nDe=[`id`],rDe=[`onMouseEnter`,`onClick`,`onMouseLeave`];function iH(){return iH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:Gk(n,t),payload:e}]},lDe=y.memo(e=>{var{dataKey:t,stroke:n,strokeWidth:r,fill:i,name:a,hide:o,unit:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:void 0,getPosition:BE,settings:{stroke:n,strokeWidth:r,fill:i,dataKey:t,nameKey:void 0,name:Gk(a,t),hide:o,type:c,color:i,unit:s,graphicalItemId:l}};return y.createElement(NB,{tooltipEntrySettings:u})});function uDe(e){var t=gD(TR),{data:n,dataKey:r,background:i,allOtherBarProps:a}=e,{onMouseEnter:o,onMouseLeave:s,onClick:c}=a,l=sH(a,eDe),u=AB(o,r,a.id),d=jB(s),f=MB(c,r,a.id);if(!i||n==null)return null;var p=ST(i);return y.createElement(KR,{zIndex:GCe(i,WF.barBackground)},n.map((e,n)=>{var{value:a,background:o,tooltipPosition:s}=e,c=sH(e,tDe);if(!o)return null;var m=u(e,n),h=d(e,n),g=f(e,n),_=oH(oH(oH(oH(oH({option:i,isActive:String(n)===t},c),{},{fill:`#eee`},o),p),JE(l,e,n)),{},{onMouseEnter:m,onMouseLeave:h,onClick:g,dataKey:r,index:n,className:`recharts-bar-background-rectangle`});return y.createElement(QV,iH({key:`background-bar-${n}`},_))}))}function dDe(e){var{showLabels:t,children:n,rects:r}=e,i=r?.map(e=>{var t={x:e.x,y:e.y,width:e.width,lowerWidth:e.width,upperWidth:e.width,height:e.height};return oH(oH({},t),{},{value:e.value,payload:e.payload,parentViewBox:e.parentViewBox,viewBox:t,fill:e.fill})});return y.createElement(Zz,{value:t?i:void 0},n)}function fDe(e){var{shape:t,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=e,s=gD(TR),c=gD(DR),l=n&&String(a)===s&&(c==null||o===c),u=l?n:t;return l?y.createElement(KR,{zIndex:WF.activeBar},y.createElement(rH,{index:a},y.createElement(QV,iH({},r,{name:String(r.name)},i,{isActive:l,option:u,index:a,dataKey:o})))):y.createElement(QV,iH({},r,{name:String(r.name)},i,{isActive:l,option:u,index:a,dataKey:o}))}function pDe(e){var{shape:t,baseProps:n,entry:r,index:i,dataKey:a}=e;return y.createElement(QV,iH({},n,{name:String(n.name)},r,{isActive:!1,option:t,index:i,dataKey:a}))}function mDe(e){var{data:t,props:n}=e,r=xT(n)??{},{id:i}=r,a=sH(r,nDe),{shape:o,dataKey:s,activeBar:c}=n,{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=sH(n,rDe),p=AB(l,s,i),m=jB(d),h=MB(u,s,i);return t?y.createElement(y.Fragment,null,t.map((e,t)=>y.createElement(rH,iH({index:t,key:`rectangle-${e?.x}-${e?.y}-${e?.value}-${t}`,className:`recharts-bar-rectangle`},JE(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),c?y.createElement(fDe,{shape:o,activeBar:c,baseProps:a,entry:e,index:t,dataKey:s}):y.createElement(pDe,{shape:o,baseProps:a,entry:e,index:t,dataKey:s})))):null}function hDe(e){var{props:t,previousRectanglesRef:n}=e,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,onAnimationEnd:l,onAnimationStart:u}=t,d=n.current,f=Zj(t,`recharts-bar-`),[p,m]=(0,y.useState)(!1),h=!p,g=(0,y.useCallback)(()=>{typeof l==`function`&&l(),m(!1)},[l]),_=(0,y.useCallback)(()=>{typeof u==`function`&&u(),m(!0)},[u]);return y.createElement(dDe,{showLabels:h,rects:r},y.createElement(Xj,{animationId:f,begin:o,duration:s,isActive:a,easing:c,onAnimationEnd:g,onAnimationStart:_,key:f},e=>{var a=e===1?r:r?.map((t,n)=>{var r=d&&d[n];if(r)return oH(oH({},t),{},{x:FE(r.x,t.x,e),y:FE(r.y,t.y,e),width:FE(r.width,t.width,e),height:FE(r.height,t.height,e)});if(i===`horizontal`){var a=FE(0,t.height,e),o=FE(t.stackedBarStart,t.y,e);return oH(oH({},t),{},{y:o,height:a})}var s=FE(0,t.width,e),c=FE(t.stackedBarStart,t.x,e);return oH(oH({},t),{},{width:s,x:c})});return e>0&&(n.current=a??null),a==null?null:y.createElement(DT,null,y.createElement(mDe,{props:t,data:a}))}),y.createElement(eB,{label:t.label}),t.children)}function gDe(e){var t=(0,y.useRef)(null);return y.createElement(hDe,{previousRectanglesRef:t,props:e})}var cH=0,_De=(e,t)=>{var n=Array.isArray(e.value)?e.value[1]:e.value;return{x:e.x,y:e.y,value:n,errorVal:Pk(e,t)}},vDe=class extends y.PureComponent{render(){var{hide:e,data:t,dataKey:n,className:r,xAxisId:i,yAxisId:a,needClip:o,background:s,id:c}=this.props;if(e||t==null)return null;var l=_T(`recharts-bar`,r),u=c;return y.createElement(DT,{className:l,id:c},o&&y.createElement(`defs`,null,y.createElement(kV,{clipPathId:u,xAxisId:i,yAxisId:a})),y.createElement(DT,{className:`recharts-bar-rectangles`,clipPath:o?`url(#clipPath-${u})`:void 0},y.createElement(uDe,{data:t,dataKey:n,background:s,allOtherBarProps:this.props}),y.createElement(gDe,this.props)))}},yDe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:`ease`,background:!1,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`rect`,minPointSize:cH,xAxisId:0,yAxisId:0,zIndex:WF.bar};function bDe(e){var{xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u}=e,{needClip:d}=OV(t,n),f=xA(),p=nA(),m=yB(e.children,uz),h=gD(t=>qEe(t,e.id,p,m));if(f!==`vertical`&&f!==`horizontal`)return null;var g,_=h?.[0];return g=_==null||_.height==null||_.width==null?0:f===`vertical`?_.height/2:_.width/2,y.createElement(mTe,{xAxisId:t,yAxisId:n,data:h,dataPointFormatter:_De,errorBarOffset:g},y.createElement(vDe,iH({},e,{layout:f,needClip:d,data:h,xAxisId:t,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:s,animationDuration:c,animationEasing:l,isAnimationActive:u})))}function xDe(e){var{layout:t,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:s,xAxisTicks:c,yAxisTicks:l,stackedData:u,displayedData:d,offset:f,cells:p,parentViewBox:m,dataStartIndex:h}=e,g=t===`horizontal`?s:o,_=u?g.scale.domain():null,v=wfe({numericAxis:g}),y=g.scale.map(v);return d.map((e,d)=>{var g,b,x,S,C,w;if(u){var T=u[d+h];if(T==null)return null;g=xfe(T,_)}else g=Pk(e,n),Array.isArray(g)||(g=[v,g]);var E=zEe(r,cH)(g[1],d);if(t===`horizontal`){var D=s.scale.map(g[0]),O=s.scale.map(g[1]);if(D==null||O==null)return null;b=Bk({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:e,index:d}),x=O??D??void 0,S=i.size;var k=D-O;if(C=OE(k)?0:k,w={x:b,y:f.top,width:S,height:f.height},Math.abs(E)>0&&Math.abs(C)0&&Math.abs(S)y.createElement(y.Fragment,null,y.createElement(PB,{legendPayload:cDe(t)}),y.createElement(lDe,{dataKey:t.dataKey,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),y.createElement(LB,{type:`bar`,id:e,data:void 0,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,stackId:n,hide:t.hide,barSize:t.barSize,minPointSize:t.minPointSize,maxBarSize:t.maxBarSize,isPanorama:r}),y.createElement(KR,{zIndex:t.zIndex},y.createElement(bDe,iH({},t,{id:e})))))}var lH=y.memo(SDe,AV);lH.displayName=`Bar`;var CDe=[`domain`,`range`],wDe=[`domain`,`range`];function uH(e,t){if(e==null)return{};var n,r,i=TDe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(o!=null)return hH(hH({},a),{},{type:o})},[a,o]);return(0,y.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(bCe(s)):n.current!==s&&t(xCe({prev:n.current,next:s})),n.current=s)},[s,t]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(SCe(n.current)),null)},[t]),null}var PDe=e=>{var{xAxisId:t,className:n}=e,r=gD(tA),i=nA(),a=`xAxis`,o=gD(e=>RL(e,a,t,i)),s=gD(e=>AL(e,t)),c=gD(e=>Xve(e,t)),l=gD(e=>TI(e,t));if(s==null||c==null||l==null)return null;var{dangerouslySetInnerHTML:u,ticks:d,scale:f}=e,p=gH(e,DDe),{id:m,scale:h}=l,g=gH(l,ODe);return y.createElement(xV,pH({},p,g,{x:c.x,y:c.y,width:s.width,height:s.height,className:_T(`recharts-${a} ${a}`,n),viewBox:r,ticks:o,axisType:a}))},FDe={allowDataOverflow:wI.allowDataOverflow,allowDecimals:wI.allowDecimals,allowDuplicatedCategory:wI.allowDuplicatedCategory,angle:wI.angle,axisLine:bV.axisLine,height:wI.height,hide:!1,includeHidden:wI.includeHidden,interval:wI.interval,label:!1,minTickGap:wI.minTickGap,mirror:wI.mirror,orientation:wI.orientation,padding:wI.padding,reversed:wI.reversed,scale:wI.scale,tick:wI.tick,tickCount:wI.tickCount,tickLine:bV.tickLine,tickSize:bV.tickSize,type:wI.type,xAxisId:0},_H=y.memo(e=>{var t=XE(e,FDe);return y.createElement(y.Fragment,null,y.createElement(NDe,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit}),y.createElement(PDe,t))},fH);_H.displayName=`XAxis`;var IDe=[`type`],LDe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],RDe=[`id`,`scale`];function vH(){return vH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return bH(bH({},a),{},{type:o})},[o,a]);return(0,y.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(CCe(s)):n.current!==s&&t(wCe({prev:n.current,next:s})),n.current=s)},[s,t]),(0,y.useLayoutEffect)(()=>()=>{n.current&&=(t(TCe(n.current)),null)},[t]),null}function WDe(e){var{yAxisId:t,className:n,width:r,label:i}=e,a=(0,y.useRef)(null),o=(0,y.useRef)(null),s=gD(tA),c=nA(),l=mD(),u=`yAxis`,d=gD(e=>jL(e,t)),f=gD(e=>Zve(e,t)),p=gD(e=>RL(e,u,t,c)),m=gD(e=>OI(e,t));if((0,y.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||Wz(i)||(0,y.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(kCe({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;var{dangerouslySetInnerHTML:h,ticks:g,scale:_}=e,v=xH(e,LDe),{id:b,scale:x}=m,S=xH(m,RDe);return y.createElement(xV,vH({},v,S,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:_T(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u}))}var GDe={allowDataOverflow:DI.allowDataOverflow,allowDecimals:DI.allowDecimals,allowDuplicatedCategory:DI.allowDuplicatedCategory,angle:DI.angle,axisLine:bV.axisLine,hide:!1,includeHidden:DI.includeHidden,interval:DI.interval,label:!1,minTickGap:DI.minTickGap,mirror:DI.mirror,orientation:DI.orientation,padding:DI.padding,reversed:DI.reversed,scale:DI.scale,tick:DI.tick,tickCount:DI.tickCount,tickLine:bV.tickLine,tickSize:bV.tickSize,type:DI.type,width:DI.width,yAxisId:0},SH=y.memo(e=>{var t=XE(e,GDe);return y.createElement(y.Fragment,null,y.createElement(UDe,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter}),y.createElement(WDe,t))},fH);SH.displayName=`YAxis`;var CH=xD([(e,t)=>t,bA,sI,hI,vR,bR,Uye,eA],Xye),wH=e=>{var t=e.currentTarget.getBoundingClientRect(),n=t.width/e.currentTarget.offsetWidth,r=t.height/e.currentTarget.offsetHeight;return{chartX:Math.round((e.clientX-t.left)/n),chartY:Math.round((e.clientY-t.top)/r)}},TH=KO(`mouseClick`),EH=Ek();EH.startListening({actionCreator:TH,effect:(e,t)=>{var n=e.payload,r=CH(t.getState(),wH(n));r?.activeIndex!=null&&t.dispatch(sye({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var DH=KO(`mouseMove`),OH=Ek(),kH=null;OH.startListening({actionCreator:DH,effect:(e,t)=>{var n=e.payload;kH!==null&&cancelAnimationFrame(kH);var r=wH(n);kH=requestAnimationFrame(()=>{var e=t.getState();if(WL(e,e.tooltip.settings.shared)===`axis`){var n=CH(e,r);n?.activeIndex==null?t.dispatch(YL()):t.dispatch(XL({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}kH=null})}});function KDe(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<>`:t}var AH={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},jH=tk({name:`rootProps`,initialState:AH,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??AH.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),qDe=jH.reducer,{updateOptions:JDe}=jH.actions,MH=tk({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>t.payload}}),{updatePolarOptions:YDe}=MH.actions,XDe=MH.reducer,NH=KO(`keyDown`),PH=KO(`focus`),FH=Ek();FH.startListening({actionCreator:NH,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip,i=e.payload;if(!(i!==`ArrowRight`&&i!==`ArrowLeft`&&i!==`Enter`)){var a=nR(r,fR(n),XI(n),gR(n)),o=a==null?-1:Number(a);if(!(!Number.isFinite(o)||o<0)){var s=bR(n);if(i===`Enter`){var c=VR(n,`axis`,`hover`,String(r.index));t.dispatch(QL({active:!r.active,activeIndex:r.index,activeCoordinate:c}));return}var l=Qve(n)===`left-to-right`?1:-1,u=o+(i===`ArrowRight`?1:-1)*l;if(!(s==null||u>=s.length||u<0)){var d=VR(n,`axis`,`hover`,String(u));t.dispatch(QL({active:!0,activeIndex:u.toString(),activeCoordinate:d}))}}}}}}),FH.startListening({actionCreator:PH,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var{keyboardInteraction:r}=n.tooltip;if(!r.active&&r.index==null){var i=`0`,a=VR(n,`axis`,`hover`,String(i));t.dispatch(QL({active:!0,activeIndex:i,activeCoordinate:a}))}}}});var IH=KO(`externalEvent`),LH=Ek(),RH=new Map;LH.startListening({actionCreator:IH,effect:(e,t)=>{var{handler:n,reactEvent:r}=e.payload;if(n!=null){r.persist();var i=r.type,a=RH.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var e=t.getState();n({activeCoordinate:kye(e),activeDataKey:DR(e),activeIndex:TR(e),activeLabel:ER(e),activeTooltipIndex:TR(e),isTooltipActive:Aye(e)},r)}finally{RH.delete(i)}});RH.set(i,o)}}});var ZDe=xD([xD([oR],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var{getPosition:i}=r;if(i!=null)return i(t)}}}),zH=KO(`touchMove`),BH=Ek();BH.startListening({actionCreator:zH,effect:(e,t)=>{var n=e.payload;if(!(n.touches==null||n.touches.length===0)){var r=t.getState(),i=WL(r,r.tooltip.settings.shared);if(i===`axis`){var a=n.touches[0];if(a==null)return;var o=CH(r,wH({clientX:a.clientX,clientY:a.clientY,currentTarget:n.currentTarget}));o?.activeIndex!=null&&t.dispatch(XL({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate}))}else if(i===`item`){var s=n.touches[0];if(document.elementFromPoint==null||s==null)return;var c=document.elementFromPoint(s.clientX,s.clientY);if(!c||!c.getAttribute)return;var l=c.getAttribute(Zk),u=c.getAttribute(`data-recharts-item-id`)??void 0,d=dR(r).find(e=>e.id===u);if(l==null||d==null||u==null)return;var{dataKey:f}=d,p=ZDe(r,l,u);t.dispatch(JL({activeDataKey:f,activeIndex:l,activeCoordinate:p,activeGraphicalItemId:u}))}}}});var QDe=PD({brush:qCe,cartesianAxis:ACe,chartData:Cbe,errorBars:lTe,graphicalItems:LSe,layout:gfe,legend:Epe,options:vbe,polarAxis:Zxe,polarOptions:XDe,referenceElements:iwe,rootProps:qDe,tooltip:cye,zIndex:lbe}),$De=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Hde({reducer:QDe,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([EH.middleware,OH.middleware,FH.middleware,LH.middleware,BH.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat($O({type:`raf`}))},devTools:qj.devToolsEnabled&&{serialize:{replacer:KDe},name:`recharts-${t}`}})};function VH(e){var{preloadedState:t,children:n,reduxStoreName:r}=e,i=nA(),a=(0,y.useRef)(null);if(i)return n;a.current??=$De(t,r);var o=fD;return y.createElement(zTe,{context:o,store:a.current},n)}function eOe(e){var{layout:t,margin:n}=e,r=mD(),i=nA();return(0,y.useEffect)(()=>{i||(r(pfe(t)),r(ffe(n)))},[r,i,t,n]),null}var HH=(0,y.memo)(eOe,AV);function UH(e){var t=mD();return(0,y.useEffect)(()=>{t(JDe(e))},[t,e]),null}function WH(e){var{zIndex:t,isPanorama:n}=e,r=(0,y.useRef)(null),i=mD();return(0,y.useLayoutEffect)(()=>(r.current&&i(sbe({zIndex:t,element:r.current,isPanorama:n})),()=>{i(cbe({zIndex:t,isPanorama:n}))}),[i,t,n]),y.createElement(`g`,{tabIndex:-1,ref:r})}function GH(e){var{children:t,isPanorama:n}=e,r=gD(Qye);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return y.createElement(y.Fragment,null,i.map(e=>y.createElement(WH,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>y.createElement(WH,{key:e,zIndex:e,isPanorama:n})))}var tOe=[`children`];function nOe(e,t){if(e==null)return{};var n,r,i=rOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=vA(),r=yA(),i=Sj();if(!jk(n)||!jk(r))return null;var{children:a,otherAttributes:o,title:s,desc:c}=e,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),y.createElement(TT,KH({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:iOe,ref:t}),a)}),oOe=e=>{var{children:t}=e,n=gD(iA);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return y.createElement(TT,{width:r,height:i,x:o,y:a},t)},qH=(0,y.forwardRef)((e,t)=>{var{children:n}=e,r=nOe(e,tOe);return nA()?y.createElement(oOe,null,y.createElement(GH,{isPanorama:!0},n)):y.createElement(aOe,KH({ref:t},r),y.createElement(GH,{isPanorama:!1},n))});function sOe(){var e=mD(),[t,n]=(0,y.useState)(null),r=gD(Afe);return(0,y.useEffect)(()=>{if(t!=null){var n=t.getBoundingClientRect().width/t.offsetWidth;Ak(n)&&n!==r&&e(hfe(n))}},[t,e,r]),n}function JH(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cOe(e){for(var t=1;t(Mbe(),null);function XH(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var pOe=(0,y.forwardRef)((e,t)=>{var n=(0,y.useRef)(null),[r,i]=(0,y.useState)({containerWidth:XH(e.style?.width),containerHeight:XH(e.style?.height)}),a=(0,y.useCallback)((e,t)=>{i(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),o=(0,y.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null&&typeof ResizeObserver<`u`){var{width:r,height:i}=e.getBoundingClientRect();a(r,i);var o=new ResizeObserver(e=>{var t=e[0];if(t!=null){var{width:n,height:r}=t.contentRect;a(n,r)}});o.observe(e),n.current=o}},[t,a]);return(0,y.useEffect)(()=>()=>{n.current?.disconnect()},[a]),y.createElement(y.Fragment,null,y.createElement(wA,{width:r.containerWidth,height:r.containerHeight}),y.createElement(`div`,YH({ref:o},e)))}),mOe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e,[i,a]=(0,y.useState)({containerWidth:XH(n),containerHeight:XH(r)}),o=(0,y.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,y.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var{width:n,height:r}=e.getBoundingClientRect();o(n,r)}},[t,o]);return y.createElement(y.Fragment,null,y.createElement(wA,{width:i.containerWidth,height:i.containerHeight}),y.createElement(`div`,YH({ref:s},e)))}),hOe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e;return y.createElement(y.Fragment,null,y.createElement(wA,{width:n,height:r}),y.createElement(`div`,YH({ref:t},e)))}),gOe=(0,y.forwardRef)((e,t)=>{var{width:n,height:r}=e;return typeof n==`string`||typeof r==`string`?y.createElement(mOe,YH({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?y.createElement(hOe,YH({},e,{width:n,height:r,ref:t})):y.createElement(y.Fragment,null,y.createElement(wA,{width:n,height:r}),y.createElement(`div`,YH({ref:t},e)))});function _Oe(e){return e?pOe:gOe}var vOe=(0,y.forwardRef)((e,t)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:s,onMouseDown:c,onMouseEnter:l,onMouseLeave:u,onMouseMove:d,onMouseUp:f,onTouchEnd:p,onTouchMove:m,onTouchStart:h,style:g,width:_,responsive:v,dispatchTouchEvents:b=!0}=e,x=(0,y.useRef)(null),S=mD(),[C,w]=(0,y.useState)(null),[T,E]=(0,y.useState)(null),D=sOe(),O=pA(),k=O?.width>0?O.width:_,A=O?.height>0?O.height:i,j=(0,y.useCallback)(e=>{D(e),typeof t==`function`&&t(e),w(e),E(e),e!=null&&(x.current=e)},[D,t,w,E]),M=(0,y.useCallback)(e=>{S(TH(e)),S(IH({handler:a,reactEvent:e}))},[S,a]),N=(0,y.useCallback)(e=>{S(DH(e)),S(IH({handler:l,reactEvent:e}))},[S,l]),P=(0,y.useCallback)(e=>{S(YL()),S(IH({handler:u,reactEvent:e}))},[S,u]),F=(0,y.useCallback)(e=>{S(DH(e)),S(IH({handler:d,reactEvent:e}))},[S,d]),I=(0,y.useCallback)(()=>{S(PH())},[S]),L=(0,y.useCallback)(e=>{S(NH(e.key))},[S]),R=(0,y.useCallback)(e=>{S(IH({handler:o,reactEvent:e}))},[S,o]),z=(0,y.useCallback)(e=>{S(IH({handler:s,reactEvent:e}))},[S,s]),B=(0,y.useCallback)(e=>{S(IH({handler:c,reactEvent:e}))},[S,c]),V=(0,y.useCallback)(e=>{S(IH({handler:f,reactEvent:e}))},[S,f]),ee=(0,y.useCallback)(e=>{S(IH({handler:h,reactEvent:e}))},[S,h]),te=(0,y.useCallback)(e=>{b&&S(zH(e)),S(IH({handler:m,reactEvent:e}))},[S,b,m]),ne=(0,y.useCallback)(e=>{S(IH({handler:p,reactEvent:e}))},[S,p]),re=_Oe(v);return y.createElement(XR.Provider,{value:C},y.createElement(OT.Provider,{value:T},y.createElement(re,{width:k??g?.width,height:A??g?.height,className:_T(`recharts-wrapper`,r),style:cOe({position:`relative`,cursor:`default`,width:k,height:A},g),onClick:M,onContextMenu:R,onDoubleClick:z,onFocus:I,onKeyDown:L,onMouseDown:B,onMouseEnter:N,onMouseLeave:P,onMouseMove:F,onMouseUp:V,onTouchEnd:ne,onTouchMove:te,onTouchStart:ee,ref:j},y.createElement(fOe,null),n)))}),yOe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function bOe(e,t){if(e==null)return{};var n,r,i=xOe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var{width:n,height:r,responsive:i,children:a,className:o,style:s,compact:c,title:l,desc:u}=e,d=xT(bOe(e,yOe));return c?y.createElement(y.Fragment,null,y.createElement(wA,{width:n,height:r}),y.createElement(qH,{otherAttributes:d,title:l,desc:u},a)):y.createElement(vOe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},y.createElement(qH,{otherAttributes:d,title:l,desc:u,ref:t},y.createElement(awe,null,a)))});function QH(){return QH=Object.assign?Object.assign.bind():function(e){for(var t=1;ty.createElement($H,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:COe,tooltipPayloadSearcher:ez,categoricalChartProps:e,ref:t})),wOe=[`axis`,`item`],tU=(0,y.forwardRef)((e,t)=>y.createElement($H,{chartName:`BarChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:wOe,tooltipPayloadSearcher:ez,categoricalChartProps:e,ref:t}));function TOe(e){var t=mD();return(0,y.useEffect)(()=>{t(YDe(e))},[t,e]),null}var EOe=[`layout`];function nU(){return nU=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=XE(e,POe);return y.createElement(kOe,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:NOe,tooltipPayloadSearcher:ez,categoricalChartProps:n,ref:t})}),FOe=[`axis`],sU=(0,y.forwardRef)((e,t)=>y.createElement($H,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:FOe,tooltipPayloadSearcher:ez,categoricalChartProps:e,ref:t})),cU=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}];function IOe({isOpen:e,onClose:t,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o=`humidity`,thresholds:s}){let{t:c}=W(),[l,u]=(0,y.useState)(`24h`),[d,f]=(0,y.useState)(o),{data:p}=q({queryKey:[`settings`],queryFn:Q.getSettings}),m=p?.time_format||`system`;(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let h=cU.find(e=>e.value===l)?.hours||24,{data:g,isLoading:_,error:v}=q({queryKey:[`ams-history`,n,i,h],queryFn:()=>Q.getAMSHistory(n,i,h),enabled:e,refetchInterval:6e4});if(!e)return null;let b=g?.data.map(e=>({time:(vf(e.recorded_at)||new Date).getTime(),humidity:e.humidity,temperature:e.temperature}))||[],x=Date.now()-h*60*60*1e3,S=Date.now(),C=[...b];if(C.length>0){let e=C[0];e.time>x&&C.unshift({...e,time:x});let t=C[C.length-1];t.time{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`},M=j(C.map(e=>e.humidity)),N=j(C.map(e=>e.temperature)),P=({trend:e})=>e===`up`?(0,K.jsx)(Su,{className:`w-4 h-4 text-red-400`}):e===`down`?(0,K.jsx)(xu,{className:`w-4 h-4 text-green-400`}):(0,K.jsx)(al,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),F=e=>e==null?`#9ca3af`:e<=w?`#22a352`:e<=T?`#d4a017`:`#c62828`,I=e=>e==null?`#9ca3af`:e<=E?`#22a352`:e<=D?`#d4a017`:`#c62828`,L=`var(--bg-secondary)`,R=`var(--bg-primary)`,z=`var(--border-color)`,B=`var(--text-primary)`,V=`var(--text-secondary)`,ee=`var(--text-muted)`;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:L},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:z},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold`,style:{color:B},children:[a,` `,c(`common.history`,`History`)]}),(0,K.jsx)(`p`,{className:`text-sm`,style:{color:V},children:r})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:V},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,K.jsxs)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:R},children:[(0,K.jsxs)(`button`,{onClick:()=>f(`humidity`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${d===`humidity`?`bg-blue-600 text-white`:``}`,style:d===`humidity`?void 0:{color:V},children:[(0,K.jsx)(Us,{className:`w-4 h-4`}),c(`common.humidity`,`Humidity`)]}),(0,K.jsxs)(`button`,{onClick:()=>f(`temperature`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${d===`temperature`?`bg-orange-600 text-white`:``}`,style:d===`temperature`?void 0:{color:V},children:[(0,K.jsx)(vu,{className:`w-4 h-4`}),c(`common.temperature`,`Temperature`)]})]}),(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:R},children:cU.map(e=>(0,K.jsx)(`button`,{onClick:()=>u(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${l===e.value?`bg-bambu-green text-white`:``}`,style:l===e.value?void 0:{color:V},children:e.label},e.value))})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:d===`humidity`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:F(k)},children:k==null?`—`:`${k}%`}),(0,K.jsx)(P,{trend:M})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:B},children:g?.avg_humidity==null?`—`:`${g.avg_humidity}%`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-green-500`,children:g?.min_humidity==null?`—`:`${g.min_humidity}%`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:g?.max_humidity==null?`—`:`${g.max_humidity}%`})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:I(A)},children:A==null?`—`:`${A}°C`}),(0,K.jsx)(P,{trend:N})]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:B},children:g?.avg_temperature==null?`—`:`${g.avg_temperature}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-blue-500`,children:g?.min_temperature==null?`—`:`${g.min_temperature}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:R},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:V},children:c(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:g?.max_temperature==null?`—`:`${g.max_temperature}°C`})]})]})}),(0,K.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:R},children:_?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:c(`common.loading`,`Loading...`)}):v?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center text-red-500`,children:c(`common.error`,`Error loading data`)}):C.length===0?(0,K.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:c(`common.noData`,`No data available for this time range`)}):(0,K.jsx)(mA,{width:`100%`,height:300,children:(0,K.jsxs)(eU,{data:C,children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:z}),(0,K.jsx)(_H,{dataKey:`time`,type:`number`,domain:[Date.now()-h*60*60*1e3,Date.now()],tickFormatter:e=>{let t=new Date(e);return h>24?t.toLocaleDateString([],{day:`numeric`,month:`short`}):t.toLocaleTimeString([],_f({hour:`2-digit`,minute:`2-digit`},m))},stroke:ee,tick:{fontSize:12}}),(0,K.jsx)(SH,{stroke:ee,tick:{fontSize:12},domain:d===`humidity`?[0,100]:[`auto`,`auto`],tickFormatter:e=>d===`humidity`?`${e}%`:`${e}°C`}),(0,K.jsx)(lz,{contentStyle:{backgroundColor:L,border:`1px solid ${z}`,borderRadius:`8px`,color:B},labelFormatter:e=>new Date(e).toLocaleString(void 0,_f({year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},m)),formatter:e=>[d===`humidity`?`${e??0}%`:`${e??0}°C`,d===`humidity`?`Humidity`:`Temperature`]}),(0,K.jsx)(fj,{}),d===`humidity`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dV,{y:w,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,K.jsx)(dV,{y:T,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dV,{y:E,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,K.jsx)(dV,{y:D,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}),(0,K.jsx)(PV,{type:`monotone`,dataKey:d,name:d===`humidity`?`Humidity`:`Temperature`,stroke:d===`humidity`?`#3b82f6`:`#f97316`,strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0})]})})}),(0,K.jsx)(`div`,{className:`text-xs text-center`,style:{color:V},children:c(`amsHistory.recordingInfo`,`Data is recorded every 5 minutes while the printer is connected`)})]})]})})}function lU({checked:e,onChange:t,disabled:n}){return(0,K.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,disabled:n,onClick:r=>{r.preventDefault(),r.stopPropagation(),n||t(!e)},className:`relative inline-flex w-11 h-7 md:w-9 md:h-5 rounded-full transition-colors flex-shrink-0 focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${n?`bg-bambu-dark-tertiary/50 cursor-not-allowed opacity-50`:e?`bg-bambu-green cursor-pointer`:`bg-bambu-dark-tertiary cursor-pointer hover:bg-bambu-dark-tertiary/80`}`,children:(0,K.jsx)(`span`,{className:`pointer-events-none absolute top-[3px] md:top-[2px] left-[3px] md:left-[2px] w-5 h-5 md:w-4 md:h-4 bg-white rounded-full shadow transition-transform duration-200 ease-in-out ${e?`translate-x-4`:`translate-x-0`}`})})}function LOe(e,t,n){let r=n===1||e>=128,i=e>=128?e-128:e,a=String.fromCharCode(65+i);return r?`HT·${t+1}`:`${a}·${t+1}`}function ROe(e){let t=(e||``).replace(`#`,``).slice(0,6);if(t.length!==6)return`#FFFFFF`;let n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);return[n,r,i].some(Number.isNaN)?`#FFFFFF`:(.2126*n+.7152*r+.0722*i)/255>.55?`#1A1A1A`:`#FFFFFF`}function zOe({group:e,trayCountByAms:t,innerBg:n,textPrimary:r,textSecondary:i,showExtruderBadge:a,extruderLabel:o}){let s=Of(e.trayColor||void 0),c=ROe(e.trayColor),l=c===`#FFFFFF`?`rgba(0,0,0,0.45)`:`rgba(255,255,255,0.7)`,u=e.members.length;return(0,K.jsxs)(`div`,{className:`relative flex flex-col items-center`,children:[a&&(0,K.jsx)(`span`,{className:`absolute -top-1 -left-1 z-10 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shadow`,style:{backgroundColor:r,color:n},"aria-label":o,title:o,children:o}),(0,K.jsxs)(`svg`,{viewBox:`-100 -100 200 200`,className:`w-44 h-44`,children:[(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`95`,fill:`none`,stroke:i,strokeOpacity:`0.25`,strokeWidth:`1`}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`92`,fill:s}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:n}),(0,K.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:`none`,stroke:i,strokeOpacity:`0.3`,strokeWidth:`1`}),(0,K.jsx)(`text`,{x:`0`,y:`-4`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`14`,fontWeight:`700`,fill:r,children:e.displayName||`—`}),(0,K.jsx)(`text`,{x:`0`,y:`16`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`11`,fontWeight:`500`,fill:i,children:`${u}× ↻`}),e.members.map((e,n)=>{let r=(n*360/u-90)*Math.PI/180,i=76*Math.cos(r),a=76*Math.sin(r),o=LOe(e.amsId,e.slotIdx,t.get(e.amsId)??4),s=Math.max(22,o.length*7+8);return(0,K.jsxs)(`g`,{children:[(0,K.jsx)(`rect`,{x:i-s/2,y:a-9,width:s,height:18,rx:9,ry:9,fill:l}),(0,K.jsx)(`text`,{x:i,y:a,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`12`,fontWeight:`700`,fill:c,children:o})]},`${e.amsId}-${e.slotIdx}`)})]})]})}function BOe({isOpen:e,state:t,amsUnits:n,amsExtruderMap:r,isDualNozzle:i,canToggle:a,pending:o,onToggle:s,onClose:c}){let{t:l}=W();if((0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,c]),!e)return null;let u=`var(--bg-secondary)`,d=`var(--border-color)`,f=`var(--text-primary)`,p=`var(--text-secondary)`,m=(()=>{if(!i||!r)return!1;let e=new Set;for(let t of n||[]){let n=r[String(t.id)];if(n!==void 0&&(e.add(Number(n)),e.size>1))return!0}return!1})(),h=Qf(n,r,m),g=new Map((n||[]).map(e=>[e.id,e.tray.length])),_=h.filter(e=>e.members.length>=2),v=t===!0,b=t===null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:c,"data-testid":`ams-backup-modal`,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-2xl max-h-[90vh] overflow-hidden shadow-xl flex flex-col`,style:{backgroundColor:u},onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`ams-backup-modal-title`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:d},children:[(0,K.jsx)(`h2`,{id:`ams-backup-modal-title`,className:`text-base font-semibold`,style:{color:f},children:l(`printers.amsBackup.modalTitle`)}),(0,K.jsx)(`button`,{type:`button`,onClick:c,className:`p-1 rounded-md transition-colors hover:bg-black/10`,style:{color:p},"aria-label":l(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:d,backgroundColor:`var(--bg-primary)`},children:[(0,K.jsxs)(`div`,{className:`min-w-0 mr-3`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium`,style:{color:f},children:l(b?`printers.amsBackup.stateUnknown`:v?`printers.amsBackup.stateOn`:`printers.amsBackup.stateOff`)}),(0,K.jsx)(`p`,{className:`text-xs mt-0.5`,style:{color:p},children:l(`printers.amsBackup.modalHelp`)})]}),(0,K.jsx)(lU,{checked:v,onChange:s,disabled:!a||b||o})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-6`,children:_.length===0?(0,K.jsx)(`p`,{className:`text-sm text-center py-8`,style:{color:p},children:l(`printers.amsBackup.modalNoPairs`)}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6 justify-items-center`,children:_.map(e=>(0,K.jsx)(zOe,{group:e,trayCountByAms:g,innerBg:u,textPrimary:f,textSecondary:p,showExtruderBadge:m,extruderLabel:e.extruder===0?l(`printers.amsBackup.extruderRightShort`):l(`printers.amsBackup.extruderLeftShort`)},e.key))})})]})})}var uU=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}],dU={nozzle:`#fb923c`,nozzle_2:`#f97316`,bed:`#60a5fa`,chamber:`#34d399`},VOe={nozzle:`#fed7aa`,nozzle_2:`#fdba74`,bed:`#bfdbfe`,chamber:`#a7f3d0`};function HOe({isOpen:e,onClose:t,printerId:n,printerName:r,initialKind:i=`nozzle`,availableKinds:a=[`nozzle`,`bed`,`chamber`]}){let{t:o}=W(),[s,c]=(0,y.useState)(`24h`),[l,u]=(0,y.useState)(i);(0,y.useEffect)(()=>{u(i)},[i]);let{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings}),f=d?.time_format||`system`;(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let p=uU.find(e=>e.value===s)?.hours||24,{data:m,isLoading:h,error:g}=q({queryKey:[`printer-sensor-history`,n,p,a.join(`,`)],queryFn:()=>Q.getPrinterSensorHistory(n,p,a),enabled:e,refetchInterval:6e4});if(!e)return null;let _=m?.series.find(e=>e.sensor_kind===l),v=(_?.data||[]).map(e=>({time:(vf(e.recorded_at)||new Date).getTime(),value:e.value,target:e.target})),b=Date.now()-p*60*60*1e3,x=Date.now(),S=[...v];if(S.length>0){let e=S[0];e.time>b&&S.unshift({...e,time:b});let t=S[S.length-1];t.time{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`})(S.map(e=>e.value)),D=({trend:e})=>e===`up`?(0,K.jsx)(Su,{className:`w-4 h-4 text-red-400`}):e===`down`?(0,K.jsx)(xu,{className:`w-4 h-4 text-green-400`}):(0,K.jsx)(al,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),O=`var(--bg-secondary)`,k=`var(--bg-primary)`,A=`var(--border-color)`,j=`var(--text-primary)`,M=`var(--text-secondary)`,N=`var(--text-muted)`,P=e=>{switch(e){case`nozzle`:return o(`printers.heaterHistory.nozzle`,`Nozzle`);case`nozzle_2`:return o(`printers.heaterHistory.nozzle2`,`Nozzle 2`);case`bed`:return o(`printers.heaterHistory.bed`,`Bed`);case`chamber`:return o(`printers.heaterHistory.chamber`,`Chamber`)}},F=({k:e})=>e===`nozzle`||e===`nozzle_2`?(0,K.jsx)(ac,{className:`w-4 h-4`}):e===`bed`?(0,K.jsx)(ou,{className:`w-4 h-4`}):(0,K.jsx)(Wo,{className:`w-4 h-4`});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,K.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:O},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:A},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,style:{color:j},children:o(`printers.heaterHistory.title`,`Heater History`)}),(0,K.jsx)(`p`,{className:`text-sm`,style:{color:M},children:r})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:M},"aria-label":o(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:k},children:a.map(e=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${l===e?`text-white`:``}`,style:l===e?{backgroundColor:dU[e]}:{color:M},children:[(0,K.jsx)(F,{k:e}),P(e)]},e))}),(0,K.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:k},children:uU.map(e=>(0,K.jsx)(`button`,{onClick:()=>c(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${s===e.value?`bg-bambu-green text-white`:``}`,style:s===e.value?void 0:{color:M},children:e.label},e.value))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.current`,`Current`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:dU[l]},children:w==null?`—`:`${Math.round(w)}°C`}),(0,K.jsx)(D,{trend:E})]}),T!=null&&T>0&&(0,K.jsxs)(`p`,{className:`text-xs mt-1`,style:{color:M},children:[o(`common.target`,`Target`),`: `,Math.round(T),`°C`]})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.average`,`Average`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.avg_value==null?`—`:`${_.avg_value}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.min`,`Min`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.min_value==null?`—`:`${Math.round(_.min_value)}°C`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:[(0,K.jsx)(`p`,{className:`text-xs`,style:{color:M},children:o(`common.max`,`Max`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:j},children:_?.max_value==null?`—`:`${Math.round(_.max_value)}°C`})]})]}),(0,K.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:k},children:h?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:M},children:o(`common.loading`,`Loading...`)}):g?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center text-red-400`,children:o(`printers.heaterHistory.error`,`Failed to load history`)}):S.length===0?(0,K.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:M},children:o(`printers.heaterHistory.empty`,`No data recorded yet`)}):(0,K.jsx)(mA,{width:`100%`,height:300,children:(0,K.jsxs)(eU,{data:S,margin:{top:5,right:10,left:0,bottom:5},children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:A}),(0,K.jsx)(_H,{dataKey:`time`,type:`number`,domain:[b,x],tickFormatter:e=>new Date(e).toLocaleTimeString([],_f({hour:`2-digit`,minute:`2-digit`},f)),stroke:N,fontSize:11}),(0,K.jsx)(SH,{stroke:N,fontSize:11,domain:[0,`auto`],tickFormatter:e=>`${Math.round(e)}°`}),(0,K.jsx)(lz,{contentStyle:{backgroundColor:O,border:`1px solid ${A}`,borderRadius:6,color:j},labelFormatter:e=>new Date(e).toLocaleString(void 0,_f({month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},f)),formatter:e=>e==null?`—`:`${Math.round(Number(e))}°C`}),(0,K.jsx)(fj,{}),(0,K.jsx)(PV,{type:`monotone`,dataKey:`value`,name:o(`common.current`,`Current`),stroke:dU[l],strokeWidth:2,dot:!1,isAnimationActive:!1}),(0,K.jsx)(PV,{type:`stepAfter`,dataKey:`target`,name:o(`common.target`,`Target`),stroke:VOe[l],strokeDasharray:`4 4`,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})]})]})})}function fU({data:e,children:t,disabled:n,className:r=``,spoolman:i,inventory:a,configureSlot:o,actions:s}){let{t:c}=W(),l=$n(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(`top`),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),x=(0,y.useRef)(null),S=(0,y.useRef)(null),C=(0,y.useRef)(null),w=()=>{let t=e.trayUuid;t&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(t).then(()=>{_(!0),setTimeout(()=>_(!1),2e3)}).catch(()=>{T(t)}):T(t))},T=e=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`),_(!0),setTimeout(()=>_(!1),2e3)}catch{console.error(`Failed to copy to clipboard`)}document.body.removeChild(t)};(0,y.useLayoutEffect)(()=>{if(!u){h(null);return}let e=()=>{if(!x.current||!S.current)return;let e=x.current.getBoundingClientRect(),t=S.current.offsetHeight,n=S.current.offsetWidth,r=e.top-56,i=window.innerHeight-e.bottom,a=rr?`bottom`:`top`,o=e.left+e.width/2,s=Math.max(8,Math.min(o-n/2,window.innerWidth-n-8)),c=a===`top`?e.top-t-8:e.bottom+8;p(a),h({top:c,left:s})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[u]);let E=()=>{n||(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>d(!0),80))},D=()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>d(!1),100)};(0,y.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]);let O=e=>e<=15?`#ef4444`:e<=30?`#f97316`:e<=50?`#eab308`:`#22c55e`,k=e.colorHex?`#${e.colorHex.replace(`#`,``)}`:null,A=a?.assignedSpool?.remainingWeightGrams??null;return(0,K.jsxs)(`div`,{ref:x,"data-testid":`filament-slot`,className:`relative ${r}`,onMouseEnter:E,onMouseLeave:D,children:[t,u&&(0,Op.createPortal)((0,K.jsxs)(`div`,{ref:S,className:`fixed z-[60]`,style:{top:m?.top??-9999,left:m?.left??-9999,maxWidth:`calc(100vw - 24px)`,visibility:m?`visible`:`hidden`},onMouseEnter:E,onMouseLeave:D,children:[(0,K.jsxs)(`div`,{className:` w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm @@ -8500,7 +8500,7 @@ void main() { border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent ${f===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`} - `})]}),document.body),v&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center`,onClick:()=>b(!1),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(`div`,{className:`relative bg-bambu-dark-secondary rounded-lg shadow-xl w-full max-w-sm mx-4 border border-bambu-dark-tertiary`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:c(`spoolman.unlinkConfirmTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:c(`spoolman.unlinkConfirmMessage`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>b(!1),className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-bambu-dark hover:bg-bambu-dark-tertiary text-white`,children:c(`common.cancel`)}),(0,K.jsx)(`button`,{onClick:()=>{i?.onUnlinkSpool?.(),b(!1)},className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-red-500/20 hover:bg-red-500/30 text-red-400`,children:c(`inventory.unassignSpool`)})]})]})})]})]})}function fU({children:e,className:t=``,configureSlot:n,onAssignSpool:r,actions:i,kind:a}){let{t:o}=W(),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>c(!0),80)},h=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>c(!1),100)};return(0,y.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,y.useLayoutEffect)(()=>{if(!s){u(null);return}let e=()=>{if(!d.current||!f.current)return;let e=d.current.getBoundingClientRect(),t=f.current.offsetHeight,n=f.current.offsetWidth,r=e.left+e.width/2,i=Math.max(8,Math.min(r-n/2,window.innerWidth-n-8));u({top:e.top-t-8,left:i})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]),(0,K.jsxs)(`div`,{ref:d,className:`relative ${t}`,onMouseEnter:m,onMouseLeave:h,children:[e,s&&(0,Op.createPortal)((0,K.jsxs)(`div`,{ref:f,className:`fixed z-[60]`,style:{top:l?.top??-9999,left:l?.left??-9999,visibility:l?`visible`:`hidden`},onMouseEnter:m,onMouseLeave:h,children:[(0,K.jsxs)(`div`,{className:` + `})]}),document.body),v&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center`,onClick:()=>b(!1),children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`}),(0,K.jsx)(`div`,{className:`relative bg-bambu-dark-secondary rounded-lg shadow-xl w-full max-w-sm mx-4 border border-bambu-dark-tertiary`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:c(`spoolman.unlinkConfirmTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:c(`spoolman.unlinkConfirmMessage`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>b(!1),className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-bambu-dark hover:bg-bambu-dark-tertiary text-white`,children:c(`common.cancel`)}),(0,K.jsx)(`button`,{onClick:()=>{i?.onUnlinkSpool?.(),b(!1)},className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-red-500/20 hover:bg-red-500/30 text-red-400`,children:c(`inventory.unassignSpool`)})]})]})})]})]})}function pU({children:e,className:t=``,configureSlot:n,onAssignSpool:r,actions:i,kind:a}){let{t:o}=W(),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=(0,y.useRef)(null),m=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>c(!0),80)},h=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>c(!1),100)};return(0,y.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,y.useLayoutEffect)(()=>{if(!s){u(null);return}let e=()=>{if(!d.current||!f.current)return;let e=d.current.getBoundingClientRect(),t=f.current.offsetHeight,n=f.current.offsetWidth,r=e.left+e.width/2,i=Math.max(8,Math.min(r-n/2,window.innerWidth-n-8));u({top:e.top-t-8,left:i})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]),(0,K.jsxs)(`div`,{ref:d,className:`relative ${t}`,onMouseEnter:m,onMouseLeave:h,children:[e,s&&(0,Op.createPortal)((0,K.jsxs)(`div`,{ref:f,className:`fixed z-[60]`,style:{top:l?.top??-9999,left:l?.left??-9999,visibility:l?`visible`:`hidden`},onMouseEnter:m,onMouseLeave:h,children:[(0,K.jsxs)(`div`,{className:` bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md shadow-lg overflow-hidden `,children:[(0,K.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap`,children:o(a===`reset`?`ams.emptySlotReset`:`ams.emptySlot`)}),(n?.enabled||r||i)&&(0,K.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[n?.enabled&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),n.onConfigure?.()},className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue`,title:o(`ams.configureSlot`),children:[(0,K.jsx)(Hl,{className:`w-3.5 h-3.5`}),o(`ams.configure`)]}),r&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),r()},className:`w-full flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/30 text-bambu-blue`,children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5`}),o(`inventory.assignSpool`)]}),i&&(0,K.jsx)(`div`,{className:`pt-1 mt-1 border-t border-bambu-dark-tertiary space-y-1`,children:i})]})]}),(0,K.jsx)(`div`,{className:` @@ -8508,8 +8508,8 @@ void main() { border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[5px] border-t-bambu-dark-tertiary - `})]}),document.body)]})}function pU({isOpen:e,onClose:t,tagUid:n,trayUuid:r,printerId:i,amsId:a,trayId:o}){let{t:s}=W(),c=no(),{showToast:l}=Td(),[u,d]=(0,y.useState)(``),f=r||n,{data:p,isLoading:m}=q({queryKey:[`unlinked-spools`],queryFn:Q.getUnlinkedSpools,enabled:e}),h=(0,y.useMemo)(()=>p?p.filter(e=>{if(!u)return!0;let t=u.toLowerCase();return e.filament_name&&e.filament_name.toLowerCase().includes(t)||e.filament_vendor&&e.filament_vendor.toLowerCase().includes(t)||e.filament_material&&e.filament_material.toLowerCase().includes(t)||String(e.id).includes(t)}):[],[p,u]),g=J({mutationFn:e=>Q.linkSpool(e,{spoolTag:f,printerId:i,amsId:a,trayId:o}),onSuccess:()=>{c.invalidateQueries({queryKey:[`unlinked-spools`]}),c.invalidateQueries({queryKey:[`linked-spools`]}),c.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),l(s(`spoolman.linkSuccess`),`success`),t()},onError:e=>{l(e.message||s(`spoolman.linkFailed`),`error`)}});return e?(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative bg-bambu-dark-secondary rounded-xl shadow-xl w-full max-w-md mx-4 max-h-[80vh] flex flex-col border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-white/10`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Hc,{className:`w-5 h-5 text-bambu-green`}),s(`spoolman.selectSpool`)]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[`AMS `,a,` T`,o,` · Printer #`,i]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-white/10`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:s(`inventory.searchSpools`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark rounded-lg border border-white/10 text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),(r||n)&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-2 font-mono truncate`,title:r||n,children:[`Tag: `,r||n]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 min-h-0`,children:m?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):h.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8 text-sm`,children:s(`inventory.noSpoolsMatch`)}):h.map(e=>(0,K.jsxs)(`button`,{onClick:()=>g.mutate(e.id),disabled:g.isPending||!f,className:`w-full flex items-center gap-3 p-3 rounded-lg hover:bg-white/5 transition-colors text-left`,children:[(0,K.jsx)(`span`,{className:`w-6 h-6 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.filament_color_hex?`#${e.filament_color_hex}`:`#808080`}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white font-medium truncate`,children:e.filament_name||s(`spoolman.spoolId`)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray truncate`,children:[e.filament_vendor?`${e.filament_vendor} · `:``,e.filament_material||`Unknown`,` · #`,e.id]})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.remaining_weight==null?`—`:`${Math.round(e.remaining_weight)}g`})]},e.id))}),(0,K.jsx)(`div`,{className:`p-4 border-t border-white/10 flex justify-end`,children:(0,K.jsx)($,{variant:`ghost`,onClick:t,children:s(`inventory.cancel`)||`Cancel`})})]})]}):null}function WOe(e,t){if(!t)return!0;let n=t.toLowerCase();return String(e.id).includes(n)||e.material.toLowerCase().includes(n)||(e.brand?.toLowerCase().includes(n)??!1)||(e.color_name?.toLowerCase().includes(n)??!1)||(e.subtype?.toLowerCase().includes(n)??!1)||(e.note?.toLowerCase().includes(n)??!1)||(e.slicer_filament_name?.toLowerCase().includes(n)??!1)||(e.storage_location?.toLowerCase().includes(n)??!1)}function mU(e,t){return t?e.filter(e=>WOe(e,t)):e}function hU({isOpen:e,onClose:t,printerId:n,amsId:r,trayId:i,trayInfo:a,spoolmanEnabled:o}){let{t:s}=W(),c=no(),{showToast:l}=Td(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null);(0,y.useEffect)(()=>{p(null),h(null)},[u]);let[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(null);(0,y.useEffect)(()=>{e&&d(!1)},[e]);let{data:T,isLoading:E}=q({queryKey:[`inventory-spools`,`assign-modal`],queryFn:()=>Q.getSpools(!0),enabled:e&&!o}),{data:D}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:e}),{data:O}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),enabled:e}),{data:k,isLoading:A}=q({queryKey:[`spoolman-inventory-spools`,`assign-modal`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:e&&!!o}),{data:j}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e&&!!o}),M=(0,y.useMemo)(()=>j?new Set(j.filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i)).map(e=>e.spoolman_spool_id)):new Set,[j,n,r,i]),N=()=>{Q.refreshPrinterStatus(n).catch(()=>{}),c.invalidateQueries({queryKey:[`printerStatus`,n]})},P=J({mutationFn:e=>Q.assignSpool({spool_id:e,printer_id:n,ams_id:r,tray_id:i}),onSuccess:e=>{c.setQueryData([`spool-assignments`],t=>{let a=(t||[]).filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i));return a.push(e),a}),c.invalidateQueries({queryKey:[`spool-assignments`]}),N(),l(s(e.pending_config?`inventory.assignPendingInsert`:`inventory.assignSuccess`),`success`),S(!1),b(null),w(null),t()},onError:e=>{l(`${s(`inventory.assignFailed`)}: ${e.message}`,`error`)}}),F=J({mutationFn:e=>Q.assignSpoolmanSlot({spoolman_spool_id:e,printer_id:n,ams_id:r,tray_id:i}),onSuccess:()=>{c.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),c.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),N(),l(s(`inventory.assignSuccess`),`success`),t()},onError:e=>{l(`${s(`inventory.assignFailed`)}: ${e.message}`,`error`)}}),I=e=>(e??``).trim().toUpperCase(),L=(e,t)=>{let n=I(e),r=I(t);return!n||!r?`none`:n===r?`exact`:r.includes(n)||n.includes(r)?`partial`:`none`},R=e=>e.split(`@`)[0].trim(),z=(e,t)=>{let n=R(I(e)),r=R(I(t));return!n||!r?!1:n===r};if(!e)return null;let B=new Set((D||[]).filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i)).map(e=>e.spool_id)),V=T?.filter(e=>!e.archived_at&&(u||!B.has(e.id))),ee=V;if(!u){let e=R(I(a?.profile)),t=I(a?.material||a?.type);(e||t)&&(ee=ee?.filter(n=>{let r=R(I(n.slicer_filament_name||n.slicer_filament)),i=I(n.material);return e&&r&&r===e?!0:t&&i?i===t||t.includes(i)||i.includes(t):!r&&!i}))}g&&ee&&(ee=mU(ee,g));let te=()=>{if(m!==null){F.mutate(m);return}if(!f)return;let e=T?.find(e=>e.id===f);if(!e){l(s(`inventory.assignFailed`),`error`);return}if(!O?.disable_filament_warnings&&a){let t=a.material||a.type,n=L(e.material,t),r=e.slicer_filament_name||e.slicer_filament,i=a.profile||a.type,o=z(r,i);if(n!==`exact`){let a;a=n===`none`&&!o?`material_profile`:n===`partial`&&!o?`partial_profile`:n===`none`?`material`:`partial`,b(f),w({type:a,spoolMaterial:e.material||``,trayMaterial:t||``,spoolProfile:r||void 0,trayProfile:i||void 0}),S(!0);return}}P.mutate(f)},ne=()=>{v&&(P.mutate(v),S(!1),b(null))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-start sm:items-center justify-center p-4 overflow-y-auto`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-2xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] overflow-hidden flex flex-col my-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:s(`inventory.assignSpool`)})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto`,children:[a&&(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:[s(`inventory.selectSpool`),`:`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.color&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${a.color}`}}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:a.type||s(`ams.emptySlot`)}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,a.location,`)`]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:s(`inventory.searchSpools`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!o&&(E?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):ee&&ee.length>0?(0,K.jsx)(`div`,{className:`max-h-96 overflow-y-auto grid grid-cols-2 sm:grid-cols-3 gap-2`,children:ee.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{p(e.id),h(null)},title:e.note||void 0,className:`p-2.5 rounded-lg border text-left transition-colors ${f===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.color_name||``})]}),e.label_weight&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[Math.max(0,Math.round(e.label_weight-e.weight_used)),` / `,e.label_weight,`g`]})]},e.id))}):V&&V.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:s(`inventory.noAvailableSpools`)}),T&&(0,K.jsxs)(`p`,{className:`text-[10px] mt-2 opacity-60`,children:[T.length,` fetched · `,T.filter(e=>e.archived_at).length,` archived ·`,` `,T.filter(e=>B.has(e.id)).length,` assigned to other slots`]})]}):(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:s(`inventory.noSpoolsMatch`)}),V&&(0,K.jsxs)(`p`,{className:`text-[10px] mt-2 opacity-60`,children:[V.length,` unassigned spools — `,V.length-(ee?.length??0),` filtered by tray match. Try "Show all spools".`]})]})),o&&(0,K.jsx)(K.Fragment,{children:A?(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`})}):k&&k.filter(e=>!e.archived_at&&!M.has(e.id)).length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide pt-1`,children:s(`inventory.spoolmanSpools`)}),(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto grid grid-cols-2 sm:grid-cols-3 gap-2`,children:mU(k.filter(e=>!e.archived_at&&!M.has(e.id)),g).map(e=>(0,K.jsxs)(`button`,{onClick:()=>{h(e.id),p(null)},title:e.note||void 0,className:`p-2.5 rounded-lg border text-left transition-colors ${m===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.color_name||``})]}),e.label_weight&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[Math.max(0,Math.round(e.label_weight-e.weight_used)),` / `,e.label_weight,`g`]})]},`spoolman-${e.id}`))})]}):null})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{id:`disable-filtering-toggle`,type:`checkbox`,checked:u,onChange:()=>d(e=>!e),className:`accent-bambu-green w-4 h-4 rounded focus:ring-0 border-bambu-dark-tertiary`}),(0,K.jsx)(`label`,{htmlFor:`disable-filtering-toggle`,className:`text-xs text-bambu-gray select-none cursor-pointer`,children:s(`inventory.showAllSpools`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:s(`common.cancel`)}),(0,K.jsx)($,{onClick:te,disabled:!f&&m===null||P.isPending||F.isPending,children:P.isPending||F.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),s(`inventory.assigning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pl,{className:`w-4 h-4`}),s(`inventory.assignSpool`)]})})]})]}),P.isError&&(0,K.jsx)(`div`,{className:`mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:P.error.message})]})]}),x&&a&&f&&C&&(()=>{let e=``;return C.type===`material`?e=s(`inventory.assignMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location}):C.type===`partial`?e=s(`inventory.assignPartialMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location}):C.type===`material_profile`?e=`${s(`inventory.assignMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location})}\n\n${s(`inventory.assignProfileMismatchMessage`,{spoolProfile:C.spoolProfile||s(`common.unknown`),trayProfile:C.trayProfile||s(`common.unknown`),location:a.location})}`:C.type===`partial_profile`&&(e=`${s(`inventory.assignPartialMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location})}\n\n${s(`inventory.assignProfileMismatchMessage`,{spoolProfile:C.spoolProfile||s(`common.unknown`),trayProfile:C.trayProfile||s(`common.unknown`),location:a.location})}`),e=`${e}\n\n${s(`inventory.assignReconfigureNote`)}`,(0,K.jsx)(Ad,{title:s(`inventory.assignMismatchTitle`),message:e,confirmText:s(`inventory.assignMismatchConfirm`),variant:`warning`,overlayZIndex:`z-[110]`,isLoading:P.isPending,onConfirm:ne,onCancel:()=>{P.isPending||(S(!1),b(null),w(null))}})})()]})}var GOe={bambuModelByShortCode:{}},gU={"A1 MINI":[`A1M`]};function _U(e,t){let n=e.toUpperCase(),r=t.toUpperCase();if(n===r)return!0;let i=gU[r];if(i&&i.includes(n))return!0;let a=gU[n];return!!(a&&a.includes(r))}function KOe(e){let t={};for(let[n,r]of Object.entries(e))r in t||(t[r]=n.replace(/^Bambu Lab\s+/,``));return t}function vU(e={}){return{bambuModelByShortCode:KOe(e)}}function yU(e){return e.replace(/\s+/g,``).toLowerCase()}var qOe=`0.4`;function bU(e){let t=e.match(/^(.*?)\s+([\d.]+)\s*nozzle\s*$/i);return t?{stripped:t[1].trim(),nozzle:t[2]}:{stripped:e.trim(),nozzle:null}}function JOe(e){let t=e.indexOf(`@BBL `);if(t<0)return null;let{stripped:n,nozzle:r}=bU(e.slice(t+5).trim());return n?{token:n,nozzle:r}:null}function YOe(e){let t=e.match(/^Bambu Lab\s+(.+)$/i);if(!t)return null;let{stripped:n,nozzle:r}=bU(t[1]);return n?{model:n,nozzle:r}:null}function XOe(e,t,n){let r=JOe(e);if(!r)return`unknown`;let i=n[r.token]??r.token,a=YOe(t);return a?yU(a.model)!==yU(i)&&!_U(r.token,a.model)||a.nozzle!==null&&(r.nozzle??qOe)!==a.nozzle?`mismatch`:`match`:`unknown`}function xU(e,t,n,r){if(!n)return`unknown`;let i=e.compatible_printers;return i&&i.length>0?i.includes(n)?`match`:`mismatch`:XOe(e.name,n,r.bambuModelByShortCode)}var SU=[`PLA`,`PETG`,`ABS`,`TPU`,`ASA`,`PC`,`PA`,`PVA`,`HIPS`,`PA-CF`,`PETG-CF`,`PLA-CF`],CU=[`Bambu`,`PolyLite`,`PolyTerra`,`eSUN`,`Overture`,`Fiberon`,`SUNLU`,`Inland`,`Hatchbox`,`Generic`],wU=`Basic.Matte.Silk.Silk+.Tough.Tough+.HF.High Flow.Engineering.CF.GF.Galaxy.Glow.Marble.Metal.Rainbow.Sparkle.Wood.Translucent.Transparent.Clear.Lite.Pro.Plus.Max.Super.Ultra.Flex.Soft.Hard.Strong.Impact.Heat Resistant.UV Resistant.ESD.Conductive.Magnetic.Gradient.Dual Color.Tri Color.Multicolor`.split(`.`),TU=[{name:`Black`,hex:`000000`},{name:`White`,hex:`FFFFFF`},{name:`Gray`,hex:`808080`},{name:`Red`,hex:`FF0000`},{name:`Orange`,hex:`FFA500`},{name:`Yellow`,hex:`FFFF00`},{name:`Green`,hex:`00AE42`},{name:`Blue`,hex:`0066FF`},{name:`Purple`,hex:`8B00FF`},{name:`Pink`,hex:`FF69B4`},{name:`Brown`,hex:`8B4513`},{name:`Silver`,hex:`C0C0C0`},{name:`Clear`,hex:`00000000`}],ZOe=[{name:`Dark Red`,hex:`8B0000`},{name:`Crimson`,hex:`DC143C`},{name:`Coral`,hex:`FF7F50`},{name:`Salmon`,hex:`FA8072`},{name:`Dark Orange`,hex:`FF8C00`},{name:`Peach`,hex:`FFDAB9`},{name:`Gold`,hex:`FFD700`},{name:`Khaki`,hex:`F0E68C`},{name:`Lemon`,hex:`FFF44F`},{name:`Lime`,hex:`32CD32`},{name:`Forest Green`,hex:`228B22`},{name:`Olive`,hex:`808000`},{name:`Mint`,hex:`98FF98`},{name:`Teal`,hex:`008080`},{name:`Navy`,hex:`000080`},{name:`Sky Blue`,hex:`87CEEB`},{name:`Royal Blue`,hex:`4169E1`},{name:`Cyan`,hex:`00FFFF`},{name:`Turquoise`,hex:`40E0D0`},{name:`Violet`,hex:`EE82EE`},{name:`Magenta`,hex:`FF00FF`},{name:`Indigo`,hex:`4B0082`},{name:`Lavender`,hex:`E6E6FA`},{name:`Plum`,hex:`DDA0DD`},{name:`Hot Pink`,hex:`FF69B4`},{name:`Rose`,hex:`FF007F`},{name:`Blush`,hex:`FFB6C1`},{name:`Chocolate`,hex:`D2691E`},{name:`Tan`,hex:`D2B48C`},{name:`Beige`,hex:`F5F5DC`},{name:`Maroon`,hex:`800000`},{name:`Dark Gray`,hex:`404040`},{name:`Light Gray`,hex:`D3D3D3`},{name:`Charcoal`,hex:`36454F`},{name:`Ivory`,hex:`FFFFF0`},{name:`Bambu Green`,hex:`00AE42`},{name:`Jade White`,hex:`E8E8E8`},{name:`Titan Gray`,hex:`5A5A5A`}],EU=[...TU,...ZOe],DU=`bambuddy-recent-colors`,QOe=[{code:`GFL00`,name:`Bambu PLA Basic`,displayName:`Bambu PLA Basic`,isCustom:!1,allCodes:[`GFL00`]},{code:`GFL01`,name:`Bambu PLA Matte`,displayName:`Bambu PLA Matte`,isCustom:!1,allCodes:[`GFL01`]},{code:`GFL05`,name:`Generic PLA`,displayName:`Generic PLA`,isCustom:!1,allCodes:[`GFL05`]},{code:`GFG00`,name:`Bambu PETG Basic`,displayName:`Bambu PETG Basic`,isCustom:!1,allCodes:[`GFG00`]},{code:`GFG05`,name:`Generic PETG`,displayName:`Generic PETG`,isCustom:!1,allCodes:[`GFG05`]},{code:`GFB00`,name:`Bambu ABS Basic`,displayName:`Bambu ABS Basic`,isCustom:!1,allCodes:[`GFB00`]},{code:`GFB05`,name:`Generic ABS`,displayName:`Generic ABS`,isCustom:!1,allCodes:[`GFB05`]},{code:`GFA00`,name:`Bambu ASA Basic`,displayName:`Bambu ASA Basic`,isCustom:!1,allCodes:[`GFA00`]},{code:`GFU00`,name:`Bambu TPU 95A`,displayName:`Bambu TPU 95A`,isCustom:!1,allCodes:[`GFU00`]},{code:`GFU05`,name:`Generic TPU`,displayName:`Generic TPU`,isCustom:!1,allCodes:[`GFU05`]},{code:`GFC00`,name:`Bambu PC Basic`,displayName:`Bambu PC Basic`,isCustom:!1,allCodes:[`GFC00`]},{code:`GFN00`,name:`Bambu PA Basic`,displayName:`Bambu PA Basic`,isCustom:!1,allCodes:[`GFN00`]},{code:`GFN05`,name:`Generic PA`,displayName:`Generic PA`,isCustom:!1,allCodes:[`GFN05`]},{code:`GFS00`,name:`Bambu PLA-CF`,displayName:`Bambu PLA-CF`,isCustom:!1,allCodes:[`GFS00`]},{code:`GFT00`,name:`Bambu PETG-CF`,displayName:`Bambu PETG-CF`,isCustom:!1,allCodes:[`GFT00`]},{code:`GFNC0`,name:`Bambu PA-CF`,displayName:`Bambu PA-CF`,isCustom:!1,allCodes:[`GFNC0`]},{code:`GFV00`,name:`Bambu PVA`,displayName:`Bambu PVA`,isCustom:!1,allCodes:[`GFV00`]}];function OU(e){let t=e.replace(/@.*$/,``).trim();t=t.replace(/\(Custom\)/i,``).trim(),t=t.replace(/^[#*]+\s*/,``).trim();let n=`PLA-CF.PETG-CF.ABS-GF.ASA-CF.PA-CF.PAHT-CF.PA6-CF.PA6-GF.PPA-CF.PPA-GF.PET-CF.PPS-CF.PC-CF.PC-ABS.ABS-GF.PCTG.PETG.PLA.ABS.ASA.PC.PA.TPU.PVA.HIPS.BVOH.PPS.PEEK.PEI`.split(`.`),r=``,i=-1;for(let e of n){let n=t.toUpperCase().indexOf(e.toUpperCase());if(n!==-1){r=e,i=n;break}}let a=``;i>0&&(a=t.substring(0,i).trim(),a=a.replace(/[-_\s]+$/,``));let o=``;i!==-1&&r&&(o=t.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,``));let s=``;for(let e of wU)if(o.toLowerCase().includes(e.toLowerCase())){s=e;break}if(!s&&a)for(let e of wU){let t=RegExp(`\\s+${e}$`,`i`);if(t.test(a)){s=e,a=a.replace(t,``).trim();break}}return{brand:a,material:r,variant:s}}function kU(e,t){let n=new Set(CU);for(let t of e){let{brand:e}=OU(t.name);e&&e.length>1&&n.add(e)}if(t)for(let e of t)if(e.filament_vendor&&e.filament_vendor.length>1)n.add(e.filament_vendor);else{let{brand:t}=OU(e.name);t&&t.length>1&&n.add(t)}return Array.from(n).sort((e,t)=>e.localeCompare(t))}function $Oe(e){let t=e.filter(e=>e.preset_type===`filament`);return t.length===0?[]:t.map(e=>{let t=String(e.id),n=e.filament_type||t,r=Array.from(new Set([t,n]));return{code:t,name:e.name,displayName:e.name,isCustom:!1,allCodes:r}}).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function AU(e,t,n,r){let i=[],a=[],o=new Set;for(let n of e)if(n.is_custom){let e=n.name.toUpperCase();(t.size===0||Array.from(t).some(t=>e.includes(t))||!e.includes(`@`))&&(i.push({code:n.setting_id,name:n.name,displayName:`${n.name} (Custom)`,isCustom:!0,allCodes:[n.setting_id]}),o.add(n.setting_id))}else a.push({code:n.setting_id,name:n.name,displayName:n.name,isCustom:!1,allCodes:[n.setting_id]}),o.add(n.setting_id);let s=n&&n.length>0?$Oe(n):[],c=[];if(r&&r.length>0)for(let e of r){let t=e.filament_id.startsWith(`GF`)?`GFS`+e.filament_id.slice(2):e.filament_id;o.has(e.filament_id)||o.has(t)||c.push({code:e.filament_id,name:e.name,displayName:e.name,isCustom:!1,allCodes:[e.filament_id,t]})}let l=[...i,...a,...s,...c];return l.length===0?QOe:l.sort((e,t)=>e.displayName.localeCompare(t.displayName))}function jU(e,t){if(!e)return;let n=t.find(t=>t.code===e);if(n||=t.find(t=>t.allCodes.includes(e)),!n){let r=e.toLowerCase();n=t.find(e=>e.code.toLowerCase()===r||e.allCodes.some(e=>e.toLowerCase()===r))}return n}function MU(){try{let e=localStorage.getItem(DU);if(e)return JSON.parse(e)}catch{}return[]}function NU(e,t){let n=[e,...t.filter(t=>t.hex.toUpperCase()!==e.hex.toUpperCase())].slice(0,8);try{localStorage.setItem(DU,JSON.stringify(n))}catch{}return n}function PU(e){if(!e)return``;let t=e.split(`_`)[0];return/^GFS/i.test(t)&&(t=t.slice(0,2)+t.slice(3)),t.toUpperCase()}function FU(e){return!!e&&/^GF[A-Z]99$/i.test(e)}function IU(e,t){if(!t.material)return!1;let n=PU(t.slicer_filament),r=PU(e.filament_id);if(n&&r&&n===r&&!FU(r))return!0;let i=(e.name||``).replace(/^High Flow[_\s]+/i,``).replace(/^Standard[_\s]+/i,``).replace(/^HF[_\s]+/i,``).replace(/^S[_\s]+/i,``).trim(),a=OU(i);return!(a.material.toUpperCase()!==t.material.toUpperCase()||t.brand&&!(a.brand.toLowerCase().includes(t.brand.toLowerCase())||t.brand.toLowerCase().includes(a.brand.toLowerCase()))||t.subtype&&!(a.variant.toLowerCase().includes(t.subtype.toLowerCase())||t.subtype.toLowerCase().includes(a.variant.toLowerCase())||i.toLowerCase().includes(t.subtype.toLowerCase())))}function LU(e){let t=e.includes(`_`)?e.split(`_`)[0]:e;return t.startsWith(`GFS`)?`GF`+t.slice(3):(t.startsWith(`PFUS`)||t.startsWith(`PFSP`),t)}var RU=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`NYLON`,`PVA`,`HIPS`,`PP`,`PET`];function zU(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase(),r=n.match(/\bSUPPORT\s+FOR\s+/);if(r){let e=n.slice(r.index+r[0].length);for(let n of RU)if(RegExp(`\\b${n}\\b`).test(e))return{material:n,brand:t.slice(0,r.index).trim(),variant:`Support`}}for(let e of RU){let r=RegExp(`\\b${e}\\b`,`i`);if(r.test(n)){let n=t.split(r);return{material:e,brand:n[0]?.trim()||``,variant:n[1]?.trim()||``}}}let i=t.split(/\s+/);return i.length>=2?{material:i[1],brand:i[0],variant:i.slice(2).join(` `)}:{material:t,brand:``,variant:``}}function eke(e){return!e.startsWith(`GF`)&&!e.startsWith(`P1`)}var tke={white:`FFFFFF`,black:`000000`,red:`FF0000`,green:`00FF00`,blue:`0000FF`,yellow:`FFFF00`,cyan:`00FFFF`,magenta:`FF00FF`,orange:`FFA500`,purple:`800080`,pink:`FFC0CB`,brown:`8B4513`,gray:`808080`,grey:`808080`,"jade white":`FFFEF2`,ivory:`FFFFF0`,beige:`F5F5DC`,cream:`FFFDD0`,silver:`C0C0C0`,gold:`FFD700`,bronze:`CD7F32`,copper:`B87333`,navy:`000080`,teal:`008080`,olive:`808000`,maroon:`800000`,coral:`FF7F50`,salmon:`FA8072`,lime:`32CD32`,mint:`98FF98`,"forest green":`228B22`,"sky blue":`87CEEB`,"royal blue":`4169E1`,turquoise:`40E0D0`,lavender:`E6E6FA`,violet:`EE82EE`,plum:`DDA0DD`,tan:`D2B48C`,chocolate:`D2691E`,charcoal:`36454F`,slate:`708090`,transparent:`000000`,natural:`F5F5DC`,wood:`DEB887`},BU=[{name:`White`,hex:`FFFFFF`},{name:`Black`,hex:`000000`},{name:`Red`,hex:`FF0000`},{name:`Blue`,hex:`0000FF`},{name:`Green`,hex:`00AA00`},{name:`Yellow`,hex:`FFFF00`},{name:`Orange`,hex:`FFA500`},{name:`Gray`,hex:`808080`}],VU=[{name:`Cyan`,hex:`00FFFF`},{name:`Magenta`,hex:`FF00FF`},{name:`Purple`,hex:`800080`},{name:`Pink`,hex:`FFC0CB`},{name:`Brown`,hex:`8B4513`},{name:`Beige`,hex:`F5F5DC`},{name:`Navy`,hex:`000080`},{name:`Teal`,hex:`008080`},{name:`Lime`,hex:`32CD32`},{name:`Gold`,hex:`FFD700`},{name:`Silver`,hex:`C0C0C0`},{name:`Maroon`,hex:`800000`},{name:`Olive`,hex:`808000`},{name:`Coral`,hex:`FF7F50`},{name:`Salmon`,hex:`FA8072`},{name:`Turquoise`,hex:`40E0D0`},{name:`Violet`,hex:`EE82EE`},{name:`Indigo`,hex:`4B0082`},{name:`Chocolate`,hex:`D2691E`},{name:`Tan`,hex:`D2B48C`},{name:`Slate`,hex:`708090`},{name:`Charcoal`,hex:`36454F`},{name:`Ivory`,hex:`FFFFF0`},{name:`Cream`,hex:`FFFDD0`}];function HU(e){return tke[e.toLowerCase().trim()]||null}function nke(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\s+/g,`\\s+`);return RegExp(`\\b${t}\\b`,`i`)}function UU(e,t){let n=e.indexOf(`@`);if(n>=0){let r=e.slice(n+1).trim(),i=r.match(/^BBL\s+(.+?)(?:\s+[\d.]+\s*nozzle)?$/i);if(i)return i[1].trim();let a=r.match(/^Bambu Lab\s+(.+?)(?:\s+[\d.]+\s*nozzle)?$/i);if(a){let e=a[1].trim(),n=`Bambu Lab ${e}`;if(t[n])return t[n];let r=n.toLowerCase();for(let[e,n]of Object.entries(t))if(e.toLowerCase()===r)return n;return e}}let r=[],i=new Set;for(let[e,n]of Object.entries(t)){let t=e.replace(/^Bambu Lab\s+/,``),a=t.toLowerCase();i.has(a)||(r.push({token:t,short:n}),i.add(a));let o=n.toLowerCase();i.has(o)||(r.push({token:n,short:n}),i.add(o))}r.sort((e,t)=>t.token.length-e.token.length);for(let{token:t,short:n}of r)if(nke(t).test(e))return n;return null}function WU({isOpen:e,onClose:t,printerId:n,slotInfo:r,nozzleDiameter:i=`0.4`,printerModel:a,onSuccess:o,fullScreen:s}){let{t:c}=W(),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),w=(0,y.useRef)(``),{data:T,isLoading:E,isError:D}=q({queryKey:[`cloudSettings`],queryFn:()=>Q.getCloudSettings(),enabled:e,retry:!1}),{data:O}=q({queryKey:[`orcaCloudProfilesForAmsSlot`],queryFn:()=>Q.orcaCloudListProfiles(),enabled:e,retry:!1}),{data:k,isLoading:A}=q({queryKey:[`localPresets`],queryFn:()=>Q.getLocalPresets(),enabled:e}),{data:j,isLoading:M}=q({queryKey:[`builtinFilaments`],queryFn:()=>Q.getBuiltinFilaments(),enabled:e,staleTime:1/0}),{data:N,isLoading:P}=q({queryKey:[`kprofiles`,n,i],queryFn:()=>Q.getKProfiles(n,i),enabled:e&&!!n}),{data:F}=q({queryKey:[`colorCatalog`],queryFn:()=>Q.getColorCatalog(),enabled:e,staleTime:1/0}),{data:I}=q({queryKey:[`slicerPrinterModels`],queryFn:Q.getSlicerPrinterModels,enabled:e,staleTime:1/0}),L=(0,y.useMemo)(()=>vU(I??{}),[I]),R=(0,y.useMemo)(()=>{if(!a||!I)return null;for(let[e,t]of Object.entries(I))if(t===a)return`${e.startsWith(`Bambu Lab `)?e:`Bambu Lab ${e}`} ${i} nozzle`;return null},[a,I,i]),z=J({mutationFn:async()=>{if(!l)throw Error(`No filament preset selected`);let e=l.startsWith(`local_`),t=l.startsWith(`builtin_`),a=l.startsWith(`orca_`)?l.replace(`orca_`,``):l,o=!e&&!t?O?.filament.find(e=>e.setting_id===a):void 0,s=!!o,c=o??null,u=e?parseInt(l.replace(`local_`,``),10):null,f=t?l.replace(`builtin_`,``):null,m=e?k?.filament.find(e=>e.id===u):null,h=t?j?.find(e=>e.filament_id===f):null,g=!e&&!t&&!s?T?.filament.find(e=>e.setting_id===l):null;if(!e&&!t&&!s&&!g)throw Error(`Selected preset not found`);if(e&&!m)throw Error(`Selected local preset not found`);if(t&&!h)throw Error(`Selected builtin preset not found`);if(s&&!c)throw Error(`Selected Orca Cloud preset not found`);let _=e?m.name:t?h.name:s?c.name:g.name,v=zU(_),y=d?.slot_id??-1,b=p||r.trayColor?.slice(0,6)||`FFFFFF`,x=_.replace(/@.+$/,``).trim(),S,C,w=v.material.toUpperCase(),E={PLA:`GFL99`,"PLA-CF":`GFL98`,"PLA SILK":`GFL96`,"PLA HIGH SPEED":`GFL95`,PETG:`GFG99`,"PETG HF":`GFG96`,"PETG-CF":`GFG98`,PCTG:`GFG97`,ABS:`GFB99`,ASA:`GFB98`,PC:`GFC99`,PA:`GFN99`,"PA-CF":`GFN98`,NYLON:`GFN99`,TPU:`GFU99`,PVA:`GFS99`,HIPS:`GFS98`,PE:`GFP99`,PP:`GFP97`};if(e){let e=(RU.includes(w)?w:m?.filament_type||v.material||``).toUpperCase();S=E[e]||E[e.replace(/[-\s]?CF$/,``)]||E[e.replace(/\+$/,``)]||E[e.split(/[-\s]/)[0]]||``,C=``}else if(s){let e=(RU.includes(w)?w:v.material||``).toUpperCase();S=E[e]||E[e.replace(/[-\s]?CF$/,``)]||E[e.replace(/\+$/,``)]||E[e.split(/[-\s]/)[0]]||``,C=``}else if(t)S=f,C=``;else if(S=LU(l),C=l,!l.startsWith(`GFS`))try{let e=await Q.getCloudSettingDetail(l);e.filament_id&&(S=e.filament_id)}catch(e){console.warn(`Failed to fetch preset detail for filament_id:`,e)}let D=e&&m?.nozzle_temp_min?m.nozzle_temp_min:190,A=e&&m?.nozzle_temp_max?m.nozzle_temp_max:230;if(!e||t||s||!m?.nozzle_temp_min&&!m?.nozzle_temp_max){let t=(e?RU.includes(w)?w:m?.filament_type||v.material||``:v.material).toUpperCase();t.includes(`PLA`)?(D=190,A=230):t.includes(`PETG`)?(D=220,A=260):t.includes(`ABS`)||t.includes(`ASA`)?(D=240,A=280):t.includes(`TPU`)?(D=200,A=240):t===`PCTG`?(D=220,A=260):t.includes(`PC`)?(D=260,A=300):(t.includes(`PA`)||t.includes(`NYLON`))&&(D=250,A=290)}let M=d?.k_value?parseFloat(d.k_value):0,N=e?RU.includes(w)?w:m?.filament_type||v.material||`PLA`:s&&RU.includes(w)?w:v.material||`PLA`,P=await Q.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:S,tray_type:N,tray_sub_brands:x,tray_color:b+`FF`,nozzle_temp_min:D,nozzle_temp_max:A,cali_idx:y,nozzle_diameter:i,setting_id:C,kprofile_filament_id:d?.filament_id,kprofile_setting_id:d?.setting_id||void 0,k_value:M}),F=e?`local_${u}`:t?`builtin_${f}`:l,I=e?`local`:t?`builtin`:s?`orca_cloud`:`cloud`;try{await Q.saveSlotPreset(n,r.amsId,r.trayId,F,x,I)}catch(e){console.warn(`Failed to save slot preset mapping:`,e)}return P},onSuccess:()=>{x(!0),o?.(),setTimeout(()=>{x(!1),t()},1500)}}),B=J({mutationFn:async()=>Q.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{x(!0),o?.(),setTimeout(()=>{x(!1),t()},1500)}}),V=(0,y.useMemo)(()=>{let e=_.toLowerCase(),t=[],n=new Set,i=r.savedPresetId,o=r.trayInfoIdx;if(O?.filament)for(let r of O.filament){let i=`orca_${r.setting_id}`;if(n.add(r.setting_id),n.add(i),!(e&&!r.name.toLowerCase().includes(e))){if(a){let e=UU(r.name,I??{});if(e&&!_U(e,a))continue}t.push({id:i,name:r.name,source:`orca_cloud`,isUser:!0})}}if(T?.filament)for(let r of T.filament){if(n.has(r.setting_id))continue;n.add(r.setting_id);let s=i===r.setting_id||o&&(r.setting_id===o||LU(r.setting_id)===o);if(!(e&&!r.name.toLowerCase().includes(e))){if(!s&&a){let e=UU(r.name,I??{});if(e&&!_U(e,a))continue}t.push({id:r.setting_id,name:r.name,source:`cloud`,isUser:eke(r.setting_id)})}}if(k?.filament){let n=r.savedPresetId;for(let r of k.filament){let i=`local_${r.id}`;if(!(e&&!r.name.toLowerCase().includes(e))){if(n!==i&&R){let e=null;if(r.compatible_printers)try{let t=JSON.parse(r.compatible_printers);Array.isArray(t)&&(e=t.filter(e=>typeof e==`string`))}catch{e=null}if(xU({name:r.name,compatible_printers:e},`filament`,R,L)===`mismatch`)continue}t.push({id:i,name:r.name,source:`local`,isUser:!1})}}}if(j)for(let r of j){if(n.has(r.filament_id))continue;let i=r.filament_id.startsWith(`GF`)?`GFS`+r.filament_id.slice(2):r.filament_id;n.has(i)||(!e||r.name.toLowerCase().includes(e))&&t.push({id:`builtin_${r.filament_id}`,name:r.name,source:`builtin`,isUser:!1})}return t.sort((e,t)=>{let n={local:0,orca_cloud:1,cloud:2,builtin:3};return e.source===t.source?e.isUser&&!t.isUser?-1:!e.isUser&&t.isUser?1:e.name.localeCompare(t.name):n[e.source]-n[t.source]})},[O?.filament,T?.filament,k?.filament,j,_,a,r.savedPresetId,r.trayInfoIdx,R,L,I]),ee=(0,y.useMemo)(()=>{if(!l)return null;let e=null,t=``;if(l.startsWith(`local_`)){let t=parseInt(l.replace(`local_`,``),10);e=k?.filament.find(e=>e.id===t)?.name||null}else if(l.startsWith(`builtin_`)){let n=l.replace(`builtin_`,``);e=j?.find(e=>e.filament_id===n)?.name||null,t=PU(n)}else{let n=l.startsWith(`orca_`)?l.replace(`orca_`,``):l,r=O?.filament.find(e=>e.setting_id===n);if(r)e=r.name;else if(T?.filament){let n=T.filament.find(e=>e.setting_id===l);e=n?.name||null,n&&(t=PU(n.setting_id))}}if(!e)return null;let n=e.replace(/@.+$/,``).trim();n.startsWith(`# `)&&(n=n.slice(2).trim());let r=zU(n);return{fullName:n,material:r.material,brand:r.brand,filamentId:t}},[l,T?.filament,k?.filament,j,O?.filament]),te=ee?.fullName||``,ne=(0,y.useMemo)(()=>{if(!F||!ee)return[];let{fullName:e,brand:t}=ee,n=e.replace(/^(Bambu\s*(Lab)?|eSUN|Polymaker|Overture|Sunlu|Hatchbox)\s*/i,``).trim();return F.filter(e=>{let r=(e.material||``).toUpperCase(),i=e.manufacturer.toUpperCase();if(!(r===n.toUpperCase()||r.includes(n.toUpperCase())||n.toUpperCase().includes(r)))return!1;if(t){let e=t.toUpperCase();if(!i.includes(e)&&!e.includes(i))return!1}return!0})},[F,ee]),re=(0,y.useMemo)(()=>{if(!N?.profiles)return[];if(!ee){let e=r.caliIdx;if(e!=null&&e>0){let t=N.profiles.find(t=>t.slot_id===e&&(r.extruderId===void 0||t.extruder_id===r.extruderId));if(t)return[t]}return[]}let{fullName:e,material:t,brand:n,filamentId:i}=ee,a=e.toUpperCase(),o=t.toUpperCase(),s=n.toUpperCase(),c=i;if(!o||o.length<2)return[];let l=N.profiles.filter(e=>{if(c){let t=PU(e.filament_id);if(t&&t===c&&!FU(t))return!0}let t=e.name.toUpperCase();if(s)return!(!t.includes(s)||!t.includes(o));if(t.includes(a)||t.includes(o))return!0;let n={NYLON:[`PA`,`PA-CF`,`PA6`],PA:[`NYLON`]}[o]||[];for(let e of n)if(t.includes(e))return!0;return!1}),u=new Map;for(let e of l){let t=`${e.name}|${e.k_value}`,n=u.get(t);n?r.extruderId!==void 0&&e.extruder_id===r.extruderId&&n.extruder_id!==r.extruderId&&u.set(t,e):u.set(t,e)}let d=Array.from(u.values()),f=r.caliIdx;if(f!=null&&f>0&&!d.some(e=>e.slot_id===f)){let e=N.profiles.find(e=>e.slot_id===f&&(r.extruderId===void 0||e.extruder_id===r.extruderId));e&&d.unshift(e)}return d},[N?.profiles,ee,r.extruderId,r.caliIdx]);(0,y.useEffect)(()=>{if(e){if(r.savedPresetId)u(r.savedPresetId);else if(r.trayInfoIdx&&T?.filament){let e=T.filament.find(e=>e.setting_id===r.trayInfoIdx);e||=T.filament.find(e=>LU(e.setting_id)===r.trayInfoIdx),e&&u(e.setting_id)}else if(r.trayInfoIdx&&j?.length){let e=r.trayInfoIdx,t=j.find(t=>t.filament_id===e);t&&u(`builtin_${t.filament_id}`)}if(r.trayColor){let e=r.trayColor.slice(0,6);e&&m(e)}}else u(``),f(null),m(``),g(``),v(``),x(!1),w.current=``},[e,r.savedPresetId,r.trayInfoIdx,r.trayColor,T?.filament,j]),(0,y.useEffect)(()=>{if(re.length>0){if(r.caliIdx!=null&&r.caliIdx>0){let e=re.find(e=>e.slot_id===r.caliIdx);if(e){f(e);return}}f(re[0])}else f(null)},[l,re,r.caliIdx]);let ie=(0,y.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,y.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,ie),()=>document.removeEventListener(`keydown`,ie)},[e,ie]);let H=E&&!D||A||M||P;if((0,y.useEffect)(()=>{if(!H&&l&&l!==w.current){let e=requestAnimationFrame(()=>{let e=document.querySelector(`[class*="fixed inset-0 z-50"]`)?.querySelector(`[data-preset-id="${CSS.escape(l)}"]`);e&&(w.current=l,e.scrollIntoView({block:`nearest`}))});return()=>cancelAnimationFrame(e)}},[l,H]),!e)return null;let ae=l&&!z.isPending,oe=p||r.trayColor?.slice(0,6)||`FFFFFF`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${s?``:`items-center justify-center`}`,children:[!s&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:s?`relative w-full h-full bg-bambu-dark-secondary flex flex-col`:`relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-5 h-5 text-bambu-blue`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:c(`configureAmsSlot.title`)}),s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-4 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white/30`,children:`|`}),r.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),(0,K.jsx)(`span`,{className:`text-white/70`,children:c(`configureAmsSlot.slotLabel`,{ams:Af(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&(0,K.jsxs)(`span`,{children:[`(`,r.traySubBrands,`)`]})]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 overflow-y-auto ${s?`flex-1 min-h-0`:`space-y-4 max-h-[60vh]`}`,children:[b&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl`,children:(0,K.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,K.jsx)(ms,{className:`w-16 h-16 text-bambu-green mx-auto`}),(0,K.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:c(`configureAmsSlot.slotConfigured`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:c(`configureAmsSlot.settingsSentToPrinter`)})]})}),!s&&(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:c(`configureAmsSlot.configuringSlot`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:c(`configureAmsSlot.slotLabel`,{ams:Af(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,r.traySubBrands,`)`]})]})]}),H?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):s?(0,K.jsxs)(`div`,{className:`flex gap-4 h-full`,children:[(0,K.jsxs)(`div`,{className:`w-1/2 flex flex-col min-h-0`,children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.filamentProfile`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.searchPresets`),value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2 shrink-0`}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto space-y-1`,children:V.length===0?(0,K.jsx)(`p`,{className:`text-center py-4 text-bambu-gray`,children:T?.filament?.length===0&&!k?.filament?.length?c(`configureAmsSlot.noPresetsAvailable`):c(`configureAmsSlot.noMatchingPresets`)}):V.map(e=>(0,K.jsx)(`button`,{"data-preset-id":e.id,onClick:()=>u(e.id),className:`group w-full p-2 rounded-lg border text-left transition-colors ${l===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate group-hover:whitespace-normal group-hover:break-all`,title:e.name,children:e.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.source===`local`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400`,children:c(`profiles.localProfiles.badge`)}),e.source===`orca_cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-400`,children:c(`configureAmsSlot.orcaCloud`)}),e.source===`cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue`,children:c(`configureAmsSlot.bambuCloud`)}),e.source===`builtin`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400`,children:c(`configureAmsSlot.builtin`)})]})]})},e.id))})]}),(0,K.jsxs)(`div`,{className:`w-1/2 flex flex-col gap-4 min-h-0 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.kProfileLabel`),te&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-blue`,children:c(`configureAmsSlot.filteringFor`,{material:te})})]}),re.length>0?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:d?.name||``,onChange:e=>{f(re.find(t=>t.name===e.target.value)||null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:c(`configureAmsSlot.noKProfile`)}),re.map(e=>(0,K.jsxs)(`option`,{value:e.name,children:[e.name,` (K=`,e.k_value,`)`]},`${e.name}-${e.extruder_id}`))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}):l?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:c(`configureAmsSlot.noMatchingKProfiles`)}):(0,K.jsx)(`span`,{className:`inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30`,children:c(`configureAmsSlot.selectFilamentFirst`)}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-green mt-1`,children:c(`configureAmsSlot.kFromCalibration`,{value:d.k_value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:c(`configureAmsSlot.customColorLabel`)}),ne.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1.5`,children:c(`configureAmsSlot.presetColors`,{name:ee?.fullName})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ne.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{m(e.hex_color.replace(`#`,``).toUpperCase()),g(e.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===e.hex_color.replace(`#`,``).toUpperCase()?`border-bambu-green scale-105`:`border-white/20 hover:border-white/40`}`,title:e.color_name,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.hex_color}}),(0,K.jsx)(`span`,{className:`text-xs text-white/80 whitespace-nowrap`,children:e.color_name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[BU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex)),(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs`,title:c(S?`configureAmsSlot.showLessColors`:`configureAmsSlot.showMoreColors`),children:S?`−`:`+`})]}),S&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:VU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex))}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0`,style:{backgroundColor:`#${oe}`}}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.colorPlaceholder`),value:h,onChange:e=>{let t=e.target.value;g(t);let n=HU(t);if(n)m(n);else{let e=t.replace(/[^0-9A-Fa-f]/g,``).toUpperCase();e.length===6?m(e):e.length===3&&m(e.split(``).map(e=>e+e).join(``))}},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm`}),p&&(0,K.jsx)(`button`,{onClick:()=>{m(``),g(``)},className:`px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded`,title:c(`configureAmsSlot.clearCustomColor`),children:c(`configureAmsSlot.clear`)})]}),p&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5`,children:c(`configureAmsSlot.hexLabel`,{hex:p})})]})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.filamentProfile`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.searchPresets`),value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2`}),(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:V.length===0?(0,K.jsx)(`p`,{className:`text-center py-4 text-bambu-gray`,children:T?.filament?.length===0&&!k?.filament?.length?c(`configureAmsSlot.noPresetsAvailable`):c(`configureAmsSlot.noMatchingPresets`)}):V.map(e=>(0,K.jsx)(`button`,{"data-preset-id":e.id,onClick:()=>u(e.id),className:`group w-full p-2 rounded-lg border text-left transition-colors ${l===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate group-hover:whitespace-normal group-hover:break-all`,title:e.name,children:e.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.source===`local`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400`,children:c(`profiles.localProfiles.badge`)}),e.source===`orca_cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-400`,children:c(`configureAmsSlot.orcaCloud`)}),e.source===`cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue`,children:c(`configureAmsSlot.bambuCloud`)}),e.source===`builtin`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400`,children:c(`configureAmsSlot.builtin`)})]})]})},e.id))})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.kProfileLabel`),te&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-blue`,children:c(`configureAmsSlot.filteringFor`,{material:te})})]}),re.length>0?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:d?.name||``,onChange:e=>{f(re.find(t=>t.name===e.target.value)||null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:c(`configureAmsSlot.noKProfile`)}),re.map(e=>(0,K.jsxs)(`option`,{value:e.name,children:[e.name,` (K=`,e.k_value,`)`]},`${e.name}-${e.extruder_id}`))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}):l?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:c(`configureAmsSlot.noMatchingKProfiles`)}):(0,K.jsx)(`span`,{className:`inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30`,children:c(`configureAmsSlot.selectFilamentFirst`)}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-green mt-1`,children:c(`configureAmsSlot.kFromCalibration`,{value:d.k_value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:c(`configureAmsSlot.customColorLabel`)}),ne.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1.5`,children:c(`configureAmsSlot.presetColors`,{name:ee?.fullName})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ne.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{m(e.hex_color.replace(`#`,``).toUpperCase()),g(e.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===e.hex_color.replace(`#`,``).toUpperCase()?`border-bambu-green scale-105`:`border-white/20 hover:border-white/40`}`,title:e.color_name,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.hex_color}}),(0,K.jsx)(`span`,{className:`text-xs text-white/80 whitespace-nowrap`,children:e.color_name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[BU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex)),(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs`,title:c(S?`configureAmsSlot.showLessColors`:`configureAmsSlot.showMoreColors`),children:S?`−`:`+`})]}),S&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:VU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex))}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0`,style:{backgroundColor:`#${oe}`}}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.colorPlaceholder`),value:h,onChange:e=>{let t=e.target.value;g(t);let n=HU(t);if(n)m(n);else{let e=t.replace(/[^0-9A-Fa-f]/g,``).toUpperCase();e.length===6?m(e):e.length===3&&m(e.split(``).map(e=>e+e).join(``))}},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm`}),p&&(0,K.jsx)(`button`,{onClick:()=>{m(``),g(``)},className:`px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded`,title:c(`configureAmsSlot.clearCustomColor`),children:c(`configureAmsSlot.clear`)})]}),p&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5`,children:c(`configureAmsSlot.hexLabel`,{hex:p})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between p-4 border-t border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>B.mutate(),disabled:B.isPending||z.isPending,className:`text-red-400 hover:text-red-300 hover:bg-red-500/10`,children:B.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),c(`configureAmsSlot.resetting`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),c(`configureAmsSlot.resetSlot`)]})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:c(`configureAmsSlot.cancel`)}),(0,K.jsx)($,{onClick:()=>z.mutate(),disabled:!ae,children:z.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),c(`configureAmsSlot.configuring`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),c(`configureAmsSlot.configureSlot`)]})})]})]}),(z.isError||B.isError)&&(0,K.jsx)(`div`,{className:`mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:z.error?.message||B.error?.message})]})]})}function GU({className:e=`w-4 h-4`}){return(0,K.jsx)(`svg`,{viewBox:`0 0 1945 1370`,fill:`none`,className:e,"aria-hidden":`true`,children:(0,K.jsxs)(`g`,{transform:`translate(-754.293 -471.685)`,children:[(0,K.jsxs)(`g`,{transform:`translate(0.18191 255.976)`,children:[(0,K.jsx)(`g`,{transform:`matrix(1.05469 0 0 0.241063 -153.484 1120.2)`,children:(0,K.jsx)(`rect`,{x:`922.048`,y:`1195.15`,width:`1721.5`,height:`470.135`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`168.84`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,K.jsx)(`g`,{transform:`matrix(0.983656 0 0 1.0767 -62.2035 141.539)`,children:(0,K.jsx)(`path`,{d:`M2741.42,1175.93L895.832,1175.93L1125.16,621.902L2512.09,621.902L2741.42,1175.93Z`,fill:`currentColor`,fillOpacity:`0.05`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`125.26`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,K.jsx)(`g`,{transform:`translate(21.1916 0.684817)`,children:(0,K.jsx)(`path`,{d:`M1981.31,567.518C1954.86,567.518 1933.39,546.047 1933.39,519.601C1933.39,493.156 1954.86,471.685 1981.31,471.685L2146.61,471.685C2173.07,471.685 2194.53,493.138 2194.53,519.601L2194.53,688.741C2194.53,715.187 2173.05,736.658 2146.61,736.658C2120.16,736.658 2098.69,715.187 2098.69,688.741L2098.69,567.518L1981.31,567.518ZM2098.69,1252.54C2098.69,1226.1 2120.16,1204.62 2146.61,1204.62C2173.05,1204.62 2194.53,1226.1 2194.53,1252.54L2194.53,1421.68C2194.53,1448.14 2173.07,1469.6 2146.61,1469.6L1981.31,1469.6C1954.86,1469.6 1933.39,1448.13 1933.39,1421.68C1933.39,1395.24 1954.86,1373.76 1981.31,1373.76L2098.69,1373.76L2098.69,1252.54ZM1430.29,1373.76C1456.74,1373.76 1478.21,1395.24 1478.21,1421.68C1478.21,1448.13 1456.74,1469.6 1430.29,1469.6L1264.99,1469.6C1238.53,1469.6 1217.07,1448.14 1217.07,1421.68L1217.07,1252.54C1217.07,1226.1 1238.55,1204.62 1264.99,1204.62C1291.44,1204.62 1312.91,1226.1 1312.91,1252.54L1312.91,1373.76L1430.29,1373.76ZM1312.91,688.741C1312.91,715.187 1291.44,736.658 1264.99,736.658C1238.55,736.658 1217.07,715.187 1217.07,688.741L1217.07,519.601C1217.07,493.138 1238.53,471.685 1264.99,471.685L1430.29,471.685C1456.74,471.685 1478.21,493.156 1478.21,519.601C1478.21,546.047 1456.74,567.518 1430.29,567.518L1312.91,567.518L1312.91,688.741Z`,fill:`currentColor`,fillOpacity:`0.99`})})]})})}function KU({folderId:e,onClose:t,onUploadComplete:n,onFileUploaded:r,autoUpload:i,validateFile:a,accept:o,initialFiles:s}){let{t:c}=W(),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!0),[S,C]=(0,y.useState)(null),w=(0,y.useRef)(null),T=e=>{e.preventDefault(),f(!0)},E=e=>{e.preventDefault(),f(!1)},D=e=>{e.preventDefault(),f(!1),j(Array.from(e.dataTransfer.files))},O=e=>{e.target.files&&j(Array.from(e.target.files))},k=(e,t)=>{u(n=>n.map(n=>n.file===e?{...n,...t}:n))},A=async i=>{m(!0);for(let t of i)if(t.status===`pending`){k(t.file,{status:`uploading`});try{if(t.isZip){let n=await Q.extractZipFile(t.file,e,h,_,b);k(t.file,{status:n.errors.length>0&&n.extracted===0?`error`:`success`,extractedCount:n.extracted,error:n.errors.length>0?c(`fileManager.zipFilesFailed`,`{{count}} files failed`,{count:n.errors.length}):void 0})}else{let n=await Q.uploadLibraryFile(t.file,e,b);k(t.file,{status:`success`});let i=r?.(n);if(i){C(i),u([]),m(!1);return}}}catch(e){k(t.file,{status:`error`,error:e instanceof Error?e.message:c(`fileManager.uploadFailed`,`Upload failed`)})}}m(!1),n(),u(e=>(e.some(e=>e.status===`error`)||t(),e))},j=e=>{if(C(null),a)for(let t of e){let e=a(t);if(e){C(e);return}}let t=e.map(e=>({file:e,status:`pending`,isZip:e.name.toLowerCase().endsWith(`.zip`),is3mf:e.name.toLowerCase().endsWith(`.3mf`)}));u(e=>[...e,...t]),i&&e.length>0&&A(t)},M=e=>{u(t=>t.filter((t,n)=>n!==e))},N=(0,y.useRef)(!1);(0,y.useEffect)(()=>{N.current||!s||s.length===0||(N.current=!0,j(s))},[]);let P=l.some(e=>e.isZip&&e.status===`pending`),F=l.some(e=>e.file.name.toLowerCase().endsWith(`.stl`)&&e.status===`pending`),I=l.some(e=>e.is3mf&&e.status===`pending`),L=l.filter(e=>e.status===`pending`).length,R=l.length>0&&L===0&&!p;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:c(`fileManager.uploadFiles`)}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{onDragOver:T,onDragLeave:E,onDrop:D,onClick:()=>w.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${d?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Du,{className:`w-10 h-10 mx-auto mb-3 ${d?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:c(d?`fileManager.dropFilesHere`:`fileManager.dragDropFiles`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:c(`fileManager.orClickToBrowse`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-2`,children:c(`fileManager.allFileTypesSupported`)})]}),(0,K.jsx)(`input`,{ref:w,type:`file`,multiple:!0,accept:o,className:`hidden`,onChange:O}),P&&(0,K.jsx)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Oo,{className:`w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-blue-300 font-medium`,children:c(`fileManager.zipFilesDetected`)}),(0,K.jsx)(`p`,{className:`text-xs text-blue-300/70 mt-1`,children:c(`fileManager.zipExtractOptions`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.preserveZipStructure`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.createFolderFromZip`)})]})]})]})}),I&&(0,K.jsx)(`div`,{className:`p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-purple-300 font-medium`,children:c(`fileManager.threemfDetected`)}),(0,K.jsx)(`p`,{className:`text-xs text-purple-300/70 mt-1`,children:c(`fileManager.threemfExtractionInfo`)})]})]})}),(F||P)&&(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Mc,{className:`w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-green font-medium`,children:c(`fileManager.stlThumbnailGeneration`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-green/70 mt-1`,children:c(P&&!F?`fileManager.zipMayContainStl`:`fileManager.thumbnailsCanBeGenerated`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.generateThumbnailsForStl`)})]})]})]})}),l.length>0&&(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-2`,children:l.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 bg-bambu-dark rounded-lg`,children:[e.isZip?(0,K.jsx)(Oo,{className:`w-4 h-4 text-blue-400 flex-shrink-0`}):(0,K.jsx)(rc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.file.name}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[(e.file.size/1024/1024).toFixed(2),` MB`,e.isZip&&e.status===`pending`&&(0,K.jsxs)(`span`,{className:`text-blue-400 ml-2`,children:[`• `,c(`fileManager.willBeExtracted`)]}),e.extractedCount!==void 0&&(0,K.jsxs)(`span`,{className:`text-green-400 ml-2`,children:[`• `,c(`fileManager.filesExtracted`,{count:e.extractedCount})]})]}),e.status===`error`&&e.error&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1 break-words`,children:e.error})]}),e.status===`pending`&&(0,K.jsx)(`button`,{onClick:()=>M(t),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray`})}),e.status===`uploading`&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`}),e.status===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-green-500`}),e.status===`error`&&(0,K.jsx)(`span`,{title:e.error,children:(0,K.jsx)(ys,{className:`w-4 h-4 text-red-500`})})]},t))}),S&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-sm text-red-300`,children:S})]})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:c(`common.cancel`)}),!R&&(0,K.jsx)($,{onClick:()=>A(l),disabled:L===0||p,children:p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),c(`fileManager.uploading`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),c(`common.upload`),` `,L>0?`(${L})`:``]})})]})]})})}function qU(e){let t=[],n=e?.ams_extruder_map,r=!!e?.nozzles?.[1]?.nozzle_diameter||n&&Object.keys(n).length>0||(e?.vt_tray?.length??0)>1;e?.ams?.forEach(e=>{let r=e.tray.length===1;e.tray.forEach(i=>{if(i.tray_type){let a=Of(i.tray_color);t.push({type:i.tray_type,color:a,colorName:Gd(a),amsId:e.id,trayId:i.id,isHt:r,isExternal:!1,label:If(e.id,i.id,r,!1),globalTrayId:Lf(e.id,i.id,!1),trayInfoIdx:i.tray_info_idx||``,traySubBrands:i.tray_sub_brands||``,extruderId:n?.[String(e.id)],remain:i.remain??-1})}})});for(let n of e?.vt_tray??[])if(n.tray_type){let i=Of(n.tray_color),a=n.id??254,o=(e?.vt_tray?.length??0)>1;t.push({type:n.tray_type,color:i,colorName:Gd(i),amsId:-1,trayId:a-254,isHt:!1,isExternal:!0,label:o?a===254?`Ext-L`:`Ext-R`:`External`,globalTrayId:a,trayInfoIdx:n.tray_info_idx||``,traySubBrands:n.tray_sub_brands||``,extruderId:r?255-a:void 0,remain:n.remain??-1})}return t}function JU(e,t,n,r){if(!e?.filaments||e.filaments.length===0)return;let i=qU(t);if(i.length===0)return;let a=t?.fila_switch?.installed===!0,o=new Set,s=e.filaments.map(e=>{let t=e.tray_info_idx||``,s=i.filter(e=>!o.has(e.globalTrayId));e.nozzle_id!=null&&!a&&(s=s.filter(t=>t.extruderId===e.nozzle_id)),n&&(s=[...s].sort((e,t)=>Kf(Gf(e,r),Gf(t,r))));let c,l,u,d;if(t){let i=s.filter(e=>e.trayInfoIdx===t);i.length===1?c=i[0]:i.length>1&&(n&&i.sort((e,t)=>Kf(Gf(e,r),Gf(t,r))),l=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),l||(u=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!l&&!u&&(d=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())))}!c&&!l&&!u&&!d&&(l=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),l||(u=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!l&&!u&&(d=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())));let f=c||l||u||d||void 0;return f&&o.add(f.globalTrayId),{slot_id:e.slot_id,globalTrayId:f?.globalTrayId??-1}}),c=Math.max(...s.map(e=>e.slot_id||0));if(c<=0)return;let l=Array(c).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(l[e.slot_id-1]=e.globalTrayId)}),l}function rke(e){return(0,y.useMemo)(()=>qU(e),[e])}function YU(e,t,n,r,i){let a=rke(t),o=t?.fila_switch?.installed===!0,s=(0,y.useMemo)(()=>{if(!e?.filaments||e.filaments.length===0)return[];let t=new Set(Object.values(n));return e.filaments.map(e=>{let s=e.slot_id||0;if(s>0&&n[s]!==void 0){let t=n[s],r=a.find(e=>e.globalTrayId===t);if(r){let t=r.type?.toUpperCase()===e.type?.toUpperCase(),n=kf(r.color)===kf(e.color)||Ff(r.color,e.color),i;return i=t&&n?`match`:t?`type_only`:`mismatch`,{...e,loaded:r,hasFilament:!0,typeMatch:t,colorMatch:n,status:i,isManual:!0}}}let c=e.tray_info_idx||``,l=a.filter(e=>!t.has(e.globalTrayId));e.nozzle_id!=null&&!o&&(l=l.filter(t=>t.extruderId===e.nozzle_id)),r&&(l=[...l].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let u,d,f,p;if(c){let t=l.filter(e=>e.trayInfoIdx===c);t.length===1?u=t[0]:t.length>1&&(r&&t.sort((e,t)=>Kf(Gf(e,i),Gf(t,i))),d=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),d||(f=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!d&&!f&&(p=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())))}!u&&!d&&!f&&!p&&(d=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),d||(f=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!d&&!f&&(p=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())));let m=u||d||f||p||void 0;m&&t.add(m.globalTrayId);let h=!!m,g=h,_=!!u||!!d||!!f,v;return v=u||d||f?`match`:p?`type_only`:`mismatch`,{...e,loaded:m,hasFilament:h,typeMatch:g,colorMatch:_,status:v,isManual:!1}})},[e,a,n,r,o,i]);return{loadedFilaments:a,filamentComparison:s,amsMapping:(0,y.useMemo)(()=>{if(s.length===0)return;let e=Math.max(...s.map(e=>e.slot_id||0));if(e<=0)return;let t=Array(e).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(t[e.slot_id-1]=e.loaded?.globalTrayId??-1)}),t},[s]),hasTypeMismatch:s.some(e=>e.status===`mismatch`),hasColorMismatch:s.some(e=>e.status===`type_only`)}}function ike(e,t,n,r,i){if(!e||e.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:`full`};let a=0,o=0,s=0,c=new Set(Object.values(n));for(let l of e){let e=l.slot_id||0;if(e>0&&n[e]!==void 0){let r=n[e],i=t.find(e=>e.globalTrayId===r);if(i){let e=i.type?.toUpperCase()===l.type?.toUpperCase(),t=kf(i.color)===kf(l.color)||Ff(i.color,l.color);e&&t?a++:e?o++:s++;continue}}let u=t.filter(e=>!c.has(e.globalTrayId));if(l.nozzle_id!=null){let e=u.filter(e=>e.extruderId===l.nozzle_id);e.length>0&&(u=e)}r&&(u=[...u].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let d=u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()&&kf(e.color)===kf(l.color)),f=d?void 0:u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()&&Ff(e.color,l.color)),p=d||f?void 0:u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()),m=d??f??p;m&&c.add(m.globalTrayId),d||f?a++:p?o++:s++}let l=e.length,u=`full`;return s>0?u=`missing`:o>0&&(u=`partial`),{exactMatches:a,typeOnlyMatches:o,missingTypes:s,totalSlots:l,status:u}}function ake(e,t,n,r,i){if(!e?.filaments||e.filaments.length===0)return;let a=qU(t);if(a.length===0)return;let o=new Set(Object.values(n)),s=[];for(let t of e.filaments){let e=t.slot_id||0;if(e>0&&n[e]!==void 0){s.push({slot_id:e,globalTrayId:n[e]});continue}let c=a.filter(e=>!o.has(e.globalTrayId));if(t.nozzle_id!=null){let e=c.filter(e=>e.extruderId===t.nozzle_id);e.length>0&&(c=e)}r&&(c=[...c].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let l=c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()&&kf(e.color)===kf(t.color)),u=l?void 0:c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()&&Ff(e.color,t.color)),d=l||u?void 0:c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()),f=l??u??d;f&&o.add(f.globalTrayId),s.push({slot_id:e,globalTrayId:f?.globalTrayId??-1})}let c=Math.max(...s.map(e=>e.slot_id||0));if(c<=0)return;let l=Array(c).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(l[e.slot_id-1]=e.globalTrayId)}),l}var XU={useDefault:!0,manualMappings:{},autoConfigured:!1};function oke(e,t,n,r,i,a,o,s){let c=_o({queries:e.map(t=>({queryKey:[`printer-status`,t],queryFn:()=>Q.getPrinterStatus(t),enabled:e.length>0,staleTime:5e3}))}),l=(0,y.useMemo)(()=>e.map((e,a)=>{let l=c[a],u=l?.data,d=t?.find(t=>t.id===e)?.name||`Printer ${e}`,f=qU(u),p=i[e]||XU,m=s?.get(e),h=qf(o,u?.ams_filament_backup),g=JU(n,u,h,m),_=p.useDefault?r:p.manualMappings,v=ake(n,u,_,h,m),y=ike(n?.filaments,f,_,h,m);return{printerId:e,printerName:d,status:u,isLoading:l?.isLoading??!1,loadedFilaments:f,autoMapping:g,finalMapping:v,matchStatus:y.status,exactMatches:y.exactMatches,typeOnlyMatches:y.typeOnlyMatches,missingTypes:y.missingTypes,totalSlots:y.totalSlots,config:p,inventoryByTrayId:m}}),[e,c,t,n,i,r,o,s]),u=c.some(e=>e.isLoading),d=(e,t)=>{a(n=>({...n,[e]:{...n[e]||XU,...t}}))},f=e=>{let t=l.find(t=>t.printerId===e);if(!t||!t.status||!n?.filaments)return;let r=JU(n,t.status,qf(o,t.status?.ams_filament_backup),s?.get(e));if(!r)return;let i={};r.forEach((e,t)=>{e!==-1&&(i[t+1]=e)}),d(e,{useDefault:!1,manualMappings:i,autoConfigured:!0})};return{printerResults:l,isLoading:u,perPrinterConfigs:i,updatePrinterConfig:d,autoConfigureAll:()=>{for(let t of e)f(t)},autoConfigurePrinter:f,getFinalMapping:e=>l.find(t=>t.printerId===e)?.finalMapping,allPrintersReady:l.every(e=>e.matchStatus!==`missing`)}}var ZU=`/img/bed`,ske={"cool plate":{icon:`${ZU}/bed_cool.png`,label:`Cool Plate`},"pc plate":{icon:`${ZU}/bed_cool.png`,label:`Cool Plate`},"cool plate (supertack)":{icon:`${ZU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"supertack plate":{icon:`${ZU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"bambu cool plate supertack":{icon:`${ZU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"engineering plate":{icon:`${ZU}/bed_engineering.png`,label:`Engineering Plate`},"high temp plate":{icon:`${ZU}/bed_high_templ.png`,label:`High Temp Plate`},"textured pei plate":{icon:`${ZU}/bed_pei.png`,label:`Textured PEI Plate`},"pei plate":{icon:`${ZU}/bed_pei.png`,label:`PEI Plate`},"smooth pei plate":{icon:`${ZU}/bed_pei_cool.png`,label:`Smooth PEI Plate`}};function QU(e){return e?ske[e.trim().toLowerCase()]??null:null}function cke(e){let t=e.trim().split(/\s+/);return t.length<=1?e.trim():t.slice(1).join(` `)}function $U(e){let{data:t}=q({queryKey:[`builtin-filaments`],queryFn:()=>Q.getBuiltinFilaments(),staleTime:300*1e3}),{data:n}=q({queryKey:[`filament-id-map`],queryFn:()=>Q.getFilamentIdMap(),staleTime:300*1e3}),r=(0,y.useMemo)(()=>{let e={};for(let n of t||[])n.filament_id&&(e[n.filament_id]=n.name);for(let[t,r]of Object.entries(n||{}))t&&r&&(e[t]=r);return e},[t,n]),i=(0,y.useMemo)(()=>(e||[]).map(e=>{let t=e.tray_info_idx&&r[e.tray_info_idx]||e.type;return{resolvedName:t,materialHint:cke(t),color:e.color}}),[e,r]),a=_o({queries:i.map(({color:e,materialHint:t})=>({queryKey:[`color-by-material`,e,t],queryFn:()=>Q.getColorByMaterial(e,t),enabled:!!e,staleTime:300*1e3}))});return i.map(({resolvedName:e,color:t},n)=>({resolvedName:e,colorLabel:(a[n]?.data?.color_name??null)||Gd(t)}))}function lke({printerId:e,filamentReqs:t,manualMappings:n,onManualMappingChange:r,currencySymbol:i,defaultCostPerKg:a,defaultExpanded:o=!1,forceColorMatch:s,onForceColorMatchChange:c}){let{t:l}=W(),u=no(),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(o),{data:h}=q({queryKey:[`printer-status`,e],queryFn:()=>Q.getPrinterStatus(e),enabled:!!e}),{data:g}=q({queryKey:[`spool-assignments`,e],queryFn:()=>Q.getAssignments(e),enabled:!!e}),{data:_}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:v}=q({queryKey:[`printer-inventory-remain`,e],queryFn:()=>Q.getInventoryRemain(e),enabled:!!e,staleTime:30*1e3}),b=(0,y.useMemo)(()=>{if(!v?.inventory_remain_g)return;let e=new Map;return Object.entries(v.inventory_remain_g).forEach(([t,n])=>{let r=Number(t);Number.isNaN(r)||e.set(r,n)}),e},[v]),{loadedFilaments:x,filamentComparison:S,hasTypeMismatch:C,hasColorMismatch:w}=YU(t,h,n,qf(_?.prefer_lowest_filament,h?.ams_filament_backup),b),T=$U(t?.filaments),E=(0,y.useMemo)(()=>{let e=new Map;for(let t of g||[]){let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n);e.set(r,t.spool?.cost_per_kg??null)}return e},[g]),D=(0,y.useMemo)(()=>{let e=new Map;for(let t of g||[]){let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n),i=t.spool;if(!i){e.set(r,null);continue}e.set(r,Math.max(0,Math.round((i.label_weight??0)-(i.weight_used??0))))}return e},[g]),O=(0,y.useMemo)(()=>{let e=0;for(let t of S){let n=t.loaded?.globalTrayId;if(n==null)continue;let r=E.get(n)??null??a;r>0&&(e+=t.used_grams/1e3*r)}return e},[S,E,a]),k=(0,y.useMemo)(()=>Array.from(E.values()).some(e=>e!=null&&e>0),[E]),A=t?.filaments&&t.filaments.length>0,j=t?.filaments?.some(e=>e.nozzle_id!=null)??!1,M=h?.fila_switch?.installed===!0,N=e=>{let t=h?.fila_switch;if(!t?.installed)return null;let n=t.in_slots.indexOf(e);return n<0?null:t.out_extruders[n]??null};if(!A||!h)return null;let P=C?`#f97316`:w?`#facc15`:`#00ae42`,F=(e,t)=>{if(e>0)if(t===``){let t={...n};delete t[e],r(t)}else r({...n,[e]:parseInt(t,10)})};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>m(!p),className:`flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full`,children:[(0,K.jsx)(bs,{className:`w-4 h-4`,fill:P,stroke:`none`}),(0,K.jsx)(`span`,{children:l(`printModal.filamentMapping`)}),C?(0,K.jsx)(`span`,{className:`text-xs text-orange-400`,children:`(Type not found)`}):w?(0,K.jsx)(`span`,{className:`text-xs text-yellow-400`,children:`(Color mismatch)`}):(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:`(Ready)`}),p?(0,K.jsx)(cs,{className:`w-4 h-4 ml-auto`}):(0,K.jsx)(is,{className:`w-4 h-4 ml-auto`})]}),p&&(0,K.jsxs)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Click to change slot assignment`}),(0,K.jsxs)(`button`,{type:`button`,onClick:async()=>{f(!0);try{await Q.refreshPrinterStatus(e),await new Promise(e=>setTimeout(e,500)),await u.refetchQueries({queryKey:[`printer-status`,e]})}finally{f(!1)}},className:`flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,disabled:d,children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${d?`animate-spin`:``}`}),(0,K.jsx)(`span`,{children:`Re-read`})]})]}),S.map((e,t)=>{let n=e.slot_id??0,r=n>0&&c!=null,{resolvedName:i,colorLabel:a}=T[t]??{resolvedName:e.type,colorLabel:Gd(e.color)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 16px`},children:[(0,K.jsx)(`span`,{title:`Required: ${i} - ${a}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:e.color,stroke:e.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate flex items-center gap-1`,children:[j&&e.nozzle_id!=null&&(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded text-[9px] font-bold leading-none bg-bambu-gray/20 text-bambu-gray shrink-0`,title:e.nozzle_id===1?l(`printModal.leftNozzleTooltip`):l(`printModal.rightNozzleTooltip`),children:e.nozzle_id===1?l(`printModal.leftNozzle`):l(`printModal.rightNozzle`)}),i,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:e.loaded?.globalTrayId??``,onChange:e=>F(n,e.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${e.status===`match`?`border-bambu-green/50 text-bambu-green`:e.status===`type_only`?`border-yellow-400/50 text-yellow-400`:`border-orange-400/50 text-orange-400`} ${e.isManual?`ring-1 ring-blue-400/50`:``}`,title:e.isManual?`Manually selected`:`Auto-matched`,children:[(0,K.jsx)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:`-- Select slot --`}),x.map(e=>{let t=D.get(e.globalTrayId),n=t==null?``:l(`printModal.slotRemainingShort`,{grams:t,defaultValue:` - ${t}g left`}),r=M?N(e.globalTrayId):null,i=r==null?``:` [${l(r===1?`printModal.leftNozzle`:`printModal.rightNozzle`)}]`;return(0,K.jsxs)(`option`,{value:e.globalTrayId,className:`bg-bambu-dark text-white`,children:[e.label,`: `,e.traySubBrands||e.type,` (`,e.colorName,`)`,n,i]},e.globalTrayId)})]}),e.status===`match`?(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}):e.status===`type_only`?(0,K.jsx)(`span`,{title:`Same type, different color`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`})}):(0,K.jsx)(`span`,{title:`Filament type not loaded`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-orange-400`})})]}),r&&(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-bambu-gray cursor-pointer select-none pl-5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s?.[n]??!1,onChange:e=>c(n,e.target.checked),className:`accent-bambu-green w-3 h-3`}),(0,K.jsx)(ml,{className:`w-3 h-3`}),l(`printModal.forceColorMatch`)]})]},t)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[l(`printModal.totalCost`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:O>0||k?`${i}${O.toFixed(2)}`:`N/A`})]}),C&&(0,K.jsx)(`p`,{className:`text-xs text-orange-400 mt-2`,children:`Required filament type not found in printer.`})]})]})}function uke({filamentReqs:e,availableFilaments:t,overrides:n,onChange:r,forceColorMatch:i,onForceColorMatchChange:a}){let{t:o}=W(),s=$U(e?.filaments),c=(0,y.useMemo)(()=>{let e={};for(let n of t){let t=Nf(n.type);e[t]||(e[t]=[]),e[t].push(n)}return e},[t]),l=e?.filaments;if(!l||l.length===0||t.length===0)return null;let u=(e,t)=>{if(t===``){let t={...n};delete t[e],r(t)}else{let[i,a]=t.split(`|`);r({...n,[e]:{type:i,color:a}})}};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:(0,K.jsx)(`span`,{children:o(`printModal.filamentOverride`)})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:o(`printModal.filamentOverrideHint`)}),(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-3 space-y-2`,children:l.map((e,t)=>{let r=n[e.slot_id],l=!!r,d=c[Nf(e.type)]||[],f=e.nozzle_id==null?d:d.filter(t=>t.extruder_id==null||t.extruder_id===e.nozzle_id),{resolvedName:p,colorLabel:m}=s[t]??{resolvedName:e.type,colorLabel:Gd(e.color)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 20px`},children:[(0,K.jsx)(`span`,{title:`${o(`printModal.originalFilament`)}: ${p} - ${m}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:e.color,stroke:e.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate`,children:[p,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:l?`${r.type}|${r.color}`:``,onChange:t=>u(e.slot_id,t.target.value),disabled:f.length===0,className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${l?`border-blue-400/50 text-blue-400`:`border-bambu-gray/30 text-bambu-gray`}`,children:[(0,K.jsxs)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:[o(`printModal.originalFilament`),`: `,p,` (`,m,`)`]}),f.map((e,t)=>(0,K.jsxs)(`option`,{value:`${e.type}|${e.color}`,className:`bg-bambu-dark text-white`,children:[e.tray_sub_brands||e.type,` (`,Gd(e.color),`)`]},`${e.type}-${e.color}-${e.tray_sub_brands}-${t}`))]}),l?(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(e.slot_id,``),className:`text-bambu-gray hover:text-white transition-colors`,title:o(`printModal.resetToOriginal`),children:(0,K.jsx)(Al,{className:`w-3 h-3`})}):(0,K.jsx)(`span`,{className:`w-3`})]}),(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-bambu-gray cursor-pointer select-none pl-5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i?.[e.slot_id]??!1,onChange:t=>a?.(e.slot_id,t.target.checked),className:`accent-bambu-green w-3 h-3`}),(0,K.jsx)(ml,{className:`w-3 h-3`}),o(`printModal.forceColorMatch`)]})]},e.slot_id)})})]})}function dke({plates:e,isMultiPlate:t,selectedPlates:n,onToggle:r,onSelectAll:i,onDeselectAll:a,multiSelect:o}){let{t:s}=W();if(!t||e.length<=1)return null;let c=n.size===e.length;return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`Select Plate`,o?`s`:``,` to Print`]}),n.size===0&&(0,K.jsxs)(`span`,{className:`text-xs text-orange-400 flex items-center gap-1`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),`Selection required`]}),o&&i&&a&&(0,K.jsx)(`button`,{type:`button`,onClick:c?a:i,className:`ml-auto text-xs px-2 py-0.5 rounded-full border transition-colors ${c?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-gray`}`,children:c?s(`queue.deselectAll`):s(`queue.selectAllPlates`,{count:e.length})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map(e=>{let t=n.has(e.index);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray`}`,children:[o&&(t?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`})),e.has_thumbnail&&e.thumbnail_url!=null?(0,K.jsx)(`img`,{src:Xu(e.thumbnail_url),alt:`Plate ${e.index}`,className:`w-10 h-10 rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:e.name||`Plate ${e.index}`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[e.objects.length>0?e.objects.slice(0,3).join(`, `)+(e.objects.length>3?`...`:``):`${e.filaments.length} filament${e.filaments.length===1?``:`s`}`,e.print_time_seconds==null?``:` • ${Cf(e.print_time_seconds)}`]}),(()=>{let t=QU(e.bed_type);return t?(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray flex items-center gap-1 mt-0.5 truncate`,title:t.label,children:[(0,K.jsx)(`img`,{src:t.icon,alt:``,className:`w-3.5 h-3.5 object-contain flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t.label})]}):null})()]}),!o&&t&&(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]},e.index)})})]})}var eW=new Set,tW=new Set,nW=!1;function fke(e){let t=new Set;for(let n of e.dispatched_jobs??[])typeof n.printer_id==`number`&&t.add(n.printer_id);for(let n of e.active_jobs??[])typeof n.printer_id==`number`&&t.add(n.printer_id);return t}function pke(e){let t=fke(e.detail??{});t.size===eW.size&&[...t].every(e=>eW.has(e))||(eW=t,tW.forEach(e=>e()))}function mke(){nW||typeof window>`u`||(window.addEventListener(`background-dispatch`,pke),nW=!0)}var hke=e=>(mke(),tW.add(e),()=>{tW.delete(e)}),rW=()=>eW;function gke(){return(0,y.useSyncExternalStore)(hke,rW,rW)}var _ke=new Set([`IDLE`,`FINISH`,`FAILED`]);function vke({printerResult:e,filamentReqs:t,onUpdateConfig:n}){let r=no(),[i,a]=(0,y.useState)(!1),o=(t,r)=>{if(t<=0)return;let i={...e.config.manualMappings};r===``?delete i[t]:i[t]=parseInt(r,10),n({useDefault:!1,manualMappings:i,autoConfigured:!1})},s=async()=>{a(!0);try{await Q.refreshPrinterStatus(e.printerId),await new Promise(e=>setTimeout(e,500)),await r.refetchQueries({queryKey:[`printer-status`,e.printerId]})}finally{a(!1)}},c=t.map(t=>{let n=t.slot_id||0,i=e.config.manualMappings[n],a,o=!1;if(i!==void 0)a=e.loadedFilaments.find(e=>e.globalTrayId===i),o=!0;else{let n=new Set(Object.values(e.config.manualMappings)),i=r.getQueryData([`settings`]);a=Jf(t,e.loadedFilaments,n,qf(i?.prefer_lowest_filament,e.status?.ams_filament_backup),e.inventoryByTrayId)}let s=`mismatch`;if(a){let e=a.type?.toUpperCase()===t.type?.toUpperCase(),n=kf(a.color)===kf(t.color)||Ff(a.color,t.color);e&&n?s=`match`:e&&(s=`type_only`)}return{req:t,loaded:a,status:s,isManual:o}});return(0,K.jsxs)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Custom slot mapping`}),(0,K.jsxs)(`button`,{type:`button`,onClick:s,className:`flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,disabled:i,children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${i?`animate-spin`:``}`}),(0,K.jsx)(`span`,{children:`Re-read`})]})]}),c.map(({req:t,loaded:n,status:r,isManual:i},a)=>(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 16px`},children:[(0,K.jsx)(`span`,{title:`Required: ${t.type} - ${Gd(t.color)}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:t.color,stroke:t.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate`,children:[t.type,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,t.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:n?.globalTrayId??``,onChange:e=>o(t.slot_id||0,e.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${r===`match`?`border-bambu-green/50 text-bambu-green`:r===`type_only`?`border-yellow-400/50 text-yellow-400`:`border-orange-400/50 text-orange-400`} ${i?`ring-1 ring-blue-400/50`:``}`,title:i?`Manually selected`:`Auto-matched`,children:[(0,K.jsx)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:`-- Select slot --`}),Yf(e.loadedFilaments,t.nozzle_id).map(e=>(0,K.jsxs)(`option`,{value:e.globalTrayId,className:`bg-bambu-dark text-white`,children:[e.label,`: `,e.traySubBrands||e.type,` (`,e.colorName,`)`]},e.globalTrayId))]}),r===`match`?(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}):r===`type_only`?(0,K.jsx)(`span`,{title:`Same type, different color`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`})}):(0,K.jsx)(`span`,{title:`Filament type not loaded`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-orange-400`})})]},a))]})}function yke({printers:e,selectedPrinterIds:t,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,disableBusy:o=!1,printerMappingResults:s,filamentReqs:c,onAutoConfigurePrinter:l,onUpdatePrinterConfig:u,assignmentMode:d=`printer`,onAssignmentModeChange:f,targetModel:p,onTargetModelChange:m,targetLocation:h,onTargetLocationChange:g,slicedForModel:_}){let[v,b]=(0,y.useState)(!1),x=a?e:e.filter(e=>e.is_active),S=_o({queries:x.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),staleTime:5e3}))}),C=(0,y.useMemo)(()=>{let e=new Map;return x.forEach((t,n)=>{let r=S[n];r?.data&&e.set(t.id,r.data)}),e},[x,S]),w=gke(),T=e=>{if(w.has(e))return!0;let t=C.get(e);return t?t.connected?!_ke.has(t.state??``):!0:!1},E=e=>{if(w.has(e))return`Dispatching...`;let t=C.get(e);if(!t)return null;if(!t.connected)return`Offline`;let n=t.state;return n?n===`RUNNING`?t.stg_cur_name||`Printing`:n===`PREPARE`?`Preparing`:n===`PAUSE`?`Paused`:n===`IDLE`?`Idle`:n===`FINISH`?`Finished`:n===`FAILED`?`Failed`:n:null},D=(0,y.useMemo)(()=>{if(d!==`printer`||!_||v)return x;let e=x.filter(e=>e.model===_);return e.length>0?e:x},[x,d,_,v]),O=x.length-D.length,k=(0,y.useMemo)(()=>{let e=x.map(e=>e.model).filter(e=>!!e);return[...new Set(e)].sort()},[x]),A=(0,y.useMemo)(()=>{if(!p)return[];let e=x.filter(e=>e.model===p&&e.location).map(e=>e.location).filter(e=>!!e);return[...new Set(e)].sort()},[x,p]),j=f&&m&&k.length>0,M=i&&t.length>1&&s&&c?.filaments&&c.filaments.length>0&&l&&u;if(r)return(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})});if(D.length===0)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm mb-4`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),`No `,a?``:`active `,`printers available`]});let N=e=>{o&&T(e)||(i?t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e]):n([e]))},P=()=>{n((o?D.filter(e=>!T(e.id)):D).map(e=>e.id))},F=()=>{n([])},I=(e,t,n)=>{n.stopPropagation(),!(!l||!u)&&(t?l(e):u(e,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},L=e=>t.includes(e),R=t.length,z=e=>s?.find(t=>t.printerId===e);return(0,K.jsxs)(`div`,{className:`space-y-2 mb-6`,children:[j&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{f(`printer`),m(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d===`printer`?`border-bambu-green bg-bambu-green/10 text-white`:`border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray`}`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:`Specific Printer`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{f(`model`),n([]),m(_&&k.includes(_)?_:k[0])},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d===`model`?`border-bambu-green bg-bambu-green/10 text-white`:`border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[`Any `,_||`Model`]})]})]}),d===`model`&&j&&(0,K.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[!_&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:`Target Model`}),(0,K.jsxs)(`select`,{value:p||``,onChange:e=>{m(e.target.value||null),g&&g(null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`Select a model...`}),k.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),p&&A.length>0&&g&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:`Location Filter (optional)`}),(0,K.jsxs)(`select`,{value:h||``,onChange:e=>g(e.target.value||null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`Any location`}),A.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),p&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Scheduler will assign to first available idle `,p,` printer`,h?` in ${h}`:``]})]}),d===`printer`&&i&&D.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray mb-2`,children:[(0,K.jsx)(`span`,{children:R===0?`Select printers`:`${R} printer${R===1?``:`s`} selected`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[R0&&(0,K.jsx)(`button`,{type:`button`,onClick:F,className:`text-bambu-gray hover:text-white transition-colors`,children:`Clear`})]})]}),d===`printer`&&D.map(e=>{let t=L(e.id),n=z(e.id),r=n&&!n.config.useDefault,a=T(e.id),s=o&&a,d=E(e.id);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>N(e.id),disabled:s,className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${s?`border-bambu-dark-tertiary bg-bambu-dark opacity-50 cursor-not-allowed`:t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray`} ${e.is_active?``:`opacity-60`}`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${s?`bg-bambu-dark-tertiary`:t?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(Tl,{className:`w-5 h-5 ${s?`text-bambu-gray/50`:t?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{className:`text-left flex-1`,children:[(0,K.jsxs)(`p`,{className:`font-medium ${s?`text-bambu-gray`:`text-white`}`,children:[e.name,!e.is_active&&(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs ml-2`,children:`(inactive)`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.model||`Unknown model`,` • `,e.ip_address]})]}),d&&(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${a?`bg-yellow-500/20 text-yellow-400`:`bg-bambu-green/20 text-bambu-green`}`,children:d}),i&&(0,K.jsx)(`div`,{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${s?`border-bambu-gray/30`:t?`bg-bambu-green border-bambu-green`:`border-bambu-gray/50`}`,children:t&&(0,K.jsx)(rs,{className:`w-3 h-3 text-white`})})]}),t&&M&&n&&(0,K.jsxs)(`div`,{className:`ml-4 mt-2 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,onChange:t=>I(e.id,t.target.checked,t),className:`w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Custom mapping`})]}),(0,K.jsxs)(`span`,{className:`text-xs ml-2 ${n.matchStatus===`full`?`text-bambu-green`:n.matchStatus===`partial`?`text-yellow-400`:`text-orange-400`}`,children:[`(`,n.exactMatches,`/`,n.totalSlots,` matched)`]}),n.isLoading&&(0,K.jsx)(Ol,{className:`w-3 h-3 text-bambu-gray animate-spin`}),r&&(0,K.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e.id)},className:`ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,children:[(0,K.jsx)(Mu,{className:`w-3 h-3`}),`Auto`]})]}),r&&(0,K.jsx)(vke,{printerResult:n,filamentReqs:c.filaments,onUpdateConfig:t=>u(e.id,t)})]})]},e.id)}),d===`printer`&&O>0&&!v&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:`text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`}),O,` other printer`,O>1?`s`:``,` hidden (different model) —`,(0,K.jsx)(`span`,{className:`underline`,children:`show all`})]}),d===`printer`&&v&&_&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:`text-xs text-bambu-gray hover:text-white transition-colors mt-2`,children:(0,K.jsxs)(`span`,{className:`underline`,children:[`Show only `,_,` printers`]})}),d===`printer`&&R===0&&(0,K.jsxs)(`p`,{className:`text-xs text-orange-400 mt-1 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Select at least one printer`]}),d===`model`&&!p&&(0,K.jsxs)(`p`,{className:`text-xs text-orange-400 mt-1 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Select a target printer model`]})]})}function bke({options:e,onChange:t,defaultExpanded:n=!1,showDualNozzleOptions:r=!1}){let{t:i}=W(),[a,o]=(0,y.useState)(n),s=[{key:`bed_levelling`,label:i(`settings.defaultBedLevelling`),desc:i(`settings.defaultBedLevellingDesc`)},{key:`flow_cali`,label:i(`settings.defaultFlowCali`),desc:i(`settings.defaultFlowCaliDesc`)},{key:`vibration_cali`,label:i(`settings.defaultVibrationCali`),desc:i(`settings.defaultVibrationCaliDesc`)},{key:`layer_inspect`,label:i(`settings.defaultLayerInspect`),desc:i(`settings.defaultLayerInspectDesc`)},{key:`timelapse`,label:i(`settings.defaultTimelapse`),desc:i(`settings.defaultTimelapseDesc`)},{key:`nozzle_offset_cali`,label:i(`settings.defaultNozzleOffsetCali`),desc:i(`settings.defaultNozzleOffsetCaliDesc`),dualNozzleOnly:!0}].filter(e=>!e.dualNozzleOnly||r),c=n=>{t({...e,[n]:!e[n]})};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full`,children:[(0,K.jsx)(Ul,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:i(`queue.bulkEdit.printOptions`)}),a?(0,K.jsx)(cs,{className:`w-4 h-4 ml-auto`}):(0,K.jsx)(is,{className:`w-4 h-4 ml-auto`})]}),a&&(0,K.jsx)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:s.map(({key:t,label:n,desc:r})=>(0,K.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer group`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r})]}),(0,K.jsx)(`div`,{className:`relative w-10 h-5 rounded-full transition-colors ${e[t]?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,onClick:()=>c(t),children:(0,K.jsx)(`div`,{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${e[t]?`translate-x-5`:`translate-x-0.5`}`})})]},t))})]})}function xke({options:e,onChange:t,dateFormat:n=`system`,timeFormat:r=`system`,canControlPrinter:i=!0,showStagger:a=!1,printerCount:o=0,hasGcodeSnippets:s=!1}){let{t:c}=W(),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(!0),_=(0,y.useRef)(null),v=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(e.scheduleType!==`scheduled`){v.current=!1;return}if(!v.current){v.current=!0;let i;e.scheduledTime?(i=new Date(e.scheduledTime),isNaN(i.getTime())&&(i=new Date,i.setHours(i.getHours()+1,0,0,0))):(i=new Date,i.setHours(i.getHours()+1,0,0,0),t({...e,scheduledTime:gf(i)})),u(uf(i,n)),f(df(i,r)),m(!0),g(!0)}},[e.scheduleType,e.scheduledTime,n,r,t,e]);let b=n=>{t({...e,scheduleType:n})},x=(r,i)=>{let a=mf(r,n),o=hf(i);m(!!a),g(!!o),a&&o&&(a.setHours(o.hours,o.minutes,0,0),a>new Date&&t({...e,scheduledTime:gf(a)}))},S=e=>{u(e),x(e,d)},C=e=>{f(e),x(l,e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:`When to print`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`asap`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`asap`),children:[(0,K.jsx)(Ss,{className:`w-4 h-4`}),`ASAP`]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`scheduled`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`scheduled`),children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),`Scheduled`]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`manual`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`manual`),children:[(0,K.jsx)(Cc,{className:`w-4 h-4`}),`Queue Only`]})]})]}),e.scheduleType===`scheduled`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Date & Time`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 pr-10 bg-bambu-dark border rounded-lg text-white focus:outline-none ${p?`border-bambu-dark-tertiary focus:border-bambu-green`:`border-red-500`}`,value:l,onChange:e=>S(e.target.value),placeholder:cf(n)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{_.current?.showPicker()},className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,title:`Open calendar`,children:(0,K.jsx)(Zo,{className:`w-4 h-4`})}),(0,K.jsx)(`input`,{ref:_,type:`datetime-local`,className:`absolute top-0 left-0 w-0 h-0 opacity-0 pointer-events-none`,value:e.scheduledTime,onChange:i=>{let a=i.target.value;if(a){let i=new Date(a);isNaN(i.getTime())||(u(uf(i,n)),f(df(i,r)),m(!0),g(!0),t({...e,scheduledTime:a}))}},tabIndex:-1})]}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:outline-none ${h?`border-bambu-dark-tertiary focus:border-bambu-green`:`border-red-500`}`,value:d,onChange:e=>C(e.target.value),placeholder:lf(r)})})]}),(!p||!h)&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:`Please enter a valid date and time`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`requirePrevious`,checked:e.requirePreviousSuccess,onChange:n=>t({...e,requirePreviousSuccess:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`requirePrevious`,className:`text-sm text-bambu-gray`,children:`Only start if previous print succeeded`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`autoOffAfter`,checked:e.autoOffAfter,onChange:n=>t({...e,autoOffAfter:n.target.checked}),disabled:!i,className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green disabled:opacity-50`}),(0,K.jsxs)(`label`,{htmlFor:`autoOffAfter`,className:`text-sm flex items-center gap-1 ${i?`text-bambu-gray`:`text-bambu-gray/50`}`,children:[(0,K.jsx)(wl,{className:`w-3.5 h-3.5`}),`Power off printer when done`]})]}),s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`gcodeInjection`,checked:e.gcodeInjection,onChange:n=>t({...e,gcodeInjection:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`gcodeInjection`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Es,{className:`w-3.5 h-3.5`}),c(`printModal.gcodeInjection`,`Inject auto-print G-code`)]})]}),a&&e.scheduleType!==`manual`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`staggerEnabled`,checked:e.staggerEnabled,onChange:n=>t({...e,staggerEnabled:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`staggerEnabled`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5`}),c(`printModal.staggerPrinterStarts`,`Stagger printer starts`)]})]}),e.staggerEnabled&&(0,K.jsxs)(`div`,{className:`ml-6 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:c(`printModal.staggerGroupSize`,`Group size`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:o,value:e.staggerGroupSize,onChange:n=>t({...e,staggerGroupSize:Math.max(1,parseInt(n.target.value)||1)}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:c(`printModal.staggerInterval`,`Interval (min)`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:60,value:e.staggerIntervalMinutes,onChange:n=>t({...e,staggerIntervalMinutes:Math.max(1,parseInt(n.target.value)||1)}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})]}),o>0&&(()=>{let t=Math.ceil(o/e.staggerGroupSize),n=o%e.staggerGroupSize,r=(t-1)*e.staggerIntervalMinutes;return(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[c(`printModal.staggerPreview`,`{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min`,{printers:o,groups:t,size:e.staggerGroupSize,interval:e.staggerIntervalMinutes}),n!==0&&e.staggerGroupSize1?` (${c(`printModal.staggerTotal`,`total: {{minutes}} min`,{minutes:r})})`:``]})})()]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.scheduleType===`asap`?`Print will start as soon as the printer is idle.`:e.scheduleType===`scheduled`?`Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.`:`Print will be staged but won't start automatically. Use the Start button to release it to the queue.`})]})}var iW={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1,nozzle_offset_cali:!0},aW={scheduleType:`asap`,scheduledTime:``,requirePreviousSuccess:!1,autoOffAfter:!1,gcodeInjection:!1,staggerEnabled:!1,staggerGroupSize:2,staggerIntervalMinutes:5};function oW({mode:e,archiveId:t,libraryFileId:n,archiveName:r,queueItem:i,initialSelectedPrinterIds:a,onClose:o,onSuccess:s,projectId:c,cleanupLibraryAfterDispatch:l}){let{t:u}=W(),d=no(),{showToast:f}=Td(),{hasPermission:p}=dd(),m=!!n&&!t,[h,g]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.printer_id?[i.printer_id]:a?.length?a:[]),[_,v]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.plate_id!=null?new Set([i.plate_id]):new Set),b=_.size===1?[..._][0]:null,[x,S]=(0,y.useState)(1),[C,w]=(0,y.useState)(()=>e===`edit-queue-item`&&i?{bed_levelling:i.bed_levelling??iW.bed_levelling,flow_cali:i.flow_cali??iW.flow_cali,vibration_cali:i.vibration_cali??iW.vibration_cali,layer_inspect:i.layer_inspect??iW.layer_inspect,timelapse:i.timelapse??iW.timelapse,nozzle_offset_cali:i.nozzle_offset_cali??iW.nozzle_offset_cali}:iW),[T,E]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i){let e=`asap`;i.manual_start?e=`manual`:i.scheduled_time&&!Uf(i.scheduled_time)&&(e=`scheduled`);let t=``;return i.scheduled_time&&!Uf(i.scheduled_time)&&(t=gf(vf(i.scheduled_time)??new Date)),{scheduleType:e,scheduledTime:t,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after,gcodeInjection:i.gcode_injection??!1,staggerEnabled:!1,staggerGroupSize:aW.staggerGroupSize,staggerIntervalMinutes:aW.staggerIntervalMinutes}}return aW}),[D,O]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){let e={};return i.ams_mapping.forEach((t,n)=>{t!==-1&&(e[n+1]=t)}),e}return{}}),[k,A]=(0,y.useState)({}),[j,M]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_model?`model`:`printer`),[N,P]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_model?i.target_model:null),[F,I]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_location?i.target_location:null),[L,R]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.filament_overrides){let e={};for(let t of i.filament_overrides)e[t.slot_id]={type:t.type,color:t.color};return e}return{}}),[z,B]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.filament_overrides){let e={};for(let t of i.filament_overrides)e[t.slot_id]=t.force_color_match===!0;return e}return{}}),[V]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.printer_id?[i.printer_id]:[]),[ee]=(0,y.useState)(()=>e===`edit-queue-item`&&i?i.plate_id:null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)({current:0,total:0}),[H,ae]=(0,y.useState)(null),[oe,U]=(0,y.useState)(new Set),se=h.length,ce=h.length>0?h[0]:null,{data:le}=q({queryKey:[`settings`],queryFn:Q.getSettings}),ue=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!le||ue.current||e===`edit-queue-item`||(ue.current=!0,w({bed_levelling:le.default_bed_levelling??iW.bed_levelling,flow_cali:le.default_flow_cali??iW.flow_cali,vibration_cali:le.default_vibration_cali??iW.vibration_cali,layer_inspect:le.default_layer_inspect??iW.layer_inspect,timelapse:le.default_timelapse??iW.timelapse,nozzle_offset_cali:le.default_nozzle_offset_cali??iW.nozzle_offset_cali}))},[le,e]);let de=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!le||de.current||e===`edit-queue-item`||(de.current=!0,E(e=>({...e,staggerGroupSize:le.stagger_group_size??e.staggerGroupSize,staggerIntervalMinutes:le.stagger_interval_minutes??e.staggerIntervalMinutes})))},[le,e]);let fe=$d(le?.currency||`USD`),pe=le?.default_filament_cost??0,{data:me,isLoading:he}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:ge}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),staleTime:30*1e3,enabled:(e===`reprint`||e===`add-to-queue`)&&j===`printer`||m&&e===`reprint`}),_e=_o({queries:h.map(e=>({queryKey:[`printer-inventory-remain`,e],queryFn:()=>Q.getInventoryRemain(e),staleTime:30*1e3,enabled:h.length>0}))}),ve=(0,y.useMemo)(()=>{let e=new Map;return h.forEach((t,n)=>{let r=_e[n]?.data?.inventory_remain_g;if(!r)return;let i=new Map;Object.entries(r).forEach(([e,t])=>{let n=Number(e);Number.isNaN(n)||i.set(n,t)}),e.set(t,i)}),e},[h,_e]),{data:ye}=q({queryKey:[`archive`,t],queryFn:()=>Q.getArchive(t),enabled:!!t&&!m}),{data:be}=q({queryKey:[`library-file`,n],queryFn:()=>Q.getLibraryFile(n),enabled:m&&!!n}),xe=ye?.sliced_for_model||be?.sliced_for_model||null,{data:Se,isError:Ce}=q({queryKey:[`archive-plates`,t],queryFn:()=>Q.getArchivePlates(t),enabled:!!t&&!m,retry:!1}),{data:we}=q({queryKey:[`library-file-plates`,n],queryFn:()=>Q.getLibraryFilePlates(n),enabled:m&&!!n}),Te=m?we:Se,{data:Ee,isError:De}=q({queryKey:[`archive-filaments`,t,b],queryFn:()=>Q.getArchiveFilamentRequirements(t,b??void 0),enabled:!!t&&!m&&(b!==null||!Te?.is_multi_plate),retry:!1}),{data:Oe}=q({queryKey:[`library-file-filaments`,n,b],queryFn:()=>Q.getLibraryFileFilamentRequirements(n,b??void 0),enabled:m&&!!n&&(b!==null||!Te?.is_multi_plate)}),ke=!m&&(Ce||De),Ae=m?Oe:Ee,je=(0,y.useMemo)(()=>{if(!(b===null||!Te?.plates?.length))return Te.plates.find(e=>e.index===b)?.name||void 0},[Te,b]),{data:Me}=q({queryKey:[`available-filaments`,N,F],queryFn:()=>Q.getAvailableFilaments(N,F??void 0),enabled:j===`model`&&!!N}),{data:Ne}=q({queryKey:[`printer-status`,ce],queryFn:()=>Q.getPrinterStatus(ce),enabled:!!ce}),{amsMapping:Pe}=YU(Ae,Ne,D,qf(le?.prefer_lowest_filament,Ne?.ams_filament_backup),ce?ve.get(ce):void 0),Fe=oke(h,me,Ae,D,k,A,le?.prefer_lowest_filament,ve);(0,y.useEffect)(()=>{Te?.plates&&Te.plates.length>=1&&_.size===0&&v(new Set([Te.plates[0].index]))},[Te,_.size]),(0,y.useEffect)(()=>{if(e===`edit-queue-item`)return;let t=me?.filter(e=>e.is_active)||[];t.length===1&&h.length===0&&g([t[0].id])},[e,me,h.length]),(0,y.useEffect)(()=>{e===`edit-queue-item`?(JSON.stringify(h.sort())!==JSON.stringify(V.sort())||b!==ee)&&(O({}),A({}),U(new Set)):(O({}),A({}),U(new Set))},[e,h,b,V,ee]);let[Ie,Le]=(0,y.useState)(N),[Re,ze]=(0,y.useState)(b);(0,y.useEffect)(()=>{(N!==Ie||b!==Re)&&(Le(N),ze(b),(e!==`edit-queue-item`||Ie!==null)&&(R({}),B({})))},[N,b,Ie,Re,e]),(0,y.useEffect)(()=>{if(!le?.per_printer_mapping_expanded||h.length<=1)return;let e=h.filter(e=>{if(oe.has(e))return!1;let t=Fe.printerResults.find(t=>t.printerId===e);return t&&t.status&&!t.isLoading});e.length>0&&(U(t=>{let n=new Set(t);return e.forEach(e=>n.add(e)),n}),e.forEach(e=>{Fe.autoConfigurePrinter(e)}))},[le?.per_printer_mapping_expanded,h,oe,Fe]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!te&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,te]);let Be=Te?.is_multi_plate??!1,Ve=Te?.plates??[],He=(0,y.useMemo)(()=>{let e=new Map;return ge&&ge.forEach(t=>{let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n),i=e.get(t.printer_id)??new Map;i.set(r,t),e.set(t.printer_id,i)}),e},[ge]),Ue=(0,y.useMemo)(()=>{if(!H||H.length===0)return``;let e=H.map(e=>u(`printModal.insufficientFilamentLine`,{printer:e.printerName,slot:e.slotLabel,required:Math.round(e.requiredGrams),remaining:Math.round(e.remainingGrams)}));return[u(`printModal.insufficientFilamentMessage`),...e].join(` -`)},[H,u]),We=J({mutationFn:e=>Q.addToQueue(e)}),Ge=J({mutationFn:e=>Q.updateQueueItem(i.id,e),onSuccess:()=>{d.invalidateQueries({queryKey:[`queue`]}),f(`Queue item updated`),s?.(),o()},onError:e=>{f(e.message||`Failed to update queue item`,`error`)}}),Ke=T.staggerEnabled&&h.length>1,qe=async(i,a)=>{if(i?.preventDefault(),!a?.skipFilamentCheck&&!le?.disable_filament_warnings&&(e===`reprint`||e===`add-to-queue`)&&j===`printer`){let e=[],t=Ae?.filaments??[];if(t.length>0&&He.size>0){let n=(e,t)=>!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<0?null:Math.max(0,e-t);for(let r of h){let i=h.length>1?Fe.getFinalMapping(r):Pe;if(!i)continue;let a=qU(h.length>1?Fe.printerResults.find(e=>e.printerId===r)?.status:Ne),o=new Map(a.map(e=>[e.globalTrayId,e.label])),s=He.get(r),c=me?.find(e=>e.id===r)?.name??`Printer ${r}`;s&&t.forEach(t=>{if(!t.slot_id||t.slot_id<=0)return;let r=i[t.slot_id-1];if(!Number.isFinite(r)||r<0)return;let a=s.get(r)?.spool;if(!a)return;let l=n(a.label_weight,a.weight_used);l!==null&&(l>=t.used_grams||e.push({printerName:c,slotLabel:o.get(r)??`Slot ${t.slot_id}`,requiredGrams:t.used_grams,remainingGrams:l}))})}}if(e.length>0){ae(e);return}}if(j===`printer`&&h.length===0){f(`Please select at least one printer`,`error`);return}if(j===`model`&&!N){f(`Please select a target printer model`,`error`);return}ne(!0);let p=_.size>1?Ve.filter(e=>_.has(e.index)):[null],g=j===`model`?p.length:h.length*p.length;ie({current:0,total:g});let v={success:0,failed:0,errors:[]},y=e=>{if(h.length>1){let t=k[e];if(t&&!t.useDefault)return Fe.getFinalMapping(e)}return Pe},x=(()=>{let e=[];if(Ae?.filaments)for(let t of Ae.filaments){let n=L[t.slot_id],r=z[t.slot_id]??!1,i=n?.type??t.type,a=n?.color??t.color;(n||r)&&e.push({slot_id:t.slot_id,type:i,color:a,color_name:Gd(a),force_color_match:r})}else for(let[t,{type:n,color:r}]of Object.entries(L)){let i=parseInt(t,10),a=z[i]??!1;e.push({slot_id:i,type:n,color:r,color_name:Gd(r),force_color_match:a})}return e.length>0?e:void 0})(),S=e===`add-to-queue`&&p.length>1&&(j===`model`||h.length===1),w=null;if(S)try{let e=`${(r||``).replace(/\.gcode\.3mf$/i,``).replace(/\.3mf$/i,``)||`Batch`} · ${p.length} plates`;w=(await Q.createBatch({name:e,archive_id:m?void 0:t,library_file_id:m?n:void 0})).id}catch{w=null}let E=(e,r)=>({printer_id:j===`printer`?e:null,target_model:j===`model`?N:null,target_location:j===`model`?F:null,filament_overrides:j===`model`?x:void 0,archive_id:m?void 0:t,library_file_id:m?n:void 0,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,skip_filament_check:a?.skipFilamentCheck===!0?!0:void 0,ams_mapping:e?y(e):void 0,plate_id:r===void 0?b:r,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():void 0,...C,project_id:c??void 0,batch_id:w??void 0});if(j===`model`){if(e===`reprint`){f(`Model-based assignment only works with queue mode`,`error`),ne(!1);return}let t=0;for(let n of p){t++,ie({current:t,total:g});let r=n?n.index:b;try{if(e===`edit-queue-item`&&!n){let e={printer_id:null,target_model:N,target_location:F,filament_overrides:x||null,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,ams_mapping:void 0,plate_id:r,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():null,...C};await Ge.mutateAsync(e)}else{let e=E(null,r);Xe>1&&(e.quantity=Xe),await We.mutateAsync(e)}v.success++}catch(e){v.failed++;let t=n?n.name||`Plate ${n.index}`:``;v.errors.push(t?`${t}: ${e.message}`:e.message)}}}else{let r=T.staggerEnabled&&(e===`add-to-queue`||e===`reprint`)&&h.length>1,i=r?T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).getTime():Date.now():0,a=0;for(let o of p){let s=o?o.index:b;for(let u=0;u1){let e=E(d,s);e.quantity=Xe,await We.mutateAsync(e)}else if(m?await Q.printLibraryFile(n,d,{plate_id:b??void 0,plate_name:je,ams_mapping:e,...C,project_id:c,cleanup_library_after_dispatch:l}):await Q.reprintArchive(t,d,{plate_id:b??void 0,plate_name:je,ams_mapping:e,...C}),Xe>1){let e=E(d,s);e.quantity=Xe-1,await We.mutateAsync(e)}}else if(e===`edit-queue-item`&&a===1){let e=y(d),t={printer_id:d,target_model:null,target_location:null,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,ams_mapping:e,plate_id:s,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():null,...C};await Ge.mutateAsync(t)}else{let e=E(d,s);if(Xe>1&&(e.quantity=Xe),r){let t=Math.floor(u/T.staggerGroupSize);if(t>0){let n=t*T.staggerIntervalMinutes*6e4;e.scheduled_time=new Date(i+n).toISOString()}}await We.mutateAsync(e)}v.success++}catch(e){v.failed++;let t=me?.find(e=>e.id===d)?.name||`Printer ${d}`,n=o?o.name||`Plate ${o.index}`:``,r=n?`${t} (${n})`:t;v.errors.push(`${r}: ${e.message}`)}}}}ne(!1),v.failed===0?(e===`reprint`&&Ke?f(u(`queue.itemsQueued`,{count:v.success})):e!==`reprint`&&(e===`edit-queue-item`?f(`Queue item updated`):v.success===1?f(j===`model`?`Queued for any ${N}`:u(`queue.printQueued`)):f(u(`queue.itemsQueued`,{count:v.success}))),d.invalidateQueries({queryKey:[`queue`]}),s?.(),o()):v.success===0?f(`Failed: ${v.errors[0]}`,`error`):(f(`${v.success} succeeded, ${v.failed} failed`,`error`),d.invalidateQueries({queryKey:[`queue`]}))},Je=te||Ge.isPending,Ye=(0,y.useMemo)(()=>!(Je||j===`printer`&&h.length===0||j===`model`&&!N||j===`model`&&e===`reprint`||Be&&_.size===0),[h.length,j,N,e,Be,_.size,Je]),Xe=j===`printer`&&h.length>1?1:x;(0,y.useEffect)(()=>{e===`reprint`&&T.gcodeInjection&&(Xe<=1||!le?.gcode_snippets)&&E(e=>({...e,gcodeInjection:!1}))},[e,Xe,le?.gcode_snippets,T.gcodeInjection]);let Ze=(()=>{let t=h.length;if(e===`reprint`){let e=Ke&&t>1,n=e?u(`printModal.staggerToPrinters`,{count:t,defaultValue:`Stagger to {{count}} printers`}):t>1?u(`queue.printToPrinters`,{count:t}):u(`queue.print`);return Xe>1&&(n=`${n} ×${Xe}`),{title:u(m?`queue.print`:`queue.reprint`),icon:Tl,submitText:n,submitIcon:e?Zo:Tl,loadingText:re.total>1?u(`queue.sendingProgress`,{current:re.current,total:re.total}):u(`queue.sending`)}}if(e===`add-to-queue`){let e=u(`queue.addToQueue`);return _.size>1?e=u(`queue.queueSelectedPlates`,{count:_.size}):t>1&&(e=u(`queue.queueToPrinters`,{count:t})),Xe>1&&(e=`${e} ×${Xe}`),{title:u(`queue.schedulePrint`),icon:Zo,submitText:e,submitIcon:Zo,loadingText:re.total>1?u(`queue.addingProgress`,{current:re.current,total:re.total}):u(`queue.adding`)}}return{title:u(`queue.editQueueItem`),icon:vl,submitText:u(`common.save`),submitIcon:vl,loadingText:re.total>1?u(`queue.savingProgress`,{current:re.current,total:re.total}):u(`common.saving`)}})(),Qe=Ze.icon,$e=Ze.submitIcon,et=ce&&_.size<=1&&(m||(Be?b!==null:!0)),tt=(0,y.useMemo)(()=>new Set([`H2D`,`H2DPRO`,`H2C`,`X2D`]),[]),nt=(0,y.useMemo)(()=>j===`model`?N?tt.has(N.toUpperCase().replace(/[\s-]/g,``)):!1:!me||h.length===0?!1:h.some(e=>me.find(t=>t.id===e)?.nozzle_count===2),[j,N,me,h,tt]);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:te?void 0:o,children:[(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:e===`reprint`?``:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${e===`reprint`?`mb-4`:`p-4 border-b border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Qe,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:Ze.title})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:o,disabled:te,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:qe,className:e===`reprint`?``:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray ${e===`reprint`?`mb-4`:``}`,children:e===`reprint`?(0,K.jsxs)(K.Fragment,{children:[`Send `,(0,K.jsx)(`span`,{className:`text-white`,children:r}),` to`,` `,a?.length===1&&me?(0,K.jsx)(`span`,{className:`text-white`,children:me.find(e=>e.id===a[0])?.name??`printer(s)`}):`printer(s)`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`block text-bambu-gray mb-1`,children:`Print Job`}),(0,K.jsx)(`span`,{className:`text-white font-medium truncate block`,children:r})]})}),(()=>{if(!Ve.length)return null;let e=QU((b==null?Ve[0]:Ve.find(e=>e.index===b))?.bed_type);return e?(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray -mt-2`,title:e.label,children:[(0,K.jsx)(`img`,{src:e.icon,alt:``,className:`w-4 h-4 object-contain flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label})]}):null})(),(0,K.jsx)(dke,{plates:Ve,isMultiPlate:Be,selectedPlates:_,onToggle:t=>{v(n=>{let r=new Set(n);return e===`add-to-queue`?r.has(t)?r.delete(t):r.add(t):(r.clear(),r.add(t)),r})},onSelectAll:e===`add-to-queue`?()=>v(new Set(Ve.map(e=>e.index))):void 0,onDeselectAll:e===`add-to-queue`?()=>v(new Set):void 0,multiSelect:e===`add-to-queue`}),!a?.length&&(0,K.jsx)(yke,{printers:me||[],selectedPrinterIds:h,onMultiSelect:g,isLoading:he,allowMultiple:!0,showInactive:e===`edit-queue-item`,disableBusy:e===`reprint`,printerMappingResults:Fe.printerResults,filamentReqs:Ae,onAutoConfigurePrinter:Fe.autoConfigurePrinter,onUpdatePrinterConfig:Fe.updatePrinterConfig,assignmentMode:e===`reprint`?`printer`:j,onAssignmentModeChange:e===`reprint`?void 0:M,targetModel:N,onTargetModelChange:e===`reprint`?void 0:P,targetLocation:F,onTargetLocationChange:e===`reprint`?void 0:I,slicedForModel:xe}),j===`model`&&N&&Ae&&Me&&Me.length>0&&(0,K.jsx)(uke,{filamentReqs:Ae,availableFilaments:Me,overrides:L,onChange:R,forceColorMatch:z,onForceColorMatchChange:(e,t)=>B(n=>({...n,[e]:t}))}),xe&&j===`printer`&&h.length===1&&(()=>{let e=me?.find(e=>e.id===h[0]);return e&&e.model&&xe!==e.model?(0,K.jsxs)(`div`,{className:`p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`span`,{className:`text-sm text-yellow-400`,children:[`File was sliced for `,xe,`, but printing on `,e.model]})]}):null})(),ke&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-orange-400`,children:`Archive data unavailable. The source file may have been deleted. Filament mapping is disabled.`})]}),et&&!ke&&h.length===1&&(0,K.jsx)(lke,{printerId:ce,filamentReqs:Ae,manualMappings:D,onManualMappingChange:O,defaultExpanded:!!a?.length||(le?.per_printer_mapping_expanded??!1),currencySymbol:fe,defaultCostPerKg:pe,forceColorMatch:z,onForceColorMatchChange:(e,t)=>B(n=>({...n,[e]:t}))}),(e===`reprint`||se>0||j===`model`&&N)&&(0,K.jsx)(bke,{options:C,onChange:w,defaultExpanded:!!a?.length,showDualNozzleOptions:nt}),e!==`edit-queue-item`&&(j===`model`||h.length<=1)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`label`,{htmlFor:`printQuantity`,className:`text-sm text-bambu-gray whitespace-nowrap`,children:u(`queue.quantity`,`Quantity`)}),(0,K.jsx)(`input`,{id:`printQuantity`,type:`number`,min:1,max:999,value:x,onChange:e=>S(Math.max(1,Math.min(999,parseInt(e.target.value)||1))),className:`w-20 px-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green`}),x>1&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:u(`queue.quantityHint`,`Creates {{count}} queue items`,{count:x})})]}),e===`reprint`&&j===`printer`&&h.length>1&&(0,K.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`staggerEnabledReprint`,checked:T.staggerEnabled,onChange:e=>E({...T,staggerEnabled:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`staggerEnabledReprint`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5`}),u(`printModal.staggerPrinterStarts`,`Stagger printer starts`)]})]}),T.staggerEnabled&&(()=>{let e=T.staggerGroupSize,t=T.staggerIntervalMinutes,n=Math.ceil(h.length/e),r=(n-1)*t;return(0,K.jsxs)(`p`,{className:`ml-6 text-xs text-bambu-gray`,children:[u(`printModal.staggerPreview`,`{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min`,{printers:h.length,groups:n,size:e,interval:t}),n>1?` (${u(`printModal.staggerTotal`,`total: {{minutes}} min`,{minutes:r})})`:``]})})()]}),e!==`reprint`&&(0,K.jsx)(xke,{options:T,onChange:E,dateFormat:le?.date_format||`system`,timeFormat:le?.time_format||`system`,canControlPrinter:p(`printers:control`),showStagger:e===`add-to-queue`&&j===`printer`&&h.length>1,printerCount:h.length,hasGcodeSnippets:!!le?.gcode_snippets}),e===`reprint`&&!!le?.gcode_snippets&&Xe>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`gcodeInjectionReprint`,checked:T.gcodeInjection,onChange:e=>E({...T,gcodeInjection:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`gcodeInjectionReprint`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Es,{className:`w-3.5 h-3.5`}),u(`printModal.gcodeInjection`,`Inject auto-print G-code`)]})]}),Ge.isError&&(0,K.jsx)(`div`,{className:`mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:Ge.error?.message||`Failed to complete operation`}),(0,K.jsxs)(`div`,{className:`flex gap-3 ${e===`reprint`?``:`pt-2`}`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:o,className:`flex-1`,disabled:te,children:`Cancel`}),(0,K.jsx)($,{type:`submit`,disabled:!Ye,className:`flex-1`,children:Je?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),Ze.loadingText]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{className:`w-4 h-4`}),Ze.submitText]})})]})]})]})}),H&&H.length>0&&(0,K.jsx)(Ad,{title:u(`printModal.insufficientFilamentTitle`),message:Ue,confirmText:u(`printModal.printAnyway`),cancelText:u(`common.cancel`),variant:`warning`,onConfirm:()=>{ae(null),qe(void 0,{skipFilamentCheck:!0})},onCancel:()=>ae(null)})]})}function sW({value:e}){let{t}=W(),[n,r]=(0,y.useState)(!1);return(0,K.jsx)(`button`,{onClick:async()=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{if(t.select(),!document.execCommand(`copy`))return}finally{document.body.removeChild(t)}}r(!0),setTimeout(()=>r(!1),2e3)}catch{}},className:`ml-2 p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:t(n?`printers.copied`:`printers.copyToClipboard`),children:n?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})}function Ske({printer:e,status:t,totalPrintHours:n,onClose:r}){let{t:i}=W();(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let a=[];if(a.push({label:i(`printers.model`),value:e.model??`—`}),a.push({label:i(`common.status`),value:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${t?.connected?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${t?.connected?`bg-bambu-green`:`bg-red-400`}`}),t?.connected?i(`printers.status.available`):i(`printers.status.offline`)]})}),t?.state&&a.push({label:i(`printers.state`),value:i({IDLE:`printers.status.idle`,RUNNING:`printers.status.printing`,PAUSE:`printers.status.paused`,FINISH:`printers.status.finished`,FAILED:`printers.status.error`}[t.state]??`printers.status.unknown`)}),a.push({label:i(`printers.ipAddress`),value:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e.ip_address}),(0,K.jsx)(sW,{value:e.ip_address})]})}),a.push({label:i(`printers.serialNumber`),value:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[(0,K.jsx)(`span`,{className:`font-mono truncate`,children:e.serial_number}),(0,K.jsx)(sW,{value:e.serial_number})]})}),t?.wired_network)a.push({label:i(`printers.networkLabel`,`Network`),value:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qo,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-bambu-green`,children:i(`printers.connection.ethernet`,`Ethernet`)})]})});else if(t?.wifi_signal!=null){let e=pT(t.wifi_signal);a.push({label:i(`printers.wifiSignalLabel`),value:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Yl,{className:`w-4 h-4 ${e.color}`}),(0,K.jsx)(`span`,{className:e.color,children:i(e.labelKey)}),(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,t.wifi_signal,` dBm)`]})]})})}return a.push({label:i(`printers.firmware`),value:t?.firmware_version??`—`}),t?.developer_mode!=null&&a.push({label:i(`printers.developerMode`),value:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.developer_mode?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:t.developer_mode?i(`printers.enabled`):i(`printers.disabled`)})}),a.push({label:i(`printers.nozzleCount`),value:e.nozzle_count}),a.push({label:i(`printers.autoArchive`),value:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.auto_archive?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:e.auto_archive?i(`printers.enabled`):i(`printers.disabled`)})}),n!=null&&n>0&&a.push({label:i(`printers.totalPrintHours`),value:`${Math.round(n)}h`}),e.location&&a.push({label:i(`printers.sort.location`),value:e.location}),a.push({label:i(`printers.addedOn`),value:yf(e.created_at)}),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,role:`dialog`,"aria-modal":`true`,onClick:r,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e.name}),(0,K.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-bambu-dark rounded flex-shrink-0`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,K.jsx)(`img`,{src:fT(e.model),alt:e.model??e.name,className:`h-24 object-contain`})}),(0,K.jsx)(`div`,{className:`space-y-0`,children:a.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray whitespace-nowrap`,children:e.label}),(0,K.jsx)(`span`,{className:`text-sm text-white text-right`,children:e.value})]},t))})]})})})}function Cke(e){if(!e||e.length<6)return!1;let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return(.299*t+.587*n+.114*r)/255>.6}function cW({trayColor:e,trayType:t,isEmpty:n,emptyKind:r,slotNumber:i}){let a=r===`reset`?`#3d3d3d`:`#666`;return(0,K.jsx)(`div`,{className:`w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2 flex items-center justify-center`,style:{backgroundColor:e?`#${e}`:t?`#333`:`transparent`,borderColor:n?a:`rgba(255,255,255,0.1)`,borderStyle:n?`dashed`:`solid`},children:(0,K.jsx)(`span`,{className:`text-[6px] font-bold leading-none select-none`,style:{color:e&&Cke(e)?`#000`:`#fff`},children:i})})}var lW=240,uW=320;function dW(e){return(e??.02).toFixed(3)}function fW({side:e}){let{mode:t}=md();return(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded`,style:{backgroundColor:t===`dark`?`#1a4d2e`:`#e7f5e9`,color:`#00ae42`},children:e})}function pW(e,t){if(!e)return``;if(e.includes(`hardened`))return t(`printers.nozzleHardenedSteel`);if(e.includes(`stainless`))return t(`printers.nozzleStainlessSteel`);if(e.includes(`tungsten`))return t(`printers.nozzleTungstenCarbide`);if(e.length>=4){let n=e.slice(2,4);if(n===`00`)return t(`printers.nozzleStainlessSteel`);if(n===`01`)return t(`printers.nozzleHardenedSteel`);if(n===`05`)return t(`printers.nozzleTungstenCarbide`)}return e===`00`?t(`printers.nozzleStainlessSteel`):e===`01`?t(`printers.nozzleHardenedSteel`):e===`05`?t(`printers.nozzleTungstenCarbide`):e.startsWith(`H`)?t(`printers.nozzleHardenedSteel`):e}function mW(e,t){return e?e.startsWith(`HH`)?t(`printers.nozzleHighFlow`):e.startsWith(`HS`)?t(`printers.nozzleStandardFlow`):``:``}function hW({slot:e,index:t,activeStatus:n,filamentName:r,children:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(`top`),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=!e.nozzle_diameter&&!e.nozzle_type,m=e.stat===1;(0,y.useEffect)(()=>{if(o&&u.current&&d.current){let e=u.current.getBoundingClientRect(),t=d.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;nn?l(`bottom`):l(`top`)}},[o]);let h=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!0),80)},g=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!1),100)};(0,y.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let _=Yd(e.filament_color),v=pW(e.nozzle_type,a),b=mW(e.nozzle_type,a);return(0,K.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:h,onMouseLeave:g,children:[i,o&&(0,K.jsxs)(`div`,{ref:d,className:` + `})]}),document.body)]})}function mU({isOpen:e,onClose:t,tagUid:n,trayUuid:r,printerId:i,amsId:a,trayId:o}){let{t:s}=W(),c=no(),{showToast:l}=Td(),[u,d]=(0,y.useState)(``),f=r||n,{data:p,isLoading:m}=q({queryKey:[`unlinked-spools`],queryFn:Q.getUnlinkedSpools,enabled:e}),h=(0,y.useMemo)(()=>p?p.filter(e=>{if(!u)return!0;let t=u.toLowerCase();return e.filament_name&&e.filament_name.toLowerCase().includes(t)||e.filament_vendor&&e.filament_vendor.toLowerCase().includes(t)||e.filament_material&&e.filament_material.toLowerCase().includes(t)||String(e.id).includes(t)}):[],[p,u]),g=J({mutationFn:e=>Q.linkSpool(e,{spoolTag:f,printerId:i,amsId:a,trayId:o}),onSuccess:()=>{c.invalidateQueries({queryKey:[`unlinked-spools`]}),c.invalidateQueries({queryKey:[`linked-spools`]}),c.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),l(s(`spoolman.linkSuccess`),`success`),t()},onError:e=>{l(e.message||s(`spoolman.linkFailed`),`error`)}});return e?(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative bg-bambu-dark-secondary rounded-xl shadow-xl w-full max-w-md mx-4 max-h-[80vh] flex flex-col border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-white/10`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Hc,{className:`w-5 h-5 text-bambu-green`}),s(`spoolman.selectSpool`)]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[`AMS `,a,` T`,o,` · Printer #`,i]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-white/10`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:s(`inventory.searchSpools`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark rounded-lg border border-white/10 text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),(r||n)&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-2 font-mono truncate`,title:r||n,children:[`Tag: `,r||n]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 min-h-0`,children:m?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):h.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8 text-sm`,children:s(`inventory.noSpoolsMatch`)}):h.map(e=>(0,K.jsxs)(`button`,{onClick:()=>g.mutate(e.id),disabled:g.isPending||!f,className:`w-full flex items-center gap-3 p-3 rounded-lg hover:bg-white/5 transition-colors text-left`,children:[(0,K.jsx)(`span`,{className:`w-6 h-6 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.filament_color_hex?`#${e.filament_color_hex}`:`#808080`}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white font-medium truncate`,children:e.filament_name||s(`spoolman.spoolId`)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray truncate`,children:[e.filament_vendor?`${e.filament_vendor} · `:``,e.filament_material||`Unknown`,` · #`,e.id]})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.remaining_weight==null?`—`:`${Math.round(e.remaining_weight)}g`})]},e.id))}),(0,K.jsx)(`div`,{className:`p-4 border-t border-white/10 flex justify-end`,children:(0,K.jsx)($,{variant:`ghost`,onClick:t,children:s(`inventory.cancel`)||`Cancel`})})]})]}):null}function UOe(e,t){if(!t)return!0;let n=t.toLowerCase();return String(e.id).includes(n)||e.material.toLowerCase().includes(n)||(e.brand?.toLowerCase().includes(n)??!1)||(e.color_name?.toLowerCase().includes(n)??!1)||(e.subtype?.toLowerCase().includes(n)??!1)||(e.note?.toLowerCase().includes(n)??!1)||(e.slicer_filament_name?.toLowerCase().includes(n)??!1)||(e.storage_location?.toLowerCase().includes(n)??!1)}function hU(e,t){return t?e.filter(e=>UOe(e,t)):e}function gU({isOpen:e,onClose:t,printerId:n,amsId:r,trayId:i,trayInfo:a,spoolmanEnabled:o}){let{t:s}=W(),c=no(),{showToast:l}=Td(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null);(0,y.useEffect)(()=>{p(null),h(null)},[u]);let[g,_]=(0,y.useState)(``),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(null);(0,y.useEffect)(()=>{e&&d(!1)},[e]);let{data:T,isLoading:E}=q({queryKey:[`inventory-spools`,`assign-modal`],queryFn:()=>Q.getSpools(!0),enabled:e&&!o}),{data:D}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:e}),{data:O}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),enabled:e}),{data:k,isLoading:A}=q({queryKey:[`spoolman-inventory-spools`,`assign-modal`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:e&&!!o}),{data:j}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e&&!!o}),M=(0,y.useMemo)(()=>j?new Set(j.filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i)).map(e=>e.spoolman_spool_id)):new Set,[j,n,r,i]),N=()=>{Q.refreshPrinterStatus(n).catch(()=>{}),c.invalidateQueries({queryKey:[`printerStatus`,n]})},P=J({mutationFn:e=>Q.assignSpool({spool_id:e,printer_id:n,ams_id:r,tray_id:i}),onSuccess:e=>{c.setQueryData([`spool-assignments`],t=>{let a=(t||[]).filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i));return a.push(e),a}),c.invalidateQueries({queryKey:[`spool-assignments`]}),N(),l(s(e.pending_config?`inventory.assignPendingInsert`:`inventory.assignSuccess`),`success`),S(!1),b(null),w(null),t()},onError:e=>{l(`${s(`inventory.assignFailed`)}: ${e.message}`,`error`)}}),F=J({mutationFn:e=>Q.assignSpoolmanSlot({spoolman_spool_id:e,printer_id:n,ams_id:r,tray_id:i}),onSuccess:()=>{c.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),c.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),N(),l(s(`inventory.assignSuccess`),`success`),t()},onError:e=>{l(`${s(`inventory.assignFailed`)}: ${e.message}`,`error`)}}),I=e=>(e??``).trim().toUpperCase(),L=(e,t)=>{let n=I(e),r=I(t);return!n||!r?`none`:n===r?`exact`:r.includes(n)||n.includes(r)?`partial`:`none`},R=e=>e.split(`@`)[0].trim(),z=(e,t)=>{let n=R(I(e)),r=R(I(t));return!n||!r?!1:n===r};if(!e)return null;let B=new Set((D||[]).filter(e=>!(e.printer_id===n&&e.ams_id===r&&e.tray_id===i)).map(e=>e.spool_id)),V=T?.filter(e=>!e.archived_at&&(u||!B.has(e.id))),ee=V;if(!u){let e=R(I(a?.profile)),t=I(a?.material||a?.type);(e||t)&&(ee=ee?.filter(n=>{let r=R(I(n.slicer_filament_name||n.slicer_filament)),i=I(n.material);return e&&r&&r===e?!0:t&&i?i===t||t.includes(i)||i.includes(t):!r&&!i}))}g&&ee&&(ee=hU(ee,g));let te=()=>{if(m!==null){F.mutate(m);return}if(!f)return;let e=T?.find(e=>e.id===f);if(!e){l(s(`inventory.assignFailed`),`error`);return}if(!O?.disable_filament_warnings&&a){let t=a.material||a.type,n=L(e.material,t),r=e.slicer_filament_name||e.slicer_filament,i=a.profile||a.type,o=z(r,i);if(n!==`exact`){let a;a=n===`none`&&!o?`material_profile`:n===`partial`&&!o?`partial_profile`:n===`none`?`material`:`partial`,b(f),w({type:a,spoolMaterial:e.material||``,trayMaterial:t||``,spoolProfile:r||void 0,trayProfile:i||void 0}),S(!0);return}}P.mutate(f)},ne=()=>{v&&(P.mutate(v),S(!1),b(null))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-start sm:items-center justify-center p-4 overflow-y-auto`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-2xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] overflow-hidden flex flex-col my-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:s(`inventory.assignSpool`)})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto`,children:[a&&(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:[s(`inventory.selectSpool`),`:`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.color&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${a.color}`}}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:a.type||s(`ams.emptySlot`)}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,a.location,`)`]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:s(`inventory.searchSpools`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!o&&(E?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):ee&&ee.length>0?(0,K.jsx)(`div`,{className:`max-h-96 overflow-y-auto grid grid-cols-2 sm:grid-cols-3 gap-2`,children:ee.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{p(e.id),h(null)},title:e.note||void 0,className:`p-2.5 rounded-lg border text-left transition-colors ${f===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.color_name||``})]}),e.label_weight&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[Math.max(0,Math.round(e.label_weight-e.weight_used)),` / `,e.label_weight,`g`]})]},e.id))}):V&&V.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:s(`inventory.noAvailableSpools`)}),T&&(0,K.jsxs)(`p`,{className:`text-[10px] mt-2 opacity-60`,children:[T.length,` fetched · `,T.filter(e=>e.archived_at).length,` archived ·`,` `,T.filter(e=>B.has(e.id)).length,` assigned to other slots`]})]}):(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:s(`inventory.noSpoolsMatch`)}),V&&(0,K.jsxs)(`p`,{className:`text-[10px] mt-2 opacity-60`,children:[V.length,` unassigned spools — `,V.length-(ee?.length??0),` filtered by tray match. Try "Show all spools".`]})]})),o&&(0,K.jsx)(K.Fragment,{children:A?(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`})}):k&&k.filter(e=>!e.archived_at&&!M.has(e.id)).length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide pt-1`,children:s(`inventory.spoolmanSpools`)}),(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto grid grid-cols-2 sm:grid-cols-3 gap-2`,children:hU(k.filter(e=>!e.archived_at&&!M.has(e.id)),g).map(e=>(0,K.jsxs)(`button`,{onClick:()=>{h(e.id),p(null)},title:e.note||void 0,className:`p-2.5 rounded-lg border text-left transition-colors ${m===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.color_name||``})]}),e.label_weight&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[Math.max(0,Math.round(e.label_weight-e.weight_used)),` / `,e.label_weight,`g`]})]},`spoolman-${e.id}`))})]}):null})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{id:`disable-filtering-toggle`,type:`checkbox`,checked:u,onChange:()=>d(e=>!e),className:`accent-bambu-green w-4 h-4 rounded focus:ring-0 border-bambu-dark-tertiary`}),(0,K.jsx)(`label`,{htmlFor:`disable-filtering-toggle`,className:`text-xs text-bambu-gray select-none cursor-pointer`,children:s(`inventory.showAllSpools`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:s(`common.cancel`)}),(0,K.jsx)($,{onClick:te,disabled:!f&&m===null||P.isPending||F.isPending,children:P.isPending||F.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),s(`inventory.assigning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pl,{className:`w-4 h-4`}),s(`inventory.assignSpool`)]})})]})]}),P.isError&&(0,K.jsx)(`div`,{className:`mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:P.error.message})]})]}),x&&a&&f&&C&&(()=>{let e=``;return C.type===`material`?e=s(`inventory.assignMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location}):C.type===`partial`?e=s(`inventory.assignPartialMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location}):C.type===`material_profile`?e=`${s(`inventory.assignMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location})}\n\n${s(`inventory.assignProfileMismatchMessage`,{spoolProfile:C.spoolProfile||s(`common.unknown`),trayProfile:C.trayProfile||s(`common.unknown`),location:a.location})}`:C.type===`partial_profile`&&(e=`${s(`inventory.assignPartialMismatchMessage`,{spoolMaterial:C.spoolMaterial,trayMaterial:C.trayMaterial,location:a.location})}\n\n${s(`inventory.assignProfileMismatchMessage`,{spoolProfile:C.spoolProfile||s(`common.unknown`),trayProfile:C.trayProfile||s(`common.unknown`),location:a.location})}`),e=`${e}\n\n${s(`inventory.assignReconfigureNote`)}`,(0,K.jsx)(Ad,{title:s(`inventory.assignMismatchTitle`),message:e,confirmText:s(`inventory.assignMismatchConfirm`),variant:`warning`,overlayZIndex:`z-[110]`,isLoading:P.isPending,onConfirm:ne,onCancel:()=>{P.isPending||(S(!1),b(null),w(null))}})})()]})}var WOe={bambuModelByShortCode:{}},_U={"A1 MINI":[`A1M`]};function vU(e,t){let n=e.toUpperCase(),r=t.toUpperCase();if(n===r)return!0;let i=_U[r];if(i&&i.includes(n))return!0;let a=_U[n];return!!(a&&a.includes(r))}function GOe(e){let t={};for(let[n,r]of Object.entries(e))r in t||(t[r]=n.replace(/^Bambu Lab\s+/,``));return t}function yU(e={}){return{bambuModelByShortCode:GOe(e)}}function bU(e){return e.replace(/\s+/g,``).toLowerCase()}var KOe=`0.4`;function xU(e){let t=e.match(/^(.*?)\s+([\d.]+)\s*nozzle\s*$/i);return t?{stripped:t[1].trim(),nozzle:t[2]}:{stripped:e.trim(),nozzle:null}}function qOe(e){let t=e.indexOf(`@BBL `);if(t<0)return null;let{stripped:n,nozzle:r}=xU(e.slice(t+5).trim());return n?{token:n,nozzle:r}:null}function JOe(e){let t=e.match(/^Bambu Lab\s+(.+)$/i);if(!t)return null;let{stripped:n,nozzle:r}=xU(t[1]);return n?{model:n,nozzle:r}:null}function YOe(e,t,n){let r=qOe(e);if(!r)return`unknown`;let i=n[r.token]??r.token,a=JOe(t);return a?bU(a.model)!==bU(i)&&!vU(r.token,a.model)||a.nozzle!==null&&(r.nozzle??KOe)!==a.nozzle?`mismatch`:`match`:`unknown`}function SU(e,t,n,r){if(!n)return`unknown`;let i=e.compatible_printers;return i&&i.length>0?i.includes(n)?`match`:`mismatch`:YOe(e.name,n,r.bambuModelByShortCode)}var CU=[`PLA`,`PETG`,`ABS`,`TPU`,`ASA`,`PC`,`PA`,`PVA`,`HIPS`,`PA-CF`,`PETG-CF`,`PLA-CF`],wU=[`Bambu`,`PolyLite`,`PolyTerra`,`eSUN`,`Overture`,`Fiberon`,`SUNLU`,`Inland`,`Hatchbox`,`Generic`],TU=`Basic.Matte.Silk.Silk+.Tough.Tough+.HF.High Flow.Engineering.CF.GF.Galaxy.Glow.Marble.Metal.Rainbow.Sparkle.Wood.Translucent.Transparent.Clear.Lite.Pro.Plus.Max.Super.Ultra.Flex.Soft.Hard.Strong.Impact.Heat Resistant.UV Resistant.ESD.Conductive.Magnetic.Gradient.Dual Color.Tri Color.Multicolor`.split(`.`),EU=[{name:`Black`,hex:`000000`},{name:`White`,hex:`FFFFFF`},{name:`Gray`,hex:`808080`},{name:`Red`,hex:`FF0000`},{name:`Orange`,hex:`FFA500`},{name:`Yellow`,hex:`FFFF00`},{name:`Green`,hex:`00AE42`},{name:`Blue`,hex:`0066FF`},{name:`Purple`,hex:`8B00FF`},{name:`Pink`,hex:`FF69B4`},{name:`Brown`,hex:`8B4513`},{name:`Silver`,hex:`C0C0C0`},{name:`Clear`,hex:`00000000`}],XOe=[{name:`Dark Red`,hex:`8B0000`},{name:`Crimson`,hex:`DC143C`},{name:`Coral`,hex:`FF7F50`},{name:`Salmon`,hex:`FA8072`},{name:`Dark Orange`,hex:`FF8C00`},{name:`Peach`,hex:`FFDAB9`},{name:`Gold`,hex:`FFD700`},{name:`Khaki`,hex:`F0E68C`},{name:`Lemon`,hex:`FFF44F`},{name:`Lime`,hex:`32CD32`},{name:`Forest Green`,hex:`228B22`},{name:`Olive`,hex:`808000`},{name:`Mint`,hex:`98FF98`},{name:`Teal`,hex:`008080`},{name:`Navy`,hex:`000080`},{name:`Sky Blue`,hex:`87CEEB`},{name:`Royal Blue`,hex:`4169E1`},{name:`Cyan`,hex:`00FFFF`},{name:`Turquoise`,hex:`40E0D0`},{name:`Violet`,hex:`EE82EE`},{name:`Magenta`,hex:`FF00FF`},{name:`Indigo`,hex:`4B0082`},{name:`Lavender`,hex:`E6E6FA`},{name:`Plum`,hex:`DDA0DD`},{name:`Hot Pink`,hex:`FF69B4`},{name:`Rose`,hex:`FF007F`},{name:`Blush`,hex:`FFB6C1`},{name:`Chocolate`,hex:`D2691E`},{name:`Tan`,hex:`D2B48C`},{name:`Beige`,hex:`F5F5DC`},{name:`Maroon`,hex:`800000`},{name:`Dark Gray`,hex:`404040`},{name:`Light Gray`,hex:`D3D3D3`},{name:`Charcoal`,hex:`36454F`},{name:`Ivory`,hex:`FFFFF0`},{name:`Bambu Green`,hex:`00AE42`},{name:`Jade White`,hex:`E8E8E8`},{name:`Titan Gray`,hex:`5A5A5A`}],DU=[...EU,...XOe],OU=`bambuddy-recent-colors`,ZOe=[{code:`GFL00`,name:`Bambu PLA Basic`,displayName:`Bambu PLA Basic`,isCustom:!1,allCodes:[`GFL00`]},{code:`GFL01`,name:`Bambu PLA Matte`,displayName:`Bambu PLA Matte`,isCustom:!1,allCodes:[`GFL01`]},{code:`GFL05`,name:`Generic PLA`,displayName:`Generic PLA`,isCustom:!1,allCodes:[`GFL05`]},{code:`GFG00`,name:`Bambu PETG Basic`,displayName:`Bambu PETG Basic`,isCustom:!1,allCodes:[`GFG00`]},{code:`GFG05`,name:`Generic PETG`,displayName:`Generic PETG`,isCustom:!1,allCodes:[`GFG05`]},{code:`GFB00`,name:`Bambu ABS Basic`,displayName:`Bambu ABS Basic`,isCustom:!1,allCodes:[`GFB00`]},{code:`GFB05`,name:`Generic ABS`,displayName:`Generic ABS`,isCustom:!1,allCodes:[`GFB05`]},{code:`GFA00`,name:`Bambu ASA Basic`,displayName:`Bambu ASA Basic`,isCustom:!1,allCodes:[`GFA00`]},{code:`GFU00`,name:`Bambu TPU 95A`,displayName:`Bambu TPU 95A`,isCustom:!1,allCodes:[`GFU00`]},{code:`GFU05`,name:`Generic TPU`,displayName:`Generic TPU`,isCustom:!1,allCodes:[`GFU05`]},{code:`GFC00`,name:`Bambu PC Basic`,displayName:`Bambu PC Basic`,isCustom:!1,allCodes:[`GFC00`]},{code:`GFN00`,name:`Bambu PA Basic`,displayName:`Bambu PA Basic`,isCustom:!1,allCodes:[`GFN00`]},{code:`GFN05`,name:`Generic PA`,displayName:`Generic PA`,isCustom:!1,allCodes:[`GFN05`]},{code:`GFS00`,name:`Bambu PLA-CF`,displayName:`Bambu PLA-CF`,isCustom:!1,allCodes:[`GFS00`]},{code:`GFT00`,name:`Bambu PETG-CF`,displayName:`Bambu PETG-CF`,isCustom:!1,allCodes:[`GFT00`]},{code:`GFNC0`,name:`Bambu PA-CF`,displayName:`Bambu PA-CF`,isCustom:!1,allCodes:[`GFNC0`]},{code:`GFV00`,name:`Bambu PVA`,displayName:`Bambu PVA`,isCustom:!1,allCodes:[`GFV00`]}];function kU(e){let t=e.replace(/@.*$/,``).trim();t=t.replace(/\(Custom\)/i,``).trim(),t=t.replace(/^[#*]+\s*/,``).trim();let n=`PLA-CF.PETG-CF.ABS-GF.ASA-CF.PA-CF.PAHT-CF.PA6-CF.PA6-GF.PPA-CF.PPA-GF.PET-CF.PPS-CF.PC-CF.PC-ABS.ABS-GF.PCTG.PETG.PLA.ABS.ASA.PC.PA.TPU.PVA.HIPS.BVOH.PPS.PEEK.PEI`.split(`.`),r=``,i=-1;for(let e of n){let n=t.toUpperCase().indexOf(e.toUpperCase());if(n!==-1){r=e,i=n;break}}let a=``;i>0&&(a=t.substring(0,i).trim(),a=a.replace(/[-_\s]+$/,``));let o=``;i!==-1&&r&&(o=t.substring(i+r.length).trim(),o=o.replace(/^[-_\s]+/,``));let s=``;for(let e of TU)if(o.toLowerCase().includes(e.toLowerCase())){s=e;break}if(!s&&a)for(let e of TU){let t=RegExp(`\\s+${e}$`,`i`);if(t.test(a)){s=e,a=a.replace(t,``).trim();break}}return{brand:a,material:r,variant:s}}function AU(e,t){let n=new Set(wU);for(let t of e){let{brand:e}=kU(t.name);e&&e.length>1&&n.add(e)}if(t)for(let e of t)if(e.filament_vendor&&e.filament_vendor.length>1)n.add(e.filament_vendor);else{let{brand:t}=kU(e.name);t&&t.length>1&&n.add(t)}return Array.from(n).sort((e,t)=>e.localeCompare(t))}function QOe(e){let t=e.filter(e=>e.preset_type===`filament`);return t.length===0?[]:t.map(e=>{let t=String(e.id),n=e.filament_type||t,r=Array.from(new Set([t,n]));return{code:t,name:e.name,displayName:e.name,isCustom:!1,allCodes:r}}).sort((e,t)=>e.displayName.localeCompare(t.displayName))}function jU(e,t,n,r){let i=[],a=[],o=new Set;for(let n of e)if(n.is_custom){let e=n.name.toUpperCase();(t.size===0||Array.from(t).some(t=>e.includes(t))||!e.includes(`@`))&&(i.push({code:n.setting_id,name:n.name,displayName:`${n.name} (Custom)`,isCustom:!0,allCodes:[n.setting_id]}),o.add(n.setting_id))}else a.push({code:n.setting_id,name:n.name,displayName:n.name,isCustom:!1,allCodes:[n.setting_id]}),o.add(n.setting_id);let s=n&&n.length>0?QOe(n):[],c=[];if(r&&r.length>0)for(let e of r){let t=e.filament_id.startsWith(`GF`)?`GFS`+e.filament_id.slice(2):e.filament_id;o.has(e.filament_id)||o.has(t)||c.push({code:e.filament_id,name:e.name,displayName:e.name,isCustom:!1,allCodes:[e.filament_id,t]})}let l=[...i,...a,...s,...c];return l.length===0?ZOe:l.sort((e,t)=>e.displayName.localeCompare(t.displayName))}function MU(e,t){if(!e)return;let n=t.find(t=>t.code===e);if(n||=t.find(t=>t.allCodes.includes(e)),!n){let r=e.toLowerCase();n=t.find(e=>e.code.toLowerCase()===r||e.allCodes.some(e=>e.toLowerCase()===r))}return n}function NU(){try{let e=localStorage.getItem(OU);if(e)return JSON.parse(e)}catch{}return[]}function PU(e,t){let n=[e,...t.filter(t=>t.hex.toUpperCase()!==e.hex.toUpperCase())].slice(0,8);try{localStorage.setItem(OU,JSON.stringify(n))}catch{}return n}function FU(e){if(!e)return``;let t=e.split(`_`)[0];return/^GFS/i.test(t)&&(t=t.slice(0,2)+t.slice(3)),t.toUpperCase()}function IU(e){return!!e&&/^GF[A-Z]99$/i.test(e)}function LU(e,t){if(!t.material)return!1;let n=FU(t.slicer_filament),r=FU(e.filament_id);if(n&&r&&n===r&&!IU(r))return!0;let i=(e.name||``).replace(/^High Flow[_\s]+/i,``).replace(/^Standard[_\s]+/i,``).replace(/^HF[_\s]+/i,``).replace(/^S[_\s]+/i,``).trim(),a=kU(i);return!(a.material.toUpperCase()!==t.material.toUpperCase()||t.brand&&!(a.brand.toLowerCase().includes(t.brand.toLowerCase())||t.brand.toLowerCase().includes(a.brand.toLowerCase()))||t.subtype&&!(a.variant.toLowerCase().includes(t.subtype.toLowerCase())||t.subtype.toLowerCase().includes(a.variant.toLowerCase())||i.toLowerCase().includes(t.subtype.toLowerCase())))}function RU(e){let t=e.includes(`_`)?e.split(`_`)[0]:e;return t.startsWith(`GFS`)?`GF`+t.slice(3):(t.startsWith(`PFUS`)||t.startsWith(`PFSP`),t)}var zU=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`NYLON`,`PVA`,`HIPS`,`PP`,`PET`];function BU(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase(),r=n.match(/\bSUPPORT\s+FOR\s+/);if(r){let e=n.slice(r.index+r[0].length);for(let n of zU)if(RegExp(`\\b${n}\\b`).test(e))return{material:n,brand:t.slice(0,r.index).trim(),variant:`Support`}}for(let e of zU){let r=RegExp(`\\b${e}\\b`,`i`);if(r.test(n)){let n=t.split(r);return{material:e,brand:n[0]?.trim()||``,variant:n[1]?.trim()||``}}}let i=t.split(/\s+/);return i.length>=2?{material:i[1],brand:i[0],variant:i.slice(2).join(` `)}:{material:t,brand:``,variant:``}}function $Oe(e){return!e.startsWith(`GF`)&&!e.startsWith(`P1`)}var eke={white:`FFFFFF`,black:`000000`,red:`FF0000`,green:`00FF00`,blue:`0000FF`,yellow:`FFFF00`,cyan:`00FFFF`,magenta:`FF00FF`,orange:`FFA500`,purple:`800080`,pink:`FFC0CB`,brown:`8B4513`,gray:`808080`,grey:`808080`,"jade white":`FFFEF2`,ivory:`FFFFF0`,beige:`F5F5DC`,cream:`FFFDD0`,silver:`C0C0C0`,gold:`FFD700`,bronze:`CD7F32`,copper:`B87333`,navy:`000080`,teal:`008080`,olive:`808000`,maroon:`800000`,coral:`FF7F50`,salmon:`FA8072`,lime:`32CD32`,mint:`98FF98`,"forest green":`228B22`,"sky blue":`87CEEB`,"royal blue":`4169E1`,turquoise:`40E0D0`,lavender:`E6E6FA`,violet:`EE82EE`,plum:`DDA0DD`,tan:`D2B48C`,chocolate:`D2691E`,charcoal:`36454F`,slate:`708090`,transparent:`000000`,natural:`F5F5DC`,wood:`DEB887`},VU=[{name:`White`,hex:`FFFFFF`},{name:`Black`,hex:`000000`},{name:`Red`,hex:`FF0000`},{name:`Blue`,hex:`0000FF`},{name:`Green`,hex:`00AA00`},{name:`Yellow`,hex:`FFFF00`},{name:`Orange`,hex:`FFA500`},{name:`Gray`,hex:`808080`}],HU=[{name:`Cyan`,hex:`00FFFF`},{name:`Magenta`,hex:`FF00FF`},{name:`Purple`,hex:`800080`},{name:`Pink`,hex:`FFC0CB`},{name:`Brown`,hex:`8B4513`},{name:`Beige`,hex:`F5F5DC`},{name:`Navy`,hex:`000080`},{name:`Teal`,hex:`008080`},{name:`Lime`,hex:`32CD32`},{name:`Gold`,hex:`FFD700`},{name:`Silver`,hex:`C0C0C0`},{name:`Maroon`,hex:`800000`},{name:`Olive`,hex:`808000`},{name:`Coral`,hex:`FF7F50`},{name:`Salmon`,hex:`FA8072`},{name:`Turquoise`,hex:`40E0D0`},{name:`Violet`,hex:`EE82EE`},{name:`Indigo`,hex:`4B0082`},{name:`Chocolate`,hex:`D2691E`},{name:`Tan`,hex:`D2B48C`},{name:`Slate`,hex:`708090`},{name:`Charcoal`,hex:`36454F`},{name:`Ivory`,hex:`FFFFF0`},{name:`Cream`,hex:`FFFDD0`}];function UU(e){return eke[e.toLowerCase().trim()]||null}function tke(e){let t=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`).replace(/\s+/g,`\\s+`);return RegExp(`\\b${t}\\b`,`i`)}function WU(e,t){let n=e.indexOf(`@`);if(n>=0){let r=e.slice(n+1).trim(),i=r.match(/^BBL\s+(.+?)(?:\s+[\d.]+\s*nozzle)?$/i);if(i)return i[1].trim();let a=r.match(/^Bambu Lab\s+(.+?)(?:\s+[\d.]+\s*nozzle)?$/i);if(a){let e=a[1].trim(),n=`Bambu Lab ${e}`;if(t[n])return t[n];let r=n.toLowerCase();for(let[e,n]of Object.entries(t))if(e.toLowerCase()===r)return n;return e}}let r=[],i=new Set;for(let[e,n]of Object.entries(t)){let t=e.replace(/^Bambu Lab\s+/,``),a=t.toLowerCase();i.has(a)||(r.push({token:t,short:n}),i.add(a));let o=n.toLowerCase();i.has(o)||(r.push({token:n,short:n}),i.add(o))}r.sort((e,t)=>t.token.length-e.token.length);for(let{token:t,short:n}of r)if(tke(t).test(e))return n;return null}function GU({isOpen:e,onClose:t,printerId:n,slotInfo:r,nozzleDiameter:i=`0.4`,printerModel:a,onSuccess:o,fullScreen:s}){let{t:c}=W(),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),w=(0,y.useRef)(``),{data:T,isLoading:E,isError:D}=q({queryKey:[`cloudSettings`],queryFn:()=>Q.getCloudSettings(),enabled:e,retry:!1}),{data:O}=q({queryKey:[`orcaCloudProfilesForAmsSlot`],queryFn:()=>Q.orcaCloudListProfiles(),enabled:e,retry:!1}),{data:k,isLoading:A}=q({queryKey:[`localPresets`],queryFn:()=>Q.getLocalPresets(),enabled:e}),{data:j,isLoading:M}=q({queryKey:[`builtinFilaments`],queryFn:()=>Q.getBuiltinFilaments(),enabled:e,staleTime:1/0}),{data:N,isLoading:P}=q({queryKey:[`kprofiles`,n,i],queryFn:()=>Q.getKProfiles(n,i),enabled:e&&!!n}),{data:F}=q({queryKey:[`colorCatalog`],queryFn:()=>Q.getColorCatalog(),enabled:e,staleTime:1/0}),{data:I}=q({queryKey:[`slicerPrinterModels`],queryFn:Q.getSlicerPrinterModels,enabled:e,staleTime:1/0}),L=(0,y.useMemo)(()=>yU(I??{}),[I]),R=(0,y.useMemo)(()=>{if(!a||!I)return null;for(let[e,t]of Object.entries(I))if(t===a)return`${e.startsWith(`Bambu Lab `)?e:`Bambu Lab ${e}`} ${i} nozzle`;return null},[a,I,i]),z=J({mutationFn:async()=>{if(!l)throw Error(`No filament preset selected`);let e=l.startsWith(`local_`),t=l.startsWith(`builtin_`),a=l.startsWith(`orca_`)?l.replace(`orca_`,``):l,o=!e&&!t?O?.filament.find(e=>e.setting_id===a):void 0,s=!!o,c=o??null,u=e?parseInt(l.replace(`local_`,``),10):null,f=t?l.replace(`builtin_`,``):null,m=e?k?.filament.find(e=>e.id===u):null,h=t?j?.find(e=>e.filament_id===f):null,g=!e&&!t&&!s?T?.filament.find(e=>e.setting_id===l):null;if(!e&&!t&&!s&&!g)throw Error(`Selected preset not found`);if(e&&!m)throw Error(`Selected local preset not found`);if(t&&!h)throw Error(`Selected builtin preset not found`);if(s&&!c)throw Error(`Selected Orca Cloud preset not found`);let _=e?m.name:t?h.name:s?c.name:g.name,v=BU(_),y=d?.slot_id??-1,b=p||r.trayColor?.slice(0,6)||`FFFFFF`,x=_.replace(/@.+$/,``).trim(),S,C,w=v.material.toUpperCase(),E={PLA:`GFL99`,"PLA-CF":`GFL98`,"PLA SILK":`GFL96`,"PLA HIGH SPEED":`GFL95`,PETG:`GFG99`,"PETG HF":`GFG96`,"PETG-CF":`GFG98`,PCTG:`GFG97`,ABS:`GFB99`,ASA:`GFB98`,PC:`GFC99`,PA:`GFN99`,"PA-CF":`GFN98`,NYLON:`GFN99`,TPU:`GFU99`,PVA:`GFS99`,HIPS:`GFS98`,PE:`GFP99`,PP:`GFP97`};if(e){let e=(zU.includes(w)?w:m?.filament_type||v.material||``).toUpperCase();S=E[e]||E[e.replace(/[-\s]?CF$/,``)]||E[e.replace(/\+$/,``)]||E[e.split(/[-\s]/)[0]]||``,C=``}else if(s){let e=(zU.includes(w)?w:v.material||``).toUpperCase();S=E[e]||E[e.replace(/[-\s]?CF$/,``)]||E[e.replace(/\+$/,``)]||E[e.split(/[-\s]/)[0]]||``,C=``}else if(t)S=f,C=``;else if(S=RU(l),C=l,!l.startsWith(`GFS`))try{let e=await Q.getCloudSettingDetail(l);e.filament_id&&(S=e.filament_id)}catch(e){console.warn(`Failed to fetch preset detail for filament_id:`,e)}let D=e&&m?.nozzle_temp_min?m.nozzle_temp_min:190,A=e&&m?.nozzle_temp_max?m.nozzle_temp_max:230;if(!e||t||s||!m?.nozzle_temp_min&&!m?.nozzle_temp_max){let t=(e?zU.includes(w)?w:m?.filament_type||v.material||``:v.material).toUpperCase();t.includes(`PLA`)?(D=190,A=230):t.includes(`PETG`)?(D=220,A=260):t.includes(`ABS`)||t.includes(`ASA`)?(D=240,A=280):t.includes(`TPU`)?(D=200,A=240):t===`PCTG`?(D=220,A=260):t.includes(`PC`)?(D=260,A=300):(t.includes(`PA`)||t.includes(`NYLON`))&&(D=250,A=290)}let M=d?.k_value?parseFloat(d.k_value):0,N=e?zU.includes(w)?w:m?.filament_type||v.material||`PLA`:s&&zU.includes(w)?w:v.material||`PLA`,P=await Q.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:S,tray_type:N,tray_sub_brands:x,tray_color:b+`FF`,nozzle_temp_min:D,nozzle_temp_max:A,cali_idx:y,nozzle_diameter:i,setting_id:C,kprofile_filament_id:d?.filament_id,kprofile_setting_id:d?.setting_id||void 0,k_value:M}),F=e?`local_${u}`:t?`builtin_${f}`:l,I=e?`local`:t?`builtin`:s?`orca_cloud`:`cloud`;try{await Q.saveSlotPreset(n,r.amsId,r.trayId,F,x,I)}catch(e){console.warn(`Failed to save slot preset mapping:`,e)}return P},onSuccess:()=>{x(!0),o?.(),setTimeout(()=>{x(!1),t()},1500)}}),B=J({mutationFn:async()=>Q.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{x(!0),o?.(),setTimeout(()=>{x(!1),t()},1500)}}),V=(0,y.useMemo)(()=>{let e=_.toLowerCase(),t=[],n=new Set,i=r.savedPresetId,o=r.trayInfoIdx;if(O?.filament)for(let r of O.filament){let i=`orca_${r.setting_id}`;if(n.add(r.setting_id),n.add(i),!(e&&!r.name.toLowerCase().includes(e))){if(a){let e=WU(r.name,I??{});if(e&&!vU(e,a))continue}t.push({id:i,name:r.name,source:`orca_cloud`,isUser:!0})}}if(T?.filament)for(let r of T.filament){if(n.has(r.setting_id))continue;n.add(r.setting_id);let s=i===r.setting_id||o&&(r.setting_id===o||RU(r.setting_id)===o);if(!(e&&!r.name.toLowerCase().includes(e))){if(!s&&a){let e=WU(r.name,I??{});if(e&&!vU(e,a))continue}t.push({id:r.setting_id,name:r.name,source:`cloud`,isUser:$Oe(r.setting_id)})}}if(k?.filament){let n=r.savedPresetId;for(let r of k.filament){let i=`local_${r.id}`;if(!(e&&!r.name.toLowerCase().includes(e))){if(n!==i&&R){let e=null;if(r.compatible_printers)try{let t=JSON.parse(r.compatible_printers);Array.isArray(t)&&(e=t.filter(e=>typeof e==`string`))}catch{e=null}if(SU({name:r.name,compatible_printers:e},`filament`,R,L)===`mismatch`)continue}t.push({id:i,name:r.name,source:`local`,isUser:!1})}}}if(j)for(let r of j){if(n.has(r.filament_id))continue;let i=r.filament_id.startsWith(`GF`)?`GFS`+r.filament_id.slice(2):r.filament_id;n.has(i)||(!e||r.name.toLowerCase().includes(e))&&t.push({id:`builtin_${r.filament_id}`,name:r.name,source:`builtin`,isUser:!1})}return t.sort((e,t)=>{let n={local:0,orca_cloud:1,cloud:2,builtin:3};return e.source===t.source?e.isUser&&!t.isUser?-1:!e.isUser&&t.isUser?1:e.name.localeCompare(t.name):n[e.source]-n[t.source]})},[O?.filament,T?.filament,k?.filament,j,_,a,r.savedPresetId,r.trayInfoIdx,R,L,I]),ee=(0,y.useMemo)(()=>{if(!l)return null;let e=null,t=``;if(l.startsWith(`local_`)){let t=parseInt(l.replace(`local_`,``),10);e=k?.filament.find(e=>e.id===t)?.name||null}else if(l.startsWith(`builtin_`)){let n=l.replace(`builtin_`,``);e=j?.find(e=>e.filament_id===n)?.name||null,t=FU(n)}else{let n=l.startsWith(`orca_`)?l.replace(`orca_`,``):l,r=O?.filament.find(e=>e.setting_id===n);if(r)e=r.name;else if(T?.filament){let n=T.filament.find(e=>e.setting_id===l);e=n?.name||null,n&&(t=FU(n.setting_id))}}if(!e)return null;let n=e.replace(/@.+$/,``).trim();n.startsWith(`# `)&&(n=n.slice(2).trim());let r=BU(n);return{fullName:n,material:r.material,brand:r.brand,filamentId:t}},[l,T?.filament,k?.filament,j,O?.filament]),te=ee?.fullName||``,ne=(0,y.useMemo)(()=>{if(!F||!ee)return[];let{fullName:e,brand:t}=ee,n=e.replace(/^(Bambu\s*(Lab)?|eSUN|Polymaker|Overture|Sunlu|Hatchbox)\s*/i,``).trim();return F.filter(e=>{let r=(e.material||``).toUpperCase(),i=e.manufacturer.toUpperCase();if(!(r===n.toUpperCase()||r.includes(n.toUpperCase())||n.toUpperCase().includes(r)))return!1;if(t){let e=t.toUpperCase();if(!i.includes(e)&&!e.includes(i))return!1}return!0})},[F,ee]),re=(0,y.useMemo)(()=>{if(!N?.profiles)return[];if(!ee){let e=r.caliIdx;if(e!=null&&e>0){let t=N.profiles.find(t=>t.slot_id===e&&(r.extruderId===void 0||t.extruder_id===r.extruderId));if(t)return[t]}return[]}let{fullName:e,material:t,brand:n,filamentId:i}=ee,a=e.toUpperCase(),o=t.toUpperCase(),s=n.toUpperCase(),c=i;if(!o||o.length<2)return[];let l=N.profiles.filter(e=>{if(c){let t=FU(e.filament_id);if(t&&t===c&&!IU(t))return!0}let t=e.name.toUpperCase();if(s)return!(!t.includes(s)||!t.includes(o));if(t.includes(a)||t.includes(o))return!0;let n={NYLON:[`PA`,`PA-CF`,`PA6`],PA:[`NYLON`]}[o]||[];for(let e of n)if(t.includes(e))return!0;return!1}),u=new Map;for(let e of l){let t=`${e.name}|${e.k_value}`,n=u.get(t);n?r.extruderId!==void 0&&e.extruder_id===r.extruderId&&n.extruder_id!==r.extruderId&&u.set(t,e):u.set(t,e)}let d=Array.from(u.values()),f=r.caliIdx;if(f!=null&&f>0&&!d.some(e=>e.slot_id===f)){let e=N.profiles.find(e=>e.slot_id===f&&(r.extruderId===void 0||e.extruder_id===r.extruderId));e&&d.unshift(e)}return d},[N?.profiles,ee,r.extruderId,r.caliIdx]);(0,y.useEffect)(()=>{if(e){if(r.savedPresetId)u(r.savedPresetId);else if(r.trayInfoIdx&&T?.filament){let e=T.filament.find(e=>e.setting_id===r.trayInfoIdx);e||=T.filament.find(e=>RU(e.setting_id)===r.trayInfoIdx),e&&u(e.setting_id)}else if(r.trayInfoIdx&&j?.length){let e=r.trayInfoIdx,t=j.find(t=>t.filament_id===e);t&&u(`builtin_${t.filament_id}`)}if(r.trayColor){let e=r.trayColor.slice(0,6);e&&m(e)}}else u(``),f(null),m(``),g(``),v(``),x(!1),w.current=``},[e,r.savedPresetId,r.trayInfoIdx,r.trayColor,T?.filament,j]),(0,y.useEffect)(()=>{if(re.length>0){if(r.caliIdx!=null&&r.caliIdx>0){let e=re.find(e=>e.slot_id===r.caliIdx);if(e){f(e);return}}f(re[0])}else f(null)},[l,re,r.caliIdx]);let ie=(0,y.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,y.useEffect)(()=>{if(e)return document.addEventListener(`keydown`,ie),()=>document.removeEventListener(`keydown`,ie)},[e,ie]);let H=E&&!D||A||M||P;if((0,y.useEffect)(()=>{if(!H&&l&&l!==w.current){let e=requestAnimationFrame(()=>{let e=document.querySelector(`[class*="fixed inset-0 z-50"]`)?.querySelector(`[data-preset-id="${CSS.escape(l)}"]`);e&&(w.current=l,e.scrollIntoView({block:`nearest`}))});return()=>cancelAnimationFrame(e)}},[l,H]),!e)return null;let ae=l&&!z.isPending,oe=p||r.trayColor?.slice(0,6)||`FFFFFF`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex ${s?``:`items-center justify-center`}`,children:[!s&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:s?`relative w-full h-full bg-bambu-dark-secondary flex flex-col`:`relative w-full max-w-lg mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-5 h-5 text-bambu-blue`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:c(`configureAmsSlot.title`)}),s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 ml-4 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white/30`,children:`|`}),r.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),(0,K.jsx)(`span`,{className:`text-white/70`,children:c(`configureAmsSlot.slotLabel`,{ams:Af(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&(0,K.jsxs)(`span`,{children:[`(`,r.traySubBrands,`)`]})]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 overflow-y-auto ${s?`flex-1 min-h-0`:`space-y-4 max-h-[60vh]`}`,children:[b&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl`,children:(0,K.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,K.jsx)(ms,{className:`w-16 h-16 text-bambu-green mx-auto`}),(0,K.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:c(`configureAmsSlot.slotConfigured`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:c(`configureAmsSlot.settingsSentToPrinter`)})]})}),!s&&(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:c(`configureAmsSlot.configuringSlot`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:c(`configureAmsSlot.slotLabel`,{ams:Af(r.amsId,r.trayCount),slot:r.trayId+1})}),r.traySubBrands&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,r.traySubBrands,`)`]})]})]}),H?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):s?(0,K.jsxs)(`div`,{className:`flex gap-4 h-full`,children:[(0,K.jsxs)(`div`,{className:`w-1/2 flex flex-col min-h-0`,children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.filamentProfile`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.searchPresets`),value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2 shrink-0`}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto space-y-1`,children:V.length===0?(0,K.jsx)(`p`,{className:`text-center py-4 text-bambu-gray`,children:T?.filament?.length===0&&!k?.filament?.length?c(`configureAmsSlot.noPresetsAvailable`):c(`configureAmsSlot.noMatchingPresets`)}):V.map(e=>(0,K.jsx)(`button`,{"data-preset-id":e.id,onClick:()=>u(e.id),className:`group w-full p-2 rounded-lg border text-left transition-colors ${l===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate group-hover:whitespace-normal group-hover:break-all`,title:e.name,children:e.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.source===`local`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400`,children:c(`profiles.localProfiles.badge`)}),e.source===`orca_cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-400`,children:c(`configureAmsSlot.orcaCloud`)}),e.source===`cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue`,children:c(`configureAmsSlot.bambuCloud`)}),e.source===`builtin`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400`,children:c(`configureAmsSlot.builtin`)})]})]})},e.id))})]}),(0,K.jsxs)(`div`,{className:`w-1/2 flex flex-col gap-4 min-h-0 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.kProfileLabel`),te&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-blue`,children:c(`configureAmsSlot.filteringFor`,{material:te})})]}),re.length>0?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:d?.name||``,onChange:e=>{f(re.find(t=>t.name===e.target.value)||null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:c(`configureAmsSlot.noKProfile`)}),re.map(e=>(0,K.jsxs)(`option`,{value:e.name,children:[e.name,` (K=`,e.k_value,`)`]},`${e.name}-${e.extruder_id}`))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}):l?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:c(`configureAmsSlot.noMatchingKProfiles`)}):(0,K.jsx)(`span`,{className:`inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30`,children:c(`configureAmsSlot.selectFilamentFirst`)}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-green mt-1`,children:c(`configureAmsSlot.kFromCalibration`,{value:d.k_value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:c(`configureAmsSlot.customColorLabel`)}),ne.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1.5`,children:c(`configureAmsSlot.presetColors`,{name:ee?.fullName})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ne.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{m(e.hex_color.replace(`#`,``).toUpperCase()),g(e.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===e.hex_color.replace(`#`,``).toUpperCase()?`border-bambu-green scale-105`:`border-white/20 hover:border-white/40`}`,title:e.color_name,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.hex_color}}),(0,K.jsx)(`span`,{className:`text-xs text-white/80 whitespace-nowrap`,children:e.color_name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[VU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex)),(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs`,title:c(S?`configureAmsSlot.showLessColors`:`configureAmsSlot.showMoreColors`),children:S?`−`:`+`})]}),S&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:HU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex))}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0`,style:{backgroundColor:`#${oe}`}}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.colorPlaceholder`),value:h,onChange:e=>{let t=e.target.value;g(t);let n=UU(t);if(n)m(n);else{let e=t.replace(/[^0-9A-Fa-f]/g,``).toUpperCase();e.length===6?m(e):e.length===3&&m(e.split(``).map(e=>e+e).join(``))}},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm`}),p&&(0,K.jsx)(`button`,{onClick:()=>{m(``),g(``)},className:`px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded`,title:c(`configureAmsSlot.clearCustomColor`),children:c(`configureAmsSlot.clear`)})]}),p&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5`,children:c(`configureAmsSlot.hexLabel`,{hex:p})})]})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.filamentProfile`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.searchPresets`),value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none mb-2`}),(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:V.length===0?(0,K.jsx)(`p`,{className:`text-center py-4 text-bambu-gray`,children:T?.filament?.length===0&&!k?.filament?.length?c(`configureAmsSlot.noPresetsAvailable`):c(`configureAmsSlot.noMatchingPresets`)}):V.map(e=>(0,K.jsx)(`button`,{"data-preset-id":e.id,onClick:()=>u(e.id),className:`group w-full p-2 rounded-lg border text-left transition-colors ${l===e.id?`bg-bambu-green/20 border-bambu-green`:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate group-hover:whitespace-normal group-hover:break-all`,title:e.name,children:e.name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[e.source===`local`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-green-500/20 text-green-400`,children:c(`profiles.localProfiles.badge`)}),e.source===`orca_cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-purple-500/20 text-purple-400`,children:c(`configureAmsSlot.orcaCloud`)}),e.source===`cloud`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue`,children:c(`configureAmsSlot.bambuCloud`)}),e.source===`builtin`&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400`,children:c(`configureAmsSlot.builtin`)})]})]})},e.id))})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:[c(`configureAmsSlot.kProfileLabel`),te&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-blue`,children:c(`configureAmsSlot.filteringFor`,{material:te})})]}),re.length>0?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:d?.name||``,onChange:e=>{f(re.find(t=>t.name===e.target.value)||null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:c(`configureAmsSlot.noKProfile`)}),re.map(e=>(0,K.jsxs)(`option`,{value:e.name,children:[e.name,` (K=`,e.k_value,`)`]},`${e.name}-${e.extruder_id}`))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}):l?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:c(`configureAmsSlot.noMatchingKProfiles`)}):(0,K.jsx)(`span`,{className:`inline-block text-xs px-2 py-1 rounded bg-amber-500/20 text-amber-400 border border-amber-500/30`,children:c(`configureAmsSlot.selectFilamentFirst`)}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-green mt-1`,children:c(`configureAmsSlot.kFromCalibration`,{value:d.k_value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:c(`configureAmsSlot.customColorLabel`)}),ne.length>0&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1.5`,children:c(`configureAmsSlot.presetColors`,{name:ee?.fullName})}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:ne.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{m(e.hex_color.replace(`#`,``).toUpperCase()),g(e.color_name)},className:`h-7 px-2 rounded-md border-2 transition-all flex items-center gap-1.5 ${p===e.hex_color.replace(`#`,``).toUpperCase()?`border-bambu-green scale-105`:`border-white/20 hover:border-white/40`}`,title:e.color_name,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:e.hex_color}}),(0,K.jsx)(`span`,{className:`text-xs text-white/80 whitespace-nowrap`,children:e.color_name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:[VU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex)),(0,K.jsx)(`button`,{onClick:()=>C(!S),className:`w-7 h-7 rounded-md border-2 border-white/20 hover:border-white/40 flex items-center justify-center text-white/60 hover:text-white/80 transition-all text-xs`,title:c(S?`configureAmsSlot.showLessColors`:`configureAmsSlot.showMoreColors`),children:S?`−`:`+`})]}),S&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:HU.map(e=>(0,K.jsx)(`button`,{onClick:()=>{m(e.hex),g(e.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${p===e.hex?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:`#${e.hex}`},title:e.name},e.hex))}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0`,style:{backgroundColor:`#${oe}`}}),(0,K.jsx)(`input`,{type:`text`,placeholder:c(`configureAmsSlot.colorPlaceholder`),value:h,onChange:e=>{let t=e.target.value;g(t);let n=UU(t);if(n)m(n);else{let e=t.replace(/[^0-9A-Fa-f]/g,``).toUpperCase();e.length===6?m(e):e.length===3&&m(e.split(``).map(e=>e+e).join(``))}},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder:text-bambu-gray focus:border-bambu-green focus:outline-none text-sm`}),p&&(0,K.jsx)(`button`,{onClick:()=>{m(``),g(``)},className:`px-2 py-1 text-xs text-bambu-gray hover:text-white bg-bambu-dark-tertiary rounded`,title:c(`configureAmsSlot.clearCustomColor`),children:c(`configureAmsSlot.clear`)})]}),p&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5`,children:c(`configureAmsSlot.hexLabel`,{hex:p})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between p-4 border-t border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>B.mutate(),disabled:B.isPending||z.isPending,className:`text-red-400 hover:text-red-300 hover:bg-red-500/10`,children:B.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),c(`configureAmsSlot.resetting`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),c(`configureAmsSlot.resetSlot`)]})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:c(`configureAmsSlot.cancel`)}),(0,K.jsx)($,{onClick:()=>z.mutate(),disabled:!ae,children:z.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),c(`configureAmsSlot.configuring`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),c(`configureAmsSlot.configureSlot`)]})})]})]}),(z.isError||B.isError)&&(0,K.jsx)(`div`,{className:`mx-4 mb-4 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:z.error?.message||B.error?.message})]})]})}function KU({className:e=`w-4 h-4`}){return(0,K.jsx)(`svg`,{viewBox:`0 0 1945 1370`,fill:`none`,className:e,"aria-hidden":`true`,children:(0,K.jsxs)(`g`,{transform:`translate(-754.293 -471.685)`,children:[(0,K.jsxs)(`g`,{transform:`translate(0.18191 255.976)`,children:[(0,K.jsx)(`g`,{transform:`matrix(1.05469 0 0 0.241063 -153.484 1120.2)`,children:(0,K.jsx)(`rect`,{x:`922.048`,y:`1195.15`,width:`1721.5`,height:`470.135`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`168.84`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,K.jsx)(`g`,{transform:`matrix(0.983656 0 0 1.0767 -62.2035 141.539)`,children:(0,K.jsx)(`path`,{d:`M2741.42,1175.93L895.832,1175.93L1125.16,621.902L2512.09,621.902L2741.42,1175.93Z`,fill:`currentColor`,fillOpacity:`0.05`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`125.26`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,K.jsx)(`g`,{transform:`translate(21.1916 0.684817)`,children:(0,K.jsx)(`path`,{d:`M1981.31,567.518C1954.86,567.518 1933.39,546.047 1933.39,519.601C1933.39,493.156 1954.86,471.685 1981.31,471.685L2146.61,471.685C2173.07,471.685 2194.53,493.138 2194.53,519.601L2194.53,688.741C2194.53,715.187 2173.05,736.658 2146.61,736.658C2120.16,736.658 2098.69,715.187 2098.69,688.741L2098.69,567.518L1981.31,567.518ZM2098.69,1252.54C2098.69,1226.1 2120.16,1204.62 2146.61,1204.62C2173.05,1204.62 2194.53,1226.1 2194.53,1252.54L2194.53,1421.68C2194.53,1448.14 2173.07,1469.6 2146.61,1469.6L1981.31,1469.6C1954.86,1469.6 1933.39,1448.13 1933.39,1421.68C1933.39,1395.24 1954.86,1373.76 1981.31,1373.76L2098.69,1373.76L2098.69,1252.54ZM1430.29,1373.76C1456.74,1373.76 1478.21,1395.24 1478.21,1421.68C1478.21,1448.13 1456.74,1469.6 1430.29,1469.6L1264.99,1469.6C1238.53,1469.6 1217.07,1448.14 1217.07,1421.68L1217.07,1252.54C1217.07,1226.1 1238.55,1204.62 1264.99,1204.62C1291.44,1204.62 1312.91,1226.1 1312.91,1252.54L1312.91,1373.76L1430.29,1373.76ZM1312.91,688.741C1312.91,715.187 1291.44,736.658 1264.99,736.658C1238.55,736.658 1217.07,715.187 1217.07,688.741L1217.07,519.601C1217.07,493.138 1238.53,471.685 1264.99,471.685L1430.29,471.685C1456.74,471.685 1478.21,493.156 1478.21,519.601C1478.21,546.047 1456.74,567.518 1430.29,567.518L1312.91,567.518L1312.91,688.741Z`,fill:`currentColor`,fillOpacity:`0.99`})})]})})}function qU({folderId:e,onClose:t,onUploadComplete:n,onFileUploaded:r,autoUpload:i,validateFile:a,accept:o,initialFiles:s}){let{t:c}=W(),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!0),[S,C]=(0,y.useState)(null),w=(0,y.useRef)(null),T=e=>{e.preventDefault(),f(!0)},E=e=>{e.preventDefault(),f(!1)},D=e=>{e.preventDefault(),f(!1),j(Array.from(e.dataTransfer.files))},O=e=>{e.target.files&&j(Array.from(e.target.files))},k=(e,t)=>{u(n=>n.map(n=>n.file===e?{...n,...t}:n))},A=async i=>{m(!0);for(let t of i)if(t.status===`pending`){k(t.file,{status:`uploading`});try{if(t.isZip){let n=await Q.extractZipFile(t.file,e,h,_,b);k(t.file,{status:n.errors.length>0&&n.extracted===0?`error`:`success`,extractedCount:n.extracted,error:n.errors.length>0?c(`fileManager.zipFilesFailed`,`{{count}} files failed`,{count:n.errors.length}):void 0})}else{let n=await Q.uploadLibraryFile(t.file,e,b);k(t.file,{status:`success`});let i=r?.(n);if(i){C(i),u([]),m(!1);return}}}catch(e){k(t.file,{status:`error`,error:e instanceof Error?e.message:c(`fileManager.uploadFailed`,`Upload failed`)})}}m(!1),n(),u(e=>(e.some(e=>e.status===`error`)||t(),e))},j=e=>{if(C(null),a)for(let t of e){let e=a(t);if(e){C(e);return}}let t=e.map(e=>({file:e,status:`pending`,isZip:e.name.toLowerCase().endsWith(`.zip`),is3mf:e.name.toLowerCase().endsWith(`.3mf`)}));u(e=>[...e,...t]),i&&e.length>0&&A(t)},M=e=>{u(t=>t.filter((t,n)=>n!==e))},N=(0,y.useRef)(!1);(0,y.useEffect)(()=>{N.current||!s||s.length===0||(N.current=!0,j(s))},[]);let P=l.some(e=>e.isZip&&e.status===`pending`),F=l.some(e=>e.file.name.toLowerCase().endsWith(`.stl`)&&e.status===`pending`),I=l.some(e=>e.is3mf&&e.status===`pending`),L=l.filter(e=>e.status===`pending`).length,R=l.length>0&&L===0&&!p;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:c(`fileManager.uploadFiles`)}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{onDragOver:T,onDragLeave:E,onDrop:D,onClick:()=>w.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${d?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Du,{className:`w-10 h-10 mx-auto mb-3 ${d?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:c(d?`fileManager.dropFilesHere`:`fileManager.dragDropFiles`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:c(`fileManager.orClickToBrowse`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-2`,children:c(`fileManager.allFileTypesSupported`)})]}),(0,K.jsx)(`input`,{ref:w,type:`file`,multiple:!0,accept:o,className:`hidden`,onChange:O}),P&&(0,K.jsx)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Oo,{className:`w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-blue-300 font-medium`,children:c(`fileManager.zipFilesDetected`)}),(0,K.jsx)(`p`,{className:`text-xs text-blue-300/70 mt-1`,children:c(`fileManager.zipExtractOptions`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.preserveZipStructure`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.createFolderFromZip`)})]})]})]})}),I&&(0,K.jsx)(`div`,{className:`p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-purple-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-purple-300 font-medium`,children:c(`fileManager.threemfDetected`)}),(0,K.jsx)(`p`,{className:`text-xs text-purple-300/70 mt-1`,children:c(`fileManager.threemfExtractionInfo`)})]})]})}),(F||P)&&(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Mc,{className:`w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-green font-medium`,children:c(`fileManager.stlThumbnailGeneration`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-green/70 mt-1`,children:c(P&&!F?`fileManager.zipMayContainStl`:`fileManager.thumbnailsCanBeGenerated`)}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:c(`fileManager.generateThumbnailsForStl`)})]})]})]})}),l.length>0&&(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-2`,children:l.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 bg-bambu-dark rounded-lg`,children:[e.isZip?(0,K.jsx)(Oo,{className:`w-4 h-4 text-blue-400 flex-shrink-0`}):(0,K.jsx)(rc,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.file.name}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[(e.file.size/1024/1024).toFixed(2),` MB`,e.isZip&&e.status===`pending`&&(0,K.jsxs)(`span`,{className:`text-blue-400 ml-2`,children:[`• `,c(`fileManager.willBeExtracted`)]}),e.extractedCount!==void 0&&(0,K.jsxs)(`span`,{className:`text-green-400 ml-2`,children:[`• `,c(`fileManager.filesExtracted`,{count:e.extractedCount})]})]}),e.status===`error`&&e.error&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1 break-words`,children:e.error})]}),e.status===`pending`&&(0,K.jsx)(`button`,{onClick:()=>M(t),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray`})}),e.status===`uploading`&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`}),e.status===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-green-500`}),e.status===`error`&&(0,K.jsx)(`span`,{title:e.error,children:(0,K.jsx)(ys,{className:`w-4 h-4 text-red-500`})})]},t))}),S&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-sm text-red-300`,children:S})]})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:c(`common.cancel`)}),!R&&(0,K.jsx)($,{onClick:()=>A(l),disabled:L===0||p,children:p?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),c(`fileManager.uploading`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),c(`common.upload`),` `,L>0?`(${L})`:``]})})]})]})})}function JU(e){let t=[],n=e?.ams_extruder_map,r=!!e?.nozzles?.[1]?.nozzle_diameter||n&&Object.keys(n).length>0||(e?.vt_tray?.length??0)>1;e?.ams?.forEach(e=>{let r=e.tray.length===1;e.tray.forEach(i=>{if(i.tray_type){let a=Of(i.tray_color);t.push({type:i.tray_type,color:a,colorName:Gd(a),amsId:e.id,trayId:i.id,isHt:r,isExternal:!1,label:If(e.id,i.id,r,!1),globalTrayId:Lf(e.id,i.id,!1),trayInfoIdx:i.tray_info_idx||``,traySubBrands:i.tray_sub_brands||``,extruderId:n?.[String(e.id)],remain:i.remain??-1})}})});for(let n of e?.vt_tray??[])if(n.tray_type){let i=Of(n.tray_color),a=n.id??254,o=(e?.vt_tray?.length??0)>1;t.push({type:n.tray_type,color:i,colorName:Gd(i),amsId:-1,trayId:a-254,isHt:!1,isExternal:!0,label:o?a===254?`Ext-L`:`Ext-R`:`External`,globalTrayId:a,trayInfoIdx:n.tray_info_idx||``,traySubBrands:n.tray_sub_brands||``,extruderId:r?255-a:void 0,remain:n.remain??-1})}return t}function YU(e,t,n,r){if(!e?.filaments||e.filaments.length===0)return;let i=JU(t);if(i.length===0)return;let a=t?.fila_switch?.installed===!0,o=new Set,s=e.filaments.map(e=>{let t=e.tray_info_idx||``,s=i.filter(e=>!o.has(e.globalTrayId));e.nozzle_id!=null&&!a&&(s=s.filter(t=>t.extruderId===e.nozzle_id)),n&&(s=[...s].sort((e,t)=>Kf(Gf(e,r),Gf(t,r))));let c,l,u,d;if(t){let i=s.filter(e=>e.trayInfoIdx===t);i.length===1?c=i[0]:i.length>1&&(n&&i.sort((e,t)=>Kf(Gf(e,r),Gf(t,r))),l=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),l||(u=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!l&&!u&&(d=i.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())))}!c&&!l&&!u&&!d&&(l=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),l||(u=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!l&&!u&&(d=s.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())));let f=c||l||u||d||void 0;return f&&o.add(f.globalTrayId),{slot_id:e.slot_id,globalTrayId:f?.globalTrayId??-1}}),c=Math.max(...s.map(e=>e.slot_id||0));if(c<=0)return;let l=Array(c).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(l[e.slot_id-1]=e.globalTrayId)}),l}function nke(e){return(0,y.useMemo)(()=>JU(e),[e])}function XU(e,t,n,r,i){let a=nke(t),o=t?.fila_switch?.installed===!0,s=(0,y.useMemo)(()=>{if(!e?.filaments||e.filaments.length===0)return[];let t=new Set(Object.values(n));return e.filaments.map(e=>{let s=e.slot_id||0;if(s>0&&n[s]!==void 0){let t=n[s],r=a.find(e=>e.globalTrayId===t);if(r){let t=r.type?.toUpperCase()===e.type?.toUpperCase(),n=kf(r.color)===kf(e.color)||Ff(r.color,e.color),i;return i=t&&n?`match`:t?`type_only`:`mismatch`,{...e,loaded:r,hasFilament:!0,typeMatch:t,colorMatch:n,status:i,isManual:!0}}}let c=e.tray_info_idx||``,l=a.filter(e=>!t.has(e.globalTrayId));e.nozzle_id!=null&&!o&&(l=l.filter(t=>t.extruderId===e.nozzle_id)),r&&(l=[...l].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let u,d,f,p;if(c){let t=l.filter(e=>e.trayInfoIdx===c);t.length===1?u=t[0]:t.length>1&&(r&&t.sort((e,t)=>Kf(Gf(e,i),Gf(t,i))),d=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),d||(f=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!d&&!f&&(p=t.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())))}!u&&!d&&!f&&!p&&(d=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&kf(t.color)===kf(e.color)),d||(f=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase()&&Ff(t.color,e.color))),!d&&!f&&(p=l.find(t=>t.type?.toUpperCase()===e.type?.toUpperCase())));let m=u||d||f||p||void 0;m&&t.add(m.globalTrayId);let h=!!m,g=h,_=!!u||!!d||!!f,v;return v=u||d||f?`match`:p?`type_only`:`mismatch`,{...e,loaded:m,hasFilament:h,typeMatch:g,colorMatch:_,status:v,isManual:!1}})},[e,a,n,r,o,i]);return{loadedFilaments:a,filamentComparison:s,amsMapping:(0,y.useMemo)(()=>{if(s.length===0)return;let e=Math.max(...s.map(e=>e.slot_id||0));if(e<=0)return;let t=Array(e).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(t[e.slot_id-1]=e.loaded?.globalTrayId??-1)}),t},[s]),hasTypeMismatch:s.some(e=>e.status===`mismatch`),hasColorMismatch:s.some(e=>e.status===`type_only`)}}function rke(e,t,n,r,i){if(!e||e.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:`full`};let a=0,o=0,s=0,c=new Set(Object.values(n));for(let l of e){let e=l.slot_id||0;if(e>0&&n[e]!==void 0){let r=n[e],i=t.find(e=>e.globalTrayId===r);if(i){let e=i.type?.toUpperCase()===l.type?.toUpperCase(),t=kf(i.color)===kf(l.color)||Ff(i.color,l.color);e&&t?a++:e?o++:s++;continue}}let u=t.filter(e=>!c.has(e.globalTrayId));if(l.nozzle_id!=null){let e=u.filter(e=>e.extruderId===l.nozzle_id);e.length>0&&(u=e)}r&&(u=[...u].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let d=u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()&&kf(e.color)===kf(l.color)),f=d?void 0:u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()&&Ff(e.color,l.color)),p=d||f?void 0:u.find(e=>e.type?.toUpperCase()===l.type?.toUpperCase()),m=d??f??p;m&&c.add(m.globalTrayId),d||f?a++:p?o++:s++}let l=e.length,u=`full`;return s>0?u=`missing`:o>0&&(u=`partial`),{exactMatches:a,typeOnlyMatches:o,missingTypes:s,totalSlots:l,status:u}}function ike(e,t,n,r,i){if(!e?.filaments||e.filaments.length===0)return;let a=JU(t);if(a.length===0)return;let o=new Set(Object.values(n)),s=[];for(let t of e.filaments){let e=t.slot_id||0;if(e>0&&n[e]!==void 0){s.push({slot_id:e,globalTrayId:n[e]});continue}let c=a.filter(e=>!o.has(e.globalTrayId));if(t.nozzle_id!=null){let e=c.filter(e=>e.extruderId===t.nozzle_id);e.length>0&&(c=e)}r&&(c=[...c].sort((e,t)=>Kf(Gf(e,i),Gf(t,i))));let l=c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()&&kf(e.color)===kf(t.color)),u=l?void 0:c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()&&Ff(e.color,t.color)),d=l||u?void 0:c.find(e=>e.type?.toUpperCase()===t.type?.toUpperCase()),f=l??u??d;f&&o.add(f.globalTrayId),s.push({slot_id:e,globalTrayId:f?.globalTrayId??-1})}let c=Math.max(...s.map(e=>e.slot_id||0));if(c<=0)return;let l=Array(c).fill(-1);return s.forEach(e=>{e.slot_id&&e.slot_id>0&&(l[e.slot_id-1]=e.globalTrayId)}),l}var ZU={useDefault:!0,manualMappings:{},autoConfigured:!1};function ake(e,t,n,r,i,a,o,s){let c=_o({queries:e.map(t=>({queryKey:[`printer-status`,t],queryFn:()=>Q.getPrinterStatus(t),enabled:e.length>0,staleTime:5e3}))}),l=(0,y.useMemo)(()=>e.map((e,a)=>{let l=c[a],u=l?.data,d=t?.find(t=>t.id===e)?.name||`Printer ${e}`,f=JU(u),p=i[e]||ZU,m=s?.get(e),h=qf(o,u?.ams_filament_backup),g=YU(n,u,h,m),_=p.useDefault?r:p.manualMappings,v=ike(n,u,_,h,m),y=rke(n?.filaments,f,_,h,m);return{printerId:e,printerName:d,status:u,isLoading:l?.isLoading??!1,loadedFilaments:f,autoMapping:g,finalMapping:v,matchStatus:y.status,exactMatches:y.exactMatches,typeOnlyMatches:y.typeOnlyMatches,missingTypes:y.missingTypes,totalSlots:y.totalSlots,config:p,inventoryByTrayId:m}}),[e,c,t,n,i,r,o,s]),u=c.some(e=>e.isLoading),d=(e,t)=>{a(n=>({...n,[e]:{...n[e]||ZU,...t}}))},f=e=>{let t=l.find(t=>t.printerId===e);if(!t||!t.status||!n?.filaments)return;let r=YU(n,t.status,qf(o,t.status?.ams_filament_backup),s?.get(e));if(!r)return;let i={};r.forEach((e,t)=>{e!==-1&&(i[t+1]=e)}),d(e,{useDefault:!1,manualMappings:i,autoConfigured:!0})};return{printerResults:l,isLoading:u,perPrinterConfigs:i,updatePrinterConfig:d,autoConfigureAll:()=>{for(let t of e)f(t)},autoConfigurePrinter:f,getFinalMapping:e=>l.find(t=>t.printerId===e)?.finalMapping,allPrintersReady:l.every(e=>e.matchStatus!==`missing`)}}var QU=`/img/bed`,oke={"cool plate":{icon:`${QU}/bed_cool.png`,label:`Cool Plate`},"pc plate":{icon:`${QU}/bed_cool.png`,label:`Cool Plate`},"cool plate (supertack)":{icon:`${QU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"supertack plate":{icon:`${QU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"bambu cool plate supertack":{icon:`${QU}/bed_cool_supertack.png`,label:`Cool Plate SuperTack`},"engineering plate":{icon:`${QU}/bed_engineering.png`,label:`Engineering Plate`},"high temp plate":{icon:`${QU}/bed_high_templ.png`,label:`High Temp Plate`},"textured pei plate":{icon:`${QU}/bed_pei.png`,label:`Textured PEI Plate`},"pei plate":{icon:`${QU}/bed_pei.png`,label:`PEI Plate`},"smooth pei plate":{icon:`${QU}/bed_pei_cool.png`,label:`Smooth PEI Plate`}};function $U(e){return e?oke[e.trim().toLowerCase()]??null:null}function ske(e){let t=e.trim().split(/\s+/);return t.length<=1?e.trim():t.slice(1).join(` `)}function eW(e){let{data:t}=q({queryKey:[`builtin-filaments`],queryFn:()=>Q.getBuiltinFilaments(),staleTime:300*1e3}),{data:n}=q({queryKey:[`filament-id-map`],queryFn:()=>Q.getFilamentIdMap(),staleTime:300*1e3}),r=(0,y.useMemo)(()=>{let e={};for(let n of t||[])n.filament_id&&(e[n.filament_id]=n.name);for(let[t,r]of Object.entries(n||{}))t&&r&&(e[t]=r);return e},[t,n]),i=(0,y.useMemo)(()=>(e||[]).map(e=>{let t=e.tray_info_idx&&r[e.tray_info_idx]||e.type;return{resolvedName:t,materialHint:ske(t),color:e.color}}),[e,r]),a=_o({queries:i.map(({color:e,materialHint:t})=>({queryKey:[`color-by-material`,e,t],queryFn:()=>Q.getColorByMaterial(e,t),enabled:!!e,staleTime:300*1e3}))});return i.map(({resolvedName:e,color:t},n)=>({resolvedName:e,colorLabel:(a[n]?.data?.color_name??null)||Gd(t)}))}function cke({printerId:e,filamentReqs:t,manualMappings:n,onManualMappingChange:r,currencySymbol:i,defaultCostPerKg:a,defaultExpanded:o=!1,forceColorMatch:s,onForceColorMatchChange:c}){let{t:l}=W(),u=no(),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(o),{data:h}=q({queryKey:[`printer-status`,e],queryFn:()=>Q.getPrinterStatus(e),enabled:!!e}),{data:g}=q({queryKey:[`spool-assignments`,e],queryFn:()=>Q.getAssignments(e),enabled:!!e}),{data:_}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:v}=q({queryKey:[`printer-inventory-remain`,e],queryFn:()=>Q.getInventoryRemain(e),enabled:!!e,staleTime:30*1e3}),b=(0,y.useMemo)(()=>{if(!v?.inventory_remain_g)return;let e=new Map;return Object.entries(v.inventory_remain_g).forEach(([t,n])=>{let r=Number(t);Number.isNaN(r)||e.set(r,n)}),e},[v]),{loadedFilaments:x,filamentComparison:S,hasTypeMismatch:C,hasColorMismatch:w}=XU(t,h,n,qf(_?.prefer_lowest_filament,h?.ams_filament_backup),b),T=eW(t?.filaments),E=(0,y.useMemo)(()=>{let e=new Map;for(let t of g||[]){let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n);e.set(r,t.spool?.cost_per_kg??null)}return e},[g]),D=(0,y.useMemo)(()=>{let e=new Map;for(let t of g||[]){let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n),i=t.spool;if(!i){e.set(r,null);continue}e.set(r,Math.max(0,Math.round((i.label_weight??0)-(i.weight_used??0))))}return e},[g]),O=(0,y.useMemo)(()=>{let e=0;for(let t of S){let n=t.loaded?.globalTrayId;if(n==null)continue;let r=E.get(n)??null??a;r>0&&(e+=t.used_grams/1e3*r)}return e},[S,E,a]),k=(0,y.useMemo)(()=>Array.from(E.values()).some(e=>e!=null&&e>0),[E]),A=t?.filaments&&t.filaments.length>0,j=t?.filaments?.some(e=>e.nozzle_id!=null)??!1,M=h?.fila_switch?.installed===!0,N=e=>{let t=h?.fila_switch;if(!t?.installed)return null;let n=t.in_slots.indexOf(e);return n<0?null:t.out_extruders[n]??null};if(!A||!h)return null;let P=C?`#f97316`:w?`#facc15`:`#00ae42`,F=(e,t)=>{if(e>0)if(t===``){let t={...n};delete t[e],r(t)}else r({...n,[e]:parseInt(t,10)})};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>m(!p),className:`flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full`,children:[(0,K.jsx)(bs,{className:`w-4 h-4`,fill:P,stroke:`none`}),(0,K.jsx)(`span`,{children:l(`printModal.filamentMapping`)}),C?(0,K.jsx)(`span`,{className:`text-xs text-orange-400`,children:`(Type not found)`}):w?(0,K.jsx)(`span`,{className:`text-xs text-yellow-400`,children:`(Color mismatch)`}):(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:`(Ready)`}),p?(0,K.jsx)(cs,{className:`w-4 h-4 ml-auto`}):(0,K.jsx)(is,{className:`w-4 h-4 ml-auto`})]}),p&&(0,K.jsxs)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Click to change slot assignment`}),(0,K.jsxs)(`button`,{type:`button`,onClick:async()=>{f(!0);try{await Q.refreshPrinterStatus(e),await new Promise(e=>setTimeout(e,500)),await u.refetchQueries({queryKey:[`printer-status`,e]})}finally{f(!1)}},className:`flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,disabled:d,children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${d?`animate-spin`:``}`}),(0,K.jsx)(`span`,{children:`Re-read`})]})]}),S.map((e,t)=>{let n=e.slot_id??0,r=n>0&&c!=null,{resolvedName:i,colorLabel:a}=T[t]??{resolvedName:e.type,colorLabel:Gd(e.color)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 16px`},children:[(0,K.jsx)(`span`,{title:`Required: ${i} - ${a}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:e.color,stroke:e.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate flex items-center gap-1`,children:[j&&e.nozzle_id!=null&&(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-3.5 h-3.5 rounded text-[9px] font-bold leading-none bg-bambu-gray/20 text-bambu-gray shrink-0`,title:e.nozzle_id===1?l(`printModal.leftNozzleTooltip`):l(`printModal.rightNozzleTooltip`),children:e.nozzle_id===1?l(`printModal.leftNozzle`):l(`printModal.rightNozzle`)}),i,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:e.loaded?.globalTrayId??``,onChange:e=>F(n,e.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${e.status===`match`?`border-bambu-green/50 text-bambu-green`:e.status===`type_only`?`border-yellow-400/50 text-yellow-400`:`border-orange-400/50 text-orange-400`} ${e.isManual?`ring-1 ring-blue-400/50`:``}`,title:e.isManual?`Manually selected`:`Auto-matched`,children:[(0,K.jsx)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:`-- Select slot --`}),x.map(e=>{let t=D.get(e.globalTrayId),n=t==null?``:l(`printModal.slotRemainingShort`,{grams:t,defaultValue:` - ${t}g left`}),r=M?N(e.globalTrayId):null,i=r==null?``:` [${l(r===1?`printModal.leftNozzle`:`printModal.rightNozzle`)}]`;return(0,K.jsxs)(`option`,{value:e.globalTrayId,className:`bg-bambu-dark text-white`,children:[e.label,`: `,e.traySubBrands||e.type,` (`,e.colorName,`)`,n,i]},e.globalTrayId)})]}),e.status===`match`?(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}):e.status===`type_only`?(0,K.jsx)(`span`,{title:`Same type, different color`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`})}):(0,K.jsx)(`span`,{title:`Filament type not loaded`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-orange-400`})})]}),r&&(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-bambu-gray cursor-pointer select-none pl-5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s?.[n]??!1,onChange:e=>c(n,e.target.checked),className:`accent-bambu-green w-3 h-3`}),(0,K.jsx)(ml,{className:`w-3 h-3`}),l(`printModal.forceColorMatch`)]})]},t)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[l(`printModal.totalCost`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:O>0||k?`${i}${O.toFixed(2)}`:`N/A`})]}),C&&(0,K.jsx)(`p`,{className:`text-xs text-orange-400 mt-2`,children:`Required filament type not found in printer.`})]})]})}function lke({filamentReqs:e,availableFilaments:t,overrides:n,onChange:r,forceColorMatch:i,onForceColorMatchChange:a}){let{t:o}=W(),s=eW(e?.filaments),c=(0,y.useMemo)(()=>{let e={};for(let n of t){let t=Nf(n.type);e[t]||(e[t]=[]),e[t].push(n)}return e},[t]),l=e?.filaments;if(!l||l.length===0||t.length===0)return null;let u=(e,t)=>{if(t===``){let t={...n};delete t[e],r(t)}else{let[i,a]=t.split(`|`);r({...n,[e]:{type:i,color:a}})}};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:(0,K.jsx)(`span`,{children:o(`printModal.filamentOverride`)})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:o(`printModal.filamentOverrideHint`)}),(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-3 space-y-2`,children:l.map((e,t)=>{let r=n[e.slot_id],l=!!r,d=c[Nf(e.type)]||[],f=e.nozzle_id==null?d:d.filter(t=>t.extruder_id==null||t.extruder_id===e.nozzle_id),{resolvedName:p,colorLabel:m}=s[t]??{resolvedName:e.type,colorLabel:Gd(e.color)};return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 20px`},children:[(0,K.jsx)(`span`,{title:`${o(`printModal.originalFilament`)}: ${p} - ${m}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:e.color,stroke:e.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate`,children:[p,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:l?`${r.type}|${r.color}`:``,onChange:t=>u(e.slot_id,t.target.value),disabled:f.length===0,className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${l?`border-blue-400/50 text-blue-400`:`border-bambu-gray/30 text-bambu-gray`}`,children:[(0,K.jsxs)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:[o(`printModal.originalFilament`),`: `,p,` (`,m,`)`]}),f.map((e,t)=>(0,K.jsxs)(`option`,{value:`${e.type}|${e.color}`,className:`bg-bambu-dark text-white`,children:[e.tray_sub_brands||e.type,` (`,Gd(e.color),`)`]},`${e.type}-${e.color}-${e.tray_sub_brands}-${t}`))]}),l?(0,K.jsx)(`button`,{type:`button`,onClick:()=>u(e.slot_id,``),className:`text-bambu-gray hover:text-white transition-colors`,title:o(`printModal.resetToOriginal`),children:(0,K.jsx)(Al,{className:`w-3 h-3`})}):(0,K.jsx)(`span`,{className:`w-3`})]}),(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-xs text-bambu-gray cursor-pointer select-none pl-5`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i?.[e.slot_id]??!1,onChange:t=>a?.(e.slot_id,t.target.checked),className:`accent-bambu-green w-3 h-3`}),(0,K.jsx)(ml,{className:`w-3 h-3`}),o(`printModal.forceColorMatch`)]})]},e.slot_id)})})]})}function uke({plates:e,isMultiPlate:t,selectedPlates:n,onToggle:r,onSelectAll:i,onDeselectAll:a,multiSelect:o}){let{t:s}=W();if(!t||e.length<=1)return null;let c=n.size===e.length;return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`Select Plate`,o?`s`:``,` to Print`]}),n.size===0&&(0,K.jsxs)(`span`,{className:`text-xs text-orange-400 flex items-center gap-1`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),`Selection required`]}),o&&i&&a&&(0,K.jsx)(`button`,{type:`button`,onClick:c?a:i,className:`ml-auto text-xs px-2 py-0.5 rounded-full border transition-colors ${c?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-gray`}`,children:c?s(`queue.deselectAll`):s(`queue.selectAllPlates`,{count:e.length})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map(e=>{let t=n.has(e.index);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.index),className:`flex items-center gap-2 p-2 rounded-lg border transition-colors text-left ${t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray`}`,children:[o&&(t?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`})),e.has_thumbnail&&e.thumbnail_url!=null?(0,K.jsx)(`img`,{src:Xu(e.thumbnail_url),alt:`Plate ${e.index}`,className:`w-10 h-10 rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:e.name||`Plate ${e.index}`}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[e.objects.length>0?e.objects.slice(0,3).join(`, `)+(e.objects.length>3?`...`:``):`${e.filaments.length} filament${e.filaments.length===1?``:`s`}`,e.print_time_seconds==null?``:` • ${Cf(e.print_time_seconds)}`]}),(()=>{let t=$U(e.bed_type);return t?(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray flex items-center gap-1 mt-0.5 truncate`,title:t.label,children:[(0,K.jsx)(`img`,{src:t.icon,alt:``,className:`w-3.5 h-3.5 object-contain flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t.label})]}):null})()]}),!o&&t&&(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]},e.index)})})]})}var tW=new Set,nW=new Set,rW=!1;function dke(e){let t=new Set;for(let n of e.dispatched_jobs??[])typeof n.printer_id==`number`&&t.add(n.printer_id);for(let n of e.active_jobs??[])typeof n.printer_id==`number`&&t.add(n.printer_id);return t}function fke(e){let t=dke(e.detail??{});t.size===tW.size&&[...t].every(e=>tW.has(e))||(tW=t,nW.forEach(e=>e()))}function pke(){rW||typeof window>`u`||(window.addEventListener(`background-dispatch`,fke),rW=!0)}var mke=e=>(pke(),nW.add(e),()=>{nW.delete(e)}),iW=()=>tW;function hke(){return(0,y.useSyncExternalStore)(mke,iW,iW)}var gke=new Set([`IDLE`,`FINISH`,`FAILED`]);function _ke({printerResult:e,filamentReqs:t,onUpdateConfig:n}){let r=no(),[i,a]=(0,y.useState)(!1),o=(t,r)=>{if(t<=0)return;let i={...e.config.manualMappings};r===``?delete i[t]:i[t]=parseInt(r,10),n({useDefault:!1,manualMappings:i,autoConfigured:!1})},s=async()=>{a(!0);try{await Q.refreshPrinterStatus(e.printerId),await new Promise(e=>setTimeout(e,500)),await r.refetchQueries({queryKey:[`printer-status`,e.printerId]})}finally{a(!1)}},c=t.map(t=>{let n=t.slot_id||0,i=e.config.manualMappings[n],a,o=!1;if(i!==void 0)a=e.loadedFilaments.find(e=>e.globalTrayId===i),o=!0;else{let n=new Set(Object.values(e.config.manualMappings)),i=r.getQueryData([`settings`]);a=Jf(t,e.loadedFilaments,n,qf(i?.prefer_lowest_filament,e.status?.ams_filament_backup),e.inventoryByTrayId)}let s=`mismatch`;if(a){let e=a.type?.toUpperCase()===t.type?.toUpperCase(),n=kf(a.color)===kf(t.color)||Ff(a.color,t.color);e&&n?s=`match`:e&&(s=`type_only`)}return{req:t,loaded:a,status:s,isManual:o}});return(0,K.jsxs)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Custom slot mapping`}),(0,K.jsxs)(`button`,{type:`button`,onClick:s,className:`flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,disabled:i,children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${i?`animate-spin`:``}`}),(0,K.jsx)(`span`,{children:`Re-read`})]})]}),c.map(({req:t,loaded:n,status:r,isManual:i},a)=>(0,K.jsxs)(`div`,{className:`grid items-center gap-2 text-xs`,style:{gridTemplateColumns:`16px minmax(70px, 1fr) auto 2fr 16px`},children:[(0,K.jsx)(`span`,{title:`Required: ${t.type} - ${Gd(t.color)}`,children:(0,K.jsx)(bs,{className:`w-3 h-3`,fill:t.color,stroke:t.color})}),(0,K.jsxs)(`span`,{className:`text-white truncate`,children:[t.type,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,t.used_grams,`g)`]})]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`→`}),(0,K.jsxs)(`select`,{value:n?.globalTrayId??``,onChange:e=>o(t.slot_id||0,e.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${r===`match`?`border-bambu-green/50 text-bambu-green`:r===`type_only`?`border-yellow-400/50 text-yellow-400`:`border-orange-400/50 text-orange-400`} ${i?`ring-1 ring-blue-400/50`:``}`,title:i?`Manually selected`:`Auto-matched`,children:[(0,K.jsx)(`option`,{value:``,className:`bg-bambu-dark text-bambu-gray`,children:`-- Select slot --`}),Yf(e.loadedFilaments,t.nozzle_id).map(e=>(0,K.jsxs)(`option`,{value:e.globalTrayId,className:`bg-bambu-dark text-white`,children:[e.label,`: `,e.traySubBrands||e.type,` (`,e.colorName,`)`]},e.globalTrayId))]}),r===`match`?(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}):r===`type_only`?(0,K.jsx)(`span`,{title:`Same type, different color`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`})}):(0,K.jsx)(`span`,{title:`Filament type not loaded`,children:(0,K.jsx)(Cu,{className:`w-3 h-3 text-orange-400`})})]},a))]})}function vke({printers:e,selectedPrinterIds:t,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,disableBusy:o=!1,printerMappingResults:s,filamentReqs:c,onAutoConfigurePrinter:l,onUpdatePrinterConfig:u,assignmentMode:d=`printer`,onAssignmentModeChange:f,targetModel:p,onTargetModelChange:m,targetLocation:h,onTargetLocationChange:g,slicedForModel:_}){let[v,b]=(0,y.useState)(!1),x=a?e:e.filter(e=>e.is_active),S=_o({queries:x.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),staleTime:5e3}))}),C=(0,y.useMemo)(()=>{let e=new Map;return x.forEach((t,n)=>{let r=S[n];r?.data&&e.set(t.id,r.data)}),e},[x,S]),w=hke(),T=e=>{if(w.has(e))return!0;let t=C.get(e);return t?t.connected?!gke.has(t.state??``):!0:!1},E=e=>{if(w.has(e))return`Dispatching...`;let t=C.get(e);if(!t)return null;if(!t.connected)return`Offline`;let n=t.state;return n?n===`RUNNING`?t.stg_cur_name||`Printing`:n===`PREPARE`?`Preparing`:n===`PAUSE`?`Paused`:n===`IDLE`?`Idle`:n===`FINISH`?`Finished`:n===`FAILED`?`Failed`:n:null},D=(0,y.useMemo)(()=>{if(d!==`printer`||!_||v)return x;let e=x.filter(e=>e.model===_);return e.length>0?e:x},[x,d,_,v]),O=x.length-D.length,k=(0,y.useMemo)(()=>{let e=x.map(e=>e.model).filter(e=>!!e);return[...new Set(e)].sort()},[x]),A=(0,y.useMemo)(()=>{if(!p)return[];let e=x.filter(e=>e.model===p&&e.location).map(e=>e.location).filter(e=>!!e);return[...new Set(e)].sort()},[x,p]),j=f&&m&&k.length>0,M=i&&t.length>1&&s&&c?.filaments&&c.filaments.length>0&&l&&u;if(r)return(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})});if(D.length===0)return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm mb-4`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),`No `,a?``:`active `,`printers available`]});let N=e=>{o&&T(e)||(i?t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e]):n([e]))},P=()=>{n((o?D.filter(e=>!T(e.id)):D).map(e=>e.id))},F=()=>{n([])},I=(e,t,n)=>{n.stopPropagation(),!(!l||!u)&&(t?l(e):u(e,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},L=e=>t.includes(e),R=t.length,z=e=>s?.find(t=>t.printerId===e);return(0,K.jsxs)(`div`,{className:`space-y-2 mb-6`,children:[j&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{f(`printer`),m(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d===`printer`?`border-bambu-green bg-bambu-green/10 text-white`:`border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray`}`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:`Specific Printer`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{f(`model`),n([]),m(_&&k.includes(_)?_:k[0])},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${d===`model`?`border-bambu-green bg-bambu-green/10 text-white`:`border-bambu-dark-tertiary bg-bambu-dark text-bambu-gray hover:border-bambu-gray`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[`Any `,_||`Model`]})]})]}),d===`model`&&j&&(0,K.jsxs)(`div`,{className:`space-y-3 mb-4`,children:[!_&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:`Target Model`}),(0,K.jsxs)(`select`,{value:p||``,onChange:e=>{m(e.target.value||null),g&&g(null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`Select a model...`}),k.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),p&&A.length>0&&g&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:`Location Filter (optional)`}),(0,K.jsxs)(`select`,{value:h||``,onChange:e=>g(e.target.value||null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`Any location`}),A.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),p&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Scheduler will assign to first available idle `,p,` printer`,h?` in ${h}`:``]})]}),d===`printer`&&i&&D.length>1&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray mb-2`,children:[(0,K.jsx)(`span`,{children:R===0?`Select printers`:`${R} printer${R===1?``:`s`} selected`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[R0&&(0,K.jsx)(`button`,{type:`button`,onClick:F,className:`text-bambu-gray hover:text-white transition-colors`,children:`Clear`})]})]}),d===`printer`&&D.map(e=>{let t=L(e.id),n=z(e.id),r=n&&!n.config.useDefault,a=T(e.id),s=o&&a,d=E(e.id);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>N(e.id),disabled:s,className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${s?`border-bambu-dark-tertiary bg-bambu-dark opacity-50 cursor-not-allowed`:t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray`} ${e.is_active?``:`opacity-60`}`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${s?`bg-bambu-dark-tertiary`:t?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(Tl,{className:`w-5 h-5 ${s?`text-bambu-gray/50`:t?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{className:`text-left flex-1`,children:[(0,K.jsxs)(`p`,{className:`font-medium ${s?`text-bambu-gray`:`text-white`}`,children:[e.name,!e.is_active&&(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs ml-2`,children:`(inactive)`})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.model||`Unknown model`,` • `,e.ip_address]})]}),d&&(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${a?`bg-yellow-500/20 text-yellow-400`:`bg-bambu-green/20 text-bambu-green`}`,children:d}),i&&(0,K.jsx)(`div`,{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${s?`border-bambu-gray/30`:t?`bg-bambu-green border-bambu-green`:`border-bambu-gray/50`}`,children:t&&(0,K.jsx)(rs,{className:`w-3 h-3 text-white`})})]}),t&&M&&n&&(0,K.jsxs)(`div`,{className:`ml-4 mt-2 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,onChange:t=>I(e.id,t.target.checked,t),className:`w-3.5 h-3.5 rounded border-bambu-gray/30 bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Custom mapping`})]}),(0,K.jsxs)(`span`,{className:`text-xs ml-2 ${n.matchStatus===`full`?`text-bambu-green`:n.matchStatus===`partial`?`text-yellow-400`:`text-orange-400`}`,children:[`(`,n.exactMatches,`/`,n.totalSlots,` matched)`]}),n.isLoading&&(0,K.jsx)(Ol,{className:`w-3 h-3 text-bambu-gray animate-spin`}),r&&(0,K.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l(e.id)},className:`ml-auto flex items-center gap-1 px-2 py-0.5 text-xs rounded border border-bambu-gray/30 hover:border-bambu-gray hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray hover:text-white`,children:[(0,K.jsx)(Mu,{className:`w-3 h-3`}),`Auto`]})]}),r&&(0,K.jsx)(_ke,{printerResult:n,filamentReqs:c.filaments,onUpdateConfig:t=>u(e.id,t)})]})]},e.id)}),d===`printer`&&O>0&&!v&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>b(!0),className:`text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`}),O,` other printer`,O>1?`s`:``,` hidden (different model) —`,(0,K.jsx)(`span`,{className:`underline`,children:`show all`})]}),d===`printer`&&v&&_&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>b(!1),className:`text-xs text-bambu-gray hover:text-white transition-colors mt-2`,children:(0,K.jsxs)(`span`,{className:`underline`,children:[`Show only `,_,` printers`]})}),d===`printer`&&R===0&&(0,K.jsxs)(`p`,{className:`text-xs text-orange-400 mt-1 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Select at least one printer`]}),d===`model`&&!p&&(0,K.jsxs)(`p`,{className:`text-xs text-orange-400 mt-1 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Select a target printer model`]})]})}function yke({options:e,onChange:t,defaultExpanded:n=!1,showDualNozzleOptions:r=!1}){let{t:i}=W(),[a,o]=(0,y.useState)(n),s=[{key:`bed_levelling`,label:i(`settings.defaultBedLevelling`),desc:i(`settings.defaultBedLevellingDesc`)},{key:`flow_cali`,label:i(`settings.defaultFlowCali`),desc:i(`settings.defaultFlowCaliDesc`)},{key:`vibration_cali`,label:i(`settings.defaultVibrationCali`),desc:i(`settings.defaultVibrationCaliDesc`)},{key:`layer_inspect`,label:i(`settings.defaultLayerInspect`),desc:i(`settings.defaultLayerInspectDesc`)},{key:`timelapse`,label:i(`settings.defaultTimelapse`),desc:i(`settings.defaultTimelapseDesc`)},{key:`nozzle_offset_cali`,label:i(`settings.defaultNozzleOffsetCali`),desc:i(`settings.defaultNozzleOffsetCaliDesc`),dualNozzleOnly:!0}].filter(e=>!e.dualNozzleOnly||r),c=n=>{t({...e,[n]:!e[n]})};return(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`flex items-center gap-2 text-sm text-bambu-gray hover:text-white transition-colors w-full`,children:[(0,K.jsx)(Ul,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:i(`queue.bulkEdit.printOptions`)}),a?(0,K.jsx)(cs,{className:`w-4 h-4 ml-auto`}):(0,K.jsx)(is,{className:`w-4 h-4 ml-auto`})]}),a&&(0,K.jsx)(`div`,{className:`mt-2 bg-bambu-dark rounded-lg p-3 space-y-2`,children:s.map(({key:t,label:n,desc:r})=>(0,K.jsxs)(`label`,{className:`flex items-center justify-between cursor-pointer group`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r})]}),(0,K.jsx)(`div`,{className:`relative w-10 h-5 rounded-full transition-colors ${e[t]?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,onClick:()=>c(t),children:(0,K.jsx)(`div`,{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white transition-transform ${e[t]?`translate-x-5`:`translate-x-0.5`}`})})]},t))})]})}function bke({options:e,onChange:t,dateFormat:n=`system`,timeFormat:r=`system`,canControlPrinter:i=!0,showStagger:a=!1,printerCount:o=0,hasGcodeSnippets:s=!1}){let{t:c}=W(),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(!0),_=(0,y.useRef)(null),v=(0,y.useRef)(!1);(0,y.useEffect)(()=>{if(e.scheduleType!==`scheduled`){v.current=!1;return}if(!v.current){v.current=!0;let i;e.scheduledTime?(i=new Date(e.scheduledTime),isNaN(i.getTime())&&(i=new Date,i.setHours(i.getHours()+1,0,0,0))):(i=new Date,i.setHours(i.getHours()+1,0,0,0),t({...e,scheduledTime:gf(i)})),u(uf(i,n)),f(df(i,r)),m(!0),g(!0)}},[e.scheduleType,e.scheduledTime,n,r,t,e]);let b=n=>{t({...e,scheduleType:n})},x=(r,i)=>{let a=mf(r,n),o=hf(i);m(!!a),g(!!o),a&&o&&(a.setHours(o.hours,o.minutes,0,0),a>new Date&&t({...e,scheduledTime:gf(a)}))},S=e=>{u(e),x(e,d)},C=e=>{f(e),x(l,e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:`When to print`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`asap`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`asap`),children:[(0,K.jsx)(Ss,{className:`w-4 h-4`}),`ASAP`]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`scheduled`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`scheduled`),children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),`Scheduled`]}),(0,K.jsxs)(`button`,{type:`button`,className:`flex-1 px-2 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 transition-colors ${e.scheduleType===`manual`?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,onClick:()=>b(`manual`),children:[(0,K.jsx)(Cc,{className:`w-4 h-4`}),`Queue Only`]})]})]}),e.scheduleType===`scheduled`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Date & Time`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 pr-10 bg-bambu-dark border rounded-lg text-white focus:outline-none ${p?`border-bambu-dark-tertiary focus:border-bambu-green`:`border-red-500`}`,value:l,onChange:e=>S(e.target.value),placeholder:cf(n)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{_.current?.showPicker()},className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,title:`Open calendar`,children:(0,K.jsx)(Zo,{className:`w-4 h-4`})}),(0,K.jsx)(`input`,{ref:_,type:`datetime-local`,className:`absolute top-0 left-0 w-0 h-0 opacity-0 pointer-events-none`,value:e.scheduledTime,onChange:i=>{let a=i.target.value;if(a){let i=new Date(a);isNaN(i.getTime())||(u(uf(i,n)),f(df(i,r)),m(!0),g(!0),t({...e,scheduledTime:a}))}},tabIndex:-1})]}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:outline-none ${h?`border-bambu-dark-tertiary focus:border-bambu-green`:`border-red-500`}`,value:d,onChange:e=>C(e.target.value),placeholder:lf(r)})})]}),(!p||!h)&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:`Please enter a valid date and time`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`requirePrevious`,checked:e.requirePreviousSuccess,onChange:n=>t({...e,requirePreviousSuccess:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`requirePrevious`,className:`text-sm text-bambu-gray`,children:`Only start if previous print succeeded`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`autoOffAfter`,checked:e.autoOffAfter,onChange:n=>t({...e,autoOffAfter:n.target.checked}),disabled:!i,className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green disabled:opacity-50`}),(0,K.jsxs)(`label`,{htmlFor:`autoOffAfter`,className:`text-sm flex items-center gap-1 ${i?`text-bambu-gray`:`text-bambu-gray/50`}`,children:[(0,K.jsx)(wl,{className:`w-3.5 h-3.5`}),`Power off printer when done`]})]}),s&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`gcodeInjection`,checked:e.gcodeInjection,onChange:n=>t({...e,gcodeInjection:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`gcodeInjection`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Es,{className:`w-3.5 h-3.5`}),c(`printModal.gcodeInjection`,`Inject auto-print G-code`)]})]}),a&&e.scheduleType!==`manual`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`staggerEnabled`,checked:e.staggerEnabled,onChange:n=>t({...e,staggerEnabled:n.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`staggerEnabled`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5`}),c(`printModal.staggerPrinterStarts`,`Stagger printer starts`)]})]}),e.staggerEnabled&&(0,K.jsxs)(`div`,{className:`ml-6 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:c(`printModal.staggerGroupSize`,`Group size`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:o,value:e.staggerGroupSize,onChange:n=>t({...e,staggerGroupSize:Math.max(1,parseInt(n.target.value)||1)}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:c(`printModal.staggerInterval`,`Interval (min)`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:60,value:e.staggerIntervalMinutes,onChange:n=>t({...e,staggerIntervalMinutes:Math.max(1,parseInt(n.target.value)||1)}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})]}),o>0&&(()=>{let t=Math.ceil(o/e.staggerGroupSize),n=o%e.staggerGroupSize,r=(t-1)*e.staggerIntervalMinutes;return(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[c(`printModal.staggerPreview`,`{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min`,{printers:o,groups:t,size:e.staggerGroupSize,interval:e.staggerIntervalMinutes}),n!==0&&e.staggerGroupSize1?` (${c(`printModal.staggerTotal`,`total: {{minutes}} min`,{minutes:r})})`:``]})})()]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.scheduleType===`asap`?`Print will start as soon as the printer is idle.`:e.scheduleType===`scheduled`?`Print will start at the scheduled time if the printer is idle. If busy, it will wait until the printer becomes available.`:`Print will be staged but won't start automatically. Use the Start button to release it to the queue.`})]})}var aW={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1,nozzle_offset_cali:!0},oW={scheduleType:`asap`,scheduledTime:``,requirePreviousSuccess:!1,autoOffAfter:!1,gcodeInjection:!1,staggerEnabled:!1,staggerGroupSize:2,staggerIntervalMinutes:5};function sW({mode:e,archiveId:t,libraryFileId:n,archiveName:r,queueItem:i,initialSelectedPrinterIds:a,onClose:o,onSuccess:s,projectId:c,cleanupLibraryAfterDispatch:l}){let{t:u}=W(),d=no(),{showToast:f}=Td(),{hasPermission:p}=dd(),m=!!n&&!t,[h,g]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.printer_id?[i.printer_id]:a?.length?a:[]),[_,v]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.plate_id!=null?new Set([i.plate_id]):new Set),b=_.size===1?[..._][0]:null,[x,S]=(0,y.useState)(1),[C,w]=(0,y.useState)(()=>e===`edit-queue-item`&&i?{bed_levelling:i.bed_levelling??aW.bed_levelling,flow_cali:i.flow_cali??aW.flow_cali,vibration_cali:i.vibration_cali??aW.vibration_cali,layer_inspect:i.layer_inspect??aW.layer_inspect,timelapse:i.timelapse??aW.timelapse,nozzle_offset_cali:i.nozzle_offset_cali??aW.nozzle_offset_cali}:aW),[T,E]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i){let e=`asap`;i.manual_start?e=`manual`:i.scheduled_time&&!Uf(i.scheduled_time)&&(e=`scheduled`);let t=``;return i.scheduled_time&&!Uf(i.scheduled_time)&&(t=gf(vf(i.scheduled_time)??new Date)),{scheduleType:e,scheduledTime:t,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after,gcodeInjection:i.gcode_injection??!1,staggerEnabled:!1,staggerGroupSize:oW.staggerGroupSize,staggerIntervalMinutes:oW.staggerIntervalMinutes}}return oW}),[D,O]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){let e={};return i.ams_mapping.forEach((t,n)=>{t!==-1&&(e[n+1]=t)}),e}return{}}),[k,A]=(0,y.useState)({}),[j,M]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_model?`model`:`printer`),[N,P]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_model?i.target_model:null),[F,I]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.target_location?i.target_location:null),[L,R]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.filament_overrides){let e={};for(let t of i.filament_overrides)e[t.slot_id]={type:t.type,color:t.color};return e}return{}}),[z,B]=(0,y.useState)(()=>{if(e===`edit-queue-item`&&i?.filament_overrides){let e={};for(let t of i.filament_overrides)e[t.slot_id]=t.force_color_match===!0;return e}return{}}),[V]=(0,y.useState)(()=>e===`edit-queue-item`&&i?.printer_id?[i.printer_id]:[]),[ee]=(0,y.useState)(()=>e===`edit-queue-item`&&i?i.plate_id:null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)({current:0,total:0}),[H,ae]=(0,y.useState)(null),[oe,U]=(0,y.useState)(new Set),se=h.length,ce=h.length>0?h[0]:null,{data:le}=q({queryKey:[`settings`],queryFn:Q.getSettings}),ue=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!le||ue.current||e===`edit-queue-item`||(ue.current=!0,w({bed_levelling:le.default_bed_levelling??aW.bed_levelling,flow_cali:le.default_flow_cali??aW.flow_cali,vibration_cali:le.default_vibration_cali??aW.vibration_cali,layer_inspect:le.default_layer_inspect??aW.layer_inspect,timelapse:le.default_timelapse??aW.timelapse,nozzle_offset_cali:le.default_nozzle_offset_cali??aW.nozzle_offset_cali}))},[le,e]);let de=(0,y.useRef)(!1);(0,y.useEffect)(()=>{!le||de.current||e===`edit-queue-item`||(de.current=!0,E(e=>({...e,staggerGroupSize:le.stagger_group_size??e.staggerGroupSize,staggerIntervalMinutes:le.stagger_interval_minutes??e.staggerIntervalMinutes})))},[le,e]);let fe=$d(le?.currency||`USD`),pe=le?.default_filament_cost??0,{data:me,isLoading:he}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:ge}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),staleTime:30*1e3,enabled:(e===`reprint`||e===`add-to-queue`)&&j===`printer`||m&&e===`reprint`}),_e=_o({queries:h.map(e=>({queryKey:[`printer-inventory-remain`,e],queryFn:()=>Q.getInventoryRemain(e),staleTime:30*1e3,enabled:h.length>0}))}),ve=(0,y.useMemo)(()=>{let e=new Map;return h.forEach((t,n)=>{let r=_e[n]?.data?.inventory_remain_g;if(!r)return;let i=new Map;Object.entries(r).forEach(([e,t])=>{let n=Number(e);Number.isNaN(n)||i.set(n,t)}),e.set(t,i)}),e},[h,_e]),{data:ye}=q({queryKey:[`archive`,t],queryFn:()=>Q.getArchive(t),enabled:!!t&&!m}),{data:be}=q({queryKey:[`library-file`,n],queryFn:()=>Q.getLibraryFile(n),enabled:m&&!!n}),xe=ye?.sliced_for_model||be?.sliced_for_model||null,{data:Se,isError:Ce}=q({queryKey:[`archive-plates`,t],queryFn:()=>Q.getArchivePlates(t),enabled:!!t&&!m,retry:!1}),{data:we}=q({queryKey:[`library-file-plates`,n],queryFn:()=>Q.getLibraryFilePlates(n),enabled:m&&!!n}),Te=m?we:Se,{data:Ee,isError:De}=q({queryKey:[`archive-filaments`,t,b],queryFn:()=>Q.getArchiveFilamentRequirements(t,b??void 0),enabled:!!t&&!m&&(b!==null||!Te?.is_multi_plate),retry:!1}),{data:Oe}=q({queryKey:[`library-file-filaments`,n,b],queryFn:()=>Q.getLibraryFileFilamentRequirements(n,b??void 0),enabled:m&&!!n&&(b!==null||!Te?.is_multi_plate)}),ke=!m&&(Ce||De),Ae=m?Oe:Ee,je=(0,y.useMemo)(()=>{if(!(b===null||!Te?.plates?.length))return Te.plates.find(e=>e.index===b)?.name||void 0},[Te,b]),{data:Me}=q({queryKey:[`available-filaments`,N,F],queryFn:()=>Q.getAvailableFilaments(N,F??void 0),enabled:j===`model`&&!!N}),{data:Ne}=q({queryKey:[`printer-status`,ce],queryFn:()=>Q.getPrinterStatus(ce),enabled:!!ce}),{amsMapping:Pe}=XU(Ae,Ne,D,qf(le?.prefer_lowest_filament,Ne?.ams_filament_backup),ce?ve.get(ce):void 0),Fe=ake(h,me,Ae,D,k,A,le?.prefer_lowest_filament,ve);(0,y.useEffect)(()=>{Te?.plates&&Te.plates.length>=1&&_.size===0&&v(new Set([Te.plates[0].index]))},[Te,_.size]),(0,y.useEffect)(()=>{if(e===`edit-queue-item`)return;let t=me?.filter(e=>e.is_active)||[];t.length===1&&h.length===0&&g([t[0].id])},[e,me,h.length]),(0,y.useEffect)(()=>{e===`edit-queue-item`?(JSON.stringify(h.sort())!==JSON.stringify(V.sort())||b!==ee)&&(O({}),A({}),U(new Set)):(O({}),A({}),U(new Set))},[e,h,b,V,ee]);let[Ie,Le]=(0,y.useState)(N),[Re,ze]=(0,y.useState)(b);(0,y.useEffect)(()=>{(N!==Ie||b!==Re)&&(Le(N),ze(b),(e!==`edit-queue-item`||Ie!==null)&&(R({}),B({})))},[N,b,Ie,Re,e]),(0,y.useEffect)(()=>{if(!le?.per_printer_mapping_expanded||h.length<=1)return;let e=h.filter(e=>{if(oe.has(e))return!1;let t=Fe.printerResults.find(t=>t.printerId===e);return t&&t.status&&!t.isLoading});e.length>0&&(U(t=>{let n=new Set(t);return e.forEach(e=>n.add(e)),n}),e.forEach(e=>{Fe.autoConfigurePrinter(e)}))},[le?.per_printer_mapping_expanded,h,oe,Fe]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!te&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,te]);let Be=Te?.is_multi_plate??!1,Ve=Te?.plates??[],He=(0,y.useMemo)(()=>{let e=new Map;return ge&&ge.forEach(t=>{let n=t.ams_id===255,r=Lf(t.ams_id,t.tray_id,n),i=e.get(t.printer_id)??new Map;i.set(r,t),e.set(t.printer_id,i)}),e},[ge]),Ue=(0,y.useMemo)(()=>{if(!H||H.length===0)return``;let e=H.map(e=>u(`printModal.insufficientFilamentLine`,{printer:e.printerName,slot:e.slotLabel,required:Math.round(e.requiredGrams),remaining:Math.round(e.remainingGrams)}));return[u(`printModal.insufficientFilamentMessage`),...e].join(` +`)},[H,u]),We=J({mutationFn:e=>Q.addToQueue(e)}),Ge=J({mutationFn:e=>Q.updateQueueItem(i.id,e),onSuccess:()=>{d.invalidateQueries({queryKey:[`queue`]}),f(`Queue item updated`),s?.(),o()},onError:e=>{f(e.message||`Failed to update queue item`,`error`)}}),Ke=T.staggerEnabled&&h.length>1,qe=async(i,a)=>{if(i?.preventDefault(),!a?.skipFilamentCheck&&!le?.disable_filament_warnings&&(e===`reprint`||e===`add-to-queue`)&&j===`printer`){let e=[],t=Ae?.filaments??[];if(t.length>0&&He.size>0){let n=(e,t)=>!Number.isFinite(e)||e<=0||!Number.isFinite(t)||t<0?null:Math.max(0,e-t);for(let r of h){let i=h.length>1?Fe.getFinalMapping(r):Pe;if(!i)continue;let a=JU(h.length>1?Fe.printerResults.find(e=>e.printerId===r)?.status:Ne),o=new Map(a.map(e=>[e.globalTrayId,e.label])),s=He.get(r),c=me?.find(e=>e.id===r)?.name??`Printer ${r}`;s&&t.forEach(t=>{if(!t.slot_id||t.slot_id<=0)return;let r=i[t.slot_id-1];if(!Number.isFinite(r)||r<0)return;let a=s.get(r)?.spool;if(!a)return;let l=n(a.label_weight,a.weight_used);l!==null&&(l>=t.used_grams||e.push({printerName:c,slotLabel:o.get(r)??`Slot ${t.slot_id}`,requiredGrams:t.used_grams,remainingGrams:l}))})}}if(e.length>0){ae(e);return}}if(j===`printer`&&h.length===0){f(`Please select at least one printer`,`error`);return}if(j===`model`&&!N){f(`Please select a target printer model`,`error`);return}ne(!0);let p=_.size>1?Ve.filter(e=>_.has(e.index)):[null],g=j===`model`?p.length:h.length*p.length;ie({current:0,total:g});let v={success:0,failed:0,errors:[]},y=e=>{if(h.length>1){let t=k[e];if(t&&!t.useDefault)return Fe.getFinalMapping(e)}return Pe},x=(()=>{let e=[];if(Ae?.filaments)for(let t of Ae.filaments){let n=L[t.slot_id],r=z[t.slot_id]??!1,i=n?.type??t.type,a=n?.color??t.color;(n||r)&&e.push({slot_id:t.slot_id,type:i,color:a,color_name:Gd(a),force_color_match:r})}else for(let[t,{type:n,color:r}]of Object.entries(L)){let i=parseInt(t,10),a=z[i]??!1;e.push({slot_id:i,type:n,color:r,color_name:Gd(r),force_color_match:a})}return e.length>0?e:void 0})(),S=e===`add-to-queue`&&p.length>1&&(j===`model`||h.length===1),w=null;if(S)try{let e=`${(r||``).replace(/\.gcode\.3mf$/i,``).replace(/\.3mf$/i,``)||`Batch`} · ${p.length} plates`;w=(await Q.createBatch({name:e,archive_id:m?void 0:t,library_file_id:m?n:void 0})).id}catch{w=null}let E=(e,r)=>({printer_id:j===`printer`?e:null,target_model:j===`model`?N:null,target_location:j===`model`?F:null,filament_overrides:j===`model`?x:void 0,archive_id:m?void 0:t,library_file_id:m?n:void 0,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,skip_filament_check:a?.skipFilamentCheck===!0?!0:void 0,ams_mapping:e?y(e):void 0,plate_id:r===void 0?b:r,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():void 0,...C,project_id:c??void 0,batch_id:w??void 0});if(j===`model`){if(e===`reprint`){f(`Model-based assignment only works with queue mode`,`error`),ne(!1);return}let t=0;for(let n of p){t++,ie({current:t,total:g});let r=n?n.index:b;try{if(e===`edit-queue-item`&&!n){let e={printer_id:null,target_model:N,target_location:F,filament_overrides:x||null,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,ams_mapping:void 0,plate_id:r,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():null,...C};await Ge.mutateAsync(e)}else{let e=E(null,r);Xe>1&&(e.quantity=Xe),await We.mutateAsync(e)}v.success++}catch(e){v.failed++;let t=n?n.name||`Plate ${n.index}`:``;v.errors.push(t?`${t}: ${e.message}`:e.message)}}}else{let r=T.staggerEnabled&&(e===`add-to-queue`||e===`reprint`)&&h.length>1,i=r?T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).getTime():Date.now():0,a=0;for(let o of p){let s=o?o.index:b;for(let u=0;u1){let e=E(d,s);e.quantity=Xe,await We.mutateAsync(e)}else if(m?await Q.printLibraryFile(n,d,{plate_id:b??void 0,plate_name:je,ams_mapping:e,...C,project_id:c,cleanup_library_after_dispatch:l}):await Q.reprintArchive(t,d,{plate_id:b??void 0,plate_name:je,ams_mapping:e,...C}),Xe>1){let e=E(d,s);e.quantity=Xe-1,await We.mutateAsync(e)}}else if(e===`edit-queue-item`&&a===1){let e=y(d),t={printer_id:d,target_model:null,target_location:null,require_previous_success:T.requirePreviousSuccess,auto_off_after:T.autoOffAfter,gcode_injection:T.gcodeInjection,manual_start:T.scheduleType===`manual`,ams_mapping:e,plate_id:s,scheduled_time:T.scheduleType===`scheduled`&&T.scheduledTime?new Date(T.scheduledTime).toISOString():null,...C};await Ge.mutateAsync(t)}else{let e=E(d,s);if(Xe>1&&(e.quantity=Xe),r){let t=Math.floor(u/T.staggerGroupSize);if(t>0){let n=t*T.staggerIntervalMinutes*6e4;e.scheduled_time=new Date(i+n).toISOString()}}await We.mutateAsync(e)}v.success++}catch(e){v.failed++;let t=me?.find(e=>e.id===d)?.name||`Printer ${d}`,n=o?o.name||`Plate ${o.index}`:``,r=n?`${t} (${n})`:t;v.errors.push(`${r}: ${e.message}`)}}}}ne(!1),v.failed===0?(e===`reprint`&&Ke?f(u(`queue.itemsQueued`,{count:v.success})):e!==`reprint`&&(e===`edit-queue-item`?f(`Queue item updated`):v.success===1?f(j===`model`?`Queued for any ${N}`:u(`queue.printQueued`)):f(u(`queue.itemsQueued`,{count:v.success}))),d.invalidateQueries({queryKey:[`queue`]}),s?.(),o()):v.success===0?f(`Failed: ${v.errors[0]}`,`error`):(f(`${v.success} succeeded, ${v.failed} failed`,`error`),d.invalidateQueries({queryKey:[`queue`]}))},Je=te||Ge.isPending,Ye=(0,y.useMemo)(()=>!(Je||j===`printer`&&h.length===0||j===`model`&&!N||j===`model`&&e===`reprint`||Be&&_.size===0),[h.length,j,N,e,Be,_.size,Je]),Xe=j===`printer`&&h.length>1?1:x;(0,y.useEffect)(()=>{e===`reprint`&&T.gcodeInjection&&(Xe<=1||!le?.gcode_snippets)&&E(e=>({...e,gcodeInjection:!1}))},[e,Xe,le?.gcode_snippets,T.gcodeInjection]);let Ze=(()=>{let t=h.length;if(e===`reprint`){let e=Ke&&t>1,n=e?u(`printModal.staggerToPrinters`,{count:t,defaultValue:`Stagger to {{count}} printers`}):t>1?u(`queue.printToPrinters`,{count:t}):u(`queue.print`);return Xe>1&&(n=`${n} ×${Xe}`),{title:u(m?`queue.print`:`queue.reprint`),icon:Tl,submitText:n,submitIcon:e?Zo:Tl,loadingText:re.total>1?u(`queue.sendingProgress`,{current:re.current,total:re.total}):u(`queue.sending`)}}if(e===`add-to-queue`){let e=u(`queue.addToQueue`);return _.size>1?e=u(`queue.queueSelectedPlates`,{count:_.size}):t>1&&(e=u(`queue.queueToPrinters`,{count:t})),Xe>1&&(e=`${e} ×${Xe}`),{title:u(`queue.schedulePrint`),icon:Zo,submitText:e,submitIcon:Zo,loadingText:re.total>1?u(`queue.addingProgress`,{current:re.current,total:re.total}):u(`queue.adding`)}}return{title:u(`queue.editQueueItem`),icon:vl,submitText:u(`common.save`),submitIcon:vl,loadingText:re.total>1?u(`queue.savingProgress`,{current:re.current,total:re.total}):u(`common.saving`)}})(),Qe=Ze.icon,$e=Ze.submitIcon,et=ce&&_.size<=1&&(m||(Be?b!==null:!0)),tt=(0,y.useMemo)(()=>new Set([`H2D`,`H2DPRO`,`H2C`,`X2D`]),[]),nt=(0,y.useMemo)(()=>j===`model`?N?tt.has(N.toUpperCase().replace(/[\s-]/g,``)):!1:!me||h.length===0?!1:h.some(e=>me.find(t=>t.id===e)?.nozzle_count===2),[j,N,me,h,tt]);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:te?void 0:o,children:[(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:e===`reprint`?``:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${e===`reprint`?`mb-4`:`p-4 border-b border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Qe,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:Ze.title})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:o,disabled:te,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:qe,className:e===`reprint`?``:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray ${e===`reprint`?`mb-4`:``}`,children:e===`reprint`?(0,K.jsxs)(K.Fragment,{children:[`Send `,(0,K.jsx)(`span`,{className:`text-white`,children:r}),` to`,` `,a?.length===1&&me?(0,K.jsx)(`span`,{className:`text-white`,children:me.find(e=>e.id===a[0])?.name??`printer(s)`}):`printer(s)`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`block text-bambu-gray mb-1`,children:`Print Job`}),(0,K.jsx)(`span`,{className:`text-white font-medium truncate block`,children:r})]})}),(()=>{if(!Ve.length)return null;let e=$U((b==null?Ve[0]:Ve.find(e=>e.index===b))?.bed_type);return e?(0,K.jsxs)(`p`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray -mt-2`,title:e.label,children:[(0,K.jsx)(`img`,{src:e.icon,alt:``,className:`w-4 h-4 object-contain flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.label})]}):null})(),(0,K.jsx)(uke,{plates:Ve,isMultiPlate:Be,selectedPlates:_,onToggle:t=>{v(n=>{let r=new Set(n);return e===`add-to-queue`?r.has(t)?r.delete(t):r.add(t):(r.clear(),r.add(t)),r})},onSelectAll:e===`add-to-queue`?()=>v(new Set(Ve.map(e=>e.index))):void 0,onDeselectAll:e===`add-to-queue`?()=>v(new Set):void 0,multiSelect:e===`add-to-queue`}),!a?.length&&(0,K.jsx)(vke,{printers:me||[],selectedPrinterIds:h,onMultiSelect:g,isLoading:he,allowMultiple:!0,showInactive:e===`edit-queue-item`,disableBusy:e===`reprint`,printerMappingResults:Fe.printerResults,filamentReqs:Ae,onAutoConfigurePrinter:Fe.autoConfigurePrinter,onUpdatePrinterConfig:Fe.updatePrinterConfig,assignmentMode:e===`reprint`?`printer`:j,onAssignmentModeChange:e===`reprint`?void 0:M,targetModel:N,onTargetModelChange:e===`reprint`?void 0:P,targetLocation:F,onTargetLocationChange:e===`reprint`?void 0:I,slicedForModel:xe}),j===`model`&&N&&Ae&&Me&&Me.length>0&&(0,K.jsx)(lke,{filamentReqs:Ae,availableFilaments:Me,overrides:L,onChange:R,forceColorMatch:z,onForceColorMatchChange:(e,t)=>B(n=>({...n,[e]:t}))}),xe&&j===`printer`&&h.length===1&&(()=>{let e=me?.find(e=>e.id===h[0]);return e&&e.model&&xe!==e.model?(0,K.jsxs)(`div`,{className:`p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`span`,{className:`text-sm text-yellow-400`,children:[`File was sliced for `,xe,`, but printing on `,e.model]})]}):null})(),ke&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-orange-400`,children:`Archive data unavailable. The source file may have been deleted. Filament mapping is disabled.`})]}),et&&!ke&&h.length===1&&(0,K.jsx)(cke,{printerId:ce,filamentReqs:Ae,manualMappings:D,onManualMappingChange:O,defaultExpanded:!!a?.length||(le?.per_printer_mapping_expanded??!1),currencySymbol:fe,defaultCostPerKg:pe,forceColorMatch:z,onForceColorMatchChange:(e,t)=>B(n=>({...n,[e]:t}))}),(e===`reprint`||se>0||j===`model`&&N)&&(0,K.jsx)(yke,{options:C,onChange:w,defaultExpanded:!!a?.length,showDualNozzleOptions:nt}),e!==`edit-queue-item`&&(j===`model`||h.length<=1)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`label`,{htmlFor:`printQuantity`,className:`text-sm text-bambu-gray whitespace-nowrap`,children:u(`queue.quantity`,`Quantity`)}),(0,K.jsx)(`input`,{id:`printQuantity`,type:`number`,min:1,max:999,value:x,onChange:e=>S(Math.max(1,Math.min(999,parseInt(e.target.value)||1))),className:`w-20 px-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green`}),x>1&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:u(`queue.quantityHint`,`Creates {{count}} queue items`,{count:x})})]}),e===`reprint`&&j===`printer`&&h.length>1&&(0,K.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`staggerEnabledReprint`,checked:T.staggerEnabled,onChange:e=>E({...T,staggerEnabled:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`staggerEnabledReprint`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5`}),u(`printModal.staggerPrinterStarts`,`Stagger printer starts`)]})]}),T.staggerEnabled&&(()=>{let e=T.staggerGroupSize,t=T.staggerIntervalMinutes,n=Math.ceil(h.length/e),r=(n-1)*t;return(0,K.jsxs)(`p`,{className:`ml-6 text-xs text-bambu-gray`,children:[u(`printModal.staggerPreview`,`{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min`,{printers:h.length,groups:n,size:e,interval:t}),n>1?` (${u(`printModal.staggerTotal`,`total: {{minutes}} min`,{minutes:r})})`:``]})})()]}),e!==`reprint`&&(0,K.jsx)(bke,{options:T,onChange:E,dateFormat:le?.date_format||`system`,timeFormat:le?.time_format||`system`,canControlPrinter:p(`printers:control`),showStagger:e===`add-to-queue`&&j===`printer`&&h.length>1,printerCount:h.length,hasGcodeSnippets:!!le?.gcode_snippets}),e===`reprint`&&!!le?.gcode_snippets&&Xe>1&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`gcodeInjectionReprint`,checked:T.gcodeInjection,onChange:e=>E({...T,gcodeInjection:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`label`,{htmlFor:`gcodeInjectionReprint`,className:`text-sm flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Es,{className:`w-3.5 h-3.5`}),u(`printModal.gcodeInjection`,`Inject auto-print G-code`)]})]}),Ge.isError&&(0,K.jsx)(`div`,{className:`mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:Ge.error?.message||`Failed to complete operation`}),(0,K.jsxs)(`div`,{className:`flex gap-3 ${e===`reprint`?``:`pt-2`}`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:o,className:`flex-1`,disabled:te,children:`Cancel`}),(0,K.jsx)($,{type:`submit`,disabled:!Ye,className:`flex-1`,children:Je?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),Ze.loadingText]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($e,{className:`w-4 h-4`}),Ze.submitText]})})]})]})]})}),H&&H.length>0&&(0,K.jsx)(Ad,{title:u(`printModal.insufficientFilamentTitle`),message:Ue,confirmText:u(`printModal.printAnyway`),cancelText:u(`common.cancel`),variant:`warning`,onConfirm:()=>{ae(null),qe(void 0,{skipFilamentCheck:!0})},onCancel:()=>ae(null)})]})}function cW({value:e}){let{t}=W(),[n,r]=(0,y.useState)(!1);return(0,K.jsx)(`button`,{onClick:async()=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{if(t.select(),!document.execCommand(`copy`))return}finally{document.body.removeChild(t)}}r(!0),setTimeout(()=>r(!1),2e3)}catch{}},className:`ml-2 p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:t(n?`printers.copied`:`printers.copyToClipboard`),children:n?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})}function xke({printer:e,status:t,totalPrintHours:n,onClose:r}){let{t:i}=W();(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let a=[];if(a.push({label:i(`printers.model`),value:e.model??`—`}),a.push({label:i(`common.status`),value:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${t?.connected?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${t?.connected?`bg-bambu-green`:`bg-red-400`}`}),t?.connected?i(`printers.status.available`):i(`printers.status.offline`)]})}),t?.state&&a.push({label:i(`printers.state`),value:i({IDLE:`printers.status.idle`,RUNNING:`printers.status.printing`,PAUSE:`printers.status.paused`,FINISH:`printers.status.finished`,FAILED:`printers.status.error`}[t.state]??`printers.status.unknown`)}),a.push({label:i(`printers.ipAddress`),value:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[(0,K.jsx)(`span`,{className:`font-mono`,children:e.ip_address}),(0,K.jsx)(cW,{value:e.ip_address})]})}),a.push({label:i(`printers.serialNumber`),value:(0,K.jsxs)(`span`,{className:`flex items-center`,children:[(0,K.jsx)(`span`,{className:`font-mono truncate`,children:e.serial_number}),(0,K.jsx)(cW,{value:e.serial_number})]})}),t?.wired_network)a.push({label:i(`printers.networkLabel`,`Network`),value:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(qo,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-bambu-green`,children:i(`printers.connection.ethernet`,`Ethernet`)})]})});else if(t?.wifi_signal!=null){let e=mT(t.wifi_signal);a.push({label:i(`printers.wifiSignalLabel`),value:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Yl,{className:`w-4 h-4 ${e.color}`}),(0,K.jsx)(`span`,{className:e.color,children:i(e.labelKey)}),(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,t.wifi_signal,` dBm)`]})]})})}return a.push({label:i(`printers.firmware`),value:t?.firmware_version??`—`}),t?.developer_mode!=null&&a.push({label:i(`printers.developerMode`),value:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.developer_mode?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:t.developer_mode?i(`printers.enabled`):i(`printers.disabled`)})}),a.push({label:i(`printers.nozzleCount`),value:e.nozzle_count}),a.push({label:i(`printers.autoArchive`),value:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.auto_archive?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:e.auto_archive?i(`printers.enabled`):i(`printers.disabled`)})}),n!=null&&n>0&&a.push({label:i(`printers.totalPrintHours`),value:`${Math.round(n)}h`}),e.location&&a.push({label:i(`printers.sort.location`),value:e.location}),a.push({label:i(`printers.addedOn`),value:yf(e.created_at)}),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,role:`dialog`,"aria-modal":`true`,onClick:r,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e.name}),(0,K.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-bambu-dark rounded flex-shrink-0`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,K.jsx)(`img`,{src:pT(e.model),alt:e.model??e.name,className:`h-24 object-contain`})}),(0,K.jsx)(`div`,{className:`space-y-0`,children:a.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray whitespace-nowrap`,children:e.label}),(0,K.jsx)(`span`,{className:`text-sm text-white text-right`,children:e.value})]},t))})]})})})}function Ske(e){if(!e||e.length<6)return!1;let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return(.299*t+.587*n+.114*r)/255>.6}function lW({trayColor:e,trayType:t,isEmpty:n,emptyKind:r,slotNumber:i}){let a=r===`reset`?`#3d3d3d`:`#666`;return(0,K.jsx)(`div`,{className:`w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2 flex items-center justify-center`,style:{backgroundColor:e?`#${e}`:t?`#333`:`transparent`,borderColor:n?a:`rgba(255,255,255,0.1)`,borderStyle:n?`dashed`:`solid`},children:(0,K.jsx)(`span`,{className:`text-[6px] font-bold leading-none select-none`,style:{color:e&&Ske(e)?`#000`:`#fff`},children:i})})}var uW=240,dW=320;function fW(e){return(e??.02).toFixed(3)}function pW({side:e}){let{mode:t}=md();return(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded`,style:{backgroundColor:t===`dark`?`#1a4d2e`:`#e7f5e9`,color:`#00ae42`},children:e})}function mW(e,t){if(!e)return``;if(e.includes(`hardened`))return t(`printers.nozzleHardenedSteel`);if(e.includes(`stainless`))return t(`printers.nozzleStainlessSteel`);if(e.includes(`tungsten`))return t(`printers.nozzleTungstenCarbide`);if(e.length>=4){let n=e.slice(2,4);if(n===`00`)return t(`printers.nozzleStainlessSteel`);if(n===`01`)return t(`printers.nozzleHardenedSteel`);if(n===`05`)return t(`printers.nozzleTungstenCarbide`)}return e===`00`?t(`printers.nozzleStainlessSteel`):e===`01`?t(`printers.nozzleHardenedSteel`):e===`05`?t(`printers.nozzleTungstenCarbide`):e.startsWith(`H`)?t(`printers.nozzleHardenedSteel`):e}function hW(e,t){return e?e.startsWith(`HH`)?t(`printers.nozzleHighFlow`):e.startsWith(`HS`)?t(`printers.nozzleStandardFlow`):``:``}function gW({slot:e,index:t,activeStatus:n,filamentName:r,children:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(`top`),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null),p=!e.nozzle_diameter&&!e.nozzle_type,m=e.stat===1;(0,y.useEffect)(()=>{if(o&&u.current&&d.current){let e=u.current.getBoundingClientRect(),t=d.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;nn?l(`bottom`):l(`top`)}},[o]);let h=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!0),80)},g=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!1),100)};(0,y.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]);let _=Yd(e.filament_color),v=mW(e.nozzle_type,a),b=hW(e.nozzle_type,a);return(0,K.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:h,onMouseLeave:g,children:[i,o&&(0,K.jsxs)(`div`,{ref:d,className:` absolute left-1/2 -translate-x-1/2 z-50 ${c===`top`?`bottom-full mb-2`:`top-full mt-2`} animate-in fade-in-0 zoom-in-95 duration-150 @@ -8518,7 +8518,7 @@ void main() { border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent ${c===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`} - `})]})]})}function wke({leftSlot:e,rightSlot:t,activeNozzle:n,filamentInfo:r,children:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(`top`),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(o&&u.current&&d.current){let e=u.current.getBoundingClientRect(),t=d.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;nn?l(`bottom`):l(`top`)}},[o]);let p=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!0),80)},m=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!1),100)};if((0,y.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),!e&&!t)return(0,K.jsx)(K.Fragment,{children:i});let h=(e,t)=>{let i=n===t,o=pW(e.nozzle_type,a),s=mW(e.nozzle_type,a),c=Yd(e.filament_color),l=e.filament_id?r?.[e.filament_id]?.name:void 0;return(0,K.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-bold pb-1 border-b border-bambu-dark-tertiary/50 ${i?`text-amber-400`:`text-bambu-gray`}`,children:a(t===`L`?`common.left`:`common.right`)}),e.nozzle_diameter&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleDiameter`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.nozzle_diameter,` mm`]})]}),o&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleType`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold`,children:o})]}),s&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleFlow`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold`,children:s})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleStatus`)}),(0,K.jsx)(`span`,{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${i?`bg-green-900/50 text-green-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:a(i?`printers.nozzleActive`:`printers.nozzleIdle`)})]}),e.wear!=null&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleWear`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.wear,`%`]})]}),t===`R`&&e.max_temp>0&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleMaxTemp`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.max_temp,`°C`]})]}),t===`R`&&e.serial_number&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleSerial`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono`,children:e.serial_number})]}),(c||e.filament_type||e.filament_id)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleFilament`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[c&&(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-sm border border-white/20`,style:{backgroundColor:c}}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold truncate max-w-[100px]`,children:l||e.filament_type||e.filament_id||``})]})]})]})};return(0,K.jsxs)(`div`,{ref:u,className:`relative flex-1`,onMouseEnter:p,onMouseLeave:m,children:[i,o&&(0,K.jsxs)(`div`,{ref:d,className:` + `})]})]})}function Cke({leftSlot:e,rightSlot:t,activeNozzle:n,filamentInfo:r,children:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(`top`),u=(0,y.useRef)(null),d=(0,y.useRef)(null),f=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(o&&u.current&&d.current){let e=u.current.getBoundingClientRect(),t=d.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;nn?l(`bottom`):l(`top`)}},[o]);let p=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!0),80)},m=()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>s(!1),100)};if((0,y.useEffect)(()=>()=>{f.current&&clearTimeout(f.current)},[]),!e&&!t)return(0,K.jsx)(K.Fragment,{children:i});let h=(e,t)=>{let i=n===t,o=mW(e.nozzle_type,a),s=hW(e.nozzle_type,a),c=Yd(e.filament_color),l=e.filament_id?r?.[e.filament_id]?.name:void 0;return(0,K.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`text-[10px] font-bold pb-1 border-b border-bambu-dark-tertiary/50 ${i?`text-amber-400`:`text-bambu-gray`}`,children:a(t===`L`?`common.left`:`common.right`)}),e.nozzle_diameter&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleDiameter`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.nozzle_diameter,` mm`]})]}),o&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleType`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold`,children:o})]}),s&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleFlow`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold`,children:s})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleStatus`)}),(0,K.jsx)(`span`,{className:`text-[10px] font-bold px-1.5 py-0.5 rounded ${i?`bg-green-900/50 text-green-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:a(i?`printers.nozzleActive`:`printers.nozzleIdle`)})]}),e.wear!=null&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleWear`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.wear,`%`]})]}),t===`R`&&e.max_temp>0&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleMaxTemp`)}),(0,K.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.max_temp,`°C`]})]}),t===`R`&&e.serial_number&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleSerial`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono`,children:e.serial_number})]}),(c||e.filament_type||e.filament_id)&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:a(`printers.nozzleFilament`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[c&&(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-sm border border-white/20`,style:{backgroundColor:c}}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-semibold truncate max-w-[100px]`,children:l||e.filament_type||e.filament_id||``})]})]})]})};return(0,K.jsxs)(`div`,{ref:u,className:`relative flex-1`,onMouseEnter:p,onMouseLeave:m,children:[i,o&&(0,K.jsxs)(`div`,{ref:d,className:` absolute left-1/2 -translate-x-1/2 z-50 ${c===`top`?`bottom-full mb-2`:`top-full mt-2`} animate-in fade-in-0 zoom-in-95 duration-150 @@ -8527,31 +8527,31 @@ void main() { border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent ${c===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`} - `})]})]})}function Tke({slots:e,filamentInfo:t}){let{t:n}=W(),r=e.filter(e=>e.id>=2),i=Array.from({length:6},(e,t)=>r.find(e=>e.id===16+t)??{id:-(t+1),nozzle_type:``,nozzle_diameter:``,wear:null,stat:null,max_temp:0,serial_number:``,filament_color:``,filament_id:``,filament_type:``});return(0,K.jsxs)(`div`,{className:`text-center px-2.5 py-1.5 bg-bambu-dark rounded-lg flex-[2_1_190px] flex flex-col justify-center`,children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray mb-1`,children:n(`printers.nozzleRack`)}),(0,K.jsx)(`div`,{className:`flex gap-[3px] justify-center`,children:i.map((e,n)=>{let r=!e.nozzle_diameter&&!e.nozzle_type,i=r?null:Yd(e.filament_color),a=i?Xd(e.filament_color):!1;return(0,K.jsx)(hW,{slot:e,index:n,filamentName:e.filament_id?t?.[e.filament_id]?.name:void 0,children:(0,K.jsx)(`div`,{className:`w-7 h-7 rounded flex items-center justify-center cursor-default transition-colors border-b-2 ${r?`bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20`:`bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40`}`,style:i?{backgroundColor:i}:void 0,children:(0,K.jsx)(`span`,{className:`text-[10px] font-semibold ${r?`text-bambu-gray/30`:a?`text-black/80`:`text-white`}`,style:i&&!a?{textShadow:`0 1px 3px rgba(0,0,0,0.9)`}:void 0,children:r?`—`:e.nozzle_diameter||`?`})})},e.id>=0?e.id:`empty-${n}`)})})]})}function Eke({className:e}){return(0,K.jsx)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{d:`M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z`,fill:`#C3C2C1`})})}function Dke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 35 53`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z`,fill:`#C3C2C1`}),(0,K.jsx)(`path`,{d:`M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z`,fill:`#1F8FEB`})]})}function Oke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z`,fill:`#1F8FEB`}),(0,K.jsx)(`path`,{d:`M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z`,fill:`#C3C2C1`})]})}function kke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function Ake({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`8`,width:`3`,height:`4.5`,fill:`#d4a017`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#d4a017`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function jke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:`#c62828`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#c62828`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function Mke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`rect`,{x:`9.2`,y:`3.4`,width:`5.6`,height:`8.1`}),(0,K.jsx)(`rect`,{x:`6`,y:`11.5`,width:`12.1`,height:`3.7`}),(0,K.jsx)(`path`,{d:`M 7.3 15.2 L 12.1 19.6 L 16.7 15.2`})]})}function gW({className:e,color:t,isHeating:n}){let r={"text-orange-400":`#fb923c`,"text-blue-400":`#60a5fa`,"text-green-400":`#4ade80`}[t]||`#888`,i=n?{filter:`drop-shadow(0 0 4px ${r}) drop-shadow(0 0 8px ${r})`}:{};return n?(0,K.jsxs)(`svg`,{className:e,style:i,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:r,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:r}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`})]}):(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:r,strokeWidth:`1`,fill:`none`})]})}function Nke({state:e,onClick:t}){let{t:n}=W(),r=e!==null,i=`flex items-center justify-center w-[18px] h-[18px] rounded text-[10px] transition-colors `,a;return e===!0?(i+=r?`bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 cursor-pointer`:`bg-blue-500/20 text-blue-400 cursor-default`,a=n(`printers.amsBackup.titleOn`)):e===!1?(i+=r?`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80 cursor-pointer`:`bg-bambu-dark text-bambu-gray cursor-default`,a=n(`printers.amsBackup.titleOff`)):(i+=`bg-bambu-dark text-bambu-gray/50 cursor-default`,a=n(`printers.amsBackup.titleUnknown`)),(0,K.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&t(),className:i,title:a,"aria-label":a,children:r?(0,K.jsx)(kl,{className:`w-3 h-3`}):(0,K.jsx)(`span`,{children:`?`})})}function _W({humidity:e,goodThreshold:t=40,fairThreshold:n=60,onClick:r,compact:i}){let a=typeof e==`string`?parseInt(e,10):e,o=typeof t==`number`?t:40,s=typeof n==`number`?n:60,c,l;isNaN(a)?(c=`#C3C2C1`,l=`Unknown`):a<=o?(c=`#22a352`,l=`Good`):a<=s?(c=`#d4a017`,l=`Fair`):(c=`#c62828`,l=`Bad`);let u;return u=isNaN(a)||a<=o?Eke:a<=s?Dke:Oke,(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Humidity: ${a}% - ${l}${r?` (click for history)`:``}`,children:[(0,K.jsx)(u,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums ${i?`text-[10px]`:`text-xs`}`,style:{color:c},children:[a,`%`]})]})}function vW({temp:e,goodThreshold:t=28,fairThreshold:n=35,onClick:r,compact:i}){let a=typeof t==`number`?t:28,o=typeof n==`number`?n:35,s,c,l;return e<=a?(s=`#22a352`,c=`Good`,l=kke):e<=o?(s=`#d4a017`,c=`Fair`,l=Ake):(s=`#c62828`,c=`Bad`,l=jke),(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Temperature: ${e}°C - ${c}${r?` (click for history)`:``}`,children:[(0,K.jsx)(l,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,K.jsxs)(`span`,{className:`tabular-nums text-right ${i?`text-[10px] w-8`:`w-12`}`,style:{color:s},children:[e,`°C`]})]})}function yW(e){return e?.tray_type?null:e?.state===9||e?.state===10?`physical`:`reset`}function Pke({url:e,printName:t,className:n=`w-20 h-20`,radiusClass:r=`rounded-lg`}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),d=(0,y.useMemo)(()=>e?Xu(`${e}${e.includes(`?`)?`&`:`?`}v=${encodeURIComponent(t||Date.now().toString())}`):null,[e,t]);return(0,y.useEffect)(()=>{o(!1),c(!1)},[d]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`${n} flex-shrink-0 ${r} overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${d&&a?`cursor-pointer`:``}`,onClick:()=>d&&a&&u(!0),children:d&&!s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:d,alt:i(`printers.printPreview`),className:`w-full h-full object-cover ${a?`block`:`hidden`}`,onLoad:()=>o(!0),onError:()=>c(!0)}),!a&&(0,K.jsx)(Wo,{className:`w-8 h-8 text-bambu-gray`})]}):(0,K.jsx)(Wo,{className:`w-8 h-8 text-bambu-gray`})}),l&&d&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8`,onClick:()=>u(!1),children:(0,K.jsxs)(`div`,{className:`relative max-w-2xl max-h-full`,children:[(0,K.jsx)(`img`,{src:d,alt:i(`printers.printPreview`),className:`max-w-full max-h-[80vh] rounded-lg shadow-2xl`}),t&&(0,K.jsx)(`p`,{className:`text-white text-center mt-4 text-lg`,children:t})]})})]})}function Fke({printers:e}){let{t}=W(),n=no(),[r,i]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=!1,t=n.getQueryCache().subscribe(()=>{e||(e=!0,requestAnimationFrame(()=>{i(e=>e+1),e=!1}))});return()=>t()},[n]);let{counts:a,nextFinish:o}=(0,y.useMemo)(()=>{let t=0,r=0,i=0,a=0,o=0,s=0,c=0,l=null,u=null,d=0;return e?.forEach(e=>{let f=n.getQueryData([`printerStatus`,e.id]);if(f===void 0)s++;else if(!f.connected)o++;else{let n=f.hms_errors?Vp(f.hms_errors).length:0;switch(n>0&&c++,f.state){case`RUNNING`:t++,f.remaining_time!=null&&f.remaining_time>0&&(u===null||f.remaining_time0||i++;break;default:a++;break}}}),{counts:{printing:t,paused:r,finished:i,idle:a,offline:o,loading:s,error:c,total:e?.length||0},nextFinish:l&&u?{name:l,remainingMin:u,progress:d}:null}},[e,n,r]);return e?.length?(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-4 gap-y-2 text-bambu-gray`,children:[[{count:a.printing,dot:`bg-bambu-green animate-pulse`,label:t(`printers.status.printing`).toLowerCase()},{count:a.paused,dot:`bg-status-warning`,label:t(`printers.status.paused`,`paused`).toLowerCase()},{count:a.finished,dot:`bg-blue-400`,label:t(`printers.status.finished`,`finished`).toLowerCase()},{count:a.idle,dot:a.idle>0?`bg-bambu-green`:`bg-gray-500`,label:t(`printers.status.available`).toLowerCase()},{count:a.error,dot:`bg-status-error`,label:t(`printers.status.problem`).toLowerCase()},{count:a.offline,dot:`bg-gray-400`,label:t(`printers.status.offline`).toLowerCase()}].map(({count:e,dot:t,label:n})=>e>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t}`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:e}),` `,n]})]},n)),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-px h-4 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,children:[t(`printers.nextAvailable`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:o.name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 w-full sm:w-auto`,children:[(0,K.jsx)(`div`,{className:`w-full sm:w-16 bg-bambu-dark-tertiary rounded-full h-1.5`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-1.5 rounded-full transition-all`,style:{width:`${o.progress}%`}})}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[Math.round(o.progress),`%`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,Cf(o.remainingMin*60),`)`]})]})]})]})]}):null}function bW({value:e,options:t,onChange:n,fullWidth:r=!1}){let[i,a]=(0,y.useState)(!1),o=t.find(t=>t.value===e)??t[0];return(0,K.jsxs)(`div`,{className:`relative ${r?`w-full min-w-0`:``}`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`h-8 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white text-sm font-medium transition-colors hover:bg-bambu-dark-tertiary focus:outline-none focus:border-bambu-green flex items-center justify-between gap-2 ${r?`w-full`:`min-w-28`}`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:o?.label}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,K.jsx)(`div`,{className:`absolute left-0 top-full z-20 mt-1 min-w-full rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary py-1 shadow-xl`,children:t.map(t=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>{n(t.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-bambu-dark-tertiary ${t.value===e?`text-bambu-green`:`text-white`}`,children:t.label},t.value))})]})]})}function xW({label:e,icon:t,children:n}){let[r,i]=(0,y.useState)(!1);return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`h-8 w-8 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,"aria-label":e,title:e,children:t}),r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,K.jsx)(`div`,{className:`absolute right-0 top-full z-20 mt-1 min-w-40 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary p-2 shadow-xl`,children:n})]})]})}function SW({title:e,options:t=[],unit:n,customMin:r,customMax:i,customStep:a=1,widthClass:o=`w-[240px]`,popoverWidth:s=240,popoverHeight:c=280,isPending:l,onClose:u,onSubmit:d,children:f}){let p=(0,y.useRef)(null),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(``);(0,y.useLayoutEffect)(()=>{let e=p.current?.parentElement;if(!e)return;let t=()=>{h(jp({triggerRect:e.getBoundingClientRect(),popoverWidth:s,estimatedHeight:c,horizontalAlign:`center`}))};return t(),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[s,c]);let v=n!==void 0,b=()=>{let e=Number(g);Number.isFinite(e)&&d?.(Math.round(Math.min(i??e,Math.max(r??e,e))))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{ref:p,className:`hidden`,"aria-hidden":`true`}),(0,Op.createPortal)((0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[1000]`,onClick:u}),(0,K.jsxs)(`div`,{className:`fixed z-[1001] flex ${o} flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,style:{top:m?.top??-9999,left:m?.left??-9999,visibility:m?`visible`:`hidden`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:e}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),t.length>0&&(0,K.jsx)(`div`,{className:`px-3 py-2.5`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:t.map(e=>(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>d?.(e.value),className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:e.label},`${e.label}-${e.value}`))})}),f,v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`form`,{className:`flex gap-1.5 px-3 pt-2.5 pb-3`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,K.jsx)(`input`,{type:`number`,min:r,max:i,step:a,value:g,onChange:e=>_(e.target.value),placeholder:`Custom`,className:`h-8 min-w-0 flex-1 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{type:`submit`,disabled:l||g.trim()===``,className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})]})]}),document.body)]})}var Ike=Rp(Mp,`C`);function CW({label:e,current:t,target:n,isActive:r,isPending:i,onSubmit:a,options:o=Ike}){let[s,c]=(0,y.useState)(``),l=()=>{let e=Number(s);Number.isFinite(e)&&a(Math.min(320,Math.max(0,Math.round(e))))};return(0,K.jsxs)(`div`,{className:`rounded-lg border p-2 ${r?`border-amber-400/60 bg-amber-400/10`:`border-bambu-dark-tertiary bg-bambu-dark`}`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium ${r?`text-amber-300`:`text-white`}`,children:e}),(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray`,children:[Math.round(t??0),`°C`,n===void 0?``:` / ${Math.round(n)}°`]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:o.map(t=>(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>a(t.value),className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:t.label},`${e}-${t.value}`))}),(0,K.jsxs)(`form`,{className:`mt-1.5 flex gap-1`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:320,step:1,value:s,onChange:e=>c(e.target.value),placeholder:`Custom`,className:`h-7 min-w-0 flex-1 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{type:`submit`,disabled:i||s.trim()===``,className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-2 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})}var Lke=[`error`,`printing`,`paused`,`finished`,`idle`,`offline`],wW={error:{labelKey:`printers.status.problem`,dot:`bg-status-error`},printing:{labelKey:`printers.status.printing`,dot:`bg-bambu-green animate-pulse`},paused:{labelKey:`printers.status.paused`,dot:`bg-status-warning`},finished:{labelKey:`printers.status.finished`,dot:`bg-blue-400`},idle:{labelKey:`printers.status.idle`,dot:`bg-bambu-green`},offline:{labelKey:`printers.status.offline`,dot:`bg-gray-400`}};function TW(e){if(!e?.connected)return`offline`;if((e.hms_errors?Vp(e.hms_errors):[]).length>0)return`error`;switch(e.state){case`RUNNING`:return`printing`;case`PAUSE`:return`paused`;case`FINISH`:return`finished`;case`FAILED`:return`finished`;default:return`idle`}}function Rke(e,t){if(t)return t;switch(e){case`RUNNING`:return`Printing`;case`PAUSE`:return`Paused`;case`FINISH`:return`Finished`;case`FAILED`:return`Failed`;case`IDLE`:return`Idle`;default:return e?e.charAt(0)+e.slice(1).toLowerCase():`Idle`}}var zke=new Set([`X1C`,`X1`,`X1E`,`X2D`,`P1S`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`]);function EW(e){return e?{O1D:`H2D`,O1E:`H2D Pro`,O2D:`H2D Pro`,O1C:`H2C`,O1C2:`H2C`,O1S:`H2S`,"BL-P001":`X1C`,"BL-P002":`X1`,"BL-P003":`X1E`,N6:`X2D`,N9:`A2L`,C11:`P1S`,C12:`P1P`,C13:`P2S`,N2S:`A1`,N1:`A1 Mini`,X1C:`X1C`,X1:`X1`,X1E:`X1E`,X2D:`X2D`,P1S:`P1S`,P1P:`P1P`,P2S:`P2S`,A1:`A1`,"A1 Mini":`A1 Mini`,A2L:`A2L`,H2D:`H2D`,"H2D Pro":`H2D Pro`,H2C:`H2C`,H2S:`H2S`}[e]||e:``}function DW({ams:e,printerId:t,label:n,amsLabels:r,canEdit:i,onSaved:a,children:o}){let{t:s}=W(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(`top`),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),x=(0,y.useRef)(null),S=(0,y.useRef)(null),C=(0,y.useRef)(null);(0,y.useEffect)(()=>{c&&(p(r?.[e.id]??``),_(null),requestAnimationFrame(()=>{if(x.current&&S.current){let e=x.current.getBoundingClientRect(),t=e.top-56,n=window.innerHeight-e.bottom;d(tt?`bottom`:`top`)}}))},[c,r,e.id]);let w=()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>l(!0),80)},T=()=>{C.current&&clearTimeout(C.current),v||(C.current=setTimeout(()=>l(!1),200))};(0,y.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]);let E=async()=>{if(i){h(!0),_(null);try{let n=f.trim();n?await Q.saveAmsLabel(t,e.id,n,e.serial_number):await Q.deleteAmsLabel(t,e.id,e.serial_number),a(),l(!1)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,K.jsxs)(`div`,{ref:x,className:`relative inline-block`,onMouseEnter:w,onMouseLeave:T,children:[o,c&&(0,K.jsx)(`div`,{ref:S,className:` + `})]})]})}function wke({slots:e,filamentInfo:t}){let{t:n}=W(),r=e.filter(e=>e.id>=2),i=Array.from({length:6},(e,t)=>r.find(e=>e.id===16+t)??{id:-(t+1),nozzle_type:``,nozzle_diameter:``,wear:null,stat:null,max_temp:0,serial_number:``,filament_color:``,filament_id:``,filament_type:``});return(0,K.jsxs)(`div`,{className:`text-center px-2.5 py-1.5 bg-bambu-dark rounded-lg flex-[2_1_190px] flex flex-col justify-center`,children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray mb-1`,children:n(`printers.nozzleRack`)}),(0,K.jsx)(`div`,{className:`flex gap-[3px] justify-center`,children:i.map((e,n)=>{let r=!e.nozzle_diameter&&!e.nozzle_type,i=r?null:Yd(e.filament_color),a=i?Xd(e.filament_color):!1;return(0,K.jsx)(gW,{slot:e,index:n,filamentName:e.filament_id?t?.[e.filament_id]?.name:void 0,children:(0,K.jsx)(`div`,{className:`w-7 h-7 rounded flex items-center justify-center cursor-default transition-colors border-b-2 ${r?`bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20`:`bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40`}`,style:i?{backgroundColor:i}:void 0,children:(0,K.jsx)(`span`,{className:`text-[10px] font-semibold ${r?`text-bambu-gray/30`:a?`text-black/80`:`text-white`}`,style:i&&!a?{textShadow:`0 1px 3px rgba(0,0,0,0.9)`}:void 0,children:r?`—`:e.nozzle_diameter||`?`})})},e.id>=0?e.id:`empty-${n}`)})})]})}function Tke({className:e}){return(0,K.jsx)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{d:`M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z`,fill:`#C3C2C1`})})}function Eke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 35 53`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z`,fill:`#C3C2C1`}),(0,K.jsx)(`path`,{d:`M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z`,fill:`#1F8FEB`})]})}function Dke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z`,fill:`#1F8FEB`}),(0,K.jsx)(`path`,{d:`M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z`,fill:`#C3C2C1`})]})}function Oke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function kke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`8`,width:`3`,height:`4.5`,fill:`#d4a017`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#d4a017`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function Ake({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:`#c62828`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#c62828`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function jke({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,K.jsx)(`rect`,{x:`9.2`,y:`3.4`,width:`5.6`,height:`8.1`}),(0,K.jsx)(`rect`,{x:`6`,y:`11.5`,width:`12.1`,height:`3.7`}),(0,K.jsx)(`path`,{d:`M 7.3 15.2 L 12.1 19.6 L 16.7 15.2`})]})}function _W({className:e,color:t,isHeating:n}){let r={"text-orange-400":`#fb923c`,"text-blue-400":`#60a5fa`,"text-green-400":`#4ade80`}[t]||`#888`,i=n?{filter:`drop-shadow(0 0 4px ${r}) drop-shadow(0 0 8px ${r})`}:{};return n?(0,K.jsxs)(`svg`,{className:e,style:i,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:r,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:r}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`})]}):(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:r,strokeWidth:`1`,fill:`none`})]})}function Mke({state:e,onClick:t}){let{t:n}=W(),r=e!==null,i=`flex items-center justify-center w-[18px] h-[18px] rounded text-[10px] transition-colors `,a;return e===!0?(i+=r?`bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 cursor-pointer`:`bg-blue-500/20 text-blue-400 cursor-default`,a=n(`printers.amsBackup.titleOn`)):e===!1?(i+=r?`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80 cursor-pointer`:`bg-bambu-dark text-bambu-gray cursor-default`,a=n(`printers.amsBackup.titleOff`)):(i+=`bg-bambu-dark text-bambu-gray/50 cursor-default`,a=n(`printers.amsBackup.titleUnknown`)),(0,K.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&t(),className:i,title:a,"aria-label":a,children:r?(0,K.jsx)(kl,{className:`w-3 h-3`}):(0,K.jsx)(`span`,{children:`?`})})}function vW({humidity:e,goodThreshold:t=40,fairThreshold:n=60,onClick:r,compact:i}){let a=typeof e==`string`?parseInt(e,10):e,o=typeof t==`number`?t:40,s=typeof n==`number`?n:60,c,l;isNaN(a)?(c=`#C3C2C1`,l=`Unknown`):a<=o?(c=`#22a352`,l=`Good`):a<=s?(c=`#d4a017`,l=`Fair`):(c=`#c62828`,l=`Bad`);let u;return u=isNaN(a)||a<=o?Tke:a<=s?Eke:Dke,(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Humidity: ${a}% - ${l}${r?` (click for history)`:``}`,children:[(0,K.jsx)(u,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums ${i?`text-[10px]`:`text-xs`}`,style:{color:c},children:[a,`%`]})]})}function yW({temp:e,goodThreshold:t=28,fairThreshold:n=35,onClick:r,compact:i}){let a=typeof t==`number`?t:28,o=typeof n==`number`?n:35,s,c,l;return e<=a?(s=`#22a352`,c=`Good`,l=Oke):e<=o?(s=`#d4a017`,c=`Fair`,l=kke):(s=`#c62828`,c=`Bad`,l=Ake),(0,K.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Temperature: ${e}°C - ${c}${r?` (click for history)`:``}`,children:[(0,K.jsx)(l,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,K.jsxs)(`span`,{className:`tabular-nums text-right ${i?`text-[10px] w-8`:`w-12`}`,style:{color:s},children:[e,`°C`]})]})}function bW(e){return e?.tray_type?null:e?.state===9||e?.state===10?`physical`:`reset`}function Nke({url:e,printName:t,className:n=`w-20 h-20`,radiusClass:r=`rounded-lg`}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),d=(0,y.useMemo)(()=>e?Xu(`${e}${e.includes(`?`)?`&`:`?`}v=${encodeURIComponent(t||Date.now().toString())}`):null,[e,t]);return(0,y.useEffect)(()=>{o(!1),c(!1)},[d]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`${n} flex-shrink-0 ${r} overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${d&&a?`cursor-pointer`:``}`,onClick:()=>d&&a&&u(!0),children:d&&!s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`img`,{src:d,alt:i(`printers.printPreview`),className:`w-full h-full object-cover ${a?`block`:`hidden`}`,onLoad:()=>o(!0),onError:()=>c(!0)}),!a&&(0,K.jsx)(Wo,{className:`w-8 h-8 text-bambu-gray`})]}):(0,K.jsx)(Wo,{className:`w-8 h-8 text-bambu-gray`})}),l&&d&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8`,onClick:()=>u(!1),children:(0,K.jsxs)(`div`,{className:`relative max-w-2xl max-h-full`,children:[(0,K.jsx)(`img`,{src:d,alt:i(`printers.printPreview`),className:`max-w-full max-h-[80vh] rounded-lg shadow-2xl`}),t&&(0,K.jsx)(`p`,{className:`text-white text-center mt-4 text-lg`,children:t})]})})]})}function Pke({printers:e}){let{t}=W(),n=no(),[r,i]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=!1,t=n.getQueryCache().subscribe(()=>{e||(e=!0,requestAnimationFrame(()=>{i(e=>e+1),e=!1}))});return()=>t()},[n]);let{counts:a,nextFinish:o}=(0,y.useMemo)(()=>{let t=0,r=0,i=0,a=0,o=0,s=0,c=0,l=null,u=null,d=0;return e?.forEach(e=>{let f=n.getQueryData([`printerStatus`,e.id]);if(f===void 0)s++;else if(!f.connected)o++;else{let n=f.hms_errors?Vp(f.hms_errors).length:0;switch(n>0&&c++,f.state){case`RUNNING`:t++,f.remaining_time!=null&&f.remaining_time>0&&(u===null||f.remaining_time0||i++;break;default:a++;break}}}),{counts:{printing:t,paused:r,finished:i,idle:a,offline:o,loading:s,error:c,total:e?.length||0},nextFinish:l&&u?{name:l,remainingMin:u,progress:d}:null}},[e,n,r]);return e?.length?(0,K.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-4 gap-y-2 text-bambu-gray`,children:[[{count:a.printing,dot:`bg-bambu-green animate-pulse`,label:t(`printers.status.printing`).toLowerCase()},{count:a.paused,dot:`bg-status-warning`,label:t(`printers.status.paused`,`paused`).toLowerCase()},{count:a.finished,dot:`bg-blue-400`,label:t(`printers.status.finished`,`finished`).toLowerCase()},{count:a.idle,dot:a.idle>0?`bg-bambu-green`:`bg-gray-500`,label:t(`printers.status.available`).toLowerCase()},{count:a.error,dot:`bg-status-error`,label:t(`printers.status.problem`).toLowerCase()},{count:a.offline,dot:`bg-gray-400`,label:t(`printers.status.offline`).toLowerCase()}].map(({count:e,dot:t,label:n})=>e>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t}`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:e}),` `,n]})]},n)),o&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-px h-4 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,children:[t(`printers.nextAvailable`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:o.name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 w-full sm:w-auto`,children:[(0,K.jsx)(`div`,{className:`w-full sm:w-16 bg-bambu-dark-tertiary rounded-full h-1.5`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-1.5 rounded-full transition-all`,style:{width:`${o.progress}%`}})}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[Math.round(o.progress),`%`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,Cf(o.remainingMin*60),`)`]})]})]})]})]}):null}function xW({value:e,options:t,onChange:n,fullWidth:r=!1}){let[i,a]=(0,y.useState)(!1),o=t.find(t=>t.value===e)??t[0];return(0,K.jsxs)(`div`,{className:`relative ${r?`w-full min-w-0`:``}`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`h-8 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white text-sm font-medium transition-colors hover:bg-bambu-dark-tertiary focus:outline-none focus:border-bambu-green flex items-center justify-between gap-2 ${r?`w-full`:`min-w-28`}`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:o?.label}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,K.jsx)(`div`,{className:`absolute left-0 top-full z-20 mt-1 min-w-full rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary py-1 shadow-xl`,children:t.map(t=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>{n(t.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-bambu-dark-tertiary ${t.value===e?`text-bambu-green`:`text-white`}`,children:t.label},t.value))})]})]})}function SW({label:e,icon:t,children:n}){let[r,i]=(0,y.useState)(!1);return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`h-8 w-8 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,"aria-label":e,title:e,children:t}),r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,K.jsx)(`div`,{className:`absolute right-0 top-full z-20 mt-1 min-w-40 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary p-2 shadow-xl`,children:n})]})]})}function CW({title:e,options:t=[],unit:n,customMin:r,customMax:i,customStep:a=1,widthClass:o=`w-[240px]`,popoverWidth:s=240,popoverHeight:c=280,isPending:l,onClose:u,onSubmit:d,children:f}){let p=(0,y.useRef)(null),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(``);(0,y.useLayoutEffect)(()=>{let e=p.current?.parentElement;if(!e)return;let t=()=>{h(jp({triggerRect:e.getBoundingClientRect(),popoverWidth:s,estimatedHeight:c,horizontalAlign:`center`}))};return t(),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[s,c]);let v=n!==void 0,b=()=>{let e=Number(g);Number.isFinite(e)&&d?.(Math.round(Math.min(i??e,Math.max(r??e,e))))};return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{ref:p,className:`hidden`,"aria-hidden":`true`}),(0,Op.createPortal)((0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[1000]`,onClick:u}),(0,K.jsxs)(`div`,{className:`fixed z-[1001] flex ${o} flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,style:{top:m?.top??-9999,left:m?.left??-9999,visibility:m?`visible`:`hidden`},onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:e}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),t.length>0&&(0,K.jsx)(`div`,{className:`px-3 py-2.5`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:t.map(e=>(0,K.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>d?.(e.value),className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:e.label},`${e.label}-${e.value}`))})}),f,v&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`form`,{className:`flex gap-1.5 px-3 pt-2.5 pb-3`,onSubmit:e=>{e.preventDefault(),b()},children:[(0,K.jsx)(`input`,{type:`number`,min:r,max:i,step:a,value:g,onChange:e=>_(e.target.value),placeholder:`Custom`,className:`h-8 min-w-0 flex-1 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{type:`submit`,disabled:l||g.trim()===``,className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})]})]}),document.body)]})}var Fke=Rp(Mp,`C`);function wW({label:e,current:t,target:n,isActive:r,isPending:i,onSubmit:a,options:o=Fke}){let[s,c]=(0,y.useState)(``),l=()=>{let e=Number(s);Number.isFinite(e)&&a(Math.min(320,Math.max(0,Math.round(e))))};return(0,K.jsxs)(`div`,{className:`rounded-lg border p-2 ${r?`border-amber-400/60 bg-amber-400/10`:`border-bambu-dark-tertiary bg-bambu-dark`}`,children:[(0,K.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium ${r?`text-amber-300`:`text-white`}`,children:e}),(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray`,children:[Math.round(t??0),`°C`,n===void 0?``:` / ${Math.round(n)}°`]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:o.map(t=>(0,K.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>a(t.value),className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:t.label},`${e}-${t.value}`))}),(0,K.jsxs)(`form`,{className:`mt-1.5 flex gap-1`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:320,step:1,value:s,onChange:e=>c(e.target.value),placeholder:`Custom`,className:`h-7 min-w-0 flex-1 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{type:`submit`,disabled:i||s.trim()===``,className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-2 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})}var Ike=[`error`,`printing`,`paused`,`finished`,`idle`,`offline`],TW={error:{labelKey:`printers.status.problem`,dot:`bg-status-error`},printing:{labelKey:`printers.status.printing`,dot:`bg-bambu-green animate-pulse`},paused:{labelKey:`printers.status.paused`,dot:`bg-status-warning`},finished:{labelKey:`printers.status.finished`,dot:`bg-blue-400`},idle:{labelKey:`printers.status.idle`,dot:`bg-bambu-green`},offline:{labelKey:`printers.status.offline`,dot:`bg-gray-400`}};function EW(e){if(!e?.connected)return`offline`;if((e.hms_errors?Vp(e.hms_errors):[]).length>0)return`error`;switch(e.state){case`RUNNING`:return`printing`;case`PAUSE`:return`paused`;case`FINISH`:return`finished`;case`FAILED`:return`finished`;default:return`idle`}}function Lke(e,t){if(t)return t;switch(e){case`RUNNING`:return`Printing`;case`PAUSE`:return`Paused`;case`FINISH`:return`Finished`;case`FAILED`:return`Failed`;case`IDLE`:return`Idle`;default:return e?e.charAt(0)+e.slice(1).toLowerCase():`Idle`}}var Rke=new Set([`X1C`,`X1`,`X1E`,`X2D`,`P1S`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`]);function DW(e){return e?{O1D:`H2D`,O1E:`H2D Pro`,O2D:`H2D Pro`,O1C:`H2C`,O1C2:`H2C`,O1S:`H2S`,"BL-P001":`X1C`,"BL-P002":`X1`,"BL-P003":`X1E`,N6:`X2D`,N9:`A2L`,C11:`P1S`,C12:`P1P`,C13:`P2S`,N2S:`A1`,N1:`A1 Mini`,X1C:`X1C`,X1:`X1`,X1E:`X1E`,X2D:`X2D`,P1S:`P1S`,P1P:`P1P`,P2S:`P2S`,A1:`A1`,"A1 Mini":`A1 Mini`,A2L:`A2L`,H2D:`H2D`,"H2D Pro":`H2D Pro`,H2C:`H2C`,H2S:`H2S`}[e]||e:``}function OW({ams:e,printerId:t,label:n,amsLabels:r,canEdit:i,onSaved:a,children:o}){let{t:s}=W(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(`top`),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),x=(0,y.useRef)(null),S=(0,y.useRef)(null),C=(0,y.useRef)(null);(0,y.useEffect)(()=>{c&&(p(r?.[e.id]??``),_(null),requestAnimationFrame(()=>{if(x.current&&S.current){let e=x.current.getBoundingClientRect(),t=e.top-56,n=window.innerHeight-e.bottom;d(tt?`bottom`:`top`)}}))},[c,r,e.id]);let w=()=>{C.current&&clearTimeout(C.current),C.current=setTimeout(()=>l(!0),80)},T=()=>{C.current&&clearTimeout(C.current),v||(C.current=setTimeout(()=>l(!1),200))};(0,y.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]);let E=async()=>{if(i){h(!0),_(null);try{let n=f.trim();n?await Q.saveAmsLabel(t,e.id,n,e.serial_number):await Q.deleteAmsLabel(t,e.id,e.serial_number),a(),l(!1)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,K.jsxs)(`div`,{ref:x,className:`relative inline-block`,onMouseEnter:w,onMouseLeave:T,children:[o,c&&(0,K.jsx)(`div`,{ref:S,className:` absolute left-0 z-50 ${u===`top`?`bottom-full mb-2`:`top-full mt-2`} animate-in fade-in-0 zoom-in-95 duration-150 - `,style:{maxWidth:`calc(100vw - 24px)`},onMouseEnter:w,onMouseLeave:T,children:(0,K.jsxs)(`div`,{className:`w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm p-2.5 space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:n}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] tracking-wide text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.serialNumber`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono truncate`,children:e.serial_number||`—`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] tracking-wide text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.firmwareVersion`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono truncate`,children:e.sw_ver||`—`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.friendlyName`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary/50`})]}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>i&&p(e.target.value),onKeyDown:e=>e.key===`Enter`&&E(),onFocus:()=>b(!0),onBlur:()=>{b(!1),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>l(!1),200)},placeholder:i?s(`printers.amsPopup.friendlyNamePlaceholder`):r?.[e.id]||`—`,disabled:!i,title:i?void 0:s(`printers.amsPopup.noEditPermission`),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-xs text-white placeholder-bambu-gray/60 focus:outline-none focus:border-bambu-green disabled:opacity-50 disabled:cursor-not-allowed`,maxLength:100}),i&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[g&&(0,K.jsx)(`p`,{className:`text-[10px] text-red-400 break-words`,children:g}),(0,K.jsxs)(`div`,{className:`flex gap-1 justify-end`,children:[(0,K.jsx)(`button`,{onClick:E,disabled:m,className:`px-2 py-0.5 text-[10px] bg-bambu-green text-white rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:s(`printers.amsPopup.save`)}),r?.[e.id]&&(0,K.jsx)(`button`,{onClick:async()=>{if(i){h(!0),_(null);try{await Q.deleteAmsLabel(t,e.id,e.serial_number),a(),l(!1)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}},disabled:m,className:`px-2 py-0.5 text-[10px] bg-bambu-dark-tertiary text-bambu-gray rounded hover:bg-bambu-dark-tertiary/70 disabled:opacity-50`,children:s(`printers.amsPopup.clear`)})]})]})]})]})})]})}var OW={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}};function kW({printer:e,hideIfDisconnected:t,maintenanceInfo:n,viewMode:r=`expanded`,cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,linkedSpools:s,spoolmanUrl:c,spoolmanSyncMode:l,onGetAssignment:u,onUnassignSpool:d,spoolmanSpools:f,spoolmanSlotAssignments:p,spoolmanLoading:m=!1,onUnassignSpoolmanSpool:h,timeFormat:g=`system`,cameraViewMode:_=`window`,onOpenEmbeddedCamera:v,checkPrinterFirmware:b=!0,dryingPresets:x=OW,requirePlateClear:S=!1,selectionMode:C=!1,isSelected:w=!1,onToggleSelect:T,onOpenCompactCard:E,nozzleTempPresets:D=Mp,bedTempPresets:O=Np,chamberTempPresets:k=Pp,fanSpeedPresets:A=Fp}){let{t:j}=W(),M=no(),N=$n(),{showToast:P}=Td(),{hasPermission:F}=dd(),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!0),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(!1),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(!1),[ce,le]=(0,y.useState)(null),[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)(!1),[me,he]=(0,y.useState)(!1),[ge,_e]=(0,y.useState)(!1),[ve,ye]=(0,y.useState)(null),[be,xe]=(0,y.useState)(null),[Se,Ce]=(0,y.useState)(null),[we,Te]=(0,y.useState)(null),[Ee,De]=(0,y.useState)(10),[Oe,ke]=(0,y.useState)(null),[Ae,je]=(0,y.useState)(!1),[Me,Ne]=(0,y.useState)(!1),[Pe,Fe]=(0,y.useState)(!1),[Ie,Le]=(0,y.useState)(!1),[Re,ze]=(0,y.useState)(!1),Be=(0,y.useCallback)(()=>Le(!1),[]),[Ve,He]=(0,y.useState)(null),[Ue,We]=(0,y.useState)(null),[Ge,Ke]=(0,y.useState)(`n3f`),[qe,Je]=(0,y.useState)(`PLA`),[Ye,Xe]=(0,y.useState)(50),[Ze,Qe]=(0,y.useState)(4),[$e,et]=(0,y.useState)(!1),[tt,nt]=(0,y.useState)(null),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)(!1),st=(0,y.useRef)(null),ct=(0,y.useRef)(0),[lt,ut]=(0,y.useState)(null),[dt,ft]=(0,y.useState)(null),[pt,mt]=(0,y.useState)(null),[ht,gt]=(0,y.useState)(null),[_t,vt]=(0,y.useState)(null),[yt,bt]=(0,y.useState)(!1),[xt,St]=(0,y.useState)(null),[Ct,wt]=(0,y.useState)(!1),[Tt,Et]=(0,y.useState)(!1),[Dt,Ot]=(0,y.useState)(null),[kt,At]=(0,y.useState)(!1),[jt,Mt]=(0,y.useState)(!1),{data:G}=q({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:3e4}),{data:Nt}=q({queryKey:[`firmwareUpdate`,e.id],queryFn:()=>id.checkPrinterUpdate(e.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:b&&F(`firmware:read`)}),Pt=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams)for(let t of G.ams)for(let n of t.tray||[])n.tray_info_idx&&e.add(n.tray_info_idx);for(let t of G?.vt_tray??[])t.tray_info_idx&&e.add(t.tray_info_idx);if(G?.nozzle_rack)for(let t of G.nozzle_rack)t.filament_id&&e.add(t.filament_id);return Array.from(e)},[G?.ams,G?.vt_tray,G?.nozzle_rack]),Ft=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams)for(let t of G.ams)for(let n of t.tray||[])n.tray_type&&e.add(n.tray_type.toUpperCase());for(let t of G?.vt_tray??[])t.tray_type&&e.add(t.tray_type.toUpperCase());return e},[G?.ams,G?.vt_tray]),It=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams){for(let t of G.ams)for(let n of t.tray||[])if(n.tray_type&&n.tray_color){let t=n.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${n.tray_type.toUpperCase()}:${t}`)}}for(let t of G?.vt_tray??[])if(t.tray_type&&t.tray_color){let n=t.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${t.tray_type.toUpperCase()}:${n}`)}return e},[G?.ams,G?.vt_tray]),{data:Lt}=q({queryKey:[`filamentInfo`,Pt],queryFn:()=>Q.getFilamentInfo(Pt),enabled:Pt.length>0,staleTime:300*1e3}),{data:Rt}=q({queryKey:[`slotPresets`,e.id],queryFn:()=>Q.getSlotPresets(e.id),staleTime:120*1e3}),zt=G?.state===`RUNNING`||G?.state===`PAUSE`?G?.current_archive_id??null:null,{data:Bt}=q({queryKey:[`archive-plates`,zt],queryFn:()=>Q.getArchivePlates(zt),enabled:zt!=null,staleTime:300*1e3}),Vt=!Bt?.is_multi_plate||G?.current_plate_id==null?null:Bt.plates.find(e=>e.index===G.current_plate_id)?.name||j(`printers.plateNumber`,`Plate {{number}}`,{number:G.current_plate_id}),{data:Ht,refetch:Ut}=q({queryKey:[`amsLabels`,e.id],queryFn:()=>Q.getAmsLabels(e.id),staleTime:300*1e3}),[Wt,Gt]=(0,y.useState)(null);(0,y.useEffect)(()=>{G?.wifi_signal!=null&&Gt(G.wifi_signal)},[G?.wifi_signal]);let Kt=G?.wifi_signal??Wt,qt=(0,y.useRef)(void 0);(0,y.useEffect)(()=>{G?.connected!==void 0&&(qt.current=G.connected)},[G?.connected]);let Jt=G?.connected??qt.current,Yt=(0,y.useRef)({});(0,y.useEffect)(()=>{G?.ams_extruder_map&&Object.keys(G.ams_extruder_map).length>0&&(Yt.current=G.ams_extruder_map)},[G?.ams_extruder_map]);let Xt=G?.ams_extruder_map&&Object.keys(G.ams_extruder_map).length>0?G.ams_extruder_map:Yt.current,Zt=(0,y.useRef)([]);(0,y.useEffect)(()=>{G?.ams&&G.ams.length>0&&(Zt.current=G.ams)},[G?.ams]);let Qt=G?.ams&&G.ams.length>0?G.ams:Zt.current,$t=(0,y.useRef)(void 0),en=G?.tray_now;en!==void 0&&en!==255?$t.current=en:en===255&&($t.current=void 0);let tn=en!==void 0&&en!==255?en:$t.current,{data:nn}=q({queryKey:[`smartPlugByPrinter`,e.id],queryFn:()=>Q.getSmartPlugByPrinter(e.id)}),{data:rn}=q({queryKey:[`scriptPlugsByPrinter`,e.id],queryFn:()=>Q.getScriptPlugsByPrinter(e.id)}),{data:an}=q({queryKey:[`smartPlugStatus`,nn?.id],queryFn:()=>nn?Q.getSmartPlugStatus(nn.id):null,enabled:!!nn,refetchInterval:1e4}),{data:on}=q({queryKey:[`queue`,e.id,`pending`],queryFn:()=>Q.getQueue(e.id,`pending`)}),sn=(0,y.useMemo)(()=>on?.length?mT(on,Ft,It).length:0,[on,Ft,It]),{data:cn}=q({queryKey:[`queue`,e.id,`printing`],queryFn:()=>Q.getQueue(e.id,`printing`),enabled:G?.state===`RUNNING`}),{data:ln}=q({queryKey:[`currentPrintUser`,e.id],queryFn:()=>Q.getCurrentPrintUser(e.id),enabled:G?.state===`RUNNING`}),un=cn?.[0]?.created_by_username||ln?.username,{data:dn}=q({queryKey:[`archives`,e.id,`last`],queryFn:()=>Q.getArchives(e.id,1,0),enabled:G?.connected&&G?.state!==`RUNNING`}),fn=dn?.[0],pn=G?.state===`RUNNING`||G?.state===`PAUSE`,mn=S&&G?.awaiting_plate_clear===!0,hn=G?.connected&&mn&&!pn,gn=G?.current_print&&pn?Ap(G.subtask_name||G.current_print||null,G.gcode_file,j,Vt):null,[_n,vn]=(0,y.useState)(null);(0,y.useEffect)(()=>{gn?vn({name:gn,coverUrl:G?.cover_url??null}):mn||vn(null)},[gn,mn,G?.cover_url]);let yn=!S||!G?.connected?null:pn?{label:j(`printers.plateStatus.inUse`),className:`bg-blue-500/20 text-blue-400`}:G.awaiting_plate_clear?{label:j(`printers.plateStatus.notCleared`),className:`bg-yellow-500/20 text-yellow-400`}:{label:j(`printers.plateStatus.cleared`),className:`bg-status-ok/20 text-status-ok`},bn=yn?(0,K.jsx)(`span`,{className:`inline-flex flex-shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${yn.className}`,children:yn.label}):null,xn=t&&Jt===!1,Sn=J({mutationFn:t=>Q.deletePrinter(e.id,t.deleteArchives),onSuccess:()=>{M.invalidateQueries({queryKey:[`printers`]}),M.invalidateQueries({queryKey:[`archives`]}),M.invalidateQueries({queryKey:[`maintenanceOverview`]})},onError:e=>P(e.message||j(`printers.toast.failedToDelete`),`error`)}),Cn=J({mutationFn:()=>Q.connectPrinter(e.id),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),wn=J({mutationFn:()=>Q.refreshPrinterStatus(e.id),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),P(j(`printers.forceRefreshSuccess`),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Tn=J({mutationFn:e=>Q.unlinkSpool(e),onSuccess:e=>{P(j(`spoolman.unlinkSuccess`)||e?.message,`success`),M.invalidateQueries({queryKey:[`linked-spools`]}),M.invalidateQueries({queryKey:[`unlinked-spools`]}),M.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})},onError:e=>{P(e.message||j(`spoolman.unlinkFailed`),`error`)}}),En=J({mutationFn:({amsId:t,temp:n,duration:r,filament:i,rotateTray:a})=>Q.startDrying(e.id,t,n,r,i,a),onSuccess:()=>{We(null),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Dn=J({mutationFn:t=>Q.stopDrying(e.id,t),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),On=J({mutationFn:t=>Q.setAmsFilamentBackup(e.id,t),onSuccess:(t,n)=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),M.invalidateQueries({queryKey:[`printer-status`,e.id]}),P(j(n?`printers.amsBackup.toastEnabled`:`printers.amsBackup.toastDisabled`),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),kn=J({mutationFn:e=>nn?Q.controlSmartPlug(nn.id,e):Promise.reject(`No plug`),onSuccess:()=>{M.invalidateQueries({queryKey:[`smartPlugStatus`,nn?.id]})}}),An=J({mutationFn:e=>nn?Q.updateSmartPlug(nn.id,{auto_off:e}):Promise.reject(`No plug`),onSuccess:()=>{M.invalidateQueries({queryKey:[`smartPlugByPrinter`,e.id]}),M.invalidateQueries({queryKey:[`smart-plugs`]})}}),jn=J({mutationFn:({id:e,action:t})=>Q.controlSmartPlug(e,t),onSuccess:()=>{P(j(`printers.toast.scriptTriggered`))},onError:e=>P(e.message||j(`printers.toast.failedToRunScript`),`error`)}),Mn=J({mutationFn:()=>Q.stopPrint(e.id),onSuccess:()=>{P(j(`printers.toast.printStopped`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToStopPrint`),`error`)}),Nn=J({mutationFn:()=>Q.pausePrint(e.id),onSuccess:()=>{P(j(`printers.toast.printPaused`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToPausePrint`),`error`)}),Pn=J({mutationFn:()=>Q.resumePrint(e.id),onSuccess:()=>{P(j(`printers.toast.printResumed`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToResumePrint`),`error`)}),Fn=J({mutationFn:()=>Q.clearPlate(e.id),onSuccess:()=>{P(j(`queue.clearPlateSuccess`)),M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,awaiting_plate_clear:!1}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),M.invalidateQueries({queryKey:[`queue`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),In=J({mutationFn:({target:t,nozzle:n})=>Q.setNozzleTemperature(e.id,t,n),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Ln=J({mutationFn:t=>Q.setBedTemperature(e.id,t),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Rn=J({mutationFn:t=>Q.setChamberTemperature(e.id,t),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),zn=J({mutationFn:({fan:t,speed:n})=>Q.setFanSpeed(e.id,t,n),onMutate:async({fan:t,speed:n})=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let r=M.getQueryData([`printerStatus`,e.id]),i={part:`cooling_fan_speed`,aux:`big_fan1_speed`,chamber:`big_fan2_speed`}[t];return M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,[i]:n}),{previousStatus:r}},onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Bn=J({mutationFn:t=>Q.selectExtruder(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,active_extruder:t}),{previousStatus:n}},onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Vn=J({mutationFn:t=>Q.setChamberLight(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{P(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToControlChamberLight`),`error`)}}),Hn=J({mutationFn:t=>Q.setPrintSpeed(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,speed_level:t})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSetSpeed`),`error`)}}),Un=J({mutationFn:t=>Q.setAirductMode(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,airduct_mode:t===`cooling`?0:1})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Wn=J({mutationFn:({distance:t,force:n})=>Q.bedJog(e.id,t,n??!1),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Gn=J({mutationFn:({x:t,y:n})=>Q.xyJog(e.id,t,n),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Kn=J({mutationFn:t=>Q.extruderJog(e.id,t),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),qn=J({mutationFn:t=>Q.homeAxes(e.id,t),onSuccess:()=>{try{sessionStorage.setItem(`bambuddy.bedJog.warned.${e.id}`,`1`)}catch{}P(j(`printers.bedJog.homingStarted`))},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Jn=J({mutationFn:t=>Q.updatePrinter(e.id,{plate_detection_enabled:t}),onSuccess:()=>{M.invalidateQueries({queryKey:[`printers`]}),P(Jn.variables?j(`printers.toast.plateCheckEnabled`):j(`printers.toast.plateCheckDisabled`))},onError:e=>P(e.message||j(`printers.toast.failedToUpdateSetting`),`error`)}),Yn=J({mutationFn:t=>Q.updatePrinter(e.id,{is_active:t}),onSuccess:(t,n)=>{M.invalidateQueries({queryKey:[`printers`]}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),P(j(n?`printers.maintenance.toastExited`:`printers.maintenance.toastEntered`,{name:e.name}),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToUpdateSetting`),`error`)}),[Xn,Zn]=(0,y.useState)(!1),Qn=()=>{G?.state===`RUNNING`||G?.state===`PAUSE`?Zn(!0):Yn.mutate(!1)},er=(G?.state===`RUNNING`||G?.state===`PAUSE`)&&(G?.printable_objects_count??0)>=2,{data:tr}=q({queryKey:[`printableObjects`,e.id],queryFn:()=>Q.getPrintableObjects(e.id),enabled:Me||er,refetchInterval:Me?5e3:er?3e4:!1}),[nr,rr]=(0,y.useState)(null),ir=(0,y.useRef)(!1),ar=(0,y.useRef)(null),or=(0,y.useRef)(!1),sr=J({mutationFn:({amsId:t,slotId:n})=>Q.refreshAmsSlot(e.id,t,n),onMutate:({amsId:e,slotId:t})=>{ar.current&&clearTimeout(ar.current),ir.current=!1,or.current=!1,rr({amsId:e,slotId:t}),setTimeout(()=>{or.current=!0},2e3),ar.current=setTimeout(()=>{rr(null)},3e4)},onSuccess:e=>{P(e.message||j(`printers.toast.rfidRereadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToRereadRfid`),`error`),ar.current&&clearTimeout(ar.current),rr(null)}}),cr=J({mutationFn:({trayId:t})=>Q.loadAmsTray(e.id,t),onSuccess:e=>{P(e.message||j(`printers.toast.loadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToLoad`),`error`)}}),lr=J({mutationFn:()=>Q.unloadAms(e.id),onSuccess:e=>{P(e.message||j(`printers.toast.unloadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToUnload`),`error`)}}),[ur,dr]=(0,y.useState)(null),[fr,pr]=(0,y.useState)(null),mr=async()=>{try{dr(await Q.getPlateReferences(e.id))}catch{}},hr=()=>{Jn.mutate(!e.plate_detection_enabled)},gr=async()=>{wt(!0),St(null);let t=G?.chamber_light===!1;Mt(t),t&&(await Q.setChamberLight(e.id,!0),await new Promise(e=>setTimeout(e,2500)));try{St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0})),mr()}catch(n){P(n instanceof Error?n.message:j(`printers.toast.failedToCheckPlate`),`error`),t&&(await Q.setChamberLight(e.id,!1),Mt(!1))}finally{wt(!1)}},_r=(0,y.useCallback)(async()=>{St(null),jt&&(await Q.setChamberLight(e.id,!1),Mt(!1))},[jt,e.id]),vr=async t=>{Et(!0);try{let n=await Q.calibratePlateDetection(e.id,{label:t});n.success?(P(n.message||j(`printers.toast.calibrationSaved`),`success`),mr(),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))):P(n.message||j(`printers.toast.calibrationFailed`),`error`)}catch(e){P(e instanceof Error?e.message:j(`printers.toast.calibrationFailed`),`error`)}finally{Et(!1)}},yr=async(t,n)=>{try{await Q.updatePlateReferenceLabel(e.id,t,n),pr(null),mr()}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToUpdateLabel`),`error`)}},br=async t=>{try{await Q.deletePlateReference(e.id,t),P(j(`printers.toast.referenceDeleted`),`success`),mr(),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToDeleteReference`),`error`)}},xr=async()=>{if(Dt){At(!0);try{await Q.updatePrinter(e.id,{plate_detection_roi:Dt}),P(j(`printers.toast.detectionAreaSaved`),`success`),Ot(null),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToSaveDetectionArea`),`error`)}finally{At(!1)}}};(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&xt&&_r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[xt,_r]);let Sr=(0,y.useRef)(null);if((0,y.useEffect)(()=>{if(!nr)return;let e=G?.ams_status_main??0;return e!==0&&(ir.current=!0,Sr.current&&=(clearTimeout(Sr.current),null)),ir.current&&e===0&&(or.current?(ar.current&&clearTimeout(ar.current),rr(null)):Sr.current||=setTimeout(()=>{ar.current&&clearTimeout(ar.current),rr(null)},2e3)),()=>{Sr.current&&clearTimeout(Sr.current)}},[G?.ams_status_main,nr]),(0,y.useEffect)(()=>{if(!I)return;let e=e=>{let t=e.target;st.current?.contains(t)||L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[I]),xn)return null;let Cr=()=>{switch(i){case 1:return`w-10 h-10`;case 2:return`w-14 h-14`;case 3:return`w-16 h-16`;case 4:return`w-20 h-20`;default:return`w-14 h-14`}},wr=()=>{switch(i){case 1:return`text-base truncate`;case 2:return`text-lg`;case 3:return`text-xl`;case 4:return`text-2xl`;default:return`text-lg`}},Tr=()=>{switch(i){case 1:return`mb-2`;case 2:return`mb-4`;case 3:return`mb-5`;case 4:return`mb-6`;default:return`mb-4`}},Er=Jt&&G?.state!==`RUNNING`&&G?.state!==`PAUSE`&&F(`printers:control`),Dr=e=>{e.preventDefault(),ct.current++,ct.current===1&&it(!0)},Or=e=>{e.preventDefault(),e.dataTransfer.dropEffect=Er?`copy`:`none`},kr=e=>{e.preventDefault(),ct.current--,ct.current===0&&it(!1)},Ar=async t=>{if(t.preventDefault(),ct.current=0,it(!1),!Er)return;let n=Array.from(t.dataTransfer.files)[0];if(!n)return;let r=n.name.toLowerCase();if(!r.endsWith(`.gcode`)&&!r.includes(`.gcode.`)){P(j(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`),`error`);return}ot(!0);try{let t=await Q.uploadLibraryFile(n,null),r=t.metadata?.sliced_for_model,i=EW(e.model);if(r&&i&&r.toLowerCase()!==i.toLowerCase()){await Q.deleteLibraryFile(t.id).catch(()=>{}),P(j(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:r,printerModel:i}),`error`);return}He({id:t.id,filename:t.filename})}catch{P(j(`common.uploadFailed`,`Upload failed`),`error`)}finally{ot(!1)}},jr=t=>{r!==`compact`||C||t.target.closest(`button, a, input, select, textarea, [role="button"]`)||E?.(e.id)},Mr=`!h-8 !min-h-8 !w-8 !px-0 !py-0`,Nr=({amsId:e,slotId:t,loadTrayId:n,isRefreshing:r,includeRfid:i=!0})=>{let a=G?.state===`RUNNING`;return(0,K.jsxs)(K.Fragment,{children:[i&&(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:ams_rfid`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:n=>{n.stopPropagation(),!(a||!F(`printers:ams_rfid`))&&sr.mutate({amsId:e,slotId:t})},disabled:a||r||!F(`printers:ams_rfid`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:ams_rfid`)?void 0:j(`printers.permission.noAmsRfid`),children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${r?`animate-spin`:``}`}),j(`printers.rfid.reread`)]}),(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),!(a||!F(`printers:control`))&&cr.mutate({trayId:n})},disabled:a||!F(`printers:control`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:control`)?void 0:j(`printers.permission.noControl`),children:[(0,K.jsx)(Jc,{className:`w-3 h-3`}),j(`printers.ams.load`)]}),(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),!(a||!F(`printers:control`))&&lr.mutate()},disabled:a||!F(`printers:control`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:control`)?void 0:j(`printers.permission.noControl`),children:[(0,K.jsx)(Yc,{className:`w-3 h-3`}),j(`printers.ams.unload`)]})]})},Pr=(0,K.jsxs)(`div`,{ref:st,className:`relative flex-shrink-0`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>L(!I),title:j(`common.more`,`More`),className:Mr,children:(0,K.jsx)(Ws,{className:`w-4 h-4`})}),I&&(0,K.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,onClick:()=>{F(`printers:update`)&&(te(!0),L(!1))},title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:[(0,K.jsx)(vl,{className:`w-4 h-4`}),j(`common.edit`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Le(!0),L(!1)},children:[(0,K.jsx)(Pc,{className:`w-4 h-4`}),j(`printers.printerInformation`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,disabled:Yn.isPending||!F(`printers:update`),onClick:()=>{F(`printers:update`)&&(L(!1),e.is_active===!1?Yn.mutate(!0):Qn())},title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:[(0,K.jsx)(Lu,{className:`w-4 h-4`}),e.is_active===!1?j(`printers.maintenance.menuExit`):j(`printers.maintenance.menuEnter`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Cn.mutate(),L(!1)},children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),j(`printers.reconnect`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2 disabled:opacity-50`,disabled:wn.isPending,onClick:()=>{wn.mutate(),L(!1)},children:[(0,K.jsx)(jl,{className:`w-4 h-4 ${wn.isPending?`animate-spin`:``}`}),j(`printers.forceRefresh`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{H(!0),L(!1)},children:[(0,K.jsx)(mu,{className:`w-4 h-4`}),j(`printers.mqttDebug`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{ze(!0),L(!1)},children:[(0,K.jsx)(cu,{className:`w-4 h-4`}),j(`diagnostic.runButton`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:delete`)?`text-red-400 hover:bg-bambu-dark-tertiary`:`text-red-400/50 cursor-not-allowed`}`,onClick:()=>{F(`printers:delete`)&&(z(!0),L(!1))},title:F(`printers:delete`)?void 0:j(`printers.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),j(`common.delete`)]})]})]});return(0,K.jsxs)(_d,{id:`printer-card-${e.id}`,className:`relative flex h-full flex-col ${w?`ring-2 ring-bambu-green`:``} ${C||r===`compact`?`cursor-pointer`:``}`,onClick:jr,onDragEnter:Dr,onDragOver:Or,onDragLeave:kr,onDrop:Ar,children:[C&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-start p-2`,onClick:t=>{t.stopPropagation(),T?.(e.id)},children:w?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5 text-bambu-gray`})}),(rt||at)&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-10 rounded-xl border-2 border-dashed flex items-center justify-center transition-colors ${at?`bg-bambu-green/10 border-bambu-green/50`:Er?`bg-bambu-green/10 border-bambu-green`:`bg-red-500/10 border-red-500/50`}`,children:(0,K.jsx)(`div`,{className:`text-center`,children:at?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green animate-spin`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:j(`common.uploading`,`Uploading...`)})]}):Er?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Tl,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:j(`printers.dropToPrint`,`Drop to print`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ru,{className:`w-8 h-8 mx-auto mb-2 text-red-400`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-red-400`,children:j(`printers.cannotPrint`,`Printer busy`)})]})})}),(0,K.jsxs)(yd,{className:`${i>=3?`p-5`:``} flex flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:Tr(),children:[(0,K.jsx)(`div`,{className:`flex items-start justify-between gap-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(`img`,{src:fT(e.model),alt:e.model||j(`common.printer`),className:`object-contain rounded-lg flex-shrink-0 ${Cr()}`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white ${wr()}`,children:e.name}),r===`compact`&&(()=>{let e=G?.connected&&G.hms_errors?Vp(G.hms_errors):[],t=e.some(e=>e.severity<=2),n=e.length>0,r=G?.connected?t?`bg-status-error`:n?`bg-status-warning`:`bg-status-ok`:`bg-status-error`,i=G?.connected?n?`${e.length} HMS ${e.length===1?`error`:`errors`}`:j(`printers.connection.connected`):j(`printers.connection.offline`);return(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full flex-shrink-0 ${r}`,title:i})})()]}),r===`compact`&&hn&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>Fn.mutate(),disabled:Fn.isPending||!F(`printers:clear_plate`),"aria-label":j(`printers.plateStatus.markCleared`),className:`inline-flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md bg-yellow-500/20 border border-yellow-400/40 text-yellow-400 hover:bg-yellow-500/30 transition-colors disabled:opacity-50`,title:F(`printers:clear_plate`)?j(`printers.plateStatus.markCleared`):j(`printers.permission.noControl`),children:Fn.isPending?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(GU,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[e.model||`Unknown Model`,r===`expanded`&&G?.nozzles&&G.nozzles[0]?.nozzle_diameter&&(0,K.jsxs)(`span`,{className:`ml-1.5 text-bambu-gray`,title:G.nozzles[0].nozzle_type||`Nozzle`,children:[`• `,G.nozzles[0].nozzle_diameter,`mm`]}),r===`expanded`&&n&&n.total_print_hours>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-bambu-gray`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 inline-block mr-1`}),Math.round(n.total_print_hours),`h`]})]})]})]})}),r===`expanded`&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.is_active===!1?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs bg-amber-500/20 text-amber-400`,title:j(`printers.maintenance.subtitle`),children:[(0,K.jsx)(Lu,{className:`w-3 h-3`}),j(`printers.maintenance.pillLabel`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${G?.connected?`bg-status-ok/20 text-status-ok`:`bg-status-error/20 text-status-error`}`,children:[G?.connected?(0,K.jsx)(Hc,{className:`w-3 h-3`}):(0,K.jsx)(Eu,{className:`w-3 h-3`}),G?.connected?j(`printers.connection.connected`):j(`printers.connection.offline`)]}),e.is_active!==!1&&!G?.connected&&(0,K.jsxs)(`button`,{onClick:()=>ze(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:j(`diagnostic.runButton`),children:[(0,K.jsx)(cu,{className:`w-3 h-3`}),j(`diagnostic.runButton`)]}),G?.connected&&G?.wired_network&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-status-ok/20 text-status-ok`,title:j(`printers.connection.ethernet`,`Ethernet`),children:[(0,K.jsx)(qo,{className:`w-3 h-3`}),j(`printers.connection.ethernet`,`Ethernet`)]}),G?.connected&&!G?.wired_network&&Kt!=null&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Kt>=-50||Kt>=-60?`bg-status-ok/20 text-status-ok`:Kt>=-70?`bg-status-warning/20 text-status-warning`:Kt>=-80?`bg-orange-500/20 text-orange-600`:`bg-status-error/20 text-status-error`}`,title:`WiFi: ${Kt} dBm - ${j(pT(Kt).labelKey)}`,children:[(0,K.jsx)(Yl,{className:`w-3 h-3`}),Kt,`dBm`]}),G?.connected&&(()=>{let e=G.hms_errors?Vp(G.hms_errors):[];return(0,K.jsxs)(`button`,{onClick:()=>de(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${e.length>0?e.some(e=>e.severity<=2)?`bg-status-error/20 text-status-error`:`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:j(`printers.clickToViewHmsErrors`),children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),e.length>0?e.length:`OK`]})})(),n&&(0,K.jsxs)(`button`,{onClick:()=>N(`/maintenance`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?`bg-status-error/20 text-status-error`:n.warning_count>0?`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:``}${n.due_count>0&&n.warning_count>0?`, `:``}${n.warning_count>0?`${n.warning_count} due soon`:``} - Click to view`:j(`printers.maintenanceUpToDate`),children:[(0,K.jsx)(Lu,{className:`w-3 h-3`}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:`OK`]}),sn>0&&(0,K.jsxs)(`button`,{onClick:()=>N(`/queue`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-indigo-500/20 text-indigo-400 hover:opacity-80 transition-opacity`,title:j(`printers.queue.inQueue`,{count:sn}),children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),sn]}),b&&Nt?.current_version&&Nt?.latest_version?(0,K.jsxs)(`button`,{onClick:()=>bt(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${Nt.update_available?`bg-orange-500/20 text-orange-400`:`bg-status-ok/20 text-status-ok`}`,title:Nt.update_available?j(`printers.firmwareUpdateAvailable`,{current:Nt.current_version,latest:Nt.latest_version}):j(`printers.firmwareUpToDate`,{version:Nt.current_version}),children:[Nt.update_available?(0,K.jsx)(Vs,{className:`w-3 h-3`}):(0,K.jsx)(ps,{className:`w-3 h-3`}),Nt.current_version]}):G?.firmware_version?(0,K.jsx)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-bambu-dark-tertiary/50 text-bambu-gray`,children:G.firmware_version}):null,G?.connected&&[`X1C`,`X1`,`X1E`,`X2D`,`P1S`,`P1P`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`].includes(e.model??``)&&(0,K.jsx)(`span`,{className:`flex items-center px-2 py-1 rounded-full text-xs ${G.door_open?`bg-yellow-500/20 text-yellow-400`:`bg-status-ok/20 text-status-ok`}`,title:G.door_open?j(`printers.door.open`):j(`printers.door.closed`),children:G.door_open?(0,K.jsx)(Bs,{className:`w-3 h-3`}):(0,K.jsx)(zs,{className:`w-3 h-3`})})]})})]}),R&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsx)(_d,{className:`w-full max-w-md mx-4`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-red-500/20`,children:(0,K.jsx)(Cu,{className:`w-5 h-5 text-red-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:j(`printers.confirm.deleteTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:j(`printers.confirm.deleteMessage`,{name:e.name})})]})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:(0,K.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:j(`printers.deleteArchives`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:j(B?`printers.confirm.deleteArchivesNote`:`printers.confirm.keepArchivesNote`)})]})]})}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{z(!1),V(!0)},children:j(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,onClick:()=>{Sn.mutate({deleteArchives:B}),z(!1),V(!0)},children:`Delete`})]})]})})}),e.is_active===!1?(0,K.jsx)(K.Fragment,{children:r===`compact`?(0,K.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 px-2 py-1.5 rounded-full bg-amber-500/15 border border-amber-500/30`,children:[(0,K.jsx)(Lu,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-[11px] text-amber-400 font-medium truncate`,children:j(`printers.maintenance.pillLabel`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.status.title`,`Status`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`p-3 bg-amber-500/10 border border-amber-500/30 rounded-[10px] flex items-center gap-3`,children:[(0,K.jsx)(Lu,{className:`w-6 h-6 text-amber-400 shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-amber-400 font-medium`,children:j(`printers.maintenance.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:j(`printers.maintenance.subtitle`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,disabled:Yn.isPending||!F(`printers:update`),onClick:()=>Yn.mutate(!0),title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:j(`printers.maintenance.exitButton`)})]})]})}):G?.connected&&(0,K.jsxs)(K.Fragment,{children:[r===`compact`?(()=>{let e=G.hms_errors?Vp(G.hms_errors):[],t=G.state===`FAILED`||e.length>0,n=G.state===`RUNNING`||G.state===`PAUSE`?Math.max(0,Math.min(100,G.progress||0)):hn||t?100:0,r=G.state===`RUNNING`||G.state===`PAUSE`;return(0,K.jsxs)(`div`,{className:`relative mt-2 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`${t?`bg-status-error`:G.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`} h-1.5 rounded-full transition-all`,style:{width:`${n}%`}})}),(0,K.jsx)(`span`,{className:`w-9 shrink-0 text-right text-[11px] leading-none ${r?`text-white`:`text-bambu-gray`}`,children:r?`${Math.round(n)}%`:`---%`})]})})():(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.status.title`,`Status`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(()=>{let t=!!(G.current_print&&(G.state===`RUNNING`||G.state===`PAUSE`)),n=!t&&mn&&_n,r=t?gn:n?_n.name:null,i=t?G.cover_url:n?_n.coverUrl:null,a=t?G.progress||0:n?100:0;return(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded-[10px] relative overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>Ne(!0),disabled:!t||(G.printable_objects_count??0)<2||!F(`printers:control`),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${t&&(G.printable_objects_count??0)>=2&&F(`printers:control`)?`text-bambu-gray hover:text-white hover:bg-white/10`:`text-bambu-gray/30 cursor-not-allowed`}`,title:F(`printers:control`)?t?(G.printable_objects_count??0)>=2?j(`printers.skipObjects.tooltip`):j(`printers.skipObjects.requiresMultiple`):j(`printers.skipObjects.onlyWhilePrinting`):j(`printers.permission.noControl`),children:[(0,K.jsx)(sT,{className:`w-4 h-4`}),tr&&tr.skipped_count>0&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full`,children:tr.skipped_count})]}),(0,K.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,K.jsx)(Pke,{url:i,printName:r||void 0,className:`w-24 h-24 max-[520px]:w-20 max-[520px]:h-20`}),(0,K.jsxs)(`div`,{className:`flex h-24 max-[520px]:h-20 min-w-0 flex-1 flex-col justify-between pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-[18px] items-center gap-2 pr-8`,children:[(0,K.jsx)(`p`,{className:`min-w-0 truncate text-sm text-bambu-gray`,children:Rke(G.state,G.stg_cur_name)}),bn]}),(0,K.jsx)(`p`,{className:`min-h-[18px] truncate pr-8 text-sm ${r?`text-white`:`text-bambu-gray/70`}`,children:r||j(`printers.noActiveJob`,`No active job`)}),(0,K.jsxs)(`div`,{className:`flex h-3 items-center gap-2 text-sm`,children:[(0,K.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 rounded-full bg-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`${t?G.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`:n?`bg-bambu-green`:`bg-bambu-dark-tertiary`} h-1.5 rounded-full transition-all`,style:{width:`${a}%`}})}),(0,K.jsx)(`span`,{className:`w-9 shrink-0 pr-1 text-right text-[11px] leading-none ${t||n?`text-white`:`text-bambu-gray`}`,children:t||n?`${Math.round(a)}%`:`---%`})]}),(0,K.jsx)(`div`,{className:`flex min-h-[16px] items-center gap-2 text-xs text-bambu-gray`,children:t?(0,K.jsxs)(K.Fragment,{children:[G.remaining_time!=null&&G.remaining_time>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(G.remaining_time*60)]}),(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,title:j(`printers.estimatedCompletion`),children:[`ETA `,Sf(G.remaining_time,g,j)]})]}),G.layer_num!=null&&G.total_layers!=null&&G.total_layers>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),G.layer_num,`/`,G.total_layers]}),un&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Started by ${un}`,children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),un]})]}):fn?(0,K.jsxs)(`p`,{className:`truncate`,title:fn.print_name||fn.filename,children:[`Last: `,fn.print_name||fn.filename,fn.completed_at&&(0,K.jsxs)(`span`,{className:`ml-1 text-bambu-gray/60`,children:[`• `,yf(fn.completed_at,{month:`short`,day:`numeric`})]})]}):(0,K.jsx)(`span`,{children:j(`printers.readyToPrint`)})})]})]}),(0,K.jsx)(_le,{printerId:e.id,printerModel:e.model,loadedFilamentTypes:Ft,loadedFilaments:It,variant:`panelExtension`})]})})()]}),G.temperatures&&r===`expanded`&&(()=>{let t=G.temperatures.nozzle_heating||G.temperatures.nozzle_2_heating||!1,n=G.temperatures.bed_heating||!1,r=G.temperatures.chamber_heating||!1,i=e.nozzle_count===2||G.temperatures.nozzle_2!==void 0,a=(()=>{let e=[`nozzle`];return G.temperatures.nozzle_2!==void 0&&e.push(`nozzle_2`),e.push(`bed`),G.temperatures.chamber!==void 0&&e.push(`chamber`),e})(),o=G.active_extruder===1?`L`:`R`,s=G.nozzle_rack?.find(e=>e.id===1),c=G.nozzle_rack?.find(e=>e.id===0),l=c||s,u=G.connected&&F(`printers:control`),d=u?void 0:j(`printers.permission.noControl`),f=`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,p=zke.has(e.model??``),m=[{key:`part`,label:j(`printers.fans.partCooling`),value:G.cooling_fan_speed??0,Icon:Zs,activeClass:`text-cyan-400`},{key:`aux`,label:j(`printers.fans.auxiliary`),value:G.big_fan1_speed??0,Icon:Iu,activeClass:`text-blue-400`},...p?[{key:`chamber`,label:j(`printers.fans.chamber`),value:G.big_fan2_speed??0,Icon:Do,activeClass:`text-green-400`}]:[]];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-2 flex items-stretch gap-1.5 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&Te(we===`nozzle-temp`?null:`nozzle-temp`),children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`nozzle`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(gW,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-orange-400`,isHeating:t}),G.temperatures.nozzle_2===void 0?l?(0,K.jsx)(hW,{slot:l,index:0,activeStatus:!0,filamentName:l.filament_id?Lt?.[l.filament_id]?.name:void 0,children:(0,K.jsxs)(`div`,{className:`cursor-default`,children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`°C`]})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`°C`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:`L / R`}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`° / `,Math.round(G.temperatures.nozzle_2||0),`°`]})]}),we===`nozzle-temp`&&(i?(0,K.jsx)(SW,{title:`Set Nozzle Temperatures`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:260,isPending:In.isPending,onClose:()=>Te(null),children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 px-3 py-2.5`,children:[(0,K.jsx)(CW,{label:`Left Temp`,current:G.temperatures.nozzle,target:G.temperatures.nozzle_target,isActive:o===`L`,isPending:In.isPending,onSubmit:e=>In.mutate({target:e,nozzle:1}),options:Rp(D,`C`)}),(0,K.jsx)(CW,{label:`Right Temp`,current:G.temperatures.nozzle_2,target:G.temperatures.nozzle_2_target,isActive:o===`R`,isPending:In.isPending,onSubmit:e=>In.mutate({target:e,nozzle:0}),options:Rp(D,`C`)})]})}):(0,K.jsx)(SW,{title:`Set Nozzle Temperature`,unit:`°C`,customMin:0,customMax:320,isPending:In.isPending,options:Rp(D,`C`),onClose:()=>Te(null),onSubmit:e=>In.mutate({target:e,nozzle:G.active_extruder??0})}))]}),(0,K.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&Te(we===`bed-temp`?null:`bed-temp`),children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`bed`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(gW,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-blue-400`,isHeating:n}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.bed`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.bed||0),`°C`]}),we===`bed-temp`&&(0,K.jsx)(SW,{title:`Set Bed Temperature`,unit:`°C`,customMin:0,customMax:140,isPending:Ln.isPending,options:Rp(O,`C`),onClose:()=>Te(null),onSubmit:e=>Ln.mutate(e)})]}),G.temperatures.chamber!==void 0&&(()=>{let e=G.supports_chamber_heater===!0;return(0,K.jsxs)(`div`,{className:e?f:`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center`,title:e?d:void 0,onClick:e?()=>u&&Te(we===`chamber-temp`?null:`chamber-temp`):void 0,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`chamber`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(gW,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-green-400`,isHeating:r}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.chamber`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.chamber||0),`°C`]}),e&&we===`chamber-temp`&&(0,K.jsx)(SW,{title:`Set Chamber Temperature`,unit:`°C`,customMin:0,customMax:60,isPending:Rn.isPending,options:Rp(k,`C`),onClose:()=>Te(null),onSubmit:e=>Rn.mutate(e)})]})})(),i&&(0,K.jsx)(wke,{leftSlot:s,rightSlot:c,activeNozzle:o,filamentInfo:Lt,children:(0,K.jsxs)(`div`,{className:`relative text-center px-3 py-1.5 bg-bambu-dark rounded-lg h-full flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?j(`printers.activeNozzle`,{nozzle:j(o===`L`?`common.left`:`common.right`)}):d,onClick:()=>u&&Te(we===`nozzle-select`?null:`nozzle-select`),children:[(0,K.jsx)(Mke,{className:`w-3.5 h-3.5 mb-0.5 text-amber-400`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] font-bold ${o===`L`?`text-amber-400`:`text-gray-500`}`,children:[`L`,s?.nozzle_diameter?` ${s.nozzle_diameter}`:``]}),(0,K.jsx)(`span`,{className:`text-[9px] text-bambu-gray/40`,children:`·`}),(0,K.jsxs)(`span`,{className:`text-[11px] font-bold ${o===`R`?`text-amber-400`:`text-gray-500`}`,children:[`R`,c?.nozzle_diameter?` ${c.nozzle_diameter}`:``]})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),we===`nozzle-select`&&(0,K.jsx)(SW,{title:`Set Nozzle Selection`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:140,isPending:Bn.isPending,options:[{label:`Left`,value:1},{label:`Right`,value:0}],onClose:()=>Te(null),onSubmit:e=>Bn.mutate(e)})]})}),G.nozzle_rack&&G.nozzle_rack.some(e=>e.id>=2)&&(0,K.jsx)(Tke,{slots:G.nozzle_rack,filamentInfo:Lt})]}),(0,K.jsx)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:m.map(({key:e,label:t,value:n,Icon:r,activeClass:i})=>{let a=n>0;return(0,K.jsxs)(`div`,{className:`relative px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 min-w-0 flex items-center justify-center gap-1 transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?t:d,onClick:()=>u&&Te(we===`fan-${e}`?null:`fan-${e}`),children:[(0,K.jsx)(r,{className:`w-3 h-3 shrink-0 ${a?i:`text-bambu-gray/50`}`}),(0,K.jsxs)(`span`,{className:`text-[10px] leading-none ${a?`text-white`:`text-bambu-gray/50`}`,children:[n,`%`]}),we===`fan-${e}`&&(0,K.jsx)(SW,{title:`Set ${t} Speed`,unit:`%`,customMin:0,customMax:100,isPending:zn.isPending,options:Rp(A,`%`),onClose:()=>Te(null),onSubmit:t=>zn.mutate({fan:e,speed:t})})]},e)})})]})})(),r===`expanded`&&hn&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>Fn.mutate(),disabled:Fn.isPending||!F(`printers:clear_plate`),className:`mt-2 w-full inline-flex items-center justify-center gap-2 px-3 py-1.5 rounded-lg bg-yellow-500/20 border border-yellow-400/40 text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs font-medium disabled:opacity-50`,title:F(`printers:clear_plate`)?j(`printers.plateStatus.markCleared`):j(`printers.permission.noControl`),children:[Fn.isPending?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(GU,{className:`w-4 h-4`}),j(`printers.plateStatus.markCleared`)]}),r===`expanded`&&(()=>{let t=G.state===`RUNNING`,n=G.state===`PAUSE`,r=t||n,i=Mn.isPending||Nn.isPending||Pn.isPending,a=`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed opacity-50`,o=`flex h-8 w-8 items-center justify-center rounded-lg text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,s=`flex h-8 w-20 items-center justify-center gap-1 px-2 rounded-lg text-xs font-medium transition-colors`;return(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.controls`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-2 gap-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,K.jsx)(`button`,{onClick:()=>Vn.mutate(!G.chamber_light),disabled:!G.connected||Vn.isPending||!F(`printers:control`),className:`${o} ${G.chamber_light?`bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:control`)?G.chamber_light?j(`printers.chamberLightOff`):j(`printers.chamberLightOn`):j(`printers.permission.noControl`),children:(0,K.jsx)(oT,{on:G.chamber_light??!1,className:`w-4 h-4`})}),[`P2S`,`X2D`,`H2D`,`H2C`,`H2S`].includes(e.model??``)&&(()=>{let t=G.airduct_mode===1,n=t?ac:nu,r=t?`text-orange-400`:`text-sky-400`,i=t?`bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`bg-sky-500/10 text-sky-400 hover:bg-sky-500/20`;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>xe(be===e.id?null:e.id),disabled:!F(`printers:control`),className:`${o} ${i}`,title:`${j(`printers.airduct.title`)}: ${j(t?`printers.airduct.heating`:`printers.airduct.cooling`)}`,children:(0,K.jsx)(n,{className:`w-4 h-4 ${r}`})}),be===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>xe(null)}),(0,K.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:`cooling`,label:j(`printers.airduct.cooling`),modeId:0},{mode:`heating`,label:j(`printers.airduct.heating`),modeId:1}].map(({mode:e,label:t,modeId:n})=>(0,K.jsxs)(`button`,{onClick:()=>{Un.mutate(e),xe(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors flex items-center gap-2 ${G.airduct_mode===n?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e===`heating`?(0,K.jsx)(ac,{className:`w-3 h-3`}):(0,K.jsx)(nu,{className:`w-3 h-3`}),t]},e))})]})]})})(),(()=>{let t=F(`printers:control`),n=r||!t,i=`flex h-8 w-8 items-center justify-center rounded bg-indigo-500/15 text-indigo-300 transition-colors hover:bg-indigo-500/30 disabled:cursor-not-allowed disabled:opacity-50`,a=t=>{let n=t*Ee*1,r=`bambuddy.bedJog.warned.${e.id}`;(()=>{try{return sessionStorage.getItem(r)===`1`}catch{return!1}})()?Wn.mutate({distance:n,force:!0}):ke({distance:n})},s=(e,t)=>{Gn.mutate({x:e,y:t})},c=e=>{Kn.mutate(e)};return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>Ce(Se===e.id?null:e.id),disabled:n,className:`${o} ${n?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-indigo-500/10 text-indigo-400 hover:bg-indigo-500/20`}`,title:j(t?r?`printers.bedJog.disabledWhilePrinting`:`printers.bedJog.title`:`printers.permission.noControl`),children:(0,K.jsx)(ll,{className:`w-4 h-4`})}),Se===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>Ce(null)}),(0,K.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 flex w-[216px] flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:j(`printers.bedJog.title`)}),(0,K.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex justify-center px-3 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-1`,children:[(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(0,Ee),disabled:Gn.isPending,className:i,"aria-label":`Move Y forward`,children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(-Ee,0),disabled:Gn.isPending,className:i,"aria-label":`Move X left`,children:(0,K.jsx)(jo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{Ce(null),qn.mutate(`all`)},disabled:qn.isPending,className:i,"aria-label":j(`printers.bedJog.homeZ`),children:(0,K.jsx)(Ac,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>s(Ee,0),disabled:Gn.isPending,className:i,"aria-label":`Move X right`,children:(0,K.jsx)(No,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(0,-Ee),disabled:Gn.isPending,className:i,"aria-label":`Move Y back`,children:(0,K.jsx)(Ao,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>a(-1),disabled:Wn.isPending,className:i,"aria-label":j(`printers.bedJog.up`),children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,K.jsx)(Rc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(1),disabled:Wn.isPending,className:i,"aria-label":j(`printers.bedJog.down`),children:(0,K.jsx)(Ao,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>c(-Ee),disabled:Kn.isPending,className:i,"aria-label":`Retract filament`,children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,K.jsx)(`span`,{className:`text-sm font-semibold leading-none`,children:`E`})}),(0,K.jsx)(`button`,{onClick:()=>c(Ee),disabled:Kn.isPending,className:i,"aria-label":`Extrude filament`,children:(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]})}),(0,K.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`px-3 pt-2.5 pb-3`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-[9px] uppercase tracking-wider text-bambu-gray/70`,children:j(`printers.bedJog.step`)}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:[1,10,50].map(e=>(0,K.jsx)(`button`,{onClick:()=>De(e),className:`flex-1 px-1 py-1 rounded text-[10px] transition-colors ${Ee===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:e},e))})]})]})]})]})})(),(0,K.jsxs)(`div`,{className:`inline-flex rounded-lg ${e.plate_detection_enabled?`ring-1 ring-green-500`:``}`,children:[(0,K.jsx)(`button`,{onClick:hr,disabled:!G.connected||Jn.isPending||!F(`printers:update`),className:`${o} rounded-r-none ${e.plate_detection_enabled?`bg-green-500/10 text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:update`)?e.plate_detection_enabled?j(`printers.plateDetection.enabledClick`):j(`printers.plateDetection.disabledClick`):j(`printers.plateDetection.noPermission`),children:Jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Il,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:gr,disabled:!G.connected||Ct||!F(`printers:update`),className:`flex h-8 w-8 items-center justify-center rounded-r-lg border-l border-bambu-dark-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e.plate_detection_enabled?`bg-green-500/10 text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:update`)?j(`printers.plateDetection.manageCalibration`):j(`printers.plateDetection.noPermission`),children:Ct?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(is,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{"data-testid":`speed-control`,onClick:()=>ye(ve===e.id?null:e.id),disabled:!r||!F(`printers:control`),className:`${o} ${r?`bg-amber-500/10 text-amber-400 hover:bg-amber-500/20`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`}`,title:r?j(`printers.speed.title`):void 0,children:(0,K.jsx)(hc,{className:`w-4 h-4`})}),ve===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ye(null)}),(0,K.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:1,label:j(`printers.speed.silent`)},{mode:2,label:j(`printers.speed.standard`)},{mode:3,label:j(`printers.speed.sport`)},{mode:4,label:j(`printers.speed.ludicrous`)}].map(({mode:e,label:t})=>(0,K.jsx)(`button`,{onClick:()=>{Hn.mutate(e),ye(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors ${G.speed_level===e?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:t},e))})]})]})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-2 flex-shrink-0`,children:[(()=>{let e=!r||i||!F(`printers:control`);return(0,K.jsxs)(`button`,{onClick:()=>n?je(!0):_e(!0),disabled:e,className:` + `,style:{maxWidth:`calc(100vw - 24px)`},onMouseEnter:w,onMouseLeave:T,children:(0,K.jsxs)(`div`,{className:`w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm p-2.5 space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:n}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] tracking-wide text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.serialNumber`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono truncate`,children:e.serial_number||`—`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] tracking-wide text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.firmwareVersion`)}),(0,K.jsx)(`span`,{className:`text-[10px] text-white font-mono truncate`,children:e.sw_ver||`—`})]}),(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray font-medium shrink-0`,children:s(`printers.amsPopup.friendlyName`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary/50`})]}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>i&&p(e.target.value),onKeyDown:e=>e.key===`Enter`&&E(),onFocus:()=>b(!0),onBlur:()=>{b(!1),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>l(!1),200)},placeholder:i?s(`printers.amsPopup.friendlyNamePlaceholder`):r?.[e.id]||`—`,disabled:!i,title:i?void 0:s(`printers.amsPopup.noEditPermission`),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-xs text-white placeholder-bambu-gray/60 focus:outline-none focus:border-bambu-green disabled:opacity-50 disabled:cursor-not-allowed`,maxLength:100}),i&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[g&&(0,K.jsx)(`p`,{className:`text-[10px] text-red-400 break-words`,children:g}),(0,K.jsxs)(`div`,{className:`flex gap-1 justify-end`,children:[(0,K.jsx)(`button`,{onClick:E,disabled:m,className:`px-2 py-0.5 text-[10px] bg-bambu-green text-white rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:s(`printers.amsPopup.save`)}),r?.[e.id]&&(0,K.jsx)(`button`,{onClick:async()=>{if(i){h(!0),_(null);try{await Q.deleteAmsLabel(t,e.id,e.serial_number),a(),l(!1)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}},disabled:m,className:`px-2 py-0.5 text-[10px] bg-bambu-dark-tertiary text-bambu-gray rounded hover:bg-bambu-dark-tertiary/70 disabled:opacity-50`,children:s(`printers.amsPopup.clear`)})]})]})]})]})})]})}var kW={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}};function AW({printer:e,hideIfDisconnected:t,maintenanceInfo:n,viewMode:r=`expanded`,cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,linkedSpools:s,spoolmanUrl:c,spoolmanSyncMode:l,onGetAssignment:u,onUnassignSpool:d,spoolmanSpools:f,spoolmanSlotAssignments:p,spoolmanLoading:m=!1,onUnassignSpoolmanSpool:h,timeFormat:g=`system`,cameraViewMode:_=`window`,onOpenEmbeddedCamera:v,checkPrinterFirmware:b=!0,dryingPresets:x=kW,requirePlateClear:S=!1,selectionMode:C=!1,isSelected:w=!1,onToggleSelect:T,onOpenCompactCard:E,nozzleTempPresets:D=Mp,bedTempPresets:O=Np,chamberTempPresets:k=Pp,fanSpeedPresets:A=Fp}){let{t:j}=W(),M=no(),N=$n(),{showToast:P}=Td(),{hasPermission:F}=dd(),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!0),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(!1),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(!1),[ce,le]=(0,y.useState)(null),[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)(!1),[me,he]=(0,y.useState)(!1),[ge,_e]=(0,y.useState)(!1),[ve,ye]=(0,y.useState)(null),[be,xe]=(0,y.useState)(null),[Se,Ce]=(0,y.useState)(null),[we,Te]=(0,y.useState)(null),[Ee,De]=(0,y.useState)(10),[Oe,ke]=(0,y.useState)(null),[Ae,je]=(0,y.useState)(!1),[Me,Ne]=(0,y.useState)(!1),[Pe,Fe]=(0,y.useState)(!1),[Ie,Le]=(0,y.useState)(!1),[Re,ze]=(0,y.useState)(!1),Be=(0,y.useCallback)(()=>Le(!1),[]),[Ve,He]=(0,y.useState)(null),[Ue,We]=(0,y.useState)(null),[Ge,Ke]=(0,y.useState)(`n3f`),[qe,Je]=(0,y.useState)(`PLA`),[Ye,Xe]=(0,y.useState)(50),[Ze,Qe]=(0,y.useState)(4),[$e,et]=(0,y.useState)(!1),[tt,nt]=(0,y.useState)(null),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)(!1),st=(0,y.useRef)(null),ct=(0,y.useRef)(0),[lt,ut]=(0,y.useState)(null),[dt,ft]=(0,y.useState)(null),[pt,mt]=(0,y.useState)(null),[ht,gt]=(0,y.useState)(null),[_t,vt]=(0,y.useState)(null),[yt,bt]=(0,y.useState)(!1),[xt,St]=(0,y.useState)(null),[Ct,wt]=(0,y.useState)(!1),[Tt,Et]=(0,y.useState)(!1),[Dt,Ot]=(0,y.useState)(null),[kt,At]=(0,y.useState)(!1),[jt,Mt]=(0,y.useState)(!1),{data:G}=q({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:3e4}),{data:Nt}=q({queryKey:[`firmwareUpdate`,e.id],queryFn:()=>id.checkPrinterUpdate(e.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:b&&F(`firmware:read`)}),Pt=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams)for(let t of G.ams)for(let n of t.tray||[])n.tray_info_idx&&e.add(n.tray_info_idx);for(let t of G?.vt_tray??[])t.tray_info_idx&&e.add(t.tray_info_idx);if(G?.nozzle_rack)for(let t of G.nozzle_rack)t.filament_id&&e.add(t.filament_id);return Array.from(e)},[G?.ams,G?.vt_tray,G?.nozzle_rack]),Ft=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams)for(let t of G.ams)for(let n of t.tray||[])n.tray_type&&e.add(n.tray_type.toUpperCase());for(let t of G?.vt_tray??[])t.tray_type&&e.add(t.tray_type.toUpperCase());return e},[G?.ams,G?.vt_tray]),It=(0,y.useMemo)(()=>{let e=new Set;if(G?.ams){for(let t of G.ams)for(let n of t.tray||[])if(n.tray_type&&n.tray_color){let t=n.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${n.tray_type.toUpperCase()}:${t}`)}}for(let t of G?.vt_tray??[])if(t.tray_type&&t.tray_color){let n=t.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${t.tray_type.toUpperCase()}:${n}`)}return e},[G?.ams,G?.vt_tray]),{data:Lt}=q({queryKey:[`filamentInfo`,Pt],queryFn:()=>Q.getFilamentInfo(Pt),enabled:Pt.length>0,staleTime:300*1e3}),{data:Rt}=q({queryKey:[`slotPresets`,e.id],queryFn:()=>Q.getSlotPresets(e.id),staleTime:120*1e3}),zt=G?.state===`RUNNING`||G?.state===`PAUSE`?G?.current_archive_id??null:null,{data:Bt}=q({queryKey:[`archive-plates`,zt],queryFn:()=>Q.getArchivePlates(zt),enabled:zt!=null,staleTime:300*1e3}),Vt=!Bt?.is_multi_plate||G?.current_plate_id==null?null:Bt.plates.find(e=>e.index===G.current_plate_id)?.name||j(`printers.plateNumber`,`Plate {{number}}`,{number:G.current_plate_id}),{data:Ht,refetch:Ut}=q({queryKey:[`amsLabels`,e.id],queryFn:()=>Q.getAmsLabels(e.id),staleTime:300*1e3}),[Wt,Gt]=(0,y.useState)(null);(0,y.useEffect)(()=>{G?.wifi_signal!=null&&Gt(G.wifi_signal)},[G?.wifi_signal]);let Kt=G?.wifi_signal??Wt,qt=(0,y.useRef)(void 0);(0,y.useEffect)(()=>{G?.connected!==void 0&&(qt.current=G.connected)},[G?.connected]);let Jt=G?.connected??qt.current,Yt=(0,y.useRef)({});(0,y.useEffect)(()=>{G?.ams_extruder_map&&Object.keys(G.ams_extruder_map).length>0&&(Yt.current=G.ams_extruder_map)},[G?.ams_extruder_map]);let Xt=G?.ams_extruder_map&&Object.keys(G.ams_extruder_map).length>0?G.ams_extruder_map:Yt.current,Zt=(0,y.useRef)([]);(0,y.useEffect)(()=>{G?.ams&&G.ams.length>0&&(Zt.current=G.ams)},[G?.ams]);let Qt=G?.ams&&G.ams.length>0?G.ams:Zt.current,$t=(0,y.useRef)(void 0),en=G?.tray_now;en!==void 0&&en!==255?$t.current=en:en===255&&($t.current=void 0);let tn=en!==void 0&&en!==255?en:$t.current,{data:nn}=q({queryKey:[`smartPlugByPrinter`,e.id],queryFn:()=>Q.getSmartPlugByPrinter(e.id)}),{data:rn}=q({queryKey:[`scriptPlugsByPrinter`,e.id],queryFn:()=>Q.getScriptPlugsByPrinter(e.id)}),{data:an}=q({queryKey:[`smartPlugStatus`,nn?.id],queryFn:()=>nn?Q.getSmartPlugStatus(nn.id):null,enabled:!!nn,refetchInterval:1e4}),{data:on}=q({queryKey:[`queue`,e.id,`pending`],queryFn:()=>Q.getQueue(e.id,`pending`)}),sn=(0,y.useMemo)(()=>on?.length?hT(on,Ft,It).length:0,[on,Ft,It]),{data:cn}=q({queryKey:[`queue`,e.id,`printing`],queryFn:()=>Q.getQueue(e.id,`printing`),enabled:G?.state===`RUNNING`}),{data:ln}=q({queryKey:[`currentPrintUser`,e.id],queryFn:()=>Q.getCurrentPrintUser(e.id),enabled:G?.state===`RUNNING`}),un=cn?.[0]?.created_by_username||ln?.username,{data:dn}=q({queryKey:[`archives`,e.id,`last`],queryFn:()=>Q.getArchives(e.id,1,0),enabled:G?.connected&&G?.state!==`RUNNING`}),fn=dn?.[0],pn=G?.state===`RUNNING`||G?.state===`PAUSE`,mn=S&&G?.awaiting_plate_clear===!0,hn=G?.connected&&mn&&!pn,gn=G?.current_print&&pn?Ap(G.subtask_name||G.current_print||null,G.gcode_file,j,Vt):null,[_n,vn]=(0,y.useState)(null);(0,y.useEffect)(()=>{gn?vn({name:gn,coverUrl:G?.cover_url??null}):mn||vn(null)},[gn,mn,G?.cover_url]);let yn=!S||!G?.connected?null:pn?{label:j(`printers.plateStatus.inUse`),className:`bg-blue-500/20 text-blue-400`}:G.awaiting_plate_clear?{label:j(`printers.plateStatus.notCleared`),className:`bg-yellow-500/20 text-yellow-400`}:{label:j(`printers.plateStatus.cleared`),className:`bg-status-ok/20 text-status-ok`},bn=yn?(0,K.jsx)(`span`,{className:`inline-flex flex-shrink-0 items-center rounded-full px-2 py-0.5 text-[10px] font-medium ${yn.className}`,children:yn.label}):null,xn=t&&Jt===!1,Sn=J({mutationFn:t=>Q.deletePrinter(e.id,t.deleteArchives),onSuccess:()=>{M.invalidateQueries({queryKey:[`printers`]}),M.invalidateQueries({queryKey:[`archives`]}),M.invalidateQueries({queryKey:[`maintenanceOverview`]})},onError:e=>P(e.message||j(`printers.toast.failedToDelete`),`error`)}),Cn=J({mutationFn:()=>Q.connectPrinter(e.id),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),wn=J({mutationFn:()=>Q.refreshPrinterStatus(e.id),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),P(j(`printers.forceRefreshSuccess`),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Tn=J({mutationFn:e=>Q.unlinkSpool(e),onSuccess:e=>{P(j(`spoolman.unlinkSuccess`)||e?.message,`success`),M.invalidateQueries({queryKey:[`linked-spools`]}),M.invalidateQueries({queryKey:[`unlinked-spools`]}),M.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})},onError:e=>{P(e.message||j(`spoolman.unlinkFailed`),`error`)}}),En=J({mutationFn:({amsId:t,temp:n,duration:r,filament:i,rotateTray:a})=>Q.startDrying(e.id,t,n,r,i,a),onSuccess:()=>{We(null),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Dn=J({mutationFn:t=>Q.stopDrying(e.id,t),onSuccess:()=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),On=J({mutationFn:t=>Q.setAmsFilamentBackup(e.id,t),onSuccess:(t,n)=>{M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),M.invalidateQueries({queryKey:[`printer-status`,e.id]}),P(j(n?`printers.amsBackup.toastEnabled`:`printers.amsBackup.toastDisabled`),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),kn=J({mutationFn:e=>nn?Q.controlSmartPlug(nn.id,e):Promise.reject(`No plug`),onSuccess:()=>{M.invalidateQueries({queryKey:[`smartPlugStatus`,nn?.id]})}}),An=J({mutationFn:e=>nn?Q.updateSmartPlug(nn.id,{auto_off:e}):Promise.reject(`No plug`),onSuccess:()=>{M.invalidateQueries({queryKey:[`smartPlugByPrinter`,e.id]}),M.invalidateQueries({queryKey:[`smart-plugs`]})}}),jn=J({mutationFn:({id:e,action:t})=>Q.controlSmartPlug(e,t),onSuccess:()=>{P(j(`printers.toast.scriptTriggered`))},onError:e=>P(e.message||j(`printers.toast.failedToRunScript`),`error`)}),Mn=J({mutationFn:()=>Q.stopPrint(e.id),onSuccess:()=>{P(j(`printers.toast.printStopped`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToStopPrint`),`error`)}),Nn=J({mutationFn:()=>Q.pausePrint(e.id),onSuccess:()=>{P(j(`printers.toast.printPaused`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToPausePrint`),`error`)}),Pn=J({mutationFn:()=>Q.resumePrint(e.id),onSuccess:()=>{P(j(`printers.toast.printResumed`)),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToResumePrint`),`error`)}),Fn=J({mutationFn:()=>Q.clearPlate(e.id),onSuccess:()=>{P(j(`queue.clearPlateSuccess`)),M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,awaiting_plate_clear:!1}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),M.invalidateQueries({queryKey:[`queue`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),In=J({mutationFn:({target:t,nozzle:n})=>Q.setNozzleTemperature(e.id,t,n),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Ln=J({mutationFn:t=>Q.setBedTemperature(e.id,t),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Rn=J({mutationFn:t=>Q.setChamberTemperature(e.id,t),onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),zn=J({mutationFn:({fan:t,speed:n})=>Q.setFanSpeed(e.id,t,n),onMutate:async({fan:t,speed:n})=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let r=M.getQueryData([`printerStatus`,e.id]),i={part:`cooling_fan_speed`,aux:`big_fan1_speed`,chamber:`big_fan2_speed`}[t];return M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,[i]:n}),{previousStatus:r}},onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Bn=J({mutationFn:t=>Q.selectExtruder(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>e&&{...e,active_extruder:t}),{previousStatus:n}},onSuccess:t=>{Te(null),P(t.message),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Vn=J({mutationFn:t=>Q.setChamberLight(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{P(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToControlChamberLight`),`error`)}}),Hn=J({mutationFn:t=>Q.setPrintSpeed(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,speed_level:t})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSetSpeed`),`error`)}}),Un=J({mutationFn:t=>Q.setAirductMode(e.id,t),onMutate:async t=>{await M.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=M.getQueryData([`printerStatus`,e.id]);return M.setQueryData([`printerStatus`,e.id],e=>({...e,airduct_mode:t===`cooling`?0:1})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&M.setQueryData([`printerStatus`,e.id],r.previousStatus),P(t.message||j(`printers.toast.failedToSendCommand`),`error`)}}),Wn=J({mutationFn:({distance:t,force:n})=>Q.bedJog(e.id,t,n??!1),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Gn=J({mutationFn:({x:t,y:n})=>Q.xyJog(e.id,t,n),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Kn=J({mutationFn:t=>Q.extruderJog(e.id,t),onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),qn=J({mutationFn:t=>Q.homeAxes(e.id,t),onSuccess:()=>{try{sessionStorage.setItem(`bambuddy.bedJog.warned.${e.id}`,`1`)}catch{}P(j(`printers.bedJog.homingStarted`))},onError:e=>P(e.message||j(`printers.toast.failedToSendCommand`),`error`)}),Jn=J({mutationFn:t=>Q.updatePrinter(e.id,{plate_detection_enabled:t}),onSuccess:()=>{M.invalidateQueries({queryKey:[`printers`]}),P(Jn.variables?j(`printers.toast.plateCheckEnabled`):j(`printers.toast.plateCheckDisabled`))},onError:e=>P(e.message||j(`printers.toast.failedToUpdateSetting`),`error`)}),Yn=J({mutationFn:t=>Q.updatePrinter(e.id,{is_active:t}),onSuccess:(t,n)=>{M.invalidateQueries({queryKey:[`printers`]}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]}),P(j(n?`printers.maintenance.toastExited`:`printers.maintenance.toastEntered`,{name:e.name}),`success`)},onError:e=>P(e.message||j(`printers.toast.failedToUpdateSetting`),`error`)}),[Xn,Zn]=(0,y.useState)(!1),Qn=()=>{G?.state===`RUNNING`||G?.state===`PAUSE`?Zn(!0):Yn.mutate(!1)},er=(G?.state===`RUNNING`||G?.state===`PAUSE`)&&(G?.printable_objects_count??0)>=2,{data:tr}=q({queryKey:[`printableObjects`,e.id],queryFn:()=>Q.getPrintableObjects(e.id),enabled:Me||er,refetchInterval:Me?5e3:er?3e4:!1}),[nr,rr]=(0,y.useState)(null),ir=(0,y.useRef)(!1),ar=(0,y.useRef)(null),or=(0,y.useRef)(!1),sr=J({mutationFn:({amsId:t,slotId:n})=>Q.refreshAmsSlot(e.id,t,n),onMutate:({amsId:e,slotId:t})=>{ar.current&&clearTimeout(ar.current),ir.current=!1,or.current=!1,rr({amsId:e,slotId:t}),setTimeout(()=>{or.current=!0},2e3),ar.current=setTimeout(()=>{rr(null)},3e4)},onSuccess:e=>{P(e.message||j(`printers.toast.rfidRereadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToRereadRfid`),`error`),ar.current&&clearTimeout(ar.current),rr(null)}}),cr=J({mutationFn:({trayId:t})=>Q.loadAmsTray(e.id,t),onSuccess:e=>{P(e.message||j(`printers.toast.loadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToLoad`),`error`)}}),lr=J({mutationFn:()=>Q.unloadAms(e.id),onSuccess:e=>{P(e.message||j(`printers.toast.unloadInitiated`))},onError:e=>{P(e.message||j(`printers.toast.failedToUnload`),`error`)}}),[ur,dr]=(0,y.useState)(null),[fr,pr]=(0,y.useState)(null),mr=async()=>{try{dr(await Q.getPlateReferences(e.id))}catch{}},hr=()=>{Jn.mutate(!e.plate_detection_enabled)},gr=async()=>{wt(!0),St(null);let t=G?.chamber_light===!1;Mt(t),t&&(await Q.setChamberLight(e.id,!0),await new Promise(e=>setTimeout(e,2500)));try{St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0})),mr()}catch(n){P(n instanceof Error?n.message:j(`printers.toast.failedToCheckPlate`),`error`),t&&(await Q.setChamberLight(e.id,!1),Mt(!1))}finally{wt(!1)}},_r=(0,y.useCallback)(async()=>{St(null),jt&&(await Q.setChamberLight(e.id,!1),Mt(!1))},[jt,e.id]),vr=async t=>{Et(!0);try{let n=await Q.calibratePlateDetection(e.id,{label:t});n.success?(P(n.message||j(`printers.toast.calibrationSaved`),`success`),mr(),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))):P(n.message||j(`printers.toast.calibrationFailed`),`error`)}catch(e){P(e instanceof Error?e.message:j(`printers.toast.calibrationFailed`),`error`)}finally{Et(!1)}},yr=async(t,n)=>{try{await Q.updatePlateReferenceLabel(e.id,t,n),pr(null),mr()}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToUpdateLabel`),`error`)}},br=async t=>{try{await Q.deletePlateReference(e.id,t),P(j(`printers.toast.referenceDeleted`),`success`),mr(),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToDeleteReference`),`error`)}},xr=async()=>{if(Dt){At(!0);try{await Q.updatePrinter(e.id,{plate_detection_roi:Dt}),P(j(`printers.toast.detectionAreaSaved`),`success`),Ot(null),St(await Q.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){P(e instanceof Error?e.message:j(`printers.toast.failedToSaveDetectionArea`),`error`)}finally{At(!1)}}};(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&xt&&_r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[xt,_r]);let Sr=(0,y.useRef)(null);if((0,y.useEffect)(()=>{if(!nr)return;let e=G?.ams_status_main??0;return e!==0&&(ir.current=!0,Sr.current&&=(clearTimeout(Sr.current),null)),ir.current&&e===0&&(or.current?(ar.current&&clearTimeout(ar.current),rr(null)):Sr.current||=setTimeout(()=>{ar.current&&clearTimeout(ar.current),rr(null)},2e3)),()=>{Sr.current&&clearTimeout(Sr.current)}},[G?.ams_status_main,nr]),(0,y.useEffect)(()=>{if(!I)return;let e=e=>{let t=e.target;st.current?.contains(t)||L(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[I]),xn)return null;let Cr=()=>{switch(i){case 1:return`w-10 h-10`;case 2:return`w-14 h-14`;case 3:return`w-16 h-16`;case 4:return`w-20 h-20`;default:return`w-14 h-14`}},wr=()=>{switch(i){case 1:return`text-base truncate`;case 2:return`text-lg`;case 3:return`text-xl`;case 4:return`text-2xl`;default:return`text-lg`}},Tr=()=>{switch(i){case 1:return`mb-2`;case 2:return`mb-4`;case 3:return`mb-5`;case 4:return`mb-6`;default:return`mb-4`}},Er=Jt&&G?.state!==`RUNNING`&&G?.state!==`PAUSE`&&F(`printers:control`),Dr=e=>{e.preventDefault(),ct.current++,ct.current===1&&it(!0)},Or=e=>{e.preventDefault(),e.dataTransfer.dropEffect=Er?`copy`:`none`},kr=e=>{e.preventDefault(),ct.current--,ct.current===0&&it(!1)},Ar=async t=>{if(t.preventDefault(),ct.current=0,it(!1),!Er)return;let n=Array.from(t.dataTransfer.files)[0];if(!n)return;let r=n.name.toLowerCase();if(!r.endsWith(`.gcode`)&&!r.includes(`.gcode.`)){P(j(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`),`error`);return}ot(!0);try{let t=await Q.uploadLibraryFile(n,null),r=t.metadata?.sliced_for_model,i=DW(e.model);if(r&&i&&r.toLowerCase()!==i.toLowerCase()){await Q.deleteLibraryFile(t.id).catch(()=>{}),P(j(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:r,printerModel:i}),`error`);return}He({id:t.id,filename:t.filename})}catch{P(j(`common.uploadFailed`,`Upload failed`),`error`)}finally{ot(!1)}},jr=t=>{r!==`compact`||C||t.target.closest(`button, a, input, select, textarea, [role="button"]`)||E?.(e.id)},Mr=`!h-8 !min-h-8 !w-8 !px-0 !py-0`,Nr=({amsId:e,slotId:t,loadTrayId:n,isRefreshing:r,includeRfid:i=!0})=>{let a=G?.state===`RUNNING`;return(0,K.jsxs)(K.Fragment,{children:[i&&(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:ams_rfid`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:n=>{n.stopPropagation(),!(a||!F(`printers:ams_rfid`))&&sr.mutate({amsId:e,slotId:t})},disabled:a||r||!F(`printers:ams_rfid`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:ams_rfid`)?void 0:j(`printers.permission.noAmsRfid`),children:[(0,K.jsx)(Ol,{className:`w-3 h-3 ${r?`animate-spin`:``}`}),j(`printers.rfid.reread`)]}),(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),!(a||!F(`printers:control`))&&cr.mutate({trayId:n})},disabled:a||!F(`printers:control`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:control`)?void 0:j(`printers.permission.noControl`),children:[(0,K.jsx)(Jc,{className:`w-3 h-3`}),j(`printers.ams.load`)]}),(0,K.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${F(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),!(a||!F(`printers:control`))&&lr.mutate()},disabled:a||!F(`printers:control`),title:a?j(`printers.bedJog.disabledWhilePrinting`):F(`printers:control`)?void 0:j(`printers.permission.noControl`),children:[(0,K.jsx)(Yc,{className:`w-3 h-3`}),j(`printers.ams.unload`)]})]})},Pr=(0,K.jsxs)(`div`,{ref:st,className:`relative flex-shrink-0`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>L(!I),title:j(`common.more`,`More`),className:Mr,children:(0,K.jsx)(Ws,{className:`w-4 h-4`})}),I&&(0,K.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,onClick:()=>{F(`printers:update`)&&(te(!0),L(!1))},title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:[(0,K.jsx)(vl,{className:`w-4 h-4`}),j(`common.edit`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Le(!0),L(!1)},children:[(0,K.jsx)(Pc,{className:`w-4 h-4`}),j(`printers.printerInformation`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,disabled:Yn.isPending||!F(`printers:update`),onClick:()=>{F(`printers:update`)&&(L(!1),e.is_active===!1?Yn.mutate(!0):Qn())},title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:[(0,K.jsx)(Lu,{className:`w-4 h-4`}),e.is_active===!1?j(`printers.maintenance.menuExit`):j(`printers.maintenance.menuEnter`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Cn.mutate(),L(!1)},children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),j(`printers.reconnect`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2 disabled:opacity-50`,disabled:wn.isPending,onClick:()=>{wn.mutate(),L(!1)},children:[(0,K.jsx)(jl,{className:`w-4 h-4 ${wn.isPending?`animate-spin`:``}`}),j(`printers.forceRefresh`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{H(!0),L(!1)},children:[(0,K.jsx)(mu,{className:`w-4 h-4`}),j(`printers.mqttDebug`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{ze(!0),L(!1)},children:[(0,K.jsx)(cu,{className:`w-4 h-4`}),j(`diagnostic.runButton`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${F(`printers:delete`)?`text-red-400 hover:bg-bambu-dark-tertiary`:`text-red-400/50 cursor-not-allowed`}`,onClick:()=>{F(`printers:delete`)&&(z(!0),L(!1))},title:F(`printers:delete`)?void 0:j(`printers.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),j(`common.delete`)]})]})]});return(0,K.jsxs)(_d,{id:`printer-card-${e.id}`,className:`relative flex h-full flex-col ${w?`ring-2 ring-bambu-green`:``} ${C||r===`compact`?`cursor-pointer`:``}`,onClick:jr,onDragEnter:Dr,onDragOver:Or,onDragLeave:kr,onDrop:Ar,children:[C&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-start p-2`,onClick:t=>{t.stopPropagation(),T?.(e.id)},children:w?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5 text-bambu-gray`})}),(rt||at)&&(0,K.jsx)(`div`,{className:`absolute inset-0 z-10 rounded-xl border-2 border-dashed flex items-center justify-center transition-colors ${at?`bg-bambu-green/10 border-bambu-green/50`:Er?`bg-bambu-green/10 border-bambu-green`:`bg-red-500/10 border-red-500/50`}`,children:(0,K.jsx)(`div`,{className:`text-center`,children:at?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green animate-spin`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:j(`common.uploading`,`Uploading...`)})]}):Er?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Tl,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:j(`printers.dropToPrint`,`Drop to print`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ru,{className:`w-8 h-8 mx-auto mb-2 text-red-400`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-red-400`,children:j(`printers.cannotPrint`,`Printer busy`)})]})})}),(0,K.jsxs)(yd,{className:`${i>=3?`p-5`:``} flex flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:Tr(),children:[(0,K.jsx)(`div`,{className:`flex items-start justify-between gap-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(`img`,{src:pT(e.model),alt:e.model||j(`common.printer`),className:`object-contain rounded-lg flex-shrink-0 ${Cr()}`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white ${wr()}`,children:e.name}),r===`compact`&&(()=>{let e=G?.connected&&G.hms_errors?Vp(G.hms_errors):[],t=e.some(e=>e.severity<=2),n=e.length>0,r=G?.connected?t?`bg-status-error`:n?`bg-status-warning`:`bg-status-ok`:`bg-status-error`,i=G?.connected?n?`${e.length} HMS ${e.length===1?`error`:`errors`}`:j(`printers.connection.connected`):j(`printers.connection.offline`);return(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full flex-shrink-0 ${r}`,title:i})})()]}),r===`compact`&&hn&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>Fn.mutate(),disabled:Fn.isPending||!F(`printers:clear_plate`),"aria-label":j(`printers.plateStatus.markCleared`),className:`inline-flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md bg-yellow-500/20 border border-yellow-400/40 text-yellow-400 hover:bg-yellow-500/30 transition-colors disabled:opacity-50`,title:F(`printers:clear_plate`)?j(`printers.plateStatus.markCleared`):j(`printers.permission.noControl`),children:Fn.isPending?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(KU,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[e.model||`Unknown Model`,r===`expanded`&&G?.nozzles&&G.nozzles[0]?.nozzle_diameter&&(0,K.jsxs)(`span`,{className:`ml-1.5 text-bambu-gray`,title:G.nozzles[0].nozzle_type||`Nozzle`,children:[`• `,G.nozzles[0].nozzle_diameter,`mm`]}),r===`expanded`&&n&&n.total_print_hours>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-bambu-gray`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 inline-block mr-1`}),Math.round(n.total_print_hours),`h`]})]})]})]})}),r===`expanded`&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.is_active===!1?(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs bg-amber-500/20 text-amber-400`,title:j(`printers.maintenance.subtitle`),children:[(0,K.jsx)(Lu,{className:`w-3 h-3`}),j(`printers.maintenance.pillLabel`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${G?.connected?`bg-status-ok/20 text-status-ok`:`bg-status-error/20 text-status-error`}`,children:[G?.connected?(0,K.jsx)(Hc,{className:`w-3 h-3`}):(0,K.jsx)(Eu,{className:`w-3 h-3`}),G?.connected?j(`printers.connection.connected`):j(`printers.connection.offline`)]}),e.is_active!==!1&&!G?.connected&&(0,K.jsxs)(`button`,{onClick:()=>ze(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:j(`diagnostic.runButton`),children:[(0,K.jsx)(cu,{className:`w-3 h-3`}),j(`diagnostic.runButton`)]}),G?.connected&&G?.wired_network&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-status-ok/20 text-status-ok`,title:j(`printers.connection.ethernet`,`Ethernet`),children:[(0,K.jsx)(qo,{className:`w-3 h-3`}),j(`printers.connection.ethernet`,`Ethernet`)]}),G?.connected&&!G?.wired_network&&Kt!=null&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Kt>=-50||Kt>=-60?`bg-status-ok/20 text-status-ok`:Kt>=-70?`bg-status-warning/20 text-status-warning`:Kt>=-80?`bg-orange-500/20 text-orange-600`:`bg-status-error/20 text-status-error`}`,title:`WiFi: ${Kt} dBm - ${j(mT(Kt).labelKey)}`,children:[(0,K.jsx)(Yl,{className:`w-3 h-3`}),Kt,`dBm`]}),G?.connected&&(()=>{let e=G.hms_errors?Vp(G.hms_errors):[];return(0,K.jsxs)(`button`,{onClick:()=>de(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${e.length>0?e.some(e=>e.severity<=2)?`bg-status-error/20 text-status-error`:`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:j(`printers.clickToViewHmsErrors`),children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),e.length>0?e.length:`OK`]})})(),n&&(0,K.jsxs)(`button`,{onClick:()=>N(`/maintenance`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?`bg-status-error/20 text-status-error`:n.warning_count>0?`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:``}${n.due_count>0&&n.warning_count>0?`, `:``}${n.warning_count>0?`${n.warning_count} due soon`:``} - Click to view`:j(`printers.maintenanceUpToDate`),children:[(0,K.jsx)(Lu,{className:`w-3 h-3`}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:`OK`]}),sn>0&&(0,K.jsxs)(`button`,{onClick:()=>N(`/queue`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-indigo-500/20 text-indigo-400 hover:opacity-80 transition-opacity`,title:j(`printers.queue.inQueue`,{count:sn}),children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),sn]}),b&&Nt?.current_version&&Nt?.latest_version?(0,K.jsxs)(`button`,{onClick:()=>bt(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${Nt.update_available?`bg-orange-500/20 text-orange-400`:`bg-status-ok/20 text-status-ok`}`,title:Nt.update_available?j(`printers.firmwareUpdateAvailable`,{current:Nt.current_version,latest:Nt.latest_version}):j(`printers.firmwareUpToDate`,{version:Nt.current_version}),children:[Nt.update_available?(0,K.jsx)(Vs,{className:`w-3 h-3`}):(0,K.jsx)(ps,{className:`w-3 h-3`}),Nt.current_version]}):G?.firmware_version?(0,K.jsx)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-bambu-dark-tertiary/50 text-bambu-gray`,children:G.firmware_version}):null,G?.connected&&[`X1C`,`X1`,`X1E`,`X2D`,`P1S`,`P1P`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`].includes(e.model??``)&&(0,K.jsx)(`span`,{className:`flex items-center px-2 py-1 rounded-full text-xs ${G.door_open?`bg-yellow-500/20 text-yellow-400`:`bg-status-ok/20 text-status-ok`}`,title:G.door_open?j(`printers.door.open`):j(`printers.door.closed`),children:G.door_open?(0,K.jsx)(Bs,{className:`w-3 h-3`}):(0,K.jsx)(zs,{className:`w-3 h-3`})})]})})]}),R&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsx)(_d,{className:`w-full max-w-md mx-4`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-red-500/20`,children:(0,K.jsx)(Cu,{className:`w-5 h-5 text-red-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:j(`printers.confirm.deleteTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:j(`printers.confirm.deleteMessage`,{name:e.name})})]})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:(0,K.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>V(e.target.checked),className:`mt-0.5 w-4 h-4 rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:j(`printers.deleteArchives`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:j(B?`printers.confirm.deleteArchivesNote`:`printers.confirm.keepArchivesNote`)})]})]})}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{z(!1),V(!0)},children:j(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,onClick:()=>{Sn.mutate({deleteArchives:B}),z(!1),V(!0)},children:`Delete`})]})]})})}),e.is_active===!1?(0,K.jsx)(K.Fragment,{children:r===`compact`?(0,K.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 px-2 py-1.5 rounded-full bg-amber-500/15 border border-amber-500/30`,children:[(0,K.jsx)(Lu,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-[11px] text-amber-400 font-medium truncate`,children:j(`printers.maintenance.pillLabel`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.status.title`,`Status`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`p-3 bg-amber-500/10 border border-amber-500/30 rounded-[10px] flex items-center gap-3`,children:[(0,K.jsx)(Lu,{className:`w-6 h-6 text-amber-400 shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-amber-400 font-medium`,children:j(`printers.maintenance.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:j(`printers.maintenance.subtitle`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,disabled:Yn.isPending||!F(`printers:update`),onClick:()=>Yn.mutate(!0),title:F(`printers:update`)?void 0:j(`printers.permission.noEdit`),children:j(`printers.maintenance.exitButton`)})]})]})}):G?.connected&&(0,K.jsxs)(K.Fragment,{children:[r===`compact`?(()=>{let e=G.hms_errors?Vp(G.hms_errors):[],t=G.state===`FAILED`||e.length>0,n=G.state===`RUNNING`||G.state===`PAUSE`?Math.max(0,Math.min(100,G.progress||0)):hn||t?100:0,r=G.state===`RUNNING`||G.state===`PAUSE`;return(0,K.jsxs)(`div`,{className:`relative mt-2 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`${t?`bg-status-error`:G.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`} h-1.5 rounded-full transition-all`,style:{width:`${n}%`}})}),(0,K.jsx)(`span`,{className:`w-9 shrink-0 text-right text-[11px] leading-none ${r?`text-white`:`text-bambu-gray`}`,children:r?`${Math.round(n)}%`:`---%`})]})})():(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.status.title`,`Status`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(()=>{let t=!!(G.current_print&&(G.state===`RUNNING`||G.state===`PAUSE`)),n=!t&&mn&&_n,r=t?gn:n?_n.name:null,i=t?G.cover_url:n?_n.coverUrl:null,a=t?G.progress||0:n?100:0;return(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded-[10px] relative overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>Ne(!0),disabled:!t||(G.printable_objects_count??0)<2||!F(`printers:control`),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${t&&(G.printable_objects_count??0)>=2&&F(`printers:control`)?`text-bambu-gray hover:text-white hover:bg-white/10`:`text-bambu-gray/30 cursor-not-allowed`}`,title:F(`printers:control`)?t?(G.printable_objects_count??0)>=2?j(`printers.skipObjects.tooltip`):j(`printers.skipObjects.requiresMultiple`):j(`printers.skipObjects.onlyWhilePrinting`):j(`printers.permission.noControl`),children:[(0,K.jsx)(cT,{className:`w-4 h-4`}),tr&&tr.skipped_count>0&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[10px] font-bold bg-red-500 text-white rounded-full`,children:tr.skipped_count})]}),(0,K.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,K.jsx)(Nke,{url:i,printName:r||void 0,className:`w-24 h-24 max-[520px]:w-20 max-[520px]:h-20`}),(0,K.jsxs)(`div`,{className:`flex h-24 max-[520px]:h-20 min-w-0 flex-1 flex-col justify-between pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-h-[18px] items-center gap-2 pr-8`,children:[(0,K.jsx)(`p`,{className:`min-w-0 truncate text-sm text-bambu-gray`,children:Lke(G.state,G.stg_cur_name)}),bn]}),(0,K.jsx)(`p`,{className:`min-h-[18px] truncate pr-8 text-sm ${r?`text-white`:`text-bambu-gray/70`}`,children:r||j(`printers.noActiveJob`,`No active job`)}),(0,K.jsxs)(`div`,{className:`flex h-3 items-center gap-2 text-sm`,children:[(0,K.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 rounded-full bg-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`${t?G.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`:n?`bg-bambu-green`:`bg-bambu-dark-tertiary`} h-1.5 rounded-full transition-all`,style:{width:`${a}%`}})}),(0,K.jsx)(`span`,{className:`w-9 shrink-0 pr-1 text-right text-[11px] leading-none ${t||n?`text-white`:`text-bambu-gray`}`,children:t||n?`${Math.round(a)}%`:`---%`})]}),(0,K.jsx)(`div`,{className:`flex min-h-[16px] items-center gap-2 text-xs text-bambu-gray`,children:t?(0,K.jsxs)(K.Fragment,{children:[G.remaining_time!=null&&G.remaining_time>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(G.remaining_time*60)]}),(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,title:j(`printers.estimatedCompletion`),children:[`ETA `,Sf(G.remaining_time,g,j)]})]}),G.layer_num!=null&&G.total_layers!=null&&G.total_layers>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),G.layer_num,`/`,G.total_layers]}),un&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Started by ${un}`,children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),un]})]}):fn?(0,K.jsxs)(`p`,{className:`truncate`,title:fn.print_name||fn.filename,children:[`Last: `,fn.print_name||fn.filename,fn.completed_at&&(0,K.jsxs)(`span`,{className:`ml-1 text-bambu-gray/60`,children:[`• `,yf(fn.completed_at,{month:`short`,day:`numeric`})]})]}):(0,K.jsx)(`span`,{children:j(`printers.readyToPrint`)})})]})]}),(0,K.jsx)(gle,{printerId:e.id,printerModel:e.model,loadedFilamentTypes:Ft,loadedFilaments:It,variant:`panelExtension`})]})})()]}),G.temperatures&&r===`expanded`&&(()=>{let t=G.temperatures.nozzle_heating||G.temperatures.nozzle_2_heating||!1,n=G.temperatures.bed_heating||!1,r=G.temperatures.chamber_heating||!1,i=e.nozzle_count===2||G.temperatures.nozzle_2!==void 0,a=(()=>{let e=[`nozzle`];return G.temperatures.nozzle_2!==void 0&&e.push(`nozzle_2`),e.push(`bed`),G.temperatures.chamber!==void 0&&e.push(`chamber`),e})(),o=G.active_extruder===1?`L`:`R`,s=G.nozzle_rack?.find(e=>e.id===1),c=G.nozzle_rack?.find(e=>e.id===0),l=c||s,u=G.connected&&F(`printers:control`),d=u?void 0:j(`printers.permission.noControl`),f=`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,p=Rke.has(e.model??``),m=[{key:`part`,label:j(`printers.fans.partCooling`),value:G.cooling_fan_speed??0,Icon:Zs,activeClass:`text-cyan-400`},{key:`aux`,label:j(`printers.fans.auxiliary`),value:G.big_fan1_speed??0,Icon:Iu,activeClass:`text-blue-400`},...p?[{key:`chamber`,label:j(`printers.fans.chamber`),value:G.big_fan2_speed??0,Icon:Do,activeClass:`text-green-400`}]:[]];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mt-2 flex items-stretch gap-1.5 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&Te(we===`nozzle-temp`?null:`nozzle-temp`),children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`nozzle`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(_W,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-orange-400`,isHeating:t}),G.temperatures.nozzle_2===void 0?l?(0,K.jsx)(gW,{slot:l,index:0,activeStatus:!0,filamentName:l.filament_id?Lt?.[l.filament_id]?.name:void 0,children:(0,K.jsxs)(`div`,{className:`cursor-default`,children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`°C`]})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`°C`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:`L / R`}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.nozzle||0),`° / `,Math.round(G.temperatures.nozzle_2||0),`°`]})]}),we===`nozzle-temp`&&(i?(0,K.jsx)(CW,{title:`Set Nozzle Temperatures`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:260,isPending:In.isPending,onClose:()=>Te(null),children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 px-3 py-2.5`,children:[(0,K.jsx)(wW,{label:`Left Temp`,current:G.temperatures.nozzle,target:G.temperatures.nozzle_target,isActive:o===`L`,isPending:In.isPending,onSubmit:e=>In.mutate({target:e,nozzle:1}),options:Rp(D,`C`)}),(0,K.jsx)(wW,{label:`Right Temp`,current:G.temperatures.nozzle_2,target:G.temperatures.nozzle_2_target,isActive:o===`R`,isPending:In.isPending,onSubmit:e=>In.mutate({target:e,nozzle:0}),options:Rp(D,`C`)})]})}):(0,K.jsx)(CW,{title:`Set Nozzle Temperature`,unit:`°C`,customMin:0,customMax:320,isPending:In.isPending,options:Rp(D,`C`),onClose:()=>Te(null),onSubmit:e=>In.mutate({target:e,nozzle:G.active_extruder??0})}))]}),(0,K.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&Te(we===`bed-temp`?null:`bed-temp`),children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`bed`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(_W,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-blue-400`,isHeating:n}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.bed`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.bed||0),`°C`]}),we===`bed-temp`&&(0,K.jsx)(CW,{title:`Set Bed Temperature`,unit:`°C`,customMin:0,customMax:140,isPending:Ln.isPending,options:Rp(O,`C`),onClose:()=>Te(null),onSubmit:e=>Ln.mutate(e)})]}),G.temperatures.chamber!==void 0&&(()=>{let e=G.supports_chamber_heater===!0;return(0,K.jsxs)(`div`,{className:e?f:`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center`,title:e?d:void 0,onClick:e?()=>u&&Te(we===`chamber-temp`?null:`chamber-temp`):void 0,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:j(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),ft({initialKind:`chamber`,availableKinds:a})},children:(0,K.jsx)(es,{className:`w-2.5 h-2.5`})}),(0,K.jsx)(_W,{className:`w-3.5 h-3.5 mb-0.5`,color:`text-green-400`,isHeating:r}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.chamber`)}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white`,children:[Math.round(G.temperatures.chamber||0),`°C`]}),e&&we===`chamber-temp`&&(0,K.jsx)(CW,{title:`Set Chamber Temperature`,unit:`°C`,customMin:0,customMax:60,isPending:Rn.isPending,options:Rp(k,`C`),onClose:()=>Te(null),onSubmit:e=>Rn.mutate(e)})]})})(),i&&(0,K.jsx)(Cke,{leftSlot:s,rightSlot:c,activeNozzle:o,filamentInfo:Lt,children:(0,K.jsxs)(`div`,{className:`relative text-center px-3 py-1.5 bg-bambu-dark rounded-lg h-full flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?j(`printers.activeNozzle`,{nozzle:j(o===`L`?`common.left`:`common.right`)}):d,onClick:()=>u&&Te(we===`nozzle-select`?null:`nozzle-select`),children:[(0,K.jsx)(jke,{className:`w-3.5 h-3.5 mb-0.5 text-amber-400`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-[11px] font-bold ${o===`L`?`text-amber-400`:`text-gray-500`}`,children:[`L`,s?.nozzle_diameter?` ${s.nozzle_diameter}`:``]}),(0,K.jsx)(`span`,{className:`text-[9px] text-bambu-gray/40`,children:`·`}),(0,K.jsxs)(`span`,{className:`text-[11px] font-bold ${o===`R`?`text-amber-400`:`text-gray-500`}`,children:[`R`,c?.nozzle_diameter?` ${c.nozzle_diameter}`:``]})]}),(0,K.jsx)(`p`,{className:`text-[9px] text-bambu-gray`,children:j(`printers.temperatures.nozzle`)}),we===`nozzle-select`&&(0,K.jsx)(CW,{title:`Set Nozzle Selection`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:140,isPending:Bn.isPending,options:[{label:`Left`,value:1},{label:`Right`,value:0}],onClose:()=>Te(null),onSubmit:e=>Bn.mutate(e)})]})}),G.nozzle_rack&&G.nozzle_rack.some(e=>e.id>=2)&&(0,K.jsx)(wke,{slots:G.nozzle_rack,filamentInfo:Lt})]}),(0,K.jsx)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:m.map(({key:e,label:t,value:n,Icon:r,activeClass:i})=>{let a=n>0;return(0,K.jsxs)(`div`,{className:`relative px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 min-w-0 flex items-center justify-center gap-1 transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?t:d,onClick:()=>u&&Te(we===`fan-${e}`?null:`fan-${e}`),children:[(0,K.jsx)(r,{className:`w-3 h-3 shrink-0 ${a?i:`text-bambu-gray/50`}`}),(0,K.jsxs)(`span`,{className:`text-[10px] leading-none ${a?`text-white`:`text-bambu-gray/50`}`,children:[n,`%`]}),we===`fan-${e}`&&(0,K.jsx)(CW,{title:`Set ${t} Speed`,unit:`%`,customMin:0,customMax:100,isPending:zn.isPending,options:Rp(A,`%`),onClose:()=>Te(null),onSubmit:t=>zn.mutate({fan:e,speed:t})})]},e)})})]})})(),r===`expanded`&&hn&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>Fn.mutate(),disabled:Fn.isPending||!F(`printers:clear_plate`),className:`mt-2 w-full inline-flex items-center justify-center gap-2 px-3 py-1.5 rounded-lg bg-yellow-500/20 border border-yellow-400/40 text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs font-medium disabled:opacity-50`,title:F(`printers:clear_plate`)?j(`printers.plateStatus.markCleared`):j(`printers.permission.noControl`),children:[Fn.isPending?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):(0,K.jsx)(KU,{className:`w-4 h-4`}),j(`printers.plateStatus.markCleared`)]}),r===`expanded`&&(()=>{let t=G.state===`RUNNING`,n=G.state===`PAUSE`,r=t||n,i=Mn.isPending||Nn.isPending||Pn.isPending,a=`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed opacity-50`,o=`flex h-8 w-8 items-center justify-center rounded-lg text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,s=`flex h-8 w-20 items-center justify-center gap-1 px-2 rounded-lg text-xs font-medium transition-colors`;return(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.controls`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-2 gap-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,K.jsx)(`button`,{onClick:()=>Vn.mutate(!G.chamber_light),disabled:!G.connected||Vn.isPending||!F(`printers:control`),className:`${o} ${G.chamber_light?`bg-yellow-500/10 text-yellow-400 hover:bg-yellow-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:control`)?G.chamber_light?j(`printers.chamberLightOff`):j(`printers.chamberLightOn`):j(`printers.permission.noControl`),children:(0,K.jsx)(sT,{on:G.chamber_light??!1,className:`w-4 h-4`})}),[`P2S`,`X2D`,`H2D`,`H2C`,`H2S`].includes(e.model??``)&&(()=>{let t=G.airduct_mode===1,n=t?ac:nu,r=t?`text-orange-400`:`text-sky-400`,i=t?`bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`bg-sky-500/10 text-sky-400 hover:bg-sky-500/20`;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>xe(be===e.id?null:e.id),disabled:!F(`printers:control`),className:`${o} ${i}`,title:`${j(`printers.airduct.title`)}: ${j(t?`printers.airduct.heating`:`printers.airduct.cooling`)}`,children:(0,K.jsx)(n,{className:`w-4 h-4 ${r}`})}),be===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>xe(null)}),(0,K.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:`cooling`,label:j(`printers.airduct.cooling`),modeId:0},{mode:`heating`,label:j(`printers.airduct.heating`),modeId:1}].map(({mode:e,label:t,modeId:n})=>(0,K.jsxs)(`button`,{onClick:()=>{Un.mutate(e),xe(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors flex items-center gap-2 ${G.airduct_mode===n?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e===`heating`?(0,K.jsx)(ac,{className:`w-3 h-3`}):(0,K.jsx)(nu,{className:`w-3 h-3`}),t]},e))})]})]})})(),(()=>{let t=F(`printers:control`),n=r||!t,i=`flex h-8 w-8 items-center justify-center rounded bg-indigo-500/15 text-indigo-300 transition-colors hover:bg-indigo-500/30 disabled:cursor-not-allowed disabled:opacity-50`,a=t=>{let n=t*Ee*1,r=`bambuddy.bedJog.warned.${e.id}`;(()=>{try{return sessionStorage.getItem(r)===`1`}catch{return!1}})()?Wn.mutate({distance:n,force:!0}):ke({distance:n})},s=(e,t)=>{Gn.mutate({x:e,y:t})},c=e=>{Kn.mutate(e)};return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>Ce(Se===e.id?null:e.id),disabled:n,className:`${o} ${n?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-indigo-500/10 text-indigo-400 hover:bg-indigo-500/20`}`,title:j(t?r?`printers.bedJog.disabledWhilePrinting`:`printers.bedJog.title`:`printers.permission.noControl`),children:(0,K.jsx)(ll,{className:`w-4 h-4`})}),Se===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>Ce(null)}),(0,K.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 flex w-[216px] flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,children:[(0,K.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:j(`printers.bedJog.title`)}),(0,K.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex justify-center px-3 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-1`,children:[(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(0,Ee),disabled:Gn.isPending,className:i,"aria-label":`Move Y forward`,children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(-Ee,0),disabled:Gn.isPending,className:i,"aria-label":`Move X left`,children:(0,K.jsx)(jo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{Ce(null),qn.mutate(`all`)},disabled:qn.isPending,className:i,"aria-label":j(`printers.bedJog.homeZ`),children:(0,K.jsx)(Ac,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>s(Ee,0),disabled:Gn.isPending,className:i,"aria-label":`Move X right`,children:(0,K.jsx)(No,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{}),(0,K.jsx)(`button`,{onClick:()=>s(0,-Ee),disabled:Gn.isPending,className:i,"aria-label":`Move Y back`,children:(0,K.jsx)(Ao,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>a(-1),disabled:Wn.isPending,className:i,"aria-label":j(`printers.bedJog.up`),children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,K.jsx)(Rc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(1),disabled:Wn.isPending,className:i,"aria-label":j(`printers.bedJog.down`),children:(0,K.jsx)(Ao,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>c(-Ee),disabled:Kn.isPending,className:i,"aria-label":`Retract filament`,children:(0,K.jsx)(Io,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,K.jsx)(`span`,{className:`text-sm font-semibold leading-none`,children:`E`})}),(0,K.jsx)(`button`,{onClick:()=>c(Ee),disabled:Kn.isPending,className:i,"aria-label":`Extrude filament`,children:(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]})}),(0,K.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`px-3 pt-2.5 pb-3`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-[9px] uppercase tracking-wider text-bambu-gray/70`,children:j(`printers.bedJog.step`)}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:[1,10,50].map(e=>(0,K.jsx)(`button`,{onClick:()=>De(e),className:`flex-1 px-1 py-1 rounded text-[10px] transition-colors ${Ee===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:e},e))})]})]})]})]})})(),(0,K.jsxs)(`div`,{className:`inline-flex rounded-lg ${e.plate_detection_enabled?`ring-1 ring-green-500`:``}`,children:[(0,K.jsx)(`button`,{onClick:hr,disabled:!G.connected||Jn.isPending||!F(`printers:update`),className:`${o} rounded-r-none ${e.plate_detection_enabled?`bg-green-500/10 text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:update`)?e.plate_detection_enabled?j(`printers.plateDetection.enabledClick`):j(`printers.plateDetection.disabledClick`):j(`printers.plateDetection.noPermission`),children:Jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Il,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:gr,disabled:!G.connected||Ct||!F(`printers:update`),className:`flex h-8 w-8 items-center justify-center rounded-r-lg border-l border-bambu-dark-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e.plate_detection_enabled?`bg-green-500/10 text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:F(`printers:update`)?j(`printers.plateDetection.manageCalibration`):j(`printers.plateDetection.noPermission`),children:Ct?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(is,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{"data-testid":`speed-control`,onClick:()=>ye(ve===e.id?null:e.id),disabled:!r||!F(`printers:control`),className:`${o} ${r?`bg-amber-500/10 text-amber-400 hover:bg-amber-500/20`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`}`,title:r?j(`printers.speed.title`):void 0,children:(0,K.jsx)(hc,{className:`w-4 h-4`})}),ve===e.id&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ye(null)}),(0,K.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:1,label:j(`printers.speed.silent`)},{mode:2,label:j(`printers.speed.standard`)},{mode:3,label:j(`printers.speed.sport`)},{mode:4,label:j(`printers.speed.ludicrous`)}].map(({mode:e,label:t})=>(0,K.jsx)(`button`,{onClick:()=>{Hn.mutate(e),ye(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors ${G.speed_level===e?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:t},e))})]})]})]}),(0,K.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-2 flex-shrink-0`,children:[(()=>{let e=!r||i||!F(`printers:control`);return(0,K.jsxs)(`button`,{onClick:()=>n?je(!0):_e(!0),disabled:e,className:` ${s} ${e?a:n?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30`} `,title:F(`printers:control`)?j(n?`printers.resume`:`printers.pause`):j(`printers.permission.noControl`),children:[n?(0,K.jsx)(bl,{className:`w-3 h-3`}):(0,K.jsx)(hl,{className:`w-3 h-3`}),j(n?`printers.resume`:`printers.pause`)]})})(),(()=>{let e=!r||i||!F(`printers:control`);return(0,K.jsxs)(`button`,{onClick:()=>he(!0),disabled:e,className:` ${s} ${e?a:`bg-red-500/20 text-red-400 hover:bg-red-500/30`} - `,title:F(`printers:control`)?j(`printers.stop`):j(`printers.permission.noControl`),children:[(0,K.jsx)(ou,{className:`w-3 h-3`}),j(`printers.stop`)]})})()]})]})]})})(),(Qt?.length>0||G.vt_tray.length>0)&&r===`expanded`&&(()=>{let t=Qt.filter(e=>e.tray.length>1),n=Qt.filter(e=>e.tray.length===1),r=e.nozzle_count===2||G?.temperatures?.nozzle_2!==void 0,i=`min-w-14`,g=(G.state===`RUNNING`||G.state===`PAUSE`)&&Array.isArray(G.ams_mapping)?G.ams_mapping:[],_=e=>{let t=Math.max(1,e),n=`calc(${t} * 3.5rem + ${Math.max(0,t-1)} * 0.25rem + 1rem)`;return{flex:`1 1 ${n}`,minWidth:n}};return(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.filaments`)}),(0,K.jsx)(Nke,{state:G.ams_filament_backup,onClick:()=>pe(!0)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.map(t=>{let n=Xt[String(t.id)],v=t.id>=128?t.id-128:t.id,y=n===void 0?v:n,b=y===1,S=y===0;return(0,K.jsxs)(`div`,{style:_(4),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex w-full min-h-7 items-center justify-between gap-2 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,K.jsx)(DW,{ams:t,printerId:e.id,label:Af(t.id,t.tray.length),amsLabels:Ht,canEdit:F(`printers:update`),onSaved:Ut,children:(0,K.jsx)(`span`,{className:`block truncate text-[10px] text-white font-medium cursor-default select-none`,children:Ht?.[t.id]||Af(t.id,t.tray.length)})}),r&&(b||S)&&(0,K.jsx)(fW,{side:b?`L`:`R`})]}),(t.humidity!=null||t.temp!=null)&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.humidity!=null&&(0,K.jsx)(_W,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`humidity`}),compact:!0}),t.temp!=null&&(0,K.jsx)(`div`,{className:`mr-1`,children:(0,K.jsx)(vW,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`temperature`}),compact:!0})}),G.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&F(`printers:control`)&&(0,K.jsx)(`button`,{disabled:!!(t.dry_sf_reason?.length&&t.dry_time===0),onClick:e=>{if(t.dry_time>0)Dn.mutate(t.id);else if(Ue===t.id)We(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;Je(n),Xe(r[i]||r.n3f),Qe(i===`n3s`?r.n3s_hours:r.n3f_hours),et(!1),Ke(t.module_type),We(t.id),nt(jp({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:lW,estimatedHeight:uW,horizontalAlign:`center`}))}},className:`ml-1 flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:t.dry_sf_reason?.length?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:t.dry_time>0?j(`printers.drying.stop`):t.dry_sf_reason?.length?j(`printers.drying.powerRequired`):j(`printers.drying.start`),children:(0,K.jsx)(ac,{className:`w-3 h-3`})})]})]}),t.dry_time>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-amber-500/10 px-2 py-1 text-[9px]`,children:[(0,K.jsx)(ac,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-amber-400 font-medium`,children:j(`printers.drying.active`)}),(0,K.jsx)(`span`,{className:`text-amber-300/70`,children:j(`printers.drying.timeRemaining`,{time:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`})}),(0,K.jsx)(`button`,{onClick:()=>Dn.mutate(t.id),disabled:Dn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50`,title:j(`printers.drying.stop`),children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]}),(0,K.jsx)(`div`,{className:`grid w-full grid-cols-[repeat(4,minmax(3.5rem,1fr))] gap-1`,children:[0,1,2,3].map(r=>{let a=t.tray[r]||t.tray.find(e=>e.id===r),_=a?.tray_type&&a.remain>=0,v=!a?.tray_type,y=yW(a),b=t.id*4+r,x=tn===b,S=a?.tray_info_idx?Lt?.[a.tray_info_idx]:null,C=Rt?.[b],w=(a?.tray_uuid||a?.tag_uid||Hf(e.serial_number,t.id,r))?.toUpperCase(),T=w?s?.[w]:void 0,E=zf(T),D=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===r):void 0,O=D?f?.find(e=>e.id===D.spoolman_spool_id):void 0,k=O&&(O.label_weight??0)>0?Math.round(Math.max(0,(O.label_weight??0)-O.weight_used)/(O.label_weight??1)*100):null,A=u?.(e.id,t.id,r),M=(()=>{let e=A?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),N=M===0&&_&&a.remain>0?null:M,P=E??k??N??(_?a.remain:null),I=E!==null||k!==null?`spoolman`:N===null?_?`ams`:void 0:`inventory`,L=a?.tray_type?{vendor:Xf(a)?`Bambu Lab`:`Generic`,profile:C?.preset_name||(O?[O.brand,O.slicer_filament_name?.split(`@`)[0].trim()||O.material].filter(Boolean).join(` `).trim():null)||A?.spool?.slicer_filament_name||S?.name||a.tray_sub_brands||a.tray_type,colorName:Gd(a.tray_color||``),colorHex:a.tray_color||null,kFactor:dW(a.k),fillLevel:P,trayUuid:a.tray_uuid||null,tagUid:a.tag_uid||null,fillSource:I}:null,R=nr?.amsId===t.id&&nr?.slotId===r,z=g.indexOf(b),B=z>=0?`P${z+1}`:null,V=(0,K.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${v?`opacity-50`:``} ${x?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[B&&(0,K.jsx)(`span`,{"aria-label":j(`printers.activeJobSlot.ariaLabel`,{n:z+1}),title:j(`printers.activeJobSlot.title`,{n:z+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[8px] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:B}),(0,K.jsx)(cW,{trayColor:a?.tray_color,trayType:a?.tray_type,isEmpty:v,emptyKind:y,slotNumber:r+1}),(0,K.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:a?.tray_type||j(y===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:P!==null&&P>=0&&!v&&a&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${P}%`,backgroundColor:Rf(P)}})})]});return(0,K.jsxs)(`div`,{className:`relative group w-full ${i}`,children:[R&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-green animate-spin`})}),L?(0,K.jsx)(dU,{data:L,actions:Nr({amsId:t.id,slotId:r,loadTrayId:t.id*4+r,isRefreshing:R}),spoolman:{enabled:o,linkedSpoolId:D?.spoolman_spool_id??(w?s?.[w]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!D&&!A?()=>{let n=(L.trayUuid||L.tagUid||Hf(e.serial_number,t.id,r)).toUpperCase();mt({tagUid:L.tagUid||n,trayUuid:L.trayUuid||``,printerId:e.id,amsId:t.id,trayId:r})}:void 0,onUnlinkSpool:T?.id?()=>Tn.mutate(T.id):void 0},inventory:(()=>{if(o){if(m)return;let n=D,i=O;return{assignedSpool:i?{id:i.id,material:i.material,brand:i.brand??null,color_name:i.color_name??null,remainingWeightGrams:i.label_weight?Math.max(0,Math.round(i.label_weight-i.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:a?.tray_type||L.profile,material:a?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:i&&!Xf(a)?()=>h?.(i.id):void 0,isAssigned:!!n||Xf(a)}}let n=u?.(e.id,t.id,r);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:a?.tray_type||L.profile,material:a?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:n&&!Xf(a)?()=>d?.(e.id,t.id,r):void 0,isAssigned:!!n||Xf(a)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:r,trayCount:t.tray.length,trayType:a?.tray_type||void 0,trayColor:a?.tray_color||void 0,traySubBrands:a?.tray_sub_brands||void 0,trayInfoIdx:a?.tray_info_idx||void 0,extruderId:n,caliIdx:a?.cali_idx,savedPresetId:C?.preset_id})},children:V}):(0,K.jsx)(fU,{kind:y??void 0,actions:Nr({amsId:t.id,slotId:r,loadTrayId:t.id*4+r,isRefreshing:R}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:r,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),children:V})]},r)})})]},t.id)}),n.map(t=>{let n=Xt[String(t.id)],i=t.id>=128?t.id-128:t.id,_=n===void 0?i:n,v=_===1,y=_===0,b=t.tray[0],S=b?.tray_type&&b.remain>=0,C=!b?.tray_type,w=yW(b),T=Lf(t.id,b?.id??0,!1),E=tn===T,D=b?.tray_info_idx?Lt?.[b.tray_info_idx]:null,O=Rt?.[T],k=b?.id??0,A=(b?.tray_uuid||b?.tag_uid||Hf(e.serial_number,t.id,k))?.toUpperCase(),M=A?s?.[A]:void 0,N=zf(M),P=u?.(e.id,t.id,k),I=(()=>{let e=P?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),L=I===0&&S&&b.remain>0?null:I,R=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===k):void 0,z=R?f?.find(e=>e.id===R.spoolman_spool_id):void 0,B=z&&(z.label_weight??0)>0?Math.round(Math.max(0,(z.label_weight??0)-z.weight_used)/(z.label_weight??1)*100):null,V=N??B??L??(S?b.remain:null),ee=N!==null||B!==null?`spoolman`:L===null?S?`ams`:void 0:`inventory`,te=b?.tray_type?{vendor:Xf(b)?`Bambu Lab`:`Generic`,profile:O?.preset_name||(z?[z.brand,z.slicer_filament_name?.split(`@`)[0].trim()||z.material].filter(Boolean).join(` `).trim():null)||P?.spool?.slicer_filament_name||D?.name||b.tray_sub_brands||b.tray_type,colorName:Gd(b.tray_color||``),colorHex:b.tray_color||null,kFactor:dW(b.k),fillLevel:V,trayUuid:b.tray_uuid||null,tagUid:b.tag_uid||null,fillSource:ee}:null,ne=nr?.amsId===t.id&&nr?.slotId===k,re=g.indexOf(T),ie=re>=0?`P${re+1}`:null,H=(0,K.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${C?`opacity-50`:``} ${E?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[ie&&(0,K.jsx)(`span`,{"aria-label":j(`printers.activeJobSlot.ariaLabel`,{n:re+1}),title:j(`printers.activeJobSlot.title`,{n:re+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[8px] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:ie}),(0,K.jsx)(cW,{trayColor:b?.tray_color,trayType:b?.tray_type,isEmpty:C,emptyKind:w,slotNumber:1}),(0,K.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:b?.tray_type||j(w===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:V!==null&&V>=0&&!C&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${V}%`,backgroundColor:Rf(V)}})})]});return(0,K.jsxs)(`div`,{style:{flex:`1 1 11rem`,minWidth:`11rem`},className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,K.jsx)(DW,{ams:t,printerId:e.id,label:Af(t.id,t.tray.length),amsLabels:Ht,canEdit:F(`printers:update`),onSaved:Ut,children:(0,K.jsx)(`span`,{className:`block truncate text-[10px] text-white font-medium cursor-default select-none`,children:Ht?.[t.id]||Af(t.id,t.tray.length)})}),r&&(v||y)&&(0,K.jsx)(fW,{side:v?`L`:`R`})]}),G.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&F(`printers:control`)&&(0,K.jsx)(`div`,{className:`relative ml-auto`,children:(0,K.jsx)(`button`,{onClick:e=>{if(t.dry_time>0)Dn.mutate(t.id);else if(Ue===t.id)We(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;Je(n),Xe(r[i]||r.n3f),Qe(i===`n3s`?r.n3s_hours:r.n3f_hours),et(!1),Ke(t.module_type),We(t.id),nt(jp({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:lW,estimatedHeight:uW,horizontalAlign:`center`}))}},className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:t.dry_time>0?j(`printers.drying.stop`):j(`printers.drying.start`),children:(0,K.jsx)(ac,{className:`w-3 h-3`})})})]}),t.dry_time>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-hidden whitespace-nowrap rounded-lg bg-amber-500/10 px-2 py-1 text-[9px]`,children:[(0,K.jsx)(ac,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-amber-300/70 text-[8px] truncate`,children:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`}),(0,K.jsx)(`button`,{onClick:()=>Dn.mutate(t.id),disabled:Dn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50 shrink-0`,title:j(`printers.drying.stop`),children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5 max-[550px]:flex-col max-[550px]:items-start`,children:[(0,K.jsxs)(`div`,{className:`relative group min-w-14 flex-1`,children:[ne&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-green animate-spin`})}),te?(0,K.jsx)(dU,{data:te,actions:Nr({amsId:t.id,slotId:k,loadTrayId:t.id*4+k,isRefreshing:ne}),spoolman:{enabled:o,linkedSpoolId:R?.spoolman_spool_id??(A?s?.[A]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!R&&!P?()=>{let n=(te.trayUuid||te.tagUid||Hf(e.serial_number,t.id,k)).toUpperCase();mt({tagUid:te.tagUid||n,trayUuid:te.trayUuid||``,printerId:e.id,amsId:t.id,trayId:k})}:void 0,onUnlinkSpool:M?.id?()=>Tn.mutate(M.id):void 0},inventory:(()=>{if(o){if(m)return;let n=R,r=z;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:b?.tray_type||te.profile,material:b?.tray_type??void 0,profile:te.profile,color:te.colorHex||``,location:Af(t.id,t.tray.length)}}),onUnassignSpool:r&&!Xf(b)?()=>h?.(r.id):void 0,isAssigned:!!n||Xf(b)}}let n=u?.(e.id,t.id,k);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:b?.tray_type||te.profile,material:b?.tray_type??void 0,profile:te.profile,color:te.colorHex||``,location:Af(t.id,t.tray.length)}}),onUnassignSpool:n&&!Xf(b)?()=>d?.(e.id,t.id,k):void 0,isAssigned:!!n||Xf(b)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:k,trayCount:t.tray.length,trayType:b?.tray_type||void 0,trayColor:b?.tray_color||void 0,traySubBrands:b?.tray_sub_brands||void 0,trayInfoIdx:b?.tray_info_idx||void 0,extruderId:n,caliIdx:b?.cali_idx,savedPresetId:O?.preset_id})},children:H}):(0,K.jsx)(fU,{kind:w??void 0,actions:Nr({amsId:t.id,slotId:k,loadTrayId:t.id*4+k,isRefreshing:ne}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:k,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:``,material:void 0,profile:``,color:``,location:Af(t.id,t.tray.length)}}),children:H})]}),(t.humidity!=null||t.temp!=null)&&(0,K.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full`,children:[t.temp!=null&&(0,K.jsx)(vW,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`temperature`}),compact:!0}),t.humidity!=null&&(0,K.jsx)(_W,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`humidity`}),compact:!0})]})]})]},t.id)}),G.vt_tray.length>0&&(0,K.jsxs)(`div`,{style:_(G.vt_tray.length),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsx)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:(0,K.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-[10px] text-white font-medium`,children:j(`printers.external`)})}),(0,K.jsx)(`div`,{className:`grid w-full ${G.vt_tray.length>1?`grid-cols-[repeat(2,minmax(3.5rem,1fr))]`:`grid-cols-[minmax(3.5rem,1fr)]`} gap-1`,children:[...G.vt_tray].sort((e,t)=>(e.id??254)-(t.id??254)).map(t=>{let n=t.id??254,a=r&&tn===254?n===254&&G.active_extruder===1||n===255&&G.active_extruder===0:tn===n,g=n-254,_=r?j(n===254?`printers.extL`:`printers.extR`):``,v=t.tray_info_idx?Lt?.[t.tray_info_idx]:null,y=Rt?.[1020+g],b=(t.tray_uuid||t.tag_uid||Hf(e.serial_number,255,g))?.toUpperCase(),x=b?s?.[b]:void 0,S=zf(x),C=u?.(e.id,255,g),w=(()=>{let e=C?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),T=t.tray_type&&t.remain>=0,E=w===0&&T&&t.remain>0?null:w,D=o&&!m?p?.find(t=>t.printer_id===e.id&&t.ams_id===255&&t.tray_id===g):void 0,O=D?f?.find(e=>e.id===D.spoolman_spool_id):void 0,k=O&&(O.label_weight??0)>0?Math.round(Math.max(0,(O.label_weight??0)-O.weight_used)/(O.label_weight??1)*100):null,A=S??k??E??(T?t.remain:null),M=S!==null||k!==null?`spoolman`:E===null?T?`ams`:void 0:`inventory`,N={vendor:Xf(t)?`Bambu Lab`:`Generic`,profile:y?.preset_name||(O?[O.brand,O.slicer_filament_name?.split(`@`)[0].trim()||O.material].filter(Boolean).join(` `).trim():null)||C?.spool?.slicer_filament_name||v?.name||t.tray_sub_brands||t.tray_type||`Unknown`,colorName:Gd(t.tray_color||``),colorHex:t.tray_color||null,kFactor:dW(t.k),fillLevel:A,trayUuid:t.tray_uuid||null,tagUid:t.tag_uid||null,fillSource:M},P=!t.tray_type,I=yW(t),L=(0,K.jsxs)(`div`,{className:`w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${P?`opacity-50`:``} ${a?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,K.jsx)(cW,{trayColor:t.tray_color,trayType:t.tray_type,isEmpty:P,emptyKind:I,slotNumber:g+1}),(0,K.jsx)(`div`,{className:`text-[9px] font-bold truncate ${P?`text-white/40`:`text-white`}`,children:t.tray_type||j(`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:A!==null&&A>=0&&!P&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${A}%`,backgroundColor:Rf(A)}})}),_&&(0,K.jsx)(`div`,{className:`text-[7px] text-white/40 mt-0.5 truncate`,children:_})]});return(0,K.jsx)(`div`,{className:`relative group w-full ${i}`,children:P?(0,K.jsx)(fU,{kind:I??void 0,actions:Nr({amsId:255,slotId:g,loadTrayId:n,includeRfid:!1}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:255,trayId:g,trayCount:1,extruderId:r?+(n===254):void 0})},onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`External Slot ${g+1}`}}),children:L}):(0,K.jsx)(dU,{data:N,actions:Nr({amsId:255,slotId:g,loadTrayId:n,includeRfid:!1}),spoolman:{enabled:o,linkedSpoolId:D?.spoolman_spool_id??(b?s?.[b]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!D&&!C?()=>{let t=(N.trayUuid||N.tagUid||Hf(e.serial_number,255,g)).toUpperCase();mt({tagUid:N.tagUid||t,trayUuid:N.trayUuid||``,printerId:e.id,amsId:255,trayId:g})}:void 0,onUnlinkSpool:x?.id?()=>Tn.mutate(x.id):void 0},inventory:(()=>{if(o){if(m)return;let n=D,r=O;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:_||j(`printers.external`)}}),onUnassignSpool:r&&!Xf(t)?()=>h?.(r.id):void 0,isAssigned:!!n||Xf(t)}}let n=u?.(e.id,255,g);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:_||j(`printers.external`)}}),onUnassignSpool:n&&!Xf(t)?()=>d?.(e.id,255,g):void 0,isAssigned:!!n||Xf(t)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:255,trayId:g,trayCount:1,trayType:t.tray_type||void 0,trayColor:t.tray_color||void 0,traySubBrands:t.tray_sub_brands||void 0,trayInfoIdx:t.tray_info_idx||void 0,extruderId:r?+(n===254):void 0,caliIdx:t.cali_idx,savedPresetId:y?.preset_id})},children:L})},n)})})]})]})]})})()]}),r===`expanded`&&(0,K.jsxs)(`div`,{className:`mt-auto`,children:[nn&&(0,K.jsxs)(`div`,{className:`pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.power`,`Power`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-[10px] bg-bambu-dark p-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 pl-1`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate`,children:nn.name}),(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-[10px] font-medium flex-shrink-0`,title:j(`smartPlugs.power`),children:an?.energy?.power!==null&&an?.energy?.power!==void 0?`${Math.round(an.energy.power)}W`:`--`})]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>An.mutate(!nn.auto_off),disabled:An.isPending||nn.auto_off_executed||!F(`smart_plugs:control`),title:F(`smart_plugs:control`)?nn.auto_off_executed?j(`printers.autoOffExecuted`):j(`printers.autoOffAfterPrint`):j(`printers.permission.noSmartPlugControl`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs font-bold transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${F(`smart_plugs:control`)?nn.auto_off||nn.auto_off_executed?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,children:(0,K.jsx)(Ss,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{an?.state===`ON`?se(!0):oe(!0)},disabled:kn.isPending||!F(`smart_plugs:control`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${F(`smart_plugs:control`)?an?.state===`ON`?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,title:F(`smart_plugs:control`)?an?.state===`ON`?`Turn off`:`Turn on`:j(`printers.permission.noSmartPlugControl`),children:(0,K.jsx)(Bu,{className:`w-4 h-4`})})]})]}),rn&&rn.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,K.jsx)(Ac,{className:`w-3.5 h-3.5 text-blue-400 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`HA:`}),(0,K.jsx)(`div`,{className:`h-[2px] w-5 bg-bambu-dark-tertiary/50`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:rn.map(e=>{let t=e.ha_entity_id?.startsWith(`script.`);return(0,K.jsxs)(`button`,{onClick:()=>{t?jn.mutate({id:e.id,action:`on`}):le(e)},disabled:jn.isPending,title:`${t?`Run`:`Toggle`} ${e.ha_entity_id}`,className:`px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1`,children:[(0,K.jsx)(bl,{className:`w-2.5 h-2.5`}),e.name]},e.id)})})]})]}),(0,K.jsxs)(`div`,{className:`pt-4`,children:[(0,K.jsx)(`div`,{className:`mb-3 h-[2px] bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[Pr,(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{if(_===`embedded`&&v)v(e.id,e.name);else{let t=localStorage.getItem(`cameraWindowState`),n=t?JSON.parse(t):{width:640,height:400},r=[`width=${n.width}`,`height=${n.height}`,n.left===void 0?``:`left=${n.left}`,n.top===void 0?``:`top=${n.top}`,`menubar=no,toolbar=no,location=no,status=no`].filter(Boolean).join(`,`);window.open(`/camera/${e.id}`,`camera-${e.id}`,r)}},disabled:!G?.connected||!F(`camera:view`),title:F(`camera:view`)?j(_===`embedded`?`printers.openCameraOverlay`:`printers.openCameraWindow`):j(`printers.permission.noCamera`),className:Mr,children:(0,K.jsx)(Au,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>re(!0),disabled:!Jt||!F(`printers:files`),title:F(`printers:files`)?j(`printers.browseFiles`):j(`printers.permission.noFiles`),className:Mr,children:(0,K.jsx)(wc,{className:`w-4 h-4`})}),Jt&&G?.state!==`RUNNING`&&G?.state!==`PAUSE`&&(0,K.jsxs)($,{size:`sm`,onClick:()=>Fe(!0),disabled:!F(`printers:control`),title:F(`printers:control`)?j(`common.print`):j(`printers.permission.noControl`),className:`!h-8 !min-h-8 !px-2 !py-0 !bg-bambu-green hover:!bg-bambu-green/80 !text-white`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),j(`common.print`)]})]})]})]})]})]}),ne&&(0,K.jsx)(lle,{printerId:e.id,printerName:e.name,onClose:()=>re(!1)}),Pe&&(0,K.jsx)(KU,{folderId:null,onClose:()=>Fe(!1),onUploadComplete:()=>{},autoUpload:!0,accept:`.gcode,.3mf`,validateFile:e=>{let t=e.name.toLowerCase();if(!t.endsWith(`.gcode`)&&!t.includes(`.gcode.`))return j(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`)},onFileUploaded:t=>{let n=t.metadata?.sliced_for_model,r=EW(e.model);if(n&&r&&n.toLowerCase()!==r.toLowerCase())return Q.deleteLibraryFile(t.id).catch(()=>{}),j(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:n,printerModel:r});He({id:t.id,filename:t.filename})}}),Ve&&(0,K.jsx)(oW,{mode:`reprint`,libraryFileId:Ve.id,archiveName:Ve.filename,initialSelectedPrinterIds:[e.id],onClose:()=>He(null),onSuccess:()=>He(null),cleanupLibraryAfterDispatch:!0}),ie&&(0,K.jsx)(gle,{printerId:e.id,printerName:e.name,onClose:()=>H(!1)}),Re&&(0,K.jsx)(ip,{printerId:e.id,printerName:e.name,onClose:()=>ze(!1)}),Ie&&(0,K.jsx)(Ske,{printer:e,status:G,totalPrintHours:n?.total_print_hours,onClose:Be}),xt&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>_r(),children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[xt.needs_calibration?(0,K.jsx)(Il,{className:`w-5 h-5 text-blue-500`}):xt.is_empty?(0,K.jsx)(ps,{className:`w-5 h-5 text-green-500`}):(0,K.jsx)(ys,{className:`w-5 h-5 text-yellow-500`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`Build Plate Check`}),xt.reference_count!==void 0&&xt.max_references&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[xt.reference_count,`/`,xt.max_references,` refs`]})]}),(0,K.jsx)(`button`,{onClick:()=>_r(),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[xt.needs_calibration?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 rounded-lg bg-blue-500/20 border border-blue-500/50`,children:[(0,K.jsx)(`p`,{className:`font-medium text-blue-400`,children:j(`printers.plateDetection.calibrationRequired`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,dangerouslySetInnerHTML:{__html:j(`printers.plateDetection.calibrationInstructions`)}})]}),(0,K.jsxs)(`div`,{className:`text-sm text-bambu-gray space-y-2`,children:[(0,K.jsx)(`p`,{children:j(`printers.plateDetection.calibrationDescription`)}),(0,K.jsx)(`p`,{dangerouslySetInnerHTML:{__html:j(`printers.plateDetection.calibrationTip`)}})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 rounded-lg ${xt.is_empty?`bg-green-500/20 border border-green-500/50`:`bg-yellow-500/20 border border-yellow-500/50`}`,children:[(0,K.jsx)(`p`,{className:`font-medium ${xt.is_empty?`text-green-400`:`text-yellow-400`}`,children:xt.is_empty?j(`printers.plateDetection.plateEmpty`):j(`printers.plateDetection.objectsDetected`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:[j(`printers.plateDetection.confidence`),`: `,Math.round(xt.confidence*100),`% | `,j(`printers.plateDetection.difference`),`: `,xt.difference_percent.toFixed(1),`%`]})]}),xt.debug_image_url&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:j(`printers.plateDetection.analysisPreview`)}),(0,K.jsx)(`img`,{src:xt.debug_image_url,alt:j(`printers.plateDetection.analysisPreview`),className:`w-full rounded-lg border border-bambu-dark-tertiary`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:j(`printers.plateDetection.analysisLegend`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:xt.message})]}),ur&&ur.references.length>0&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:j(`printers.plateDetection.savedReferences`,{count:ur.references.length,max:ur.max_references})}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:ur.references.map(t=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`img`,{src:Q.getPlateReferenceThumbnailUrl(e.id,t.index),alt:t.label||`Reference ${t.index+1}`,className:`w-full aspect-video object-cover rounded border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{onClick:()=>br(t.index),className:`absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity`,title:j(`printers.plateDetection.deleteReference`),children:(0,K.jsx)(Ru,{className:`w-3 h-3 text-white`})}),fr?.index===t.index?(0,K.jsx)(`input`,{type:`text`,value:fr.label,onChange:e=>pr({...fr,label:e.target.value}),onBlur:()=>yr(t.index,fr.label),onKeyDown:e=>{e.key===`Enter`&&yr(t.index,fr.label),e.key===`Escape`&&pr(null)},className:`w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white`,autoFocus:!0,placeholder:j(`printers.plateDetection.labelPlaceholder`)}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white`,onClick:()=>pr({index:t.index,label:t.label}),title:t.label?j(`printers.plateDetection.clickToEdit`,{label:t.label}):j(`printers.plateDetection.clickToAddLabel`),children:t.label||(0,K.jsx)(`span`,{className:`italic opacity-50`,children:j(`printers.noLabel`)})}),(0,K.jsx)(`p`,{className:`text-[10px] text-bambu-gray/60`,children:t.timestamp?vf(t.timestamp)?.toLocaleDateString()??``:``})]},t.index))})]}),!xt.needs_calibration&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:j(`printers.roi.title`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),Dt?(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>Ot(null),disabled:kt,children:j(`common.cancel`)}),(0,K.jsx)($,{size:`sm`,onClick:xr,disabled:kt,children:kt?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):j(`common.save`)})]}):(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>Ot(xt.roi||{x:.15,y:.35,w:.7,h:.55}),children:[(0,K.jsx)(vl,{className:`w-3 h-3 mr-1`}),j(`common.edit`)]})]}),Dt?(0,K.jsxs)(`div`,{className:`space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.xStart`)}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Dt.x,onChange:e=>Ot({...Dt,x:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.x*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.yStart`)}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Dt.y,onChange:e=>Ot({...Dt,y:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.y*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.width`)}),(0,K.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Dt.w,onChange:e=>Ot({...Dt,w:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.w*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.height`)}),(0,K.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Dt.h,onChange:e=>Ot({...Dt,h:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.h*100),`%`]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.instruction`)})]}):(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Current: X=`,Math.round((xt.roi?.x||.15)*100),`%, Y=`,Math.round((xt.roi?.y||.35)*100),`%, W=`,Math.round((xt.roi?.w||.7)*100),`%, H=`,Math.round((xt.roi?.h||.55)*100),`%`]})]})]}),(0,K.jsx)(`div`,{className:`flex justify-end gap-2 p-4`,children:xt.needs_calibration?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>_r(),children:j(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>vr(),disabled:Tt,children:Tt?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),`Calibrating...`]}):`Calibrate Empty Plate`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>vr(),disabled:Tt,children:Tt?`Adding...`:`Add Reference (${ur?.references.length||0}/${ur?.max_references||5})`}),(0,K.jsx)($,{onClick:()=>_r(),children:`Close`})]})})]})}),ae&&nn&&(0,K.jsx)(Ad,{title:j(`printers.confirm.powerOnTitle`),message:j(`printers.confirm.powerOnMessage`,{name:e.name}),confirmText:j(`printers.confirm.powerOnButton`),variant:`default`,onConfirm:()=>{kn.mutate(`on`),oe(!1)},onCancel:()=>oe(!1)}),Xn&&(0,K.jsx)(Ad,{title:j(`printers.maintenance.confirmMidPrintTitle`),message:j(`printers.maintenance.confirmMidPrintMessage`,{name:e.name}),confirmText:j(`printers.maintenance.menuEnter`),variant:`danger`,onConfirm:()=>{Yn.mutate(!1),Zn(!1)},onCancel:()=>Zn(!1)}),U&&nn&&(0,K.jsx)(Ad,{title:j(`printers.confirm.powerOffTitle`),message:G?.state===`RUNNING`?j(`printers.confirm.powerOffWarning`,{name:e.name}):j(`printers.confirm.powerOffMessage`,{name:e.name}),confirmText:j(`printers.confirm.powerOffButton`),variant:`danger`,onConfirm:()=>{kn.mutate(`off`),se(!1)},onCancel:()=>se(!1)}),ce&&(0,K.jsx)(Ad,{title:j(`printers.confirm.haToggleTitle`,{name:ce.name}),message:G?.state===`RUNNING`?j(`printers.confirm.haToggleWarning`,{name:e.name,entity:ce.ha_entity_id||ce.name}):j(`printers.confirm.haToggleMessage`,{entity:ce.ha_entity_id||ce.name}),confirmText:j(`printers.confirm.haToggleButton`),variant:G?.state===`RUNNING`?`danger`:`default`,onConfirm:()=>{jn.mutate({id:ce.id,action:`toggle`}),le(null)},onCancel:()=>le(null)}),me&&(0,K.jsx)(Ad,{title:j(`printers.confirm.stopTitle`),message:j(`printers.confirm.stopMessage`,{name:e.name}),confirmText:j(`printers.confirm.stopButton`),variant:`danger`,onConfirm:()=>{Mn.mutate(),he(!1)},onCancel:()=>he(!1)}),ge&&(0,K.jsx)(Ad,{title:j(`printers.confirm.pauseTitle`),message:j(`printers.confirm.pauseMessage`,{name:e.name}),confirmText:j(`printers.confirm.pauseButton`),variant:`default`,onConfirm:()=>{Nn.mutate(),_e(!1)},onCancel:()=>_e(!1)}),Ae&&(0,K.jsx)(Ad,{title:j(`printers.confirm.resumeTitle`),message:j(`printers.confirm.resumeMessage`,{name:e.name}),confirmText:j(`printers.confirm.resumeButton`),variant:`default`,onConfirm:()=>{Pn.mutate(),je(!1)},onCancel:()=>je(!1)}),Oe&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl w-full max-w-sm p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white mb-1`,children:j(`printers.bedJog.notHomedTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray leading-relaxed`,children:j(`printers.bedJog.notHomedMessage`)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{qn.mutate(`all`),ke(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors`,children:j(`printers.bedJog.homeZ`)}),(0,K.jsx)(`button`,{onClick:()=>{let t=Oe.distance;try{sessionStorage.setItem(`bambuddy.bedJog.warned.${e.id}`,`1`)}catch{}Wn.mutate({distance:t,force:!0}),ke(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30 transition-colors`,children:j(`printers.bedJog.moveAnyway`)}),(0,K.jsx)(`button`,{onClick:()=>ke(null),className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary transition-colors`,children:j(`common.cancel`)})]})]})}),(0,K.jsx)(cT,{printerId:e.id,isOpen:Me,onClose:()=>Ne(!1)}),ue&&(0,K.jsx)(iee,{printerName:e.name,errors:G?.hms_errors||[],onClose:()=>de(!1),printerId:e.id,hasPermission:F}),fe&&G&&(0,K.jsx)(VOe,{isOpen:fe,state:G.ams_filament_backup,amsUnits:G.ams,amsExtruderMap:G.ams_extruder_map,isDualNozzle:e.nozzle_count===2||G?.temperatures?.nozzle_2!==void 0,canToggle:F(`printers:control`),pending:On.isPending,onToggle:e=>On.mutate(e),onClose:()=>pe(!1)}),lt&&(0,K.jsx)(LOe,{isOpen:!!lt,onClose:()=>ut(null),printerId:e.id,printerName:e.name,amsId:lt.amsId,amsLabel:lt.amsLabel,initialMode:lt.mode,thresholds:a}),dt&&(0,K.jsx)(UOe,{isOpen:!!dt,onClose:()=>ft(null),printerId:e.id,printerName:e.name,initialKind:dt.initialKind,availableKinds:dt.availableKinds}),pt&&(0,K.jsx)(pU,{isOpen:!!pt,onClose:()=>mt(null),tagUid:pt.tagUid,trayUuid:pt.trayUuid,printerId:pt.printerId,amsId:pt.amsId,trayId:pt.trayId}),ht&&(0,K.jsx)(hU,{isOpen:!!ht,onClose:()=>gt(null),printerId:ht.printerId,amsId:ht.amsId,trayId:ht.trayId,trayInfo:ht.trayInfo,spoolmanEnabled:!!o}),_t&&(0,K.jsx)(WU,{isOpen:!!_t,onClose:()=>vt(null),printerId:e.id,slotInfo:_t,printerModel:EW(e.model)||void 0,onSuccess:()=>{M.invalidateQueries({queryKey:[`slotPresets`,e.id]}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),ee&&(0,K.jsx)(Hke,{printer:e,onClose:()=>te(!1)}),yt&&Nt&&(0,K.jsx)(Vke,{printer:e,firmwareInfo:Nt,onClose:()=>bt(!1)}),Ue!==null&&tt&&(()=>{let e=Ge===`n3s`?85:65,t=e+10;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[100]`,onClick:()=>We(null)}),(0,K.jsxs)(`div`,{className:`fixed z-[101] flex flex-col w-[240px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl overflow-hidden`,style:{top:tt.top,left:tt.left,maxHeight:`calc(100dvh - ${tt.top}px - 8px)`},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`shrink-0 flex items-center justify-center gap-2 px-3 py-2.5`,children:[(0,K.jsx)(ac,{className:`w-3.5 h-3.5 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium text-center`,children:j(`printers.drying.start`)})]}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2.5 overflow-y-auto min-h-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium mb-1 block`,children:j(`printers.filaments`)}),(0,K.jsx)(bW,{value:qe,options:Object.keys(x).map(e=>({value:e,label:e})),onChange:e=>{Je(e);let t=x[e];t&&(Xe(t[Ge===`n3s`?`n3s`:`n3f`]),Qe(Ge===`n3s`?t.n3s_hours:t.n3f_hours))},fullWidth:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium`,children:j(`printers.drying.temperature`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:45,max:e,value:Ye,onChange:t=>Xe(Math.min(e,Math.max(45,Number(t.target.value)||45))),className:`w-12 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:`°C`})]})]}),(0,K.jsx)(`input`,{type:`range`,min:35,max:t,value:Ye,onChange:t=>Xe(Math.min(e,Math.max(45,Number(t.target.value)))),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,K.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,K.jsx)(`span`,{children:`45°C`}),(0,K.jsxs)(`span`,{children:[e,`°C`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium`,children:j(`printers.drying.duration`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:Ze,onChange:e=>Qe(Math.min(24,Math.max(1,Number(e.target.value)||1))),className:`w-10 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:j(`printers.drying.hours`)})]})]}),(0,K.jsx)(`input`,{type:`range`,min:1,max:24,value:Ze,onChange:e=>Qe(Number(e.target.value)),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,K.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,K.jsx)(`span`,{children:`1h`}),(0,K.jsx)(`span`,{children:`24h`})]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>et(e=>!e),"aria-pressed":$e,className:`h-8 w-full rounded-lg border px-2 text-sm font-medium transition-colors ${$e?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:j(`printers.drying.rotateTray`)})]}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5 pb-3`,children:(0,K.jsx)(`button`,{onClick:()=>{Ue!==null&&En.mutate({amsId:Ue,temp:Ye,duration:Ze,filament:qe,rotateTray:$e})},disabled:En.isPending,className:`w-full py-1.5 bg-bambu-green hover:bg-bambu-green/80 text-white text-xs font-medium rounded-lg transition-colors disabled:opacity-50`,children:En.isPending?j(`printers.drying.startingDrying`):j(`printers.drying.start`)})})]})]})})()]})}function Bke({onClose:e,onAdd:t,existingSerials:n}){let{t:r}=W(),[i,a]=(0,y.useState)({name:``,serial_number:``,ip_address:``,access_code:``,model:``,location:``,auto_archive:!0}),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)([]),[v,b]=(0,y.useState)(``),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)({scanned:0,total:0}),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(null);(0,y.useEffect)(()=>{ed.getInfo().then(e=>{h(e.is_docker),e.subnets.length>0&&(_(e.subnets),b(e.subnets[0]))}).catch(()=>{});try{let e=localStorage.getItem(`bambuddy.discovery.customSubnet`);e&&S(e)}catch{}},[]);let N=c.filter(e=>!n.includes(e.serial)),P=async e=>{e.preventDefault(),A(!0);try{let e=await Q.diagnoseConnection({ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0});if(e.checks.some(e=>e.status===`fail`)){M(e);return}}catch{}finally{A(!1)}t(i)},F=async()=>{d(``),l([]),s(!0),p(!1),E({scanned:0,total:0});let e=C?x.trim():v,t=m||C;if(t&&C)try{localStorage.setItem(`bambuddy.discovery.customSubnet`,e)}catch{}try{if(t){await ed.startSubnetScan(e);let t=setInterval(async()=>{try{let e=await ed.getScanStatus();E({scanned:e.scanned,total:e.total}),l(await ed.getDiscoveredPrinters()),e.running||(clearInterval(t),s(!1),p(!0))}catch(e){console.error(`Failed to get scan status:`,e)}},500)}else{await ed.startDiscovery(10);let e=setInterval(async()=>{try{l(await ed.getDiscoveredPrinters())}catch(e){console.error(`Failed to get discovered printers:`,e)}},1e3);setTimeout(async()=>{clearInterval(e);try{await ed.stopDiscovery()}catch{}s(!1),p(!0);try{l(await ed.getDiscoveredPrinters())}catch(e){console.error(`Failed to get final discovered printers:`,e)}},1e4)}}catch(e){console.error(`Failed to start discovery:`,e),d(e instanceof Error?e.message:r(`printers.discovery.failedToStart`)),s(!1),p(!0)}},I=e=>{let t=e.serial.startsWith(`unknown-`)?``:e.serial;a({...i,name:e.name||``,serial_number:t,ip_address:e.ip_address,model:EW(e.model)}),l([])};return(0,y.useEffect)(()=>()=>{ed.stopDiscovery().catch(()=>{}),ed.stopSubnetScan().catch(()=>{})},[]),(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:e,children:(0,K.jsx)(_d,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:r(`printers.addPrinter`)}),(0,K.jsxs)(`div`,{className:`mb-4 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.discovery.subnetToScan`)}),g.length>0?(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:C?`__custom__`:v,onChange:e=>{e.target.value===`__custom__`?w(!0):(w(!1),b(e.target.value))},disabled:o,children:[g.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:`__custom__`,children:r(`printers.discovery.customSubnetOption`)})]}):(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:v,onChange:e=>b(e.target.value),placeholder:`192.168.1.0/24`,disabled:o}),C&&(0,K.jsx)(`input`,{type:`text`,"aria-label":r(`printers.discovery.customSubnetLabel`),className:`mt-2 w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:x,onChange:e=>S(e.target.value),placeholder:`10.1.1.0/24`,disabled:o}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:r(m?`printers.discovery.dockerNote`:`printers.discovery.customSubnetNote`)})]}),(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:F,disabled:o,className:`w-full`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(m||C)&&T.total>0?r(`printers.discovery.scanProgress`,{scanned:T.scanned,total:T.total}):r(`printers.discovery.scanning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Rl,{className:`w-4 h-4`}),r(m||C?`printers.discovery.scanSubnet`:`printers.discovery.discoverNetwork`)]})}),u&&(0,K.jsx)(`div`,{className:`mt-2 text-sm text-red-400`,children:u}),N.length>0&&(0,K.jsx)(`div`,{className:`mt-3 space-y-2 max-h-40 overflow-y-auto`,children:N.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors`,onClick:()=>I(e),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium text-white text-sm truncate`,children:e.name||e.serial}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[EW(e.model)||r(`printers.discovery.unknown`),` • `,e.ip_address,e.serial.startsWith(`unknown-`)&&(0,K.jsxs)(`span`,{className:`text-yellow-500`,children:[` • `,r(`printers.discovery.serialRequired`)]})]})]}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2`})]},e.serial))}),o&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.scanningSubnet`:`printers.discovery.scanningNetwork`)}),f&&!o&&c.length===0&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.noPrintersFoundSubnet`:`printers.discovery.noPrintersFoundNetwork`)}),f&&!o&&c.length>0&&N.length===0&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(`printers.discovery.allConfigured`)})]}),(0,K.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.name`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:r(`printers.modal.myPrinter`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.ipAddress`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[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])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.ip_address,onChange:e=>a({...i,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.serialNumber`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.serial_number,onChange:e=>a({...i,serial_number:e.target.value}),placeholder:`01P00A000000000`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.accessCode`)}),(0,K.jsx)(`input`,{type:`password`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.access_code,onChange:e=>a({...i,access_code:e.target.value}),placeholder:r(`printers.modal.fromPrinterSettings`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.modelOptional`)}),(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.model||``,onChange:e=>a({...i,model:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`printers.modal.selectModel`)}),(0,K.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,K.jsx)(`option`,{value:`A1`,children:`A1`}),(0,K.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,K.jsx)(`optgroup`,{label:`A2 Series`,children:(0,K.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,K.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,K.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,K.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,K.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,K.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,K.jsxs)(`optgroup`,{label:`P Series`,children:[(0,K.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,K.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,K.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,K.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,K.jsx)(`option`,{value:`X1`,children:`X1`}),(0,K.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,K.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,K.jsx)(`optgroup`,{label:`X2 Series`,children:(0,K.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.locationGroup`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.location||``,onChange:e=>a({...i,location:e.target.value}),placeholder:r(`printers.modal.locationPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`printers.locationHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`auto_archive`,checked:i.auto_archive,onChange:e=>a({...i,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`auto_archive`,className:`text-sm text-bambu-gray`,children:r(`printers.modal.autoArchiveLabel`)})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>O(!0),disabled:!i.ip_address.trim(),className:`w-full flex items-center justify-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white disabled:opacity-40 disabled:cursor-not-allowed border border-bambu-dark-tertiary rounded-lg transition-colors`,children:[(0,K.jsx)(cu,{className:`w-4 h-4`}),r(`diagnostic.runButton`)]}),j?(0,K.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,K.jsx)(`p`,{className:`text-sm text-amber-300`,children:r(`printers.addPreflight.warning`)})]}),(0,K.jsx)(np,{result:j}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>M(null),className:`flex-1`,children:r(`printers.addPreflight.back`)}),(0,K.jsx)($,{type:`button`,onClick:()=>t(i),className:`flex-1`,children:r(`printers.addPreflight.saveAnyway`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:k,className:`flex-1`,children:r(k?`printers.addPreflight.checking`:`printers.addPrinter`)})]})]})]})})}),D&&(0,K.jsx)(ip,{connection:{ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0},printerName:i.name||null,onClose:()=>O(!1)})]})}function Vke({printer:e,firmwareInfo:t,onClose:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),{hasPermission:o}=dd(),s=o(`firmware:update`),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(t.update_available?t.latest_version:null),{data:g,isLoading:_}=q({queryKey:[`firmwarePrepare`,e.id,m],queryFn:()=>id.prepareUpload(e.id,m??void 0),staleTime:3e4,enabled:!!m&&s&&!u}),v=J({mutationFn:()=>id.startUpload(e.id,m??void 0),onSuccess:()=>{d(!0);let t=setInterval(async()=>{try{let n=await id.getUploadStatus(e.id);l(n),(n.status===`complete`||n.status===`error`)&&(clearInterval(t),p(null),d(!1),n.status===`complete`&&(a(r(`printers.firmwareModal.uploadedToast`),`success`),i.invalidateQueries({queryKey:[`firmwareUpdate`,e.id]})))}catch{}},2e3);p(t)},onError:e=>{a(r(`printers.firmwareModal.uploadFailed`,{error:e.message}),`error`),d(!1)}});return(0,y.useEffect)(()=>()=>{f&&clearInterval(f)},[f]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsx)(_d,{className:`w-full max-w-md mx-4`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full ${t.update_available?`bg-orange-500/20`:`bg-status-ok/20`}`,children:t.update_available?(0,K.jsx)(Vs,{className:`w-5 h-5 text-orange-400`}):(0,K.jsx)(ps,{className:`w-5 h-5 text-status-ok`})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t.update_available?r(`printers.firmwareModal.title`):r(`printers.firmwareModal.titleUpToDate`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e.name})]})]}),(()=>{let e=m?t.available_versions?.find(e=>e.version===m):null,n=m??t.latest_version,i=e?.release_notes??t.release_notes,a=!!n&&n!==t.current_version;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.currentVersion`)}),(0,K.jsx)(`span`,{className:`font-mono ${a?`text-white`:`text-status-ok`}`,children:t.current_version||r(`common.unknown`)})]}),a&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm mt-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.latestVersion`)}),(0,K.jsx)(`span`,{className:`text-orange-400 font-mono`,children:n})]}),i&&(0,K.jsxs)(`details`,{className:`mt-3 text-sm`,open:!a,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:underline ${a?`text-orange-400`:`text-status-ok`}`,children:r(`printers.firmwareModal.releaseNotes`)}),(0,K.jsx)(`div`,{className:`mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap`,children:i})]},n??`none`)]})})(),t.available_versions&&t.available_versions.length>0&&!u&&c?.status!==`complete`&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mb-2`,children:r(`printers.firmwareModal.availableVersions`)}),(0,K.jsx)(`div`,{className:`max-h-56 overflow-y-auto border border-bambu-dark-tertiary rounded-lg divide-y divide-bambu-dark-tertiary`,children:t.available_versions.map(e=>{let n=t.current_version===e.version,i=m===e.version,a=t.current_version?kp(e.version,t.current_version):0,o=r(n?`printers.firmwareModal.currentBadge`:a>0?`printers.firmwareModal.newerBadge`:`printers.firmwareModal.olderBadge`),c=n?`text-bambu-gray`:a>0?`text-orange-400`:`text-blue-400`;return(0,K.jsxs)(`button`,{type:`button`,disabled:!e.file_available||!s||n,onClick:()=>h(e.version),className:`w-full text-left px-3 py-2 text-sm flex items-center justify-between gap-2 transition-colors ${i?`bg-orange-500/10`:`hover:bg-bambu-dark`} ${!e.file_available||!s||n?`opacity-60 cursor-not-allowed`:`cursor-pointer`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-mono text-white`,children:e.version}),(0,K.jsx)(`span`,{className:`text-xs ${c}`,children:o})]}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${n?`bg-blue-500/15 text-blue-400 border border-blue-500/30`:e.file_available?`bg-bambu-green/15 text-bambu-green border border-bambu-green/30`:`bg-bambu-gray/10 text-bambu-gray border border-bambu-gray/30`}`,children:n?r(`printers.firmwareModal.installed`):e.file_available?r(`printers.firmwareModal.usable`):r(`printers.firmwareModal.unavailable`)})]},e.version)})})]}),m?_?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm mb-4`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`printers.firmwareModal.checkingPrereqs`)]}):g&&!u&&!c?(0,K.jsx)(`div`,{className:`mb-4`,children:g.can_proceed?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green text-sm`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),r(`printers.firmwareModal.sdCardReady`)]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:g.errors.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 flex-shrink-0`}),e]},t))})}):null:null,(u||c)&&c&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray capitalize`,children:c.status}),(0,K.jsxs)(`span`,{className:`text-white`,children:[c.progress,`%`]})]}),(0,K.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`h-2 rounded-full transition-all ${c.status===`error`?`bg-status-error`:c.status===`complete`?`bg-status-ok`:`bg-orange-500`} ${c.status===`uploading`?`animate-pulse`:``}`,style:{width:`${c.progress}%`}})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:c.message}),c.error&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:c.error})]}),c?.status===`complete`&&(0,K.jsxs)(`div`,{className:`bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-green font-medium mb-2`,children:r(`printers.firmwareModal.uploadedSuccess`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`printers.firmwareModal.applyInstructions`)}),(0,K.jsxs)(`ol`,{className:`text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1`,children:[(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step1`)}}),(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step2`)}}),(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step3`)}}),(0,K.jsx)(`li`,{children:r(`printers.firmwareModal.step4`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:n,children:c?.status===`complete`?r(`printers.firmwareModal.done`):r(`common.cancel`)}),g?.can_proceed&&!u&&c?.status!==`complete`&&s&&(0,K.jsx)($,{onClick:()=>{l(null),v.mutate()},disabled:v.isPending,children:v.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}),r(`printers.firmwareModal.starting`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),r(`printers.firmwareModal.uploadFirmware`)]})})]})]})})})}function Hke({printer:e,onClose:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)({name:e.name,ip_address:e.ip_address,access_code:``,model:e.model||``,location:e.location||``,auto_archive:e.auto_archive,is_active:e.is_active}),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=J({mutationFn:t=>Q.updatePrinter(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`printers`]}),r.invalidateQueries({queryKey:[`printerStatus`,e.id]}),t()},onError:e=>i(e.message||n(`printers.toast.failedToUpdate`),`error`)});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=()=>{let e={name:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive,is_active:a.is_active};a.access_code&&(e.access_code=a.access_code),d.mutate(e)};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,K.jsx)(_d,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:n(`printers.editPrinter`)}),(0,K.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),c(!0);try{let t=await Q.diagnoseConnection({ip_address:a.ip_address.trim(),serial_number:e.serial_number,access_code:a.access_code||void 0});if(t.checks.some(e=>e.status===`fail`)){u(t);return}}catch{}finally{c(!1)}f()},className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.name`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:n(`printers.modal.myPrinter`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.ipAddress`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[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])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.ip_address,onChange:e=>o({...a,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.serialNumber`)}),(0,K.jsx)(`input`,{type:`text`,disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed`,value:e.serial_number}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.serialCannotBeChanged`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.accessCode`)}),(0,K.jsx)(`input`,{type:`password`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.access_code,onChange:e=>o({...a,access_code:e.target.value}),placeholder:n(`printers.accessCodePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.model`)}),(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.model,onChange:e=>o({...a,model:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:n(`printers.modal.selectModel`)}),(0,K.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,K.jsx)(`option`,{value:`A1`,children:`A1`}),(0,K.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,K.jsx)(`optgroup`,{label:`A2 Series`,children:(0,K.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,K.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,K.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,K.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,K.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,K.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,K.jsxs)(`optgroup`,{label:`P Series`,children:[(0,K.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,K.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,K.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,K.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,K.jsx)(`option`,{value:`X1`,children:`X1`}),(0,K.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,K.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,K.jsx)(`optgroup`,{label:`X2 Series`,children:(0,K.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Location / Group`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.location,onChange:e=>o({...a,location:e.target.value}),placeholder:n(`printers.modal.locationPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.locationHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`edit_auto_archive`,checked:a.auto_archive,onChange:e=>o({...a,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`edit_auto_archive`,className:`text-sm text-bambu-gray`,children:n(`printers.modal.autoArchiveLabel`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`edit_maintenance_mode`,checked:!a.is_active,onChange:e=>o({...a,is_active:!e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-amber-400 focus:ring-amber-400`}),(0,K.jsxs)(`label`,{htmlFor:`edit_maintenance_mode`,className:`text-sm text-bambu-gray flex items-center gap-1.5`,children:[(0,K.jsx)(Lu,{className:`w-3.5 h-3.5 text-amber-400`}),n(`printers.maintenance.editFieldLabel`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1 ml-6`,children:n(`printers.maintenance.editFieldHelp`)})]}),l?(0,K.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,K.jsx)(`p`,{className:`text-sm text-amber-300`,children:n(`printers.addPreflight.warning`)})]}),(0,K.jsx)(np,{result:l}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>u(null),className:`flex-1`,children:n(`printers.addPreflight.back`)}),(0,K.jsx)($,{type:`button`,onClick:f,className:`flex-1`,disabled:d.isPending,children:n(`printers.addPreflight.saveAnyway`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3 pt-4`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,className:`flex-1`,disabled:d.isPending||s,children:s?n(`printers.addPreflight.checking`):d.isPending?n(`common.saving`):n(`printers.modal.saveChanges`)})]})]})]})})})}function Uke(e){let{data:t}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4});return!t?.connected}function Wke({printer:e,plug:t,onPowerOn:n,isPowering:r}){let i=Uke(e.id),{data:a}=q({queryKey:[`smartPlugStatus`,t.id],queryFn:()=>Q.getSmartPlugStatus(t.id),refetchInterval:1e4});return i?(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm text-gray-900 dark:text-white truncate`,children:e.name}),a&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${a.state===`ON`?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:a.state||`?`})]}),(0,K.jsxs)(`button`,{onClick:()=>n(t.id),disabled:r||a?.state===`ON`,className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state===`ON`?`bg-bambu-green/20 text-bambu-green cursor-default`:`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white`}`,children:[(0,K.jsx)(wl,{className:`w-3 h-3`}),r?`...`:`On`]})]}):null}function Gke(){let{t:e}=W(),{resolvedMode:t,darkAccent:n,lightAccent:r}=md(),i={green:`bg-green-500 text-white hover:bg-green-400 border-green-400/60`,teal:`bg-teal-500 text-white hover:bg-teal-400 border-teal-400/60`,blue:`bg-blue-500 text-white hover:bg-blue-400 border-blue-400/60`,orange:`bg-orange-500 text-white hover:bg-orange-400 border-orange-400/60`,purple:`bg-purple-500 text-white hover:bg-purple-400 border-purple-400/60`,red:`bg-red-500 text-white hover:bg-red-400 border-red-400/60`}[t===`dark`?n:r],[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(()=>localStorage.getItem(`hideDisconnectedPrinters`)===`true`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(()=>localStorage.getItem(`printerSortBy`)||`name`),[h,g]=(0,y.useState)(()=>localStorage.getItem(`printerSortAsc`)!==`false`),[_,v]=(0,y.useState)(()=>{let e=localStorage.getItem(`printerCardSize`);return e?parseInt(e,10):2}),b=_===1?`compact`:`expanded`,[x,S]=(0,y.useState)(null),C=(0,y.useCallback)(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(`printer-card-${e}`);if(!t)return;let n=document.querySelector(`header`)?.getBoundingClientRect().height??56,r=t.getBoundingClientRect().top+window.scrollY-n-16;window.scrollTo({top:Math.max(0,r),behavior:`smooth`})})})},[]),w=(0,y.useCallback)(e=>{S(e),v(2),localStorage.setItem(`printerCardSize`,`2`),C(e)},[C]),T=(0,y.useCallback)(()=>{let e=x;S(null),v(1),localStorage.setItem(`printerCardSize`,`1`),e!=null&&C(e)},[x,C]),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(`all`),[A,j]=(0,y.useState)(`all`),[M,N]=(0,y.useState)(0),[P,F]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`printerCollapsedSections`);return e?JSON.parse(e):{}}catch{return{}}}),I=no(),{showToast:L}=Td(),{hasPermission:R}=dd(),[z,B]=(0,y.useState)(()=>{let e=localStorage.getItem(`openEmbeddedCameras`);if(e)try{let t=JSON.parse(e);return new Map(t.map(e=>[e.id,e]))}catch{return new Map}return new Map});(0,y.useEffect)(()=>{let e=Array.from(z.values());e.length>0?localStorage.setItem(`openEmbeddedCameras`,JSON.stringify(e)):localStorage.removeItem(`openEmbeddedCameras`)},[z]);let{data:V,isLoading:ee}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:te}=q({queryKey:[`ui-preferences`],queryFn:Q.getUiPreferences}),ne=(0,y.useMemo)(()=>Lp(te?.nozzle_temp_presets,Mp,0,320),[te?.nozzle_temp_presets]),re=(0,y.useMemo)(()=>Lp(te?.bed_temp_presets,Np,0,140),[te?.bed_temp_presets]),ie=(0,y.useMemo)(()=>Lp(te?.chamber_temp_presets,Pp,0,60),[te?.chamber_temp_presets]),H=(0,y.useMemo)(()=>Lp(te?.fan_speed_presets,Fp,0,100),[te?.fan_speed_presets]),ae=(0,y.useMemo)(()=>{if(te?.drying_presets)try{let e=JSON.parse(te.drying_presets);if(typeof e==`object`&&e&&Object.keys(e).length>0)return{...OW,...e}}catch{}return OW},[te?.drying_presets]);(0,y.useEffect)(()=>{te?.camera_view_mode===`window`&&z.size>0&&B(new Map)},[te?.camera_view_mode,z.size]);let{data:oe}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:U}=q({queryKey:[`maintenanceOverview`],queryFn:Q.getMaintenanceOverview,staleTime:60*1e3}),{data:se}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,staleTime:60*1e3}),ce=se?.enabled&&se?.connected,{data:le}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,enabled:!!ce,staleTime:60*1e3}),ue=le?.spoolman_sync_mode,{data:de}=q({queryKey:[`unlinked-spools`],queryFn:Q.getUnlinkedSpools,enabled:!!ce,staleTime:30*1e3}),fe=de&&de.length>0,{data:pe}=q({queryKey:[`linked-spools`],queryFn:Q.getLinkedSpools,enabled:!!ce,staleTime:30*1e3}),me=pe?.linked,{data:he}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:R(`inventory:view_assignments`),staleTime:30*1e3}),ge=J({mutationFn:({printerId:e,amsId:t,trayId:n})=>Q.unassignSpool(e,t,n),onSuccess:()=>{I.invalidateQueries({queryKey:[`spool-assignments`]})}}),{data:_e,isLoading:ve}=q({queryKey:[`spoolman-inventory-spools`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:!!ce,staleTime:30*1e3}),{data:ye,isLoading:be}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:!!ce,staleTime:30*1e3}),xe=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{I.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),I.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})}}),Se=(e,t,n)=>he?.find(r=>r.printer_id===e&&r.ams_id===Number(t)&&r.tray_id===Number(n)),Ce=U?.reduce((e,t)=>(e[t.printer_id]={due_count:t.due_count,warning_count:t.warning_count,total_print_hours:t.total_print_hours},e),{})||{},we=oe?.reduce((e,t)=>(t.printer_id&&(e[t.printer_id]=t),e),{})||{},Te=J({mutationFn:Q.createPrinter,onSuccess:()=>{I.invalidateQueries({queryKey:[`printers`]}),I.invalidateQueries({queryKey:[`maintenanceOverview`]}),o(!1)},onError:t=>{if(t instanceof Uu&&t.code===`printer_connection_failed`){L(e(`printers.toast.connectionFailedNotAdded`),`error`);return}L(t.message||e(`printers.toast.failedToAdd`),`error`)}}),Ee=J({mutationFn:e=>Q.controlSmartPlug(e,`on`),onSuccess:()=>{I.invalidateQueries({queryKey:[`smart-plugs`]}),f(null)},onError:()=>{f(null)}}),[De,Oe]=(0,y.useState)(new Set),[ke,Ae]=(0,y.useState)(!1),[je,Me]=(0,y.useState)(null),[Ne,Pe]=(0,y.useState)(!1),Fe=ke||De.size>0,Ie=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Le=(0,y.useCallback)(()=>{Oe(new Set),Ae(!1)},[]);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&Fe&&Le()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Fe,Le]);let Re=(0,y.useCallback)(async t=>{Pe(!0);let n=Array.from(De).filter(e=>{let n=I.getQueryData([`printerStatus`,e]);if(!n?.connected)return!1;switch(t){case`stop`:return n.state===`RUNNING`||n.state===`PAUSE`;case`pause`:return n.state===`RUNNING`;case`resume`:return n.state===`PAUSE`;case`clearPlate`:return!!n.awaiting_plate_clear;case`clearHMS`:return n.hms_errors&&Vp(n.hms_errors).length>0;default:return!1}});if(n.length===0){L(e(`printers.bulk.noneApplicable`),`error`),Pe(!1),Me(null);return}let r={stop:Q.stopPrint,pause:Q.pausePrint,resume:Q.resumePrint,clearPlate:Q.clearPlate,clearHMS:Q.clearHMSErrors}[t],i=await Promise.allSettled(n.map(e=>r(e))),a=i.filter(e=>e.status===`fulfilled`).length,o=i.filter(e=>e.status===`rejected`).length;o===0?L(e(`printers.bulk.success`,{action:e(`printers.bulk.actions.${t}`),count:a})):L(e(`printers.bulk.partial`,{succeeded:a,failed:o}),`error`),n.forEach(e=>{I.invalidateQueries({queryKey:[`printerStatus`,e]})}),Pe(!1),Me(null)},[De,I,L,e]),ze=(0,y.useCallback)(e=>{e===`stop`||e===`pause`||e===`clearPlate`?Me(e):Re(e)},[Re]),Be=()=>{let e=!s;c(e),localStorage.setItem(`hideDisconnectedPrinters`,String(e))},Ve=e=>{m(e),localStorage.setItem(`printerSortBy`,e)},He=()=>{let e=!h;g(e),localStorage.setItem(`printerSortAsc`,String(e))},Ue=()=>{switch(_){case 1:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`;case 2:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`;case 3:return`grid-cols-1 lg:grid-cols-2`;case 4:return`grid-cols-1`;default:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`}},We=[`S`,`M`,`L`,`XL`];(0,y.useEffect)(()=>I.getQueryCache().subscribe(e=>{e.type===`updated`&&Array.isArray(e.query.queryKey)&&e.query.queryKey[0]===`printerStatus`&&N(e=>e+1)}),[I]);let Ge=(0,y.useMemo)(()=>{if(!V)return[];let e=V;if(E.trim()){let t=E.trim().toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||(e.model||``).toLowerCase().includes(t)||(e.location||``).toLowerCase().includes(t)||(e.serial_number||``).toLowerCase().includes(t))}return A!==`all`&&(e=e.filter(e=>(e.location||``)===A)),O!==`all`&&(e=e.filter(e=>{let t=I.getQueryData([`printerStatus`,e.id]);if(!t?.connected)return O===`offline`;let n=t.hms_errors?Vp(t.hms_errors):[];switch(O){case`printing`:return t.state===`RUNNING`;case`paused`:return t.state===`PAUSE`;case`finished`:return t.state===`FINISH`;case`error`:return t.state===`FAILED`||n.length>0;case`idle`:return t.state!==`RUNNING`&&t.state!==`PAUSE`&&t.state!==`FINISH`&&t.state!==`FAILED`&&n.length===0;case`offline`:return!1;default:return!0}})),e},[V,E,O,A,I,M]),Ke=(0,y.useMemo)(()=>V?[...new Set(V.map(e=>e.location||``).filter(Boolean))].sort():[],[V]),qe=(0,y.useMemo)(()=>{let e=[...Ge];switch(p){case`name`:e.sort((e,t)=>e.name.localeCompare(t.name));break;case`model`:e.sort((e,t)=>(e.model||``).localeCompare(t.model||``));break;case`location`:e.sort((e,t)=>{let n=e.location||``,r=t.location||``;return!n&&r?1:n&&!r?-1:n.localeCompare(r)||e.name.localeCompare(t.name)});break;case`status`:e.sort((e,t)=>{let n=I.getQueryData([`printerStatus`,e.id]),r=I.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?(e.hms_errors?Vp(e.hms_errors):[]).length>0?0:e.state===`RUNNING`?1:2:3;return i(n)-i(r)});break;case`eta`:e.sort((e,t)=>{let n=I.getQueryData([`printerStatus`,e.id]),r=I.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?e.state===`RUNNING`&&e.remaining_time!=null&&e.remaining_time>0?0:e.state===`RUNNING`?1:2:3,a=i(n),o=i(r);if(a!==o)return a-o;if(a===0){let e=(n.remaining_time??0)-(r.remaining_time??0);if(e!==0)return e}return e.name.localeCompare(t.name)});break}return h||e.reverse(),e},[Ge,p,h,I]),Je=(0,y.useCallback)(()=>{Oe(new Set(qe.map(e=>e.id))),Ae(!0)},[qe]),Ye=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.forEach(t=>{TW(I.getQueryData([`printerStatus`,t.id]))===e&&n.add(t.id)}),n}),Ae(!0)},[qe,I]),Xe=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.filter(t=>(t.location||``)===e).forEach(e=>n.add(e.id)),n}),Ae(!0)},[qe]),Ze=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.filter(t=>(t.model||`Unknown`)===e).forEach(e=>n.add(e.id)),n}),Ae(!0)},[qe]),Qe=(0,y.useCallback)(e=>{F(t=>{let n={...t,[e]:!t[e]};try{localStorage.setItem(`printerCollapsedSections`,JSON.stringify(n))}catch{}return n})},[]),$e=(0,y.useMemo)(()=>{if(p===`name`||p===`eta`)return null;let e={};return p===`location`?qe.forEach(t=>{let n=t.location||`Ungrouped`;e[n]||(e[n]=[]),e[n].push(t)}):p===`model`?qe.forEach(t=>{let n=t.model||`Unknown`;e[n]||(e[n]=[]),e[n].push(t)}):p===`status`&&qe.forEach(t=>{let n=TW(I.getQueryData([`printerStatus`,t.id]));e[n]||(e[n]=[]),e[n].push(t)}),e},[p,qe,I,M]),et=(0,y.useRef)(null),tt=(0,y.useRef)(null),nt=(0,y.useRef)(0),[rt,it]=(0,y.useState)(!1),at=(0,y.useCallback)(()=>{let e=et.current;if(!e)return;let t=tt.current?.offsetWidth;t&&(nt.current=t);let n=nt.current>0&&e.clientWidthe===n?e:n)},[]),ot=Object.keys(we).length;(0,y.useLayoutEffect)(()=>{at();let e=et.current;if(!e)return;if(typeof ResizeObserver>`u`)return window.addEventListener(`resize`,at),()=>window.removeEventListener(`resize`,at);let t=new ResizeObserver(()=>at());return t.observe(e),window.addEventListener(`resize`,at),()=>{t.disconnect(),window.removeEventListener(`resize`,at)}},[at,V?.length,Ke.length,s,ot]);let st=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[V&&V.length>0&&(0,K.jsx)(bW,{value:O,onChange:k,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allStatuses`)},{value:`printing`,label:e(`printers.status.printing`)},{value:`paused`,label:e(`printers.status.paused`)},{value:`idle`,label:e(`printers.status.idle`)},{value:`finished`,label:e(`printers.status.finished`)},{value:`error`,label:e(`printers.status.error`)},{value:`offline`,label:e(`printers.status.offline`)}]}),V&&V.length>0&&Ke.length>0&&(0,K.jsx)(bW,{value:A,onChange:j,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allLocations`)},...Ke.map(e=>({value:e,label:e}))]}),(0,K.jsx)(`button`,{type:`button`,onClick:Be,"aria-pressed":s,className:`h-8 px-2 rounded-lg border text-sm font-medium transition-colors ${t?`w-full`:``} ${s?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:e(`printers.hideOffline`)})]}),ct=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 ${t?`w-full`:``}`,children:[(0,K.jsx)(bW,{value:p,onChange:Ve,fullWidth:t,options:[{value:`name`,label:e(`printers.sort.name`)},{value:`status`,label:e(`printers.sort.status`)},{value:`model`,label:e(`printers.sort.model`)},{value:`location`,label:e(`printers.sort.location`)},{value:`eta`,label:e(`printers.sort.eta`)}]}),(0,K.jsx)(`button`,{onClick:He,className:`h-8 shrink-0 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,title:e(h?`printers.sort.descending`:`printers.sort.ascending`),children:h?(0,K.jsx)(Io,{className:`w-4 h-4 text-white`}):(0,K.jsx)(Ao,{className:`w-4 h-4 text-white`})})]}),(0,K.jsx)(`div`,{className:`flex h-8 items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary ${t?`w-full`:``}`,children:We.map((n,r)=>{let i=r+1,a=_===i;return(0,K.jsx)(`button`,{onClick:()=>{S(null),v(i),localStorage.setItem(`printerCardSize`,String(i))},className:`h-full px-2 text-xs font-medium transition-colors ${t?`flex-1`:``} ${r===0?`rounded-l-lg`:``} ${r===We.length-1?`rounded-r-lg`:``} ${a?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(n===`S`?`printers.cardSize.small`:n===`M`?`printers.cardSize.medium`:n===`L`?`printers.cardSize.large`:`printers.cardSize.extraLarge`),children:n},n)})})]}),lt=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:()=>{Fe?Le():Ae(!0)},className:`h-8 px-2 rounded-lg border transition-colors ${t?`w-full justify-center gap-1.5 text-sm font-medium flex items-center`:``} ${Fe?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.bulk.select`),disabled:!R(`printers:control`),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),t&&(0,K.jsx)(`span`,{children:e(`printers.bulk.select`)})]}),s&&Object.keys(we).length>0&&(0,K.jsxs)(`div`,{className:`relative ${t?`w-full`:``}`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(!l),className:`h-8 flex items-center gap-1.5 px-2 text-sm rounded-lg border transition-colors ${t?`w-full justify-between bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary hover:text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(wl,{className:`w-4 h-4`}),e(`printers.powerOn`)]}),(0,K.jsx)(is,{className:`w-3 h-3 transition-transform ${l?`rotate-180`:``}`})]}),l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>u(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:[(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:e(`printers.offlinePrintersWithPlugs`)}),V?.filter(e=>we[e.id]).map(e=>(0,K.jsx)(Wke,{printer:e,plug:we[e.id],onPowerOn:e=>{f(e),Ee.mutate(e)},isPowering:d===we[e.id]?.id},e.id)),V?.filter(e=>we[e.id]).length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:`No printers with smart plugs`})]})]})]}),(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!R(`printers:create`),title:R(`printers:create`)?void 0:e(`printers.permission.noAdd`),className:`!h-8 !min-h-8 px-2 py-0 ${t?`w-full`:``}`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]});return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Tl,{className:`w-7 h-7 text-bambu-green`}),e(`printers.title`)]}),(0,K.jsx)(Fke,{printers:V})]}),(0,K.jsxs)(`div`,{ref:et,className:`relative flex items-center gap-2`,children:[V&&V.length>0&&(0,K.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,K.jsx)(`input`,{type:`search`,name:`printer-search`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,value:E,onChange:e=>D(e.target.value),placeholder:e(`printers.search`),"aria-label":e(`printers.search`),className:`w-full h-8 pl-9 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),E&&(0,K.jsx)(`button`,{type:`button`,"aria-label":e(`common.clear`),onClick:()=>D(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{ref:tt,"aria-hidden":rt,inert:rt,className:`${rt?`absolute -left-[9999px] top-0 flex w-max pointer-events-none opacity-0`:`flex`} ml-auto items-center justify-end gap-2 flex-nowrap [&>*]:shrink-0`,children:[(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:st()}),(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:ct()}),(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:lt()})]}),rt&&(0,K.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-1`,children:[(0,K.jsx)(xW,{label:e(`printers.toolbar.filters`,`Filters`),icon:(0,K.jsx)(mc,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:st(!0)})}),(0,K.jsx)(xW,{label:e(`printers.toolbar.view`,`View`),icon:(0,K.jsx)(Ql,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:ct(!0)})}),(0,K.jsx)(xW,{label:e(`printers.toolbar.actions`,`Actions`),icon:(0,K.jsx)(Gs,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:lt(!0)})})]})]})]}),ee?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):V?.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`printers.noPrintersConfigured`)}),(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!R(`printers:create`),title:R(`printers:create`)?void 0:e(`printers.permission.noAdd`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]})}):qe.length===0&&(E.trim()||O!==`all`||A!==`all`)?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`text-center py-12`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`printers.noSearchResults`)})})}):$e?(0,K.jsx)(`div`,{className:`space-y-6`,children:(()=>{let e=p===`status`?Lke.filter(e=>$e[e]?.length>0):Object.keys($e);return h?e:[...e].reverse()})().map(t=>{let n=$e[t],r=`${p}:${t}`,i=!P[r],a=p===`status`&&wW[t]?.dot||`bg-bambu-green`,o=p===`status`?e(wW[t]?.labelKey||t):t;return(0,K.jsx)(lp,{open:i,onToggle:()=>Qe(r),summaryClassName:`py-1`,summary:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${a}`}),o,(0,K.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n.length,`)`]}),Fe&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),p===`location`?Xe(t===`Ungrouped`?``:t):p===`status`?Ye(t):p===`model`&&Ze(t)},className:`text-xs text-bambu-green hover:text-bambu-green-light transition-colors ml-1`,children:e(`printers.bulk.selectAll`)})]}),children:(0,K.jsx)(`div`,{className:`grid gap-4 ${_>=3?`gap-6`:``} ${Ue()}`,children:n.map(e=>(0,K.jsx)(kW,{printer:e,hideIfDisconnected:s,maintenanceInfo:Ce[e.id],viewMode:b,cardSize:_,amsThresholds:te?{humidityGood:Number(te.ams_humidity_good)||40,humidityFair:Number(te.ams_humidity_fair)||60,tempGood:Number(te.ams_temp_good)||28,tempFair:Number(te.ams_temp_fair)||35}:void 0,spoolmanEnabled:ce,hasUnlinkedSpools:fe,linkedSpools:me,spoolmanUrl:se?.url,spoolmanSyncMode:ue,onGetAssignment:Se,onUnassignSpool:(e,t,n)=>ge.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:_e,spoolmanSlotAssignments:ye,spoolmanLoading:ve||be,onUnassignSpoolmanSpool:e=>xe.mutate(e),timeFormat:te?.time_format||`system`,cameraViewMode:te?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>B(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:te?.check_printer_firmware!==!1,dryingPresets:ae,nozzleTempPresets:ne,bedTempPresets:re,chamberTempPresets:ie,fanSpeedPresets:H,requirePlateClear:te?.require_plate_clear===!0,selectionMode:Fe,isSelected:De.has(e.id),onToggleSelect:Ie,onOpenCompactCard:w},e.id))})},t)})}):(0,K.jsx)(`div`,{className:`grid gap-4 ${_>=3?`gap-6`:``} ${Ue()}`,children:qe.map(e=>(0,K.jsx)(kW,{printer:e,hideIfDisconnected:s,maintenanceInfo:Ce[e.id],viewMode:b,cardSize:_,spoolmanEnabled:ce,hasUnlinkedSpools:fe,linkedSpools:me,spoolmanUrl:se?.url,spoolmanSyncMode:ue,onGetAssignment:Se,onUnassignSpool:(e,t,n)=>ge.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:_e,spoolmanSlotAssignments:ye,spoolmanLoading:ve||be,onUnassignSpoolmanSpool:e=>xe.mutate(e),amsThresholds:te?{humidityGood:Number(te.ams_humidity_good)||40,humidityFair:Number(te.ams_humidity_fair)||60,tempGood:Number(te.ams_temp_good)||28,tempFair:Number(te.ams_temp_fair)||35}:void 0,timeFormat:te?.time_format||`system`,cameraViewMode:te?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>B(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:te?.check_printer_firmware!==!1,dryingPresets:ae,nozzleTempPresets:ne,bedTempPresets:re,chamberTempPresets:ie,fanSpeedPresets:H,requirePlateClear:te?.require_plate_clear===!0,selectionMode:Fe,isSelected:De.has(e.id),onToggleSelect:Ie,onOpenCompactCard:w},e.id))}),_===2&&x!=null&&(0,K.jsxs)(`button`,{type:`button`,onClick:T,className:`fixed bottom-5 left-1/2 z-40 inline-flex -translate-x-1/2 items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-xl transition-colors ${i}`,title:e(`common.back`,`Back`),children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),e(`common.back`,`Back`)]}),a&&(0,K.jsx)(Bke,{onClose:()=>o(!1),onAdd:e=>Te.mutate(e),existingSerials:V?.map(e=>e.serial_number)||[]}),Fe&&V&&(0,K.jsx)(oee,{selectedIds:De,printers:V,onClose:Le,onSelectAll:Je,onSelectByLocation:Xe,onSelectByState:Ye,onAction:ze,actionPending:Ne}),je===`stop`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.stopTitle`,{count:De.size}),message:e(`printers.bulk.confirm.stopMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.stopButton`),variant:`danger`,isLoading:Ne,onConfirm:()=>Re(`stop`),onCancel:()=>Me(null)}),je===`pause`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.pauseTitle`,{count:De.size}),message:e(`printers.bulk.confirm.pauseMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.pauseButton`),isLoading:Ne,onConfirm:()=>Re(`pause`),onCancel:()=>Me(null)}),je===`clearPlate`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.clearPlateTitle`,{count:De.size}),message:e(`printers.bulk.confirm.clearPlateMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.clearPlateButton`),isLoading:Ne,onConfirm:()=>Re(`clearPlate`),onCancel:()=>Me(null)}),Array.from(z.values()).map((e,t)=>(0,K.jsx)(hle,{printerId:e.id,printerName:e.name,viewerIndex:t,onClose:()=>B(t=>{let n=new Map(t);return n.delete(e.id),n})},e.id))]})}function Kke({title:e,message:t,subtitle:n,closeText:r,variant:i=`error`,onClose:a}){let{t:o}=W(),s=r??o(`common.close`);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-[120]`,onClick:a,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-dark ${i===`warning`?`text-yellow-400`:`text-red-400`}`,children:(0,K.jsx)(Cu,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:e}),n&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2 truncate`,children:n}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm whitespace-pre-line break-words`,children:t})]})]}),(0,K.jsx)(`div`,{className:`flex mt-6`,children:(0,K.jsx)($,{onClick:a,className:`flex-1`,children:s})})]})})})}var AW=(0,y.createContext)(null),qke=1500,Jke=1e3,jW=e=>`slice-job-${e}`;function MW(e){try{return decodeURIComponent(e)}catch{return e}}function Yke(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function Xke({children:e}){let{t}=W(),{showToast:n,showPersistentToast:r,dismissToast:i}=Td(),a=no(),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(null),u=(0,y.useRef)([]);u.current=o;let d=(0,y.useRef)(new Map),f=(0,y.useRef)(new Map),p=(0,y.useRef)(new Map),m=(0,y.useCallback)(e=>{let n=d.current.get(e.id);if(n==null)return;let i=(Date.now()-n)/1e3,a=f.current.get(e.id)??`pending`,o=Yke(i),s=p.current.get(e.id)??null,c=s&&s.stage&&s.total_percent>0;if(a===`running`&&c){let n=MW(e.sourceName),i=s.stage,a=Math.min(100,Math.max(0,Math.round(s.total_percent))),c=typeof s.multi_plate_index==`number`&&typeof s.multi_plate_count==`number`&&s.multi_plate_count>1?t(`slice.runningWithProgressMultiPlate`,`Plate {{plateIndex}} of {{plateCount}} • {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{plateIndex:s.multi_plate_index,plateCount:s.multi_plate_count,name:n,stage:i,percent:a,elapsed:o}):t(`slice.runningWithProgress`,`{{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:n,stage:i,percent:a,elapsed:o});r(jW(e.id),c,`loading`);return}let l=a===`pending`?`slice.queuedToast`:`slice.runningToast`,u=a===`pending`?`Queued: {{name}} — {{elapsed}}`:`Slicing {{name}} — {{elapsed}}`;r(jW(e.id),t(l,u,{name:MW(e.sourceName),elapsed:o}),`loading`)},[r,t]),h=(0,y.useCallback)((e,t,n)=>{s(r=>r.some(t=>t.id===e)?r:[...r,{id:e,kind:t,sourceName:n}]),d.current.set(e,Date.now()),f.current.set(e,`pending`),p.current.set(e,null),m({id:e,kind:t,sourceName:n})},[m]),g=(0,y.useCallback)((e,r)=>{s(t=>t.filter(t=>t.id!==e.id)),d.current.delete(e.id),f.current.delete(e.id),p.current.delete(e.id),i(jW(e.id)),r.status===`completed`?n(t(`slice.completedToast`,`Sliced {{name}}`,{name:MW(e.sourceName)}),`success`):r.status===`failed`&&l({name:MW(e.sourceName),detail:r.error_detail||t(`slice.failed`)}),a.invalidateQueries({queryKey:[`library-files`]}),a.invalidateQueries({queryKey:[`archives`]})},[i,a,n,t]);return(0,y.useEffect)(()=>{if(o.length===0)return;let e=!1,t=setInterval(async()=>{if(e)return;let t=[...u.current];for(let e of t)try{let t=await Q.getSliceJob(e.id);f.current.set(e.id,t.status),t.progress&&p.current.set(e.id,t.progress),(t.status===`completed`||t.status===`failed`)&&g(e,t)}catch{}},qke);return()=>{e=!0,clearInterval(t)}},[o.length,g]),(0,y.useEffect)(()=>{if(o.length===0)return;let e=setInterval(()=>{for(let e of u.current)m(e)},Jke);return()=>clearInterval(e)},[o.length,m]),(0,K.jsxs)(AW.Provider,{value:{trackJob:h,activeJobs:o},children:[e,c&&(0,K.jsx)(Kke,{title:t(`slice.failedTitle`),subtitle:c.name,message:c.detail,onClose:()=>l(null)})]})}function Zke(){let e=(0,y.useContext)(AW);if(!e)throw Error(`useSliceJobTracker must be used inside SliceJobTrackerProvider`);return e}function NW({plates:e,onSelect:t,onClose:n}){let{t:r}=W();return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:r(`archives.platePicker.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`archives.platePicker.hint`)})]}),(0,K.jsx)(`button`,{onClick:n,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors`,"aria-label":r(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.index),className:`flex items-center gap-2 p-2 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray transition-colors text-left`,children:[e.has_thumbnail&&e.thumbnail_url!=null?(0,K.jsx)(`img`,{src:Xu(e.thumbnail_url),alt:`Plate ${e.index}`,className:`w-12 h-12 rounded object-cover bg-bambu-dark-tertiary flex-shrink-0`}):(0,K.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center flex-shrink-0`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:e.name?`${r(`archives.platePicker.plateLabel`,{index:e.index})} — ${e.name}`:r(`archives.platePicker.plateLabel`,{index:e.index})}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[e.objects.length>0?e.objects.slice(0,3).join(`, `)+(e.objects.length>3?`…`:``):e.object_count!=null&&e.object_count>0?r(`archives.platePicker.objectCount`,{count:e.object_count}):`${e.filaments.length} filament${e.filaments.length===1?``:`s`}`,e.print_time_seconds==null?``:` • ${Cf(e.print_time_seconds)}`]})]})]},e.index))})})]})})}var PW=[`local`,`orca_cloud`,`cloud`,`standard`];function FW(e,t){for(let n of PW){let r=e[n][t];if(r.length>0)return{source:r[0].source,id:r[0].id}}return null}function IW(e,t,n){return t?e[t.source][n].find(e=>e.id===t.id)??null:null}function LW(e,t,n){if(!n)return null;for(let r of PW){let i=e[r][t].find(e=>e.name===n);if(i)return{source:i.source,id:i.id}}return null}function Qke(e,t,n,r){let i=LW(e,`process`,r);if(i){let r=IW(e,i,`process`);if(r&&xU(r,`process`,t,n)!==`mismatch`)return i}for(let r of[`match`,`unknown`])for(let i of PW)for(let a of e[i].process)if(xU(a,`process`,t,n)===r)return{source:a.source,id:a.id};return FW(e,`process`)}var $ke={local:1.75,orca_cloud:1.5,cloud:1,standard:.5};function eAe(e,t,n,r){let i=t.type.trim().toUpperCase(),a=kf(t.color),o=null;for(let s of PW)for(let c of e[s].filament){let e=0,l=(c.filament_type??``).trim().toUpperCase(),u=kf(c.filament_colour??``);i&&l&&i===l&&(e+=10),a&&u&&(u===a?e+=5:Ff(c.filament_colour??``,t.color)&&(e+=2)),e+=$ke[s],xU(c,`filament`,n,r)===`mismatch`&&(e-=100),(o==null||e>o.score)&&(o={ref:{source:c.source,id:c.id},score:e})}return o==null?FW(e,`filament`):o.ref}function tAe(e){return e?`${e.source}:${e.id}`:``}function nAe(e){if(!e)return null;let t=e.indexOf(`:`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1);return n!==`orca_cloud`&&n!==`cloud`&&n!==`local`&&n!==`standard`?null:{source:n,id:r}}function rAe({requestId:e,sourceName:t}){let{t:n}=W(),{showPersistentToast:r,dismissToast:i}=Td(),[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(null),l=t;try{l=decodeURIComponent(t)}catch{}(0,y.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>o(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[]),(0,y.useEffect)(()=>{let t=!1,n=setInterval(async()=>{if(t)return;let n=await Q.getPreviewSliceProgress(e);!t&&n&&c(n)},1e3);return()=>{t=!0,clearInterval(n)}},[e]);let u=`slice-preview-${e}`;(0,y.useEffect)(()=>{let e=s&&s.stage&&s.total_percent>0,t=iAe(a);return e?r(u,n(`slice.previewWithProgress`,`Analyzing {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:l,stage:s.stage,percent:Math.min(100,Math.max(0,Math.round(s.total_percent))),elapsed:t}),`loading`):r(u,n(`slice.previewToast`,{name:l,elapsed:t}),`loading`),()=>{i(u)}},[a,s,l,r,i,n,u]);let d=s?.stage,f=s?.total_percent,p=d&&typeof f==`number`&&f>0?`${d} (${Math.min(100,Math.max(0,Math.round(f)))}%)`:n(`slice.analyzingPlateFilaments`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 text-bambu-gray text-sm py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),p,(0,K.jsxs)(`span`,{className:`text-xs tabular-nums`,children:[a,`s`]})]}),a>=5&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/70 pl-6`,children:n(`slice.analyzingPlateFilamentsHint`,`Running a preview slice to discover which AMS slots this plate uses. Cached after — re-opening is instant.`)})]})}function iAe(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function RW({source:e,onClose:t}){let{t:n}=W(),{trackJob:r}=Zke(),i=no(),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),b=q({queryKey:[`slicePlates`,e.kind,e.id],queryFn:async()=>e.kind===`libraryFile`?Q.getLibraryFilePlates(e.id):Q.getArchivePlates(e.id),staleTime:6e4}),x=!!b.data?.is_multi_plate&&(b.data?.plates?.length??0)>1,S=x&&p==null,C=p??1,w=(0,y.useMemo)(()=>{let t=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`;return`${e.kind}-${e.id}-p${C}-${t}`},[e.kind,e.id,C]),T=q({queryKey:[`sliceFilamentReqs`,e.kind,e.id,C],queryFn:async()=>e.kind===`libraryFile`?Q.getLibraryFileFilamentRequirements(e.id,C,w):Q.getArchiveFilamentRequirements(e.id,C,w),enabled:!S,staleTime:6e4}),E=(0,y.useMemo)(()=>{let e=T.data?.filaments??[],t=e.length>0?e:[{slot_id:1,type:``,color:``,used_grams:0,used_meters:0}];return h?t.map(e=>({...e,used_in_plate:!0})):t},[h,T.data]),D=q({queryKey:[`slicerPresets`],queryFn:()=>Q.getSlicerPresets(),staleTime:6e4,enabled:!b.isLoading&&!S}),[O,k]=(0,y.useState)(!1),A=async()=>{if(!O){k(!0);try{let e=await Q.getSlicerPresets({refresh:!0});i.setQueryData([`slicerPresets`],e)}catch{i.invalidateQueries({queryKey:[`slicerPresets`]})}finally{k(!1)}}},j=q({queryKey:[`slicerPrinterModels`],queryFn:Q.getSlicerPrinterModels,staleTime:1/0}),M=(0,y.useMemo)(()=>!D.data||!a?null:IW(D.data,a,`printer`)?.name??null,[D.data,a]),N=(0,y.useMemo)(()=>vU(j.data??{}),[j.data]),P=b.data?.embedded_printer??null,F=b.data?.embedded_process??null;(0,y.useEffect)(()=>{let e=D.data;e&&(a??o(LW(e,`printer`,P)??FW(e,`printer`)))},[D.data,P]),(0,y.useEffect)(()=>{let e=D.data;e&&c(t=>{if(t){let n=IW(e,t,`process`);if(n&&xU(n,`process`,M,N)!==`mismatch`)return t}return Qke(e,M,N,F)})},[D.data,M,N,F]),(0,y.useEffect)(()=>{let e=D.data;e&&u(t=>E.map((n,r)=>{let i=t[r]??null;if(i){let t=IW(e,i,`filament`);if(t&&xU(t,`filament`,M,N)!==`mismatch`)return i}return eAe(e,{type:n.type,color:n.color},M,N)}))},[D.data,E,M,N]);let I=J({mutationFn:async t=>{let n=L(t);return e.kind===`libraryFile`?Q.sliceLibraryFile(e.id,n):Q.sliceArchive(e.id,n)},onSuccess:n=>{r(n.job_id,e.kind,e.filename),t()},onError:e=>{f(e instanceof Error?e.message:String(e))}});function L(e){if(!a||!s||l.length===0||l.some(e=>e==null))throw Error(n(`slice.allPresetsRequired`));return{printer_preset:a,process_preset:s,filament_preset:l[0],filament_presets:l,...e==null?{}:{plate:e},..._==null?{}:{bed_type:_}}}let R=a!=null&&s!=null&&T.isSuccess&&l.length>0&&l.every(e=>e!=null),z=I.isPending,B=b.data?.plates?.length??0,V=x&&B>1&&!S;return S&&b.data?(0,K.jsx)(NW,{plates:b.data.plates,onSelect:e=>m(e),onClose:t}):(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:()=>{z||t()},children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`h3`,{className:`text-white font-medium flex items-center gap-2`,children:[(0,K.jsx)(ks,{className:`w-4 h-4`}),n(`slice.title`)]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate`,title:e.filename,children:[e.filename,p==null?``:` • ${n(`archives.platePicker.plateLabel`,{index:p})}`]})]}),(0,K.jsx)(`button`,{onClick:t,disabled:z,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors disabled:opacity-50`,"aria-label":n(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(b.isLoading||D.isLoading)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`slice.loadingPresets`)]}),D.isError&&(0,K.jsx)(`div`,{className:`text-sm text-red-400`,role:`alert`,children:n(`slice.presetsLoadFailed`,`Failed to load presets. Open Settings → Profiles to import them, or sign in to Bambu Cloud.`)}),D.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,K.jsx)(zW,{status:D.data.cloud_status,cloudName:`bambu`}),(0,K.jsx)(zW,{status:D.data.orca_cloud_status,cloudName:`orca`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:A,disabled:O||z,className:`flex-shrink-0 inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:n(`slice.refreshPresetsTitle`),"aria-label":n(`slice.refreshPresets`),children:[(0,K.jsx)(Ol,{className:`w-3.5 h-3.5 ${O?`animate-spin`:``}`}),n(`slice.refreshPresets`)]})]}),(0,K.jsx)(BW,{label:n(`slice.printer`),slot:`printer`,data:D.data,value:a,onChange:o,disabled:z}),(0,K.jsx)(BW,{label:n(`slice.process`),slot:`process`,data:D.data,value:s,onChange:c,disabled:z,selectedPrinterName:M,compatIndex:N}),(0,K.jsx)(oAe,{value:_,onChange:v,disabled:z}),T.isLoading?(0,K.jsx)(rAe,{requestId:w,sourceName:e.filename}):E.map((e,t)=>{let r=e.used_in_plate!==!1,i=E.length>1?n(`slice.filamentSlot`,{index:t+1,type:e.type}):n(`slice.filament`);return(0,K.jsx)(BW,{label:r?i:`${i} ${n(`slice.notUsedByPlate`)}`,slot:`filament`,data:D.data,value:l[t]??null,onChange:e=>u(n=>{let r=n.length===E.length?[...n]:E.map((e,t)=>n[t]??null);return r[t]=e,r}),disabled:z||!r,swatchColor:E.length>1?e.color:void 0,selectedPrinterName:M,compatIndex:N},`filament-${t}`)})]}),d&&(0,K.jsx)(`div`,{className:`text-sm text-red-400 bg-red-900/20 border border-red-900/40 rounded p-2`,role:`alert`,children:d})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex justify-end gap-2 px-4 py-3 border-t border-bambu-dark-tertiary/40`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:t,disabled:z,className:`px-3 py-1.5 text-sm rounded-md border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray transition-colors disabled:opacity-50`,children:n(`common.cancel`)}),V&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mr-auto text-sm text-bambu-gray cursor-pointer select-none`,title:n(`slice.actionAllTitle`,{count:B}),children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:z,className:`cursor-pointer`}),n(`slice.allPlatesToggle`,{count:B})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{f(null);let e=h?0:p;I.mutate(e)},disabled:!R||z,className:`px-3 py-1.5 text-sm rounded-md bg-bambu-green hover:bg-bambu-green/90 text-bambu-dark font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2`,children:z?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`slice.enqueuing`)]}):h?n(`slice.actionAll`,{count:B}):n(`slice.action`)})]})]})})}function zW({status:e,cloudName:t=`bambu`}){let{t:n}=W();if(e===`ok`||e===`not_authenticated`)return null;let r=t===`orca`?{expired:{key:`slice.orcaCloud.expired`,fallback:`Orca Cloud session expired — sign in again to refresh your Orca presets.`},unreachable:{key:`slice.orcaCloud.unreachable`,fallback:`Orca Cloud is unreachable right now. Other presets still work.`}}:{expired:{key:`slice.cloud.expired`,fallback:`Bambu Cloud session expired — sign in again to refresh your cloud presets.`},unreachable:{key:`slice.cloud.unreachable`,fallback:`Bambu Cloud is unreachable right now. Local and standard presets still work.`}},{tone:i,icon:a}={expired:{tone:`border-amber-700/40 bg-amber-900/20 text-amber-200`,icon:Cs},unreachable:{tone:`border-bambu-dark-tertiary/40 bg-bambu-dark text-bambu-gray`,icon:Cs}}[e],{key:o,fallback:s}=r[e];return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs rounded-md border p-2 ${i}`,role:`status`,children:[(0,K.jsx)(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:n(o,s)})]})}var aAe=[{value:`Cool Plate`,labelKey:`slice.bedType.coolPlate`,fallback:`Cool Plate`},{value:`Cool Plate (SuperTack)`,labelKey:`slice.bedType.coolPlateSuperTack`,fallback:`Cool Plate SuperTack`},{value:`Engineering Plate`,labelKey:`slice.bedType.engineering`,fallback:`Engineering Plate`},{value:`High Temp Plate`,labelKey:`slice.bedType.highTemp`,fallback:`High Temp Plate`},{value:`Textured PEI Plate`,labelKey:`slice.bedType.texturedPEI`,fallback:`Textured PEI Plate`},{value:`Smooth PEI Plate`,labelKey:`slice.bedType.smoothPEI`,fallback:`Smooth PEI Plate`}];function oAe({value:e,onChange:t,disabled:n}){let{t:r}=W();return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`block text-xs text-bambu-gray mb-1`,children:r(`slice.bedType.label`)}),(0,K.jsxs)(`select`,{value:e??``,onChange:e=>t(e.target.value===``?null:e.target.value),disabled:n,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,K.jsx)(`option`,{value:``,children:r(`slice.bedType.auto`)}),aAe.map(e=>(0,K.jsx)(`option`,{value:e.value,children:r(e.labelKey,e.fallback)},e.value))]})]})}function BW({label:e,slot:t,data:n,value:r,onChange:i,disabled:a,swatchColor:o,selectedPrinterName:s,compatIndex:c}){let{t:l}=W(),{sections:u,otherEntries:d}=(0,y.useMemo)(()=>{let e=[{key:`local`,label:`slice.tier.local`,fallback:`Imported`},{key:`orca_cloud`,label:`slice.tier.orcaCloud`,fallback:`Orca Cloud`},{key:`cloud`,label:`slice.tier.cloud`,fallback:`Bambu Cloud`},{key:`standard`,label:`slice.tier.standard`,fallback:`Standard`}],r=t!==`printer`,i=[],a=[];for(let{key:o,label:u,fallback:d}of e){let e=n[o][t];if(!r){e.length>0&&i.push({tierLabel:l(u,d),entries:e});continue}let f=[];for(let n of e)xU(n,t,s??null,c??GOe)===`mismatch`?a.push(n):f.push(n);f.length>0&&i.push({tierLabel:l(u,d),entries:f})}return{sections:i,otherEntries:a}},[n,t,l,s,c]),f=u.reduce((e,t)=>e+t.entries.length,0)+d.length;return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-bambu-gray mb-1`,children:[o&&(0,K.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border border-bambu-dark-tertiary`,style:{backgroundColor:o||`transparent`},"aria-hidden":!0}),(0,K.jsx)(`span`,{children:e})]}),(0,K.jsxs)(`select`,{value:tAe(r),onChange:e=>i(nAe(e.target.value)),disabled:a||f===0,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,K.jsx)(`option`,{value:``,children:l(f===0?`slice.noPresetsForSlot`:`slice.selectPreset`)}),u.map(e=>(0,K.jsx)(`optgroup`,{label:e.tierLabel,children:e.entries.map(e=>(0,K.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))},e.tierLabel)),d.length>0&&(0,K.jsx)(`optgroup`,{label:l(`slice.otherPrinters`),children:d.map(e=>(0,K.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))})]})]})}function sAe(){let e=navigator.userAgent.toLowerCase(),t=navigator.platform?.toLowerCase()||``;return e.includes(`win`)||t.includes(`win`)?`windows`:e.includes(`mac`)||t.includes(`mac`)?`macos`:e.includes(`linux`)||t.includes(`linux`)?`linux`:`unknown`}function VW(e,t=`bambu_studio`){let n,r=encodeURIComponent(e);n=t===`orcaslicer`?`orcaslicer://open?file=${r}`:sAe()===`macos`?`bambustudioopen://${r}`:`bambustudio://open?file=${r}`;let i=document.createElement(`a`);i.href=n,i.style.display=`none`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}var HW=768;function UW(){let[e,t]=(0,y.useState)(()=>typeof window<`u`?window.innerWidth{let e=window.matchMedia(`(max-width: ${HW-1}px)`),n=e=>{t(e.matches)};return t(e.matches),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function WW({onFiles:e,onRejected:t,extensions:n,disabled:r=!1}){let[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(e),s=(0,y.useRef)(t),c=(0,y.useRef)(n);(0,y.useEffect)(()=>{o.current=e},[e]),(0,y.useEffect)(()=>{s.current=t},[t]),(0,y.useEffect)(()=>{c.current=n},[n]);let l=(0,y.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),u=(0,y.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),d=(0,y.useCallback)(e=>{if(r)return;e.preventDefault();let t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&a(!1)},[r]),f=(0,y.useCallback)(e=>{if(r)return;e.preventDefault(),a(!1);let t=Array.from(e.dataTransfer.files);if(t.length===0)return;let n=c.current,i=n&&n.length>0?t.filter(e=>n.some(t=>e.name.toLowerCase().endsWith(t))):t;i.length>0?o.current(i):s.current?.()},[r]);return(0,y.useEffect)(()=>{if(!i)return;let e=()=>a(!1),t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`drop`,e),document.addEventListener(`dragend`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`drop`,e),document.removeEventListener(`dragend`,e),document.removeEventListener(`keydown`,t)}},[i]),{isDraggingOver:i,dragHandlers:{onDragOver:l,onDragEnter:u,onDragLeave:d,onDrop:f}}}function cAe({onClose:e,initialFiles:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(()=>t?.filter(e=>e.name.endsWith(`.3mf`)).map(e=>({file:e,status:`pending`}))||[]),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let f=J({mutationFn:e=>Q.uploadArchivesBulk(e),onSuccess:e=>{d(e),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archiveStats`]}),s(t=>t.map(t=>{let n=e.results.find(e=>e.filename===t.file.name),r=e.errors.find(e=>e.filename===t.file.name);return n?{...t,status:`success`,archiveId:n.id}:r?{...t,status:`error`,error:r.error}:t})),e.failed===0?i(`${e.uploaded} file${e.uploaded===1?``:`s`} uploaded`):e.uploaded===0?i(`Failed to upload ${e.failed} file${e.failed===1?``:`s`}`,`error`):i(`${e.uploaded} uploaded, ${e.failed} failed`,`warning`)},onError:()=>{s(e=>e.map(e=>({...e,status:`error`,error:`Upload failed`}))),i(`Upload failed`,`error`)}}),p=(0,y.useCallback)(e=>{e.preventDefault(),l(!0)},[]),m=(0,y.useCallback)(e=>{e.preventDefault(),l(!1)},[]),h=(0,y.useCallback)(e=>{e.preventDefault(),l(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))])},[]),g=(0,y.useCallback)(e=>{let t=Array.from(e.target.files||[]).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))]),a.current&&(a.current.value=``)},[]),_=(0,y.useCallback)(e=>{s(t=>t.filter((t,n)=>n!==e))},[]),v=()=>{if(o.length===0)return;let e=o.filter(e=>e.status===`pending`);e.length!==0&&(s(e=>e.map(e=>e.status===`pending`?{...e,status:`uploading`}:e)),f.mutate(e.map(e=>e.file)))},b=o.filter(e=>e.status===`pending`).length,x=f.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[90vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:n(`uploadModal.title`)}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[(0,K.jsx)(Du,{className:`w-12 h-12 mx-auto mb-4 text-bambu-gray`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:n(`uploadModal.dragDrop`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mb-4`,children:n(`uploadModal.or`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>a.current?.click(),disabled:x,children:n(`uploadModal.browseFiles`)}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`.3mf`,multiple:!0,className:`hidden`,onChange:g})]})}),(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`uploadModal.extractionInfo`)})}),o.length>0&&(0,K.jsx)(`div`,{className:`px-4 pb-4 max-h-60 overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`space-y-2`,children:o.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(rc,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1 text-white text-sm truncate`,children:e.file.name}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[(e.file.size/(1024*1024)).toFixed(1),` MB`]}),e.status===`pending`&&(0,K.jsx)(`button`,{onClick:()=>_(t),className:`text-bambu-gray hover:text-red-400 transition-colors`,disabled:x,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})}),e.status===`uploading`&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`}),e.status===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green`}),e.status===`error`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-red-400`,children:e.error}),(0,K.jsx)(ds,{className:`w-4 h-4 text-red-400`})]})]},`${e.file.name}-${t}`))})}),u&&(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsx)(`span`,{className:`text-bambu-green`,children:u.uploaded}),` `,n(`uploadModal.uploaded`),u.failed>0&&(0,K.jsxs)(K.Fragment,{children:[`, `,(0,K.jsx)(`span`,{className:`text-red-400`,children:u.failed}),` `,n(`uploadModal.failed`)]})]})})}),(0,K.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:n(u?`common.close`:`common.cancel`)}),!u&&(0,K.jsx)($,{onClick:v,disabled:b===0||x,className:`flex-1`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`uploadModal.uploading`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`uploadModal.upload`),` `,b>0&&`(${b})`]})})]})]})})})}var lAe=365;function uAe({onClose:e,initialDays:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(t??lAe),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(a);(0,y.useEffect)(()=>{let e=window.setTimeout(()=>u(a),300);return()=>window.clearTimeout(e)},[a]);let d=q({queryKey:[`archive-purge-preview`,l,s],queryFn:()=>Q.previewArchivePurge(l,s),enabled:l>=1}),f=J({mutationFn:()=>Q.executeArchivePurge(a,s),onSuccess:t=>{i(n(`archivePurge.toast.success`,{count:t.deleted}),`success`),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archive-stats`]}),e()},onError:e=>i(e.message||n(`archivePurge.toast.failed`),`error`)});(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!f.isPending&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,f.isPending]);let p=d.data,m=p?.count??0,h=p?.total_bytes??0,g=m>0&&!f.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-lg w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),n(`archivePurge.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`,"aria-label":n(`common.close`),disabled:f.isPending,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.description`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`archive-purge-days`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`archivePurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{id:`archive-purge-days`,type:`number`,min:1,max:3650,value:a,onChange:e=>o(Math.max(1,Math.min(3650,parseInt(e.target.value||`0`,10)||0))),className:`w-24 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.days`)})]})]}),(0,K.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/30 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-2`,children:n(`archivePurge.effectsTitle`)}),(0,K.jsxs)(`ul`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1 list-disc pl-4`,children:[(0,K.jsx)(`li`,{children:n(`archivePurge.effect1`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect2`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect3`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect4`)})]})]}),(0,K.jsx)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 p-3`,children:d.isLoading||d.isFetching?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,n(`archivePurge.previewLoading`)]}):d.isError?(0,K.jsx)(`div`,{className:`text-sm text-red-600 dark:text-red-400`,children:d.error?.message??n(`archivePurge.previewFailed`)}):(0,K.jsxs)(`div`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:n(`archivePurge.previewSummary`,{count:m,size:Cd(h)})}),p?.sample_filenames&&p.sample_filenames.length>0&&(0,K.jsxs)(`ul`,{className:`mt-2 text-xs text-gray-600 dark:text-gray-400 space-y-0.5 list-disc pl-4`,children:[p.sample_filenames.map(e=>(0,K.jsx)(`li`,{className:`truncate`,children:e},e)),m>p.sample_filenames.length&&(0,K.jsx)(`li`,{className:`list-none italic text-gray-500`,children:n(`archivePurge.andMore`,{count:m-p.sample_filenames.length})})]})]})}),(0,K.jsxs)(`label`,{className:`flex gap-2 items-start rounded border border-gray-200 dark:border-gray-700 px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:f.isPending,className:`mt-0.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[(0,K.jsx)(`span`,{className:`font-medium block mb-0.5`,children:n(`archivePurge.purgeStatsLabel`)}),(0,K.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:n(`archivePurge.purgeStatsHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-start text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-3 py-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`archivePurge.warning`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:f.isPending,children:n(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,disabled:!g,onClick:()=>f.mutate(),children:f.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}),n(`archivePurge.purging`)]}):n(`archivePurge.confirmCta`,{count:m})})]})]})})}function dAe(e){if(!e||e<=0)return`—`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`}function fAe(e){if(!e)return`—`;let t=vf(e);return t?t.toLocaleString():`—`}function GW({archiveId:e}){let{t}=W(),{data:n,isLoading:r}=q({queryKey:[`archive-runs`,e],queryFn:()=>Q.getArchiveRuns(e)});if(r)return(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-gray animate-spin`})});let i=n?.items||[];return i.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:t(`archives.runLog.empty`)}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.date`)}),(0,K.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.status`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.duration`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.filament`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 font-medium`,children:t(`archives.runLog.col.cost`)})]})}),(0,K.jsx)(`tbody`,{children:i.map(e=>{let n=e.status===`completed`?`text-bambu-green`:e.status===`failed`?`text-red-400`:`text-bambu-gray`;return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/40 last:border-0`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-bambu-gray-light`,children:fAe(e.started_at||e.created_at)}),(0,K.jsxs)(`td`,{className:`py-1.5 pr-2 font-medium ${n}`,children:[t(`archives.runLog.status.${e.status}`,{defaultValue:e.status}),e.failure_reason&&(0,K.jsx)(`span`,{className:`block text-[10px] text-bambu-gray font-normal`,children:t(`editArchive.failureReasons.${e.failure_reason}`,{defaultValue:e.failure_reason})})]}),(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:dAe(e.duration_seconds)}),(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:e.filament_used_grams==null?`—`:`${e.filament_used_grams.toFixed(1)} g`}),(0,K.jsx)(`td`,{className:`py-1.5 text-right text-bambu-gray-light`,children:e.cost==null?`—`:e.cost.toFixed(2)})]},e.id)})})]})})}var KW=[`adhesionFailure`,`spaghettiDetached`,`layerShift`,`cloggedNozzle`,`filamentRunout`,`warping`,`stringing`,`underExtrusion`,`powerFailure`,`userCancelled`,`other`],pAe=[`completed`,`failed`,`aborted`,`printing`];function qW({archive:e,onClose:t,existingTags:n=[]}){let{t:r}=W();(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=no(),[a,o]=(0,y.useState)(e.print_name||``),[s,c]=(0,y.useState)(e.printer_id),[l,u]=(0,y.useState)(e.project_id??null),[d,f]=(0,y.useState)(e.notes||``),[p,m]=(0,y.useState)(e.tags||``),[h,g]=(0,y.useState)(()=>{let t=e.failure_reason||``;return t?KW.includes(t)?t:KW.find(e=>r(`editArchive.failureReasons.${e}`)===t)||``:``}),[_,v]=(0,y.useState)(e.status),[b,x]=(0,y.useState)(e.quantity??1),[S,C]=(0,y.useState)(e.photos||[]),[w,T]=(0,y.useState)(e.external_url||``),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),A=(0,y.useRef)(null),j=(0,y.useRef)(null),M=(0,y.useRef)(null),{data:N}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:P}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),{data:F}=q({queryKey:[`tags`],queryFn:Q.getTags,enabled:n.length===0}),I=n.length>0?n:F?.map(e=>e.name)||[],L=p.split(`,`).map(e=>e.trim()).filter(Boolean),R=p.includes(`,`)?p.substring(p.lastIndexOf(`,`)+1).trim().toLowerCase():p.trim().toLowerCase(),z=I.filter(e=>!L.includes(e)&&(R===``||e.toLowerCase().includes(R))),B=e=>{let t;t=R&&!I.includes(R)?p.includes(`,`)?p.substring(0,p.lastIndexOf(`,`)).split(`,`).map(e=>e.trim()).filter(Boolean):[]:L,t.includes(e)||m([...t,e].join(`, `)),M.current!==null&&clearTimeout(M.current),A.current?.focus()},V=e=>{m(L.filter(t=>t!==e).join(`, `))},ee=J({mutationFn:t=>Q.updateArchive(e.id,t),onSuccess:()=>{i.invalidateQueries({queryKey:[`archives`]}),i.invalidateQueries({queryKey:[`projects`]}),t()}}),te=async t=>{let n=t.target.files?.[0];if(n){D(!0);try{C((await Q.uploadArchivePhoto(e.id,n)).photos),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to upload photo:`,e)}finally{D(!1),j.current&&(j.current.value=``)}}},ne=async t=>{try{C((await Q.deleteArchivePhoto(e.id,t)).photos||[]),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to delete photo:`,e)}};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`editArchive.title`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n={print_name:a||void 0,printer_id:s,project_id:l,notes:d||void 0,tags:p||void 0,quantity:b,external_url:w||null};_!==e.status&&(n.status=_),_===`failed`||_===`aborted`?n.failure_reason=h||void 0:(e.status===`failed`||e.status===`aborted`)&&(n.failure_reason=null),ee.mutate(n)},className:`p-6 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`archives.runLog.title`)}),(0,K.jsx)(GW,{archiveId:e.id})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.name`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:r(`editArchive.namePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.printer`)}),(0,K.jsxs)(`select`,{value:s??``,onChange:e=>c(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.noPrinter`)}),N?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(sc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.project`)]}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.noProject`)}),P?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Tc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.itemsPrinted`)]}),(0,K.jsx)(`input`,{type:`number`,min:1,value:b,onChange:e=>x(Math.max(1,parseInt(e.target.value)||1)),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.itemsPrintedHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.notes`)}),(0,K.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none`,placeholder:r(`editArchive.notesPlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Hc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.externalLink`)]}),(0,K.jsx)(`input`,{type:`url`,value:w,onChange:e=>T(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`https://printables.com/model/...`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.externalLinkHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.tags`)}),L.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:L.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white`,children:[(0,K.jsx)(fu,{className:`w-3 h-3`}),e,(0,K.jsx)(`button`,{type:`button`,onClick:()=>V(e),className:`ml-0.5 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{ref:A,type:`text`,value:p,onChange:e=>m(e.target.value),onFocus:()=>{M.current!==null&&clearTimeout(M.current),k(!0)},onBlur:()=>{M.current=window.setTimeout(()=>k(!1),200)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:L.length>0?r(`editArchive.addMoreTags`):r(`editArchive.tagsPlaceholder`)}),O&&z.length>0&&(0,K.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary`,children:[R?r(`editArchive.matchingTags`,{query:R}):r(`editArchive.existingTags`),` `,r(`editArchive.clickToAdd`)]}),(0,K.jsx)(`div`,{className:`p-2 flex flex-wrap gap-1.5`,children:z.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>B(e),className:`px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors`,children:e},e))})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.status`)}),(0,K.jsx)(`select`,{value:_,onChange:e=>{v(e.target.value),e.target.value===`completed`&&g(``)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:pAe.map(e=>(0,K.jsx)(`option`,{value:e,children:r(`editArchive.statuses.${e}`)},e))})]}),(_===`failed`||_===`aborted`)&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`failure-reason-select`,className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.failureReason`)}),(0,K.jsxs)(`select`,{id:`failure-reason-select`,value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.selectReason`)}),KW.map(e=>(0,K.jsx)(`option`,{value:e,children:r(`editArchive.failureReasons.${e}`)},e))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Qo,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.photos`)]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:[S.map(t=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`img`,{src:Q.getArchivePhotoUrl(e.id,t),alt:r(`editArchive.printResult`),className:`w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>ne(t),className:`absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(bu,{className:`w-3 h-3 text-white`})})]},t)),(0,K.jsxs)(`label`,{className:`w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors`,children:[(0,K.jsx)(`input`,{ref:j,type:`file`,accept:`image/jpeg,image/png,image/webp`,onChange:te,className:`hidden`,disabled:E}),E?(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-gray animate-spin`}):(0,K.jsx)(Sl,{className:`w-6 h-6 text-bambu-gray`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`editArchive.photosHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:ee.isPending,className:`flex-1`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),ee.isPending?r(`common.saving`):r(`common.save`)]})]})]})]})})}function JW({archiveId:e,archiveName:t,onClose:n}){let{t:r}=W();return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-2xl max-h-[85vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,title:t||``,children:r(`archives.runLog.modalTitle`,{name:t||r(`archives.runLog.modalTitleFallback`)})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`p-6 overflow-y-auto flex-1`,children:(0,K.jsx)(GW,{archiveId:e})})]})})}function mAe({items:e,searchPlaceholder:t,onClose:n,className:r,onMouseEnter:i,onMouseLeave:a}){let[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(t){let e=window.setTimeout(()=>c.current?.focus(),0);return()=>window.clearTimeout(e)}},[t]);let l=o.trim().toLowerCase(),u=t&&l?e.filter(e=>e.label.toLowerCase().includes(l)):e;return(0,K.jsxs)(`div`,{className:r,onMouseEnter:i,onMouseLeave:a,children:[t&&(0,K.jsx)(`div`,{className:`sticky top-0 z-[1] px-2 py-1.5 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{ref:c,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){let e=u.find(e=>!e.disabled);e&&(e.onClick(),n())}},placeholder:t,className:`w-full pl-7 pr-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})}),u.map((e,t)=>(0,K.jsxs)(`button`,{onClick:()=>{e.disabled||(e.onClick(),n())},disabled:e.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e.icon&&(0,K.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.label})]},t)),t&&u.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray text-center italic`,children:`—`})]})}function YW({x:e,y:t,items:n,onClose:r}){let i=(0,y.useRef)(null),[a,o]=(0,y.useState)(null),s=(0,y.useRef)(null),[c,l]=(0,y.useState)({x:e,y:t,visible:!1}),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)({});(0,y.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()},n=e=>{i.current&&i.current.contains(e.target)||r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),document.addEventListener(`scroll`,n,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),document.removeEventListener(`scroll`,n,!0),s.current&&clearTimeout(s.current)}},[r]),(0,y.useLayoutEffect)(()=>{if(i.current){i.current.style.visibility=`hidden`,i.current.style.display=`block`;let n=i.current.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,o=e,s=t;e+n.width>r-8&&(o=Math.max(8,r-n.width-8)),o<8&&(o=8),t+n.height>a-8&&(s=Math.max(8,a-n.height-8)),s<8&&(s=8),d(r-o-n.width<180&&o>180),l({x:o,y:s,visible:!0})}},[e,t]);let m=(e,t)=>{s.current&&=(clearTimeout(s.current),null);let n=t.getBoundingClientRect(),r=window.innerHeight-n.top-8<300&&n.top>300;p(t=>({...t,[e]:r?`bottom`:`top`})),o(e)},h=()=>{s.current=window.setTimeout(()=>{o(null)},150)};return(0,K.jsx)(`div`,{ref:i,className:`fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1`,style:{left:c.x,top:c.y,visibility:c.visible?`visible`:`hidden`},children:n.map((e,t)=>{if(e.divider)return(0,K.jsx)(`div`,{className:`my-1 border-t border-bambu-dark-tertiary`},t);let n=e.submenu&&e.submenu.length>0;return(0,K.jsxs)(`div`,{className:`relative`,onMouseEnter:e=>n&&m(t,e.currentTarget),onMouseLeave:()=>n&&h(),children:[(0,K.jsxs)(`button`,{onMouseEnter:e=>n&&m(t,e.currentTarget.parentElement),onClick:()=>{n?o(a===t?null:t):e.disabled||(e.onClick(),r())},disabled:e.disabled,title:e.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`} ${n&&a===t?`bg-bambu-dark-tertiary`:``}`,children:[e.icon&&(0,K.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1`,children:e.label}),n&&(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`})]}),n&&a===t&&(0,K.jsx)(mAe,{items:e.submenu,searchPlaceholder:e.submenuSearchPlaceholder,onClose:r,className:`absolute min-w-[200px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${u?`right-full mr-1`:`left-full ml-1`} ${f[t]===`bottom`?`bottom-0`:`top-0`}`,onMouseEnter:()=>{s.current&&=(clearTimeout(s.current),null)},onMouseLeave:()=>h()})]},t)})})}function hAe({selectedIds:e,existingTags:t,onClose:n}){let r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(`add`);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let d=J({mutationFn:async()=>{let t=Array.from(s),n=0;for(let r of e)try{let e=await Q.getArchive(r),i=e.tags?e.tags.split(`,`).map(e=>e.trim()).filter(Boolean):[],a;a=l===`add`?[...new Set([...i,...t])]:i.filter(e=>!s.has(e)),await Q.updateArchive(r,{tags:a.join(`, `)}),n++}catch(e){throw console.error(`Failed to update archive ${r}:`,e),Error(`Failed on archive ${r}: ${e instanceof Error?e.message:`Unknown error`}`)}return{count:n,mode:l,tags:t}},onSuccess:({count:e,mode:t,tags:a})=>{r.invalidateQueries({queryKey:[`archives`]}),i(`${t===`add`?`Added`:`Removed`} ${a.length} tag${a.length===1?``:`s`} ${t===`add`?`to`:`from`} ${e} archive${e===1?``:`s`}`),n()},onError:e=>{i(e.message||`Failed to update tags`,`error`)}}),f=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=()=>{a.trim()&&!s.has(a.trim())&&(c(e=>new Set([...e,a.trim()])),o(``))};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,children:(0,K.jsxs)(yd,{className:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:l===`add`?`Add Tags`:`Remove Tags`})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[l===`add`?`Add`:`Remove`,` tags for `,e.length,` selected archive`,e.length===1?``:`s`]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{size:`sm`,variant:l===`add`?`primary`:`secondary`,onClick:()=>u(`add`),children:`Add Tags`}),(0,K.jsx)($,{size:`sm`,variant:l===`remove`?`primary`:`secondary`,onClick:()=>u(`remove`),children:`Remove Tags`})]}),l===`add`&&(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:`Enter new tag...`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())}}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:p,disabled:!a.trim(),children:(0,K.jsx)(Sl,{className:`w-4 h-4`})})]}),t.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:`Existing tags:`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,K.jsx)(`button`,{onClick:()=>f(e),className:`px-2 py-1 rounded text-sm transition-colors ${s.has(e)?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark`}`,children:e},e))})]}),s.size>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:[`Tags to `,l===`add`?`add`:`remove`,`:`]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Array.from(s).map(e=>(0,K.jsxs)(`span`,{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${l===`add`?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`}`,children:[e,(0,K.jsx)(`button`,{onClick:()=>f(e),className:`hover:opacity-70`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:n,className:`flex-1`,children:`Cancel`}),(0,K.jsx)($,{onClick:()=>d.mutate(),disabled:s.size===0||d.isPending,className:`flex-1`,children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),`Processing...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),l===`add`?`Add Tags`:`Remove Tags`]})})]})]})})})}function gAe({selectedIds:e,onClose:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(``),{data:s,isLoading:c}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects()}),l=(0,y.useMemo)(()=>s?[...s].sort((e,t)=>e.name.localeCompare(t.name)):void 0,[s]),u=a.trim().toLowerCase(),d=u?l?.filter(e=>e.name.toLowerCase().includes(u)):l,f=(l?.length??0)>5;(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let p=()=>{r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`projects`]}),r.invalidateQueries({queryKey:[`project`]}),r.invalidateQueries({queryKey:[`project-archives`]})},m=J({mutationFn:async t=>(await Q.addArchivesToProject(t,e),t),onSuccess:n=>{let r=s?.find(e=>e.id===n);p(),i(`Added ${e.length} archive${e.length===1?``:`s`} to "${r?.name}"`),t()},onError:()=>{i(`Failed to assign project`,`error`)}}),h=J({mutationFn:async()=>{for(let t of e)await Q.updateArchive(t,{project_id:null});return e.length},onSuccess:e=>{p(),i(`Removed ${e} archive${e===1?``:`s`} from project`),t()},onError:()=>{i(`Failed to remove from project`,`error`)}}),g=m.isPending||h.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-md max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:`Assign to Project`})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,disabled:g,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-3 overflow-y-auto min-h-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Assign `,e.length,` selected archive`,e.length===1?``:`s`,` to a project`]}),c?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-gray`})}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>h.mutate(),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0`,children:(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:`Remove from project`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray truncate`,children:`Clear project assignment`})]}),h.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]}),l&&l.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`or assign to`}),(0,K.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`})]}),f&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`archives.menu.searchProjects`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray text-sm focus:border-bambu-green focus:outline-none`})]}),d?.map(e=>(0,K.jsxs)(`button`,{onClick:()=>m.mutate(e.id),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0`,style:{backgroundColor:e.color?`${e.color}20`:`rgb(var(--bambu-green) / 0.2)`},children:(0,K.jsx)(sc,{className:`w-4 h-4`,style:{color:e.color||`rgb(var(--bambu-green))`}})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray truncate`,children:[e.archive_count,` archive`,e.archive_count===1?``:`s`,e.status&&` • ${e.status}`]})]}),m.isPending&&m.variables===e.id&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]},e.id)),(!l||l.length===0)&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-4`,children:`No projects yet. Create one from the Projects page.`}),l&&l.length>0&&d?.length===0&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray text-sm py-4`,children:`—`})]})]}),(0,K.jsx)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`flex-1`,disabled:g,children:`Cancel`})})]})})})}function _Ae(e,t){return new Date(e,t+1,0).getDate()}function vAe(e,t){return new Date(e,t,1).getDay()}var yAe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],bAe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function xAe({archives:e,onArchiveClick:t,highlightedArchiveId:n}){let r=new Date,[i,a]=(0,y.useState)(r.getMonth()),[o,s]=(0,y.useState)(r.getFullYear()),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null),f=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`,i=t.get(r)||[];i.push(e),t.set(r,i)}),t},[e]),p=_Ae(o,i),m=vAe(o,i),h=()=>{i===0?(a(11),s(o-1)):a(i-1)},g=()=>{i===11?(a(0),s(o+1)):a(i+1)},_=()=>{a(r.getMonth()),s(r.getFullYear())},v=[];for(let e=0;e{e!==c&&d(null),l(e)};return(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`button`,{onClick:h,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(ss,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[yAe[i],` `,o]}),(0,K.jsx)(`button`,{onClick:_,className:`px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors`,children:`Today`})]}),(0,K.jsx)(`button`,{onClick:g,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(as,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-7 gap-1 mb-1`,children:bAe.map(e=>(0,K.jsx)(`div`,{className:`text-center text-xs text-bambu-gray py-2`,children:e},e))}),(0,K.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:v.map((e,t)=>{if(e===null)return(0,K.jsx)(`div`,{className:`aspect-square`},`empty-${t}`);let n=`${o}-${String(i+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,a=f.get(n)||[],s=a.length>0,l=e===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),u=n===c,d=a.filter(e=>e.status===`completed`).length,p=a.filter(e=>e.status===`failed`).length;return(0,K.jsxs)(`button`,{onClick:()=>x(u?null:n),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${u?`bg-bambu-green text-white`:l?`bg-bambu-green/20 text-white ring-2 ring-bambu-green`:s?`bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white`:`hover:bg-bambu-dark-tertiary/50 text-bambu-gray`}`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium ${l&&!u?`text-bambu-green`:``}`,children:e}),s&&(0,K.jsxs)(`div`,{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${p>0&&d===0?`bg-red-400`:p>0?`bg-yellow-400`:`bg-green-400`}`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:a.length})]})]},e)})}),(0,K.jsx)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-center`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-white`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Prints this month`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-green-400`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`completed`}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Successful`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-red-400`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`failed`}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Failed`})]})]})})]}),(0,K.jsx)(`div`,{className:`lg:w-80 bg-bambu-dark rounded-xl p-4`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:new Date(c+`T12:00:00`).toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),b.length>0?(0,K.jsx)(`div`,{className:`calendar-scroll space-y-2 max-h-96 overflow-y-auto`,children:b.map(e=>{let r=e.id===u||e.id===n;return(0,K.jsxs)(`button`,{onClick:()=>{d(e.id),t?.(e)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${r?``:`hover:bg-bambu-dark-tertiary`}`,style:r?{outline:`4px solid #facc15`,outlineOffset:`2px`}:void 0,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:``,className:`w-12 h-12 rounded object-cover`}):(0,K.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`3MF`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.print_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:e.status===`failed`?`text-red-400`:`text-green-400`,children:e.status===`failed`?`Failed`:`Completed`}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex gap-0.5`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e}},t))})]})]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`No prints on this day`})]}):(0,K.jsx)(`div`,{className:`text-center py-8`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`Select a day to see prints`})})})]})}function XW({archiveId:e,archiveName:t,onClose:n}){let r=Q.getArchiveQRCodeUrl(e,300);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`QR Code`}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 flex flex-col items-center`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 text-center truncate max-w-full`,children:t}),(0,K.jsx)(`div`,{className:`bg-white p-4 rounded-lg mb-4`,children:(0,K.jsx)(`img`,{src:r,alt:`QR Code`,className:`w-64 h-64`})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4 text-center`,children:`Scan to open this archive`}),(0,K.jsxs)($,{onClick:()=>{let e=document.createElement(`a`);e.href=r,e.download=`${t}_qrcode.png`,e.click()},className:`w-full`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download QR Code`]})]})]})})}function ZW({archiveId:e,archiveName:t,photos:n,onClose:r,onDelete:i}){let[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(!1);if((0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r(),e.key===`ArrowLeft`&&o(e=>Math.max(0,e-1)),e.key===`ArrowRight`&&o(e=>Math.min(n.length-1,e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,n.length]),(0,y.useEffect)(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;let l=n[a],u=Q.getArchivePhotoUrl(e,l);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:r,children:[(0,K.jsxs)(`div`,{className:`relative w-full h-full flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 bg-black/50`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Photo `,a+1,` of `,n.length]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=u,e.download=`${t}_photo_${a+1}.jpg`,e.click()},children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download`]}),i&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{i&&c(!0)},className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:r,className:`p-2 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-6 h-6`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden`,children:[a>0&&(0,K.jsx)(`button`,{onClick:()=>o(e=>e-1),className:`absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,K.jsx)(ss,{className:`w-8 h-8 text-white`})}),(0,K.jsx)(`img`,{src:u,alt:`Photo ${a+1}`,className:`max-w-full max-h-full object-contain rounded-lg`,style:{maxHeight:`calc(100vh - 200px)`}}),ao(e=>e+1),className:`absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,K.jsx)(as,{className:`w-8 h-8 text-white`})})]}),n.length>1&&(0,K.jsx)(`div`,{className:`flex justify-center gap-2 p-4 bg-black/50`,children:n.map((t,n)=>(0,K.jsx)(`button`,{onClick:()=>o(n),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${n===a?`border-bambu-green`:`border-transparent hover:border-bambu-gray`}`,children:(0,K.jsx)(`img`,{src:Q.getArchivePhotoUrl(e,t),alt:`Thumbnail ${n+1}`,className:`w-full h-full object-cover`})},t))})]}),s&&(0,K.jsx)(Ad,{title:`Delete Photo`,message:`Delete this photo? This cannot be undone.`,confirmText:`Delete`,variant:`danger`,onConfirm:()=>{i?.(l),c(!1)},onCancel:()=>c(!1)})]})}function QW(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`?null:SG(BigInt.prototype.toString),_G=typeof Symbol>`u`?null:SG(Symbol.prototype.toString),vG=SG(Object.prototype.hasOwnProperty),yG=SG(Object.prototype.toString),bG=SG(RegExp.prototype.test),xG=FAe(TypeError);function SG(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return aG(e,t,n)}}function FAe(e){return function(){return oG(e,[...arguments])}}function CG(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:dG;if(eG&&eG(e,null),!uG(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(DAe(t)||(t[r]=e),i=e)}e[i]=!0}return e}function IAe(e){for(let t=0;t/g),UAe=nG(/\${[\w\W]*/g),WAe=nG(/^data-[\-\w.\u00B7-\uFFFF]+$/),GAe=nG(/^aria-[\-\w]+$/),FG=nG(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),KAe=nG(/^(?:\w+script|data):/i),qAe=nG(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),JAe=nG(/^html$/i),YAe=nG(/^[a-z][.\w]*(-[.\w]+)+$/i),IG=nG(/<[/\w!]/g),XAe=nG(/<[/\w]/g),ZAe=nG(/<\/no(script|embed|frames)/i),QAe=nG(/\/>/i),LG={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},$Ae=function(){return typeof window>`u`?null:window},eje=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},RG=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},zG=function(e,t,n,r){return vG(e,t)&&uG(e[t])?CG(r.base?wG(r.base):{},e[t],r.transform):n};function BG(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:$Ae(),t=e=>BG(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==LG.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=TG(d,`cloneNode`),p=TG(d,`remove`),m=TG(d,`nextSibling`),h=TG(d,`childNodes`),g=TG(d,`parentNode`),_=TG(d,`shadowRoot`),v=TG(d,`attributes`),y=o&&o.prototype?TG(o.prototype,`nodeType`):null,b=o&&o.prototype?TG(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw xG(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=eje(u,i),!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=RG();t.isSupported=typeof $W==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=VAe,R=HAe,z=UAe,B=WAe,V=GAe,ee=KAe,te=qAe,ne=YAe,re=FG,ie=null,H=CG({},[...EG,...DG,...OG,...kG,...AG]),ae=null,oe=CG({},[...jG,...MG,...NG,...PG]),U=Object.seal(rG(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),se=null,ce=null,le=Object.seal(rG(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ue=!0,de=!0,fe=!1,pe=!0,me=!1,he=!0,ge=!1,_e=!1,ve=null,ye=null,be=!1,xe=!1,Se=!1,Ce=!1,we=!0,Te=!1,Ee=`user-content-`,De=!0,Oe=!1,ke={},Ae=null,je=CG({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Me=null,Ne=CG({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Pe=null,Fe=CG({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ie=`http://www.w3.org/1998/Math/MathML`,Le=`http://www.w3.org/2000/svg`,Re=`http://www.w3.org/1999/xhtml`,ze=Re,Be=!1,Ve=null,He=CG({},[Ie,Le,Re],fG),Ue=tG([`mi`,`mo`,`mn`,`ms`,`mtext`]),We=CG({},Ue),Ge=tG([`annotation-xml`]),Ke=CG({},Ge),qe=CG({},[`title`,`style`,`font`,`a`,`script`]),Je=null,Ye=[`application/xhtml+xml`,`text/html`],Xe=null,Ze=null,Qe=n.createElement(`form`),$e=function(e){return e instanceof RegExp||e instanceof Function},W=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===e)return;(!e||typeof e!=`object`)&&(e={}),e=wG(e),Je=Ye.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Xe=Je===`application/xhtml+xml`?fG:dG,ie=zG(e,`ALLOWED_TAGS`,H,{transform:Xe}),ae=zG(e,`ALLOWED_ATTR`,oe,{transform:Xe}),Ve=zG(e,`ALLOWED_NAMESPACES`,He,{transform:fG}),Pe=zG(e,`ADD_URI_SAFE_ATTR`,Fe,{transform:Xe,base:Fe}),Me=zG(e,`ADD_DATA_URI_TAGS`,Ne,{transform:Xe,base:Ne}),Ae=zG(e,`FORBID_CONTENTS`,je,{transform:Xe}),se=zG(e,`FORBID_TAGS`,wG({}),{transform:Xe}),ce=zG(e,`FORBID_ATTR`,wG({}),{transform:Xe}),ke=vG(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?wG(e.USE_PROFILES):e.USE_PROFILES:!1,ue=e.ALLOW_ARIA_ATTR!==!1,de=e.ALLOW_DATA_ATTR!==!1,fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,ge=e.WHOLE_DOCUMENT||!1,xe=e.RETURN_DOM||!1,Se=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,be=e.FORCE_BODY||!1,we=e.SANITIZE_DOM!==!1,Te=e.SANITIZE_NAMED_PROPS||!1,De=e.KEEP_CONTENT!==!1,Oe=e.IN_PLACE||!1,re=RAe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:FG,ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Re,We=vG(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?wG(e.MATHML_TEXT_INTEGRATION_POINTS):CG({},Ue),Ke=vG(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?wG(e.HTML_INTEGRATION_POINTS):CG({},Ge);let t=vG(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?wG(e.CUSTOM_ELEMENT_HANDLING):rG(null);if(U=rG(null),vG(t,`tagNameCheck`)&&$e(t.tagNameCheck)&&(U.tagNameCheck=t.tagNameCheck),vG(t,`attributeNameCheck`)&&$e(t.attributeNameCheck)&&(U.attributeNameCheck=t.attributeNameCheck),vG(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(U.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),nG(U),me&&(de=!1),Se&&(xe=!0),ke&&(ie=CG({},AG),ae=rG(null),ke.html===!0&&(CG(ie,EG),CG(ae,jG)),ke.svg===!0&&(CG(ie,DG),CG(ae,MG),CG(ae,PG)),ke.svgFilters===!0&&(CG(ie,OG),CG(ae,MG),CG(ae,PG)),ke.mathMl===!0&&(CG(ie,kG),CG(ae,NG),CG(ae,PG))),le.tagCheck=null,le.attributeCheck=null,vG(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?le.tagCheck=e.ADD_TAGS:uG(e.ADD_TAGS)&&(ie===H&&(ie=wG(ie)),CG(ie,e.ADD_TAGS,Xe))),vG(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?le.attributeCheck=e.ADD_ATTR:uG(e.ADD_ATTR)&&(ae===oe&&(ae=wG(ae)),CG(ae,e.ADD_ATTR,Xe))),vG(e,`ADD_URI_SAFE_ATTR`)&&uG(e.ADD_URI_SAFE_ATTR)&&CG(Pe,e.ADD_URI_SAFE_ATTR,Xe),vG(e,`FORBID_CONTENTS`)&&uG(e.FORBID_CONTENTS)&&(Ae===je&&(Ae=wG(Ae)),CG(Ae,e.FORBID_CONTENTS,Xe)),vG(e,`ADD_FORBID_CONTENTS`)&&uG(e.ADD_FORBID_CONTENTS)&&(Ae===je&&(Ae=wG(Ae)),CG(Ae,e.ADD_FORBID_CONTENTS,Xe)),De&&(ie[`#text`]=!0),ge&&CG(ie,[`html`,`head`,`body`]),ie.table&&(CG(ie,[`tbody`]),delete se.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw xG(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw xG(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));tG&&tG(e),Ze=e},et=CG({},[...DG,...OG,...zAe]),tt=CG({},[...kG,...BAe]),nt=function(e,t,n){return t.namespaceURI===Re?e===`svg`:t.namespaceURI===Ie?e===`svg`&&(n===`annotation-xml`||We[n]):!!et[e]},rt=function(e,t,n){return t.namespaceURI===Re?e===`math`:t.namespaceURI===Le?e===`math`&&Ke[n]:!!tt[e]},it=function(e,t,n){return t.namespaceURI===Le&&!Ke[n]||t.namespaceURI===Ie&&!We[n]?!1:!tt[e]&&(qe[e]||!et[e])},at=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:ze,tagName:`template`});let n=dG(e.tagName),r=dG(t.tagName);return Ve[e.namespaceURI]?e.namespaceURI===Le?nt(n,t,r):e.namespaceURI===Ie?rt(n,t,r):e.namespaceURI===Re?it(n,t,r):!!(Je===`application/xhtml+xml`&&Ve[e.namespaceURI]):!1},ot=function(e){lG(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw xG(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},st=function(e){let t=h(e);if(t){let e=[];sG(t,t=>{lG(e,t)}),sG(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},ct=function(e,n){try{lG(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{lG(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(xe||Se)try{ot(n)}catch{}else try{n.setAttribute(e,``)}catch{}},lt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||ae[Xe(i)]))try{e.removeAttribute(i)}catch{}}},ut=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===LG.element&<(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},dt=function(e){let t=null,r=null;if(be)e=``+e;else{let t=pG(e,/^[\r\n\t ]+/);r=t&&t[0]}Je===`application/xhtml+xml`&&ze===Re&&(e=``+e+``);let i=x?D(e):e;if(ze===Re)try{t=new l().parseFromString(i,Je)}catch{}if(!t||!t.documentElement){t=j.createDocument(ze,`template`,null);try{t.documentElement.innerHTML=Be?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),ze===Re?P.call(t,ge?`html`:`body`)[0]:ge?t.documentElement:a},ft=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},pt=function(e){return e=mG(e,L,` `),e=mG(e,R,` `),e=mG(e,z,` `),e},mt=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=pt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&sG(r,e=>{gt(e.content)&&mt(e.content)})},ht=function(e){let t=b?b(e):null;return typeof t!=`string`||Xe(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},gt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===LG.documentFragment}catch{return!1}},_t=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function vt(e,n,r){e.length!==0&&sG(e,e=>{e.call(t,n,r,Ze)})}let yt=function(e,t){return!!(he&&e.hasChildNodes()&&!_t(e.firstElementChild)&&bG(IG,e.textContent)&&bG(IG,e.innerHTML)||he&&e.namespaceURI===Re&&t===`style`&&_t(e.firstElementChild)||e.nodeType===LG.processingInstruction||he&&e.nodeType===LG.comment&&bG(XAe,e.data))},bt=function(e,t){if(!se[t]&&wt(t)&&(U.tagNameCheck instanceof RegExp&&bG(U.tagNameCheck,t)||U.tagNameCheck instanceof Function&&U.tagNameCheck(t)))return!1;if(De&&!Ae[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Oe?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return ot(e),!0},xt=function(e){if(vt(I.beforeSanitizeElements,e,null),ht(e))return ot(e),!0;let n=Xe(b?b(e):e.nodeName);if(vt(I.uponSanitizeElement,e,{tagName:n,allowedTags:ie}),yt(e,n))return ot(e),!0;if(se[n]||!(le.tagCheck instanceof Function&&le.tagCheck(n))&&!ie[n])return bt(e,n);if((y?y(e):e.nodeType)===LG.element&&!at(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&bG(ZAe,e.innerHTML))return ot(e),!0;if(me&&e.nodeType===LG.text){let n=pt(e.textContent);e.textContent!==n&&(lG(t.removed,{element:e.cloneNode()}),e.textContent=n)}return vt(I.afterSanitizeElements,e,null),!1},St=function(e,t,r){if(ce[t]||we&&(t===`id`||t===`name`)&&(r in n||r in Qe))return!1;let i=ae[t]||le.attributeCheck instanceof Function&&le.attributeCheck(t,e);if(!(de&&bG(B,t))&&!(ue&&bG(V,t))){if(!i){if(!(wt(e)&&(U.tagNameCheck instanceof RegExp&&bG(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&bG(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t,e))||t===`is`&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&bG(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r))))return!1}else if(!Pe[t]&&!bG(re,mG(r,te,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&hG(r,`data:`)===0&&Me[e])&&!(fe&&!bG(ee,mG(r,te,``)))&&r)return!1}return!0},Ct=CG({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),wt=function(e){return!Ct[dG(e)]&&bG(ne,e)},Tt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Et=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),ht(e)?ot(e):cG(t.removed)}catch{ct(n,e)}},Dt=function(e){vt(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||ht(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ae,forceKeepAttr:void 0},r=t.length,i=Xe(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Xe(o),u=c,d=o===`value`?u:MAe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,vt(I.uponSanitizeAttribute,e,n),d=n.attrValue,Te&&(l===`id`||l===`name`)&&hG(d,Ee)!==0&&(ct(o,e),d=Ee+d),he&&bG(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){ct(o,e);continue}if(l===`attributename`&&pG(d,`href`)){ct(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){ct(o,e);continue}if(!pe&&bG(QAe,d)){ct(o,e);continue}if(me&&(d=pt(d)),!St(i,l,d)){ct(o,e);continue}d=Tt(i,l,s,d),d!==u&&Et(e,o,s,d)}}vt(I.afterSanitizeAttributes,e,null)},Ot=function(e){let t=null,n=ft(e);for(vt(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(vt(I.uponSanitizeShadowNode,t,null),xt(t),Dt(t),gt(t.content)&&Ot(t.content),(y?y(t):t.nodeType)===LG.element){let e=_(t);gt(e)&&(kt(e),Ot(e))}vt(I.afterSanitizeShadowDOM,e,null)},kt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ot(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===LG.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&Xe(e)===`template`){let e=n.content;gt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);gt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Be=!e,Be&&(e=``),typeof e!=`string`&&!_t(e)&&(e=LAe(e),typeof e!=`string`))throw xG(`dirty is not a string, aborting`);if(!t.isSupported)return e;_e?(ie=ve,ae=ye):W(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(ie=wG(ie)),I.uponSanitizeAttribute.length>0&&(ae=wG(ae)),t.removed=[];let c=Oe&&typeof e!=`string`&&_t(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=Xe(t);if(!ie[e]||se[e])throw xG(`root node is forbidden and cannot be sanitized in-place`)}if(ht(e))throw xG(`root node is clobbered and cannot be sanitized in-place`);try{kt(e)}catch(t){throw st(e),t}}else if(_t(e))i=dt(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===LG.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),kt(a);else{if(!xe&&!me&&!ge&&e.indexOf(`<`)===-1)return x&&Ce?D(e):e;if(i=dt(e),!i)return xe?null:Ce?S:``}i&&be&&ot(i.firstChild);let l=ft(c?e:i);try{for(;o=l.nextNode();)xt(o),Dt(o),gt(o.content)&&Ot(o.content)}catch(t){throw c&&st(e),t}if(c)return sG(t.removed,e=>{e.element&&ut(e.element)}),me&&mt(e),e;if(xe){if(me&&mt(i),Se)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ae.shadowroot||ae.shadowrootmode)&&(s=F.call(r,s,!0)),s}let u=ge?i.outerHTML:i.innerHTML;return ge&&ie[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&bG(JAe,i.ownerDocument.doctype.name)&&(u=` -`+u),me&&(u=pt(u)),x&&Ce?D(u):u},t.setConfig=function(){W(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),_e=!0,ve=ie,ye=ae},t.clearConfig=function(){Ze=null,_e=!1,ve=null,ye=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return Ze||W({}),St(Xe(e),Xe(t),n)},t.addHook=function(e,t){typeof t==`function`&&vG(I,e)&&lG(I[e],t)},t.removeHook=function(e,t){if(vG(I,e)){if(t!==void 0){let n=AAe(I[e],t);return n===-1?void 0:jAe(I[e],n,1)[0]}return cG(I[e])}},t.removeHooks=function(e){vG(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=RG()},t}var VG=BG();function HG(e){this.content=e}HG.prototype={constructor:HG,find:function(e){for(var t=0;t>1}},HG.from=function(e){if(e instanceof HG)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new HG(t)};function UG(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=UG(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function WG(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?qG(t+1,i):qG(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};YG.none=[];var XG=class extends Error{},ZG=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=$G(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(QG(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(GG.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};ZG.empty=new ZG(GG.empty,0,0);function QG(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(QG(a.content,t-i-1,n-i-1)))}function $G(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=$G(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function tje(e,t,n){if(n.openStart>e.depth)throw new XG(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new XG(`Inconsistent open depths`);return eK(e,t,n,0)}function eK(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function iK(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(rK(e.nodeAfter,r),a++));for(let e=a;ei&&nK(e,t,i+1),o=r.depth>i&&nK(n,r,i+1),s=[];return iK(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(tK(a,o),rK(aK(a,oK(e,t,n,r,i+1)),s)):(a&&rK(aK(a,sK(e,t,i+1)),s),iK(t,n,i,s),o&&rK(aK(o,sK(n,r,i+1)),s)),iK(r,null,i,s),new GG(s)}function sK(e,t,n){let r=[];return iK(null,e,n,r),e.depth>n&&rK(aK(nK(e,t,n+1),sK(e,t,n+1)),r),iK(t,null,n,r),new GG(r)}function nje(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(GG.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var cK=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new uK(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=lK.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),fK(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=GG.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=GG.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};dK.prototype.text=void 0;var oje=class e extends dK{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fK(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function fK(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var pK=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new sje(t,n);if(r.next==null)return e.empty;let i=mK(r);r.next&&r.err(`Unexpected trailing text`);let a=mje(pje(i));return hje(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` -`)}};pK.empty=new pK(!0);var sje=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function mK(e){let t=[];do t.push(cje(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function cje(e){let t=[];do t.push(lje(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function lje(e){let t=fje(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=uje(e,t);else break;return t}function hK(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function uje(e,t){let n=hK(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:hK(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function dje(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function fje(e){if(e.eat(`(`)){let t=mK(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=dje(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function pje(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new pK(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:yK(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new dK(this,this.computeAttrs(e),GG.from(t),YG.setFrom(n))}createChecked(e=null,t,n){return t=GG.from(t),this.checkContent(t),new dK(this,this.computeAttrs(e),t,YG.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=GG.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(GG.empty,!0);return i?new dK(this,e,t.append(i),YG.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function gje(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var _je=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?gje(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},CK=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=xK(e,r.attrs),this.excluded=null;let i=vK(this.attrs);this.instance=i?new YG(this,i):null}create(e=null){return!e&&this.instance?this.instance:new YG(this,yK(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},wK=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=HG.from(e.nodes),t.marks=HG.from(e.marks||{}),this.nodes=SK.compile(this.spec.nodes,this),this.marks=CK.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=pK.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?TK(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:TK(this,n.split(` `))}this.nodeFromJSON=e=>dK.fromJSON(this,e),this.markFromJSON=e=>YG.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof SK))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new oje(n,n.defaultAttrs,e,YG.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function TK(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function vje(e){return e.tag!=null}function yje(e){return e.style!=null}var EK=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(vje(e))this.tags.push(e);else if(yje(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new PK(this,t,!1);return n.addAll(e,YG.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new PK(this,t,!0);return n.addAll(e,YG.none,t.from,t.to),ZG.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=FK(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=FK(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},DK={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},bje={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},OK={ol:!0,ul:!0},kK=1,AK=2,jK=4;function MK(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?kK:0)|(t===`full`?AK:0)}var NK=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=YG.none,this.match=i||(a&jK?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(GG.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&kK)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=GG.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(GG.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!DK.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},PK=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=MK(null,t.preserveWhitespace,0)|(n?jK:0);i=r?new NK(r.type,r.attrs,YG.none,!0,t.topMatch||r.type.contentMatch,a):n?new NK(null,null,YG.none,!0,null,a):new NK(e.schema.topNodeType,null,YG.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&AK?`full`:this.localPreserveWS||(r.options&kK)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` -`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e(a.type?a.type.allowsMarkType(t.type):IK(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new NK(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=kK);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function xje(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&OK.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Sje(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function FK(e){let t={};for(let n in e)t[n]=e[n];return t}function IK(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&VK(zK(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return VK(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=RK(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return RK(e.marks)}};function RK(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function zK(e){return e.document||window.document}var BK=new WeakMap;function Cje(e){let t=BK.get(e);return t===void 0&&BK.set(e,t=wje(e)),t}function wje(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=VK(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var HK=65535,UK=2**16;function Tje(e,t){return e+t*UK}function WK(e){return e&HK}function Eje(e){return(e-(e&HK))/UK}var Dje=1,Oje=2,GK=4,KK=8,qK=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&KK)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&GK)>0}},JK=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=WK(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Tje(o/3,e-s),f=e==s?Oje:e==u?Dje:GK;return(t<0?e!=s:e!=u)&&(f|=KK),new qK(a,f,d)}r+=l-c}return n?e+r:new qK(e+r,0,null)}touches(e,t){let n=0,r=WK(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return QK.fromReplace(e,this.from,this.to,i)}invert(){return new tq(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};ZK.jsonID(`addMark`,eq);var tq=class e extends ZK{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new ZG($K(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return QK.fromReplace(e,this.from,this.to,n)}invert(){return new eq(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};ZK.jsonID(`removeMark`,tq);var nq=class e extends ZK{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return QK.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return QK.fromReplace(e,this.pos,this.pos+1,new ZG(GG.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,ZG.fromJSON(t,n.slice),n.insert,!!n.structure)}};ZK.jsonID(`replaceAround`,aq);function oq(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function kje(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function Aje(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof CK){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new tq(t.from,t.to,t.style)))}function sq(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function jje(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function cq(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=GG.from(r.node(e).copy(u)),d++):c--;let f=GG.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=GG.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new aq(i,a,i,a,new ZG(r,0,0),n.length,!0))}function Ije(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Lje(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&fq(e,t,n,a),sq(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new aq(c,l,c+1,l-1,new ZG(GG.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&dq(e,t,n,a),!1}})}function dq(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function fq(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` -`))}})}function Lje(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Rje(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new aq(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new ZG(GG.from(o),0,0),1,!0))}function pq(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function zje(e,t,n=1,r){let i=e.doc.resolve(t),a=GG.empty,o=GG.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=GG.from(i.node(e).copy(a));let t=r&&r[s];o=GG.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new iq(t,t,new ZG(a.append(o),n,n),!0))}function mq(e,t){let n=e.resolve(t),r=n.index();return hq(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Bje(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&hq(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Vje(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);fq(e,r.node(),r.before(),s)}o.inlineContent&&sq(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new iq(l,c.map(t+n,-1),ZG.empty,!0)),r===!0){let t=e.doc.resolve(l);dq(e,t.node(),t.before(),e.steps.length)}return e}function Hje(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function vq(e,t,n=t,r=ZG.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return yq(i,a,r)?new iq(t,n,r):new Uje(i,a,r).fit()}function yq(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Uje=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=GG.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=GG.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new ZG(i,a,o);return e>-1?new aq(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new iq(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Sq(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(GG.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Sq(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new ZG(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Sq(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new ZG(bq(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new ZG(bq(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(Cq(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=xq(this.placed,t,GG.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=wq(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=xq(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=xq(this.placed,this.depth,GG.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(GG.empty,!0);e.childCount&&(this.placed=xq(this.placed,this.frontier.length,e))}};function bq(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(bq(e.firstChild.content,t-1,n)))}function xq(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(xq(e.lastChild.content,t-1,n)))}function Sq(e,t){for(let n=0;n1&&(r=r.replaceChild(0,Cq(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(GG.empty,!0)))),e.copy(r)}function wq(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Wje(n,a.content,o)?s:null}function Wje(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Gje(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Tq(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(GG.empty,!0))}return e}function qje(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Hje(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new ZG(GG.from(r),0,0))}function Jje(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Eq(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Eq(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Dq=class e extends ZK{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return QK.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return QK.fromReplace(e,this.pos,this.pos+1,new ZG(GG.from(r),0,+!t.isLeaf))}getMap(){return JK.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};ZK.jsonID(`attr`,Dq);var Oq=class e extends ZK{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return QK.ok(n)}getMap(){return JK.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};ZK.jsonID(`docAttr`,Oq);var kq=class extends Error{};kq=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},kq.prototype=Object.create(Error.prototype),kq.prototype.constructor=kq,kq.prototype.name=`TransformError`;var Aq=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new YK}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new kq(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=ZG.empty){let r=vq(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new ZG(GG.from(n),0,0))}delete(e,t){return this.replace(e,t,ZG.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Kje(this,e,t,n),this}replaceRangeWith(e,t,n){return qje(this,e,t,n),this}deleteRange(e,t){return Jje(this,e,t),this}lift(e,t){return Mje(this,e,t),this}join(e,t=1){return Vje(this,e,t),this}wrap(e,t){return Fje(this,e,t),this}setBlockType(e,t=e,n,r=null){return Ije(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Rje(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Dq(e,t,n)),this}setDocAttribute(e,t){return this.step(new Oq(e,t)),this}addNodeMark(e,t){return this.step(new nq(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof YG)t.isInSet(n.marks)&&this.step(new rq(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new rq(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return zje(this,e,t,n),this}addMark(e,t,n){return kje(this,e,t,n),this}removeMark(e,t,n){return Aje(this,e,t,n),this}clearIncompatible(e,t,n){return sq(this,e,t,n),this}},jq=Object.create(null),Mq=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Yje(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?zq(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):zq(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Rq(e.node(0))}static atStart(e){return zq(e,e,0,0,1)||new Rq(e)}static atEnd(e){return zq(e,e,e.content.size,e.childCount,-1)||new Rq(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=jq[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in jq)throw RangeError(`Duplicate use of selection JSON ID `+e);return jq[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Fq.between(this.$anchor,this.$head).getBookmark()}};Mq.prototype.visible=!0;var Yje=class{constructor(e,t){this.$from=e,this.$to=t}},Nq=!1;function Pq(e){!Nq&&!e.parent.inlineContent&&(Nq=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Fq=class e extends Mq{constructor(e,t=e){Pq(e),Pq(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return Mq.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=ZG.empty){if(super.replace(e,t),t==ZG.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Iq(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=Mq.findFrom(n,r,!0)||Mq.findFrom(n,-r,!0);if(e)n=e.$head;else return Mq.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(Mq.findFrom(t,-r,!0)||Mq.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=zq(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Lq.isSelectable(r))return Lq.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Bq(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(Mq.near(e.doc.resolve(o),n))}var Vq=1,Hq=2,Uq=4,Qje=class extends Aq{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hq,this}ensureMarks(e){return YG.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Hq)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||YG.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Mq.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Uq,this}get scrolledIntoView(){return(this.updated&Uq)>0}};function Wq(e,t){return!t||!e?e:e.bind(t)}var Gq=class{constructor(e,t,n){this.name=e,this.init=Wq(t.init,n),this.apply=Wq(t.apply,n)}},$je=[new Gq(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Gq(`selection`,{init(e,t){return e.selection||Mq.atStart(t.doc)},apply(e){return e.selection}}),new Gq(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Gq(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Kq=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$je.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Gq(e.key,e.spec.state,e))})}},eMe=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Kq(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=dK.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=Mq.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function qq(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=qq(i,t,{})),n[r]=i}return n}var Jq=class{constructor(e){this.spec=e,this.props={},e.props&&qq(e.props,this,this.props),this.key=e.key?e.key.key:Xq(`plugin`)}getState(e){return e[this.key]}},Yq=Object.create(null);function Xq(e){return e in Yq?e+`$`+ ++Yq[e]:(Yq[e]=0,e+`$`)}var Zq=class{constructor(e=`key`){this.key=Xq(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Qq=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function $q(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var eJ=(e,t,n)=>{let r=$q(e,n);if(!r)return!1;let i=iJ(r);if(!i){let n=r.blockRange(),i=n&&cq(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(mJ(e,i,t,-1))return!0;if(r.parent.content.size==0&&(nJ(a,`end`)||Lq.isSelectable(a)))for(let n=r.depth;;n--){let o=vq(e.doc,r.before(n),r.after(n),ZG.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},tMe=(e,t,n)=>{let r=$q(e,n);if(!r)return!1;let i=iJ(r);return i?tJ(e,i,t):!1},nMe=(e,t,n)=>{let r=aJ(e,n);if(!r)return!1;let i=cJ(r);return i?tJ(e,i,t):!1};function tJ(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=vq(e.doc,i,o,ZG.empty);if(!s||s.from!=i||s instanceof iq&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Fq.create(t.doc,i)),n(t.scrollIntoView())}return!0}function nJ(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var rJ=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=iJ(r)}let o=a&&a.nodeBefore;return!o||!Lq.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Lq.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function iJ(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function aJ(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=aJ(e,n);if(!r)return!1;let i=cJ(r);if(!i)return!1;let a=i.nodeAfter;if(mJ(e,i,t,1))return!0;if(r.parent.content.size==0&&(nJ(a,`start`)||Lq.isSelectable(a))){let n=vq(e.doc,r.before(),r.after(),ZG.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof Lq,i;if(r){if(n.node.isTextblock||!mq(e.doc,n.from))return!1;i=n.from}else if(i=gq(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Lq.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},iMe=(e,t)=>{let n=e.selection,r;if(n instanceof Lq){if(n.node.isTextblock||!mq(e.doc,n.to))return!1;r=n.to}else if(r=gq(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},aMe=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&cq(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},lJ=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` -`).scrollIntoView()),!0)};function uJ(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=uJ(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(Mq.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},fJ=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Rq||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=uJ(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(pq(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&cq(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function oMe(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Lq&&t.selection.node.isBlock)return!r.parentOffset||!pq(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=uJ(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof Fq||t.selection instanceof Rq)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=pq(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,pq(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var sMe=oMe(),cMe=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Lq.create(e.doc,i))),!0)},lMe=(e,t)=>(t&&t(e.tr.setSelection(new Rq(e.doc))),!0);function uMe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||mq(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function mJ(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&uMe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=GG.empty;for(let e=o.length-1;e>=0;e--)s=GG.from(o[e].create(null,s));s=GG.from(i.copy(s));let c=e.tr.step(new aq(t.pos-1,r,t.pos,r,new ZG(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&mq(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:Mq.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&cq(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&nJ(a,`start`,!0)&&nJ(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=GG.empty;for(let e=o.length-1;e>=0;e--)r=GG.from(o[e].copy(r));n(e.tr.step(new aq(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new ZG(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function hJ(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Fq.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var gJ=hJ(-1),_J=hJ(1);function dMe(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&lq(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function vJ(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new uK(e,e,t.depth),t.endIndex=0;e--)a=GG.from(n[e].type.create(n[e].attrs,a));e.step(new aq(t.start-(r?2:0),t.end,t.start,t.end,new ZG(a,0,0),n.length,!0));let o=0;for(let e=0;et.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?_Me(t,n,e,a):vMe(t,n,a):!0:!1}}function _Me(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?GG.empty:GG.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new aq(d-+!!s,f+ +!!c,d+1,f-1,new ZG((s?GG.empty:GG.from(i.copy(GG.empty))).append(c?GG.empty:GG.from(i.copy(GG.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function yMe(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=GG.from(r?e.create():null),o=new ZG(GG.from(e.create(null,GG.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new aq(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var CJ=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},wJ=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},TJ=null,EJ=function(e,t,n){let r=TJ||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},bMe=function(){TJ=null},DJ=function(e,t,n,r){return n&&(OJ(e,t,n,r,-1)||OJ(e,t,n,r,1))},xMe=/^(img|br|input|textarea|hr)$/i;function OJ(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:kJ(e))){let n=e.parentNode;if(!n||n.nodeType!=1||AJ(e)||xMe.test(e.nodeName)||e.contentEditable==`false`)return!1;t=CJ(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?kJ(e):0}else return!1}}function kJ(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function SMe(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=kJ(e)}else if(e.parentNode&&!AJ(e))t=CJ(e),e=e.parentNode;else return null}}function CMe(e,t){for(;;){if(e.nodeType==3&&t2),qJ=KJ||(NJ?/Mac/.test(NJ.platform):!1),JJ=NJ?/Win/.test(NJ.platform):!1,YJ=/Android \d/.test(FJ),XJ=!!PJ&&`webkitFontSmoothing`in PJ.documentElement.style,DMe=XJ?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function OMe(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function ZJ(e,t){return typeof e==`number`?e:e[t]}function kMe(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function QJ(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=wJ(o);continue}let e=o,n=e==a.body,s=n?OMe(a):kMe(e),c=0,l=0;if(t.tops.bottom-ZJ(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+ZJ(i,`top`)-s.top:t.bottom-s.bottom+ZJ(i,`bottom`)),t.lefts.right-ZJ(r,`right`)&&(c=t.right-s.right+ZJ(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:wJ(o)}}function AMe(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:$J(e.dom)}}function $J(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=wJ(r));return t}function jMe({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;eY(n,r==0?0:r-t)}function eY(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?NMe(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:nY(n,i)}function NMe(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function rY(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function PMe(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function IMe(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function iY(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;XJ&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=IMe(e,r,i,t))}s??=FMe(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function aY(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,cY(oY(EJ(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==kJ(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return lY(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==kJ(r))){let e=r.childNodes[i-1],t=e.nodeType==3?EJ(e,kJ(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return cY(oY(t,1),!1)}if(a==null&&i=0)}function cY(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function lY(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function uY(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function zMe(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return uY(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=sY(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=EJ(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var BMe=/[\u0590-\u08ac]/;function VMe(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!BMe.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:uY(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var dY=null,fY=null,pY=!1;function HMe(e,t,n){return dY==t&&fY==n?pY:(dY=t,fY=n,pY=n==`up`||n==`down`?zMe(e,t,n):VMe(e,t,n))}var mY=0,hY=1,gY=2,_Y=3,vY=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=mY,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tCJ(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te||i instanceof wY){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof yY&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?CJ(e.dom)+1:0}}else{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=CJ(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?gY:hY,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=_Y:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?gY:_Y}n=a}this.dirty=gY}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?gY:hY;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==mY&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},UMe=class extends vY{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},bY=class e extends vY{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=LK.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&_Y||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=_Y&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=mY){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=NY(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=LK.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=AY(u,r,n),l?c=new WMe(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new CY(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>GG.empty)}return e}matchesNode(e,t,n){return this.dirty==mY&&e.eq(this.node)&&jY(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new KMe(this,a&&a.node,e);YMe(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?YG.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==gY)&&(a&&this.protectLocalComposition(e,a),TY(this.contentDOM,this.children,e),KJ&&XMe(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Fq)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=ZMe(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new UMe(this,i,t,r);e.input.compositionNodes.push(a),this.children=NY(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==_Y||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=mY}updateOuterDeco(e){if(jY(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=kY(this.dom,this.nodeDOM,OY(this.outerDeco,this.node,t),OY(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function SY(e,t,n,r,i){AY(r,t,e);let a=new xY(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var CY=class e extends xY{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==_Y||this.dirty!=mY&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=mY||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=mY,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=_Y)}get domAtom(){return!1}isText(e){return this.node.text==e}},wY=class extends vY{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==mY&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},WMe=class extends xY{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==_Y)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function TY(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=bY.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof bY)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function JMe(e,t){return e.type.side-t.type.side}function YMe(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function XMe(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function ZMe(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function NY(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function PY(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(jJ(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Lq.isSelectable(e)&&i.parent&&!(e.isInline&&wMe(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Lq(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!FY(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function $Me(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,CJ(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&zJ&&BJ<=11&&(n.disabled=!0,n.disabled=!1)}function VY(e,t){if(t instanceof Lq){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(HY(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else HY(e)}function HY(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function UY(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Fq.between(t,n,r)}function WY(e){return e.editable&&!e.hasFocus()?!1:GY(e)}function GY(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function eNe(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return DJ(t.node,t.offset,n.anchorNode,n.anchorOffset)}function KY(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&Mq.findFrom(a,t)}function qY(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function JY(e,t,n){let r=e.state.selection;if(r instanceof Fq){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return qY(e,new Fq(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=KY(e.state,t);return n&&n instanceof Lq?qY(e,n):!1}else if(!(qJ&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Lq.isSelectable(i)?qY(e,new Lq(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):XJ?qY(e,new Fq(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Lq&&r.node.isInline)return qY(e,new Fq(t>0?r.$to:r.$from));else{let n=KY(e.state,t);return n?qY(e,n):!1}}function YY(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function XY(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function ZY(e,t){return t<0?tNe(e):nNe(e)}function tNe(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(VJ&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(XY(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(QY(n))break;else{let t=n.previousSibling;for(;t&&XY(t,-1);)i=n.parentNode,a=CJ(t),t=t.previousSibling;if(t)n=t,r=YY(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?$Y(e,n,r):i&&$Y(e,i,a)}function nNe(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=YY(n),a,o;for(;;)if(r{e.state==i&&IY(e)},50)}function eX(e,t){let n=e.state.doc.resolve(t);if(!(UJ||JJ)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function tX(e,t,n){let r=e.state.selection;if(r instanceof Fq&&!r.empty||n.indexOf(`s`)>-1||qJ&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=KY(e.state,t);if(n&&n instanceof Lq)return qY(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Rq?Mq.near(n,t):Mq.findFrom(n,t);return o?qY(e,o):!1}return!1}function nX(e,t){if(!(e.state.selection instanceof Fq))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function rX(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function aNe(e){if(!GJ||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;rX(e,n,`true`),setTimeout(()=>rX(e,n,`false`),20)}return!1}function oNe(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function sNe(e,t){let n=t.keyCode,r=oNe(t);if(n==8||qJ&&n==72&&r==`c`)return nX(e,-1)||ZY(e,-1);if(n==46&&!t.shiftKey||qJ&&n==68&&r==`c`)return nX(e,1)||ZY(e,1);if(n==13||n==27)return!0;if(n==37||qJ&&n==66&&r==`c`){let t=n==37?eX(e,e.state.selection.from)==`ltr`?-1:1:-1;return JY(e,t,r)||ZY(e,t)}else if(n==39||qJ&&n==70&&r==`c`){let t=n==39?eX(e,e.state.selection.from)==`ltr`?1:-1:1;return JY(e,t,r)||ZY(e,t)}else if(n==38||qJ&&n==80&&r==`c`)return tX(e,-1,r)||ZY(e,-1);else if(n==40||qJ&&n==78&&r==`c`)return aNe(e)||tX(e,1,r)||ZY(e,1);else if(r==(qJ?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function iX(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||LK.fromSchema(e.state.schema),s=fX(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=dX[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` + `,title:F(`printers:control`)?j(`printers.stop`):j(`printers.permission.noControl`),children:[(0,K.jsx)(ou,{className:`w-3 h-3`}),j(`printers.stop`)]})})()]})]})]})})(),(Qt?.length>0||G.vt_tray.length>0)&&r===`expanded`&&(()=>{let t=Qt.filter(e=>e.tray.length>1),n=Qt.filter(e=>e.tray.length===1),r=e.nozzle_count===2||G?.temperatures?.nozzle_2!==void 0,i=`min-w-14`,g=(G.state===`RUNNING`||G.state===`PAUSE`)&&Array.isArray(G.ams_mapping)?G.ams_mapping:[],_=e=>{let t=Math.max(1,e),n=`calc(${t} * 3.5rem + ${Math.max(0,t-1)} * 0.25rem + 1rem)`;return{flex:`1 1 ${n}`,minWidth:n}};return(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.filaments`)}),(0,K.jsx)(Mke,{state:G.ams_filament_backup,onClick:()=>pe(!0)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.map(t=>{let n=Xt[String(t.id)],v=t.id>=128?t.id-128:t.id,y=n===void 0?v:n,b=y===1,S=y===0;return(0,K.jsxs)(`div`,{style:_(4),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex w-full min-h-7 items-center justify-between gap-2 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,K.jsx)(OW,{ams:t,printerId:e.id,label:Af(t.id,t.tray.length),amsLabels:Ht,canEdit:F(`printers:update`),onSaved:Ut,children:(0,K.jsx)(`span`,{className:`block truncate text-[10px] text-white font-medium cursor-default select-none`,children:Ht?.[t.id]||Af(t.id,t.tray.length)})}),r&&(b||S)&&(0,K.jsx)(pW,{side:b?`L`:`R`})]}),(t.humidity!=null||t.temp!=null)&&(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.humidity!=null&&(0,K.jsx)(vW,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`humidity`}),compact:!0}),t.temp!=null&&(0,K.jsx)(`div`,{className:`mr-1`,children:(0,K.jsx)(yW,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`temperature`}),compact:!0})}),G.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&F(`printers:control`)&&(0,K.jsx)(`button`,{disabled:!!(t.dry_sf_reason?.length&&t.dry_time===0),onClick:e=>{if(t.dry_time>0)Dn.mutate(t.id);else if(Ue===t.id)We(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;Je(n),Xe(r[i]||r.n3f),Qe(i===`n3s`?r.n3s_hours:r.n3f_hours),et(!1),Ke(t.module_type),We(t.id),nt(jp({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:uW,estimatedHeight:dW,horizontalAlign:`center`}))}},className:`ml-1 flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:t.dry_sf_reason?.length?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:t.dry_time>0?j(`printers.drying.stop`):t.dry_sf_reason?.length?j(`printers.drying.powerRequired`):j(`printers.drying.start`),children:(0,K.jsx)(ac,{className:`w-3 h-3`})})]})]}),t.dry_time>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-amber-500/10 px-2 py-1 text-[9px]`,children:[(0,K.jsx)(ac,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-amber-400 font-medium`,children:j(`printers.drying.active`)}),(0,K.jsx)(`span`,{className:`text-amber-300/70`,children:j(`printers.drying.timeRemaining`,{time:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`})}),(0,K.jsx)(`button`,{onClick:()=>Dn.mutate(t.id),disabled:Dn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50`,title:j(`printers.drying.stop`),children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]}),(0,K.jsx)(`div`,{className:`grid w-full grid-cols-[repeat(4,minmax(3.5rem,1fr))] gap-1`,children:[0,1,2,3].map(r=>{let a=t.tray[r]||t.tray.find(e=>e.id===r),_=a?.tray_type&&a.remain>=0,v=!a?.tray_type,y=bW(a),b=t.id*4+r,x=tn===b,S=a?.tray_info_idx?Lt?.[a.tray_info_idx]:null,C=Rt?.[b],w=(a?.tray_uuid||a?.tag_uid||Hf(e.serial_number,t.id,r))?.toUpperCase(),T=w?s?.[w]:void 0,E=zf(T),D=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===r):void 0,O=D?f?.find(e=>e.id===D.spoolman_spool_id):void 0,k=O&&(O.label_weight??0)>0?Math.round(Math.max(0,(O.label_weight??0)-O.weight_used)/(O.label_weight??1)*100):null,A=u?.(e.id,t.id,r),M=(()=>{let e=A?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),N=M===0&&_&&a.remain>0?null:M,P=E??k??N??(_?a.remain:null),I=E!==null||k!==null?`spoolman`:N===null?_?`ams`:void 0:`inventory`,L=a?.tray_type?{vendor:Xf(a)?`Bambu Lab`:`Generic`,profile:C?.preset_name||(O?[O.brand,O.slicer_filament_name?.split(`@`)[0].trim()||O.material].filter(Boolean).join(` `).trim():null)||A?.spool?.slicer_filament_name||S?.name||a.tray_sub_brands||a.tray_type,colorName:Gd(a.tray_color||``),colorHex:a.tray_color||null,kFactor:fW(a.k),fillLevel:P,trayUuid:a.tray_uuid||null,tagUid:a.tag_uid||null,fillSource:I}:null,R=nr?.amsId===t.id&&nr?.slotId===r,z=g.indexOf(b),B=z>=0?`P${z+1}`:null,V=(0,K.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${v?`opacity-50`:``} ${x?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[B&&(0,K.jsx)(`span`,{"aria-label":j(`printers.activeJobSlot.ariaLabel`,{n:z+1}),title:j(`printers.activeJobSlot.title`,{n:z+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[8px] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:B}),(0,K.jsx)(lW,{trayColor:a?.tray_color,trayType:a?.tray_type,isEmpty:v,emptyKind:y,slotNumber:r+1}),(0,K.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:a?.tray_type||j(y===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:P!==null&&P>=0&&!v&&a&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${P}%`,backgroundColor:Rf(P)}})})]});return(0,K.jsxs)(`div`,{className:`relative group w-full ${i}`,children:[R&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-green animate-spin`})}),L?(0,K.jsx)(fU,{data:L,actions:Nr({amsId:t.id,slotId:r,loadTrayId:t.id*4+r,isRefreshing:R}),spoolman:{enabled:o,linkedSpoolId:D?.spoolman_spool_id??(w?s?.[w]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!D&&!A?()=>{let n=(L.trayUuid||L.tagUid||Hf(e.serial_number,t.id,r)).toUpperCase();mt({tagUid:L.tagUid||n,trayUuid:L.trayUuid||``,printerId:e.id,amsId:t.id,trayId:r})}:void 0,onUnlinkSpool:T?.id?()=>Tn.mutate(T.id):void 0},inventory:(()=>{if(o){if(m)return;let n=D,i=O;return{assignedSpool:i?{id:i.id,material:i.material,brand:i.brand??null,color_name:i.color_name??null,remainingWeightGrams:i.label_weight?Math.max(0,Math.round(i.label_weight-i.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:a?.tray_type||L.profile,material:a?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:i&&!Xf(a)?()=>h?.(i.id):void 0,isAssigned:!!n||Xf(a)}}let n=u?.(e.id,t.id,r);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:a?.tray_type||L.profile,material:a?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),onUnassignSpool:n&&!Xf(a)?()=>d?.(e.id,t.id,r):void 0,isAssigned:!!n||Xf(a)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:r,trayCount:t.tray.length,trayType:a?.tray_type||void 0,trayColor:a?.tray_color||void 0,traySubBrands:a?.tray_sub_brands||void 0,trayInfoIdx:a?.tray_info_idx||void 0,extruderId:n,caliIdx:a?.cali_idx,savedPresetId:C?.preset_id})},children:V}):(0,K.jsx)(pU,{kind:y??void 0,actions:Nr({amsId:t.id,slotId:r,loadTrayId:t.id*4+r,isRefreshing:R}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:r,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:r,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`${Af(t.id,t.tray.length)} Slot ${r+1}`}}),children:V})]},r)})})]},t.id)}),n.map(t=>{let n=Xt[String(t.id)],i=t.id>=128?t.id-128:t.id,_=n===void 0?i:n,v=_===1,y=_===0,b=t.tray[0],S=b?.tray_type&&b.remain>=0,C=!b?.tray_type,w=bW(b),T=Lf(t.id,b?.id??0,!1),E=tn===T,D=b?.tray_info_idx?Lt?.[b.tray_info_idx]:null,O=Rt?.[T],k=b?.id??0,A=(b?.tray_uuid||b?.tag_uid||Hf(e.serial_number,t.id,k))?.toUpperCase(),M=A?s?.[A]:void 0,N=zf(M),P=u?.(e.id,t.id,k),I=(()=>{let e=P?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),L=I===0&&S&&b.remain>0?null:I,R=o&&!m?p?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===k):void 0,z=R?f?.find(e=>e.id===R.spoolman_spool_id):void 0,B=z&&(z.label_weight??0)>0?Math.round(Math.max(0,(z.label_weight??0)-z.weight_used)/(z.label_weight??1)*100):null,V=N??B??L??(S?b.remain:null),ee=N!==null||B!==null?`spoolman`:L===null?S?`ams`:void 0:`inventory`,te=b?.tray_type?{vendor:Xf(b)?`Bambu Lab`:`Generic`,profile:O?.preset_name||(z?[z.brand,z.slicer_filament_name?.split(`@`)[0].trim()||z.material].filter(Boolean).join(` `).trim():null)||P?.spool?.slicer_filament_name||D?.name||b.tray_sub_brands||b.tray_type,colorName:Gd(b.tray_color||``),colorHex:b.tray_color||null,kFactor:fW(b.k),fillLevel:V,trayUuid:b.tray_uuid||null,tagUid:b.tag_uid||null,fillSource:ee}:null,ne=nr?.amsId===t.id&&nr?.slotId===k,re=g.indexOf(T),ie=re>=0?`P${re+1}`:null,H=(0,K.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${C?`opacity-50`:``} ${E?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[ie&&(0,K.jsx)(`span`,{"aria-label":j(`printers.activeJobSlot.ariaLabel`,{n:re+1}),title:j(`printers.activeJobSlot.title`,{n:re+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[8px] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:ie}),(0,K.jsx)(lW,{trayColor:b?.tray_color,trayType:b?.tray_type,isEmpty:C,emptyKind:w,slotNumber:1}),(0,K.jsx)(`div`,{className:`text-[9px] text-white font-bold truncate`,children:b?.tray_type||j(w===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:V!==null&&V>=0&&!C&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${V}%`,backgroundColor:Rf(V)}})})]});return(0,K.jsxs)(`div`,{style:{flex:`1 1 11rem`,minWidth:`11rem`},className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,K.jsx)(OW,{ams:t,printerId:e.id,label:Af(t.id,t.tray.length),amsLabels:Ht,canEdit:F(`printers:update`),onSaved:Ut,children:(0,K.jsx)(`span`,{className:`block truncate text-[10px] text-white font-medium cursor-default select-none`,children:Ht?.[t.id]||Af(t.id,t.tray.length)})}),r&&(v||y)&&(0,K.jsx)(pW,{side:v?`L`:`R`})]}),G.supports_drying&&(t.module_type===`n3f`||t.module_type===`n3s`)&&F(`printers:control`)&&(0,K.jsx)(`div`,{className:`relative ml-auto`,children:(0,K.jsx)(`button`,{onClick:e=>{if(t.dry_time>0)Dn.mutate(t.id);else if(Ue===t.id)We(null);else{let n=(t.tray.find(e=>e.tray_type)?.tray_type||`PLA`).split(` `)[0].toUpperCase(),r=x[n]||x.PLA,i=t.module_type;Je(n),Xe(r[i]||r.n3f),Qe(i===`n3s`?r.n3s_hours:r.n3f_hours),et(!1),Ke(t.module_type),We(t.id),nt(jp({triggerRect:e.currentTarget.getBoundingClientRect(),popoverWidth:uW,estimatedHeight:dW,horizontalAlign:`center`}))}},className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[9px] transition-colors ${t.dry_time>0?`bg-amber-500/20 text-amber-400`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:t.dry_time>0?j(`printers.drying.stop`):j(`printers.drying.start`),children:(0,K.jsx)(ac,{className:`w-3 h-3`})})})]}),t.dry_time>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-hidden whitespace-nowrap rounded-lg bg-amber-500/10 px-2 py-1 text-[9px]`,children:[(0,K.jsx)(ac,{className:`w-3 h-3 text-amber-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-amber-300/70 text-[8px] truncate`,children:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`}),(0,K.jsx)(`button`,{onClick:()=>Dn.mutate(t.id),disabled:Dn.isPending,className:`ml-auto text-amber-400 hover:text-amber-300 transition-colors disabled:opacity-50 shrink-0`,title:j(`printers.drying.stop`),children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5 max-[550px]:flex-col max-[550px]:items-start`,children:[(0,K.jsxs)(`div`,{className:`relative group min-w-14 flex-1`,children:[ne&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-green animate-spin`})}),te?(0,K.jsx)(fU,{data:te,actions:Nr({amsId:t.id,slotId:k,loadTrayId:t.id*4+k,isRefreshing:ne}),spoolman:{enabled:o,linkedSpoolId:R?.spoolman_spool_id??(A?s?.[A]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!R&&!P?()=>{let n=(te.trayUuid||te.tagUid||Hf(e.serial_number,t.id,k)).toUpperCase();mt({tagUid:te.tagUid||n,trayUuid:te.trayUuid||``,printerId:e.id,amsId:t.id,trayId:k})}:void 0,onUnlinkSpool:M?.id?()=>Tn.mutate(M.id):void 0},inventory:(()=>{if(o){if(m)return;let n=R,r=z;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:b?.tray_type||te.profile,material:b?.tray_type??void 0,profile:te.profile,color:te.colorHex||``,location:Af(t.id,t.tray.length)}}),onUnassignSpool:r&&!Xf(b)?()=>h?.(r.id):void 0,isAssigned:!!n||Xf(b)}}let n=u?.(e.id,t.id,k);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:b?.tray_type||te.profile,material:b?.tray_type??void 0,profile:te.profile,color:te.colorHex||``,location:Af(t.id,t.tray.length)}}),onUnassignSpool:n&&!Xf(b)?()=>d?.(e.id,t.id,k):void 0,isAssigned:!!n||Xf(b)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:k,trayCount:t.tray.length,trayType:b?.tray_type||void 0,trayColor:b?.tray_color||void 0,traySubBrands:b?.tray_sub_brands||void 0,trayInfoIdx:b?.tray_info_idx||void 0,extruderId:n,caliIdx:b?.cali_idx,savedPresetId:O?.preset_id})},children:H}):(0,K.jsx)(pU,{kind:w??void 0,actions:Nr({amsId:t.id,slotId:k,loadTrayId:t.id*4+k,isRefreshing:ne}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:t.id,trayId:k,trayCount:t.tray.length,extruderId:n})},onAssignSpool:()=>gt({printerId:e.id,amsId:t.id,trayId:k,trayInfo:{type:``,material:void 0,profile:``,color:``,location:Af(t.id,t.tray.length)}}),children:H})]}),(t.humidity!=null||t.temp!=null)&&(0,K.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full`,children:[t.temp!=null&&(0,K.jsx)(yW,{temp:t.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`temperature`}),compact:!0}),t.humidity!=null&&(0,K.jsx)(vW,{humidity:t.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ut({amsId:t.id,amsLabel:Af(t.id,t.tray.length),mode:`humidity`}),compact:!0})]})]})]},t.id)}),G.vt_tray.length>0&&(0,K.jsxs)(`div`,{style:_(G.vt_tray.length),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,K.jsx)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:(0,K.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-[10px] text-white font-medium`,children:j(`printers.external`)})}),(0,K.jsx)(`div`,{className:`grid w-full ${G.vt_tray.length>1?`grid-cols-[repeat(2,minmax(3.5rem,1fr))]`:`grid-cols-[minmax(3.5rem,1fr)]`} gap-1`,children:[...G.vt_tray].sort((e,t)=>(e.id??254)-(t.id??254)).map(t=>{let n=t.id??254,a=r&&tn===254?n===254&&G.active_extruder===1||n===255&&G.active_extruder===0:tn===n,g=n-254,_=r?j(n===254?`printers.extL`:`printers.extR`):``,v=t.tray_info_idx?Lt?.[t.tray_info_idx]:null,y=Rt?.[1020+g],b=(t.tray_uuid||t.tag_uid||Hf(e.serial_number,255,g))?.toUpperCase(),x=b?s?.[b]:void 0,S=zf(x),C=u?.(e.id,255,g),w=(()=>{let e=C?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),T=t.tray_type&&t.remain>=0,E=w===0&&T&&t.remain>0?null:w,D=o&&!m?p?.find(t=>t.printer_id===e.id&&t.ams_id===255&&t.tray_id===g):void 0,O=D?f?.find(e=>e.id===D.spoolman_spool_id):void 0,k=O&&(O.label_weight??0)>0?Math.round(Math.max(0,(O.label_weight??0)-O.weight_used)/(O.label_weight??1)*100):null,A=S??k??E??(T?t.remain:null),M=S!==null||k!==null?`spoolman`:E===null?T?`ams`:void 0:`inventory`,N={vendor:Xf(t)?`Bambu Lab`:`Generic`,profile:y?.preset_name||(O?[O.brand,O.slicer_filament_name?.split(`@`)[0].trim()||O.material].filter(Boolean).join(` `).trim():null)||C?.spool?.slicer_filament_name||v?.name||t.tray_sub_brands||t.tray_type||`Unknown`,colorName:Gd(t.tray_color||``),colorHex:t.tray_color||null,kFactor:fW(t.k),fillLevel:A,trayUuid:t.tray_uuid||null,tagUid:t.tag_uid||null,fillSource:M},P=!t.tray_type,I=bW(t),L=(0,K.jsxs)(`div`,{className:`w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${P?`opacity-50`:``} ${a?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,K.jsx)(lW,{trayColor:t.tray_color,trayType:t.tray_type,isEmpty:P,emptyKind:I,slotNumber:g+1}),(0,K.jsx)(`div`,{className:`text-[9px] font-bold truncate ${P?`text-white/40`:`text-white`}`,children:t.tray_type||j(`ams.slotEmpty`)}),(0,K.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:A!==null&&A>=0&&!P&&(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${A}%`,backgroundColor:Rf(A)}})}),_&&(0,K.jsx)(`div`,{className:`text-[7px] text-white/40 mt-0.5 truncate`,children:_})]});return(0,K.jsx)(`div`,{className:`relative group w-full ${i}`,children:P?(0,K.jsx)(pU,{kind:I??void 0,actions:Nr({amsId:255,slotId:g,loadTrayId:n,includeRfid:!1}),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:255,trayId:g,trayCount:1,extruderId:r?+(n===254):void 0})},onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`External Slot ${g+1}`}}),children:L}):(0,K.jsx)(fU,{data:N,actions:Nr({amsId:255,slotId:g,loadTrayId:n,includeRfid:!1}),spoolman:{enabled:o,linkedSpoolId:D?.spoolman_spool_id??(b?s?.[b]?.id:void 0),spoolmanUrl:c,syncMode:l,onLinkSpool:o&&!D&&!C?()=>{let t=(N.trayUuid||N.tagUid||Hf(e.serial_number,255,g)).toUpperCase();mt({tagUid:N.tagUid||t,trayUuid:N.trayUuid||``,printerId:e.id,amsId:255,trayId:g})}:void 0,onUnlinkSpool:x?.id?()=>Tn.mutate(x.id):void 0},inventory:(()=>{if(o){if(m)return;let n=D,r=O;return{assignedSpool:r?{id:r.id,material:r.material,brand:r.brand??null,color_name:r.color_name??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:_||j(`printers.external`)}}),onUnassignSpool:r&&!Xf(t)?()=>h?.(r.id):void 0,isAssigned:!!n||Xf(t)}}let n=u?.(e.id,255,g);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,brand:n.spool.brand,color_name:n.spool.color_name,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>gt({printerId:e.id,amsId:255,trayId:g,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:_||j(`printers.external`)}}),onUnassignSpool:n&&!Xf(t)?()=>d?.(e.id,255,g):void 0,isAssigned:!!n||Xf(t)}})(),configureSlot:{enabled:F(`printers:control`),onConfigure:()=>vt({amsId:255,trayId:g,trayCount:1,trayType:t.tray_type||void 0,trayColor:t.tray_color||void 0,traySubBrands:t.tray_sub_brands||void 0,trayInfoIdx:t.tray_info_idx||void 0,extruderId:r?+(n===254):void 0,caliIdx:t.cali_idx,savedPresetId:y?.preset_id})},children:L})},n)})})]})]})]})})()]}),r===`expanded`&&(0,K.jsxs)(`div`,{className:`mt-auto`,children:[nn&&(0,K.jsxs)(`div`,{className:`pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:j(`printers.power`,`Power`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 rounded-[10px] bg-bambu-dark p-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 pl-1`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate`,children:nn.name}),(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-[10px] font-medium flex-shrink-0`,title:j(`smartPlugs.power`),children:an?.energy?.power!==null&&an?.energy?.power!==void 0?`${Math.round(an.energy.power)}W`:`--`})]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>An.mutate(!nn.auto_off),disabled:An.isPending||nn.auto_off_executed||!F(`smart_plugs:control`),title:F(`smart_plugs:control`)?nn.auto_off_executed?j(`printers.autoOffExecuted`):j(`printers.autoOffAfterPrint`):j(`printers.permission.noSmartPlugControl`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs font-bold transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${F(`smart_plugs:control`)?nn.auto_off||nn.auto_off_executed?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,children:(0,K.jsx)(Ss,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{an?.state===`ON`?se(!0):oe(!0)},disabled:kn.isPending||!F(`smart_plugs:control`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${F(`smart_plugs:control`)?an?.state===`ON`?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,title:F(`smart_plugs:control`)?an?.state===`ON`?`Turn off`:`Turn on`:j(`printers.permission.noSmartPlugControl`),children:(0,K.jsx)(Bu,{className:`w-4 h-4`})})]})]}),rn&&rn.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,K.jsx)(Ac,{className:`w-3.5 h-3.5 text-blue-400 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`HA:`}),(0,K.jsx)(`div`,{className:`h-[2px] w-5 bg-bambu-dark-tertiary/50`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:rn.map(e=>{let t=e.ha_entity_id?.startsWith(`script.`);return(0,K.jsxs)(`button`,{onClick:()=>{t?jn.mutate({id:e.id,action:`on`}):le(e)},disabled:jn.isPending,title:`${t?`Run`:`Toggle`} ${e.ha_entity_id}`,className:`px-2 py-0.5 text-xs bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1`,children:[(0,K.jsx)(bl,{className:`w-2.5 h-2.5`}),e.name]},e.id)})})]})]}),(0,K.jsxs)(`div`,{className:`pt-4`,children:[(0,K.jsx)(`div`,{className:`mb-3 h-[2px] bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[Pr,(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{if(_===`embedded`&&v)v(e.id,e.name);else{let t=localStorage.getItem(`cameraWindowState`),n=t?JSON.parse(t):{width:640,height:400},r=[`width=${n.width}`,`height=${n.height}`,n.left===void 0?``:`left=${n.left}`,n.top===void 0?``:`top=${n.top}`,`menubar=no,toolbar=no,location=no,status=no`].filter(Boolean).join(`,`);window.open(`/camera/${e.id}`,`camera-${e.id}`,r)}},disabled:!G?.connected||!F(`camera:view`),title:F(`camera:view`)?j(_===`embedded`?`printers.openCameraOverlay`:`printers.openCameraWindow`):j(`printers.permission.noCamera`),className:Mr,children:(0,K.jsx)(Au,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>re(!0),disabled:!Jt||!F(`printers:files`),title:F(`printers:files`)?j(`printers.browseFiles`):j(`printers.permission.noFiles`),className:Mr,children:(0,K.jsx)(wc,{className:`w-4 h-4`})}),Jt&&G?.state!==`RUNNING`&&G?.state!==`PAUSE`&&(0,K.jsxs)($,{size:`sm`,onClick:()=>Fe(!0),disabled:!F(`printers:control`),title:F(`printers:control`)?j(`common.print`):j(`printers.permission.noControl`),className:`!h-8 !min-h-8 !px-2 !py-0 !bg-bambu-green hover:!bg-bambu-green/80 !text-white`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),j(`common.print`)]})]})]})]})]})]}),ne&&(0,K.jsx)(cle,{printerId:e.id,printerName:e.name,onClose:()=>re(!1)}),Pe&&(0,K.jsx)(qU,{folderId:null,onClose:()=>Fe(!1),onUploadComplete:()=>{},autoUpload:!0,accept:`.gcode,.3mf`,validateFile:e=>{let t=e.name.toLowerCase();if(!t.endsWith(`.gcode`)&&!t.includes(`.gcode.`))return j(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`)},onFileUploaded:t=>{let n=t.metadata?.sliced_for_model,r=DW(e.model);if(n&&r&&n.toLowerCase()!==r.toLowerCase())return Q.deleteLibraryFile(t.id).catch(()=>{}),j(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:n,printerModel:r});He({id:t.id,filename:t.filename})}}),Ve&&(0,K.jsx)(sW,{mode:`reprint`,libraryFileId:Ve.id,archiveName:Ve.filename,initialSelectedPrinterIds:[e.id],onClose:()=>He(null),onSuccess:()=>He(null),cleanupLibraryAfterDispatch:!0}),ie&&(0,K.jsx)(hle,{printerId:e.id,printerName:e.name,onClose:()=>H(!1)}),Re&&(0,K.jsx)(ip,{printerId:e.id,printerName:e.name,onClose:()=>ze(!1)}),Ie&&(0,K.jsx)(xke,{printer:e,status:G,totalPrintHours:n?.total_print_hours,onClose:Be}),xt&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>_r(),children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[xt.needs_calibration?(0,K.jsx)(Il,{className:`w-5 h-5 text-blue-500`}):xt.is_empty?(0,K.jsx)(ps,{className:`w-5 h-5 text-green-500`}):(0,K.jsx)(ys,{className:`w-5 h-5 text-yellow-500`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`Build Plate Check`}),xt.reference_count!==void 0&&xt.max_references&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[xt.reference_count,`/`,xt.max_references,` refs`]})]}),(0,K.jsx)(`button`,{onClick:()=>_r(),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[xt.needs_calibration?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 rounded-lg bg-blue-500/20 border border-blue-500/50`,children:[(0,K.jsx)(`p`,{className:`font-medium text-blue-400`,children:j(`printers.plateDetection.calibrationRequired`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,dangerouslySetInnerHTML:{__html:j(`printers.plateDetection.calibrationInstructions`)}})]}),(0,K.jsxs)(`div`,{className:`text-sm text-bambu-gray space-y-2`,children:[(0,K.jsx)(`p`,{children:j(`printers.plateDetection.calibrationDescription`)}),(0,K.jsx)(`p`,{dangerouslySetInnerHTML:{__html:j(`printers.plateDetection.calibrationTip`)}})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 rounded-lg ${xt.is_empty?`bg-green-500/20 border border-green-500/50`:`bg-yellow-500/20 border border-yellow-500/50`}`,children:[(0,K.jsx)(`p`,{className:`font-medium ${xt.is_empty?`text-green-400`:`text-yellow-400`}`,children:xt.is_empty?j(`printers.plateDetection.plateEmpty`):j(`printers.plateDetection.objectsDetected`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:[j(`printers.plateDetection.confidence`),`: `,Math.round(xt.confidence*100),`% | `,j(`printers.plateDetection.difference`),`: `,xt.difference_percent.toFixed(1),`%`]})]}),xt.debug_image_url&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:j(`printers.plateDetection.analysisPreview`)}),(0,K.jsx)(`img`,{src:xt.debug_image_url,alt:j(`printers.plateDetection.analysisPreview`),className:`w-full rounded-lg border border-bambu-dark-tertiary`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:j(`printers.plateDetection.analysisLegend`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:xt.message})]}),ur&&ur.references.length>0&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:j(`printers.plateDetection.savedReferences`,{count:ur.references.length,max:ur.max_references})}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:ur.references.map(t=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`img`,{src:Q.getPlateReferenceThumbnailUrl(e.id,t.index),alt:t.label||`Reference ${t.index+1}`,className:`w-full aspect-video object-cover rounded border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{onClick:()=>br(t.index),className:`absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity`,title:j(`printers.plateDetection.deleteReference`),children:(0,K.jsx)(Ru,{className:`w-3 h-3 text-white`})}),fr?.index===t.index?(0,K.jsx)(`input`,{type:`text`,value:fr.label,onChange:e=>pr({...fr,label:e.target.value}),onBlur:()=>yr(t.index,fr.label),onKeyDown:e=>{e.key===`Enter`&&yr(t.index,fr.label),e.key===`Escape`&&pr(null)},className:`w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white`,autoFocus:!0,placeholder:j(`printers.plateDetection.labelPlaceholder`)}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white`,onClick:()=>pr({index:t.index,label:t.label}),title:t.label?j(`printers.plateDetection.clickToEdit`,{label:t.label}):j(`printers.plateDetection.clickToAddLabel`),children:t.label||(0,K.jsx)(`span`,{className:`italic opacity-50`,children:j(`printers.noLabel`)})}),(0,K.jsx)(`p`,{className:`text-[10px] text-bambu-gray/60`,children:t.timestamp?vf(t.timestamp)?.toLocaleDateString()??``:``})]},t.index))})]}),!xt.needs_calibration&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:j(`printers.roi.title`)}),(0,K.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),Dt?(0,K.jsxs)(`div`,{className:`flex gap-1`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>Ot(null),disabled:kt,children:j(`common.cancel`)}),(0,K.jsx)($,{size:`sm`,onClick:xr,disabled:kt,children:kt?(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}):j(`common.save`)})]}):(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>Ot(xt.roi||{x:.15,y:.35,w:.7,h:.55}),children:[(0,K.jsx)(vl,{className:`w-3 h-3 mr-1`}),j(`common.edit`)]})]}),Dt?(0,K.jsxs)(`div`,{className:`space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.xStart`)}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Dt.x,onChange:e=>Ot({...Dt,x:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.x*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.yStart`)}),(0,K.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Dt.y,onChange:e=>Ot({...Dt,y:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.y*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.width`)}),(0,K.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Dt.w,onChange:e=>Ot({...Dt,w:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.w*100),`%`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:j(`printers.height`)}),(0,K.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Dt.h,onChange:e=>Ot({...Dt,h:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Dt.h*100),`%`]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:j(`printers.roi.instruction`)})]}):(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Current: X=`,Math.round((xt.roi?.x||.15)*100),`%, Y=`,Math.round((xt.roi?.y||.35)*100),`%, W=`,Math.round((xt.roi?.w||.7)*100),`%, H=`,Math.round((xt.roi?.h||.55)*100),`%`]})]})]}),(0,K.jsx)(`div`,{className:`flex justify-end gap-2 p-4`,children:xt.needs_calibration?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>_r(),children:j(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>vr(),disabled:Tt,children:Tt?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),`Calibrating...`]}):`Calibrate Empty Plate`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>vr(),disabled:Tt,children:Tt?`Adding...`:`Add Reference (${ur?.references.length||0}/${ur?.max_references||5})`}),(0,K.jsx)($,{onClick:()=>_r(),children:`Close`})]})})]})}),ae&&nn&&(0,K.jsx)(Ad,{title:j(`printers.confirm.powerOnTitle`),message:j(`printers.confirm.powerOnMessage`,{name:e.name}),confirmText:j(`printers.confirm.powerOnButton`),variant:`default`,onConfirm:()=>{kn.mutate(`on`),oe(!1)},onCancel:()=>oe(!1)}),Xn&&(0,K.jsx)(Ad,{title:j(`printers.maintenance.confirmMidPrintTitle`),message:j(`printers.maintenance.confirmMidPrintMessage`,{name:e.name}),confirmText:j(`printers.maintenance.menuEnter`),variant:`danger`,onConfirm:()=>{Yn.mutate(!1),Zn(!1)},onCancel:()=>Zn(!1)}),U&&nn&&(0,K.jsx)(Ad,{title:j(`printers.confirm.powerOffTitle`),message:G?.state===`RUNNING`?j(`printers.confirm.powerOffWarning`,{name:e.name}):j(`printers.confirm.powerOffMessage`,{name:e.name}),confirmText:j(`printers.confirm.powerOffButton`),variant:`danger`,onConfirm:()=>{kn.mutate(`off`),se(!1)},onCancel:()=>se(!1)}),ce&&(0,K.jsx)(Ad,{title:j(`printers.confirm.haToggleTitle`,{name:ce.name}),message:G?.state===`RUNNING`?j(`printers.confirm.haToggleWarning`,{name:e.name,entity:ce.ha_entity_id||ce.name}):j(`printers.confirm.haToggleMessage`,{entity:ce.ha_entity_id||ce.name}),confirmText:j(`printers.confirm.haToggleButton`),variant:G?.state===`RUNNING`?`danger`:`default`,onConfirm:()=>{jn.mutate({id:ce.id,action:`toggle`}),le(null)},onCancel:()=>le(null)}),me&&(0,K.jsx)(Ad,{title:j(`printers.confirm.stopTitle`),message:j(`printers.confirm.stopMessage`,{name:e.name}),confirmText:j(`printers.confirm.stopButton`),variant:`danger`,onConfirm:()=>{Mn.mutate(),he(!1)},onCancel:()=>he(!1)}),ge&&(0,K.jsx)(Ad,{title:j(`printers.confirm.pauseTitle`),message:j(`printers.confirm.pauseMessage`,{name:e.name}),confirmText:j(`printers.confirm.pauseButton`),variant:`default`,onConfirm:()=>{Nn.mutate(),_e(!1)},onCancel:()=>_e(!1)}),Ae&&(0,K.jsx)(Ad,{title:j(`printers.confirm.resumeTitle`),message:j(`printers.confirm.resumeMessage`,{name:e.name}),confirmText:j(`printers.confirm.resumeButton`),variant:`default`,onConfirm:()=>{Pn.mutate(),je(!1)},onCancel:()=>je(!1)}),Oe&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl w-full max-w-sm p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white mb-1`,children:j(`printers.bedJog.notHomedTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray leading-relaxed`,children:j(`printers.bedJog.notHomedMessage`)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{qn.mutate(`all`),ke(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors`,children:j(`printers.bedJog.homeZ`)}),(0,K.jsx)(`button`,{onClick:()=>{let t=Oe.distance;try{sessionStorage.setItem(`bambuddy.bedJog.warned.${e.id}`,`1`)}catch{}Wn.mutate({distance:t,force:!0}),ke(null)},className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/30 transition-colors`,children:j(`printers.bedJog.moveAnyway`)}),(0,K.jsx)(`button`,{onClick:()=>ke(null),className:`w-full px-3 py-2 rounded-lg text-xs font-medium bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary transition-colors`,children:j(`common.cancel`)})]})]})}),(0,K.jsx)(lT,{printerId:e.id,isOpen:Me,onClose:()=>Ne(!1)}),ue&&(0,K.jsx)(iee,{printerName:e.name,errors:G?.hms_errors||[],onClose:()=>de(!1),printerId:e.id,hasPermission:F}),fe&&G&&(0,K.jsx)(BOe,{isOpen:fe,state:G.ams_filament_backup,amsUnits:G.ams,amsExtruderMap:G.ams_extruder_map,isDualNozzle:e.nozzle_count===2||G?.temperatures?.nozzle_2!==void 0,canToggle:F(`printers:control`),pending:On.isPending,onToggle:e=>On.mutate(e),onClose:()=>pe(!1)}),lt&&(0,K.jsx)(IOe,{isOpen:!!lt,onClose:()=>ut(null),printerId:e.id,printerName:e.name,amsId:lt.amsId,amsLabel:lt.amsLabel,initialMode:lt.mode,thresholds:a}),dt&&(0,K.jsx)(HOe,{isOpen:!!dt,onClose:()=>ft(null),printerId:e.id,printerName:e.name,initialKind:dt.initialKind,availableKinds:dt.availableKinds}),pt&&(0,K.jsx)(mU,{isOpen:!!pt,onClose:()=>mt(null),tagUid:pt.tagUid,trayUuid:pt.trayUuid,printerId:pt.printerId,amsId:pt.amsId,trayId:pt.trayId}),ht&&(0,K.jsx)(gU,{isOpen:!!ht,onClose:()=>gt(null),printerId:ht.printerId,amsId:ht.amsId,trayId:ht.trayId,trayInfo:ht.trayInfo,spoolmanEnabled:!!o}),_t&&(0,K.jsx)(GU,{isOpen:!!_t,onClose:()=>vt(null),printerId:e.id,slotInfo:_t,printerModel:DW(e.model)||void 0,onSuccess:()=>{M.invalidateQueries({queryKey:[`slotPresets`,e.id]}),M.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),ee&&(0,K.jsx)(Vke,{printer:e,onClose:()=>te(!1)}),yt&&Nt&&(0,K.jsx)(Bke,{printer:e,firmwareInfo:Nt,onClose:()=>bt(!1)}),Ue!==null&&tt&&(()=>{let e=Ge===`n3s`?85:65,t=e+10;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[100]`,onClick:()=>We(null)}),(0,K.jsxs)(`div`,{className:`fixed z-[101] flex flex-col w-[240px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl overflow-hidden`,style:{top:tt.top,left:tt.left,maxHeight:`calc(100dvh - ${tt.top}px - 8px)`},onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`shrink-0 flex items-center justify-center gap-2 px-3 py-2.5`,children:[(0,K.jsx)(ac,{className:`w-3.5 h-3.5 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium text-center`,children:j(`printers.drying.start`)})]}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2.5 overflow-y-auto min-h-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium mb-1 block`,children:j(`printers.filaments`)}),(0,K.jsx)(xW,{value:qe,options:Object.keys(x).map(e=>({value:e,label:e})),onChange:e=>{Je(e);let t=x[e];t&&(Xe(t[Ge===`n3s`?`n3s`:`n3f`]),Qe(Ge===`n3s`?t.n3s_hours:t.n3f_hours))},fullWidth:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium`,children:j(`printers.drying.temperature`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:45,max:e,value:Ye,onChange:t=>Xe(Math.min(e,Math.max(45,Number(t.target.value)||45))),className:`w-12 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:`°C`})]})]}),(0,K.jsx)(`input`,{type:`range`,min:35,max:t,value:Ye,onChange:t=>Xe(Math.min(e,Math.max(45,Number(t.target.value)))),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,K.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,K.jsx)(`span`,{children:`45°C`}),(0,K.jsxs)(`span`,{children:[e,`°C`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium`,children:j(`printers.drying.duration`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:Ze,onChange:e=>Qe(Math.min(24,Math.max(1,Number(e.target.value)||1))),className:`w-10 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:j(`printers.drying.hours`)})]})]}),(0,K.jsx)(`input`,{type:`range`,min:1,max:24,value:Ze,onChange:e=>Qe(Number(e.target.value)),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,K.jsxs)(`div`,{className:`flex justify-between text-[9px] text-bambu-gray/50 mt-0.5`,children:[(0,K.jsx)(`span`,{children:`1h`}),(0,K.jsx)(`span`,{children:`24h`})]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>et(e=>!e),"aria-pressed":$e,className:`h-8 w-full rounded-lg border px-2 text-sm font-medium transition-colors ${$e?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:j(`printers.drying.rotateTray`)})]}),(0,K.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5 pb-3`,children:(0,K.jsx)(`button`,{onClick:()=>{Ue!==null&&En.mutate({amsId:Ue,temp:Ye,duration:Ze,filament:qe,rotateTray:$e})},disabled:En.isPending,className:`w-full py-1.5 bg-bambu-green hover:bg-bambu-green/80 text-white text-xs font-medium rounded-lg transition-colors disabled:opacity-50`,children:En.isPending?j(`printers.drying.startingDrying`):j(`printers.drying.start`)})})]})]})})()]})}function zke({onClose:e,onAdd:t,existingSerials:n}){let{t:r}=W(),[i,a]=(0,y.useState)({name:``,serial_number:``,ip_address:``,access_code:``,model:``,location:``,auto_archive:!0}),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(!1),[g,_]=(0,y.useState)([]),[v,b]=(0,y.useState)(``),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)({scanned:0,total:0}),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(null);(0,y.useEffect)(()=>{ed.getInfo().then(e=>{h(e.is_docker),e.subnets.length>0&&(_(e.subnets),b(e.subnets[0]))}).catch(()=>{});try{let e=localStorage.getItem(`bambuddy.discovery.customSubnet`);e&&S(e)}catch{}},[]);let N=c.filter(e=>!n.includes(e.serial)),P=async e=>{e.preventDefault(),A(!0);try{let e=await Q.diagnoseConnection({ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0});if(e.checks.some(e=>e.status===`fail`)){M(e);return}}catch{}finally{A(!1)}t(i)},F=async()=>{d(``),l([]),s(!0),p(!1),E({scanned:0,total:0});let e=C?x.trim():v,t=m||C;if(t&&C)try{localStorage.setItem(`bambuddy.discovery.customSubnet`,e)}catch{}try{if(t){await ed.startSubnetScan(e);let t=setInterval(async()=>{try{let e=await ed.getScanStatus();E({scanned:e.scanned,total:e.total}),l(await ed.getDiscoveredPrinters()),e.running||(clearInterval(t),s(!1),p(!0))}catch(e){console.error(`Failed to get scan status:`,e)}},500)}else{await ed.startDiscovery(10);let e=setInterval(async()=>{try{l(await ed.getDiscoveredPrinters())}catch(e){console.error(`Failed to get discovered printers:`,e)}},1e3);setTimeout(async()=>{clearInterval(e);try{await ed.stopDiscovery()}catch{}s(!1),p(!0);try{l(await ed.getDiscoveredPrinters())}catch(e){console.error(`Failed to get final discovered printers:`,e)}},1e4)}}catch(e){console.error(`Failed to start discovery:`,e),d(e instanceof Error?e.message:r(`printers.discovery.failedToStart`)),s(!1),p(!0)}},I=e=>{let t=e.serial.startsWith(`unknown-`)?``:e.serial;a({...i,name:e.name||``,serial_number:t,ip_address:e.ip_address,model:DW(e.model)}),l([])};return(0,y.useEffect)(()=>()=>{ed.stopDiscovery().catch(()=>{}),ed.stopSubnetScan().catch(()=>{})},[]),(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:e,children:(0,K.jsx)(_d,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:r(`printers.addPrinter`)}),(0,K.jsxs)(`div`,{className:`mb-4 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.discovery.subnetToScan`)}),g.length>0?(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:C?`__custom__`:v,onChange:e=>{e.target.value===`__custom__`?w(!0):(w(!1),b(e.target.value))},disabled:o,children:[g.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:`__custom__`,children:r(`printers.discovery.customSubnetOption`)})]}):(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:v,onChange:e=>b(e.target.value),placeholder:`192.168.1.0/24`,disabled:o}),C&&(0,K.jsx)(`input`,{type:`text`,"aria-label":r(`printers.discovery.customSubnetLabel`),className:`mt-2 w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:x,onChange:e=>S(e.target.value),placeholder:`10.1.1.0/24`,disabled:o}),(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:r(m?`printers.discovery.dockerNote`:`printers.discovery.customSubnetNote`)})]}),(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:F,disabled:o,className:`w-full`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(m||C)&&T.total>0?r(`printers.discovery.scanProgress`,{scanned:T.scanned,total:T.total}):r(`printers.discovery.scanning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Rl,{className:`w-4 h-4`}),r(m||C?`printers.discovery.scanSubnet`:`printers.discovery.discoverNetwork`)]})}),u&&(0,K.jsx)(`div`,{className:`mt-2 text-sm text-red-400`,children:u}),N.length>0&&(0,K.jsx)(`div`,{className:`mt-3 space-y-2 max-h-40 overflow-y-auto`,children:N.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors`,onClick:()=>I(e),children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium text-white text-sm truncate`,children:e.name||e.serial}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[DW(e.model)||r(`printers.discovery.unknown`),` • `,e.ip_address,e.serial.startsWith(`unknown-`)&&(0,K.jsxs)(`span`,{className:`text-yellow-500`,children:[` • `,r(`printers.discovery.serialRequired`)]})]})]}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2`})]},e.serial))}),o&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.scanningSubnet`:`printers.discovery.scanningNetwork`)}),f&&!o&&c.length===0&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(m||C?`printers.discovery.noPrintersFoundSubnet`:`printers.discovery.noPrintersFoundNetwork`)}),f&&!o&&c.length>0&&N.length===0&&(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(`printers.discovery.allConfigured`)})]}),(0,K.jsxs)(`form`,{onSubmit:P,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.name`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.name,onChange:e=>a({...i,name:e.target.value}),placeholder:r(`printers.modal.myPrinter`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.ipAddress`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[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])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.ip_address,onChange:e=>a({...i,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.serialNumber`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.serial_number,onChange:e=>a({...i,serial_number:e.target.value}),placeholder:`01P00A000000000`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.accessCode`)}),(0,K.jsx)(`input`,{type:`password`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.access_code,onChange:e=>a({...i,access_code:e.target.value}),placeholder:r(`printers.modal.fromPrinterSettings`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.modelOptional`)}),(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.model||``,onChange:e=>a({...i,model:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:r(`printers.modal.selectModel`)}),(0,K.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,K.jsx)(`option`,{value:`A1`,children:`A1`}),(0,K.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,K.jsx)(`optgroup`,{label:`A2 Series`,children:(0,K.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,K.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,K.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,K.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,K.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,K.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,K.jsxs)(`optgroup`,{label:`P Series`,children:[(0,K.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,K.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,K.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,K.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,K.jsx)(`option`,{value:`X1`,children:`X1`}),(0,K.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,K.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,K.jsx)(`optgroup`,{label:`X2 Series`,children:(0,K.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.locationGroup`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:i.location||``,onChange:e=>a({...i,location:e.target.value}),placeholder:r(`printers.modal.locationPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`printers.locationHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`auto_archive`,checked:i.auto_archive,onChange:e=>a({...i,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`auto_archive`,className:`text-sm text-bambu-gray`,children:r(`printers.modal.autoArchiveLabel`)})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>O(!0),disabled:!i.ip_address.trim(),className:`w-full flex items-center justify-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white disabled:opacity-40 disabled:cursor-not-allowed border border-bambu-dark-tertiary rounded-lg transition-colors`,children:[(0,K.jsx)(cu,{className:`w-4 h-4`}),r(`diagnostic.runButton`)]}),j?(0,K.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,K.jsx)(`p`,{className:`text-sm text-amber-300`,children:r(`printers.addPreflight.warning`)})]}),(0,K.jsx)(np,{result:j}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>M(null),className:`flex-1`,children:r(`printers.addPreflight.back`)}),(0,K.jsx)($,{type:`button`,onClick:()=>t(i),className:`flex-1`,children:r(`printers.addPreflight.saveAnyway`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:k,className:`flex-1`,children:r(k?`printers.addPreflight.checking`:`printers.addPrinter`)})]})]})]})})}),D&&(0,K.jsx)(ip,{connection:{ip_address:i.ip_address.trim(),serial_number:i.serial_number.trim()||void 0,access_code:i.access_code||void 0},printerName:i.name||null,onClose:()=>O(!1)})]})}function Bke({printer:e,firmwareInfo:t,onClose:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),{hasPermission:o}=dd(),s=o(`firmware:update`),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(t.update_available?t.latest_version:null),{data:g,isLoading:_}=q({queryKey:[`firmwarePrepare`,e.id,m],queryFn:()=>id.prepareUpload(e.id,m??void 0),staleTime:3e4,enabled:!!m&&s&&!u}),v=J({mutationFn:()=>id.startUpload(e.id,m??void 0),onSuccess:()=>{d(!0);let t=setInterval(async()=>{try{let n=await id.getUploadStatus(e.id);l(n),(n.status===`complete`||n.status===`error`)&&(clearInterval(t),p(null),d(!1),n.status===`complete`&&(a(r(`printers.firmwareModal.uploadedToast`),`success`),i.invalidateQueries({queryKey:[`firmwareUpdate`,e.id]})))}catch{}},2e3);p(t)},onError:e=>{a(r(`printers.firmwareModal.uploadFailed`,{error:e.message}),`error`),d(!1)}});return(0,y.useEffect)(()=>()=>{f&&clearInterval(f)},[f]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsx)(_d,{className:`w-full max-w-md mx-4`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full ${t.update_available?`bg-orange-500/20`:`bg-status-ok/20`}`,children:t.update_available?(0,K.jsx)(Vs,{className:`w-5 h-5 text-orange-400`}):(0,K.jsx)(ps,{className:`w-5 h-5 text-status-ok`})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t.update_available?r(`printers.firmwareModal.title`):r(`printers.firmwareModal.titleUpToDate`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e.name})]})]}),(()=>{let e=m?t.available_versions?.find(e=>e.version===m):null,n=m??t.latest_version,i=e?.release_notes??t.release_notes,a=!!n&&n!==t.current_version;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.currentVersion`)}),(0,K.jsx)(`span`,{className:`font-mono ${a?`text-white`:`text-status-ok`}`,children:t.current_version||r(`common.unknown`)})]}),a&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm mt-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.latestVersion`)}),(0,K.jsx)(`span`,{className:`text-orange-400 font-mono`,children:n})]}),i&&(0,K.jsxs)(`details`,{className:`mt-3 text-sm`,open:!a,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer hover:underline ${a?`text-orange-400`:`text-status-ok`}`,children:r(`printers.firmwareModal.releaseNotes`)}),(0,K.jsx)(`div`,{className:`mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap`,children:i})]},n??`none`)]})})(),t.available_versions&&t.available_versions.length>0&&!u&&c?.status!==`complete`&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mb-2`,children:r(`printers.firmwareModal.availableVersions`)}),(0,K.jsx)(`div`,{className:`max-h-56 overflow-y-auto border border-bambu-dark-tertiary rounded-lg divide-y divide-bambu-dark-tertiary`,children:t.available_versions.map(e=>{let n=t.current_version===e.version,i=m===e.version,a=t.current_version?kp(e.version,t.current_version):0,o=r(n?`printers.firmwareModal.currentBadge`:a>0?`printers.firmwareModal.newerBadge`:`printers.firmwareModal.olderBadge`),c=n?`text-bambu-gray`:a>0?`text-orange-400`:`text-blue-400`;return(0,K.jsxs)(`button`,{type:`button`,disabled:!e.file_available||!s||n,onClick:()=>h(e.version),className:`w-full text-left px-3 py-2 text-sm flex items-center justify-between gap-2 transition-colors ${i?`bg-orange-500/10`:`hover:bg-bambu-dark`} ${!e.file_available||!s||n?`opacity-60 cursor-not-allowed`:`cursor-pointer`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-mono text-white`,children:e.version}),(0,K.jsx)(`span`,{className:`text-xs ${c}`,children:o})]}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${n?`bg-blue-500/15 text-blue-400 border border-blue-500/30`:e.file_available?`bg-bambu-green/15 text-bambu-green border border-bambu-green/30`:`bg-bambu-gray/10 text-bambu-gray border border-bambu-gray/30`}`,children:n?r(`printers.firmwareModal.installed`):e.file_available?r(`printers.firmwareModal.usable`):r(`printers.firmwareModal.unavailable`)})]},e.version)})})]}),m?_?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm mb-4`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`printers.firmwareModal.checkingPrereqs`)]}):g&&!u&&!c?(0,K.jsx)(`div`,{className:`mb-4`,children:g.can_proceed?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green text-sm`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),r(`printers.firmwareModal.sdCardReady`)]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:g.errors.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4 flex-shrink-0`}),e]},t))})}):null:null,(u||c)&&c&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray capitalize`,children:c.status}),(0,K.jsxs)(`span`,{className:`text-white`,children:[c.progress,`%`]})]}),(0,K.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`h-2 rounded-full transition-all ${c.status===`error`?`bg-status-error`:c.status===`complete`?`bg-status-ok`:`bg-orange-500`} ${c.status===`uploading`?`animate-pulse`:``}`,style:{width:`${c.progress}%`}})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:c.message}),c.error&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:c.error})]}),c?.status===`complete`&&(0,K.jsxs)(`div`,{className:`bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-green font-medium mb-2`,children:r(`printers.firmwareModal.uploadedSuccess`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`printers.firmwareModal.applyInstructions`)}),(0,K.jsxs)(`ol`,{className:`text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1`,children:[(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step1`)}}),(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step2`)}}),(0,K.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step3`)}}),(0,K.jsx)(`li`,{children:r(`printers.firmwareModal.step4`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:n,children:c?.status===`complete`?r(`printers.firmwareModal.done`):r(`common.cancel`)}),g?.can_proceed&&!u&&c?.status!==`complete`&&s&&(0,K.jsx)($,{onClick:()=>{l(null),v.mutate()},disabled:v.isPending,children:v.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}),r(`printers.firmwareModal.starting`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),r(`printers.firmwareModal.uploadFirmware`)]})})]})]})})})}function Vke({printer:e,onClose:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)({name:e.name,ip_address:e.ip_address,access_code:``,model:e.model||``,location:e.location||``,auto_archive:e.auto_archive,is_active:e.is_active}),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(null),d=J({mutationFn:t=>Q.updatePrinter(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`printers`]}),r.invalidateQueries({queryKey:[`printerStatus`,e.id]}),t()},onError:e=>i(e.message||n(`printers.toast.failedToUpdate`),`error`)});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let f=()=>{let e={name:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive,is_active:a.is_active};a.access_code&&(e.access_code=a.access_code),d.mutate(e)};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,K.jsx)(_d,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:n(`printers.editPrinter`)}),(0,K.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),c(!0);try{let t=await Q.diagnoseConnection({ip_address:a.ip_address.trim(),serial_number:e.serial_number,access_code:a.access_code||void 0});if(t.checks.some(e=>e.status===`fail`)){u(t);return}}catch{}finally{c(!1)}f()},className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.name`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:n(`printers.modal.myPrinter`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.ipAddress`)}),(0,K.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[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])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.ip_address,onChange:e=>o({...a,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.serialNumber`)}),(0,K.jsx)(`input`,{type:`text`,disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed`,value:e.serial_number}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.serialCannotBeChanged`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.accessCode`)}),(0,K.jsx)(`input`,{type:`password`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.access_code,onChange:e=>o({...a,access_code:e.target.value}),placeholder:n(`printers.accessCodePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.model`)}),(0,K.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.model,onChange:e=>o({...a,model:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:n(`printers.modal.selectModel`)}),(0,K.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,K.jsx)(`option`,{value:`A1`,children:`A1`}),(0,K.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,K.jsx)(`optgroup`,{label:`A2 Series`,children:(0,K.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,K.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,K.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,K.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,K.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,K.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,K.jsxs)(`optgroup`,{label:`P Series`,children:[(0,K.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,K.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,K.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,K.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,K.jsx)(`option`,{value:`X1`,children:`X1`}),(0,K.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,K.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,K.jsx)(`optgroup`,{label:`X2 Series`,children:(0,K.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Location / Group`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.location,onChange:e=>o({...a,location:e.target.value}),placeholder:n(`printers.modal.locationPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.locationHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`edit_auto_archive`,checked:a.auto_archive,onChange:e=>o({...a,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`label`,{htmlFor:`edit_auto_archive`,className:`text-sm text-bambu-gray`,children:n(`printers.modal.autoArchiveLabel`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`checkbox`,id:`edit_maintenance_mode`,checked:!a.is_active,onChange:e=>o({...a,is_active:!e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-amber-400 focus:ring-amber-400`}),(0,K.jsxs)(`label`,{htmlFor:`edit_maintenance_mode`,className:`text-sm text-bambu-gray flex items-center gap-1.5`,children:[(0,K.jsx)(Lu,{className:`w-3.5 h-3.5 text-amber-400`}),n(`printers.maintenance.editFieldLabel`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1 ml-6`,children:n(`printers.maintenance.editFieldHelp`)})]}),l?(0,K.jsxs)(`div`,{className:`rounded-lg bg-amber-500/10 border border-amber-500/30 p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-400`}),(0,K.jsx)(`p`,{className:`text-sm text-amber-300`,children:n(`printers.addPreflight.warning`)})]}),(0,K.jsx)(np,{result:l}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>u(null),className:`flex-1`,children:n(`printers.addPreflight.back`)}),(0,K.jsx)($,{type:`button`,onClick:f,className:`flex-1`,disabled:d.isPending,children:n(`printers.addPreflight.saveAnyway`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3 pt-4`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,className:`flex-1`,disabled:d.isPending||s,children:s?n(`printers.addPreflight.checking`):d.isPending?n(`common.saving`):n(`printers.modal.saveChanges`)})]})]})]})})})}function Hke(e){let{data:t}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:3e4});return!t?.connected}function Uke({printer:e,plug:t,onPowerOn:n,isPowering:r}){let i=Hke(e.id),{data:a}=q({queryKey:[`smartPlugStatus`,t.id],queryFn:()=>Q.getSmartPlugStatus(t.id),refetchInterval:1e4});return i?(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-sm text-gray-900 dark:text-white truncate`,children:e.name}),a&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${a.state===`ON`?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:a.state||`?`})]}),(0,K.jsxs)(`button`,{onClick:()=>n(t.id),disabled:r||a?.state===`ON`,className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state===`ON`?`bg-bambu-green/20 text-bambu-green cursor-default`:`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white`}`,children:[(0,K.jsx)(wl,{className:`w-3 h-3`}),r?`...`:`On`]})]}):null}function Wke(){let{t:e}=W(),{resolvedMode:t,darkAccent:n,lightAccent:r}=md(),i={green:`bg-green-500 text-white hover:bg-green-400 border-green-400/60`,teal:`bg-teal-500 text-white hover:bg-teal-400 border-teal-400/60`,blue:`bg-blue-500 text-white hover:bg-blue-400 border-blue-400/60`,orange:`bg-orange-500 text-white hover:bg-orange-400 border-orange-400/60`,purple:`bg-purple-500 text-white hover:bg-purple-400 border-purple-400/60`,red:`bg-red-500 text-white hover:bg-red-400 border-red-400/60`}[t===`dark`?n:r],[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(()=>localStorage.getItem(`hideDisconnectedPrinters`)===`true`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(()=>localStorage.getItem(`printerSortBy`)||`name`),[h,g]=(0,y.useState)(()=>localStorage.getItem(`printerSortAsc`)!==`false`),[_,v]=(0,y.useState)(()=>{let e=localStorage.getItem(`printerCardSize`);return e?parseInt(e,10):2}),b=_===1?`compact`:`expanded`,[x,S]=(0,y.useState)(null),C=(0,y.useCallback)(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(`printer-card-${e}`);if(!t)return;let n=document.querySelector(`header`)?.getBoundingClientRect().height??56,r=t.getBoundingClientRect().top+window.scrollY-n-16;window.scrollTo({top:Math.max(0,r),behavior:`smooth`})})})},[]),w=(0,y.useCallback)(e=>{S(e),v(2),localStorage.setItem(`printerCardSize`,`2`),C(e)},[C]),T=(0,y.useCallback)(()=>{let e=x;S(null),v(1),localStorage.setItem(`printerCardSize`,`1`),e!=null&&C(e)},[x,C]),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(`all`),[A,j]=(0,y.useState)(`all`),[M,N]=(0,y.useState)(0),[P,F]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`printerCollapsedSections`);return e?JSON.parse(e):{}}catch{return{}}}),I=no(),{showToast:L}=Td(),{hasPermission:R}=dd(),[z,B]=(0,y.useState)(()=>{let e=localStorage.getItem(`openEmbeddedCameras`);if(e)try{let t=JSON.parse(e);return new Map(t.map(e=>[e.id,e]))}catch{return new Map}return new Map});(0,y.useEffect)(()=>{let e=Array.from(z.values());e.length>0?localStorage.setItem(`openEmbeddedCameras`,JSON.stringify(e)):localStorage.removeItem(`openEmbeddedCameras`)},[z]);let{data:V,isLoading:ee}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:te}=q({queryKey:[`ui-preferences`],queryFn:Q.getUiPreferences}),ne=(0,y.useMemo)(()=>Lp(te?.nozzle_temp_presets,Mp,0,320),[te?.nozzle_temp_presets]),re=(0,y.useMemo)(()=>Lp(te?.bed_temp_presets,Np,0,140),[te?.bed_temp_presets]),ie=(0,y.useMemo)(()=>Lp(te?.chamber_temp_presets,Pp,0,60),[te?.chamber_temp_presets]),H=(0,y.useMemo)(()=>Lp(te?.fan_speed_presets,Fp,0,100),[te?.fan_speed_presets]),ae=(0,y.useMemo)(()=>{if(te?.drying_presets)try{let e=JSON.parse(te.drying_presets);if(typeof e==`object`&&e&&Object.keys(e).length>0)return{...kW,...e}}catch{}return kW},[te?.drying_presets]);(0,y.useEffect)(()=>{te?.camera_view_mode===`window`&&z.size>0&&B(new Map)},[te?.camera_view_mode,z.size]);let{data:oe}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:U}=q({queryKey:[`maintenanceOverview`],queryFn:Q.getMaintenanceOverview,staleTime:60*1e3}),{data:se}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,staleTime:60*1e3}),ce=se?.enabled&&se?.connected,{data:le}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,enabled:!!ce,staleTime:60*1e3}),ue=le?.spoolman_sync_mode,{data:de}=q({queryKey:[`unlinked-spools`],queryFn:Q.getUnlinkedSpools,enabled:!!ce,staleTime:30*1e3}),fe=de&&de.length>0,{data:pe}=q({queryKey:[`linked-spools`],queryFn:Q.getLinkedSpools,enabled:!!ce,staleTime:30*1e3}),me=pe?.linked,{data:he}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:R(`inventory:view_assignments`),staleTime:30*1e3}),ge=J({mutationFn:({printerId:e,amsId:t,trayId:n})=>Q.unassignSpool(e,t,n),onSuccess:()=>{I.invalidateQueries({queryKey:[`spool-assignments`]})}}),{data:_e,isLoading:ve}=q({queryKey:[`spoolman-inventory-spools`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:!!ce,staleTime:30*1e3}),{data:ye,isLoading:be}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:!!ce,staleTime:30*1e3}),xe=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{I.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),I.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})}}),Se=(e,t,n)=>he?.find(r=>r.printer_id===e&&r.ams_id===Number(t)&&r.tray_id===Number(n)),Ce=U?.reduce((e,t)=>(e[t.printer_id]={due_count:t.due_count,warning_count:t.warning_count,total_print_hours:t.total_print_hours},e),{})||{},we=oe?.reduce((e,t)=>(t.printer_id&&(e[t.printer_id]=t),e),{})||{},Te=J({mutationFn:Q.createPrinter,onSuccess:()=>{I.invalidateQueries({queryKey:[`printers`]}),I.invalidateQueries({queryKey:[`maintenanceOverview`]}),o(!1)},onError:t=>{if(t instanceof Uu&&t.code===`printer_connection_failed`){L(e(`printers.toast.connectionFailedNotAdded`),`error`);return}L(t.message||e(`printers.toast.failedToAdd`),`error`)}}),Ee=J({mutationFn:e=>Q.controlSmartPlug(e,`on`),onSuccess:()=>{I.invalidateQueries({queryKey:[`smart-plugs`]}),f(null)},onError:()=>{f(null)}}),[De,Oe]=(0,y.useState)(new Set),[ke,Ae]=(0,y.useState)(!1),[je,Me]=(0,y.useState)(null),[Ne,Pe]=(0,y.useState)(!1),Fe=ke||De.size>0,Ie=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Le=(0,y.useCallback)(()=>{Oe(new Set),Ae(!1)},[]);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&Fe&&Le()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Fe,Le]);let Re=(0,y.useCallback)(async t=>{Pe(!0);let n=Array.from(De).filter(e=>{let n=I.getQueryData([`printerStatus`,e]);if(!n?.connected)return!1;switch(t){case`stop`:return n.state===`RUNNING`||n.state===`PAUSE`;case`pause`:return n.state===`RUNNING`;case`resume`:return n.state===`PAUSE`;case`clearPlate`:return!!n.awaiting_plate_clear;case`clearHMS`:return n.hms_errors&&Vp(n.hms_errors).length>0;default:return!1}});if(n.length===0){L(e(`printers.bulk.noneApplicable`),`error`),Pe(!1),Me(null);return}let r={stop:Q.stopPrint,pause:Q.pausePrint,resume:Q.resumePrint,clearPlate:Q.clearPlate,clearHMS:Q.clearHMSErrors}[t],i=await Promise.allSettled(n.map(e=>r(e))),a=i.filter(e=>e.status===`fulfilled`).length,o=i.filter(e=>e.status===`rejected`).length;o===0?L(e(`printers.bulk.success`,{action:e(`printers.bulk.actions.${t}`),count:a})):L(e(`printers.bulk.partial`,{succeeded:a,failed:o}),`error`),n.forEach(e=>{I.invalidateQueries({queryKey:[`printerStatus`,e]})}),Pe(!1),Me(null)},[De,I,L,e]),ze=(0,y.useCallback)(e=>{e===`stop`||e===`pause`||e===`clearPlate`?Me(e):Re(e)},[Re]),Be=()=>{let e=!s;c(e),localStorage.setItem(`hideDisconnectedPrinters`,String(e))},Ve=e=>{m(e),localStorage.setItem(`printerSortBy`,e)},He=()=>{let e=!h;g(e),localStorage.setItem(`printerSortAsc`,String(e))},Ue=()=>{switch(_){case 1:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`;case 2:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`;case 3:return`grid-cols-1 lg:grid-cols-2`;case 4:return`grid-cols-1`;default:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`}},We=[`S`,`M`,`L`,`XL`];(0,y.useEffect)(()=>I.getQueryCache().subscribe(e=>{e.type===`updated`&&Array.isArray(e.query.queryKey)&&e.query.queryKey[0]===`printerStatus`&&N(e=>e+1)}),[I]);let Ge=(0,y.useMemo)(()=>{if(!V)return[];let e=V;if(E.trim()){let t=E.trim().toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||(e.model||``).toLowerCase().includes(t)||(e.location||``).toLowerCase().includes(t)||(e.serial_number||``).toLowerCase().includes(t))}return A!==`all`&&(e=e.filter(e=>(e.location||``)===A)),O!==`all`&&(e=e.filter(e=>{let t=I.getQueryData([`printerStatus`,e.id]);if(!t?.connected)return O===`offline`;let n=t.hms_errors?Vp(t.hms_errors):[];switch(O){case`printing`:return t.state===`RUNNING`;case`paused`:return t.state===`PAUSE`;case`finished`:return t.state===`FINISH`;case`error`:return t.state===`FAILED`||n.length>0;case`idle`:return t.state!==`RUNNING`&&t.state!==`PAUSE`&&t.state!==`FINISH`&&t.state!==`FAILED`&&n.length===0;case`offline`:return!1;default:return!0}})),e},[V,E,O,A,I,M]),Ke=(0,y.useMemo)(()=>V?[...new Set(V.map(e=>e.location||``).filter(Boolean))].sort():[],[V]),qe=(0,y.useMemo)(()=>{let e=[...Ge];switch(p){case`name`:e.sort((e,t)=>e.name.localeCompare(t.name));break;case`model`:e.sort((e,t)=>(e.model||``).localeCompare(t.model||``));break;case`location`:e.sort((e,t)=>{let n=e.location||``,r=t.location||``;return!n&&r?1:n&&!r?-1:n.localeCompare(r)||e.name.localeCompare(t.name)});break;case`status`:e.sort((e,t)=>{let n=I.getQueryData([`printerStatus`,e.id]),r=I.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?(e.hms_errors?Vp(e.hms_errors):[]).length>0?0:e.state===`RUNNING`?1:2:3;return i(n)-i(r)});break;case`eta`:e.sort((e,t)=>{let n=I.getQueryData([`printerStatus`,e.id]),r=I.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?e.state===`RUNNING`&&e.remaining_time!=null&&e.remaining_time>0?0:e.state===`RUNNING`?1:2:3,a=i(n),o=i(r);if(a!==o)return a-o;if(a===0){let e=(n.remaining_time??0)-(r.remaining_time??0);if(e!==0)return e}return e.name.localeCompare(t.name)});break}return h||e.reverse(),e},[Ge,p,h,I]),Je=(0,y.useCallback)(()=>{Oe(new Set(qe.map(e=>e.id))),Ae(!0)},[qe]),Ye=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.forEach(t=>{EW(I.getQueryData([`printerStatus`,t.id]))===e&&n.add(t.id)}),n}),Ae(!0)},[qe,I]),Xe=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.filter(t=>(t.location||``)===e).forEach(e=>n.add(e.id)),n}),Ae(!0)},[qe]),Ze=(0,y.useCallback)(e=>{Oe(t=>{let n=new Set(t);return qe.filter(t=>(t.model||`Unknown`)===e).forEach(e=>n.add(e.id)),n}),Ae(!0)},[qe]),Qe=(0,y.useCallback)(e=>{F(t=>{let n={...t,[e]:!t[e]};try{localStorage.setItem(`printerCollapsedSections`,JSON.stringify(n))}catch{}return n})},[]),$e=(0,y.useMemo)(()=>{if(p===`name`||p===`eta`)return null;let e={};return p===`location`?qe.forEach(t=>{let n=t.location||`Ungrouped`;e[n]||(e[n]=[]),e[n].push(t)}):p===`model`?qe.forEach(t=>{let n=t.model||`Unknown`;e[n]||(e[n]=[]),e[n].push(t)}):p===`status`&&qe.forEach(t=>{let n=EW(I.getQueryData([`printerStatus`,t.id]));e[n]||(e[n]=[]),e[n].push(t)}),e},[p,qe,I,M]),et=(0,y.useRef)(null),tt=(0,y.useRef)(null),nt=(0,y.useRef)(0),[rt,it]=(0,y.useState)(!1),at=(0,y.useCallback)(()=>{let e=et.current;if(!e)return;let t=tt.current?.offsetWidth;t&&(nt.current=t);let n=nt.current>0&&e.clientWidthe===n?e:n)},[]),ot=Object.keys(we).length;(0,y.useLayoutEffect)(()=>{at();let e=et.current;if(!e)return;if(typeof ResizeObserver>`u`)return window.addEventListener(`resize`,at),()=>window.removeEventListener(`resize`,at);let t=new ResizeObserver(()=>at());return t.observe(e),window.addEventListener(`resize`,at),()=>{t.disconnect(),window.removeEventListener(`resize`,at)}},[at,V?.length,Ke.length,s,ot]);let st=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[V&&V.length>0&&(0,K.jsx)(xW,{value:O,onChange:k,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allStatuses`)},{value:`printing`,label:e(`printers.status.printing`)},{value:`paused`,label:e(`printers.status.paused`)},{value:`idle`,label:e(`printers.status.idle`)},{value:`finished`,label:e(`printers.status.finished`)},{value:`error`,label:e(`printers.status.error`)},{value:`offline`,label:e(`printers.status.offline`)}]}),V&&V.length>0&&Ke.length>0&&(0,K.jsx)(xW,{value:A,onChange:j,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allLocations`)},...Ke.map(e=>({value:e,label:e}))]}),(0,K.jsx)(`button`,{type:`button`,onClick:Be,"aria-pressed":s,className:`h-8 px-2 rounded-lg border text-sm font-medium transition-colors ${t?`w-full`:``} ${s?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:e(`printers.hideOffline`)})]}),ct=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1 ${t?`w-full`:``}`,children:[(0,K.jsx)(xW,{value:p,onChange:Ve,fullWidth:t,options:[{value:`name`,label:e(`printers.sort.name`)},{value:`status`,label:e(`printers.sort.status`)},{value:`model`,label:e(`printers.sort.model`)},{value:`location`,label:e(`printers.sort.location`)},{value:`eta`,label:e(`printers.sort.eta`)}]}),(0,K.jsx)(`button`,{onClick:He,className:`h-8 shrink-0 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,title:e(h?`printers.sort.descending`:`printers.sort.ascending`),children:h?(0,K.jsx)(Io,{className:`w-4 h-4 text-white`}):(0,K.jsx)(Ao,{className:`w-4 h-4 text-white`})})]}),(0,K.jsx)(`div`,{className:`flex h-8 items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary ${t?`w-full`:``}`,children:We.map((n,r)=>{let i=r+1,a=_===i;return(0,K.jsx)(`button`,{onClick:()=>{S(null),v(i),localStorage.setItem(`printerCardSize`,String(i))},className:`h-full px-2 text-xs font-medium transition-colors ${t?`flex-1`:``} ${r===0?`rounded-l-lg`:``} ${r===We.length-1?`rounded-r-lg`:``} ${a?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(n===`S`?`printers.cardSize.small`:n===`M`?`printers.cardSize.medium`:n===`L`?`printers.cardSize.large`:`printers.cardSize.extraLarge`),children:n},n)})})]}),lt=(t=!1)=>(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:()=>{Fe?Le():Ae(!0)},className:`h-8 px-2 rounded-lg border transition-colors ${t?`w-full justify-center gap-1.5 text-sm font-medium flex items-center`:``} ${Fe?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.bulk.select`),disabled:!R(`printers:control`),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),t&&(0,K.jsx)(`span`,{children:e(`printers.bulk.select`)})]}),s&&Object.keys(we).length>0&&(0,K.jsxs)(`div`,{className:`relative ${t?`w-full`:``}`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(!l),className:`h-8 flex items-center gap-1.5 px-2 text-sm rounded-lg border transition-colors ${t?`w-full justify-between bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary hover:text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(wl,{className:`w-4 h-4`}),e(`printers.powerOn`)]}),(0,K.jsx)(is,{className:`w-3 h-3 transition-transform ${l?`rotate-180`:``}`})]}),l&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>u(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:[(0,K.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:e(`printers.offlinePrintersWithPlugs`)}),V?.filter(e=>we[e.id]).map(e=>(0,K.jsx)(Uke,{printer:e,plug:we[e.id],onPowerOn:e=>{f(e),Ee.mutate(e)},isPowering:d===we[e.id]?.id},e.id)),V?.filter(e=>we[e.id]).length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:`No printers with smart plugs`})]})]})]}),(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!R(`printers:create`),title:R(`printers:create`)?void 0:e(`printers.permission.noAdd`),className:`!h-8 !min-h-8 px-2 py-0 ${t?`w-full`:``}`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]});return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Tl,{className:`w-7 h-7 text-bambu-green`}),e(`printers.title`)]}),(0,K.jsx)(Pke,{printers:V})]}),(0,K.jsxs)(`div`,{ref:et,className:`relative flex items-center gap-2`,children:[V&&V.length>0&&(0,K.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,K.jsx)(`input`,{type:`search`,name:`printer-search`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,value:E,onChange:e=>D(e.target.value),placeholder:e(`printers.search`),"aria-label":e(`printers.search`),className:`w-full h-8 pl-9 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),E&&(0,K.jsx)(`button`,{type:`button`,"aria-label":e(`common.clear`),onClick:()=>D(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{ref:tt,"aria-hidden":rt,inert:rt,className:`${rt?`absolute -left-[9999px] top-0 flex w-max pointer-events-none opacity-0`:`flex`} ml-auto items-center justify-end gap-2 flex-nowrap [&>*]:shrink-0`,children:[(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:st()}),(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:ct()}),(0,K.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:lt()})]}),rt&&(0,K.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-1`,children:[(0,K.jsx)(SW,{label:e(`printers.toolbar.filters`,`Filters`),icon:(0,K.jsx)(mc,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:st(!0)})}),(0,K.jsx)(SW,{label:e(`printers.toolbar.view`,`View`),icon:(0,K.jsx)(Ql,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:ct(!0)})}),(0,K.jsx)(SW,{label:e(`printers.toolbar.actions`,`Actions`),icon:(0,K.jsx)(Gs,{className:`w-4 h-4`}),children:(0,K.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:lt(!0)})})]})]})]}),ee?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):V?.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`printers.noPrintersConfigured`)}),(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!R(`printers:create`),title:R(`printers:create`)?void 0:e(`printers.permission.noAdd`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]})}):qe.length===0&&(E.trim()||O!==`all`||A!==`all`)?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`text-center py-12`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`printers.noSearchResults`)})})}):$e?(0,K.jsx)(`div`,{className:`space-y-6`,children:(()=>{let e=p===`status`?Ike.filter(e=>$e[e]?.length>0):Object.keys($e);return h?e:[...e].reverse()})().map(t=>{let n=$e[t],r=`${p}:${t}`,i=!P[r],a=p===`status`&&TW[t]?.dot||`bg-bambu-green`,o=p===`status`?e(TW[t]?.labelKey||t):t;return(0,K.jsx)(lp,{open:i,onToggle:()=>Qe(r),summaryClassName:`py-1`,summary:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${a}`}),o,(0,K.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n.length,`)`]}),Fe&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),p===`location`?Xe(t===`Ungrouped`?``:t):p===`status`?Ye(t):p===`model`&&Ze(t)},className:`text-xs text-bambu-green hover:text-bambu-green-light transition-colors ml-1`,children:e(`printers.bulk.selectAll`)})]}),children:(0,K.jsx)(`div`,{className:`grid gap-4 ${_>=3?`gap-6`:``} ${Ue()}`,children:n.map(e=>(0,K.jsx)(AW,{printer:e,hideIfDisconnected:s,maintenanceInfo:Ce[e.id],viewMode:b,cardSize:_,amsThresholds:te?{humidityGood:Number(te.ams_humidity_good)||40,humidityFair:Number(te.ams_humidity_fair)||60,tempGood:Number(te.ams_temp_good)||28,tempFair:Number(te.ams_temp_fair)||35}:void 0,spoolmanEnabled:ce,hasUnlinkedSpools:fe,linkedSpools:me,spoolmanUrl:se?.url,spoolmanSyncMode:ue,onGetAssignment:Se,onUnassignSpool:(e,t,n)=>ge.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:_e,spoolmanSlotAssignments:ye,spoolmanLoading:ve||be,onUnassignSpoolmanSpool:e=>xe.mutate(e),timeFormat:te?.time_format||`system`,cameraViewMode:te?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>B(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:te?.check_printer_firmware!==!1,dryingPresets:ae,nozzleTempPresets:ne,bedTempPresets:re,chamberTempPresets:ie,fanSpeedPresets:H,requirePlateClear:te?.require_plate_clear===!0,selectionMode:Fe,isSelected:De.has(e.id),onToggleSelect:Ie,onOpenCompactCard:w},e.id))})},t)})}):(0,K.jsx)(`div`,{className:`grid gap-4 ${_>=3?`gap-6`:``} ${Ue()}`,children:qe.map(e=>(0,K.jsx)(AW,{printer:e,hideIfDisconnected:s,maintenanceInfo:Ce[e.id],viewMode:b,cardSize:_,spoolmanEnabled:ce,hasUnlinkedSpools:fe,linkedSpools:me,spoolmanUrl:se?.url,spoolmanSyncMode:ue,onGetAssignment:Se,onUnassignSpool:(e,t,n)=>ge.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:_e,spoolmanSlotAssignments:ye,spoolmanLoading:ve||be,onUnassignSpoolmanSpool:e=>xe.mutate(e),amsThresholds:te?{humidityGood:Number(te.ams_humidity_good)||40,humidityFair:Number(te.ams_humidity_fair)||60,tempGood:Number(te.ams_temp_good)||28,tempFair:Number(te.ams_temp_fair)||35}:void 0,timeFormat:te?.time_format||`system`,cameraViewMode:te?.camera_view_mode||`window`,onOpenEmbeddedCamera:(e,t)=>B(n=>new Map(n).set(e,{id:e,name:t})),checkPrinterFirmware:te?.check_printer_firmware!==!1,dryingPresets:ae,nozzleTempPresets:ne,bedTempPresets:re,chamberTempPresets:ie,fanSpeedPresets:H,requirePlateClear:te?.require_plate_clear===!0,selectionMode:Fe,isSelected:De.has(e.id),onToggleSelect:Ie,onOpenCompactCard:w},e.id))}),_===2&&x!=null&&(0,K.jsxs)(`button`,{type:`button`,onClick:T,className:`fixed bottom-5 left-1/2 z-40 inline-flex -translate-x-1/2 items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-xl transition-colors ${i}`,title:e(`common.back`,`Back`),children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),e(`common.back`,`Back`)]}),a&&(0,K.jsx)(zke,{onClose:()=>o(!1),onAdd:e=>Te.mutate(e),existingSerials:V?.map(e=>e.serial_number)||[]}),Fe&&V&&(0,K.jsx)(oee,{selectedIds:De,printers:V,onClose:Le,onSelectAll:Je,onSelectByLocation:Xe,onSelectByState:Ye,onAction:ze,actionPending:Ne}),je===`stop`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.stopTitle`,{count:De.size}),message:e(`printers.bulk.confirm.stopMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.stopButton`),variant:`danger`,isLoading:Ne,onConfirm:()=>Re(`stop`),onCancel:()=>Me(null)}),je===`pause`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.pauseTitle`,{count:De.size}),message:e(`printers.bulk.confirm.pauseMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.pauseButton`),isLoading:Ne,onConfirm:()=>Re(`pause`),onCancel:()=>Me(null)}),je===`clearPlate`&&(0,K.jsx)(Ad,{title:e(`printers.bulk.confirm.clearPlateTitle`,{count:De.size}),message:e(`printers.bulk.confirm.clearPlateMessage`,{count:De.size}),confirmText:e(`printers.bulk.confirm.clearPlateButton`),isLoading:Ne,onConfirm:()=>Re(`clearPlate`),onCancel:()=>Me(null)}),Array.from(z.values()).map((e,t)=>(0,K.jsx)(mle,{printerId:e.id,printerName:e.name,viewerIndex:t,onClose:()=>B(t=>{let n=new Map(t);return n.delete(e.id),n})},e.id))]})}function Gke({title:e,message:t,subtitle:n,closeText:r,variant:i=`error`,onClose:a}){let{t:o}=W(),s=r??o(`common.close`);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-[120]`,onClick:a,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-dark ${i===`warning`?`text-yellow-400`:`text-red-400`}`,children:(0,K.jsx)(Cu,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-1`,children:e}),n&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2 truncate`,children:n}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm whitespace-pre-line break-words`,children:t})]})]}),(0,K.jsx)(`div`,{className:`flex mt-6`,children:(0,K.jsx)($,{onClick:a,className:`flex-1`,children:s})})]})})})}var jW=(0,y.createContext)(null),Kke=1500,qke=1e3,MW=e=>`slice-job-${e}`;function NW(e){try{return decodeURIComponent(e)}catch{return e}}function Jke(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function Yke({children:e}){let{t}=W(),{showToast:n,showPersistentToast:r,dismissToast:i}=Td(),a=no(),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(null),u=(0,y.useRef)([]);u.current=o;let d=(0,y.useRef)(new Map),f=(0,y.useRef)(new Map),p=(0,y.useRef)(new Map),m=(0,y.useCallback)(e=>{let n=d.current.get(e.id);if(n==null)return;let i=(Date.now()-n)/1e3,a=f.current.get(e.id)??`pending`,o=Jke(i),s=p.current.get(e.id)??null,c=s&&s.stage&&s.total_percent>0;if(a===`running`&&c){let n=NW(e.sourceName),i=s.stage,a=Math.min(100,Math.max(0,Math.round(s.total_percent))),c=typeof s.multi_plate_index==`number`&&typeof s.multi_plate_count==`number`&&s.multi_plate_count>1?t(`slice.runningWithProgressMultiPlate`,`Plate {{plateIndex}} of {{plateCount}} • {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{plateIndex:s.multi_plate_index,plateCount:s.multi_plate_count,name:n,stage:i,percent:a,elapsed:o}):t(`slice.runningWithProgress`,`{{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:n,stage:i,percent:a,elapsed:o});r(MW(e.id),c,`loading`);return}let l=a===`pending`?`slice.queuedToast`:`slice.runningToast`,u=a===`pending`?`Queued: {{name}} — {{elapsed}}`:`Slicing {{name}} — {{elapsed}}`;r(MW(e.id),t(l,u,{name:NW(e.sourceName),elapsed:o}),`loading`)},[r,t]),h=(0,y.useCallback)((e,t,n)=>{s(r=>r.some(t=>t.id===e)?r:[...r,{id:e,kind:t,sourceName:n}]),d.current.set(e,Date.now()),f.current.set(e,`pending`),p.current.set(e,null),m({id:e,kind:t,sourceName:n})},[m]),g=(0,y.useCallback)((e,r)=>{s(t=>t.filter(t=>t.id!==e.id)),d.current.delete(e.id),f.current.delete(e.id),p.current.delete(e.id),i(MW(e.id)),r.status===`completed`?n(t(`slice.completedToast`,`Sliced {{name}}`,{name:NW(e.sourceName)}),`success`):r.status===`failed`&&l({name:NW(e.sourceName),detail:r.error_detail||t(`slice.failed`)}),a.invalidateQueries({queryKey:[`library-files`]}),a.invalidateQueries({queryKey:[`archives`]})},[i,a,n,t]);return(0,y.useEffect)(()=>{if(o.length===0)return;let e=!1,t=setInterval(async()=>{if(e)return;let t=[...u.current];for(let e of t)try{let t=await Q.getSliceJob(e.id);f.current.set(e.id,t.status),t.progress&&p.current.set(e.id,t.progress),(t.status===`completed`||t.status===`failed`)&&g(e,t)}catch{}},Kke);return()=>{e=!0,clearInterval(t)}},[o.length,g]),(0,y.useEffect)(()=>{if(o.length===0)return;let e=setInterval(()=>{for(let e of u.current)m(e)},qke);return()=>clearInterval(e)},[o.length,m]),(0,K.jsxs)(jW.Provider,{value:{trackJob:h,activeJobs:o},children:[e,c&&(0,K.jsx)(Gke,{title:t(`slice.failedTitle`),subtitle:c.name,message:c.detail,onClose:()=>l(null)})]})}function Xke(){let e=(0,y.useContext)(jW);if(!e)throw Error(`useSliceJobTracker must be used inside SliceJobTrackerProvider`);return e}function PW({plates:e,onSelect:t,onClose:n}){let{t:r}=W();return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:r(`archives.platePicker.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`archives.platePicker.hint`)})]}),(0,K.jsx)(`button`,{onClick:n,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors`,"aria-label":r(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(e.index),className:`flex items-center gap-2 p-2 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray transition-colors text-left`,children:[e.has_thumbnail&&e.thumbnail_url!=null?(0,K.jsx)(`img`,{src:Xu(e.thumbnail_url),alt:`Plate ${e.index}`,className:`w-12 h-12 rounded object-cover bg-bambu-dark-tertiary flex-shrink-0`}):(0,K.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center flex-shrink-0`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:e.name?`${r(`archives.platePicker.plateLabel`,{index:e.index})} — ${e.name}`:r(`archives.platePicker.plateLabel`,{index:e.index})}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[e.objects.length>0?e.objects.slice(0,3).join(`, `)+(e.objects.length>3?`…`:``):e.object_count!=null&&e.object_count>0?r(`archives.platePicker.objectCount`,{count:e.object_count}):`${e.filaments.length} filament${e.filaments.length===1?``:`s`}`,e.print_time_seconds==null?``:` • ${Cf(e.print_time_seconds)}`]})]})]},e.index))})})]})})}var FW=[`local`,`orca_cloud`,`cloud`,`standard`];function IW(e,t){for(let n of FW){let r=e[n][t];if(r.length>0)return{source:r[0].source,id:r[0].id}}return null}function LW(e,t,n){return t?e[t.source][n].find(e=>e.id===t.id)??null:null}function RW(e,t,n){if(!n)return null;for(let r of FW){let i=e[r][t].find(e=>e.name===n);if(i)return{source:i.source,id:i.id}}return null}function Zke(e,t,n,r){let i=RW(e,`process`,r);if(i){let r=LW(e,i,`process`);if(r&&SU(r,`process`,t,n)!==`mismatch`)return i}for(let r of[`match`,`unknown`])for(let i of FW)for(let a of e[i].process)if(SU(a,`process`,t,n)===r)return{source:a.source,id:a.id};return IW(e,`process`)}var Qke={local:1.75,orca_cloud:1.5,cloud:1,standard:.5};function $ke(e,t,n,r){let i=t.type.trim().toUpperCase(),a=kf(t.color),o=null;for(let s of FW)for(let c of e[s].filament){let e=0,l=(c.filament_type??``).trim().toUpperCase(),u=kf(c.filament_colour??``);i&&l&&i===l&&(e+=10),a&&u&&(u===a?e+=5:Ff(c.filament_colour??``,t.color)&&(e+=2)),e+=Qke[s],SU(c,`filament`,n,r)===`mismatch`&&(e-=100),(o==null||e>o.score)&&(o={ref:{source:c.source,id:c.id},score:e})}return o==null?IW(e,`filament`):o.ref}function eAe(e){return e?`${e.source}:${e.id}`:``}function tAe(e){if(!e)return null;let t=e.indexOf(`:`);if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1);return n!==`orca_cloud`&&n!==`cloud`&&n!==`local`&&n!==`standard`?null:{source:n,id:r}}function nAe({requestId:e,sourceName:t}){let{t:n}=W(),{showPersistentToast:r,dismissToast:i}=Td(),[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(null),l=t;try{l=decodeURIComponent(t)}catch{}(0,y.useEffect)(()=>{let e=Date.now(),t=setInterval(()=>o(Math.floor((Date.now()-e)/1e3)),1e3);return()=>clearInterval(t)},[]),(0,y.useEffect)(()=>{let t=!1,n=setInterval(async()=>{if(t)return;let n=await Q.getPreviewSliceProgress(e);!t&&n&&c(n)},1e3);return()=>{t=!0,clearInterval(n)}},[e]);let u=`slice-preview-${e}`;(0,y.useEffect)(()=>{let e=s&&s.stage&&s.total_percent>0,t=rAe(a);return e?r(u,n(`slice.previewWithProgress`,`Analyzing {{name}} — {{stage}} ({{percent}}%) — {{elapsed}}`,{name:l,stage:s.stage,percent:Math.min(100,Math.max(0,Math.round(s.total_percent))),elapsed:t}),`loading`):r(u,n(`slice.previewToast`,{name:l,elapsed:t}),`loading`),()=>{i(u)}},[a,s,l,r,i,n,u]);let d=s?.stage,f=s?.total_percent,p=d&&typeof f==`number`&&f>0?`${d} (${Math.min(100,Math.max(0,Math.round(f)))}%)`:n(`slice.analyzingPlateFilaments`);return(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 text-bambu-gray text-sm py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),p,(0,K.jsxs)(`span`,{className:`text-xs tabular-nums`,children:[a,`s`]})]}),a>=5&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/70 pl-6`,children:n(`slice.analyzingPlateFilamentsHint`,`Running a preview slice to discover which AMS slots this plate uses. Cached after — re-opening is instant.`)})]})}function rAe(e){let t=Math.max(0,Math.floor(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}function zW({source:e,onClose:t}){let{t:n}=W(),{trackJob:r}=Xke(),i=no(),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)([]),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),b=q({queryKey:[`slicePlates`,e.kind,e.id],queryFn:async()=>e.kind===`libraryFile`?Q.getLibraryFilePlates(e.id):Q.getArchivePlates(e.id),staleTime:6e4}),x=!!b.data?.is_multi_plate&&(b.data?.plates?.length??0)>1,S=x&&p==null,C=p??1,w=(0,y.useMemo)(()=>{let t=typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`;return`${e.kind}-${e.id}-p${C}-${t}`},[e.kind,e.id,C]),T=q({queryKey:[`sliceFilamentReqs`,e.kind,e.id,C],queryFn:async()=>e.kind===`libraryFile`?Q.getLibraryFileFilamentRequirements(e.id,C,w):Q.getArchiveFilamentRequirements(e.id,C,w),enabled:!S,staleTime:6e4}),E=(0,y.useMemo)(()=>{let e=T.data?.filaments??[],t=e.length>0?e:[{slot_id:1,type:``,color:``,used_grams:0,used_meters:0}];return h?t.map(e=>({...e,used_in_plate:!0})):t},[h,T.data]),D=q({queryKey:[`slicerPresets`],queryFn:()=>Q.getSlicerPresets(),staleTime:6e4,enabled:!b.isLoading&&!S}),[O,k]=(0,y.useState)(!1),A=async()=>{if(!O){k(!0);try{let e=await Q.getSlicerPresets({refresh:!0});i.setQueryData([`slicerPresets`],e)}catch{i.invalidateQueries({queryKey:[`slicerPresets`]})}finally{k(!1)}}},j=q({queryKey:[`slicerPrinterModels`],queryFn:Q.getSlicerPrinterModels,staleTime:1/0}),M=(0,y.useMemo)(()=>!D.data||!a?null:LW(D.data,a,`printer`)?.name??null,[D.data,a]),N=(0,y.useMemo)(()=>yU(j.data??{}),[j.data]),P=b.data?.embedded_printer??null,F=b.data?.embedded_process??null;(0,y.useEffect)(()=>{let e=D.data;e&&(a??o(RW(e,`printer`,P)??IW(e,`printer`)))},[D.data,P]),(0,y.useEffect)(()=>{let e=D.data;e&&c(t=>{if(t){let n=LW(e,t,`process`);if(n&&SU(n,`process`,M,N)!==`mismatch`)return t}return Zke(e,M,N,F)})},[D.data,M,N,F]),(0,y.useEffect)(()=>{let e=D.data;e&&u(t=>E.map((n,r)=>{let i=t[r]??null;if(i){let t=LW(e,i,`filament`);if(t&&SU(t,`filament`,M,N)!==`mismatch`)return i}return $ke(e,{type:n.type,color:n.color},M,N)}))},[D.data,E,M,N]);let I=J({mutationFn:async t=>{let n=L(t);return e.kind===`libraryFile`?Q.sliceLibraryFile(e.id,n):Q.sliceArchive(e.id,n)},onSuccess:n=>{r(n.job_id,e.kind,e.filename),t()},onError:e=>{f(e instanceof Error?e.message:String(e))}});function L(e){if(!a||!s||l.length===0||l.some(e=>e==null))throw Error(n(`slice.allPresetsRequired`));return{printer_preset:a,process_preset:s,filament_preset:l[0],filament_presets:l,...e==null?{}:{plate:e},..._==null?{}:{bed_type:_}}}let R=a!=null&&s!=null&&T.isSuccess&&l.length>0&&l.every(e=>e!=null),z=I.isPending,B=b.data?.plates?.length??0,V=x&&B>1&&!S;return S&&b.data?(0,K.jsx)(PW,{plates:b.data.plates,onSelect:e=>m(e),onClose:t}):(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:()=>{z||t()},children:(0,K.jsxs)(`div`,{className:`w-full max-w-xl max-h-[85vh] flex flex-col rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary/60`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-start justify-between gap-3 px-4 pt-4 pb-3 border-b border-bambu-dark-tertiary/40`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`h3`,{className:`text-white font-medium flex items-center gap-2`,children:[(0,K.jsx)(ks,{className:`w-4 h-4`}),n(`slice.title`)]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate`,title:e.filename,children:[e.filename,p==null?``:` • ${n(`archives.platePicker.plateLabel`,{index:p})}`]})]}),(0,K.jsx)(`button`,{onClick:t,disabled:z,className:`flex-shrink-0 text-bambu-gray hover:text-white transition-colors disabled:opacity-50`,"aria-label":n(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(b.isLoading||D.isLoading)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`slice.loadingPresets`)]}),D.isError&&(0,K.jsx)(`div`,{className:`text-sm text-red-400`,role:`alert`,children:n(`slice.presetsLoadFailed`,`Failed to load presets. Open Settings → Profiles to import them, or sign in to Bambu Cloud.`)}),D.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,K.jsx)(BW,{status:D.data.cloud_status,cloudName:`bambu`}),(0,K.jsx)(BW,{status:D.data.orca_cloud_status,cloudName:`orca`})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:A,disabled:O||z,className:`flex-shrink-0 inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/40 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:n(`slice.refreshPresetsTitle`),"aria-label":n(`slice.refreshPresets`),children:[(0,K.jsx)(Ol,{className:`w-3.5 h-3.5 ${O?`animate-spin`:``}`}),n(`slice.refreshPresets`)]})]}),(0,K.jsx)(VW,{label:n(`slice.printer`),slot:`printer`,data:D.data,value:a,onChange:o,disabled:z}),(0,K.jsx)(VW,{label:n(`slice.process`),slot:`process`,data:D.data,value:s,onChange:c,disabled:z,selectedPrinterName:M,compatIndex:N}),(0,K.jsx)(aAe,{value:_,onChange:v,disabled:z}),T.isLoading?(0,K.jsx)(nAe,{requestId:w,sourceName:e.filename}):E.map((e,t)=>{let r=e.used_in_plate!==!1,i=E.length>1?n(`slice.filamentSlot`,{index:t+1,type:e.type}):n(`slice.filament`);return(0,K.jsx)(VW,{label:r?i:`${i} ${n(`slice.notUsedByPlate`)}`,slot:`filament`,data:D.data,value:l[t]??null,onChange:e=>u(n=>{let r=n.length===E.length?[...n]:E.map((e,t)=>n[t]??null);return r[t]=e,r}),disabled:z||!r,swatchColor:E.length>1?e.color:void 0,selectedPrinterName:M,compatIndex:N},`filament-${t}`)})]}),d&&(0,K.jsx)(`div`,{className:`text-sm text-red-400 bg-red-900/20 border border-red-900/40 rounded p-2`,role:`alert`,children:d})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex justify-end gap-2 px-4 py-3 border-t border-bambu-dark-tertiary/40`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:t,disabled:z,className:`px-3 py-1.5 text-sm rounded-md border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray transition-colors disabled:opacity-50`,children:n(`common.cancel`)}),V&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 mr-auto text-sm text-bambu-gray cursor-pointer select-none`,title:n(`slice.actionAllTitle`,{count:B}),children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),disabled:z,className:`cursor-pointer`}),n(`slice.allPlatesToggle`,{count:B})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{f(null);let e=h?0:p;I.mutate(e)},disabled:!R||z,className:`px-3 py-1.5 text-sm rounded-md bg-bambu-green hover:bg-bambu-green/90 text-bambu-dark font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2`,children:z?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`slice.enqueuing`)]}):h?n(`slice.actionAll`,{count:B}):n(`slice.action`)})]})]})})}function BW({status:e,cloudName:t=`bambu`}){let{t:n}=W();if(e===`ok`||e===`not_authenticated`)return null;let r=t===`orca`?{expired:{key:`slice.orcaCloud.expired`,fallback:`Orca Cloud session expired — sign in again to refresh your Orca presets.`},unreachable:{key:`slice.orcaCloud.unreachable`,fallback:`Orca Cloud is unreachable right now. Other presets still work.`}}:{expired:{key:`slice.cloud.expired`,fallback:`Bambu Cloud session expired — sign in again to refresh your cloud presets.`},unreachable:{key:`slice.cloud.unreachable`,fallback:`Bambu Cloud is unreachable right now. Local and standard presets still work.`}},{tone:i,icon:a}={expired:{tone:`border-amber-700/40 bg-amber-900/20 text-amber-200`,icon:Cs},unreachable:{tone:`border-bambu-dark-tertiary/40 bg-bambu-dark text-bambu-gray`,icon:Cs}}[e],{key:o,fallback:s}=r[e];return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs rounded-md border p-2 ${i}`,role:`status`,children:[(0,K.jsx)(a,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:n(o,s)})]})}var iAe=[{value:`Cool Plate`,labelKey:`slice.bedType.coolPlate`,fallback:`Cool Plate`},{value:`Cool Plate (SuperTack)`,labelKey:`slice.bedType.coolPlateSuperTack`,fallback:`Cool Plate SuperTack`},{value:`Engineering Plate`,labelKey:`slice.bedType.engineering`,fallback:`Engineering Plate`},{value:`High Temp Plate`,labelKey:`slice.bedType.highTemp`,fallback:`High Temp Plate`},{value:`Textured PEI Plate`,labelKey:`slice.bedType.texturedPEI`,fallback:`Textured PEI Plate`},{value:`Smooth PEI Plate`,labelKey:`slice.bedType.smoothPEI`,fallback:`Smooth PEI Plate`}];function aAe({value:e,onChange:t,disabled:n}){let{t:r}=W();return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsx)(`span`,{className:`block text-xs text-bambu-gray mb-1`,children:r(`slice.bedType.label`)}),(0,K.jsxs)(`select`,{value:e??``,onChange:e=>t(e.target.value===``?null:e.target.value),disabled:n,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,K.jsx)(`option`,{value:``,children:r(`slice.bedType.auto`)}),iAe.map(e=>(0,K.jsx)(`option`,{value:e.value,children:r(e.labelKey,e.fallback)},e.value))]})]})}function VW({label:e,slot:t,data:n,value:r,onChange:i,disabled:a,swatchColor:o,selectedPrinterName:s,compatIndex:c}){let{t:l}=W(),{sections:u,otherEntries:d}=(0,y.useMemo)(()=>{let e=[{key:`local`,label:`slice.tier.local`,fallback:`Imported`},{key:`orca_cloud`,label:`slice.tier.orcaCloud`,fallback:`Orca Cloud`},{key:`cloud`,label:`slice.tier.cloud`,fallback:`Bambu Cloud`},{key:`standard`,label:`slice.tier.standard`,fallback:`Standard`}],r=t!==`printer`,i=[],a=[];for(let{key:o,label:u,fallback:d}of e){let e=n[o][t];if(!r){e.length>0&&i.push({tierLabel:l(u,d),entries:e});continue}let f=[];for(let n of e)SU(n,t,s??null,c??WOe)===`mismatch`?a.push(n):f.push(n);f.length>0&&i.push({tierLabel:l(u,d),entries:f})}return{sections:i,otherEntries:a}},[n,t,l,s,c]),f=u.reduce((e,t)=>e+t.entries.length,0)+d.length;return(0,K.jsxs)(`label`,{className:`block`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-bambu-gray mb-1`,children:[o&&(0,K.jsx)(`span`,{className:`inline-block w-3 h-3 rounded-full border border-bambu-dark-tertiary`,style:{backgroundColor:o||`transparent`},"aria-hidden":!0}),(0,K.jsx)(`span`,{children:e})]}),(0,K.jsxs)(`select`,{value:eAe(r),onChange:e=>i(tAe(e.target.value)),disabled:a||f===0,className:`w-full px-3 py-2 rounded-md bg-bambu-dark border border-bambu-dark-tertiary text-white text-sm focus:outline-none focus:border-bambu-gray disabled:opacity-50`,children:[(0,K.jsx)(`option`,{value:``,children:l(f===0?`slice.noPresetsForSlot`:`slice.selectPreset`)}),u.map(e=>(0,K.jsx)(`optgroup`,{label:e.tierLabel,children:e.entries.map(e=>(0,K.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))},e.tierLabel)),d.length>0&&(0,K.jsx)(`optgroup`,{label:l(`slice.otherPrinters`),children:d.map(e=>(0,K.jsx)(`option`,{value:`${e.source}:${e.id}`,children:e.name},`${e.source}:${e.id}`))})]})]})}function oAe(){let e=navigator.userAgent.toLowerCase(),t=navigator.platform?.toLowerCase()||``;return e.includes(`win`)||t.includes(`win`)?`windows`:e.includes(`mac`)||t.includes(`mac`)?`macos`:e.includes(`linux`)||t.includes(`linux`)?`linux`:`unknown`}function HW(e,t=`bambu_studio`){let n,r=encodeURIComponent(e);n=t===`orcaslicer`?`orcaslicer://open?file=${r}`:oAe()===`macos`?`bambustudioopen://${r}`:`bambustudio://open?file=${r}`;let i=document.createElement(`a`);i.href=n,i.style.display=`none`,document.body.appendChild(i),i.click(),document.body.removeChild(i)}var UW=768;function WW(){let[e,t]=(0,y.useState)(()=>typeof window<`u`?window.innerWidth{let e=window.matchMedia(`(max-width: ${UW-1}px)`),n=e=>{t(e.matches)};return t(e.matches),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function GW({onFiles:e,onRejected:t,extensions:n,disabled:r=!1}){let[i,a]=(0,y.useState)(!1),o=(0,y.useRef)(e),s=(0,y.useRef)(t),c=(0,y.useRef)(n);(0,y.useEffect)(()=>{o.current=e},[e]),(0,y.useEffect)(()=>{s.current=t},[t]),(0,y.useEffect)(()=>{c.current=n},[n]);let l=(0,y.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),u=(0,y.useCallback)(e=>{r||(e.preventDefault(),e.dataTransfer.types.includes(`Files`)&&a(!0))},[r]),d=(0,y.useCallback)(e=>{if(r)return;e.preventDefault();let t=e.currentTarget,n=e.relatedTarget;(!n||!t.contains(n))&&a(!1)},[r]),f=(0,y.useCallback)(e=>{if(r)return;e.preventDefault(),a(!1);let t=Array.from(e.dataTransfer.files);if(t.length===0)return;let n=c.current,i=n&&n.length>0?t.filter(e=>n.some(t=>e.name.toLowerCase().endsWith(t))):t;i.length>0?o.current(i):s.current?.()},[r]);return(0,y.useEffect)(()=>{if(!i)return;let e=()=>a(!1),t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`drop`,e),document.addEventListener(`dragend`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`drop`,e),document.removeEventListener(`dragend`,e),document.removeEventListener(`keydown`,t)}},[i]),{isDraggingOver:i,dragHandlers:{onDragOver:l,onDragEnter:u,onDragLeave:d,onDrop:f}}}function sAe({onClose:e,initialFiles:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(()=>t?.filter(e=>e.name.endsWith(`.3mf`)).map(e=>({file:e,status:`pending`}))||[]),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null);(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]);let f=J({mutationFn:e=>Q.uploadArchivesBulk(e),onSuccess:e=>{d(e),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archiveStats`]}),s(t=>t.map(t=>{let n=e.results.find(e=>e.filename===t.file.name),r=e.errors.find(e=>e.filename===t.file.name);return n?{...t,status:`success`,archiveId:n.id}:r?{...t,status:`error`,error:r.error}:t})),e.failed===0?i(`${e.uploaded} file${e.uploaded===1?``:`s`} uploaded`):e.uploaded===0?i(`Failed to upload ${e.failed} file${e.failed===1?``:`s`}`,`error`):i(`${e.uploaded} uploaded, ${e.failed} failed`,`warning`)},onError:()=>{s(e=>e.map(e=>({...e,status:`error`,error:`Upload failed`}))),i(`Upload failed`,`error`)}}),p=(0,y.useCallback)(e=>{e.preventDefault(),l(!0)},[]),m=(0,y.useCallback)(e=>{e.preventDefault(),l(!1)},[]),h=(0,y.useCallback)(e=>{e.preventDefault(),l(!1);let t=Array.from(e.dataTransfer.files).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))])},[]),g=(0,y.useCallback)(e=>{let t=Array.from(e.target.files||[]).filter(e=>e.name.endsWith(`.3mf`));t.length>0&&s(e=>[...e,...t.map(e=>({file:e,status:`pending`}))]),a.current&&(a.current.value=``)},[]),_=(0,y.useCallback)(e=>{s(t=>t.filter((t,n)=>n!==e))},[]),v=()=>{if(o.length===0)return;let e=o.filter(e=>e.status===`pending`);e.length!==0&&(s(e=>e.map(e=>e.status===`pending`?{...e,status:`uploading`}:e)),f.mutate(e.map(e=>e.file)))},b=o.filter(e=>e.status===`pending`).length,x=f.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[90vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:n(`uploadModal.title`)}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`border-2 border-dashed rounded-lg p-8 text-center transition-colors ${c?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,onDragOver:p,onDragLeave:m,onDrop:h,children:[(0,K.jsx)(Du,{className:`w-12 h-12 mx-auto mb-4 text-bambu-gray`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:n(`uploadModal.dragDrop`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mb-4`,children:n(`uploadModal.or`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>a.current?.click(),disabled:x,children:n(`uploadModal.browseFiles`)}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`.3mf`,multiple:!0,className:`hidden`,onChange:g})]})}),(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`uploadModal.extractionInfo`)})}),o.length>0&&(0,K.jsx)(`div`,{className:`px-4 pb-4 max-h-60 overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`space-y-2`,children:o.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(rc,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1 text-white text-sm truncate`,children:e.file.name}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[(e.file.size/(1024*1024)).toFixed(1),` MB`]}),e.status===`pending`&&(0,K.jsx)(`button`,{onClick:()=>_(t),className:`text-bambu-gray hover:text-red-400 transition-colors`,disabled:x,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})}),e.status===`uploading`&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`}),e.status===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green`}),e.status===`error`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-red-400`,children:e.error}),(0,K.jsx)(ds,{className:`w-4 h-4 text-red-400`})]})]},`${e.file.name}-${t}`))})}),u&&(0,K.jsx)(`div`,{className:`px-4 pb-4`,children:(0,K.jsx)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsx)(`span`,{className:`text-bambu-green`,children:u.uploaded}),` `,n(`uploadModal.uploaded`),u.failed>0&&(0,K.jsxs)(K.Fragment,{children:[`, `,(0,K.jsx)(`span`,{className:`text-red-400`,children:u.failed}),` `,n(`uploadModal.failed`)]})]})})}),(0,K.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:n(u?`common.close`:`common.cancel`)}),!u&&(0,K.jsx)($,{onClick:v,disabled:b===0||x,className:`flex-1`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`uploadModal.uploading`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`uploadModal.upload`),` `,b>0&&`(${b})`]})})]})]})})})}var cAe=365;function lAe({onClose:e,initialDays:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(t??cAe),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(a);(0,y.useEffect)(()=>{let e=window.setTimeout(()=>u(a),300);return()=>window.clearTimeout(e)},[a]);let d=q({queryKey:[`archive-purge-preview`,l,s],queryFn:()=>Q.previewArchivePurge(l,s),enabled:l>=1}),f=J({mutationFn:()=>Q.executeArchivePurge(a,s),onSuccess:t=>{i(n(`archivePurge.toast.success`,{count:t.deleted}),`success`),r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`archive-stats`]}),e()},onError:e=>i(e.message||n(`archivePurge.toast.failed`),`error`)});(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!f.isPending&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,f.isPending]);let p=d.data,m=p?.count??0,h=p?.total_bytes??0,g=m>0&&!f.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-lg w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),n(`archivePurge.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`,"aria-label":n(`common.close`),disabled:f.isPending,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.description`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`archive-purge-days`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`archivePurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{id:`archive-purge-days`,type:`number`,min:1,max:3650,value:a,onChange:e=>o(Math.max(1,Math.min(3650,parseInt(e.target.value||`0`,10)||0))),className:`w-24 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`archivePurge.days`)})]})]}),(0,K.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/30 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-2`,children:n(`archivePurge.effectsTitle`)}),(0,K.jsxs)(`ul`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1 list-disc pl-4`,children:[(0,K.jsx)(`li`,{children:n(`archivePurge.effect1`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect2`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect3`)}),(0,K.jsx)(`li`,{children:n(`archivePurge.effect4`)})]})]}),(0,K.jsx)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 p-3`,children:d.isLoading||d.isFetching?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,n(`archivePurge.previewLoading`)]}):d.isError?(0,K.jsx)(`div`,{className:`text-sm text-red-600 dark:text-red-400`,children:d.error?.message??n(`archivePurge.previewFailed`)}):(0,K.jsxs)(`div`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:n(`archivePurge.previewSummary`,{count:m,size:Cd(h)})}),p?.sample_filenames&&p.sample_filenames.length>0&&(0,K.jsxs)(`ul`,{className:`mt-2 text-xs text-gray-600 dark:text-gray-400 space-y-0.5 list-disc pl-4`,children:[p.sample_filenames.map(e=>(0,K.jsx)(`li`,{className:`truncate`,children:e},e)),m>p.sample_filenames.length&&(0,K.jsx)(`li`,{className:`list-none italic text-gray-500`,children:n(`archivePurge.andMore`,{count:m-p.sample_filenames.length})})]})]})}),(0,K.jsxs)(`label`,{className:`flex gap-2 items-start rounded border border-gray-200 dark:border-gray-700 px-3 py-2 cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800/50`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:s,onChange:e=>c(e.target.checked),disabled:f.isPending,className:`mt-0.5 shrink-0`}),(0,K.jsxs)(`span`,{className:`text-xs text-gray-700 dark:text-gray-300`,children:[(0,K.jsx)(`span`,{className:`font-medium block mb-0.5`,children:n(`archivePurge.purgeStatsLabel`)}),(0,K.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400`,children:n(`archivePurge.purgeStatsHint`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-start text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-3 py-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`archivePurge.warning`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:f.isPending,children:n(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,disabled:!g,onClick:()=>f.mutate(),children:f.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}),n(`archivePurge.purging`)]}):n(`archivePurge.confirmCta`,{count:m})})]})]})})}function uAe(e){if(!e||e<=0)return`—`;let t=Math.floor(e/3600),n=Math.floor(e%3600/60);return t>0?`${t}h ${n}m`:`${n}m`}function dAe(e){if(!e)return`—`;let t=vf(e);return t?t.toLocaleString():`—`}function KW({archiveId:e}){let{t}=W(),{data:n,isLoading:r}=q({queryKey:[`archive-runs`,e],queryFn:()=>Q.getArchiveRuns(e)});if(r)return(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-gray animate-spin`})});let i=n?.items||[];return i.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:t(`archives.runLog.empty`)}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.date`)}),(0,K.jsx)(`th`,{className:`text-left py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.status`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.duration`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2 font-medium`,children:t(`archives.runLog.col.filament`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 font-medium`,children:t(`archives.runLog.col.cost`)})]})}),(0,K.jsx)(`tbody`,{children:i.map(e=>{let n=e.status===`completed`?`text-bambu-green`:e.status===`failed`?`text-red-400`:`text-bambu-gray`;return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/40 last:border-0`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-bambu-gray-light`,children:dAe(e.started_at||e.created_at)}),(0,K.jsxs)(`td`,{className:`py-1.5 pr-2 font-medium ${n}`,children:[t(`archives.runLog.status.${e.status}`,{defaultValue:e.status}),e.failure_reason&&(0,K.jsx)(`span`,{className:`block text-[10px] text-bambu-gray font-normal`,children:t(`editArchive.failureReasons.${e.failure_reason}`,{defaultValue:e.failure_reason})})]}),(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:uAe(e.duration_seconds)}),(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-right text-bambu-gray-light`,children:e.filament_used_grams==null?`—`:`${e.filament_used_grams.toFixed(1)} g`}),(0,K.jsx)(`td`,{className:`py-1.5 text-right text-bambu-gray-light`,children:e.cost==null?`—`:e.cost.toFixed(2)})]},e.id)})})]})})}var qW=[`adhesionFailure`,`spaghettiDetached`,`layerShift`,`cloggedNozzle`,`filamentRunout`,`warping`,`stringing`,`underExtrusion`,`powerFailure`,`userCancelled`,`other`],fAe=[`completed`,`failed`,`aborted`,`printing`];function JW({archive:e,onClose:t,existingTags:n=[]}){let{t:r}=W();(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let i=no(),[a,o]=(0,y.useState)(e.print_name||``),[s,c]=(0,y.useState)(e.printer_id),[l,u]=(0,y.useState)(e.project_id??null),[d,f]=(0,y.useState)(e.notes||``),[p,m]=(0,y.useState)(e.tags||``),[h,g]=(0,y.useState)(()=>{let t=e.failure_reason||``;return t?qW.includes(t)?t:qW.find(e=>r(`editArchive.failureReasons.${e}`)===t)||``:``}),[_,v]=(0,y.useState)(e.status),[b,x]=(0,y.useState)(e.quantity??1),[S,C]=(0,y.useState)(e.photos||[]),[w,T]=(0,y.useState)(e.external_url||``),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),A=(0,y.useRef)(null),j=(0,y.useRef)(null),M=(0,y.useRef)(null),{data:N}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:P}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),{data:F}=q({queryKey:[`tags`],queryFn:Q.getTags,enabled:n.length===0}),I=n.length>0?n:F?.map(e=>e.name)||[],L=p.split(`,`).map(e=>e.trim()).filter(Boolean),R=p.includes(`,`)?p.substring(p.lastIndexOf(`,`)+1).trim().toLowerCase():p.trim().toLowerCase(),z=I.filter(e=>!L.includes(e)&&(R===``||e.toLowerCase().includes(R))),B=e=>{let t;t=R&&!I.includes(R)?p.includes(`,`)?p.substring(0,p.lastIndexOf(`,`)).split(`,`).map(e=>e.trim()).filter(Boolean):[]:L,t.includes(e)||m([...t,e].join(`, `)),M.current!==null&&clearTimeout(M.current),A.current?.focus()},V=e=>{m(L.filter(t=>t!==e).join(`, `))},ee=J({mutationFn:t=>Q.updateArchive(e.id,t),onSuccess:()=>{i.invalidateQueries({queryKey:[`archives`]}),i.invalidateQueries({queryKey:[`projects`]}),t()}}),te=async t=>{let n=t.target.files?.[0];if(n){D(!0);try{C((await Q.uploadArchivePhoto(e.id,n)).photos),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to upload photo:`,e)}finally{D(!1),j.current&&(j.current.value=``)}}},ne=async t=>{try{C((await Q.deleteArchivePhoto(e.id,t)).photos||[]),i.invalidateQueries({queryKey:[`archives`]})}catch(e){console.error(`Failed to delete photo:`,e)}};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`editArchive.title`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let n={print_name:a||void 0,printer_id:s,project_id:l,notes:d||void 0,tags:p||void 0,quantity:b,external_url:w||null};_!==e.status&&(n.status=_),_===`failed`||_===`aborted`?n.failure_reason=h||void 0:(e.status===`failed`||e.status===`aborted`)&&(n.failure_reason=null),ee.mutate(n)},className:`p-6 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`archives.runLog.title`)}),(0,K.jsx)(KW,{archiveId:e.id})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.name`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:r(`editArchive.namePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.printer`)}),(0,K.jsxs)(`select`,{value:s??``,onChange:e=>c(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.noPrinter`)}),N?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(sc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.project`)]}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.noProject`)}),P?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Tc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.itemsPrinted`)]}),(0,K.jsx)(`input`,{type:`number`,min:1,value:b,onChange:e=>x(Math.max(1,parseInt(e.target.value)||1)),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.itemsPrintedHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.notes`)}),(0,K.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none resize-none`,placeholder:r(`editArchive.notesPlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Hc,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.externalLink`)]}),(0,K.jsx)(`input`,{type:`url`,value:w,onChange:e=>T(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:`https://printables.com/model/...`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`editArchive.externalLinkHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.tags`)}),L.length>0&&(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:L.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white`,children:[(0,K.jsx)(fu,{className:`w-3 h-3`}),e,(0,K.jsx)(`button`,{type:`button`,onClick:()=>V(e),className:`ml-0.5 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{ref:A,type:`text`,value:p,onChange:e=>m(e.target.value),onFocus:()=>{M.current!==null&&clearTimeout(M.current),k(!0)},onBlur:()=>{M.current=window.setTimeout(()=>k(!1),200)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:L.length>0?r(`editArchive.addMoreTags`):r(`editArchive.tagsPlaceholder`)}),O&&z.length>0&&(0,K.jsxs)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-10 max-h-40 overflow-y-auto`,children:[(0,K.jsxs)(`div`,{className:`p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary`,children:[R?r(`editArchive.matchingTags`,{query:R}):r(`editArchive.existingTags`),` `,r(`editArchive.clickToAdd`)]}),(0,K.jsx)(`div`,{className:`p-2 flex flex-wrap gap-1.5`,children:z.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>B(e),className:`px-2 py-0.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded text-sm text-bambu-gray hover:text-white transition-colors`,children:e},e))})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.status`)}),(0,K.jsx)(`select`,{value:_,onChange:e=>{v(e.target.value),e.target.value===`completed`&&g(``)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:fAe.map(e=>(0,K.jsx)(`option`,{value:e,children:r(`editArchive.statuses.${e}`)},e))})]}),(_===`failed`||_===`aborted`)&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`failure-reason-select`,className:`block text-sm text-bambu-gray mb-1`,children:r(`editArchive.failureReason`)}),(0,K.jsxs)(`select`,{id:`failure-reason-select`,value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`editArchive.selectReason`)}),qW.map(e=>(0,K.jsx)(`option`,{value:e,children:r(`editArchive.failureReasons.${e}`)},e))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(Qo,{className:`w-4 h-4 inline mr-1`}),r(`editArchive.photos`)]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:[S.map(t=>(0,K.jsxs)(`div`,{className:`relative group`,children:[(0,K.jsx)(`img`,{src:Q.getArchivePhotoUrl(e.id,t),alt:r(`editArchive.printResult`),className:`w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>ne(t),className:`absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(bu,{className:`w-3 h-3 text-white`})})]},t)),(0,K.jsxs)(`label`,{className:`w-20 h-20 flex items-center justify-center border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green transition-colors`,children:[(0,K.jsx)(`input`,{ref:j,type:`file`,accept:`image/jpeg,image/png,image/webp`,onChange:te,className:`hidden`,disabled:E}),E?(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-gray animate-spin`}):(0,K.jsx)(Sl,{className:`w-6 h-6 text-bambu-gray`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`editArchive.photosHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:ee.isPending,className:`flex-1`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),ee.isPending?r(`common.saving`):r(`common.save`)]})]})]})]})})}function YW({archiveId:e,archiveName:t,onClose:n}){let{t:r}=W();return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-2xl max-h-[85vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,title:t||``,children:r(`archives.runLog.modalTitle`,{name:t||r(`archives.runLog.modalTitleFallback`)})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`p-6 overflow-y-auto flex-1`,children:(0,K.jsx)(KW,{archiveId:e})})]})})}function pAe({items:e,searchPlaceholder:t,onClose:n,className:r,onMouseEnter:i,onMouseLeave:a}){let[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(t){let e=window.setTimeout(()=>c.current?.focus(),0);return()=>window.clearTimeout(e)}},[t]);let l=o.trim().toLowerCase(),u=t&&l?e.filter(e=>e.label.toLowerCase().includes(l)):e;return(0,K.jsxs)(`div`,{className:r,onMouseEnter:i,onMouseLeave:a,children:[t&&(0,K.jsx)(`div`,{className:`sticky top-0 z-[1] px-2 py-1.5 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{ref:c,type:`text`,value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{if(e.key===`Enter`){let e=u.find(e=>!e.disabled);e&&(e.onClick(),n())}},placeholder:t,className:`w-full pl-7 pr-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})}),u.map((e,t)=>(0,K.jsxs)(`button`,{onClick:()=>{e.disabled||(e.onClick(),n())},disabled:e.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e.icon&&(0,K.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.label})]},t)),t&&u.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray text-center italic`,children:`—`})]})}function XW({x:e,y:t,items:n,onClose:r}){let i=(0,y.useRef)(null),[a,o]=(0,y.useState)(null),s=(0,y.useRef)(null),[c,l]=(0,y.useState)({x:e,y:t,visible:!1}),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)({});(0,y.useEffect)(()=>{let e=e=>{i.current&&!i.current.contains(e.target)&&r()},t=e=>{e.key===`Escape`&&r()},n=e=>{i.current&&i.current.contains(e.target)||r()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),document.addEventListener(`scroll`,n,!0),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t),document.removeEventListener(`scroll`,n,!0),s.current&&clearTimeout(s.current)}},[r]),(0,y.useLayoutEffect)(()=>{if(i.current){i.current.style.visibility=`hidden`,i.current.style.display=`block`;let n=i.current.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight,o=e,s=t;e+n.width>r-8&&(o=Math.max(8,r-n.width-8)),o<8&&(o=8),t+n.height>a-8&&(s=Math.max(8,a-n.height-8)),s<8&&(s=8),d(r-o-n.width<180&&o>180),l({x:o,y:s,visible:!0})}},[e,t]);let m=(e,t)=>{s.current&&=(clearTimeout(s.current),null);let n=t.getBoundingClientRect(),r=window.innerHeight-n.top-8<300&&n.top>300;p(t=>({...t,[e]:r?`bottom`:`top`})),o(e)},h=()=>{s.current=window.setTimeout(()=>{o(null)},150)};return(0,K.jsx)(`div`,{ref:i,className:`fixed z-50 min-w-[180px] max-w-[280px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1`,style:{left:c.x,top:c.y,visibility:c.visible?`visible`:`hidden`},children:n.map((e,t)=>{if(e.divider)return(0,K.jsx)(`div`,{className:`my-1 border-t border-bambu-dark-tertiary`},t);let n=e.submenu&&e.submenu.length>0;return(0,K.jsxs)(`div`,{className:`relative`,onMouseEnter:e=>n&&m(t,e.currentTarget),onMouseLeave:()=>n&&h(),children:[(0,K.jsxs)(`button`,{onMouseEnter:e=>n&&m(t,e.currentTarget.parentElement),onClick:()=>{n?o(a===t?null:t):e.disabled||(e.onClick(),r())},disabled:e.disabled,title:e.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${e.disabled?`text-bambu-gray cursor-not-allowed`:e.danger?`text-red-400 hover:bg-red-400/10`:`text-white hover:bg-bambu-dark-tertiary`} ${n&&a===t?`bg-bambu-dark-tertiary`:``}`,children:[e.icon&&(0,K.jsx)(`span`,{className:`w-4 h-4 flex-shrink-0 flex items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1`,children:e.label}),n&&(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`})]}),n&&a===t&&(0,K.jsx)(pAe,{items:e.submenu,searchPlaceholder:e.submenuSearchPlaceholder,onClose:r,className:`absolute min-w-[200px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 overflow-hidden max-h-[300px] overflow-y-auto z-[60] ${u?`right-full mr-1`:`left-full ml-1`} ${f[t]===`bottom`?`bottom-0`:`top-0`}`,onMouseEnter:()=>{s.current&&=(clearTimeout(s.current),null)},onMouseLeave:()=>h()})]},t)})})}function mAe({selectedIds:e,existingTags:t,onClose:n}){let r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(`add`);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let d=J({mutationFn:async()=>{let t=Array.from(s),n=0;for(let r of e)try{let e=await Q.getArchive(r),i=e.tags?e.tags.split(`,`).map(e=>e.trim()).filter(Boolean):[],a;a=l===`add`?[...new Set([...i,...t])]:i.filter(e=>!s.has(e)),await Q.updateArchive(r,{tags:a.join(`, `)}),n++}catch(e){throw console.error(`Failed to update archive ${r}:`,e),Error(`Failed on archive ${r}: ${e instanceof Error?e.message:`Unknown error`}`)}return{count:n,mode:l,tags:t}},onSuccess:({count:e,mode:t,tags:a})=>{r.invalidateQueries({queryKey:[`archives`]}),i(`${t===`add`?`Added`:`Removed`} ${a.length} tag${a.length===1?``:`s`} ${t===`add`?`to`:`from`} ${e} archive${e===1?``:`s`}`),n()},onError:e=>{i(e.message||`Failed to update tags`,`error`)}}),f=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},p=()=>{a.trim()&&!s.has(a.trim())&&(c(e=>new Set([...e,a.trim()])),o(``))};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,children:(0,K.jsxs)(yd,{className:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:l===`add`?`Add Tags`:`Remove Tags`})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[l===`add`?`Add`:`Remove`,` tags for `,e.length,` selected archive`,e.length===1?``:`s`]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{size:`sm`,variant:l===`add`?`primary`:`secondary`,onClick:()=>u(`add`),children:`Add Tags`}),(0,K.jsx)($,{size:`sm`,variant:l===`remove`?`primary`:`secondary`,onClick:()=>u(`remove`),children:`Remove Tags`})]}),l===`add`&&(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:`Enter new tag...`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())}}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:p,disabled:!a.trim(),children:(0,K.jsx)(Sl,{className:`w-4 h-4`})})]}),t.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:`Existing tags:`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t.map(e=>(0,K.jsx)(`button`,{onClick:()=>f(e),className:`px-2 py-1 rounded text-sm transition-colors ${s.has(e)?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark`}`,children:e},e))})]}),s.size>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:[`Tags to `,l===`add`?`add`:`remove`,`:`]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Array.from(s).map(e=>(0,K.jsxs)(`span`,{className:`px-2 py-1 rounded text-sm flex items-center gap-1 ${l===`add`?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`}`,children:[e,(0,K.jsx)(`button`,{onClick:()=>f(e),className:`hover:opacity-70`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:n,className:`flex-1`,children:`Cancel`}),(0,K.jsx)($,{onClick:()=>d.mutate(),disabled:s.size===0||d.isPending,className:`flex-1`,children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),`Processing...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),l===`add`?`Add Tags`:`Remove Tags`]})})]})]})})})}function hAe({selectedIds:e,onClose:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(``),{data:s,isLoading:c}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects()}),l=(0,y.useMemo)(()=>s?[...s].sort((e,t)=>e.name.localeCompare(t.name)):void 0,[s]),u=a.trim().toLowerCase(),d=u?l?.filter(e=>e.name.toLowerCase().includes(u)):l,f=(l?.length??0)>5;(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let p=()=>{r.invalidateQueries({queryKey:[`archives`]}),r.invalidateQueries({queryKey:[`projects`]}),r.invalidateQueries({queryKey:[`project`]}),r.invalidateQueries({queryKey:[`project-archives`]})},m=J({mutationFn:async t=>(await Q.addArchivesToProject(t,e),t),onSuccess:n=>{let r=s?.find(e=>e.id===n);p(),i(`Added ${e.length} archive${e.length===1?``:`s`} to "${r?.name}"`),t()},onError:()=>{i(`Failed to assign project`,`error`)}}),h=J({mutationFn:async()=>{for(let t of e)await Q.updateArchive(t,{project_id:null});return e.length},onSuccess:e=>{p(),i(`Removed ${e} archive${e===1?``:`s`} from project`),t()},onError:()=>{i(`Failed to remove from project`,`error`)}}),g=m.isPending||h.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-md max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:`Assign to Project`})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,disabled:g,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-3 overflow-y-auto min-h-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Assign `,e.length,` selected archive`,e.length===1?``:`s`,` to a project`]}),c?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-gray`})}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>h.mutate(),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0`,children:(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:`Remove from project`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray truncate`,children:`Clear project assignment`})]}),h.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]}),l&&l.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`or assign to`}),(0,K.jsx)(`div`,{className:`flex-1 h-px bg-bambu-dark-tertiary`})]}),f&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`archives.menu.searchProjects`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray text-sm focus:border-bambu-green focus:outline-none`})]}),d?.map(e=>(0,K.jsxs)(`button`,{onClick:()=>m.mutate(e.id),disabled:g,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary transition-colors text-left disabled:opacity-50`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0`,style:{backgroundColor:e.color?`${e.color}20`:`rgb(var(--bambu-green) / 0.2)`},children:(0,K.jsx)(sc,{className:`w-4 h-4`,style:{color:e.color||`rgb(var(--bambu-green))`}})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray truncate`,children:[e.archive_count,` archive`,e.archive_count===1?``:`s`,e.status&&` • ${e.status}`]})]}),m.isPending&&m.variables===e.id&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray shrink-0`})]},e.id)),(!l||l.length===0)&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-4`,children:`No projects yet. Create one from the Projects page.`}),l&&l.length>0&&d?.length===0&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray text-sm py-4`,children:`—`})]})]}),(0,K.jsx)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`flex-1`,disabled:g,children:`Cancel`})})]})})})}function gAe(e,t){return new Date(e,t+1,0).getDate()}function _Ae(e,t){return new Date(e,t,1).getDay()}var vAe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],yAe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function bAe({archives:e,onArchiveClick:t,highlightedArchiveId:n}){let r=new Date,[i,a]=(0,y.useState)(r.getMonth()),[o,s]=(0,y.useState)(r.getFullYear()),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(null),f=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`,i=t.get(r)||[];i.push(e),t.set(r,i)}),t},[e]),p=gAe(o,i),m=_Ae(o,i),h=()=>{i===0?(a(11),s(o-1)):a(i-1)},g=()=>{i===11?(a(0),s(o+1)):a(i+1)},_=()=>{a(r.getMonth()),s(r.getFullYear())},v=[];for(let e=0;e{e!==c&&d(null),l(e)};return(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`button`,{onClick:h,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(ss,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[vAe[i],` `,o]}),(0,K.jsx)(`button`,{onClick:_,className:`px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors`,children:`Today`})]}),(0,K.jsx)(`button`,{onClick:g,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(as,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-7 gap-1 mb-1`,children:yAe.map(e=>(0,K.jsx)(`div`,{className:`text-center text-xs text-bambu-gray py-2`,children:e},e))}),(0,K.jsx)(`div`,{className:`grid grid-cols-7 gap-1`,children:v.map((e,t)=>{if(e===null)return(0,K.jsx)(`div`,{className:`aspect-square`},`empty-${t}`);let n=`${o}-${String(i+1).padStart(2,`0`)}-${String(e).padStart(2,`0`)}`,a=f.get(n)||[],s=a.length>0,l=e===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),u=n===c,d=a.filter(e=>e.status===`completed`).length,p=a.filter(e=>e.status===`failed`).length;return(0,K.jsxs)(`button`,{onClick:()=>x(u?null:n),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${u?`bg-bambu-green text-white`:l?`bg-bambu-green/20 text-white ring-2 ring-bambu-green`:s?`bg-bambu-dark-tertiary hover:bg-bambu-dark-tertiary/70 text-white`:`hover:bg-bambu-dark-tertiary/50 text-bambu-gray`}`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium ${l&&!u?`text-bambu-green`:``}`,children:e}),s&&(0,K.jsxs)(`div`,{className:`absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${p>0&&d===0?`bg-red-400`:p>0?`bg-yellow-400`:`bg-green-400`}`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:a.length})]})]},e)})}),(0,K.jsx)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 text-center`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-white`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Prints this month`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-green-400`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`completed`}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Successful`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-2xl font-bold text-red-400`,children:e.filter(e=>{let t=vf(e.completed_at||e.created_at)||new Date;return t.getMonth()===i&&t.getFullYear()===o&&e.status===`failed`}).length}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:`Failed`})]})]})})]}),(0,K.jsx)(`div`,{className:`lg:w-80 bg-bambu-dark rounded-xl p-4`,children:c?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:new Date(c+`T12:00:00`).toLocaleDateString(`en-US`,{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`})}),b.length>0?(0,K.jsx)(`div`,{className:`calendar-scroll space-y-2 max-h-96 overflow-y-auto`,children:b.map(e=>{let r=e.id===u||e.id===n;return(0,K.jsxs)(`button`,{onClick:()=>{d(e.id),t?.(e)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${r?``:`hover:bg-bambu-dark-tertiary`}`,style:r?{outline:`4px solid #facc15`,outlineOffset:`2px`}:void 0,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:``,className:`w-12 h-12 rounded object-cover`}):(0,K.jsx)(`div`,{className:`w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`3MF`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.print_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:e.status===`failed`?`text-red-400`:`text-green-400`,children:e.status===`failed`?`Failed`:`Completed`}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex gap-0.5`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e}},t))})]})]})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`No prints on this day`})]}):(0,K.jsx)(`div`,{className:`text-center py-8`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`Select a day to see prints`})})})]})}function ZW({archiveId:e,archiveName:t,onClose:n}){let r=Q.getArchiveQRCodeUrl(e,300);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`QR Code`}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 flex flex-col items-center`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 text-center truncate max-w-full`,children:t}),(0,K.jsx)(`div`,{className:`bg-white p-4 rounded-lg mb-4`,children:(0,K.jsx)(`img`,{src:r,alt:`QR Code`,className:`w-64 h-64`})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4 text-center`,children:`Scan to open this archive`}),(0,K.jsxs)($,{onClick:()=>{let e=document.createElement(`a`);e.href=r,e.download=`${t}_qrcode.png`,e.click()},className:`w-full`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download QR Code`]})]})]})})}function QW({archiveId:e,archiveName:t,photos:n,onClose:r,onDelete:i}){let[a,o]=(0,y.useState)(0),[s,c]=(0,y.useState)(!1);if((0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r(),e.key===`ArrowLeft`&&o(e=>Math.max(0,e-1)),e.key===`ArrowRight`&&o(e=>Math.min(n.length-1,e+1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,n.length]),(0,y.useEffect)(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;let l=n[a],u=Q.getArchivePhotoUrl(e,l);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:r,children:[(0,K.jsxs)(`div`,{className:`relative w-full h-full flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 bg-black/50`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`Photo `,a+1,` of `,n.length]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=u,e.download=`${t}_photo_${a+1}.jpg`,e.click()},children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download`]}),i&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{i&&c(!0)},className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:r,className:`p-2 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-6 h-6`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden`,children:[a>0&&(0,K.jsx)(`button`,{onClick:()=>o(e=>e-1),className:`absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,K.jsx)(ss,{className:`w-8 h-8 text-white`})}),(0,K.jsx)(`img`,{src:u,alt:`Photo ${a+1}`,className:`max-w-full max-h-full object-contain rounded-lg`,style:{maxHeight:`calc(100vh - 200px)`}}),ao(e=>e+1),className:`absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors`,children:(0,K.jsx)(as,{className:`w-8 h-8 text-white`})})]}),n.length>1&&(0,K.jsx)(`div`,{className:`flex justify-center gap-2 p-4 bg-black/50`,children:n.map((t,n)=>(0,K.jsx)(`button`,{onClick:()=>o(n),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${n===a?`border-bambu-green`:`border-transparent hover:border-bambu-gray`}`,children:(0,K.jsx)(`img`,{src:Q.getArchivePhotoUrl(e,t),alt:`Thumbnail ${n+1}`,className:`w-full h-full object-cover`})},t))})]}),s&&(0,K.jsx)(Ad,{title:`Delete Photo`,message:`Delete this photo? This cannot be undone.`,confirmText:`Delete`,variant:`danger`,onConfirm:()=>{i?.(l),c(!1)},onCancel:()=>c(!1)})]})}function $W(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`?null:CG(BigInt.prototype.toString),vG=typeof Symbol>`u`?null:CG(Symbol.prototype.toString),yG=CG(Object.prototype.hasOwnProperty),bG=CG(Object.prototype.toString),xG=CG(RegExp.prototype.test),SG=PAe(TypeError);function CG(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return oG(e,t,n)}}function PAe(e){return function(){return sG(e,[...arguments])}}function wG(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:fG;if(tG&&tG(e,null),!dG(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(EAe(t)||(t[r]=e),i=e)}e[i]=!0}return e}function FAe(e){for(let t=0;t/g),HAe=rG(/\${[\w\W]*/g),UAe=rG(/^data-[\-\w.\u00B7-\uFFFF]+$/),WAe=rG(/^aria-[\-\w]+$/),IG=rG(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),GAe=rG(/^(?:\w+script|data):/i),KAe=rG(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qAe=rG(/^html$/i),JAe=rG(/^[a-z][.\w]*(-[.\w]+)+$/i),LG=rG(/<[/\w!]/g),YAe=rG(/<[/\w]/g),XAe=rG(/<\/no(script|embed|frames)/i),ZAe=rG(/\/>/i),RG={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},QAe=function(){return typeof window>`u`?null:window},$Ae=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},zG=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},BG=function(e,t,n,r){return yG(e,t)&&dG(e[t])?wG(r.base?TG(r.base):{},e[t],r.transform):n};function VG(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:QAe(),t=e=>VG(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==RG.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=EG(d,`cloneNode`),p=EG(d,`remove`),m=EG(d,`nextSibling`),h=EG(d,`childNodes`),g=EG(d,`parentNode`),_=EG(d,`shadowRoot`),v=EG(d,`attributes`),y=o&&o.prototype?EG(o.prototype,`nodeType`):null,b=o&&o.prototype?EG(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw SG(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=$Ae(u,i),!0),C},A=n,j=A.implementation,M=A.createNodeIterator,N=A.createDocumentFragment,P=A.getElementsByTagName,F=r.importNode,I=zG();t.isSupported=typeof eG==`function`&&typeof g==`function`&&j&&j.createHTMLDocument!==void 0;let L=BAe,R=VAe,z=HAe,B=UAe,V=WAe,ee=GAe,te=KAe,ne=JAe,re=IG,ie=null,H=wG({},[...DG,...OG,...kG,...AG,...jG]),ae=null,oe=wG({},[...MG,...NG,...PG,...FG]),U=Object.seal(iG(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),se=null,ce=null,le=Object.seal(iG(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ue=!0,de=!0,fe=!1,pe=!0,me=!1,he=!0,ge=!1,_e=!1,ve=null,ye=null,be=!1,xe=!1,Se=!1,Ce=!1,we=!0,Te=!1,Ee=`user-content-`,De=!0,Oe=!1,ke={},Ae=null,je=wG({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Me=null,Ne=wG({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Pe=null,Fe=wG({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ie=`http://www.w3.org/1998/Math/MathML`,Le=`http://www.w3.org/2000/svg`,Re=`http://www.w3.org/1999/xhtml`,ze=Re,Be=!1,Ve=null,He=wG({},[Ie,Le,Re],pG),Ue=nG([`mi`,`mo`,`mn`,`ms`,`mtext`]),We=wG({},Ue),Ge=nG([`annotation-xml`]),Ke=wG({},Ge),qe=wG({},[`title`,`style`,`font`,`a`,`script`]),Je=null,Ye=[`application/xhtml+xml`,`text/html`],Xe=null,Ze=null,Qe=n.createElement(`form`),$e=function(e){return e instanceof RegExp||e instanceof Function},W=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(Ze&&Ze===e)return;(!e||typeof e!=`object`)&&(e={}),e=TG(e),Je=Ye.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Xe=Je===`application/xhtml+xml`?pG:fG,ie=BG(e,`ALLOWED_TAGS`,H,{transform:Xe}),ae=BG(e,`ALLOWED_ATTR`,oe,{transform:Xe}),Ve=BG(e,`ALLOWED_NAMESPACES`,He,{transform:pG}),Pe=BG(e,`ADD_URI_SAFE_ATTR`,Fe,{transform:Xe,base:Fe}),Me=BG(e,`ADD_DATA_URI_TAGS`,Ne,{transform:Xe,base:Ne}),Ae=BG(e,`FORBID_CONTENTS`,je,{transform:Xe}),se=BG(e,`FORBID_TAGS`,TG({}),{transform:Xe}),ce=BG(e,`FORBID_ATTR`,TG({}),{transform:Xe}),ke=yG(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?TG(e.USE_PROFILES):e.USE_PROFILES:!1,ue=e.ALLOW_ARIA_ATTR!==!1,de=e.ALLOW_DATA_ATTR!==!1,fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,me=e.SAFE_FOR_TEMPLATES||!1,he=e.SAFE_FOR_XML!==!1,ge=e.WHOLE_DOCUMENT||!1,xe=e.RETURN_DOM||!1,Se=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,be=e.FORCE_BODY||!1,we=e.SANITIZE_DOM!==!1,Te=e.SANITIZE_NAMED_PROPS||!1,De=e.KEEP_CONTENT!==!1,Oe=e.IN_PLACE||!1,re=LAe(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:IG,ze=typeof e.NAMESPACE==`string`?e.NAMESPACE:Re,We=yG(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?TG(e.MATHML_TEXT_INTEGRATION_POINTS):wG({},Ue),Ke=yG(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?TG(e.HTML_INTEGRATION_POINTS):wG({},Ge);let t=yG(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?TG(e.CUSTOM_ELEMENT_HANDLING):iG(null);if(U=iG(null),yG(t,`tagNameCheck`)&&$e(t.tagNameCheck)&&(U.tagNameCheck=t.tagNameCheck),yG(t,`attributeNameCheck`)&&$e(t.attributeNameCheck)&&(U.attributeNameCheck=t.attributeNameCheck),yG(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(U.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),rG(U),me&&(de=!1),Se&&(xe=!0),ke&&(ie=wG({},jG),ae=iG(null),ke.html===!0&&(wG(ie,DG),wG(ae,MG)),ke.svg===!0&&(wG(ie,OG),wG(ae,NG),wG(ae,FG)),ke.svgFilters===!0&&(wG(ie,kG),wG(ae,NG),wG(ae,FG)),ke.mathMl===!0&&(wG(ie,AG),wG(ae,PG),wG(ae,FG))),le.tagCheck=null,le.attributeCheck=null,yG(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?le.tagCheck=e.ADD_TAGS:dG(e.ADD_TAGS)&&(ie===H&&(ie=TG(ie)),wG(ie,e.ADD_TAGS,Xe))),yG(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?le.attributeCheck=e.ADD_ATTR:dG(e.ADD_ATTR)&&(ae===oe&&(ae=TG(ae)),wG(ae,e.ADD_ATTR,Xe))),yG(e,`ADD_URI_SAFE_ATTR`)&&dG(e.ADD_URI_SAFE_ATTR)&&wG(Pe,e.ADD_URI_SAFE_ATTR,Xe),yG(e,`FORBID_CONTENTS`)&&dG(e.FORBID_CONTENTS)&&(Ae===je&&(Ae=TG(Ae)),wG(Ae,e.FORBID_CONTENTS,Xe)),yG(e,`ADD_FORBID_CONTENTS`)&&dG(e.ADD_FORBID_CONTENTS)&&(Ae===je&&(Ae=TG(Ae)),wG(Ae,e.ADD_FORBID_CONTENTS,Xe)),De&&(ie[`#text`]=!0),ge&&wG(ie,[`html`,`head`,`body`]),ie.table&&(wG(ie,[`tbody`]),delete se.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw SG(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw SG(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));nG&&nG(e),Ze=e},et=wG({},[...OG,...kG,...RAe]),tt=wG({},[...AG,...zAe]),nt=function(e,t,n){return t.namespaceURI===Re?e===`svg`:t.namespaceURI===Ie?e===`svg`&&(n===`annotation-xml`||We[n]):!!et[e]},rt=function(e,t,n){return t.namespaceURI===Re?e===`math`:t.namespaceURI===Le?e===`math`&&Ke[n]:!!tt[e]},it=function(e,t,n){return t.namespaceURI===Le&&!Ke[n]||t.namespaceURI===Ie&&!We[n]?!1:!tt[e]&&(qe[e]||!et[e])},at=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:ze,tagName:`template`});let n=fG(e.tagName),r=fG(t.tagName);return Ve[e.namespaceURI]?e.namespaceURI===Le?nt(n,t,r):e.namespaceURI===Ie?rt(n,t,r):e.namespaceURI===Re?it(n,t,r):!!(Je===`application/xhtml+xml`&&Ve[e.namespaceURI]):!1},ot=function(e){uG(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw SG(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},st=function(e){let t=h(e);if(t){let e=[];cG(t,t=>{uG(e,t)}),cG(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},ct=function(e,n){try{uG(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{uG(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(xe||Se)try{ot(n)}catch{}else try{n.setAttribute(e,``)}catch{}},lt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||ae[Xe(i)]))try{e.removeAttribute(i)}catch{}}},ut=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===RG.element&<(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},dt=function(e){let t=null,r=null;if(be)e=``+e;else{let t=mG(e,/^[\r\n\t ]+/);r=t&&t[0]}Je===`application/xhtml+xml`&&ze===Re&&(e=``+e+``);let i=x?D(e):e;if(ze===Re)try{t=new l().parseFromString(i,Je)}catch{}if(!t||!t.documentElement){t=j.createDocument(ze,`template`,null);try{t.documentElement.innerHTML=Be?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),ze===Re?P.call(t,ge?`html`:`body`)[0]:ge?t.documentElement:a},ft=function(e){return M.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},pt=function(e){return e=hG(e,L,` `),e=hG(e,R,` `),e=hG(e,z,` `),e},mt=function(e){e.normalize();let t=M.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=pt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&cG(r,e=>{gt(e.content)&&mt(e.content)})},ht=function(e){let t=b?b(e):null;return typeof t!=`string`||Xe(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},gt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===RG.documentFragment}catch{return!1}},_t=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function vt(e,n,r){e.length!==0&&cG(e,e=>{e.call(t,n,r,Ze)})}let yt=function(e,t){return!!(he&&e.hasChildNodes()&&!_t(e.firstElementChild)&&xG(LG,e.textContent)&&xG(LG,e.innerHTML)||he&&e.namespaceURI===Re&&t===`style`&&_t(e.firstElementChild)||e.nodeType===RG.processingInstruction||he&&e.nodeType===RG.comment&&xG(YAe,e.data))},bt=function(e,t){if(!se[t]&&wt(t)&&(U.tagNameCheck instanceof RegExp&&xG(U.tagNameCheck,t)||U.tagNameCheck instanceof Function&&U.tagNameCheck(t)))return!1;if(De&&!Ae[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Oe?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return ot(e),!0},xt=function(e){if(vt(I.beforeSanitizeElements,e,null),ht(e))return ot(e),!0;let n=Xe(b?b(e):e.nodeName);if(vt(I.uponSanitizeElement,e,{tagName:n,allowedTags:ie}),yt(e,n))return ot(e),!0;if(se[n]||!(le.tagCheck instanceof Function&&le.tagCheck(n))&&!ie[n])return bt(e,n);if((y?y(e):e.nodeType)===RG.element&&!at(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&xG(XAe,e.innerHTML))return ot(e),!0;if(me&&e.nodeType===RG.text){let n=pt(e.textContent);e.textContent!==n&&(uG(t.removed,{element:e.cloneNode()}),e.textContent=n)}return vt(I.afterSanitizeElements,e,null),!1},St=function(e,t,r){if(ce[t]||we&&(t===`id`||t===`name`)&&(r in n||r in Qe))return!1;let i=ae[t]||le.attributeCheck instanceof Function&&le.attributeCheck(t,e);if(!(de&&xG(B,t))&&!(ue&&xG(V,t))){if(!i){if(!(wt(e)&&(U.tagNameCheck instanceof RegExp&&xG(U.tagNameCheck,e)||U.tagNameCheck instanceof Function&&U.tagNameCheck(e))&&(U.attributeNameCheck instanceof RegExp&&xG(U.attributeNameCheck,t)||U.attributeNameCheck instanceof Function&&U.attributeNameCheck(t,e))||t===`is`&&U.allowCustomizedBuiltInElements&&(U.tagNameCheck instanceof RegExp&&xG(U.tagNameCheck,r)||U.tagNameCheck instanceof Function&&U.tagNameCheck(r))))return!1}else if(!Pe[t]&&!xG(re,hG(r,te,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&gG(r,`data:`)===0&&Me[e])&&!(fe&&!xG(ee,hG(r,te,``)))&&r)return!1}return!0},Ct=wG({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),wt=function(e){return!Ct[fG(e)]&&xG(ne,e)},Tt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Et=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),ht(e)?ot(e):lG(t.removed)}catch{ct(n,e)}},Dt=function(e){vt(I.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||ht(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:ae,forceKeepAttr:void 0},r=t.length,i=Xe(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Xe(o),u=c,d=o===`value`?u:jAe(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,vt(I.uponSanitizeAttribute,e,n),d=n.attrValue,Te&&(l===`id`||l===`name`)&&gG(d,Ee)!==0&&(ct(o,e),d=Ee+d),he&&xG(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){ct(o,e);continue}if(l===`attributename`&&mG(d,`href`)){ct(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){ct(o,e);continue}if(!pe&&xG(ZAe,d)){ct(o,e);continue}if(me&&(d=pt(d)),!St(i,l,d)){ct(o,e);continue}d=Tt(i,l,s,d),d!==u&&Et(e,o,s,d)}}vt(I.afterSanitizeAttributes,e,null)},Ot=function(e){let t=null,n=ft(e);for(vt(I.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(vt(I.uponSanitizeShadowNode,t,null),xt(t),Dt(t),gt(t.content)&&Ot(t.content),(y?y(t):t.nodeType)===RG.element){let e=_(t);gt(e)&&(kt(e),Ot(e))}vt(I.afterSanitizeShadowDOM,e,null)},kt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Ot(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===RG.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&Xe(e)===`template`){let e=n.content;gt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);gt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Be=!e,Be&&(e=``),typeof e!=`string`&&!_t(e)&&(e=IAe(e),typeof e!=`string`))throw SG(`dirty is not a string, aborting`);if(!t.isSupported)return e;_e?(ie=ve,ae=ye):W(n),(I.uponSanitizeElement.length>0||I.uponSanitizeAttribute.length>0)&&(ie=TG(ie)),I.uponSanitizeAttribute.length>0&&(ae=TG(ae)),t.removed=[];let c=Oe&&typeof e!=`string`&&_t(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=Xe(t);if(!ie[e]||se[e])throw SG(`root node is forbidden and cannot be sanitized in-place`)}if(ht(e))throw SG(`root node is clobbered and cannot be sanitized in-place`);try{kt(e)}catch(t){throw st(e),t}}else if(_t(e))i=dt(``),a=i.ownerDocument.importNode(e,!0),a.nodeType===RG.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),kt(a);else{if(!xe&&!me&&!ge&&e.indexOf(`<`)===-1)return x&&Ce?D(e):e;if(i=dt(e),!i)return xe?null:Ce?S:``}i&&be&&ot(i.firstChild);let l=ft(c?e:i);try{for(;o=l.nextNode();)xt(o),Dt(o),gt(o.content)&&Ot(o.content)}catch(t){throw c&&st(e),t}if(c)return cG(t.removed,e=>{e.element&&ut(e.element)}),me&&mt(e),e;if(xe){if(me&&mt(i),Se)for(s=N.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(ae.shadowroot||ae.shadowrootmode)&&(s=F.call(r,s,!0)),s}let u=ge?i.outerHTML:i.innerHTML;return ge&&ie[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&xG(qAe,i.ownerDocument.doctype.name)&&(u=` +`+u),me&&(u=pt(u)),x&&Ce?D(u):u},t.setConfig=function(){W(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),_e=!0,ve=ie,ye=ae},t.clearConfig=function(){Ze=null,_e=!1,ve=null,ye=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return Ze||W({}),St(Xe(e),Xe(t),n)},t.addHook=function(e,t){typeof t==`function`&&yG(I,e)&&uG(I[e],t)},t.removeHook=function(e,t){if(yG(I,e)){if(t!==void 0){let n=kAe(I[e],t);return n===-1?void 0:AAe(I[e],n,1)[0]}return lG(I[e])}},t.removeHooks=function(e){yG(I,e)&&(I[e]=[])},t.removeAllHooks=function(){I=zG()},t}var HG=VG();function UG(e){this.content=e}UG.prototype={constructor:UG,find:function(e){for(var t=0;t>1}},UG.from=function(e){if(e instanceof UG)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new UG(t)};function WG(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=WG(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function GG(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;ee&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?JG(t+1,i):JG(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};XG.none=[];var ZG=class extends Error{},QG=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=eK(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e($G(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(KG.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};QG.empty=new QG(KG.empty,0,0);function $G(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy($G(a.content,t-i-1,n-i-1)))}function eK(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=eK(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function eje(e,t,n){if(n.openStart>e.depth)throw new ZG(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ZG(`Inconsistent open depths`);return tK(e,t,n,0)}function tK(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function aK(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(iK(e.nodeAfter,r),a++));for(let e=a;ei&&rK(e,t,i+1),o=r.depth>i&&rK(n,r,i+1),s=[];return aK(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(nK(a,o),iK(oK(a,sK(e,t,n,r,i+1)),s)):(a&&iK(oK(a,cK(e,t,i+1)),s),aK(t,n,i,s),o&&iK(oK(o,cK(n,r,i+1)),s)),aK(r,null,i,s),new KG(s)}function cK(e,t,n){let r=[];return aK(null,e,n,r),e.depth>n&&iK(oK(rK(e,t,n+1),cK(e,t,n+1)),r),aK(t,null,n,r),new KG(r)}function tje(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(KG.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var lK=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new dK(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=uK.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),pK(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=KG.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=KG.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};fK.prototype.text=void 0;var aje=class e extends fK{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):pK(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function pK(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var mK=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new oje(t,n);if(r.next==null)return e.empty;let i=hK(r);r.next&&r.err(`Unexpected trailing text`);let a=pje(fje(i));return mje(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` +`)}};mK.empty=new mK(!0);var oje=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function hK(e){let t=[];do t.push(sje(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function sje(e){let t=[];do t.push(cje(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function cje(e){let t=dje(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=lje(e,t);else break;return t}function gK(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function lje(e,t){let n=gK(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:gK(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function uje(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function dje(e){if(e.eat(`(`)){let t=hK(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=uje(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function fje(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new mK(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:bK(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new fK(this,this.computeAttrs(e),KG.from(t),XG.setFrom(n))}createChecked(e=null,t,n){return t=KG.from(t),this.checkContent(t),new fK(this,this.computeAttrs(e),t,XG.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=KG.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(KG.empty,!0);return i?new fK(this,e,t.append(i),XG.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function hje(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var gje=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?hje(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},wK=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=SK(e,r.attrs),this.excluded=null;let i=yK(this.attrs);this.instance=i?new XG(this,i):null}create(e=null){return!e&&this.instance?this.instance:new XG(this,bK(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},TK=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=UG.from(e.nodes),t.marks=UG.from(e.marks||{}),this.nodes=CK.compile(this.spec.nodes,this),this.marks=wK.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=mK.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?EK(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:EK(this,n.split(` `))}this.nodeFromJSON=e=>fK.fromJSON(this,e),this.markFromJSON=e=>XG.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof CK))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new aje(n,n.defaultAttrs,e,XG.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function EK(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function _je(e){return e.tag!=null}function vje(e){return e.style!=null}var DK=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(_je(e))this.tags.push(e);else if(vje(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new FK(this,t,!1);return n.addAll(e,XG.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new FK(this,t,!0);return n.addAll(e,XG.none,t.from,t.to),QG.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=IK(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=IK(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},OK={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},yje={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},kK={ol:!0,ul:!0},AK=1,jK=2,MK=4;function NK(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?AK:0)|(t===`full`?jK:0)}var PK=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=XG.none,this.match=i||(a&MK?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(KG.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&AK)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=KG.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(KG.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!OK.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},FK=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=NK(null,t.preserveWhitespace,0)|(n?MK:0);i=r?new PK(r.type,r.attrs,XG.none,!0,t.topMatch||r.type.contentMatch,a):n?new PK(null,null,XG.none,!0,null,a):new PK(e.schema.topNodeType,null,XG.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&jK?`full`:this.localPreserveWS||(r.options&AK)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` +`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e(a.type?a.type.allowsMarkType(t.type):LK(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new PK(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=AK);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function bje(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&kK.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function xje(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function IK(e){let t={};for(let n in e)t[n]=e[n];return t}function LK(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&HK(BK(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return HK(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=zK(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return zK(e.marks)}};function zK(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function BK(e){return e.document||window.document}var VK=new WeakMap;function Sje(e){let t=VK.get(e);return t===void 0&&VK.set(e,t=Cje(e)),t}function Cje(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=HK(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var UK=65535,WK=2**16;function wje(e,t){return e+t*WK}function GK(e){return e&UK}function Tje(e){return(e-(e&UK))/WK}var Eje=1,Dje=2,KK=4,qK=8,JK=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&qK)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&KK)>0}},YK=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=GK(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:wje(o/3,e-s),f=e==s?Dje:e==u?Eje:KK;return(t<0?e!=s:e!=u)&&(f|=qK),new JK(a,f,d)}r+=l-c}return n?e+r:new JK(e+r,0,null)}touches(e,t){let n=0,r=GK(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return $K.fromReplace(e,this.from,this.to,i)}invert(){return new nq(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};QK.jsonID(`addMark`,tq);var nq=class e extends QK{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new QG(eq(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return $K.fromReplace(e,this.from,this.to,n)}invert(){return new tq(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};QK.jsonID(`removeMark`,nq);var rq=class e extends QK{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return $K.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return $K.fromReplace(e,this.pos,this.pos+1,new QG(KG.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,QG.fromJSON(t,n.slice),n.insert,!!n.structure)}};QK.jsonID(`replaceAround`,oq);function sq(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Oje(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;ee.step(t)),a.forEach(t=>e.step(t))}function kje(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof wK){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new nq(t.from,t.to,t.style)))}function cq(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function Aje(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function lq(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=KG.from(r.node(e).copy(u)),d++):c--;let f=KG.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=KG.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new oq(i,a,i,a,new QG(r,0,0),n.length,!0))}function Fje(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Ije(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&pq(e,t,n,a),cq(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new oq(c,l,c+1,l-1,new QG(KG.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&fq(e,t,n,a),!1}})}function fq(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function pq(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` +`))}})}function Ije(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Lje(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new oq(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new QG(KG.from(o),0,0),1,!0))}function mq(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Rje(e,t,n=1,r){let i=e.doc.resolve(t),a=KG.empty,o=KG.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=KG.from(i.node(e).copy(a));let t=r&&r[s];o=KG.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new aq(t,t,new QG(a.append(o),n,n),!0))}function hq(e,t){let n=e.resolve(t),r=n.index();return gq(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function zje(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&gq(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Bje(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);pq(e,r.node(),r.before(),s)}o.inlineContent&&cq(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new aq(l,c.map(t+n,-1),QG.empty,!0)),r===!0){let t=e.doc.resolve(l);fq(e,t.node(),t.before(),e.steps.length)}return e}function Vje(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function yq(e,t,n=t,r=QG.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return bq(i,a,r)?new aq(t,n,r):new Hje(i,a,r).fit()}function bq(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Hje=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=KG.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=KG.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new QG(i,a,o);return e>-1?new oq(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new aq(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Cq(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(KG.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Cq(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new QG(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Cq(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new QG(xq(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new QG(xq(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(wq(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Sq(this.placed,t,KG.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=Tq(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Sq(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Sq(this.placed,this.depth,KG.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(KG.empty,!0);e.childCount&&(this.placed=Sq(this.placed,this.frontier.length,e))}};function xq(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(xq(e.firstChild.content,t-1,n)))}function Sq(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Sq(e.lastChild.content,t-1,n)))}function Cq(e,t){for(let n=0;n1&&(r=r.replaceChild(0,wq(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(KG.empty,!0)))),e.copy(r)}function Tq(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Uje(n,a.content,o)?s:null}function Uje(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Wje(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Eq(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(KG.empty,!0))}return e}function Kje(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Vje(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new QG(KG.from(r),0,0))}function qje(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Dq(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Dq(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var Oq=class e extends QK{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return $K.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return $K.fromReplace(e,this.pos,this.pos+1,new QG(KG.from(r),0,+!t.isLeaf))}getMap(){return YK.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};QK.jsonID(`attr`,Oq);var kq=class e extends QK{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return $K.ok(n)}getMap(){return YK.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};QK.jsonID(`docAttr`,kq);var Aq=class extends Error{};Aq=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Aq.prototype=Object.create(Error.prototype),Aq.prototype.constructor=Aq,Aq.prototype.name=`TransformError`;var jq=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new XK}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Aq(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=QG.empty){let r=yq(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new QG(KG.from(n),0,0))}delete(e,t){return this.replace(e,t,QG.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Gje(this,e,t,n),this}replaceRangeWith(e,t,n){return Kje(this,e,t,n),this}deleteRange(e,t){return qje(this,e,t),this}lift(e,t){return jje(this,e,t),this}join(e,t=1){return Bje(this,e,t),this}wrap(e,t){return Pje(this,e,t),this}setBlockType(e,t=e,n,r=null){return Fje(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Lje(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new Oq(e,t,n)),this}setDocAttribute(e,t){return this.step(new kq(e,t)),this}addNodeMark(e,t){return this.step(new rq(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof XG)t.isInSet(n.marks)&&this.step(new iq(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new iq(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Rje(this,e,t,n),this}addMark(e,t,n){return Oje(this,e,t,n),this}removeMark(e,t,n){return kje(this,e,t,n),this}clearIncompatible(e,t,n){return cq(this,e,t,n),this}},Mq=Object.create(null),Nq=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Jje(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?Bq(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Bq(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new zq(e.node(0))}static atStart(e){return Bq(e,e,0,0,1)||new zq(e)}static atEnd(e){return Bq(e,e,e.content.size,e.childCount,-1)||new zq(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=Mq[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Mq)throw RangeError(`Duplicate use of selection JSON ID `+e);return Mq[e]=t,t.prototype.jsonID=e,t}getBookmark(){return Iq.between(this.$anchor,this.$head).getBookmark()}};Nq.prototype.visible=!0;var Jje=class{constructor(e,t){this.$from=e,this.$to=t}},Pq=!1;function Fq(e){!Pq&&!e.parent.inlineContent&&(Pq=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var Iq=class e extends Nq{constructor(e,t=e){Fq(e),Fq(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return Nq.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=QG.empty){if(super.replace(e,t),t==QG.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Lq(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=Nq.findFrom(n,r,!0)||Nq.findFrom(n,-r,!0);if(e)n=e.$head;else return Nq.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(Nq.findFrom(t,-r,!0)||Nq.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Bq(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&Rq.isSelectable(r))return Rq.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function Vq(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(Nq.near(e.doc.resolve(o),n))}var Hq=1,Uq=2,Wq=4,Zje=class extends jq{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Uq,this}ensureMarks(e){return XG.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Uq)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||XG.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(Nq.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Wq,this}get scrolledIntoView(){return(this.updated&Wq)>0}};function Gq(e,t){return!t||!e?e:e.bind(t)}var Kq=class{constructor(e,t,n){this.name=e,this.init=Gq(t.init,n),this.apply=Gq(t.apply,n)}},Qje=[new Kq(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Kq(`selection`,{init(e,t){return e.selection||Nq.atStart(t.doc)},apply(e){return e.selection}}),new Kq(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Kq(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],qq=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Qje.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Kq(e.key,e.spec.state,e))})}},$je=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new qq(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=fK.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=Nq.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Jq(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Jq(i,t,{})),n[r]=i}return n}var Yq=class{constructor(e){this.spec=e,this.props={},e.props&&Jq(e.props,this,this.props),this.key=e.key?e.key.key:Zq(`plugin`)}getState(e){return e[this.key]}},Xq=Object.create(null);function Zq(e){return e in Xq?e+`$`+ ++Xq[e]:(Xq[e]=0,e+`$`)}var Qq=class{constructor(e=`key`){this.key=Zq(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},$q=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function eJ(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var tJ=(e,t,n)=>{let r=eJ(e,n);if(!r)return!1;let i=aJ(r);if(!i){let n=r.blockRange(),i=n&&lq(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(hJ(e,i,t,-1))return!0;if(r.parent.content.size==0&&(rJ(a,`end`)||Rq.isSelectable(a)))for(let n=r.depth;;n--){let o=yq(e.doc,r.before(n),r.after(n),QG.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},eMe=(e,t,n)=>{let r=eJ(e,n);if(!r)return!1;let i=aJ(r);return i?nJ(e,i,t):!1},tMe=(e,t,n)=>{let r=oJ(e,n);if(!r)return!1;let i=lJ(r);return i?nJ(e,i,t):!1};function nJ(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=yq(e.doc,i,o,QG.empty);if(!s||s.from!=i||s instanceof aq&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(Iq.create(t.doc,i)),n(t.scrollIntoView())}return!0}function rJ(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var iJ=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=aJ(r)}let o=a&&a.nodeBefore;return!o||!Rq.isSelectable(o)?!1:(t&&t(e.tr.setSelection(Rq.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function aJ(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function oJ(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=oJ(e,n);if(!r)return!1;let i=lJ(r);if(!i)return!1;let a=i.nodeAfter;if(hJ(e,i,t,1))return!0;if(r.parent.content.size==0&&(rJ(a,`start`)||Rq.isSelectable(a))){let n=yq(e.doc,r.before(),r.after(),QG.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof Rq,i;if(r){if(n.node.isTextblock||!hq(e.doc,n.from))return!1;i=n.from}else if(i=_q(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(Rq.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},rMe=(e,t)=>{let n=e.selection,r;if(n instanceof Rq){if(n.node.isTextblock||!hq(e.doc,n.to))return!1;r=n.to}else if(r=_q(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},iMe=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&lq(i);return a==null?!1:(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},uJ=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` +`).scrollIntoView()),!0)};function dJ(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=dJ(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(Nq.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},pJ=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof zq||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=dJ(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(mq(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&lq(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function aMe(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof Rq&&t.selection.node.isBlock)return!r.parentOffset||!mq(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=dJ(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof Iq||t.selection instanceof zq)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=mq(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,mq(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var oMe=aMe(),sMe=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),t&&t(e.tr.setSelection(Rq.create(e.doc,i))),!0)},cMe=(e,t)=>(t&&t(e.tr.setSelection(new zq(e.doc))),!0);function lMe(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||hq(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function hJ(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&lMe(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=KG.empty;for(let e=o.length-1;e>=0;e--)s=KG.from(o[e].create(null,s));s=KG.from(i.copy(s));let c=e.tr.step(new oq(t.pos-1,r,t.pos,r,new QG(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&hq(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:Nq.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&lq(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&rJ(a,`start`,!0)&&rJ(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=KG.empty;for(let e=o.length-1;e>=0;e--)r=KG.from(o[e].copy(r));n(e.tr.step(new oq(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new QG(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function gJ(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(Iq.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var _J=gJ(-1),vJ=gJ(1);function uMe(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&uq(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function yJ(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(!(!r.isTextblock||r.hasMarkup(e,t)))if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new dK(e,e,t.depth),t.endIndex=0;e--)a=KG.from(n[e].type.create(n[e].attrs,a));e.step(new oq(t.start-(r?2:0),t.end,t.start,t.end,new QG(a,0,0),n.length,!0));let o=0;for(let e=0;et.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?gMe(t,n,e,a):_Me(t,n,a):!0:!1}}function gMe(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?KG.empty:KG.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new oq(d-+!!s,f+ +!!c,d+1,f-1,new QG((s?KG.empty:KG.from(i.copy(KG.empty))).append(c?KG.empty:KG.from(i.copy(KG.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function vMe(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==s.type,i=KG.from(r?e.create():null),o=new QG(KG.from(e.create(null,KG.from(s.type.create(null,i)))),r?3:1,0),l=a.start,u=a.end;n(t.tr.step(new oq(l-(r?3:1),u,l,u,o,1,!0)).scrollIntoView())}return!0}}var wJ=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},TJ=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},EJ=null,DJ=function(e,t,n){let r=EJ||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},yMe=function(){EJ=null},OJ=function(e,t,n,r){return n&&(kJ(e,t,n,r,-1)||kJ(e,t,n,r,1))},bMe=/^(img|br|input|textarea|hr)$/i;function kJ(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:AJ(e))){let n=e.parentNode;if(!n||n.nodeType!=1||jJ(e)||bMe.test(e.nodeName)||e.contentEditable==`false`)return!1;t=wJ(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?AJ(e):0}else return!1}}function AJ(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function xMe(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=AJ(e)}else if(e.parentNode&&!jJ(e))t=wJ(e),e=e.parentNode;else return null}}function SMe(e,t){for(;;){if(e.nodeType==3&&t2),JJ=qJ||(PJ?/Mac/.test(PJ.platform):!1),YJ=PJ?/Win/.test(PJ.platform):!1,XJ=/Android \d/.test(IJ),ZJ=!!FJ&&`webkitFontSmoothing`in FJ.documentElement.style,EMe=ZJ?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function DMe(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function QJ(e,t){return typeof e==`number`?e:e[t]}function OMe(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function $J(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=TJ(o);continue}let e=o,n=e==a.body,s=n?DMe(a):OMe(e),c=0,l=0;if(t.tops.bottom-QJ(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+QJ(i,`top`)-s.top:t.bottom-s.bottom+QJ(i,`bottom`)),t.lefts.right-QJ(r,`right`)&&(c=t.right-s.right+QJ(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:TJ(o)}}function kMe(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:eY(e.dom)}}function eY(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=TJ(r));return t}function AMe({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;tY(n,r==0?0:r-t)}function tY(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?MMe(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:rY(n,i)}function MMe(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function iY(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function NMe(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function FMe(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function aY(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;ZJ&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=FMe(e,r,i,t))}s??=PMe(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function oY(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,lY(sY(DJ(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==AJ(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return uY(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==AJ(r))){let e=r.childNodes[i-1],t=e.nodeType==3?DJ(e,AJ(e)-+!o):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return lY(sY(t,1),!1)}if(a==null&&i=0)}function lY(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function uY(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function dY(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function RMe(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return dY(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=cY(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=DJ(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var zMe=/[\u0590-\u08ac]/;function BMe(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!zMe.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:dY(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var fY=null,pY=null,mY=!1;function VMe(e,t,n){return fY==t&&pY==n?mY:(fY=t,pY=n,mY=n==`up`||n==`down`?RMe(e,t,n):BMe(e,t,n))}var hY=0,gY=1,_Y=2,vY=3,yY=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=hY,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;twJ(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te||i instanceof TY){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof bY&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?wJ(e.dom)+1:0}}else{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=wJ(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?_Y:gY,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=vY:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?_Y:vY}n=a}this.dirty=_Y}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?_Y:gY;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==hY&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},HMe=class extends yY{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},xY=class e extends yY{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=RK.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&vY||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=vY&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=hY){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=PY(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=RK.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=jY(u,r,n),l?c=new UMe(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new wY(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>KG.empty)}return e}matchesNode(e,t,n){return this.dirty==hY&&e.eq(this.node)&&MY(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new GMe(this,a&&a.node,e);JMe(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?XG.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==_Y)&&(a&&this.protectLocalComposition(e,a),EY(this.contentDOM,this.children,e),qJ&&YMe(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof Iq)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=XMe(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new HMe(this,i,t,r);e.input.compositionNodes.push(a),this.children=PY(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==vY||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=hY}updateOuterDeco(e){if(MY(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=AY(this.dom,this.nodeDOM,kY(this.outerDeco,this.node,t),kY(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function CY(e,t,n,r,i){jY(r,t,e);let a=new SY(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var wY=class e extends SY{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==vY||this.dirty!=hY&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=hY||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=hY,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=vY)}get domAtom(){return!1}isText(e){return this.node.text==e}},TY=class extends yY{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==hY&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},UMe=class extends SY{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==vY)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function EY(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=xY.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof xY)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function qMe(e,t){return e.type.side-t.type.side}function JMe(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function YMe(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function XMe(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function PY(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function FY(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(MJ(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&Rq.isSelectable(e)&&i.parent&&!(e.isInline&&CMe(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new Rq(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!IY(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function QMe(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,wJ(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&BJ&&VJ<=11&&(n.disabled=!0,n.disabled=!1)}function HY(e,t){if(t instanceof Rq){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(UY(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else UY(e)}function UY(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function WY(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||Iq.between(t,n,r)}function GY(e){return e.editable&&!e.hasFocus()?!1:KY(e)}function KY(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function $Me(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return OJ(t.node,t.offset,n.anchorNode,n.anchorOffset)}function qY(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&Nq.findFrom(a,t)}function JY(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function YY(e,t,n){let r=e.state.selection;if(r instanceof Iq){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return JY(e,new Iq(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=qY(e.state,t);return n&&n instanceof Rq?JY(e,n):!1}else if(!(JJ&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?Rq.isSelectable(i)?JY(e,new Rq(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):ZJ?JY(e,new Iq(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof Rq&&r.node.isInline)return JY(e,new Iq(t>0?r.$to:r.$from));else{let n=qY(e.state,t);return n?JY(e,n):!1}}function XY(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function ZY(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function QY(e,t){return t<0?eNe(e):tNe(e)}function eNe(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(HJ&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(ZY(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if($Y(n))break;else{let t=n.previousSibling;for(;t&&ZY(t,-1);)i=n.parentNode,a=wJ(t),t=t.previousSibling;if(t)n=t,r=XY(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?eX(e,n,r):i&&eX(e,i,a)}function tNe(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=XY(n),a,o;for(;;)if(r{e.state==i&&LY(e)},50)}function tX(e,t){let n=e.state.doc.resolve(t);if(!(WJ||YJ)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function nX(e,t,n){let r=e.state.selection;if(r instanceof Iq&&!r.empty||n.indexOf(`s`)>-1||JJ&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=qY(e.state,t);if(n&&n instanceof Rq)return JY(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof zq?Nq.near(n,t):Nq.findFrom(n,t);return o?JY(e,o):!1}return!1}function rX(e,t){if(!(e.state.selection instanceof Iq))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function iX(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function iNe(e){if(!KJ||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;iX(e,n,`true`),setTimeout(()=>iX(e,n,`false`),20)}return!1}function aNe(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function oNe(e,t){let n=t.keyCode,r=aNe(t);if(n==8||JJ&&n==72&&r==`c`)return rX(e,-1)||QY(e,-1);if(n==46&&!t.shiftKey||JJ&&n==68&&r==`c`)return rX(e,1)||QY(e,1);if(n==13||n==27)return!0;if(n==37||JJ&&n==66&&r==`c`){let t=n==37?tX(e,e.state.selection.from)==`ltr`?-1:1:-1;return YY(e,t,r)||QY(e,t)}else if(n==39||JJ&&n==70&&r==`c`){let t=n==39?tX(e,e.state.selection.from)==`ltr`?1:-1:1;return YY(e,t,r)||QY(e,t)}else if(n==38||JJ&&n==80&&r==`c`)return nX(e,-1,r)||QY(e,-1);else if(n==40||JJ&&n==78&&r==`c`)return iNe(e)||nX(e,1,r)||QY(e,1);else if(r==(JJ?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function aX(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||RK.fromSchema(e.state.schema),s=pX(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=fX[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` -`),slice:t}}function aX(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new ZG(GG.from(e.state.schema.text(t.replace(/\r\n?/g,` -`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=LK.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=fNe(n),XJ&&pNe(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||EK.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!cNe.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=mNe(uX(s,+u[1],+u[2]),u[4]);else if(s=ZG.maxOpen(lNe(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var cNe=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function lNe(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&sX(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=cX(a[a.length-1],i.length));let n=oX(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return GG.from(a)}return e}function oX(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,GG.from(e));return e}function sX(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(GG.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function uX(e,t,n){return te}),pX.createHTML(e)):e}function fNe(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=fX().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&dX[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>``).reverse().join(``)),n.innerHTML=dNe(e),i)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=GG.from(t.create(r[e+1],i)),a++,o++}return new ZG(i,a,o)}var mX={},hX={},hNe={touchstart:!0,touchmove:!0},gNe=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function _Ne(e){for(let t in mX){let n=mX[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{yNe(e,t)&&!vX(e,t)&&(e.editable||!(t.type in hX))&&n(e,t)},hNe[t]?{passive:!0}:void 0)}GJ&&e.dom.addEventListener(`input`,()=>null),_X(e)}function gX(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function vNe(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function _X(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>vX(e,t))})}function vX(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function yNe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function bNe(e,t){!vX(e,t)&&mX[t.type]&&(e.editable||!(t.type in hX))&&mX[t.type](e,t)}hX.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!wX(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(YJ&&UJ&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),KJ&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,MJ(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||sNe(e,n)?n.preventDefault():gX(e,`key`)},hX.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},hX.keypress=(e,t)=>{let n=t;if(wX(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||qJ&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Fq)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function yX(e){return{left:e.clientX,top:e.clientY}}function xNe(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function bX(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function xX(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function SNe(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Lq.isSelectable(r)?(xX(e,new Lq(n),`pointer`),!0):!1}function CNe(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Lq&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Lq.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(xX(e,Lq.create(e.state.doc,i),`pointer`),!0)}function wNe(e,t,n,r,i){return bX(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?CNe(e,n):SNe(e,n))}function TNe(e,t,n,r){return bX(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function ENe(e,t,n,r){return bX(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||DNe(e,n,r)}function DNe(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(xX(e,Fq.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)xX(e,Fq.create(r,a+1,a+1+n.content.size),`pointer`);else if(Lq.isSelectable(n))xX(e,Lq.create(r,a),`pointer`);else continue;return!0}}function SX(e){return DX(e)}var CX=qJ?`metaKey`:`ctrlKey`;mX.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=SX(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&xNe(n,e.input.lastClick)&&!n[CX]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(yX(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new ONe(e,o,n,!!r)):(a==`doubleClick`?TNe:ENe)(e,o.pos,o.inside,n)?n.preventDefault():gX(e,`pointer`))};var ONe=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[CX],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Lq&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&VJ&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),gX(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>IY(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yX(e))),this.updateAllowDefault(e),this.allowDefault||!t?gX(this.view,`pointer`):wNe(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||GJ&&this.mightDrag&&!this.mightDrag.node.isAtom||UJ&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(xX(this.view,Mq.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):gX(this.view,`pointer`)}move(e){this.updateAllowDefault(e),gX(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};mX.touchstart=e=>{e.input.lastTouch=Date.now(),SX(e),gX(e,`pointer`)},mX.touchmove=e=>{e.input.lastTouch=Date.now(),gX(e,`pointer`)},mX.contextmenu=e=>SX(e);function wX(e,t){return e.composing?!0:GJ&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var kNe=YJ?5e3:-1;hX.compositionstart=hX.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Fq&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||UJ&&JJ&&ANe(e)))e.markCursor=e.state.storedMarks||n.marks(),DX(e,!0),e.markCursor=null;else if(DX(e,!t.selection.empty),VJ&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}TX(e,kNe)};function ANe(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}hX.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,TX(e,20))};function TX(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>DX(e),t))}function EX(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=MNe());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function jNe(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=SMe(t.focusNode,t.focusOffset),r=CMe(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function MNe(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function DX(e,t=!1){if(!(YJ&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),EX(e),t||e.docView&&e.docView.dirty){let n=PY(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function NNe(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var OX=zJ&&BJ<15||KJ&&DMe<604;mX.copy=hX.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=OX?null:n.clipboardData,{dom:o,text:s}=iX(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):NNe(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function PNe(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function FNe(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?kX(e,r.value,null,i,t):kX(e,r.textContent,r.innerHTML,i,t)},50)}function kX(e,t,n,r,i){let a=aX(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||ZG.empty)))return!0;if(!a)return!1;let o=PNe(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function AX(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}hX.paste=(e,t)=>{let n=t;if(e.composing&&!YJ)return;let r=OX?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&kX(e,AX(r),r.getData(`text/html`),i,n)?n.preventDefault():FNe(e,n)};var jX=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},INe=qJ?`altKey`:`ctrlKey`;function MX(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[INe]}mX.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(yX(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Lq?i.to-1:i.to))){if(r&&r.mightDrag)o=Lq.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Lq.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=iX(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!UJ||WJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(OX?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,OX||n.dataTransfer.setData(`text/plain`,c),e.dragging=new jX(l,MX(e,n),o)},mX.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},hX.dragover=hX.dragenter=(e,t)=>t.preventDefault(),hX.drop=(e,t)=>{try{LNe(e,t,e.dragging)}finally{e.dragging=null}};function LNe(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(yX(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=aX(e,AX(t.dataTransfer),OX?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&MX(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||ZG.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?_q(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Lq.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Lq(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(UY(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}mX.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&IY(e)},20))},mX.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},mX.beforeinput=(e,t)=>{if(UJ&&YJ&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,MJ(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in hX)mX[e]=hX[e];function NX(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var PX=class e{constructor(e,t){this.toDOM=e,this.spec=t||RX,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new IX(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&NX(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},FX=class e{constructor(e,t){this.attrs=e,this.spec=t||RX}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new IX(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==BX||e.maps.length==0?this:this.mapInner(e,t,0,0,n||RX)}mapInner(t,n,r,i,a){let o;for(let e=0;e{let o=t+r,s;if(s=UX(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof FX){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,RX));return e.from(r)}forChild(t,n){if(n.isLeaf)return zX.empty;let r=[];for(let i=0;ie instanceof zX)?t:t.reduce((e,t)=>e.concat(t instanceof zX?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==BX?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=GX(BNe(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=UX(e,t,o+n);if(s){a=!0;let e=GX(s,t,n+o+1,r);e!=BX&&i.push(o,o+t.nodeSize,e)}});let o=HX(a?WX(e):e,-n).sort(KX);for(let e=0;e0;)t++;e.splice(t,0,n)}function YX(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=BX&&t.push(r)}),e.cursorWrapper&&t.push(zX.create(e.state.doc,[e.cursorWrapper.deco])),VX.from(t)}var VNe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},HNe=zJ&&BJ<=11,UNe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},WNe=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new UNe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():GJ&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),HNe&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,VNe)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(WY(this.view)){if(this.suppressingSelectionUpdates)return IY(this.view);if(zJ&&BJ<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&DJ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=wJ(n))t.add(n);for(let r=e.anchorNode;r;r=wJ(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&WY(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;t&&t.nodeType==1&&t.contentEditable==`false`&&e.parentNode.removeChild(e)}}else if(VJ&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||qNe(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),GNe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,JNe(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||IY(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;ni;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||EK.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:XNe,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function XNe(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(GJ&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||GJ&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var ZNe=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function QNe(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=PY(e,t);if(n&&!e.state.selection.eq(n)){if(UJ&&YJ&&e.input.lastKeyCode===13&&Date.now()-100t(e,MJ(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=YNe(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||YJ)&&i.some(e=>e.nodeType==1&&!ZNe.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,MJ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Fq&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=$X(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),zJ&&BJ<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((KJ&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.post(e,MJ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&ePe(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,MJ(8,`Backspace`)))){YJ&&UJ&&e.domObserver.suppressSelectionUpdates();return}UJ&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),YJ&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,MJ(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=$X(e,n.doc,l.sel);t&&!(UJ&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteIY(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=$Ne(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function $X(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:UY(e,t.resolve(n.anchor),t.resolve(n.head))}function $Ne(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||eZ(o,!0,!1)0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function tPe(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o=o?a-r:0;a-=e,a&&a=s?a-r:0;a-=t,a&&a=56320&&t<=57343&&n>=55296&&n<=56319}var nZ=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new gNe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(sZ),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=aZ(this),iZ(this),this.nodeViews=oZ(this),this.docView=SY(this.state.doc,rZ(this),YX(this),this.dom,this),this.domObserver=new WNe(this,(e,t,n,r)=>QNe(this,e,t,n,r)),this.domObserver.start(),_Ne(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&_X(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sZ),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(EX(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=oZ(this);rPe(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&_X(this),this.editable=aZ(this),iZ(this);let o=YX(this),s=rZ(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&AMe(this);if(i){this.domObserver.stop();let t=l&&(zJ||UJ)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&nPe(n.selection,e.selection);if(l){let n=UJ?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=jNe(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=SY(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&eNe(this))?IY(this,t):(VY(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&jMe(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Lq){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&QJ(this,t.getBoundingClientRect(),e)}else QJ(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new jX(e.slice,e.move,r<0?void 0:Lq.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;ne.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return LMe(this,e)}coordsAtPos(e,t=1){return sY(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return HMe(this,t||this.state,e)}pasteHTML(e,t){return kX(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return kX(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return iX(this,e)}destroy(){this.docView&&(vNe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],YX(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bMe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return bNe(this,e)}domSelectionRange(){let e=this.domSelection();return e?GJ&&this.root.nodeType===11&&TMe(this.dom.ownerDocument)==this.dom&&KNe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};nZ.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function rZ(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[IX.node(0,e.state.doc.content.size,t)]}function iZ(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:IX.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function aZ(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function nPe(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function oZ(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function rPe(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function sZ(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var cZ={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},lZ={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},iPe=typeof navigator<`u`&&/Mac/.test(navigator.platform),aPe=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),uZ=0;uZ<10;uZ++)cZ[48+uZ]=cZ[96+uZ]=String(uZ);for(var uZ=1;uZ<=24;uZ++)cZ[uZ+111]=`F`+uZ;for(var uZ=65;uZ<=90;uZ++)cZ[uZ]=String.fromCharCode(uZ+32),lZ[uZ]=String.fromCharCode(uZ);for(var dZ in cZ)lZ.hasOwnProperty(dZ)||(lZ[dZ]=cZ[dZ]);function oPe(e){var t=!(iPe&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||aPe&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?lZ:cZ)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var sPe=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),cPe=typeof navigator<`u`&&/Win/.test(navigator.platform);function lPe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e{for(var n in t)fPe(e,n,{get:t[n],enumerable:!0})};function hZ(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var gZ=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:hZ({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},_Z={};mZ(_Z,{blur:()=>pPe,clearContent:()=>mPe,clearNodes:()=>hPe,command:()=>gPe,createParagraphNear:()=>_Pe,cut:()=>vPe,deleteCurrentNode:()=>yPe,deleteNode:()=>bPe,deleteRange:()=>xPe,deleteSelection:()=>SPe,enter:()=>CPe,exitCode:()=>wPe,extendMarkRange:()=>TPe,first:()=>EPe,focus:()=>OPe,forEach:()=>kPe,insertContent:()=>APe,insertContentAt:()=>NPe,joinBackward:()=>IPe,joinDown:()=>FPe,joinForward:()=>LPe,joinItemBackward:()=>RPe,joinItemForward:()=>zPe,joinTextblockBackward:()=>BPe,joinTextblockForward:()=>VPe,joinUp:()=>PPe,keyboardShortcut:()=>UPe,lift:()=>WPe,liftEmptyBlock:()=>GPe,liftListItem:()=>KPe,newlineInCode:()=>qPe,resetAttributes:()=>JPe,scrollIntoView:()=>YPe,selectAll:()=>XPe,selectNodeBackward:()=>ZPe,selectNodeForward:()=>QPe,selectParentNode:()=>$Pe,selectTextblockEnd:()=>eFe,selectTextblockStart:()=>tFe,setContent:()=>nFe,setMark:()=>SFe,setMeta:()=>CFe,setNode:()=>wFe,setNodeSelection:()=>TFe,setTextDirection:()=>EFe,setTextSelection:()=>DFe,sinkListItem:()=>OFe,splitBlock:()=>kFe,splitListItem:()=>AFe,toggleList:()=>jFe,toggleMark:()=>MFe,toggleNode:()=>NFe,toggleWrap:()=>PFe,undoInputRule:()=>FFe,unsetAllMarks:()=>IFe,unsetMark:()=>LFe,unsetTextDirection:()=>RFe,updateAttributes:()=>zFe,wrapIn:()=>BFe,wrapInList:()=>VFe});var pPe=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),mPe=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),hPe=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=cq(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},gPe=e=>t=>e(t),_Pe=()=>({state:e,dispatch:t})=>fJ(e,t),vPe=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Fq(r.doc.resolve(Math.max(o-1,0)))),!0},yPe=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function vZ(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var bPe=e=>({tr:t,state:n,dispatch:r})=>{let i=vZ(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},xPe=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},SPe=()=>({state:e,dispatch:t})=>Qq(e,t),CPe=()=>({commands:e})=>e.keyboardShortcut(`Enter`),wPe=()=>({state:e,dispatch:t})=>dJ(e,t);function yZ(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function bZ(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:yZ(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function xZ(e,t,n={}){return e.find(e=>e.type===t&&bZ(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function SZ(e,t,n={}){return!!xZ(e,t,n)}function CZ(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t)||(n||=r.node.marks[0]?.attrs,!xZ([...r.node.marks],t,n)))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&SZ([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=wZ(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=CZ(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Fq.create(o,e.from,e.to);n.setSelection(t)}}return!0},EPe=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(kZ()||OZ())&&r.dom.focus(),DPe()&&!kZ()&&!OZ()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!TZ(n.state.selection))return o(),!0;let s=DZ(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},kPe=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),APe=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),AZ=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&AZ(r)}return e};function jZ(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return AZ(n)}function MZ(e,t,n){if(e instanceof dK||e instanceof GG)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return GG.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),MZ(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new wK({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?EK.fromSchema(a).parseSlice(jZ(e),n.parseOptions):EK.fromSchema(a).parse(jZ(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=EK.fromSchema(t);return n.slice?r.parseSlice(jZ(e),n.parseOptions).content:r.parse(jZ(e),n.parseOptions)}return MZ(``,t,n)}function jPe(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(Mq.near(e.doc.resolve(o),n))}var MPe=e=>!(`type`in e),NPe=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{MZ(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=MZ(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((MPe(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof GG){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&jPe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},PPe=()=>({state:e,dispatch:t})=>rMe(e,t),FPe=()=>({state:e,dispatch:t})=>iMe(e,t),IPe=()=>({state:e,dispatch:t})=>eJ(e,t),LPe=()=>({state:e,dispatch:t})=>oJ(e,t),RPe=()=>({state:e,dispatch:t,tr:n})=>{try{let r=gq(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},zPe=()=>({state:e,dispatch:t,tr:n})=>{try{let r=gq(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},BPe=()=>({state:e,dispatch:t})=>tMe(e,t),VPe=()=>({state:e,dispatch:t})=>nMe(e,t);function NZ(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function HPe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=HPe(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function PZ(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?vZ(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>bZ(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var WPe=(e,t={})=>({state:n,dispatch:r})=>PZ(n,vZ(e,n.schema),t)?aMe(n,r):!1,GPe=()=>({state:e,dispatch:t})=>pJ(e,t),KPe=e=>({state:t,dispatch:n})=>gMe(vZ(e,t.schema))(t,n),qPe=()=>({state:e,dispatch:t})=>lJ(e,t);function FZ(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function IZ(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var JPe=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=FZ(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=vZ(e,r.schema)),s===`mark`&&(o=wZ(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,IZ(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(IZ(a.attrs,t))))})})}),c},YPe=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),XPe=()=>({tr:e,dispatch:t})=>{if(t){let t=new Rq(e.doc);e.setSelection(t)}return!0},ZPe=()=>({state:e,dispatch:t})=>rJ(e,t),QPe=()=>({state:e,dispatch:t})=>sJ(e,t),$Pe=()=>({state:e,dispatch:t})=>cMe(e,t),eFe=()=>({state:e,dispatch:t})=>_J(e,t),tFe=()=>({state:e,dispatch:t})=>gJ(e,t);function LZ(e,t,n={},r={}){return MZ(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var nFe=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=LZ(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function RZ(e,t){let n=wZ(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function zZ(e,t){let n=new Aq(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function rFe(e){for(let t=0;t{n(e)&&r.push({node:e,pos:t})}),r}function aFe(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function BZ(e){return t=>aFe(t.$from,e)}function VZ(e,t,n){return e.config[t]===void 0&&e.parent?VZ(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?VZ(e.parent,t,n):null}):e.config[t]}function HZ(e){return e.map(e=>{let t=VZ(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...HZ(t())]:e}).flat(10)}function UZ(e,t){let n=LK.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function WZ(e){return typeof e==`function`}function GZ(e,t=void 0,...n){return WZ(e)?t?e.bind(t)(...n):e(...n):e}function oFe(e={}){return Object.keys(e).length===0&&e.constructor===Object}function KZ(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function qZ(e){let t=[],{nodeExtensions:n,markExtensions:r}=KZ(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=VZ(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=VZ(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function JZ(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=t?t.split(`;`).map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(`;`).map(e=>e.trim()).filter(Boolean):[],a=new Map;i.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),n[e]=Array.from(a.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function YZ(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>JZ(e,t),{})}function sFe(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function XZ(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):sFe(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function ZZ(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&oFe(t)?!1:t!=null))}function QZ(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function cFe(e,t){let n=qZ(e),{nodeExtensions:r,markExtensions:i}=KZ(e);return new wK({topNode:r.find(e=>VZ(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=ZZ({...e.reduce((e,t)=>{let n=VZ(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:GZ(VZ(r,`content`,a)),marks:GZ(VZ(r,`marks`,a)),group:GZ(VZ(r,`group`,a)),inline:GZ(VZ(r,`inline`,a)),atom:GZ(VZ(r,`atom`,a)),selectable:GZ(VZ(r,`selectable`,a)),draggable:GZ(VZ(r,`draggable`,a)),code:GZ(VZ(r,`code`,a)),whitespace:GZ(VZ(r,`whitespace`,a)),linebreakReplacement:GZ(VZ(r,`linebreakReplacement`,a)),defining:GZ(VZ(r,`defining`,a)),isolating:GZ(VZ(r,`isolating`,a)),attrs:Object.fromEntries(i.map(QZ))}),s=GZ(VZ(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>XZ(e,i)));let c=VZ(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:YZ(e,i)}));let l=VZ(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=ZZ({...e.reduce((e,t)=>{let n=VZ(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:GZ(VZ(r,`inclusive`,a)),excludes:GZ(VZ(r,`excludes`,a)),group:GZ(VZ(r,`group`,a)),spanning:GZ(VZ(r,`spanning`,a)),code:GZ(VZ(r,`code`,a)),attrs:Object.fromEntries(i.map(QZ))}),s=GZ(VZ(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>XZ(e,i)));let c=VZ(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:YZ(e,i)})),[r.name,o]}))})}function lFe(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function $Z(e){return e.sort((e,t)=>{let n=VZ(e,`priority`)||100,r=VZ(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function tQ(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` +`),slice:t}}function oX(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new QG(KG.from(e.state.schema.text(t.replace(/\r\n?/g,` +`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=RK.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=dNe(n),ZJ&&fNe(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||DK.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!sNe.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=pNe(dX(s,+u[1],+u[2]),u[4]);else if(s=QG.maxOpen(cNe(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var sNe=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function cNe(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&cX(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=lX(a[a.length-1],i.length));let n=sX(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return KG.from(a)}return e}function sX(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,KG.from(e));return e}function cX(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(KG.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function dX(e,t,n){return te}),mX.createHTML(e)):e}function dNe(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=pX().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&fX[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>``).reverse().join(``)),n.innerHTML=uNe(e),i)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=KG.from(t.create(r[e+1],i)),a++,o++}return new QG(i,a,o)}var hX={},gX={},mNe={touchstart:!0,touchmove:!0},hNe=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function gNe(e){for(let t in hX){let n=hX[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{vNe(e,t)&&!yX(e,t)&&(e.editable||!(t.type in gX))&&n(e,t)},mNe[t]?{passive:!0}:void 0)}KJ&&e.dom.addEventListener(`input`,()=>null),vX(e)}function _X(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function _Ne(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function vX(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>yX(e,t))})}function yX(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function vNe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function yNe(e,t){!yX(e,t)&&hX[t.type]&&(e.editable||!(t.type in gX))&&hX[t.type](e,t)}gX.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!TX(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!(XJ&&WJ&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),qJ&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,NJ(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||oNe(e,n)?n.preventDefault():_X(e,`key`)},gX.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},gX.keypress=(e,t)=>{let n=t;if(TX(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||JJ&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof Iq)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function bX(e){return{left:e.clientX,top:e.clientY}}function bNe(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function xX(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function SX(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function xNe(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&Rq.isSelectable(r)?(SX(e,new Rq(n),`pointer`),!0):!1}function SNe(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof Rq&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(Rq.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(SX(e,Rq.create(e.state.doc,i),`pointer`),!0)}function CNe(e,t,n,r,i){return xX(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?SNe(e,n):xNe(e,n))}function wNe(e,t,n,r){return xX(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function TNe(e,t,n,r){return xX(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||ENe(e,n,r)}function ENe(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(SX(e,Iq.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)SX(e,Iq.create(r,a+1,a+1+n.content.size),`pointer`);else if(Rq.isSelectable(n))SX(e,Rq.create(r,a),`pointer`);else continue;return!0}}function CX(e){return OX(e)}var wX=JJ?`metaKey`:`ctrlKey`;hX.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=CX(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&bNe(n,e.input.lastClick)&&!n[wX]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(bX(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new DNe(e,o,n,!!r)):(a==`doubleClick`?wNe:TNe)(e,o.pos,o.inside,n)?n.preventDefault():_X(e,`pointer`))};var DNe=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[wX],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Rq&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&HJ&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),_X(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>LY(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(bX(e))),this.updateAllowDefault(e),this.allowDefault||!t?_X(this.view,`pointer`):CNe(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||KJ&&this.mightDrag&&!this.mightDrag.node.isAtom||WJ&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(SX(this.view,Nq.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):_X(this.view,`pointer`)}move(e){this.updateAllowDefault(e),_X(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};hX.touchstart=e=>{e.input.lastTouch=Date.now(),CX(e),_X(e,`pointer`)},hX.touchmove=e=>{e.input.lastTouch=Date.now(),_X(e,`pointer`)},hX.contextmenu=e=>CX(e);function TX(e,t){return e.composing?!0:KJ&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var ONe=XJ?5e3:-1;gX.compositionstart=gX.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof Iq&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||WJ&&YJ&&kNe(e)))e.markCursor=e.state.storedMarks||n.marks(),OX(e,!0),e.markCursor=null;else if(OX(e,!t.selection.empty),HJ&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}EX(e,ONe)};function kNe(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}gX.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,EX(e,20))};function EX(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>OX(e),t))}function DX(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=jNe());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ANe(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=xMe(t.focusNode,t.focusOffset),r=SMe(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function jNe(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function OX(e,t=!1){if(!(XJ&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),DX(e),t||e.docView&&e.docView.dirty){let n=FY(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function MNe(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var kX=BJ&&VJ<15||qJ&&EMe<604;hX.copy=gX.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=kX?null:n.clipboardData,{dom:o,text:s}=aX(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):MNe(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function NNe(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function PNe(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?AX(e,r.value,null,i,t):AX(e,r.textContent,r.innerHTML,i,t)},50)}function AX(e,t,n,r,i){let a=oX(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||QG.empty)))return!0;if(!a)return!1;let o=NNe(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function jX(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}gX.paste=(e,t)=>{let n=t;if(e.composing&&!XJ)return;let r=kX?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&AX(e,jX(r),r.getData(`text/html`),i,n)?n.preventDefault():PNe(e,n)};var MX=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},FNe=JJ?`altKey`:`ctrlKey`;function NX(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[FNe]}hX.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(bX(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Rq?i.to-1:i.to))){if(r&&r.mightDrag)o=Rq.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=Rq.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=aX(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!WJ||GJ>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(kX?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,kX||n.dataTransfer.setData(`text/plain`,c),e.dragging=new MX(l,NX(e,n),o)},hX.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},gX.dragover=gX.dragenter=(e,t)=>t.preventDefault(),gX.drop=(e,t)=>{try{INe(e,t,e.dragging)}finally{e.dragging=null}};function INe(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(bX(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=oX(e,jX(t.dataTransfer),kX?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&NX(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||QG.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?vq(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&Rq.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new Rq(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(WY(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}hX.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&LY(e)},20))},hX.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},hX.beforeinput=(e,t)=>{if(WJ&&XJ&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,NJ(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in gX)hX[e]=gX[e];function PX(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var FX=class e{constructor(e,t){this.toDOM=e,this.spec=t||zX,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new LX(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&PX(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},IX=class e{constructor(e,t){this.attrs=e,this.spec=t||zX}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new LX(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==VX||e.maps.length==0?this:this.mapInner(e,t,0,0,n||zX)}mapInner(t,n,r,i,a){let o;for(let e=0;e{let o=t+r,s;if(s=WX(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof IX){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,zX));return e.from(r)}forChild(t,n){if(n.isLeaf)return BX.empty;let r=[];for(let i=0;ie instanceof BX)?t:t.reduce((e,t)=>e.concat(t instanceof BX?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==VX?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=KX(zNe(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=WX(e,t,o+n);if(s){a=!0;let e=KX(s,t,n+o+1,r);e!=VX&&i.push(o,o+t.nodeSize,e)}});let o=UX(a?GX(e):e,-n).sort(qX);for(let e=0;e0;)t++;e.splice(t,0,n)}function XX(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=VX&&t.push(r)}),e.cursorWrapper&&t.push(BX.create(e.state.doc,[e.cursorWrapper.deco])),HX.from(t)}var BNe={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},VNe=BJ&&VJ<=11,HNe=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},UNe=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new HNe,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():KJ&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),VNe&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,BNe)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(GY(this.view)){if(this.suppressingSelectionUpdates)return LY(this.view);if(BJ&&VJ<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&OJ(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=TJ(n))t.add(n);for(let r=e.anchorNode;r;r=TJ(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&GY(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;t&&t.nodeType==1&&t.contentEditable==`false`&&e.parentNode.removeChild(e)}}else if(HJ&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||KNe(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),WNe(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,qNe(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||LY(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;ni;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||DK.fromSchema(e.state.schema),p=d.resolve(o),m=null,h=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:YNe,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,m={anchor:e+o,head:t+o}}return{doc:h,sel:m,from:o,to:s}}function YNe(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(KJ&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||KJ&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var XNe=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function ZNe(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=FY(e,t);if(n&&!e.state.selection.eq(n)){if(WJ&&XJ&&e.input.lastKeyCode===13&&Date.now()-100t(e,NJ(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=JNe(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||XJ)&&i.some(e=>e.nodeType==1&&!XNe.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,NJ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof Iq&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=eZ(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),BJ&&VJ<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((qJ&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&h.post(e,NJ(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&$Ne(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,NJ(8,`Backspace`)))){XJ&&WJ&&e.domObserver.suppressSelectionUpdates();return}WJ&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),XJ&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,NJ(13,`Enter`))})},20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=eZ(e,n.doc,l.sel);t&&!(WJ&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteLY(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=QNe(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x());else e.dispatch(x())}function eZ(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:WY(e,t.resolve(n.anchor),t.resolve(n.head))}function QNe(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||tZ(o,!0,!1)0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function ePe(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o=o?a-r:0;a-=e,a&&a=s?a-r:0;a-=t,a&&a=56320&&t<=57343&&n>=55296&&n<=56319}var rZ=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hNe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(cZ),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=oZ(this),aZ(this),this.nodeViews=sZ(this),this.docView=CY(this.state.doc,iZ(this),XX(this),this.dom,this),this.domObserver=new UNe(this,(e,t,n,r)=>ZNe(this,e,t,n,r)),this.domObserver.start(),gNe(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&vX(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cZ),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(DX(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=sZ(this);nPe(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&vX(this),this.editable=oZ(this),aZ(this);let o=XX(this),s=iZ(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&kMe(this);if(i){this.domObserver.stop();let t=l&&(BJ||WJ)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&tPe(n.selection,e.selection);if(l){let n=WJ?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ANe(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=CY(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$Me(this))?LY(this,t):(HY(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&AMe(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof Rq){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&$J(this,t.getBoundingClientRect(),e)}else $J(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new MX(e.slice,e.move,r<0?void 0:Rq.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;ne.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return IMe(this,e)}coordsAtPos(e,t=1){return cY(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return VMe(this,t||this.state,e)}pasteHTML(e,t){return AX(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return AX(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return aX(this,e)}destroy(){this.docView&&(_Ne(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],XX(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,yMe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return yNe(this,e)}domSelectionRange(){let e=this.domSelection();return e?KJ&&this.root.nodeType===11&&wMe(this.dom.ownerDocument)==this.dom&&GNe(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};rZ.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function iZ(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[LX.node(0,e.state.doc.content.size,t)]}function aZ(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:LX.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function oZ(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function tPe(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function sZ(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function nPe(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function cZ(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var lZ={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},uZ={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},rPe=typeof navigator<`u`&&/Mac/.test(navigator.platform),iPe=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dZ=0;dZ<10;dZ++)lZ[48+dZ]=lZ[96+dZ]=String(dZ);for(var dZ=1;dZ<=24;dZ++)lZ[dZ+111]=`F`+dZ;for(var dZ=65;dZ<=90;dZ++)lZ[dZ]=String.fromCharCode(dZ+32),uZ[dZ]=String.fromCharCode(dZ);for(var fZ in lZ)uZ.hasOwnProperty(fZ)||(uZ[fZ]=lZ[fZ]);function aPe(e){var t=!(rPe&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||iPe&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?uZ:lZ)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var oPe=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),sPe=typeof navigator<`u`&&/Win/.test(navigator.platform);function cPe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e{for(var n in t)dPe(e,n,{get:t[n],enumerable:!0})};function gZ(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var _Z=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:gZ({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},vZ={};hZ(vZ,{blur:()=>fPe,clearContent:()=>pPe,clearNodes:()=>mPe,command:()=>hPe,createParagraphNear:()=>gPe,cut:()=>_Pe,deleteCurrentNode:()=>vPe,deleteNode:()=>yPe,deleteRange:()=>bPe,deleteSelection:()=>xPe,enter:()=>SPe,exitCode:()=>CPe,extendMarkRange:()=>wPe,first:()=>TPe,focus:()=>DPe,forEach:()=>OPe,insertContent:()=>kPe,insertContentAt:()=>MPe,joinBackward:()=>FPe,joinDown:()=>PPe,joinForward:()=>IPe,joinItemBackward:()=>LPe,joinItemForward:()=>RPe,joinTextblockBackward:()=>zPe,joinTextblockForward:()=>BPe,joinUp:()=>NPe,keyboardShortcut:()=>HPe,lift:()=>UPe,liftEmptyBlock:()=>WPe,liftListItem:()=>GPe,newlineInCode:()=>KPe,resetAttributes:()=>qPe,scrollIntoView:()=>JPe,selectAll:()=>YPe,selectNodeBackward:()=>XPe,selectNodeForward:()=>ZPe,selectParentNode:()=>QPe,selectTextblockEnd:()=>$Pe,selectTextblockStart:()=>eFe,setContent:()=>tFe,setMark:()=>xFe,setMeta:()=>SFe,setNode:()=>CFe,setNodeSelection:()=>wFe,setTextDirection:()=>TFe,setTextSelection:()=>EFe,sinkListItem:()=>DFe,splitBlock:()=>OFe,splitListItem:()=>kFe,toggleList:()=>AFe,toggleMark:()=>jFe,toggleNode:()=>MFe,toggleWrap:()=>NFe,undoInputRule:()=>PFe,unsetAllMarks:()=>FFe,unsetMark:()=>IFe,unsetTextDirection:()=>LFe,updateAttributes:()=>RFe,wrapIn:()=>zFe,wrapInList:()=>BFe});var fPe=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),pPe=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),mPe=()=>({state:e,tr:t,dispatch:n})=>{let{selection:r}=t,{ranges:i}=r;return n&&i.forEach(({$from:n,$to:r})=>{e.doc.nodesBetween(n.pos,r.pos,(e,n)=>{if(e.type.isText)return;let{doc:r,mapping:i}=t,a=r.resolve(i.map(n)),o=r.resolve(i.map(n+e.nodeSize)),s=a.blockRange(o);if(!s)return;let c=lq(s);if(e.type.isTextblock){let{defaultType:e}=a.parent.contentMatchAt(a.index());t.setNodeMarkup(s.start,e)}(c||c===0)&&t.lift(s,c)})}),!0},hPe=e=>t=>e(t),gPe=()=>({state:e,dispatch:t})=>pJ(e,t),_Pe=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new Iq(r.doc.resolve(Math.max(o-1,0)))),!0},vPe=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function yZ(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var yPe=e=>({tr:t,state:n,dispatch:r})=>{let i=yZ(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},bPe=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},xPe=()=>({state:e,dispatch:t})=>$q(e,t),SPe=()=>({commands:e})=>e.keyboardShortcut(`Enter`),CPe=()=>({state:e,dispatch:t})=>fJ(e,t);function bZ(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function xZ(e,t,n={strict:!0}){let r=Object.keys(t);return r.length?r.every(r=>n.strict?t[r]===e[r]:bZ(t[r])?t[r].test(e[r]):t[r]===e[r]):!0}function SZ(e,t,n={}){return e.find(e=>e.type===t&&xZ(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function CZ(e,t,n={}){return!!SZ(e,t,n)}function wZ(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t)||(n||=r.node.marks[0]?.attrs,!SZ([...r.node.marks],t,n)))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&CZ([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=TZ(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=wZ(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=Iq.create(o,e.from,e.to);n.setSelection(t)}}return!0},TPe=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(AZ()||kZ())&&r.dom.focus(),EPe()&&!AZ()&&!kZ()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!EZ(n.state.selection))return o(),!0;let s=OZ(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},OPe=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),kPe=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),jZ=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&jZ(r)}return e};function MZ(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return jZ(n)}function NZ(e,t,n){if(e instanceof fK||e instanceof KG)return e;n={slice:!0,parseOptions:{},...n};let r=typeof e==`object`&&!!e,i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return KG.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),NZ(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new TK({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?DK.fromSchema(a).parseSlice(MZ(e),n.parseOptions):DK.fromSchema(a).parse(MZ(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=DK.fromSchema(t);return n.slice?r.parseSlice(MZ(e),n.parseOptions).content:r.parse(MZ(e),n.parseOptions)}return NZ(``,t,n)}function APe(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(Nq.near(e.doc.resolve(o),n))}var jPe=e=>!(`type`in e),MPe=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{NZ(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=NZ(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0;if((jPe(i)?i:[i]).forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let f;if(u){if(Array.isArray(t))f=t.map(e=>e.text||``).join(``);else if(t instanceof KG){let e=``;t.forEach(t=>{t.text&&(e+=t.text)}),f=e}else f=typeof t==`object`&&t&&t.text?t.text:t;r.insertText(f,c,l)}else{f=i;let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,a=t.isText||t.isTextblock,o=t.content.size>0;n&&a&&o&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&APe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:f}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:f})}return!0},NPe=()=>({state:e,dispatch:t})=>nMe(e,t),PPe=()=>({state:e,dispatch:t})=>rMe(e,t),FPe=()=>({state:e,dispatch:t})=>tJ(e,t),IPe=()=>({state:e,dispatch:t})=>sJ(e,t),LPe=()=>({state:e,dispatch:t,tr:n})=>{try{let r=_q(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},RPe=()=>({state:e,dispatch:t,tr:n})=>{try{let r=_q(e.doc,e.selection.$from.pos,1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},zPe=()=>({state:e,dispatch:t})=>eMe(e,t),BPe=()=>({state:e,dispatch:t})=>tMe(e,t);function PZ(){return typeof navigator<`u`?/Mac/.test(navigator.platform):!1}function VPe(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=VPe(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function FZ(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?yZ(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>o?o.name===e.node.type.name:!0).filter(e=>xZ(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var UPe=(e,t={})=>({state:n,dispatch:r})=>FZ(n,yZ(e,n.schema),t)?iMe(n,r):!1,WPe=()=>({state:e,dispatch:t})=>mJ(e,t),GPe=e=>({state:t,dispatch:n})=>hMe(yZ(e,t.schema))(t,n),KPe=()=>({state:e,dispatch:t})=>uJ(e,t);function IZ(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function LZ(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var qPe=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=IZ(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=yZ(e,r.schema)),s===`mark`&&(o=TZ(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,LZ(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(LZ(a.attrs,t))))})})}),c},JPe=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),YPe=()=>({tr:e,dispatch:t})=>{if(t){let t=new zq(e.doc);e.setSelection(t)}return!0},XPe=()=>({state:e,dispatch:t})=>iJ(e,t),ZPe=()=>({state:e,dispatch:t})=>cJ(e,t),QPe=()=>({state:e,dispatch:t})=>sMe(e,t),$Pe=()=>({state:e,dispatch:t})=>vJ(e,t),eFe=()=>({state:e,dispatch:t})=>_J(e,t);function RZ(e,t,n={},r={}){return NZ(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var tFe=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=RZ(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,s).setMeta(`preventUpdate`,!n),!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function zZ(e,t){let n=TZ(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function BZ(e,t){let n=new jq(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function nFe(e){for(let t=0;t{n(e)&&r.push({node:e,pos:t})}),r}function iFe(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function VZ(e){return t=>iFe(t.$from,e)}function HZ(e,t,n){return e.config[t]===void 0&&e.parent?HZ(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?HZ(e.parent,t,n):null}):e.config[t]}function UZ(e){return e.map(e=>{let t=HZ(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...UZ(t())]:e}).flat(10)}function WZ(e,t){let n=RK.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function GZ(e){return typeof e==`function`}function KZ(e,t=void 0,...n){return GZ(e)?t?e.bind(t)(...n):e(...n):e}function aFe(e={}){return Object.keys(e).length===0&&e.constructor===Object}function qZ(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function JZ(e){let t=[],{nodeExtensions:n,markExtensions:r}=qZ(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n=HZ(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=HZ(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function YZ(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=t?t.split(`;`).map(e=>e.trim()).filter(Boolean):[],i=n[e]?n[e].split(`;`).map(e=>e.trim()).filter(Boolean):[],a=new Map;i.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),r.forEach(e=>{let[t,n]=e.split(`:`).map(e=>e.trim());a.set(t,n)}),n[e]=Array.from(a.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function XZ(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>YZ(e,t),{})}function oFe(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`?!0:e===`false`?!1:e:e}function ZZ(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):oFe(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function QZ(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&aFe(t)?!1:t!=null))}function $Z(e){let t={};return!e?.attribute?.isRequired&&`default`in(e?.attribute||{})&&(t.default=e.attribute.default),e?.attribute?.validate!==void 0&&(t.validate=e.attribute.validate),[e.name,t]}function sFe(e,t){let n=JZ(e),{nodeExtensions:r,markExtensions:i}=qZ(e);return new TK({topNode:r.find(e=>HZ(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=QZ({...e.reduce((e,t)=>{let n=HZ(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:KZ(HZ(r,`content`,a)),marks:KZ(HZ(r,`marks`,a)),group:KZ(HZ(r,`group`,a)),inline:KZ(HZ(r,`inline`,a)),atom:KZ(HZ(r,`atom`,a)),selectable:KZ(HZ(r,`selectable`,a)),draggable:KZ(HZ(r,`draggable`,a)),code:KZ(HZ(r,`code`,a)),whitespace:KZ(HZ(r,`whitespace`,a)),linebreakReplacement:KZ(HZ(r,`linebreakReplacement`,a)),defining:KZ(HZ(r,`defining`,a)),isolating:KZ(HZ(r,`isolating`,a)),attrs:Object.fromEntries(i.map($Z))}),s=KZ(HZ(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>ZZ(e,i)));let c=HZ(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:XZ(e,i)}));let l=HZ(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=QZ({...e.reduce((e,t)=>{let n=HZ(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:KZ(HZ(r,`inclusive`,a)),excludes:KZ(HZ(r,`excludes`,a)),group:KZ(HZ(r,`group`,a)),spanning:KZ(HZ(r,`spanning`,a)),code:KZ(HZ(r,`code`,a)),attrs:Object.fromEntries(i.map($Z))}),s=KZ(HZ(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>ZZ(e,i)));let c=HZ(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:XZ(e,i)})),[r.name,o]}))})}function cFe(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function eQ(e){return e.sort((e,t)=>{let n=HZ(e,`priority`)||100,r=HZ(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function nQ(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` -`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function uFe(e,t){return tQ(e,{from:0,to:e.content.size},t)}function nQ(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function dFe(e,t){let n=vZ(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function rQ(e,t){let n=FZ(typeof t==`string`?t:t.name,e.schema);return n===`node`?dFe(e,t):n===`mark`?RZ(e,t):{}}function fFe(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function pFe(e){let t=fFe(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function iQ(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),pFe(r)}function aQ(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=CZ(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var mFe=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function oQ(e,t){return t.nodes[e]||t.marks[e]||null}function sQ(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var hFe=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function cQ(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?wZ(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>bZ(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize),c=a-n;o+=c,s.push(...e.marks.map(e=>({mark:e,from:n,to:a})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>bZ(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function gFe(e,t,n={}){if(!t)return PZ(e,null,n)||cQ(e,null,n);let r=FZ(t,e.schema);return r===`node`?PZ(e,t,n):r===`mark`?cQ(e,t,n):!1}var _Fe=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=BZ(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function lQ(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function uQ(e,t){let{nodeExtensions:n}=KZ(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=GZ(VZ(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function dQ(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return/^\s*$/m.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(dQ(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function fQ(e){return e instanceof Lq}var pQ=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function yFe(e,t){let n=t.mapping.mapResult(e.position);return{position:new pQ(n.pos),mapResult:n}}function bFe(e){return new pQ(e)}function xFe(e,t,n){let{selection:r}=t,i=null;if(TZ(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var SFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=wZ(e,r.schema);if(i)if(o){let e=RZ(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return xFe(r,n,c)},CFe=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),wFe=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=vZ(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>vJ(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>vJ(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},TFe=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=EZ(e,0,n.content.size),i=Lq.create(n,r);t.setSelection(i)}return!0},EFe=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},DFe=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Fq.atStart(n).from,o=Fq.atEnd(n).to,s=EZ(r,a,o),c=EZ(i,a,o),l=Fq.create(n,s,c);t.setSelection(l)}return!0},OFe=e=>({state:t,dispatch:n})=>yMe(vZ(e,t.schema))(t,n);function mQ(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var kFe=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=sQ(l,s.node().type.name,s.node().attrs);if(a instanceof Lq&&a.node.isBlock)return!s.parentOffset||!pq(o,s.pos)?!1:(r&&(e&&mQ(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:rFe(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=pq(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&pq(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Fq&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&mQ(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},AFe=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=vZ(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=GG.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=GG.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Fq.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...sQ(d,u.type.name,u.attrs),...t},m={...sQ(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!pq(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},hQ=(e,t)=>{let n=BZ(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&mq(e.doc,n.pos)&&e.join(n.pos),!0},gQ=(e,t)=>{let n=BZ(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&mq(e.doc,r)&&e.join(r),!0},jFe=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=vZ(e,o.schema),m=vZ(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=BZ(e=>uQ(e.type.name,d))(h);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===p)return l.liftListItem(m);if(uQ(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>hQ(a,p)).command(()=>gQ(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>hQ(a,p)).command(()=>gQ(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>hQ(a,p)).command(()=>gQ(a,p)).run()},MFe=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=wZ(e,r.schema);return cQ(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},NFe=(e,t,n={})=>({state:r,commands:i})=>{let a=vZ(e,r.schema),o=vZ(t,r.schema),s=PZ(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},PFe=(e,t={})=>({state:n,commands:r})=>{let i=vZ(e,n.schema);return PZ(n,i,t)?r.lift(i):r.wrapIn(i,t)},FFe=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},IFe=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},LFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=wZ(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=CZ(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},RFe=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},zFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=FZ(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=vZ(e,r.schema)),s===`mark`&&(o=wZ(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},BFe=(e,t={})=>({state:n,dispatch:r})=>dMe(vZ(e,n.schema),t)(n,r),VFe=(e,t={})=>({state:n,dispatch:r})=>pMe(vZ(e,n.schema),t)(n,r),HFe=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},_Q=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},UFe=(e,t)=>{if(yZ(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function vQ(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=hFe(c)+i;return a.forEach(e=>{if(l)return;let a=UFe(u,e.find);if(!a)return;let c=s.state.tr,d=hZ({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new gZ({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function WFe(e){let{editor:t,rules:n}=e,r=new Jq({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:UZ(GG.from(e),a.schema);let{from:i}=s;vQ({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return vQ({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&vQ({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?vQ({editor:t,from:a.pos,to:a.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function GFe(e){return Object.prototype.toString.call(e).slice(8,-1)}function yQ(e){return GFe(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function bQ(e,t){let n={...e};return yQ(e)&&yQ(t)&&Object.keys(t).forEach(r=>{yQ(t[r])&&yQ(e[r])?n[r]=bQ(e[r],t[r]):n[r]=t[r]}),n}var xQ=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...GZ(VZ(this,`addOptions`,{name:this.name}))||{}}}get storage(){return{...GZ(VZ(this,`addStorage`,{name:this.name,options:this.options}))||{}}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>bQ(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},SQ=class e extends xQ{constructor(){super(...arguments),this.type=`mark`}static create(t={}){return new e(typeof t==`function`?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function KFe(e){return typeof e==`number`}var qFe=class{constructor(e){this.find=e.find,this.handler=e.handler}},JFe=(e,t,n)=>{if(yZ(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function YFe(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new gZ({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(e.type?.spec?.code||!(e.isText||e.isTextblock||e.isInline))return;let f=e.content?.size??e.nodeSize??0,p=Math.max(r,t),m=Math.min(i,t+f);p>=m||JFe(e.isText?e.text||``:e.textBetween(p-t,m-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var CQ=null,XFe=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function ZFe(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!YFe({editor:t,state:hZ({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new Jq({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(CQ=t)},i=()=>{CQ&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=CQ;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:UZ(GG.from(t),r.schema);let{from:n}=d,i=n+t.length,a=XFe(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!KFe(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var wQ=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=eQ(e),this.schema=cFe(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=VZ(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:oQ(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this;return $Z([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:oQ(t.name,this.schema)},r=[],i=VZ(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&VZ(t,`exitable`,n)&&(a.ArrowRight=()=>SQ.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=dPe(a);r.push(o);let s=VZ(t,`addInputRules`,n);if(lQ(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=WFe({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=VZ(t,`addPasteRules`,n);if(lQ(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=ZFe({editor:e,rules:t});r.push(...n)}}let l=VZ(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r})}get attributes(){return qZ(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=KZ(this.extensions);return Object.fromEntries(t.filter(e=>!!VZ(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=VZ(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:vZ(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:YZ(r,n)})]:[]}))}dispatchTransaction(e){let{editor:t}=this;return $Z([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:oQ(n.name,this.schema)},i=VZ(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}get markViews(){let{editor:e}=this,{markExtensions:t}=KZ(this.extensions);return Object.fromEntries(t.filter(e=>!!VZ(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=VZ(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:wZ(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=YZ(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{uIe(i,e,t)}})}]:[]}))}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:oQ(e.name,this.schema)};e.type===`mark`&&(GZ(VZ(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=VZ(e,`onBeforeCreate`,t),r=VZ(e,`onCreate`,t),i=VZ(e,`onUpdate`,t),a=VZ(e,`onSelectionUpdate`,t),o=VZ(e,`onTransaction`,t),s=VZ(e,`onFocus`,t),c=VZ(e,`onBlur`,t),l=VZ(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};wQ.resolve=eQ,wQ.sort=$Z,wQ.flatten=HZ,mZ({},{ClipboardTextSerializer:()=>EQ,Commands:()=>DQ,Delete:()=>OQ,Drop:()=>kQ,Editable:()=>AQ,FocusEvents:()=>MQ,Keymap:()=>NQ,Paste:()=>PQ,Tabindex:()=>FQ,TextDirection:()=>IQ,focusEventsPluginKey:()=>jQ});var TQ=class e extends xQ{constructor(){super(...arguments),this.type=`extension`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},EQ=TQ.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Jq({key:new Zq(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=nQ(n);return tQ(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),DQ=TQ.create({name:`commands`,addCommands(){return{..._Z}}}),OQ=TQ.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){let n=()=>{var n;if(((n=this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n,e)??e.getMeta(`y-sync$`))return;let r=zZ(e.before,[e,...t]);iQ(r).forEach(t=>{r.mapping.mapResult(t.oldRange.from).deletedAfter&&r.mapping.mapResult(t.oldRange.to).deletedBefore&&r.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,i)=>{let a=i+n.nodeSize-2,o=t.oldRange.from<=i&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:i,to:a,newFrom:r.mapping.map(i),newTo:r.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:r})})});let i=r.mapping;r.steps.forEach((t,n)=>{if(t instanceof tq){let a=i.slice(n).map(t.from,-1),o=i.slice(n).map(t.to),s=i.invert().map(a,-1),c=i.invert().map(o),l=r.doc.nodeAt(a-1)?.marks.some(e=>e.eq(t.mark)),u=r.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:a,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:r})}})};this.editor.options.coreExtensionOptions?.delete?.async??!0?setTimeout(n,0):n()}}),kQ=TQ.create({name:`drop`,addProseMirrorPlugins(){return[new Jq({key:new Zq(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),AQ=TQ.create({name:`editable`,addProseMirrorPlugins(){return[new Jq({key:new Zq(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),jQ=new Zq(`focusEvents`),MQ=TQ.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new Jq({key:jQ,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),NQ=TQ.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:Mq.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return kZ()||NZ()?i:r},addProseMirrorPlugins(){return[new Jq({key:new Zq(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=Mq.atStart(t.doc).from,l=Mq.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!dQ(n.doc))return;let u=n.tr,d=hZ({state:n,transaction:u}),{commands:f}=new gZ({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),PQ=TQ.create({name:`paste`,addProseMirrorPlugins(){return[new Jq({key:new Zq(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),FQ=TQ.create({name:`tabindex`,addProseMirrorPlugins(){return[new Jq({key:new Zq(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),IQ=TQ.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=KZ(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Jq({key:new Zq(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),QFe=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},$Fe=`.ProseMirror { +`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;e.isText&&(s+=(e?.text)?.slice(Math.max(r,n)-n,i-n))}),s}function lFe(e,t){return nQ(e,{from:0,to:e.content.size},t)}function rQ(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function uFe(e,t){let n=yZ(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function iQ(e,t){let n=IZ(typeof t==`string`?t:t.name,e.schema);return n===`node`?uFe(e,t):n===`mark`?zZ(e,t):{}}function dFe(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function fFe(e){let t=dFe(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function aQ(e){let{mapping:t,steps:n}=e,r=[];return t.maps.forEach((e,i)=>{let a=[];if(e.ranges.length)e.forEach((e,t)=>{a.push({from:e,to:t})});else{let{from:e,to:t}=n[i];if(e===void 0||t===void 0)return;a.push({from:e,to:t})}a.forEach(({from:e,to:n})=>{let a=t.slice(i).map(e,-1),o=t.slice(i).map(n),s=t.invert().map(a,-1),c=t.invert().map(o);r.push({oldRange:{from:s,to:c},newRange:{from:a,to:o}})})}),fFe(r)}function oQ(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=wZ(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{!e||e?.nodeSize===void 0||r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var pFe=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]};function sQ(e,t){return t.nodes[e]||t.marks[e]||null}function cQ(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var mFe=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function lQ(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?TZ(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>a?a.name===e.type.name:!0).find(e=>xZ(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize),c=a-n;o+=c,s.push(...e.marks.map(e=>({mark:e,from:n,to:a})))})}),o===0)return!1;let c=s.filter(e=>a?a.name===e.mark.type.name:!0).filter(e=>xZ(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>a?e.mark.type!==a&&e.mark.type.excludes(a):!0).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function hFe(e,t,n={}){if(!t)return FZ(e,null,n)||lQ(e,null,n);let r=IZ(t,e.schema);return r===`node`?FZ(e,t,n):r===`mark`?lQ(e,t,n):!1}var gFe=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=VZ(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function uQ(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function dQ(e,t){let{nodeExtensions:n}=qZ(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=KZ(HZ(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`?i.split(` `).includes(`list`):!1}function fQ(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return/^\s*$/m.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(fQ(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function pQ(e){return e instanceof Rq}var mQ=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function vFe(e,t){let n=t.mapping.mapResult(e.position);return{position:new mQ(n.pos),mapResult:n}}function yFe(e){return new mQ(e)}function bFe(e,t,n){let{selection:r}=t,i=null;if(EZ(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var xFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=TZ(e,r.schema);if(i)if(o){let e=zZ(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})});return bFe(r,n,c)},SFe=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),CFe=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=yZ(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>yJ(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>yJ(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},wFe=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=DZ(e,0,n.content.size),i=Rq.create(n,r);t.setSelection(i)}return!0},TFe=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},EFe=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=Iq.atStart(n).from,o=Iq.atEnd(n).to,s=DZ(r,a,o),c=DZ(i,a,o),l=Iq.create(n,s,c);t.setSelection(l)}return!0},DFe=e=>({state:t,dispatch:n})=>vMe(yZ(e,t.schema))(t,n);function hQ(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var OFe=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=cQ(l,s.node().type.name,s.node().attrs);if(a instanceof Rq&&a.node.isBlock)return!s.parentOffset||!mq(o,s.pos)?!1:(r&&(e&&hQ(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:nFe(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=mq(t.doc,t.mapping.map(s.pos),1,p);if(!p&&!m&&mq(t.doc,t.mapping.map(s.pos),1,f?[{type:f}]:void 0)&&(m=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(m&&(a instanceof Iq&&t.deleteSelection(),t.split(t.mapping.map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f)){let e=t.mapping.map(s.before()),n=t.doc.resolve(e);s.node(-1).canReplaceWith(n.index(),n.index()+1,f)&&t.setNodeMarkup(t.mapping.map(s.before()),f)}e&&hQ(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return m},kFe=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=yZ(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=KG.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=KG.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(Iq.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...cQ(d,u.type.name,u.attrs),...t},m={...cQ(d,s.node().type.name,s.node().attrs),...t};n.delete(s.pos,c.pos);let h=f?[{type:o,attrs:p},{type:f,attrs:m}]:[{type:o,attrs:p}];if(!mq(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,h).scrollIntoView(),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0},gQ=(e,t)=>{let n=VZ(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&hq(e.doc,n.pos)&&e.join(n.pos),!0},_Q=(e,t)=>{let n=VZ(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return n.node.type===i?.type&&hq(e.doc,r)&&e.join(r),!0},AFe=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=yZ(e,o.schema),m=yZ(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=VZ(e=>dQ(e.type.name,d))(h);if(y.depth>=1&&x&&y.depth-x.depth<=1){if(x.node.type===p)return l.liftListItem(m);if(dQ(x.node.type.name,d)&&p.validContent(x.node.content)&&s)return c().command(()=>(a.setNodeMarkup(x.pos,p),!0)).command(()=>gQ(a,p)).command(()=>_Q(a,p)).run()}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>gQ(a,p)).command(()=>_Q(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>gQ(a,p)).command(()=>_Q(a,p)).run()},jFe=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=TZ(e,r.schema);return lQ(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},MFe=(e,t,n={})=>({state:r,commands:i})=>{let a=yZ(e,r.schema),o=yZ(t,r.schema),s=FZ(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},NFe=(e,t={})=>({state:n,commands:r})=>{let i=yZ(e,n.schema);return FZ(n,i,t)?r.lift(i):r.wrapIn(i,t)},PFe=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},FFe=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:r,ranges:i}=n;return r||t&&i.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0},IFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=TZ(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=wZ(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},LFe=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},RFe=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=IZ(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=yZ(e,r.schema)),s===`mark`&&(o=TZ(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},zFe=(e,t={})=>({state:n,dispatch:r})=>uMe(yZ(e,n.schema),t)(n,r),BFe=(e,t={})=>({state:n,dispatch:r})=>fMe(yZ(e,n.schema),t)(n,r),VFe=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},vQ=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},HFe=(e,t)=>{if(bZ(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function yQ(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o}=e,{view:s}=t;if(s.composing)return!1;let c=s.state.doc.resolve(n);if(c.parent.type.spec.code||(c.nodeBefore||c.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let l=!1,u=mFe(c)+i;return a.forEach(e=>{if(l)return;let a=HFe(u,e.find);if(!a)return;let c=s.state.tr,d=gZ({state:s.state,transaction:c}),f={from:n-(a[0].length-i.length),to:r},{commands:p,chain:m,can:h}=new _Z({editor:t,state:d});e.handler({state:d,range:f,match:a,commands:p,chain:m,can:h})===null||!c.steps.length||(e.undoable&&c.setMeta(o,{transform:c,from:n,to:r,text:i}),s.dispatch(c),l=!0)}),l}function UFe(e){let{editor:t,rules:n}=e,r=new Yq({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:WZ(KG.from(e),a.schema);let{from:i}=s;yQ({editor:t,from:i,to:i+e.length,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return yQ({editor:t,from:i,to:a,text:o,rules:n,plugin:r})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&yQ({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?yQ({editor:t,from:a.pos,to:a.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function WFe(e){return Object.prototype.toString.call(e).slice(8,-1)}function bQ(e){return WFe(e)===`Object`?e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype:!1}function xQ(e,t){let n={...e};return bQ(e)&&bQ(t)&&Object.keys(t).forEach(r=>{bQ(t[r])&&bQ(e[r])?n[r]=xQ(e[r],t[r]):n[r]=t[r]}),n}var SQ=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...KZ(HZ(this,`addOptions`,{name:this.name}))||{}}}get storage(){return{...KZ(HZ(this,`addStorage`,{name:this.name,options:this.options}))||{}}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>xQ(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},CQ=class e extends SQ{constructor(){super(...arguments),this.type=`mark`}static create(t={}){return new e(typeof t==`function`?t():t)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function GFe(e){return typeof e==`number`}var KFe=class{constructor(e){this.find=e.find,this.handler=e.handler}},qFe=(e,t,n)=>{if(bZ(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function JFe(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new _Z({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{if(e.type?.spec?.code||!(e.isText||e.isTextblock||e.isInline))return;let f=e.content?.size??e.nodeSize??0,p=Math.max(r,t),m=Math.min(i,t+f);p>=m||qFe(e.isText?e.text||``:e.textBetween(p-t,m-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=p+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var wQ=null,YFe=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function XFe(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr;if(!(!JFe({editor:t,state:gZ({state:e,transaction:c}),from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})||!c.steps.length)){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return n.map(e=>new Yq({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(wQ=t)},i=()=>{wQ&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=wQ;e?.isEditable&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:WZ(KG.from(t),r.schema);let{from:n}=d,i=n+t.length,a=YFe(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(!(!GFe(p)||!m||p===m.b))return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var TQ=class{constructor(e,t){this.splittableMarks=[],this.editor=t,this.baseExtensions=e,this.extensions=tQ(e),this.schema=sFe(this.extensions,t),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=HZ(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:sQ(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this;return eQ([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:sQ(t.name,this.schema)},r=[],i=HZ(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&HZ(t,`exitable`,n)&&(a.ArrowRight=()=>CQ.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=uPe(a);r.push(o);let s=HZ(t,`addInputRules`,n);if(uQ(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=UFe({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=HZ(t,`addPasteRules`,n);if(uQ(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=XFe({editor:e,rules:t});r.push(...n)}}let l=HZ(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r})}get attributes(){return JZ(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=qZ(this.extensions);return Object.fromEntries(t.filter(e=>!!HZ(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=HZ(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:yZ(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:XZ(r,n)})]:[]}))}dispatchTransaction(e){let{editor:t}=this;return eQ([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:sQ(n.name,this.schema)},i=HZ(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}get markViews(){let{editor:e}=this,{markExtensions:t}=qZ(this.extensions);return Object.fromEntries(t.filter(e=>!!HZ(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=HZ(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:TZ(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=XZ(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{lIe(i,e,t)}})}]:[]}))}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:sQ(e.name,this.schema)};e.type===`mark`&&(KZ(HZ(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name);let n=HZ(e,`onBeforeCreate`,t),r=HZ(e,`onCreate`,t),i=HZ(e,`onUpdate`,t),a=HZ(e,`onSelectionUpdate`,t),o=HZ(e,`onTransaction`,t),s=HZ(e,`onFocus`,t),c=HZ(e,`onBlur`,t),l=HZ(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};TQ.resolve=tQ,TQ.sort=eQ,TQ.flatten=UZ,hZ({},{ClipboardTextSerializer:()=>DQ,Commands:()=>OQ,Delete:()=>kQ,Drop:()=>AQ,Editable:()=>jQ,FocusEvents:()=>NQ,Keymap:()=>PQ,Paste:()=>FQ,Tabindex:()=>IQ,TextDirection:()=>LQ,focusEventsPluginKey:()=>MQ});var EQ=class e extends SQ{constructor(){super(...arguments),this.type=`extension`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},DQ=EQ.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Yq({key:new Qq(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,{ranges:a}=i,o=Math.min(...a.map(e=>e.$from.pos)),s=Math.max(...a.map(e=>e.$to.pos)),c=rQ(n);return nQ(r,{from:o,to:s},{...this.options.blockSeparator===void 0?{}:{blockSeparator:this.options.blockSeparator},textSerializers:c})}}})]}}),OQ=EQ.create({name:`commands`,addCommands(){return{...vZ}}}),kQ=EQ.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){let n=()=>{var n;if(((n=this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n,e)??e.getMeta(`y-sync$`))return;let r=BZ(e.before,[e,...t]);aQ(r).forEach(t=>{r.mapping.mapResult(t.oldRange.from).deletedAfter&&r.mapping.mapResult(t.oldRange.to).deletedBefore&&r.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,i)=>{let a=i+n.nodeSize-2,o=t.oldRange.from<=i&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:i,to:a,newFrom:r.mapping.map(i),newTo:r.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:r})})});let i=r.mapping;r.steps.forEach((t,n)=>{if(t instanceof nq){let a=i.slice(n).map(t.from,-1),o=i.slice(n).map(t.to),s=i.invert().map(a,-1),c=i.invert().map(o),l=r.doc.nodeAt(a-1)?.marks.some(e=>e.eq(t.mark)),u=r.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:a,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:r})}})};this.editor.options.coreExtensionOptions?.delete?.async??!0?setTimeout(n,0):n()}}),AQ=EQ.create({name:`drop`,addProseMirrorPlugins(){return[new Yq({key:new Qq(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),jQ=EQ.create({name:`editable`,addProseMirrorPlugins(){return[new Yq({key:new Qq(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),MQ=new Qq(`focusEvents`),NQ=EQ.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new Yq({key:MQ,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),PQ=EQ.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:Nq.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return AZ()||PZ()?i:r},addProseMirrorPlugins(){return[new Yq({key:new Qq(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=Nq.atStart(t.doc).from,l=Nq.atEnd(t.doc).to;if(a||!(o===c&&s===l)||!fQ(n.doc))return;let u=n.tr,d=gZ({state:n,transaction:u}),{commands:f}=new _Z({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),FQ=EQ.create({name:`paste`,addProseMirrorPlugins(){return[new Yq({key:new Qq(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),IQ=EQ.create({name:`tabindex`,addProseMirrorPlugins(){return[new Yq({key:new Qq(`tabindex`),props:{attributes:()=>this.editor.isEditable?{tabindex:`0`}:{}}})]}}),LQ=EQ.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=qZ(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Yq({key:new Qq(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),ZFe=class e{constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1);return new e(this.resolvedPos.doc.resolve(t),this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e)if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),!(n&&r.length>0)&&(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},QFe=`.ProseMirror { position: relative; } @@ -8621,64 +8621,64 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`;function eIe(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var tIe=class extends HFe{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:yFe,createMappablePosition:bFe},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc(),n=DZ(t,this.options.autofocus);this.editorState=eMe.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=eIe($Fe,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=WZ(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[AQ,EQ.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),DQ,MQ,NQ,FQ,kQ,PQ,OQ,IQ.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new wQ(e,this)}createCommandManager(){this.commandManager=new gZ({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=LZ(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=LZ(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new nZ(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();let o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return rQ(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return gFe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return UZ(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`;function $Fe(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}var eIe=class extends VFe{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:vFe,createMappablePosition:yFe},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc(),n=OZ(t,this.options.autofocus);this.editorState=$je.create({doc:t,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=$Fe(QFe,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=GZ(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){let e=[...this.options.enableCoreExtensions?[jQ,DQ.configure({blockSeparator:this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator}),OQ,NQ,PQ,IQ,AQ,FQ,kQ,LQ.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions==`object`?this.options.enableCoreExtensions[e.name]!==!1:!0):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new TQ(e,this)}createCommandManager(){this.commandManager=new _Z({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=RZ(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(t){if(!(t instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(t.message))throw t;this.emit(`contentError`,{editor:this,error:t,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),e=RZ(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new rZ(e,{...t,attributes:{role:`textbox`,...t?.attributes},dispatchTransaction:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();let o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),!(e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc))&&this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return iQ(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return hFe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return WZ(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,textSerializers:n={}}=e||{};return uFe(this.state.doc,{blockSeparator:t,textSerializers:{...nQ(this.schema),...n}})}get isEmpty(){return dQ(this.state.doc)}destroy(){this.emit(`destroy`),this.unmount(),this.removeAllListeners()}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new QFe(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function LQ(e){return new _Q({find:e.find,handler:({state:t,range:n,match:r})=>{let i=GZ(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(aQ(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function RQ(e){return new _Q({find:e.find,handler:({state:t,range:n,match:r})=>{let i=GZ(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function zQ(e){return new _Q({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=GZ(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function BQ(e){return new _Q({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=GZ(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&lq(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&mq(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var nIe=e=>`touches`in e,rIe=class{constructor(e){this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e?.options?.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type?(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0):!1}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,nIe(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function iIe(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Lq){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}mZ({},{createAtomBlockMarkdownSpec:()=>aIe,createBlockMarkdownSpec:()=>oIe,createInlineMarkdownSpec:()=>lIe,parseAttributes:()=>VQ,parseIndentedBlocks:()=>UQ,renderNestedMarkdownContent:()=>WQ,serializeAttributes:()=>HQ});function VQ(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function HQ(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function aIe(e){let{nodeName:t,name:n,parseAttributes:r=VQ,serializeAttributes:i=HQ,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function oIe(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=VQ,serializeAttributes:a=HQ,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``} +`,textSerializers:n={}}=e||{};return lFe(this.state.doc,{blockSeparator:t,textSerializers:{...rQ(this.schema),...n}})}get isEmpty(){return fQ(this.state.doc)}destroy(){this.emit(`destroy`),this.unmount(),this.removeAllListeners()}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){return new ZFe(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}};function RQ(e){return new vQ({find:e.find,handler:({state:t,range:n,match:r})=>{let i=KZ(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(oQ(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function zQ(e){return new vQ({find:e.find,handler:({state:t,range:n,match:r})=>{let i=KZ(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function BQ(e){return new vQ({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=KZ(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function VQ(e){return new vQ({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=KZ(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&uq(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&hq(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var tIe=e=>`touches`in e,nIe=class{constructor(e){this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e?.options?.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){return this.contentElement??null}handleEditorUpdate(){let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(e,t,n){return e.type===this.node.type?(this.node=e,this.onUpdate?this.onUpdate(e,t,n):!0):!1}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,tIe(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}};function rIe(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof Rq){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}hZ({},{createAtomBlockMarkdownSpec:()=>iIe,createBlockMarkdownSpec:()=>aIe,createInlineMarkdownSpec:()=>cIe,parseAttributes:()=>HQ,parseIndentedBlocks:()=>WQ,renderNestedMarkdownContent:()=>GQ,serializeAttributes:()=>UQ});function HQ(e){if(!e?.trim())return{};let t={},n=[],r=e.replace(/["']([^"']*)["']/g,e=>(n.push(e),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);i&&(t.class=i.map(e=>e.trim().slice(1)).join(` `));let a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(t.id=a[1]),Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([,e,r])=>{let i=n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1]||`0`,10)];i&&(t[e]=i.slice(1,-1))});let o=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,``).replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,``).replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,``).trim();return o&&o.split(/\s+/).filter(Boolean).forEach(e=>{e.match(/^[a-zA-Z][\w-]*$/)&&(t[e]=!0)}),t}function UQ(e){if(!e||Object.keys(e).length===0)return``;let t=[];return e.class&&String(e.class).split(/\s+/).filter(Boolean).forEach(e=>t.push(`.${e}`)),e.id&&t.push(`#${e.id}`),Object.entries(e).forEach(([e,n])=>{e===`class`||e===`id`||(n===!0?t.push(e):n!==!1&&n!=null&&t.push(`${e}="${String(n)}"`))}),t.join(` `)}function iIe(e){let{nodeName:t,name:n,parseAttributes:r=HQ,serializeAttributes:i=UQ,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:s}=e,c=n||t,l=e=>{if(!s)return e;let t={};return s.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let r={...a,...e.attributes};return n.createNode(t,r,[])},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${c}(?:\\s|$)`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,i){let a=RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),s=e.match(a);if(!s)return;let l=r(s[1]||``);if(!o.find(e=>!(e in l)))return{type:t,raw:s[0],attributes:l}}},renderMarkdown:e=>{let t=i(l(e.attrs||{}));return`:::${c}${t?` {${t}}`:``} :::`}}}function aIe(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=HQ,serializeAttributes:a=UQ,defaultAttributes:o={},content:s=`block`,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{n in e&&(t[n]=e[n])}),t};return{parseMarkdown:(e,n)=>{let i;if(r){let t=r(e);i=typeof t==`string`?[{type:`text`,text:t}]:t}else i=s===`block`?n.parseChildren(e.tokens||[]):n.parseInline(e.tokens||[]);let a={...o,...e.attributes};return n.createNode(t,a,i)},markdownTokenizer:{name:t,level:`block`,start(e){let t=RegExp(`^:::${l}`,`m`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),o=e.match(a);if(!o)return;let[c,u=``]=o,d=i(u),f=1,p=c.length,m=``,h=/^:::([\w-]*)(\s.*)?/gm,g=e.slice(p);for(h.lastIndex=0;;){let n=h.exec(g);if(n===null)break;let i=n.index,a=n[1];if(!n[2]?.endsWith(`:::`)){if(a)f+=1;else if(--f,f===0){let a=g.slice(0,i);m=a.trim();let o=e.slice(0,p+i+n[0].length),c=[];if(m)if(s===`block`)for(c=r.blockTokens(a),c.forEach(e=>{e.text&&(!e.tokens||e.tokens.length===0)&&(e.tokens=r.inlineTokens(e.text))});c.length>0;){let e=c[c.length-1];if(e.type===`paragraph`&&(!e.text||e.text.trim()===``))c.pop();else break}else c=r.inlineTokens(m);return{type:t,raw:o,attributes:d,content:m,tokens:c}}}}}},renderMarkdown:(e,t)=>{let n=a(u(e.attrs||{}));return`:::${l}${n?` {${n}}`:``} ${t.renderChildren(e.content||[],` `)} -:::`}}}function sIe(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i]=a||o,r=n.exec(e)}return t}function cIe(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function lIe(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=sIe,serializeAttributes:a=cIe,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=a(u(e.attrs||{})),i=n?` ${n}`:``;return s?`[${l}${i}]`:`[${l}${i}]${t}[/${l}]`}}}function UQ(e,t,n){let r=e.split(` +:::`}}}function oIe(e){if(!e.trim())return{};let t={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g,r=n.exec(e);for(;r!==null;){let[,i,a,o]=r;t[i]=a||o,r=n.exec(e)}return t}function sIe(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function cIe(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=oIe,serializeAttributes:a=sIe,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=a(u(e.attrs||{})),i=n?` ${n}`:``;return s?`[${l}${i}]`:`[${l}${i}]${t}[/${l}]`}}}function WQ(e,t,n){let r=e.split(` `),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e} `;continue}else return}let l=t.extractItemData(c),{indentLevel:u,mainContent:d}=l;a=`${a}${e} `;let f=[d];for(o+=1;oe.trim()!==``);if(t===-1)break;if((r[o+1+t].match(/^(\s*)/)?.[1]?.length||0)>u){f.push(e),a=`${a}${e} `,o+=1;continue}else break}if((e.match(/^(\s*)/)?.[1]?.length||0)>u)f.push(e),a=`${a}${e} `,o+=1;else break}let p,m=f.slice(1);if(m.length>0){let e=m.map(e=>e.slice(u+s)).join(` -`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function WQ(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=[`${i}${t.renderChildren([a])}`];return o&&o.length>0&&o.forEach(e=>{let n=t.renderChildren([e]);if(n){let e=n.split(` +`);e.trim()&&(p=t.customNestedParser?t.customNestedParser(e):n.blockTokens(e))}let h=t.createToken(l,p);i.push(h)}if(i.length!==0)return{items:i,raw:a}}function GQ(e,t,n,r){if(!e||!Array.isArray(e.content))return``;let i=typeof n==`function`?n(r):n,[a,...o]=e.content,s=[`${i}${t.renderChildren([a])}`];return o&&o.length>0&&o.forEach(e=>{let n=t.renderChildren([e]);if(n){let e=n.split(` `).map(e=>e?t.indent(e):``).join(` `);s.push(e)}}),s.join(` -`)}function uIe(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var GQ=class e extends xQ{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function KQ(e){return new qFe({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=GZ(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let r=c.search(/\S/),i=n.from+c.indexOf(s),u=i+s.length;if(aQ(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;un.from&&o.delete(n.from+r,i),l=n.from+r+s.length,o.addMark(n.from+r,l,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:dIe,getOwnPropertySymbols:fIe}=Object,{hasOwnProperty:pIe}=Object.prototype;function qQ(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function JQ(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function mIe(e){return e?.[Symbol.toStringTag]}function YQ(e){return dIe(e).concat(fIe(e))}var hIe=Object.hasOwn||((e,t)=>pIe.call(e,t));function XQ(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var gIe=`__v`,_Ie=`__o`,vIe=`_owner`,{getOwnPropertyDescriptor:ZQ,keys:QQ}=Object;function yIe(e,t){return e.byteLength===t.byteLength&&n$(new Uint8Array(e),new Uint8Array(t))}function bIe(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function xIe(e,t){return e.byteLength===t.byteLength&&n$(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function SIe(e,t){return XQ(e.getTime(),t.getTime())}function CIe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function wIe(e,t){return e===t}function $Q(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var TIe=XQ;function EIe(e,t,n){let r=QQ(e),i=r.length;if(QQ(t).length!==i)return!1;for(;i-- >0;)if(!r$(e,t,n,r[i]))return!1;return!0}function e$(e,t,n){let r=YQ(e),i=r.length;if(YQ(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!r$(e,t,n,a)||(o=ZQ(e,a),s=ZQ(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function DIe(e,t){return XQ(e.valueOf(),t.valueOf())}function OIe(e,t){return e.source===t.source&&e.flags===t.flags}function t$(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function n$(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function kIe(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function r$(e,t,n,r){return(r===vIe||r===_Ie||r===gIe)&&(e.$$typeof||t.$$typeof)?!0:hIe(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var AIe=`[object ArrayBuffer]`,jIe=`[object Arguments]`,MIe=`[object Boolean]`,NIe=`[object DataView]`,PIe=`[object Date]`,FIe=`[object Error]`,IIe=`[object Map]`,LIe=`[object Number]`,RIe=`[object Object]`,zIe=`[object RegExp]`,BIe=`[object Set]`,VIe=`[object String]`,HIe={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},UIe=`[object URL]`,WIe=Object.prototype.toString;function GIe({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=WIe.call(h);if(b===PIe)return r(h,g,_);if(b===zIe)return u(h,g,_);if(b===IIe)return o(h,g,_);if(b===BIe)return d(h,g,_);if(b===RIe)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===UIe)return p(h,g,_);if(b===FIe)return i(h,g,_);if(b===jIe)return c(h,g,_);if(HIe[b])return f(h,g,_);if(b===AIe)return e(h,g,_);if(b===NIe)return n(h,g,_);if(b===MIe||b===LIe||b===VIe)return l(h,g,_);if(m){let e=m[b];if(!e){let t=mIe(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function KIe({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:yIe,areArraysEqual:n?e$:bIe,areDataViewsEqual:xIe,areDatesEqual:SIe,areErrorsEqual:CIe,areFunctionsEqual:wIe,areMapsEqual:n?qQ($Q,e$):$Q,areNumbersEqual:TIe,areObjectsEqual:n?e$:EIe,arePrimitiveWrappersEqual:DIe,areRegExpsEqual:OIe,areSetsEqual:n?qQ(t$,e$):t$,areTypedArraysEqual:n?qQ(n$,e$):n$,areUrlsEqual:kIe,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=JQ(r.areArraysEqual),t=JQ(r.areMapsEqual),n=JQ(r.areObjectsEqual),i=JQ(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function qIe(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function JIe({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var YIe=i$();i$({strict:!0}),i$({circular:!0}),i$({circular:!0,strict:!0}),i$({createInternalComparator:()=>XQ}),i$({strict:!0,createInternalComparator:()=>XQ}),i$({circular:!0,createInternalComparator:()=>XQ}),i$({circular:!0,createInternalComparator:()=>XQ,strict:!0});function i$(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=GIe(KIe(e));return JIe({circular:t,comparator:a,createState:r,equals:n?n(a):qIe(a),strict:i})}var XIe=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},ZIe=({contentComponent:e})=>{let t=(0,Ze.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function QIe(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Op.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var $Ie=class extends y.Component{constructor(e){super(e),this.editorContentRef=y.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!e.editor?.contentComponent}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=QIe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){let e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:XIe(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(ZIe,{contentComponent:e.contentComponent})]})}},eLe=(0,y.forwardRef)((e,t)=>{let n=y.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return y.createElement($Ie,{key:n,innerRef:t,...e})}),a$=y.memo(eLe),tLe=typeof window<`u`?y.useLayoutEffect:y.useEffect,nLe=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function rLe(e){let[t]=(0,y.useState)(()=>new nLe(e.editor)),n=(0,fD.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??YIe);return tLe(()=>t.watch(e.editor),[e.editor,t]),(0,y.useDebugValue)(n),n}var o$=!1,s$=typeof window>`u`,iLe=s$||!!(typeof window<`u`&&window.next),aLe=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(s$||iLe){if(o$)throw Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&s$&&o$)throw Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){return new tIe({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length?e.extensions.every((e,n)=>e===t.extensions?.[n]):!1:e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function oLe(e={},t=[]){let n=(0,y.useRef)(e);n.current=e;let[r]=(0,y.useState)(()=>new aLe(n)),i=(0,Ze.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,y.useDebugValue)(i),(0,y.useEffect)(r.onRender(t)),rLe({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var c$=(0,y.createContext)({editor:null});c$.Consumer;var sLe=(0,y.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),cLe=()=>(0,y.useContext)(sLe);y.forwardRef((e,t)=>{let{onDragStart:n}=cLe();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),y.createContext({markViewContentRef:()=>{}});var l$=(0,y.createContext)({get editor(){throw Error(`useTiptap must be used within a provider`)}});l$.displayName=`TiptapContext`;var lLe=()=>(0,y.useContext)(l$);function u$({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,y.useMemo)(()=>({editor:r}),[r]),a=(0,y.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(c$.Provider,{value:a,children:(0,K.jsx)(l$.Provider,{value:i,children:n})})}u$.displayName=`Tiptap`;function d$({...e}){let{editor:t}=lLe();return(0,K.jsx)(a$,{editor:t,...e})}d$.displayName=`Tiptap.Content`,Object.assign(u$,{Content:d$});var f$=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},uLe=/^\s*>\s$/,dLe=GQ.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return f$(`blockquote`,{...JZ(this.options.HTMLAttributes,e),children:f$(`slot`,{})})},parseMarkdown:(e,t)=>t.createNode(`blockquote`,void 0,t.parseChildren(e.tokens||[])),renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach(e=>{let r=t.renderChildren([e]).split(` +`)}function lIe(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var KQ=class e extends SQ{constructor(){super(...arguments),this.type=`node`}static create(t={}){return new e(typeof t==`function`?t():t)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function qQ(e){return new KFe({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=KZ(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let r=c.search(/\S/),i=n.from+c.indexOf(s),u=i+s.length;if(oQ(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>i).length)return null;un.from&&o.delete(n.from+r,i),l=n.from+r+s.length,o.addMark(n.from+r,l,e.type.create(a||{})),o.removeStoredMark(e.type)}}})}var{getOwnPropertyNames:uIe,getOwnPropertySymbols:dIe}=Object,{hasOwnProperty:fIe}=Object.prototype;function JQ(e,t){return function(n,r,i){return e(n,r,i)&&t(n,r,i)}}function YQ(e){return function(t,n,r){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r);let{cache:i}=r,a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);let s=e(t,n,r);return i.delete(t),i.delete(n),s}}function pIe(e){return e?.[Symbol.toStringTag]}function XQ(e){return uIe(e).concat(dIe(e))}var mIe=Object.hasOwn||((e,t)=>fIe.call(e,t));function ZQ(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var hIe=`__v`,gIe=`__o`,_Ie=`_owner`,{getOwnPropertyDescriptor:QQ,keys:$Q}=Object;function vIe(e,t){return e.byteLength===t.byteLength&&r$(new Uint8Array(e),new Uint8Array(t))}function yIe(e,t,n){let r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(!n.equals(e[r],t[r],r,r,e,t,n))return!1;return!0}function bIe(e,t){return e.byteLength===t.byteLength&&r$(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function xIe(e,t){return ZQ(e.getTime(),t.getTime())}function SIe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function CIe(e,t){return e===t}function e$(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.entries(),o,s,c=0;for(;(o=a.next())&&!o.done;){let r=t.entries(),a=!1,l=0;for(;(s=r.next())&&!s.done;){if(i[l]){l++;continue}let r=o.value,u=s.value;if(n.equals(r[0],u[0],c,l,e,t,n)&&n.equals(r[1],u[1],r[0],u[0],e,t,n)){a=i[l]=!0;break}l++}if(!a)return!1;c++}return!0}var wIe=ZQ;function TIe(e,t,n){let r=$Q(e),i=r.length;if($Q(t).length!==i)return!1;for(;i-- >0;)if(!i$(e,t,n,r[i]))return!1;return!0}function t$(e,t,n){let r=XQ(e),i=r.length;if(XQ(t).length!==i)return!1;let a,o,s;for(;i-- >0;)if(a=r[i],!i$(e,t,n,a)||(o=QQ(e,a),s=QQ(t,a),(o||s)&&(!o||!s||o.configurable!==s.configurable||o.enumerable!==s.enumerable||o.writable!==s.writable)))return!1;return!0}function EIe(e,t){return ZQ(e.valueOf(),t.valueOf())}function DIe(e,t){return e.source===t.source&&e.flags===t.flags}function n$(e,t,n){let r=e.size;if(r!==t.size)return!1;if(!r)return!0;let i=Array(r),a=e.values(),o,s;for(;(o=a.next())&&!o.done;){let r=t.values(),a=!1,c=0;for(;(s=r.next())&&!s.done;){if(!i[c]&&n.equals(o.value,s.value,o.value,s.value,e,t,n)){a=i[c]=!0;break}c++}if(!a)return!1}return!0}function r$(e,t){let n=e.byteLength;if(t.byteLength!==n||e.byteOffset!==t.byteOffset)return!1;for(;n-- >0;)if(e[n]!==t[n])return!1;return!0}function OIe(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function i$(e,t,n,r){return(r===_Ie||r===gIe||r===hIe)&&(e.$$typeof||t.$$typeof)?!0:mIe(t,r)&&n.equals(e[r],t[r],r,r,e,t,n)}var kIe=`[object ArrayBuffer]`,AIe=`[object Arguments]`,jIe=`[object Boolean]`,MIe=`[object DataView]`,NIe=`[object Date]`,PIe=`[object Error]`,FIe=`[object Map]`,IIe=`[object Number]`,LIe=`[object Object]`,RIe=`[object RegExp]`,zIe=`[object Set]`,BIe=`[object String]`,VIe={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},HIe=`[object URL]`,UIe=Object.prototype.toString;function WIe({areArrayBuffersEqual:e,areArraysEqual:t,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:s,areObjectsEqual:c,arePrimitiveWrappersEqual:l,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:p,unknownTagComparators:m}){return function(h,g,_){if(h===g)return!0;if(h==null||g==null)return!1;let v=typeof h;if(v!==typeof g)return!1;if(v!==`object`)return v===`number`?s(h,g,_):v===`function`?a(h,g,_):!1;let y=h.constructor;if(y!==g.constructor)return!1;if(y===Object)return c(h,g,_);if(Array.isArray(h))return t(h,g,_);if(y===Date)return r(h,g,_);if(y===RegExp)return u(h,g,_);if(y===Map)return o(h,g,_);if(y===Set)return d(h,g,_);let b=UIe.call(h);if(b===NIe)return r(h,g,_);if(b===RIe)return u(h,g,_);if(b===FIe)return o(h,g,_);if(b===zIe)return d(h,g,_);if(b===LIe)return typeof h.then!=`function`&&typeof g.then!=`function`&&c(h,g,_);if(b===HIe)return p(h,g,_);if(b===PIe)return i(h,g,_);if(b===AIe)return c(h,g,_);if(VIe[b])return f(h,g,_);if(b===kIe)return e(h,g,_);if(b===MIe)return n(h,g,_);if(b===jIe||b===IIe||b===BIe)return l(h,g,_);if(m){let e=m[b];if(!e){let t=pIe(h);t&&(e=m[t])}if(e)return e(h,g,_)}return!1}}function GIe({circular:e,createCustomConfig:t,strict:n}){let r={areArrayBuffersEqual:vIe,areArraysEqual:n?t$:yIe,areDataViewsEqual:bIe,areDatesEqual:xIe,areErrorsEqual:SIe,areFunctionsEqual:CIe,areMapsEqual:n?JQ(e$,t$):e$,areNumbersEqual:wIe,areObjectsEqual:n?t$:TIe,arePrimitiveWrappersEqual:EIe,areRegExpsEqual:DIe,areSetsEqual:n?JQ(n$,t$):n$,areTypedArraysEqual:n?JQ(r$,t$):r$,areUrlsEqual:OIe,unknownTagComparators:void 0};if(t&&(r=Object.assign({},r,t(r))),e){let e=YQ(r.areArraysEqual),t=YQ(r.areMapsEqual),n=YQ(r.areObjectsEqual),i=YQ(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:e,areMapsEqual:t,areObjectsEqual:n,areSetsEqual:i})}return r}function KIe(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function qIe({circular:e,comparator:t,createState:n,equals:r,strict:i}){if(n)return function(a,o){let{cache:s=e?new WeakMap:void 0,meta:c}=n();return t(a,o,{cache:s,equals:r,meta:c,strict:i})};if(e)return function(e,n){return t(e,n,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};let a={cache:void 0,equals:r,meta:void 0,strict:i};return function(e,n){return t(e,n,a)}}var JIe=a$();a$({strict:!0}),a$({circular:!0}),a$({circular:!0,strict:!0}),a$({createInternalComparator:()=>ZQ}),a$({strict:!0,createInternalComparator:()=>ZQ}),a$({circular:!0,createInternalComparator:()=>ZQ}),a$({circular:!0,createInternalComparator:()=>ZQ,strict:!0});function a$(e={}){let{circular:t=!1,createInternalComparator:n,createState:r,strict:i=!1}=e,a=WIe(GIe(e));return qIe({circular:t,comparator:a,createState:r,equals:n?n(a):KIe(a),strict:i})}var YIe=(...e)=>t=>{e.forEach(e=>{typeof e==`function`?e(t):e&&(e.current=t)})},XIe=({contentComponent:e})=>{let t=(0,Ze.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getServerSnapshot);return(0,K.jsx)(K.Fragment,{children:Object.values(t)})};function ZIe(){let e=new Set,t={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return t},getServerSnapshot(){return t},setRenderer(n,r){t={...t,[n]:Op.createPortal(r.reactElement,r.element,n)},e.forEach(e=>e())},removeRenderer(n){let r={...t};delete r[n],t=r,e.forEach(e=>e())}}}var QIe=class extends y.Component{constructor(e){super(e),this.editorContentRef=y.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!e.editor?.contentComponent}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.view.dom?.parentNode){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t}),e.contentComponent=ZIe(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){let e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!e.view.dom?.parentNode)return;let t=document.createElement(`div`);t.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:t})}catch{}}}render(){let{editor:e,innerRef:t,...n}=this.props;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{ref:YIe(t,this.editorContentRef),...n}),e?.contentComponent&&(0,K.jsx)(XIe,{contentComponent:e.contentComponent})]})}},$Ie=(0,y.forwardRef)((e,t)=>{let n=y.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[e.editor]);return y.createElement(QIe,{key:n,innerRef:t,...e})}),o$=y.memo($Ie),eLe=typeof window<`u`?y.useLayoutEffect:y.useEffect,tLe=class{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on(`transaction`,e),()=>{t.off(`transaction`,e)}}}};function nLe(e){let[t]=(0,y.useState)(()=>new tLe(e.editor)),n=(0,pD.useSyncExternalStoreWithSelector)(t.subscribe,t.getSnapshot,t.getServerSnapshot,e.selector,e.equalityFn??JIe);return eLe(()=>t.watch(e.editor),[e.editor,t]),(0,y.useDebugValue)(n),n}var s$=!1,c$=typeof window>`u`,rLe=c$||!!(typeof window<`u`&&window.next),iLe=class e{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId=``,this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(c$||rLe){if(s$)throw Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&c$&&s$)throw Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){return new eIe({...this.options.current,onBeforeCreate:(...e)=>{var t;return(t=this.options.current).onBeforeCreate?.call(t,...e)},onBlur:(...e)=>{var t;return(t=this.options.current).onBlur?.call(t,...e)},onCreate:(...e)=>{var t;return(t=this.options.current).onCreate?.call(t,...e)},onDestroy:(...e)=>{var t;return(t=this.options.current).onDestroy?.call(t,...e)},onFocus:(...e)=>{var t;return(t=this.options.current).onFocus?.call(t,...e)},onSelectionUpdate:(...e)=>{var t;return(t=this.options.current).onSelectionUpdate?.call(t,...e)},onTransaction:(...e)=>{var t;return(t=this.options.current).onTransaction?.call(t,...e)},onUpdate:(...e)=>{var t;return(t=this.options.current).onUpdate?.call(t,...e)},onContentError:(...e)=>{var t;return(t=this.options.current).onContentError?.call(t,...e)},onDrop:(...e)=>{var t;return(t=this.options.current).onDrop?.call(t,...e)},onPaste:(...e)=>{var t;return(t=this.options.current).onPaste?.call(t,...e)},onDelete:(...e)=>{var t;return(t=this.options.current).onDelete?.call(t,...e)}})}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>[`onCreate`,`onBeforeCreate`,`onDestroy`,`onUpdate`,`onTransaction`,`onFocus`,`onBlur`,`onSelectionUpdate`,`onContentError`,`onDrop`,`onPaste`].includes(n)?!0:n===`extensions`&&e.extensions&&t.extensions?e.extensions.length===t.extensions.length?e.extensions.every((e,n)=>e===t.extensions?.[n]):!1:e[n]===t[n])}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&t.length===0?e.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function aLe(e={},t=[]){let n=(0,y.useRef)(e);n.current=e;let[r]=(0,y.useState)(()=>new iLe(n)),i=(0,Ze.useSyncExternalStore)(r.subscribe,r.getEditor,r.getServerSnapshot);return(0,y.useDebugValue)(i),(0,y.useEffect)(r.onRender(t)),nLe({editor:i,selector:({transactionNumber:t})=>e.shouldRerenderOnTransaction===!1||e.shouldRerenderOnTransaction===void 0?null:e.immediatelyRender&&t===0?0:t+1}),i}var l$=(0,y.createContext)({editor:null});l$.Consumer;var oLe=(0,y.createContext)({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),sLe=()=>(0,y.useContext)(oLe);y.forwardRef((e,t)=>{let{onDragStart:n}=sLe();return(0,K.jsx)(e.as||`div`,{...e,ref:t,"data-node-view-wrapper":``,onDragStart:n,style:{whiteSpace:`normal`,...e.style}})}),y.createContext({markViewContentRef:()=>{}});var u$=(0,y.createContext)({get editor(){throw Error(`useTiptap must be used within a provider`)}});u$.displayName=`TiptapContext`;var cLe=()=>(0,y.useContext)(u$);function d$({editor:e,instance:t,children:n}){let r=e??t;if(!r)throw Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");let i=(0,y.useMemo)(()=>({editor:r}),[r]),a=(0,y.useMemo)(()=>({editor:r}),[r]);return(0,K.jsx)(l$.Provider,{value:a,children:(0,K.jsx)(u$.Provider,{value:i,children:n})})}d$.displayName=`Tiptap`;function f$({...e}){let{editor:t}=cLe();return(0,K.jsx)(o$,{editor:t,...e})}f$.displayName=`Tiptap.Content`,Object.assign(d$,{Content:f$});var p$=(e,t)=>{if(e===`slot`)return 0;if(e instanceof Function)return e(t);let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);return[e,r,n]},lLe=/^\s*>\s$/,uLe=KQ.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return p$(`blockquote`,{...YZ(this.options.HTMLAttributes,e),children:p$(`slot`,{})})},parseMarkdown:(e,t)=>t.createNode(`blockquote`,void 0,t.parseChildren(e.tokens||[])),renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach(e=>{let r=t.renderChildren([e]).split(` `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(r.join(` `))}),n.join(` > -`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[BQ({find:uLe,type:this.type})]}}),fLe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,pLe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,mLe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,hLe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gLe=SQ.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return f$(`strong`,{...JZ(this.options.HTMLAttributes,e),children:f$(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[LQ({find:fLe,type:this.type}),LQ({find:mLe,type:this.type})]},addPasteRules(){return[KQ({find:pLe,type:this.type}),KQ({find:hLe,type:this.type})]}}),_Le=/(^|[^`])`([^`]+)`(?!`)$/,vLe=/(^|[^`])`([^`]+)`(?!`)/g,yLe=SQ.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,JZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[LQ({find:_Le,type:this.type})]},addPasteRules(){return[KQ({find:vLe,type:this.type})]}}),p$=4,bLe=/^```([a-z]+)?[\s\n]$/,xLe=/^~~~([a-z]+)?[\s\n]$/,SLe=GQ.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:p$,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,JZ(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` +`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[VQ({find:lLe,type:this.type})]}}),dLe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,fLe=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,pLe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mLe=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,hLe=CQ.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return p$(`strong`,{...YZ(this.options.HTMLAttributes,e),children:p$(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[RQ({find:dLe,type:this.type}),RQ({find:pLe,type:this.type})]},addPasteRules(){return[qQ({find:fLe,type:this.type}),qQ({find:mLe,type:this.type})]}}),gLe=/(^|[^`])`([^`]+)`(?!`)$/,_Le=/(^|[^`])`([^`]+)`(?!`)/g,vLe=CQ.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,YZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t)=>e.content?`\`${t.renderChildren(e.content)}\``:``,addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[RQ({find:gLe,type:this.type})]},addPasteRules(){return[qQ({find:_Le,type:this.type})]}}),m$=4,yLe=/^```([a-z]+)?[\s\n]$/,bLe=/^~~~([a-z]+)?[\s\n]$/,xLe=KQ.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:m$,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,YZ(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` `):`\`\`\`${r} -\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??p$,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` +\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??m$,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` `,` `).split(` `).map(e=>o+e).join(` -`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??p$,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` +`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??m$,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` `,` `).split(` -`),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` +`),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` `,` `).split(` `).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(` `);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(Mq.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[zQ({find:bLe,type:this.type,getAttributes:e=>({language:e[1]})}),zQ({find:xLe,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Jq({key:new Zq(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` -`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Fq.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),CLe=GQ.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(Nq.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[BQ({find:yLe,type:this.type,getAttributes:e=>({language:e[1]})}),BQ({find:bLe,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new Yq({key:new Qq(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` +`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(Iq.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),SLe=KQ.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``}),wLe=GQ.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,JZ(this.options.HTMLAttributes,e)]},renderText(){return` +`):``}),CLe=KQ.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,YZ(this.options.HTMLAttributes,e)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),TLe=GQ.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,JZ(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>zQ({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),ELe=GQ.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,JZ(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!iIe(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return fQ(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Fq.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Lq.create(t.doc,n.pos)):t.setSelection(Fq.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(Fq.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[RQ({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),DLe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,OLe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,kLe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ALe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,jLe=SQ.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,JZ(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[LQ({find:DLe,type:this.type}),LQ({find:kLe,type:this.type})]},addPasteRules(){return[KQ({find:OLe,type:this.type}),KQ({find:ALe,type:this.type})]}}),MLe=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,NLe=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,m$=`numeric`,h$=`ascii`,g$=`alpha`,_$=`asciinumeric`,v$=`alphanumeric`,y$=`domain`,b$=`emoji`,PLe=`scheme`,FLe=`slashscheme`,x$=`whitespace`;function ILe(e,t){return e in t||(t[e]=[]),t[e]}function S$(e,t,n){t[m$]&&(t[_$]=!0,t[v$]=!0),t[h$]&&(t[_$]=!0,t[g$]=!0),t[_$]&&(t[v$]=!0),t[g$]&&(t[v$]=!0),t[v$]&&(t[y$]=!0),t[b$]&&(t[y$]=!0);for(let r in t){let t=ILe(r,n);t.indexOf(e)<0&&t.push(e)}}function LLe(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function C$(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}C$.groups={},C$.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),T$=(e,t,n,r,i)=>e.tr(t,n,r,i),E$=(e,t,n,r,i)=>e.ts(t,n,r,i),D$=(e,t,n,r,i)=>e.tt(t,n,r,i),O$=`WORD`,k$=`UWORD`,A$=`ASCIINUMERICAL`,j$=`ALPHANUMERICAL`,M$=`LOCALHOST`,N$=`TLD`,P$=`UTLD`,F$=`SCHEME`,I$=`SLASH_SCHEME`,L$=`NUM`,R$=`WS`,z$=`NL`,B$=`OPENBRACE`,V$=`CLOSEBRACE`,H$=`OPENBRACKET`,U$=`CLOSEBRACKET`,W$=`OPENPAREN`,G$=`CLOSEPAREN`,K$=`OPENANGLEBRACKET`,q$=`CLOSEANGLEBRACKET`,J$=`FULLWIDTHLEFTPAREN`,Y$=`FULLWIDTHRIGHTPAREN`,X$=`LEFTCORNERBRACKET`,Z$=`RIGHTCORNERBRACKET`,Q$=`LEFTWHITECORNERBRACKET`,$$=`RIGHTWHITECORNERBRACKET`,e1=`FULLWIDTHLESSTHAN`,t1=`FULLWIDTHGREATERTHAN`,n1=`AMPERSAND`,r1=`APOSTROPHE`,i1=`ASTERISK`,a1=`AT`,o1=`BACKSLASH`,s1=`BACKTICK`,c1=`CARET`,l1=`COLON`,u1=`COMMA`,d1=`DOLLAR`,f1=`DOT`,p1=`EQUALS`,m1=`EXCLAMATION`,h1=`HYPHEN`,g1=`PERCENT`,_1=`PIPE`,v1=`PLUS`,y1=`POUND`,b1=`QUERY`,x1=`QUOTE`,S1=`FULLWIDTHMIDDLEDOT`,C1=`SEMI`,w1=`SLASH`,T1=`TILDE`,E1=`UNDERSCORE`,D1=`EMOJI`,O1=`SYM`,k1=Object.freeze({__proto__:null,ALPHANUMERICAL:j$,AMPERSAND:n1,APOSTROPHE:r1,ASCIINUMERICAL:A$,ASTERISK:i1,AT:a1,BACKSLASH:o1,BACKTICK:s1,CARET:c1,CLOSEANGLEBRACKET:q$,CLOSEBRACE:V$,CLOSEBRACKET:U$,CLOSEPAREN:G$,COLON:l1,COMMA:u1,DOLLAR:d1,DOT:f1,EMOJI:D1,EQUALS:p1,EXCLAMATION:m1,FULLWIDTHGREATERTHAN:t1,FULLWIDTHLEFTPAREN:J$,FULLWIDTHLESSTHAN:e1,FULLWIDTHMIDDLEDOT:S1,FULLWIDTHRIGHTPAREN:Y$,HYPHEN:h1,LEFTCORNERBRACKET:X$,LEFTWHITECORNERBRACKET:Q$,LOCALHOST:M$,NL:z$,NUM:L$,OPENANGLEBRACKET:K$,OPENBRACE:B$,OPENBRACKET:H$,OPENPAREN:W$,PERCENT:g1,PIPE:_1,PLUS:v1,POUND:y1,QUERY:b1,QUOTE:x1,RIGHTCORNERBRACKET:Z$,RIGHTWHITECORNERBRACKET:$$,SCHEME:F$,SEMI:C1,SLASH:w1,SLASH_SCHEME:I$,SYM:O1,TILDE:T1,TLD:N$,UNDERSCORE:E1,UTLD:P$,UWORD:k$,WORD:O$,WS:R$}),A1=/[a-z]/,j1=/\p{L}/u,M1=/\p{Emoji}/u,N1=/\d/,P1=/\s/,F1=`\r`,I1=` -`,RLe=`️`,zLe=`‍`,L1=``,R1=null,z1=null;function BLe(e=[]){let t={};C$.groups=t;let n=new C$;R1??=H1(MLe),z1??=H1(NLe),D$(n,`'`,r1),D$(n,`{`,B$),D$(n,`}`,V$),D$(n,`[`,H$),D$(n,`]`,U$),D$(n,`(`,W$),D$(n,`)`,G$),D$(n,`<`,K$),D$(n,`>`,q$),D$(n,`(`,J$),D$(n,`)`,Y$),D$(n,`「`,X$),D$(n,`」`,Z$),D$(n,`『`,Q$),D$(n,`』`,$$),D$(n,`<`,e1),D$(n,`>`,t1),D$(n,`&`,n1),D$(n,`*`,i1),D$(n,`@`,a1),D$(n,"`",s1),D$(n,`^`,c1),D$(n,`:`,l1),D$(n,`,`,u1),D$(n,`$`,d1),D$(n,`.`,f1),D$(n,`=`,p1),D$(n,`!`,m1),D$(n,`-`,h1),D$(n,`%`,g1),D$(n,`|`,_1),D$(n,`+`,v1),D$(n,`#`,y1),D$(n,`?`,b1),D$(n,`"`,x1),D$(n,`/`,w1),D$(n,`;`,C1),D$(n,`~`,T1),D$(n,`_`,E1),D$(n,`\\`,o1),D$(n,`・`,S1);let r=T$(n,N1,L$,{[m$]:!0});T$(r,N1,r);let i=T$(r,A1,A$,{[_$]:!0}),a=T$(r,j1,j$,{[v$]:!0}),o=T$(n,A1,O$,{[h$]:!0});T$(o,N1,i),T$(o,A1,o),T$(i,N1,i),T$(i,A1,i);let s=T$(n,j1,k$,{[g$]:!0});T$(s,A1),T$(s,N1,a),T$(s,j1,s),T$(a,N1,a),T$(a,A1),T$(a,j1,a);let c=D$(n,I1,z$,{[x$]:!0}),l=D$(n,F1,R$,{[x$]:!0}),u=T$(n,P1,R$,{[x$]:!0});D$(n,L1,u),D$(l,I1,c),D$(l,L1,u),T$(l,P1,u),D$(u,F1),D$(u,I1),T$(u,P1,u),D$(u,L1,u);let d=T$(n,M1,D1,{[b$]:!0});D$(d,`#`),T$(d,M1,d),D$(d,RLe,d);let f=D$(d,zLe);D$(f,`#`),T$(f,M1,d);let p=[[A1,o],[N1,i]],m=[[A1,null],[j1,s],[N1,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[y$]=!0:A1.test(r)?N1.test(r)?i[_$]=!0:i[h$]=!0:i[m$]=!0,E$(n,r,r,i)}return E$(n,`localhost`,M$,{ascii:!0}),n.jd=new C$(O1),{start:n,tokens:Object.assign({groups:t},k1)}}function B1(e,t){let n=VLe(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function VLe(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function V1(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var U1={defaultProtocol:`http`,events:null,format:G1,formatHref:G1,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function W1(e,t=null){let n=Object.assign({},U1);e&&(n=Object.assign(n,e instanceof W1?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;en?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=U1.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function q1(e,t){class n extends K1{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var J1=q1(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Y1=q1(`text`),HLe=q1(`nl`),X1=q1(`url`,{isLink:!0,toHref(e=U1.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==M$&&e[1].t===l1}}),Z1=e=>new C$(e);function ULe({groups:e}){let t=e.domain.concat([n1,i1,a1,o1,s1,c1,d1,p1,h1,L$,g1,_1,v1,y1,w1,O1,T1,E1]),n=[r1,l1,u1,f1,m1,g1,b1,x1,C1,K$,q$,B$,V$,U$,H$,W$,G$,J$,Y$,X$,Z$,Q$,$$,e1,t1],r=[n1,r1,i1,o1,s1,c1,d1,p1,h1,B$,V$,g1,_1,v1,y1,b1,w1,O1,T1,E1],i=Z1(),a=D$(i,T1);w$(a,r,a),w$(a,e.domain,a);let o=Z1(),s=Z1(),c=Z1();w$(i,e.domain,o),w$(i,e.scheme,s),w$(i,e.slashscheme,c),w$(o,r,a),w$(o,e.domain,o);let l=D$(o,a1);D$(a,a1,l),D$(s,a1,l),D$(c,a1,l);let u=D$(a,f1);w$(u,r,a),w$(u,e.domain,a);let d=Z1();w$(l,e.domain,d),w$(d,e.domain,d);let f=D$(d,f1);w$(f,e.domain,d);let p=Z1(J1);w$(f,e.tld,p),w$(f,e.utld,p),D$(l,M$,p);let m=D$(d,h1);D$(m,h1,m),w$(m,e.domain,d),w$(p,e.domain,d),D$(p,f1,f),D$(p,h1,m),w$(D$(p,l1),e.numeric,J1);let h=D$(o,h1),g=D$(o,f1);D$(h,h1,h),w$(h,e.domain,o),w$(g,r,a),w$(g,e.domain,o);let _=Z1(X1);w$(g,e.tld,_),w$(g,e.utld,_),w$(_,e.domain,o),w$(_,r,a),D$(_,f1,g),D$(_,h1,h),D$(_,a1,l);let v=D$(_,l1),y=Z1(X1);w$(v,e.numeric,y);let b=Z1(X1),x=Z1();w$(b,t,b),w$(b,n,x),w$(x,t,b),w$(x,n,x),D$(_,w1,b),D$(y,w1,b);let S=D$(s,l1),C=D$(D$(D$(c,l1),w1),w1);w$(s,e.domain,o),D$(s,f1,g),D$(s,h1,h),w$(c,e.domain,o),D$(c,f1,g),D$(c,h1,h),w$(S,e.domain,b),D$(S,w1,b),D$(S,b1,b),w$(C,e.domain,b),w$(C,t,b),D$(C,w1,b);let w=[[B$,V$],[H$,U$],[W$,G$],[K$,q$],[J$,Y$],[X$,Z$],[Q$,$$],[e1,t1]];for(let e=0;e=0&&f++,i++,u++;if(f<0)i-=u,i0&&(a.push(Q1(Y1,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Q1(e,t,r))}}return o.length>0&&a.push(Q1(Y1,t,o)),a}function Q1(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var GLe=typeof console<`u`&&console&&console.warn||(()=>{}),KLe=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,$1={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function qLe(){return C$.groups={},$1.scanner=null,$1.parser=null,$1.tokenQueue=[],$1.pluginQueue=[],$1.customSchemes=[],$1.initialized=!1,$1}function e0(e,t=!1){if($1.initialized&&GLe(`linkifyjs: already initialized - will not register custom scheme "${e}" ${KLe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),wLe=KQ.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,YZ(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode(`heading`,{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>BQ({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),TLe=KQ.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,YZ(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!rIe(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pQ(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(Iq.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(Rq.create(t.doc,n.pos)):t.setSelection(Iq.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(Iq.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[zQ({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ELe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,DLe=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,OLe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,kLe=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ALe=CQ.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,YZ(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[RQ({find:ELe,type:this.type}),RQ({find:OLe,type:this.type})]},addPasteRules(){return[qQ({find:DLe,type:this.type}),qQ({find:kLe,type:this.type})]}}),jLe=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,MLe=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,h$=`numeric`,g$=`ascii`,_$=`alpha`,v$=`asciinumeric`,y$=`alphanumeric`,b$=`domain`,x$=`emoji`,NLe=`scheme`,PLe=`slashscheme`,S$=`whitespace`;function FLe(e,t){return e in t||(t[e]=[]),t[e]}function C$(e,t,n){t[h$]&&(t[v$]=!0,t[y$]=!0),t[g$]&&(t[v$]=!0,t[_$]=!0),t[v$]&&(t[y$]=!0),t[_$]&&(t[y$]=!0),t[y$]&&(t[b$]=!0),t[x$]&&(t[b$]=!0);for(let r in t){let t=FLe(r,n);t.indexOf(e)<0&&t.push(e)}}function ILe(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function w$(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}w$.groups={},w$.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),E$=(e,t,n,r,i)=>e.tr(t,n,r,i),D$=(e,t,n,r,i)=>e.ts(t,n,r,i),O$=(e,t,n,r,i)=>e.tt(t,n,r,i),k$=`WORD`,A$=`UWORD`,j$=`ASCIINUMERICAL`,M$=`ALPHANUMERICAL`,N$=`LOCALHOST`,P$=`TLD`,F$=`UTLD`,I$=`SCHEME`,L$=`SLASH_SCHEME`,R$=`NUM`,z$=`WS`,B$=`NL`,V$=`OPENBRACE`,H$=`CLOSEBRACE`,U$=`OPENBRACKET`,W$=`CLOSEBRACKET`,G$=`OPENPAREN`,K$=`CLOSEPAREN`,q$=`OPENANGLEBRACKET`,J$=`CLOSEANGLEBRACKET`,Y$=`FULLWIDTHLEFTPAREN`,X$=`FULLWIDTHRIGHTPAREN`,Z$=`LEFTCORNERBRACKET`,Q$=`RIGHTCORNERBRACKET`,$$=`LEFTWHITECORNERBRACKET`,e1=`RIGHTWHITECORNERBRACKET`,t1=`FULLWIDTHLESSTHAN`,n1=`FULLWIDTHGREATERTHAN`,r1=`AMPERSAND`,i1=`APOSTROPHE`,a1=`ASTERISK`,o1=`AT`,s1=`BACKSLASH`,c1=`BACKTICK`,l1=`CARET`,u1=`COLON`,d1=`COMMA`,f1=`DOLLAR`,p1=`DOT`,m1=`EQUALS`,h1=`EXCLAMATION`,g1=`HYPHEN`,_1=`PERCENT`,v1=`PIPE`,y1=`PLUS`,b1=`POUND`,x1=`QUERY`,S1=`QUOTE`,C1=`FULLWIDTHMIDDLEDOT`,w1=`SEMI`,T1=`SLASH`,E1=`TILDE`,D1=`UNDERSCORE`,O1=`EMOJI`,k1=`SYM`,LLe=Object.freeze({__proto__:null,ALPHANUMERICAL:M$,AMPERSAND:r1,APOSTROPHE:i1,ASCIINUMERICAL:j$,ASTERISK:a1,AT:o1,BACKSLASH:s1,BACKTICK:c1,CARET:l1,CLOSEANGLEBRACKET:J$,CLOSEBRACE:H$,CLOSEBRACKET:W$,CLOSEPAREN:K$,COLON:u1,COMMA:d1,DOLLAR:f1,DOT:p1,EMOJI:O1,EQUALS:m1,EXCLAMATION:h1,FULLWIDTHGREATERTHAN:n1,FULLWIDTHLEFTPAREN:Y$,FULLWIDTHLESSTHAN:t1,FULLWIDTHMIDDLEDOT:C1,FULLWIDTHRIGHTPAREN:X$,HYPHEN:g1,LEFTCORNERBRACKET:Z$,LEFTWHITECORNERBRACKET:$$,LOCALHOST:N$,NL:B$,NUM:R$,OPENANGLEBRACKET:q$,OPENBRACE:V$,OPENBRACKET:U$,OPENPAREN:G$,PERCENT:_1,PIPE:v1,PLUS:y1,POUND:b1,QUERY:x1,QUOTE:S1,RIGHTCORNERBRACKET:Q$,RIGHTWHITECORNERBRACKET:e1,SCHEME:I$,SEMI:w1,SLASH:T1,SLASH_SCHEME:L$,SYM:k1,TILDE:E1,TLD:P$,UNDERSCORE:D1,UTLD:F$,UWORD:A$,WORD:k$,WS:z$}),A1=/[a-z]/,j1=/\p{L}/u,M1=/\p{Emoji}/u,N1=/\d/,P1=/\s/,F1=`\r`,I1=` +`,RLe=`️`,zLe=`‍`,L1=``,R1=null,z1=null;function BLe(e=[]){let t={};w$.groups=t;let n=new w$;R1??=H1(jLe),z1??=H1(MLe),O$(n,`'`,i1),O$(n,`{`,V$),O$(n,`}`,H$),O$(n,`[`,U$),O$(n,`]`,W$),O$(n,`(`,G$),O$(n,`)`,K$),O$(n,`<`,q$),O$(n,`>`,J$),O$(n,`(`,Y$),O$(n,`)`,X$),O$(n,`「`,Z$),O$(n,`」`,Q$),O$(n,`『`,$$),O$(n,`』`,e1),O$(n,`<`,t1),O$(n,`>`,n1),O$(n,`&`,r1),O$(n,`*`,a1),O$(n,`@`,o1),O$(n,"`",c1),O$(n,`^`,l1),O$(n,`:`,u1),O$(n,`,`,d1),O$(n,`$`,f1),O$(n,`.`,p1),O$(n,`=`,m1),O$(n,`!`,h1),O$(n,`-`,g1),O$(n,`%`,_1),O$(n,`|`,v1),O$(n,`+`,y1),O$(n,`#`,b1),O$(n,`?`,x1),O$(n,`"`,S1),O$(n,`/`,T1),O$(n,`;`,w1),O$(n,`~`,E1),O$(n,`_`,D1),O$(n,`\\`,s1),O$(n,`・`,C1);let r=E$(n,N1,R$,{[h$]:!0});E$(r,N1,r);let i=E$(r,A1,j$,{[v$]:!0}),a=E$(r,j1,M$,{[y$]:!0}),o=E$(n,A1,k$,{[g$]:!0});E$(o,N1,i),E$(o,A1,o),E$(i,N1,i),E$(i,A1,i);let s=E$(n,j1,A$,{[_$]:!0});E$(s,A1),E$(s,N1,a),E$(s,j1,s),E$(a,N1,a),E$(a,A1),E$(a,j1,a);let c=O$(n,I1,B$,{[S$]:!0}),l=O$(n,F1,z$,{[S$]:!0}),u=E$(n,P1,z$,{[S$]:!0});O$(n,L1,u),O$(l,I1,c),O$(l,L1,u),E$(l,P1,u),O$(u,F1),O$(u,I1),E$(u,P1,u),O$(u,L1,u);let d=E$(n,M1,O1,{[x$]:!0});O$(d,`#`),E$(d,M1,d),O$(d,RLe,d);let f=O$(d,zLe);O$(f,`#`),E$(f,M1,d);let p=[[A1,o],[N1,i]],m=[[A1,null],[j1,s],[N1,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[b$]=!0:A1.test(r)?N1.test(r)?i[v$]=!0:i[g$]=!0:i[h$]=!0,D$(n,r,r,i)}return D$(n,`localhost`,N$,{ascii:!0}),n.jd=new w$(k1),{start:n,tokens:Object.assign({groups:t},LLe)}}function B1(e,t){let n=VLe(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function VLe(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function V1(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var U1={defaultProtocol:`http`,events:null,format:G1,formatHref:G1,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function W1(e,t=null){let n=Object.assign({},U1);e&&(n=Object.assign(n,e instanceof W1?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;en?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=U1.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function q1(e,t){class n extends K1{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var J1=q1(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Y1=q1(`text`),HLe=q1(`nl`),X1=q1(`url`,{isLink:!0,toHref(e=U1.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==N$&&e[1].t===u1}}),Z1=e=>new w$(e);function ULe({groups:e}){let t=e.domain.concat([r1,a1,o1,s1,c1,l1,f1,m1,g1,R$,_1,v1,y1,b1,T1,k1,E1,D1]),n=[i1,u1,d1,p1,h1,_1,x1,S1,w1,q$,J$,V$,H$,W$,U$,G$,K$,Y$,X$,Z$,Q$,$$,e1,t1,n1],r=[r1,i1,a1,s1,c1,l1,f1,m1,g1,V$,H$,_1,v1,y1,b1,x1,T1,k1,E1,D1],i=Z1(),a=O$(i,E1);T$(a,r,a),T$(a,e.domain,a);let o=Z1(),s=Z1(),c=Z1();T$(i,e.domain,o),T$(i,e.scheme,s),T$(i,e.slashscheme,c),T$(o,r,a),T$(o,e.domain,o);let l=O$(o,o1);O$(a,o1,l),O$(s,o1,l),O$(c,o1,l);let u=O$(a,p1);T$(u,r,a),T$(u,e.domain,a);let d=Z1();T$(l,e.domain,d),T$(d,e.domain,d);let f=O$(d,p1);T$(f,e.domain,d);let p=Z1(J1);T$(f,e.tld,p),T$(f,e.utld,p),O$(l,N$,p);let m=O$(d,g1);O$(m,g1,m),T$(m,e.domain,d),T$(p,e.domain,d),O$(p,p1,f),O$(p,g1,m),T$(O$(p,u1),e.numeric,J1);let h=O$(o,g1),g=O$(o,p1);O$(h,g1,h),T$(h,e.domain,o),T$(g,r,a),T$(g,e.domain,o);let _=Z1(X1);T$(g,e.tld,_),T$(g,e.utld,_),T$(_,e.domain,o),T$(_,r,a),O$(_,p1,g),O$(_,g1,h),O$(_,o1,l);let v=O$(_,u1),y=Z1(X1);T$(v,e.numeric,y);let b=Z1(X1),x=Z1();T$(b,t,b),T$(b,n,x),T$(x,t,b),T$(x,n,x),O$(_,T1,b),O$(y,T1,b);let S=O$(s,u1),C=O$(O$(O$(c,u1),T1),T1);T$(s,e.domain,o),O$(s,p1,g),O$(s,g1,h),T$(c,e.domain,o),O$(c,p1,g),O$(c,g1,h),T$(S,e.domain,b),O$(S,T1,b),O$(S,x1,b),T$(C,e.domain,b),T$(C,t,b),O$(C,T1,b);let w=[[V$,H$],[U$,W$],[G$,K$],[q$,J$],[Y$,X$],[Z$,Q$],[$$,e1],[t1,n1]];for(let e=0;e=0&&f++,i++,u++;if(f<0)i-=u,i0&&(a.push(Q1(Y1,t,o)),o=[]),i-=f,u-=f;let e=d.t,r=n.slice(i-u,i);a.push(Q1(e,t,r))}}return o.length>0&&a.push(Q1(Y1,t,o)),a}function Q1(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var GLe=typeof console<`u`&&console&&console.warn||(()=>{}),KLe=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,$1={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function qLe(){return w$.groups={},$1.scanner=null,$1.parser=null,$1.tokenQueue=[],$1.pluginQueue=[],$1.customSchemes=[],$1.initialized=!1,$1}function e0(e,t=!1){if($1.initialized&&GLe(`linkifyjs: already initialized - will not register custom scheme "${e}" ${KLe}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);$1.customSchemes.push([e,t])}function JLe(){$1.scanner=BLe($1.customSchemes);for(let e=0;e<$1.tokenQueue.length;e++)$1.tokenQueue[e][1]({scanner:$1.scanner});$1.parser=ULe($1.scanner.tokens);for(let e=0;e<$1.pluginQueue.length;e++)$1.pluginQueue[e][1]({scanner:$1.scanner,parser:$1.parser});return $1.initialized=!0,$1}function t0(e){return $1.initialized||JLe(),WLe($1.parser.start,e,B1($1.scanner.start,e))}t0.scan=B1;function n0(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new W1(n),i=t0(e),a=[];for(let e=0;e{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(iQ(zZ(n.doc,[...t])).forEach(({newRange:t})=>{let n=iFe(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!XLe.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(YLe).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=t0(n).map(t=>t.toObject(e.defaultProtocol));if(!QLe(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{aQ(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function eRe(e){return new Jq({key:new Zq(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=rQ(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}function tRe(e){return new Jq({key:new Zq(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=n0(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function i0(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(ZLe,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,`i`))}var a0=SQ.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){e0(e);return}e0(e.scheme,e.optionalSlashes)})},onDestroy(){qLe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!i0(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,JZ(this.options.HTMLAttributes,e),0]:[`a`,JZ(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[KQ({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=n0(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!i0(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push($Le({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!i0(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(eRe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(tRe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),nRe=a0,rRe=Object.defineProperty,iRe=(e,t)=>{for(var n in t)rRe(e,n,{get:t[n],enumerable:!0})},aRe=`listItem`,o0=`textStyle`,s0=/^\s*([-+*])\s$/,c0=GQ.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,JZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(aRe,this.editor.getAttributes(o0)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=BQ({find:s0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=BQ({find:s0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(o0),editor:this.editor})),[e]}}),l0=GQ.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,JZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=[];if(e.tokens&&e.tokens.length>0)if(e.tokens.some(e=>e.type===`paragraph`))n=t.parseChildren(e.tokens);else{let r=e.tokens[0];if(r&&r.type===`text`&&r.tokens&&r.tokens.length>0){if(n=[{type:`paragraph`,content:t.parseInline(r.tokens)}],e.tokens.length>1){let r=e.tokens.slice(1),i=t.parseChildren(r);n.push(...i)}}else n=t.parseChildren(e.tokens)}return n.length===0&&(n=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:n}},renderMarkdown:(e,t,n)=>WQ(e,t,e=>e.parentType===`bulletList`?`- `:e.parentType===`orderedList`?`${(e.meta?.parentAttrs?.start||1)+e.index}. `:`- `,n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});iRe({},{findListItemPos:()=>u0,getNextListDepth:()=>d0,handleBackspace:()=>h0,handleDelete:()=>v0,hasListBefore:()=>f0,hasListItemAfter:()=>oRe,hasListItemBefore:()=>p0,listItemHasSubList:()=>m0,nextListIsDeeper:()=>g0,nextListIsHigher:()=>_0});var u0=(e,t)=>{let{$from:n}=t.selection,r=vZ(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},d0=(e,t)=>{let n=u0(e,t);if(!n)return!1;let[,r]=mFe(t,e,n.$pos.pos+4);return r},f0=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},p0=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return!(r.index()===0||r.nodeBefore?.type.name!==e)},m0=(e,t,n)=>{if(!n)return!1;let r=vZ(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},h0=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!PZ(e.state,t)&&f0(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!PZ(e.state,t)||!vFe(e.state))return!1;let r=u0(t,e.state);if(!r)return!1;let i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=m0(t,e.state,i);return p0(t,e.state)&&!a?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},g0=(e,t)=>{let n=d0(e,t),r=u0(e,t);return!r||!n?!1:n>r.depth},_0=(e,t)=>{let n=d0(e,t),r=u0(e,t);return!r||!n?!1:n{if(!PZ(e.state,t)||!_Fe(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:g0(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():_0(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},oRe=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return!(r.index()===r.parent.childCount-1||r.nodeAfter?.type.name!==e)},y0=TQ.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&v0(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&v0(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&h0(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&h0(e,n,r)&&(t=!0)}),t}}}}),b0=/^(\s*)(\d+)\.\s+(.*)$/,sRe=/^\s/;function cRe(e){let t=[],n=0,r=0;for(;n{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r;if(aQ(BZ(n.doc,[...t])).forEach(({newRange:t})=>{let n=rFe(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!XLe.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(YLe).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=t0(n).map(t=>t.toObject(e.defaultProtocol));if(!QLe(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>r.schema.marks.code?!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code):!0).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{oQ(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function eRe(e){return new Yq({key:new Qq(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=iQ(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}function tRe(e){return new Yq({key:new Qq(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=n0(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function i0(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(ZLe,``).match(RegExp(`^(?:(?:${n.join(`|`)}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,`i`))}var a0=CQ.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{if(typeof e==`string`){e0(e);return}e0(e.scheme,e.optionalSlashes)})},onDestroy(){qLe()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!i0(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,YZ(this.options.HTMLAttributes,e),0]:[`a`,YZ(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!i0(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addPasteRules(){return[qQ({find:e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options,i=n0(e).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!i0(e,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t},type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push($Le({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!i0(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(eRe({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(tRe({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),nRe=a0,rRe=Object.defineProperty,iRe=(e,t)=>{for(var n in t)rRe(e,n,{get:t[n],enumerable:!0})},aRe=`listItem`,o0=`textStyle`,s0=/^\s*([-+*])\s$/,c0=KQ.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,YZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(aRe,this.editor.getAttributes(o0)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=VQ({find:s0,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=VQ({find:s0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(o0),editor:this.editor})),[e]}}),l0=KQ.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,YZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=[];if(e.tokens&&e.tokens.length>0)if(e.tokens.some(e=>e.type===`paragraph`))n=t.parseChildren(e.tokens);else{let r=e.tokens[0];if(r&&r.type===`text`&&r.tokens&&r.tokens.length>0){if(n=[{type:`paragraph`,content:t.parseInline(r.tokens)}],e.tokens.length>1){let r=e.tokens.slice(1),i=t.parseChildren(r);n.push(...i)}}else n=t.parseChildren(e.tokens)}return n.length===0&&(n=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:n}},renderMarkdown:(e,t,n)=>GQ(e,t,e=>e.parentType===`bulletList`?`- `:e.parentType===`orderedList`?`${(e.meta?.parentAttrs?.start||1)+e.index}. `:`- `,n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});iRe({},{findListItemPos:()=>u0,getNextListDepth:()=>d0,handleBackspace:()=>h0,handleDelete:()=>v0,hasListBefore:()=>f0,hasListItemAfter:()=>oRe,hasListItemBefore:()=>p0,listItemHasSubList:()=>m0,nextListIsDeeper:()=>g0,nextListIsHigher:()=>_0});var u0=(e,t)=>{let{$from:n}=t.selection,r=yZ(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},d0=(e,t)=>{let n=u0(e,t);if(!n)return!1;let[,r]=pFe(t,e,n.$pos.pos+4);return r},f0=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},p0=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-2);return!(r.index()===0||r.nodeBefore?.type.name!==e)},m0=(e,t,n)=>{if(!n)return!1;let r=yZ(e,t.schema),i=!1;return n.descendants(e=>{e.type===r&&(i=!0)}),i},h0=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!FZ(e.state,t)&&f0(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().cut({from:n.start()-1,to:n.end()+1},o.end()).joinForward().run()}if(!FZ(e.state,t)||!_Fe(e.state))return!1;let r=u0(t,e.state);if(!r)return!1;let i=e.state.doc.resolve(r.$pos.pos-2).node(r.depth),a=m0(t,e.state,i);return p0(t,e.state)&&!a?e.commands.joinItemBackward():e.chain().liftListItem(t).run()},g0=(e,t)=>{let n=d0(e,t),r=u0(e,t);return!r||!n?!1:n>r.depth},_0=(e,t)=>{let n=d0(e,t),r=u0(e,t);return!r||!n?!1:n{if(!FZ(e.state,t)||!gFe(e.state,t))return!1;let{selection:n}=e.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:g0(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():_0(t,e.state)?e.chain().joinForward().joinBackward().run():e.commands.joinItemForward()},oRe=(e,t)=>{let{$anchor:n}=t.selection,r=t.doc.resolve(n.pos-n.parentOffset-2);return!(r.index()===r.parent.childCount-1||r.nodeAfter?.type.name!==e)},y0=EQ.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&v0(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&v0(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&h0(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&h0(e,n,r)&&(t=!0)}),t}}}}),b0=/^(\s*)(\d+)\.\s+(.*)$/,sRe=/^\s/;function cRe(e){let t=[],n=0,r=0;for(;nt;)d.push(e[u]),u+=1;if(d.length>0){let e=x0(d,Math.min(...d.map(e=>e.indent)),n);c.push({type:`list`,ordered:!0,start:d[0].number,items:e,raw:d.map(e=>e.raw).join(` -`)})}r.push({type:`list_item`,raw:a.raw,tokens:c}),i=u}else i+=1}return r}function lRe(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var uRe=`listItem`,S0=`textStyle`,C0=/^(\d+)\.\s$/,w0=GQ.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,JZ(this.options.HTMLAttributes,n),0]:[`ol`,JZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.items?lRe(e.items,t):[];return n===1?{type:`orderedList`,content:r}:{type:`orderedList`,attrs:{start:n},content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`)})}r.push({type:`list_item`,raw:a.raw,tokens:c}),i=u}else i+=1}return r}function lRe(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var uRe=`listItem`,S0=`textStyle`,C0=/^(\d+)\.\s$/,w0=KQ.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>e.getAttribute(`type`)}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return t===1?[`ol`,YZ(this.options.HTMLAttributes,n),0]:[`ol`,YZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.items?lRe(e.items,t):[];return n===1?{type:`orderedList`,content:r}:{type:`orderedList`,attrs:{start:n},content:r}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(` `),[i,a]=cRe(r);if(i.length===0)return;let o=x0(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uRe,this.editor.getAttributes(S0)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=BQ({find:C0,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=BQ({find:C0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(S0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),dRe=/^\s*(\[([( |x])?\])\s$/,fRe=GQ.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,JZ(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>WQ(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=YZ(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[BQ({find:dRe,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),pRe=GQ.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,JZ(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=UQ(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=UQ(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});TQ.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(c0.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(l0.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(y0.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(w0.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(fRe.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(pRe.configure(this.options.taskList)),e}});var T0=` `,mRe=`\xA0`,hRe=GQ.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,JZ(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return r.length===1&&r[0].type===`text`&&(r[0].text===T0||r[0].text===mRe)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t)=>{if(!e)return``;let n=Array.isArray(e.content)?e.content:[];return n.length===0?T0:t.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),gRe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_Re=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,vRe=SQ.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,JZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[LQ({find:gRe,type:this.type})]},addPasteRules(){return[KQ({find:_Re,type:this.type})]}}),yRe=GQ.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),E0=SQ.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,JZ(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),bRe=E0;function xRe(e={}){return new Jq({view(t){return new SRe(t,e)}})}var SRe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=_q(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},D0=class e extends Mq{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Mq.near(r)}content(){return ZG.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new CRe(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!wRe(e)||!TRe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Lq.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};D0.prototype.visible=!1,D0.findFrom=D0.findGapCursorFrom,Mq.jsonID(`gapcursor`,D0);var CRe=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return D0.valid(t)?new D0(t):Mq.near(t)}};function O0(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function wRe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||O0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function TRe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||O0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function ERe(){return new Jq({props:{decorations:ARe,createSelectionBetween(e,t,n){return t.pos==n.pos&&D0.valid(n)?new D0(n):null},handleClick:ORe,handleKeyDown:DRe,handleDOMEvents:{beforeinput:kRe}}})}var DRe=pZ({ArrowLeft:k0(`horiz`,-1),ArrowRight:k0(`horiz`,1),ArrowUp:k0(`vert`,-1),ArrowDown:k0(`vert`,1)});function k0(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Fq){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=D0.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new D0(c))),!0):!1}}function ORe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!D0.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Lq.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new D0(r))),!0)}function kRe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof D0))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=GG.empty;for(let e=r.length-1;e>=0;e--)i=GG.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new ZG(i,0,0));return a.setSelection(Fq.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function ARe(e){if(!(e.selection instanceof D0))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,zX.create(e.doc,[IX.widget(e.selection.head,t,{key:`gapcursor`})])}var A0=200,j0=function(){};j0.prototype.append=function(e){return e.length?(e=j0.from(e),!this.length&&e||e.length=t?j0.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},j0.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},j0.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},j0.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},j0.from=function(e){return e instanceof j0?e:e&&e.length?new M0(e):j0.empty};var M0=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=A0)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=A0)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(j0);j0.empty=new M0([]);var jRe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(j0),MRe=500,N0=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new P0(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new P0(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;ePRe&&(s=NRe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new YK;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new P0(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new P0(i,o,l))}else r.push(new P0(i))},i);let l=[];for(let e=n;eMRe&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new P0(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(j0.from(i.reverse()),a)}};N0.empty=new N0(j0.empty,0);function NRe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var P0=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},F0=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},PRe=20;function FRe(e,t,n,r){let i=n.getMeta(V0),a;if(i)return i.historyState;n.getMeta(RRe)&&(e=new F0(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(V0))return o.getMeta(V0).redo?new F0(e.done.addTransform(n,void 0,r,B0(t)),e.undone,I0(n.mapping.maps),e.prevTime,e.prevComposition):new F0(e.done,e.undone.addTransform(n,void 0,r,B0(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!IRe(n,e.prevRanges)),s=o?L0(e.prevRanges,n.mapping):I0(n.mapping.maps);return new F0(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,B0(t)),N0.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new F0(e.done.rebased(n,a),e.undone.rebased(n,a),L0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new F0(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),L0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function IRe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function I0(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function L0(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=V0.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=LRe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var U0=H0(!1,!0),W0=H0(!0,!0);TQ.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Jq({key:new Zq(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var BRe=TQ.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[xRe(this.options)]}});TQ.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new Jq({key:new Zq(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return zX.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(IX.node(t,t+e.nodeSize,{class:this.options.className}))}),zX.create(e,a)}}})]}});var VRe=TQ.create({name:`gapCursor`,addProseMirrorPlugins(){return[ERe()]},extendNodeSchema(e){return{allowGapCursor:GZ(VZ(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),G0=`placeholder`;function HRe(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}TQ.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:G0,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${HRe(this.options.dataAttribute)}`:`data-${G0}`;return[new Jq({key:new Zq(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&dQ(t);if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=IX.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),zX.create(t,a)}}})]}}),TQ.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new Jq({key:new Zq(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||fQ(n.selection)||e.view.dragging?null:zX.create(n.doc,[IX.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function K0({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var URe=TQ.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new Zq(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new Jq({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!K0({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!K0({node:r,types:n})}}})]}}),WRe=TQ.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>U0(e,t),redo:()=>({state:e,dispatch:t})=>W0(e,t)}},addProseMirrorPlugins(){return[zRe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),GRe=TQ.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(gLe.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(dLe.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(c0.configure(this.options.bulletList)),this.options.code!==!1&&e.push(yLe.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(SLe.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(CLe.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(BRe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(VRe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(wLe.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(TLe.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(WRe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(ELe.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(jLe.configure(this.options.italic)),this.options.listItem!==!1&&e.push(l0.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(y0.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(a0.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(w0.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(hRe.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(vRe.configure(this.options.strike)),this.options.text!==!1&&e.push(yRe.configure(this.options.text)),this.options.underline!==!1&&e.push(E0.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(URe.configure(this.options?.trailingNode)),e}}),KRe=TQ.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),qRe=20,q0=(e,t=0)=>{let n=[];return!e.children.length||t>qRe||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...q0(e,t+1))}),n},JRe=e=>{if(!e.children.length)return;let t=q0(e);t&&t.forEach(e=>{let t=e.getAttribute(`style`),n=(e.parentElement?.closest(`span`))?.getAttribute(`style`);e.setAttribute(`style`,`${n};${t}`)})},J0=SQ.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&JRe(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,JZ(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(t.isTextblock)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),YRe=TQ.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{let t=e.getAttribute(`style`);if(t){let e=t.split(`;`).map(e=>e.trim()).filter(Boolean);for(let t=e.length-1;t>=0;--t){let n=e[t].split(`:`);if(n.length>=2){let e=n[0].trim().toLowerCase(),t=n.slice(1).join(`:`).trim();if(e===`background-color`)return t.replace(/['"]+/g,``)}}}return e.style.backgroundColor?.replace(/['"]+/g,``)},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Y0=TQ.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`style`);if(t){let e=t.split(`;`).map(e=>e.trim()).filter(Boolean);for(let t=e.length-1;t>=0;--t){let n=e[t].split(`:`);if(n.length>=2){let e=n[0].trim().toLowerCase(),t=n.slice(1).join(`:`).trim();if(e===`color`)return t.replace(/['"]+/g,``)}}}return e.style.color?.replace(/['"]+/g,``)},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),XRe=TQ.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),ZRe=TQ.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),QRe=TQ.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}});TQ.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push(YRe.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(Y0.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(XRe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(ZRe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(QRe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(J0.configure(this.options.textStyle)),e}});var $Re=Y0,eze=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,tze=GQ.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,JZ(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new rIe({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[RQ({find:eze,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function X0({content:e,onChange:t,placeholder:n}){let{t:r}=W(),i=oLe({extensions:[GRe.configure({heading:!1,codeBlock:!1,code:!1}),bRe,nRe.configure({openOnClick:!1,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer`}}),KRe.configure({types:[`paragraph`]}),J0,$Re,tze.configure({HTMLAttributes:{style:`max-width: 100%; height: auto;`}})],content:e,onUpdate:({editor:e})=>{t(e.getHTML())},editorProps:{attributes:{class:`prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2`,placeholder:n||``}}});if(!i)return null;let a=({onClick:e,isActive:t=!1,children:n,title:r})=>(0,K.jsx)(`button`,{type:`button`,onClick:e,title:r,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${t?`bg-bambu-dark-tertiary text-bambu-green`:`text-bambu-gray`}`,children:n});return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary`,children:[(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive(`bold`),title:r(`richTextEditor.bold`),children:(0,K.jsx)(Vo,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive(`italic`),title:r(`richTextEditor.italic`),children:(0,K.jsx)(Fc,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive(`underline`),title:r(`richTextEditor.underline`),children:(0,K.jsx)(wu,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive(`bulletList`),title:r(`richTextEditor.bulletList`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive(`orderedList`),title:r(`richTextEditor.numberedList`),children:(0,K.jsx)(Uc,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`left`).run(),isActive:i.isActive({textAlign:`left`}),title:r(`richTextEditor.alignLeft`),children:(0,K.jsx)(_u,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`center`).run(),isActive:i.isActive({textAlign:`center`}),title:r(`richTextEditor.alignCenter`),children:(0,K.jsx)(hu,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`right`).run(),isActive:i.isActive({textAlign:`right`}),title:r(`richTextEditor.alignRight`),children:(0,K.jsx)(gu,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>{let e=window.prompt(`Enter URL:`);e&&i.chain().focus().setLink({href:e}).run()},isActive:i.isActive(`link`),title:r(`richTextEditor.addLink`),children:(0,K.jsx)(Hc,{className:`w-4 h-4`})}),i.isActive(`link`)&&(0,K.jsx)(a,{onClick:()=>i.chain().focus().unsetLink().run(),title:r(`richTextEditor.removeLink`),children:(0,K.jsx)(Eu,{className:`w-4 h-4`})})]}),(0,K.jsx)(a$,{editor:i})]})}function Z0({archiveId:e,archiveName:t,onClose:n}){let r=no(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)({}),{data:u,isLoading:d,error:f}=q({queryKey:[`archive-project-page`,e],queryFn:()=>Q.getArchiveProjectPage(e)}),p=J({mutationFn:t=>Q.updateArchiveProjectPage(e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`archive-project-page`,e]}),a(!1),l({})}});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(o===null?i?_():n():s(null))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,i,n]);let m=[...u?.model_pictures||[],...u?.profile_pictures||[]],h=()=>{l({title:u?.title||``,description:u?.description||``,designer:u?.designer||``,license:u?.license||``,profile_title:u?.profile_title||``,profile_description:u?.profile_description||``}),a(!0)},g=()=>{p.mutate(c)},_=()=>{a(!1),l({})},v=e=>VG.sanitize(e,{ALLOWED_TAGS:[`p`,`br`,`b`,`strong`,`i`,`em`,`u`,`a`,`ul`,`ol`,`li`,`figure`,`img`],ALLOWED_ATTR:[`href`,`src`,`target`,`rel`,`style`],ADD_ATTR:[`target`]}),b=u&&(u.title||u.description||u.designer||u.profile_title||m.length>0);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Project Page`,t&&(0,K.jsxs)(`span`,{className:`text-bambu-gray ml-2`,children:[`- `,t]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!i&&b&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:h,children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-1`}),`Edit`]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:_,children:`Cancel`}),(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:g,disabled:p.isPending,children:[(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),`Save`]})]}),(0,K.jsx)(`button`,{onClick:n,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[d&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent`})}),f&&(0,K.jsx)(`div`,{className:`text-red-400 text-center py-12`,children:`Failed to load project page data`}),u&&!b&&(0,K.jsxs)(`div`,{className:`text-bambu-gray text-center py-12`,children:[(0,K.jsx)(nc,{className:`w-12 h-12 mx-auto mb-4 opacity-50`}),(0,K.jsx)(`p`,{children:`No project page data found in this 3MF file.`}),(0,K.jsx)(`p`,{className:`text-sm mt-2`,children:`Project pages are typically included in files downloaded from MakerWorld.`})]}),u&&b&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,K.jsx)(`input`,{type:`text`,value:c.title||``,onChange:e=>l({...c,title:e.target.value}),placeholder:`Title`,className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold`}):u.title&&(0,K.jsx)(`h3`,{className:`text-xl font-semibold text-white`,children:u.title}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-sm`,children:[i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ou,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c.designer||``,onChange:e=>l({...c,designer:e.target.value}),placeholder:`Designer`,className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white`})]}):u.designer&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(Ou,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.designer}),u.designer_user_id&&(0,K.jsx)(`a`,{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline`,children:(0,K.jsx)(Js,{className:`w-3 h-3`})})]}),u.creation_date&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.creation_date})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c.license||``,onChange:e=>l({...c,license:e.target.value}),placeholder:`License`,className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white`})]}):u.license&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.license})]}),u.origin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray`,children:u.origin})]})]}),(u.description||i)&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide`,children:`Description`}),i?(0,K.jsx)(X0,{content:c.description||``,onChange:e=>l({...c,description:e}),placeholder:`Enter description...`}):(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-bambu-gray-light`,dangerouslySetInnerHTML:{__html:v(u.description||``)}})]}),(u.profile_title||u.profile_description||i)&&(0,K.jsxs)(`div`,{className:`space-y-2 p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide`,children:`Print Profile`}),i?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:c.profile_title||``,onChange:e=>l({...c,profile_title:e.target.value}),placeholder:`Profile Title`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white`}),(0,K.jsx)(X0,{content:c.profile_description||``,onChange:e=>l({...c,profile_description:e}),placeholder:`Profile description...`})]}):(0,K.jsxs)(K.Fragment,{children:[u.profile_title&&(0,K.jsx)(`p`,{className:`text-white font-medium`,children:u.profile_title}),u.profile_description&&(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-bambu-gray-light`,dangerouslySetInnerHTML:{__html:v(u.profile_description)}}),u.profile_user_name&&(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`by `,u.profile_user_name]})]})]}),m.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2`,children:[(0,K.jsx)(Mc,{className:`w-4 h-4`}),`Images (`,m.length,`)`]}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2`,children:m.map((e,t)=>(0,K.jsx)(`button`,{onClick:()=>s(t),className:`aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors`,children:(0,K.jsx)(`img`,{src:e.url,alt:e.name,className:`w-full h-full object-cover`})},e.path))})]}),u.design_model_id&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`a`,{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 text-bambu-green hover:underline`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`View on MakerWorld`]})})]})]})]}),o!==null&&m[o]&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-60`,onClick:()=>s(null),children:[(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s(Math.max(0,o-1))},disabled:o===0,className:`absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30`,children:(0,K.jsx)(ss,{className:`w-6 h-6 text-white`})}),(0,K.jsx)(`img`,{src:m[o].url,alt:m[o].name,className:`max-w-[90vw] max-h-[90vh] object-contain`,onClick:e=>e.stopPropagation()}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s(Math.min(m.length-1,o+1))},disabled:o===m.length-1,className:`absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30`,children:(0,K.jsx)(as,{className:`w-6 h-6 text-white`})}),(0,K.jsx)(`button`,{onClick:()=>s(null),className:`absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-6 h-6 text-white`})}),(0,K.jsxs)(`div`,{className:`absolute bottom-4 text-white text-sm`,children:[o+1,` / `,m.length]})]})]})}var nze=[.25,.5,.75,1,1.5,2,3,4];function rze({archiveId:e,timelapseSrc:t,onClose:n,onSave:r}){let{showToast:i}=Td(),a=(0,y.useRef)(null),o=(0,y.useRef)(null),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(0),[d,f]=(0,y.useState)(0),[p,m]=(0,y.useState)(0),[h,g]=(0,y.useState)(0),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(.8),[E,D]=(0,y.useState)(!1),{data:O,isLoading:k}=q({queryKey:[`timelapse-info`,e],queryFn:()=>Q.getTimelapseInfo(e)}),{data:A}=q({queryKey:[`timelapse-thumbnails`,e],queryFn:()=>Q.getTimelapseThumbnails(e,15)}),j=J({mutationFn:()=>Q.processTimelapse(e,{trimStart:p,trimEnd:h,speed:_,saveMode:`replace`},b||void 0),onSuccess:e=>{i(e.message,`success`),r?.(),n()},onError:e=>{i(e.message||`Processing failed`,`error`)}});(0,y.useEffect)(()=>{O?.duration&&h===0&&g(O.duration)},[O?.duration,h]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.currentTime;u(t),t>=h&&(e.currentTime=p)},n=()=>{f(e.duration),h===0&&g(e.duration)},r=()=>c(!0),i=()=>c(!1);return e.addEventListener(`timeupdate`,t),e.addEventListener(`durationchange`,n),e.addEventListener(`play`,r),e.addEventListener(`pause`,i),()=>{e.removeEventListener(`timeupdate`,t),e.removeEventListener(`durationchange`,n),e.removeEventListener(`play`,r),e.removeEventListener(`pause`,i)}},[p,h]),(0,y.useEffect)(()=>{let e=o.current,t=a.current;!e||!t||!S||(e.currentTime=t.currentTime,e.playbackRate=t.playbackRate,s&&!E?e.play().catch(()=>{}):e.pause())},[s,S,E]),(0,y.useEffect)(()=>{o.current&&(o.current.volume=E?0:w)},[w,E]),(0,y.useEffect)(()=>{a.current&&(a.current.playbackRate=_),o.current&&(o.current.playbackRate=_)},[_]);let M=(0,y.useCallback)(()=>{let e=a.current;e&&(s?e.pause():(e.currentTime{let t=a.current;t&&(t.currentTime=Math.max(p,Math.min(h,e)))},P=e=>{let t=e.target.files?.[0];t&&(S&&URL.revokeObjectURL(S),x(t),C(URL.createObjectURL(t)))},F=()=>{S&&URL.revokeObjectURL(S),x(null),C(null)};(0,y.useEffect)(()=>()=>{S&&URL.revokeObjectURL(S)},[S]);let I=h-p,L=I/_;return k?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-white`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin`}),`Loading video info...`]})}):(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80`,children:(0,K.jsxs)(`div`,{className:`relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ic,{className:`w-5 h-5 text-bambu-green`}),`Edit Timelapse`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),`Processing...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),`Save`]})}),(0,K.jsx)(`button`,{onClick:n,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`video`,{ref:a,src:t,className:`w-full rounded-lg bg-black`,onClick:M,muted:!!S}),!s&&(0,K.jsx)(`button`,{onClick:M,className:`absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors`,children:(0,K.jsx)(`div`,{className:`p-4 bg-bambu-green rounded-full`,children:(0,K.jsx)(bl,{className:`w-8 h-8 text-white`})})}),S&&(0,K.jsx)(`audio`,{ref:o,src:S,loop:!0})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(Ll,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:`Trim`}),(0,K.jsxs)(`span`,{className:`ml-auto`,children:[Tf(p),` - `,Tf(h),` (`,Tf(I),`)`]})]}),(0,K.jsxs)(`div`,{className:`relative h-16 bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex`,children:A?.thumbnails.map((e,t)=>(0,K.jsx)(`div`,{className:`flex-1 bg-cover bg-center`,style:{backgroundImage:`url(data:image/jpeg;base64,${e})`}},t))}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-black/60`,style:{width:`${p/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 right-0 bg-black/60`,style:{width:`${(d-h)/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 border-2 border-bambu-green`,style:{left:`${p/d*100}%`,right:`${(d-h)/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 w-0.5 bg-white shadow-lg`,style:{left:`${l/d*100}%`}}),(0,K.jsx)(`input`,{type:`range`,min:0,max:d,step:.1,value:p,onChange:e=>{let t=parseFloat(e.target.value);t{let t=parseFloat(e.target.value);t>p+1&&g(t)},className:`absolute inset-0 w-full opacity-0 cursor-ew-resize`,style:{clipPath:`inset(0 0 0 50%)`}})]}),(0,K.jsx)(`input`,{type:`range`,min:0,max:d,step:.1,value:l,onChange:e=>N(parseFloat(e.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(uRe,this.editor.getAttributes(S0)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=VQ({find:C0,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=VQ({find:C0,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(S0)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),dRe=/^\s*(\[([( |x])?\])\s$/,fRe=KQ.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,YZ(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>GQ(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=XZ(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[VQ({find:dRe,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),pRe=KQ.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,YZ(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=WQ(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=WQ(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});EQ.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(c0.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(l0.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(y0.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(w0.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(fRe.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(pRe.configure(this.options.taskList)),e}});var T0=` `,mRe=`\xA0`,hRe=KQ.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,YZ(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return r.length===1&&r[0].type===`text`&&(r[0].text===T0||r[0].text===mRe)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t)=>{if(!e)return``;let n=Array.isArray(e.content)?e.content:[];return n.length===0?T0:t.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),gRe=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,_Re=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,vRe=CQ.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,YZ(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[RQ({find:gRe,type:this.type})]},addPasteRules(){return[qQ({find:_Re,type:this.type})]}}),yRe=KQ.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),E0=CQ.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,YZ(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),bRe=E0;function xRe(e={}){return new Yq({view(t){return new SRe(t,e)}})}var SRe=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=vq(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},D0=class e extends Nq{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):Nq.near(r)}content(){return QG.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new CRe(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!wRe(e)||!TRe(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Rq.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};D0.prototype.visible=!1,D0.findFrom=D0.findGapCursorFrom,Nq.jsonID(`gapcursor`,D0);var CRe=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return D0.valid(t)?new D0(t):Nq.near(t)}};function O0(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function wRe(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||O0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function TRe(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||O0(e.type))return!0;if(e.inlineContent)return!1}}return!0}function ERe(){return new Yq({props:{decorations:ARe,createSelectionBetween(e,t,n){return t.pos==n.pos&&D0.valid(n)?new D0(n):null},handleClick:ORe,handleKeyDown:DRe,handleDOMEvents:{beforeinput:kRe}}})}var DRe=mZ({ArrowLeft:k0(`horiz`,-1),ArrowRight:k0(`horiz`,1),ArrowUp:k0(`vert`,-1),ArrowDown:k0(`vert`,1)});function k0(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof Iq){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=D0.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new D0(c))),!0):!1}}function ORe(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!D0.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Rq.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new D0(r))),!0)}function kRe(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof D0))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=KG.empty;for(let e=r.length-1;e>=0;e--)i=KG.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new QG(i,0,0));return a.setSelection(Iq.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function ARe(e){if(!(e.selection instanceof D0))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,BX.create(e.doc,[LX.widget(e.selection.head,t,{key:`gapcursor`})])}var A0=200,j0=function(){};j0.prototype.append=function(e){return e.length?(e=j0.from(e),!this.length&&e||e.length=t?j0.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},j0.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},j0.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},j0.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},j0.from=function(e){return e instanceof j0?e:e&&e.length?new M0(e):j0.empty};var M0=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=A0)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=A0)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(j0);j0.empty=new M0([]);var jRe=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(j0),MRe=500,N0=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new P0(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new P0(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;ePRe&&(s=NRe(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new XK;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new P0(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new P0(i,o,l))}else r.push(new P0(i))},i);let l=[];for(let e=n;eMRe&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new P0(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(j0.from(i.reverse()),a)}};N0.empty=new N0(j0.empty,0);function NRe(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var P0=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},F0=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},PRe=20;function FRe(e,t,n,r){let i=n.getMeta(V0),a;if(i)return i.historyState;n.getMeta(RRe)&&(e=new F0(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(V0))return o.getMeta(V0).redo?new F0(e.done.addTransform(n,void 0,r,B0(t)),e.undone,I0(n.mapping.maps),e.prevTime,e.prevComposition):new F0(e.done,e.undone.addTransform(n,void 0,r,B0(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!IRe(n,e.prevRanges)),s=o?L0(e.prevRanges,n.mapping):I0(n.mapping.maps);return new F0(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,B0(t)),N0.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new F0(e.done.rebased(n,a),e.undone.rebased(n,a),L0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new F0(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),L0(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function IRe(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function I0(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function L0(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=V0.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=LRe(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var U0=H0(!1,!0),W0=H0(!0,!0);EQ.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new Yq({key:new Qq(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var BRe=EQ.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[xRe(this.options)]}});EQ.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new Yq({key:new Qq(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return BX.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(LX.node(t,t+e.nodeSize,{class:this.options.className}))}),BX.create(e,a)}}})]}});var VRe=EQ.create({name:`gapCursor`,addProseMirrorPlugins(){return[ERe()]},extendNodeSchema(e){return{allowGapCursor:KZ(HZ(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),G0=`placeholder`;function HRe(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}EQ.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:G0,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${HRe(this.options.dataAttribute)}`:`data-${G0}`;return[new Yq({key:new Qq(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&fQ(t);if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=LX.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),BX.create(t,a)}}})]}}),EQ.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new Yq({key:new Qq(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||pQ(n.selection)||e.view.dragging?null:BX.create(n.doc,[LX.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function K0({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var URe=EQ.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new Qq(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new Yq({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!K0({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!K0({node:r,types:n})}}})]}}),WRe=EQ.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>U0(e,t),redo:()=>({state:e,dispatch:t})=>W0(e,t)}},addProseMirrorPlugins(){return[zRe(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),GRe=EQ.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(hLe.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(uLe.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(c0.configure(this.options.bulletList)),this.options.code!==!1&&e.push(vLe.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(xLe.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(SLe.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(BRe.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(VRe.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(CLe.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(wLe.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(WRe.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(TLe.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(ALe.configure(this.options.italic)),this.options.listItem!==!1&&e.push(l0.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(y0.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(a0.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(w0.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(hRe.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(vRe.configure(this.options.strike)),this.options.text!==!1&&e.push(yRe.configure(this.options.text)),this.options.underline!==!1&&e.push(E0.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(URe.configure(this.options?.trailingNode)),e}}),KRe=EQ.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),qRe=20,q0=(e,t=0)=>{let n=[];return!e.children.length||t>qRe||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...q0(e,t+1))}),n},JRe=e=>{if(!e.children.length)return;let t=q0(e);t&&t.forEach(e=>{let t=e.getAttribute(`style`),n=(e.parentElement?.closest(`span`))?.getAttribute(`style`);e.setAttribute(`style`,`${n};${t}`)})},J0=CQ.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&JRe(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,YZ(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(t.isTextblock)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),YRe=EQ.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>{let t=e.getAttribute(`style`);if(t){let e=t.split(`;`).map(e=>e.trim()).filter(Boolean);for(let t=e.length-1;t>=0;--t){let n=e[t].split(`:`);if(n.length>=2){let e=n[0].trim().toLowerCase(),t=n.slice(1).join(`:`).trim();if(e===`background-color`)return t.replace(/['"]+/g,``)}}}return e.style.backgroundColor?.replace(/['"]+/g,``)},renderHTML:e=>e.backgroundColor?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Y0=EQ.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{let t=e.getAttribute(`style`);if(t){let e=t.split(`;`).map(e=>e.trim()).filter(Boolean);for(let t=e.length-1;t>=0;--t){let n=e[t].split(`:`);if(n.length>=2){let e=n[0].trim().toLowerCase(),t=n.slice(1).join(`:`).trim();if(e===`color`)return t.replace(/['"]+/g,``)}}}return e.style.color?.replace(/['"]+/g,``)},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),XRe=EQ.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>e.style.fontFamily,renderHTML:e=>e.fontFamily?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),ZRe=EQ.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize,renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),QRe=EQ.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>e.style.lineHeight,renderHTML:e=>e.lineHeight?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}});EQ.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push(YRe.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(Y0.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(XRe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(ZRe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(QRe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(J0.configure(this.options.textStyle)),e}});var $Re=Y0,eze=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,tze=KQ.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,YZ(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new nIe({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[zQ({find:eze,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function X0({content:e,onChange:t,placeholder:n}){let{t:r}=W(),i=aLe({extensions:[GRe.configure({heading:!1,codeBlock:!1,code:!1}),bRe,nRe.configure({openOnClick:!1,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer`}}),KRe.configure({types:[`paragraph`]}),J0,$Re,tze.configure({HTMLAttributes:{style:`max-width: 100%; height: auto;`}})],content:e,onUpdate:({editor:e})=>{t(e.getHTML())},editorProps:{attributes:{class:`prose prose-invert prose-sm max-w-none focus:outline-none min-h-[120px] px-3 py-2`,placeholder:n||``}}});if(!i)return null;let a=({onClick:e,isActive:t=!1,children:n,title:r})=>(0,K.jsx)(`button`,{type:`button`,onClick:e,title:r,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary transition-colors ${t?`bg-bambu-dark-tertiary text-bambu-green`:`text-bambu-gray`}`,children:n});return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary`,children:[(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleBold().run(),isActive:i.isActive(`bold`),title:r(`richTextEditor.bold`),children:(0,K.jsx)(Vo,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleItalic().run(),isActive:i.isActive(`italic`),title:r(`richTextEditor.italic`),children:(0,K.jsx)(Fc,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleUnderline().run(),isActive:i.isActive(`underline`),title:r(`richTextEditor.underline`),children:(0,K.jsx)(wu,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleBulletList().run(),isActive:i.isActive(`bulletList`),title:r(`richTextEditor.bulletList`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().toggleOrderedList().run(),isActive:i.isActive(`orderedList`),title:r(`richTextEditor.numberedList`),children:(0,K.jsx)(Uc,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`left`).run(),isActive:i.isActive({textAlign:`left`}),title:r(`richTextEditor.alignLeft`),children:(0,K.jsx)(_u,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`center`).run(),isActive:i.isActive({textAlign:`center`}),title:r(`richTextEditor.alignCenter`),children:(0,K.jsx)(hu,{className:`w-4 h-4`})}),(0,K.jsx)(a,{onClick:()=>i.chain().focus().setTextAlign(`right`).run(),isActive:i.isActive({textAlign:`right`}),title:r(`richTextEditor.alignRight`),children:(0,K.jsx)(gu,{className:`w-4 h-4`})}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary mx-1`}),(0,K.jsx)(a,{onClick:()=>{let e=window.prompt(`Enter URL:`);e&&i.chain().focus().setLink({href:e}).run()},isActive:i.isActive(`link`),title:r(`richTextEditor.addLink`),children:(0,K.jsx)(Hc,{className:`w-4 h-4`})}),i.isActive(`link`)&&(0,K.jsx)(a,{onClick:()=>i.chain().focus().unsetLink().run(),title:r(`richTextEditor.removeLink`),children:(0,K.jsx)(Eu,{className:`w-4 h-4`})})]}),(0,K.jsx)(o$,{editor:i})]})}function Z0({archiveId:e,archiveName:t,onClose:n}){let r=no(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)({}),{data:u,isLoading:d,error:f}=q({queryKey:[`archive-project-page`,e],queryFn:()=>Q.getArchiveProjectPage(e)}),p=J({mutationFn:t=>Q.updateArchiveProjectPage(e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`archive-project-page`,e]}),a(!1),l({})}});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(o===null?i?_():n():s(null))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,i,n]);let m=[...u?.model_pictures||[],...u?.profile_pictures||[]],h=()=>{l({title:u?.title||``,description:u?.description||``,designer:u?.designer||``,license:u?.license||``,profile_title:u?.profile_title||``,profile_description:u?.profile_description||``}),a(!0)},g=()=>{p.mutate(c)},_=()=>{a(!1),l({})},v=e=>HG.sanitize(e,{ALLOWED_TAGS:[`p`,`br`,`b`,`strong`,`i`,`em`,`u`,`a`,`ul`,`ol`,`li`,`figure`,`img`],ALLOWED_ATTR:[`href`,`src`,`target`,`rel`,`style`],ADD_ATTR:[`target`]}),b=u&&(u.title||u.description||u.designer||u.profile_title||m.length>0);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:e=>{e.target===e.currentTarget&&n()},children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Project Page`,t&&(0,K.jsxs)(`span`,{className:`text-bambu-gray ml-2`,children:[`- `,t]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!i&&b&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:h,children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-1`}),`Edit`]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:_,children:`Cancel`}),(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:g,disabled:p.isPending,children:[(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),`Save`]})]}),(0,K.jsx)(`button`,{onClick:n,className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-6`,children:[d&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent`})}),f&&(0,K.jsx)(`div`,{className:`text-red-400 text-center py-12`,children:`Failed to load project page data`}),u&&!b&&(0,K.jsxs)(`div`,{className:`text-bambu-gray text-center py-12`,children:[(0,K.jsx)(nc,{className:`w-12 h-12 mx-auto mb-4 opacity-50`}),(0,K.jsx)(`p`,{children:`No project page data found in this 3MF file.`}),(0,K.jsx)(`p`,{className:`text-sm mt-2`,children:`Project pages are typically included in files downloaded from MakerWorld.`})]}),u&&b&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[i?(0,K.jsx)(`input`,{type:`text`,value:c.title||``,onChange:e=>l({...c,title:e.target.value}),placeholder:`Title`,className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-lg px-4 py-2 text-white text-xl font-semibold`}):u.title&&(0,K.jsx)(`h3`,{className:`text-xl font-semibold text-white`,children:u.title}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 text-sm`,children:[i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ou,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c.designer||``,onChange:e=>l({...c,designer:e.target.value}),placeholder:`Designer`,className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white`})]}):u.designer&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(Ou,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.designer}),u.designer_user_id&&(0,K.jsx)(`a`,{href:`https://makerworld.com/en/@${u.designer_user_id}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline`,children:(0,K.jsx)(Js,{className:`w-3 h-3`})})]}),u.creation_date&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.creation_date})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c.license||``,onChange:e=>l({...c,license:e.target.value}),placeholder:`License`,className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white`})]}):u.license&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:u.license})]}),u.origin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray`,children:u.origin})]})]}),(u.description||i)&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide`,children:`Description`}),i?(0,K.jsx)(X0,{content:c.description||``,onChange:e=>l({...c,description:e}),placeholder:`Enter description...`}):(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-bambu-gray-light`,dangerouslySetInnerHTML:{__html:v(u.description||``)}})]}),(u.profile_title||u.profile_description||i)&&(0,K.jsxs)(`div`,{className:`space-y-2 p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide`,children:`Print Profile`}),i?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:c.profile_title||``,onChange:e=>l({...c,profile_title:e.target.value}),placeholder:`Profile Title`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white`}),(0,K.jsx)(X0,{content:c.profile_description||``,onChange:e=>l({...c,profile_description:e}),placeholder:`Profile description...`})]}):(0,K.jsxs)(K.Fragment,{children:[u.profile_title&&(0,K.jsx)(`p`,{className:`text-white font-medium`,children:u.profile_title}),u.profile_description&&(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none text-bambu-gray-light`,dangerouslySetInnerHTML:{__html:v(u.profile_description)}}),u.profile_user_name&&(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`by `,u.profile_user_name]})]})]}),m.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2`,children:[(0,K.jsx)(Mc,{className:`w-4 h-4`}),`Images (`,m.length,`)`]}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2`,children:m.map((e,t)=>(0,K.jsx)(`button`,{onClick:()=>s(t),className:`aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors`,children:(0,K.jsx)(`img`,{src:e.url,alt:e.name,className:`w-full h-full object-cover`})},e.path))})]}),u.design_model_id&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`a`,{href:`https://makerworld.com/en/models/${u.design_model_id}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 text-bambu-green hover:underline`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`View on MakerWorld`]})})]})]})]}),o!==null&&m[o]&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-60`,onClick:()=>s(null),children:[(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s(Math.max(0,o-1))},disabled:o===0,className:`absolute left-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30`,children:(0,K.jsx)(ss,{className:`w-6 h-6 text-white`})}),(0,K.jsx)(`img`,{src:m[o].url,alt:m[o].name,className:`max-w-[90vw] max-h-[90vh] object-contain`,onClick:e=>e.stopPropagation()}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s(Math.min(m.length-1,o+1))},disabled:o===m.length-1,className:`absolute right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary disabled:opacity-30`,children:(0,K.jsx)(as,{className:`w-6 h-6 text-white`})}),(0,K.jsx)(`button`,{onClick:()=>s(null),className:`absolute top-4 right-4 p-2 bg-bambu-dark-secondary rounded-full hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-6 h-6 text-white`})}),(0,K.jsxs)(`div`,{className:`absolute bottom-4 text-white text-sm`,children:[o+1,` / `,m.length]})]})]})}var nze=[.25,.5,.75,1,1.5,2,3,4];function rze({archiveId:e,timelapseSrc:t,onClose:n,onSave:r}){let{showToast:i}=Td(),a=(0,y.useRef)(null),o=(0,y.useRef)(null),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(0),[d,f]=(0,y.useState)(0),[p,m]=(0,y.useState)(0),[h,g]=(0,y.useState)(0),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(.8),[E,D]=(0,y.useState)(!1),{data:O,isLoading:k}=q({queryKey:[`timelapse-info`,e],queryFn:()=>Q.getTimelapseInfo(e)}),{data:A}=q({queryKey:[`timelapse-thumbnails`,e],queryFn:()=>Q.getTimelapseThumbnails(e,15)}),j=J({mutationFn:()=>Q.processTimelapse(e,{trimStart:p,trimEnd:h,speed:_,saveMode:`replace`},b||void 0),onSuccess:e=>{i(e.message,`success`),r?.(),n()},onError:e=>{i(e.message||`Processing failed`,`error`)}});(0,y.useEffect)(()=>{O?.duration&&h===0&&g(O.duration)},[O?.duration,h]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{let t=e.currentTime;u(t),t>=h&&(e.currentTime=p)},n=()=>{f(e.duration),h===0&&g(e.duration)},r=()=>c(!0),i=()=>c(!1);return e.addEventListener(`timeupdate`,t),e.addEventListener(`durationchange`,n),e.addEventListener(`play`,r),e.addEventListener(`pause`,i),()=>{e.removeEventListener(`timeupdate`,t),e.removeEventListener(`durationchange`,n),e.removeEventListener(`play`,r),e.removeEventListener(`pause`,i)}},[p,h]),(0,y.useEffect)(()=>{let e=o.current,t=a.current;!e||!t||!S||(e.currentTime=t.currentTime,e.playbackRate=t.playbackRate,s&&!E?e.play().catch(()=>{}):e.pause())},[s,S,E]),(0,y.useEffect)(()=>{o.current&&(o.current.volume=E?0:w)},[w,E]),(0,y.useEffect)(()=>{a.current&&(a.current.playbackRate=_),o.current&&(o.current.playbackRate=_)},[_]);let M=(0,y.useCallback)(()=>{let e=a.current;e&&(s?e.pause():(e.currentTime{let t=a.current;t&&(t.currentTime=Math.max(p,Math.min(h,e)))},P=e=>{let t=e.target.files?.[0];t&&(S&&URL.revokeObjectURL(S),x(t),C(URL.createObjectURL(t)))},F=()=>{S&&URL.revokeObjectURL(S),x(null),C(null)};(0,y.useEffect)(()=>()=>{S&&URL.revokeObjectURL(S)},[S]);let I=h-p,L=I/_;return k?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-white`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin`}),`Loading video info...`]})}):(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80`,children:(0,K.jsxs)(`div`,{className:`relative bg-bambu-dark-secondary rounded-xl max-w-5xl w-full mx-4 max-h-[90vh] overflow-hidden flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ic,{className:`w-5 h-5 text-bambu-green`}),`Edit Timelapse`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),`Processing...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),`Save`]})}),(0,K.jsx)(`button`,{onClick:n,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`video`,{ref:a,src:t,className:`w-full rounded-lg bg-black`,onClick:M,muted:!!S}),!s&&(0,K.jsx)(`button`,{onClick:M,className:`absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors`,children:(0,K.jsx)(`div`,{className:`p-4 bg-bambu-green rounded-full`,children:(0,K.jsx)(bl,{className:`w-8 h-8 text-white`})})}),S&&(0,K.jsx)(`audio`,{ref:o,src:S,loop:!0})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(Ll,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:`Trim`}),(0,K.jsxs)(`span`,{className:`ml-auto`,children:[Tf(p),` - `,Tf(h),` (`,Tf(I),`)`]})]}),(0,K.jsxs)(`div`,{className:`relative h-16 bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex`,children:A?.thumbnails.map((e,t)=>(0,K.jsx)(`div`,{className:`flex-1 bg-cover bg-center`,style:{backgroundImage:`url(data:image/jpeg;base64,${e})`}},t))}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 left-0 bg-black/60`,style:{width:`${p/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 right-0 bg-black/60`,style:{width:`${(d-h)/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute inset-y-0 border-2 border-bambu-green`,style:{left:`${p/d*100}%`,right:`${(d-h)/d*100}%`}}),(0,K.jsx)(`div`,{className:`absolute top-0 bottom-0 w-0.5 bg-white shadow-lg`,style:{left:`${l/d*100}%`}}),(0,K.jsx)(`input`,{type:`range`,min:0,max:d,step:.1,value:p,onChange:e=>{let t=parseFloat(e.target.value);t{let t=parseFloat(e.target.value);t>p+1&&g(t)},className:`absolute inset-0 w-full opacity-0 cursor-ew-resize`,style:{clipPath:`inset(0 0 0 50%)`}})]}),(0,K.jsx)(`input`,{type:`range`,min:0,max:d,step:.1,value:l,onChange:e=>N(parseFloat(e.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:cursor-pointer`}),(0,K.jsx)(`div`,{className:`flex items-center justify-center gap-2`,children:(0,K.jsx)(`button`,{onClick:M,className:`p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors`,children:s?(0,K.jsx)(hl,{className:`w-5 h-5 text-white`}):(0,K.jsx)(bl,{className:`w-5 h-5 text-white`})})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(hc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:`Speed`}),(0,K.jsxs)(`span`,{className:`ml-auto`,children:[_,`x (output: `,Tf(L),`)`]})]}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:nze.map(e=>(0,K.jsxs)(`button`,{onClick:()=>v(e),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${_===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[e,`x`]},e))})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(ul,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:`Music Overlay`})]}),b?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(ul,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:b.name}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[(b.size/1024/1024).toFixed(1),` MB`]})]}),(0,K.jsx)(`button`,{onClick:()=>D(!E),className:`p-2 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:E?(0,K.jsx)(ju,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(eee,{className:`w-4 h-4 text-bambu-green`})}),(0,K.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:w,onChange:e=>T(parseFloat(e.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer @@ -8686,7 +8686,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content: [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),(0,K.jsx)(`button`,{onClick:F,className:`p-2 hover:bg-red-500/20 rounded transition-colors`,children:(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})})]}):(0,K.jsxs)(`label`,{className:`flex flex-col items-center justify-center gap-2 p-6 border-2 border-dashed border-bambu-dark-tertiary rounded-lg cursor-pointer hover:border-bambu-green/50 transition-colors`,children:[(0,K.jsx)(Du,{className:`w-8 h-8 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`Drop audio file or click to upload`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/60`,children:`MP3, WAV, M4A, AAC, OGG`}),(0,K.jsx)(`input`,{type:`file`,accept:`.mp3,.wav,.m4a,.aac,.ogg,audio/*`,onChange:P,className:`hidden`})]})]}),(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg text-sm space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:`Original:`}),` `,Tf(d),` @ `,O?.width,`x`,O?.height]}),(0,K.jsxs)(`p`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:`Output:`}),` `,Tf(L),` @ `,_,`x speed`,b&&` + music overlay`]})]})]}),j.isPending&&(0,K.jsxs)(`div`,{className:`absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4`,children:[(0,K.jsx)(X,{className:`w-12 h-12 text-bambu-green animate-spin`}),(0,K.jsx)(`p`,{className:`text-white text-lg`,children:`Processing timelapse...`}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:`This may take a few moments`})]})]})})}var ize=[.25,.5,.75,1,1.5,2,3,4];function Q0({src:e,title:t,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){let o=(0,y.useRef)(null),[s,c]=(0,y.useState)(!0),[l,u]=(0,y.useState)(1),[d,f]=(0,y.useState)(0),[p,m]=(0,y.useState)(0),[h,g]=(0,y.useState)(!1);(0,y.useEffect)(()=>{let e=o.current;e&&(e.playbackRate=l)},[l]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,y.useEffect)(()=>{let e=o.current;if(!e)return;let t=()=>f(e.currentTime),n=()=>m(e.duration),r=()=>c(!0),i=()=>c(!1);return e.addEventListener(`timeupdate`,t),e.addEventListener(`durationchange`,n),e.addEventListener(`play`,r),e.addEventListener(`pause`,i),()=>{e.removeEventListener(`timeupdate`,t),e.removeEventListener(`durationchange`,n),e.removeEventListener(`play`,r),e.removeEventListener(`pause`,i)}},[]);let _=()=>{let e=o.current;e&&(s?e.pause():e.play())};return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/80`,children:[(0,K.jsxs)(`div`,{className:`relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ic,{className:`w-5 h-5 text-bambu-green`}),t]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>g(!0),children:[(0,K.jsx)(vl,{className:`w-4 h-4`}),`Edit`]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>{let t=document.createElement(`a`);t.href=e,t.download=n,t.click()},children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),`Download`]}),(0,K.jsx)(`button`,{onClick:i,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]})]}),(0,K.jsxs)(`div`,{className:`p-4`,children:[(0,K.jsx)(`video`,{ref:o,src:e,autoPlay:!0,className:`w-full rounded-lg`,onClick:_}),(0,K.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray w-12 text-right`,children:Tf(d)}),(0,K.jsx)(`input`,{type:`range`,min:0,max:p||100,value:d,onChange:e=>{let t=o.current;t&&(t.currentTime=parseFloat(e.target.value))},className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full - [&::-webkit-slider-thumb]:cursor-pointer`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray w-12`,children:Tf(p)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{let e=o.current;e&&(e.currentTime=Math.max(0,e.currentTime-5))},className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:`Skip back 5s`,children:(0,K.jsx)(Xl,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:_,className:`p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors`,children:s?(0,K.jsx)(hl,{className:`w-5 h-5 text-white`}):(0,K.jsx)(bl,{className:`w-5 h-5 text-white`})}),(0,K.jsx)(`button`,{onClick:()=>{let e=o.current;e&&(e.currentTime=Math.min(p,e.currentTime+5))},className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:`Skip forward 5s`,children:(0,K.jsx)(Zl,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`Speed:`}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:ize.map(e=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`px-2 py-1 text-xs rounded transition-colors ${l===e?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80`}`,children:[e,`x`]},e))})]})]})]})]})]}),h&&r&&(0,K.jsx)(rze,{archiveId:r,timelapseSrc:e,onClose:()=>g(!1),onSave:a})]})}function aze({archiveIds:e,onClose:t}){(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let{data:n,isLoading:r,error:i}=q({queryKey:[`archive-comparison`,e],queryFn:()=>Q.compareArchives(e)});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white`,children:[`Compare Archives (`,e.length,`)`]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-auto p-4 bg-bambu-dark-secondary`,children:r?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):i?(0,K.jsxs)(`div`,{className:`text-center py-12 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12 mx-auto mb-4 opacity-50`}),(0,K.jsx)(`p`,{children:`Failed to load comparison`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:i instanceof Error?i.message:`Unknown error`})]}):n?(0,K.jsx)(oze,{comparison:n}):null}),(0,K.jsx)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`w-full`,children:`Close`})})]})})}function oze({comparison:e}){return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]`,children:`Setting`}),e.archives.map(e=>(0,K.jsxs)(`th`,{className:`text-left text-sm font-medium pb-2 px-2 min-w-[120px]`,children:[(0,K.jsx)(`div`,{className:`text-white truncate max-w-[150px]`,title:e.print_name,children:e.print_name}),(0,K.jsx)(`div`,{className:`text-xs ${e.status===`completed`?`text-status-ok`:e.status===`failed`?`text-status-error`:`text-bambu-gray`}`,children:e.status})]},e.id))]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-gray/20`,children:e.comparison.map(e=>(0,K.jsxs)(`tr`,{className:e.has_difference?`bg-yellow-500/5`:``,children:[(0,K.jsx)(`td`,{className:`py-2 pr-4 text-sm`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.has_difference&&(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400 flex-shrink-0`}),(0,K.jsx)(`span`,{className:e.has_difference?`text-yellow-400`:`text-bambu-gray`,children:e.label})]})}),e.values.map((t,n)=>(0,K.jsxs)(`td`,{className:`py-2 px-2 text-sm text-white`,children:[t??(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`-`}),e.unit&&t!==null&&(0,K.jsx)(`span`,{className:`text-bambu-gray ml-1`,children:e.unit})]},n))]},e.field))})]})}),e.differences.length>0&&(0,K.jsxs)(`div`,{className:`p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4`}),e.differences.length,` Difference`,e.differences.length>1?`s`:``,` Found`]}),(0,K.jsxs)(`ul`,{className:`text-sm text-white/80 space-y-1`,children:[e.differences.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-yellow-400`,children:e.label}),`: `,e.values.join(` vs `),` `,e.unit||``]},e.field)),e.differences.length>5&&(0,K.jsxs)(`li`,{className:`text-bambu-gray`,children:[`...and `,e.differences.length-5,` more`]})]})]}),e.success_correlation.has_both_outcomes?(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-white mb-3 flex items-center gap-2`,children:[(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),`Success/Failure Analysis`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-3`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-green`,children:[e.success_correlation.successful_count,` successful`]}),(0,K.jsxs)(`span`,{className:`text-red-400`,children:[e.success_correlation.failed_count,` failed`]})]}),e.success_correlation.insights&&e.success_correlation.insights.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:e.success_correlation.insights.map(e=>(0,K.jsxs)(`div`,{className:`text-sm p-2 bg-bambu-dark-secondary rounded`,children:[(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[e.label,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-white/80`,children:e.insight})]},e.field))}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`No clear correlations found between settings and outcomes.`})]}):(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray`,children:(0,K.jsx)(`p`,{children:e.success_correlation.message||`Need both successful and failed prints for correlation analysis.`})})]})}function sze(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`Just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function cze({upload:e,projects:t,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(e.tags||``),[u,d]=(0,y.useState)(e.notes||``),[f,p]=(0,y.useState)(e.project_id),[m,h]=(0,y.useState)(!1);return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Qs,{className:`w-8 h-8 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,title:e.filename,children:e.display_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:Cd(e.file_size)}),(0,K.jsx)(`span`,{children:`·`}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),sze(e.uploaded_at)]}),e.source_ip&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:`·`}),(0,K.jsxs)(`span`,{children:[`from `,e.source_ip]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>s(!o),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:o?(0,K.jsx)(cs,{className:`w-5 h-5`}):(0,K.jsx)(is,{className:`w-5 h-5`})}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>n(e.id,{tags:c,notes:u,project_id:f||void 0}),disabled:i,children:i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),`Archive`]})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>h(!0),disabled:a,children:a?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})})]})]}),m&&(0,K.jsx)(Ad,{title:`Discard Upload`,message:`Are you sure you want to discard "${e.filename}"? This cannot be undone.`,confirmText:`Discard`,variant:`danger`,onConfirm:()=>{r(e.id),h(!1)},onCancel:()=>h(!1)}),o&&(0,K.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Tags`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`e.g., functional, prototype, gift`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Notes`}),(0,K.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),placeholder:`Add notes about this print...`,rows:2,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Project`}),(0,K.jsxs)(`select`,{value:f||``,onChange:e=>p(e.target.value?Number(e.target.value):null),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`No project`}),t.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]})]})})}function lze(){let e=no(),{showToast:t}=Td(),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(new Set),[c,l]=(0,y.useState)(new Set),{data:u,isLoading:d}=q({queryKey:[`pending-uploads`],queryFn:rd.list,refetchInterval:1e4}),{data:f}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),p=J({mutationFn:({id:e,data:t})=>rd.archive(e,t),onMutate:({id:e})=>{s(t=>new Set(t).add(e))},onSettled:(e,t,{id:n})=>{s(e=>{let t=new Set(e);return t.delete(n),t})},onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),e.invalidateQueries({queryKey:[`archives`]}),t(`Archived: ${n.print_name}`)},onError:e=>{t(e.message||`Failed to archive`,`error`)}}),m=J({mutationFn:e=>rd.discard(e),onMutate:e=>{l(t=>new Set(t).add(e))},onSettled:(e,t,n)=>{l(e=>{let t=new Set(e);return t.delete(n),t})},onSuccess:()=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),t(`Upload discarded`)},onError:e=>{t(e.message||`Failed to discard`,`error`)}}),h=J({mutationFn:rd.archiveAll,onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),e.invalidateQueries({queryKey:[`archives`]}),t(`Archived ${n.archived} files${n.failed>0?`, ${n.failed} failed`:``}`)},onError:e=>{t(e.message||`Failed to archive all`,`error`)}}),g=J({mutationFn:rd.discardAll,onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),t(`Discarded ${n.discarded} files`)},onError:e=>{t(e.message||`Failed to discard all`,`error`)}});return d?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})}):!u||u.length===0?null:(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(_d,{className:`border-l-4 border-l-yellow-500`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Du,{className:`w-5 h-5 text-yellow-500`}),(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Pending Uploads (`,u.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>r(!0),disabled:h.isPending,children:h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),`Archive All`]})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>a(!0),disabled:g.isPending,children:g.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Discard All`]})})]})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:`These files were uploaded via the virtual printer. Review and archive them to add to your collection.`}),(0,K.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>(0,K.jsx)(cze,{upload:e,projects:f||[],onArchive:(e,t)=>p.mutate({id:e,data:t}),onDiscard:e=>m.mutate(e),isArchiving:o.has(e.id),isDiscarding:c.has(e.id)},e.id))})]})]}),n&&(0,K.jsx)(Ad,{title:`Archive All Uploads`,message:`Are you sure you want to archive all ${u.length} pending uploads?`,confirmText:`Archive All`,onConfirm:()=>{h.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&(0,K.jsx)(Ad,{title:`Discard All Uploads`,message:`Are you sure you want to discard all ${u.length} pending uploads? This cannot be undone.`,confirmText:`Discard All`,variant:`danger`,onConfirm:()=>{g.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function uze({onClose:e}){let t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(`count`);(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(a?o(null):l?u(null):e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,a,l]);let{data:p,isLoading:m}=q({queryKey:[`tags`],queryFn:Q.getTags}),h=J({mutationFn:({oldName:e,newName:t})=>Q.renameTag(e,t),onSuccess:(e,{oldName:r,newName:i})=>{t.invalidateQueries({queryKey:[`tags`]}),t.invalidateQueries({queryKey:[`archives`]}),n(`Renamed "${r}" to "${i}" in ${e.affected} archive${e.affected===1?``:`s`}`),o(null)},onError:e=>{n(e.message||`Failed to rename tag`,`error`)}}),g=J({mutationFn:e=>Q.deleteTag(e),onSuccess:(e,r)=>{t.invalidateQueries({queryKey:[`tags`]}),t.invalidateQueries({queryKey:[`archives`]}),n(`Deleted "${r}" from ${e.affected} archive${e.affected===1?``:`s`}`),u(null)},onError:e=>{n(e.message||`Failed to delete tag`,`error`)}}),_=e=>{o(e.name),c(e.name),u(null)},v=()=>{o(null),c(``)},b=()=>{if(!a||!s.trim())return;let e=s.trim();if(e===a){v();return}h.mutate({oldName:a,newName:e})},x=e=>{e.key===`Enter`?(e.preventDefault(),b()):e.key===`Escape`&&(e.preventDefault(),v())},S=e=>{u(e),o(null)},C=()=>{l&&g.mutate(l)},w=p?.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())).sort((e,t)=>d===`count`&&t.count-e.count||e.name.localeCompare(t.name)),T=p?.reduce((e,t)=>e+t.count,0)||0;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-lg max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:`Manage Tags`})]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Search tags...`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:d,onChange:e=>f(e.target.value),children:[(0,K.jsx)(`option`,{value:`count`,children:`Sort by Count`}),(0,K.jsx)(`option`,{value:`name`,children:`Sort by Name`})]})]}),p&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:[p.length,` tag`,p.length===1?``:`s`,` across `,T,` usage`,T===1?``:`s`]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0 p-4`,children:m?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-gray`})}):w?.length?(0,K.jsx)(`div`,{className:`space-y-2`,children:w.map(e=>(0,K.jsx)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group`,children:a===e.name?(0,K.jsxs)(`div`,{className:`flex-1 flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:`flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none`,value:s,onChange:e=>c(e.target.value),onKeyDown:x,autoFocus:!0}),(0,K.jsx)($,{size:`sm`,variant:`primary`,onClick:b,disabled:!s.trim()||h.isPending,className:`p-1.5`,children:h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:v,className:`p-1.5`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):l===e.name?(0,K.jsxs)(`div`,{className:`flex-1 flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray-light flex-1`,children:[`Delete "`,e.name,`" from `,e.count,` archive`,e.count===1?``:`s`,`?`]}),(0,K.jsx)($,{size:`sm`,variant:`danger`,onClick:C,disabled:g.isPending,className:`p-1.5`,children:g.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>u(null),className:`p-1.5`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-white flex-1 truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs`,children:e.count}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(`button`,{onClick:()=>_(e),className:`p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors`,title:`Rename tag`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>S(e.name),className:`p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors`,title:`Delete tag`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})},e.name))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-bambu-gray`,children:r?`No tags match your search`:`No tags found`})}),(0,K.jsx)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:`Close`})})]})})})}function $0(e){let t=e.filename;if(t){let e=t.toLowerCase();if(e.endsWith(`.gcode`)||e.includes(`.gcode.`))return!0}return!!(e.total_layers||e.print_time_seconds)}async function e2(e,t,n,r){try{if(n===`source`){let{token:n}=await Q.createSourceSlicerToken(e),i=Q.getSourceSlicerDownloadUrl(e,n,t);VW(`${window.location.origin}${i}`,r)}else{let{token:n}=await Q.createArchiveSlicerToken(e),i=Q.getArchiveSlicerDownloadUrl(e,n,t);VW(`${window.location.origin}${i}`,r)}}catch{let i=n===`source`?Q.getSource3mfForSlicer(e,t):Q.getArchiveForSlicer(e,t);VW(`${window.location.origin}${i}`,r)}}function dze({archive:e,printerName:t,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:s=`system`,preferredSlicer:c=`bambu_studio`,useSlicerApi:l=!1,currency:u,t:d,onNavigateToArchive:f}){o&&console.log(`ArchiveCard isHighlighted=true for archive:`,e.id);let p=no(),{showToast:m}=Td(),{hasPermission:h,canModify:g}=dd(),_=UW(),v=$n(),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),O=q({queryKey:[`archive`,e.id,`delete-impact`],queryFn:()=>Q.getArchiveDeleteImpact(e.id),enabled:w,staleTime:0}),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)([]),[z,B]=(0,y.useState)(!1),[V,ee]=(0,y.useState)(!1),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(!1),[H,ae]=(0,y.useState)(!1),[oe,U]=(0,y.useState)(!1),[se,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(null),[de,fe]=(0,y.useState)(null),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(null),_e=(0,y.useRef)(null),ve=(0,y.useRef)(null),ye=(0,y.useRef)(null),{data:be}=q({queryKey:[`archive-plates`,e.id],queryFn:()=>Q.getArchivePlates(e.id),enabled:pe,staleTime:300*1e3}),xe=e.duplicate_sequence??0,Se=e.original_archive_id??null,Ce=be?.plates??[],we=be?.is_multi_plate??!1,Te=de??0,Ee=async()=>{try{let t=await Q.getArchivePlates(e.id);if(t.has_gcode===!1){m(d(`archives.platePicker.noGcode`),`info`);return}if(t.is_multi_plate&&t.plates.length>1){ge(t.plates);return}}catch{}v(`/gcode-viewer?archive=${e.id}`)},De=J({mutationFn:()=>Q.deleteArchiveTimelapse(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveTimelapse`),`error`)}}),Oe=J({mutationFn:t=>Q.uploadArchiveTimelapse(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseUploaded`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadTimelapse`),`error`)}}),ke=J({mutationFn:t=>Q.uploadSource3mf(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.source3mfAttached`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadSource3mf`),`error`)}}),Ae=J({mutationFn:()=>Q.deleteSource3mf(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.source3mfRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveSource3mf`),`error`)}}),je=J({mutationFn:t=>Q.uploadF3d(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.f3dAttached`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadF3d`),`error`)}}),Me=J({mutationFn:()=>Q.deleteF3d(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.f3dRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveF3d`),`error`)}}),Ne=J({mutationFn:()=>Q.scanArchiveTimelapse(e.id),onSuccess:e=>{e.status===`attached`?(p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseAttached`,{filename:e.filename}))):e.status===`exists`?m(d(`archives.toast.timelapseAlreadyAttached`)):e.status===`not_found`&&e.available_files&&e.available_files.length>0?(R(e.available_files),I(!0)):m(e.message||d(`archives.toast.noMatchingTimelapse`),`warning`)},onError:e=>{m(e.message||d(`archives.toast.failedScanTimelapse`),`error`)}}),Pe=J({mutationFn:t=>Q.selectArchiveTimelapse(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseAttached`,{filename:e.filename})),I(!1),R([])},onError:e=>{m(e.message||d(`archives.toast.failedAttachTimelapse`),`error`)}}),Fe=J({mutationFn:t=>Q.deleteArchive(e.id,t),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.archiveDeleted`))},onError:()=>{m(d(`archives.toast.failedDeleteArchive`),`error`)}}),Ie=J({mutationFn:()=>Q.toggleFavorite(e.id),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(e.is_favorite?d(`archives.toast.addedToFavorites`):d(`archives.toast.removedFromFavorites`))}}),{data:Le}=q({queryKey:[`archive-folders`,e.id],queryFn:()=>Q.getLibraryFoldersByArchive(e.id)}),Re=J({mutationFn:t=>Q.updateArchive(e.id,{project_id:t}),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),p.invalidateQueries({queryKey:[`projects`]}),m(d(`archives.toast.projectUpdated`))},onError:()=>{m(d(`archives.toast.failedUpdateProject`),`error`)}}),ze=e=>{e.preventDefault(),ue({x:e.clientX,y:e.clientY})},Be=[...$0(e)?[{label:d(`archives.menu.print`),icon:(0,K.jsx)(Tl,{className:`w-4 h-4`}),onClick:()=>x(!0),disabled:!e.file_path||!g(`archives`,`reprint`,e.created_by_id),title:e.file_path?g(`archives`,`reprint`,e.created_by_id)?void 0:d(`archives.permission.noReprint`):d(`archives.card.noFileForReprint`)},{label:d(`archives.menu.schedule`),icon:(0,K.jsx)(Zo,{className:`w-4 h-4`}),onClick:()=>ie(!0),disabled:!e.file_path||!h(`queue:create`),title:e.file_path?h(`queue:create`)?void 0:d(`archives.permission.noAddToQueue`):d(`archives.card.noFileForReprint`)},{label:d(`archives.menu.openInBambuStudio`),icon:(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)},disabled:!e.file_path,title:e.file_path?void 0:d(`archives.card.noFileForReprint`)}]:[{label:d(`archives.menu.slice`),icon:l?(0,K.jsx)(ks,{className:`w-4 h-4`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{if(l)C(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)}}}],{label:e.external_url?d(`archives.menu.externalLink`):d(`archives.menu.viewOnMakerWorld`),icon:(0,K.jsx)(bc,{className:`w-4 h-4`}),onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url},{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.preview3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>{Ee()}},{label:d(`archives.menu.viewTimelapse`),icon:(0,K.jsx)(ic,{className:`w-4 h-4`}),onClick:()=>P(!0),disabled:!e.timelapse_path},{label:d(`archives.menu.scanForTimelapse`),icon:(0,K.jsx)(Il,{className:`w-4 h-4`}),onClick:()=>Ne.mutate(),disabled:!e.printer_id||!!e.timelapse_path||Ne.isPending||!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.uploadTimelapse`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ye.current?.click(),disabled:!!e.timelapse_path||!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},...e.timelapse_path?[{label:d(`archives.menu.removeTimelapse`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>ce(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:e.source_3mf_path?d(`archives.menu.downloadSource3mf`):d(`archives.menu.uploadSource3mf`),icon:(0,K.jsx)($s,{className:`w-4 h-4`}),onClick:()=>{e.source_3mf_path?Q.downloadSource3mf(e.id).catch(e=>{console.error(`Source 3MF download failed:`,e)}):_e.current?.click()},disabled:!e.source_3mf_path&&!g(`archives`,`update`,e.created_by_id),title:!e.source_3mf_path&&!g(`archives`,`update`,e.created_by_id)?d(`archives.permission.noUploadFiles`):void 0},...e.source_3mf_path?[{label:d(`archives.menu.replaceSource3mf`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>_e.current?.click(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.removeSource3mf`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>ae(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:e.f3d_path?d(`archives.menu.replaceF3d`):d(`archives.menu.uploadF3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>ve.current?.click(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},...e.f3d_path?[{label:d(`archives.menu.downloadF3d`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})}},{label:d(`archives.menu.removeF3d`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>U(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.download`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},disabled:!h(`archives:read`),title:h(`archives:read`)?void 0:d(`archives.permission.noDownload`)},{label:d(`archives.menu.copyDownloadLink`),icon:(0,K.jsx)(Ms,{className:`w-4 h-4`}),onClick:()=>{let t=`${window.location.origin}${Q.getArchiveDownload(e.id)}`;navigator.clipboard.writeText(t).then(()=>{m(d(`archives.toast.linkCopied`))}).catch(()=>{m(d(`archives.toast.failedCopyLink`),`error`)})},disabled:!h(`archives:read`),title:h(`archives:read`)?void 0:d(`archives.permission.noCopyLink`)},{label:d(`archives.menu.qrCode`),icon:(0,K.jsx)(El,{className:`w-4 h-4`}),onClick:()=>B(!0)},{label:e.photos?.length?d(`archives.menu.viewPhotosCount`,{count:e.photos.length}):d(`archives.menu.viewPhotos`),icon:(0,K.jsx)(Qo,{className:`w-4 h-4`}),onClick:()=>ee(!0),disabled:!e.photos?.length},{label:d(`archives.menu.projectPage`),icon:(0,K.jsx)(nc,{className:`w-4 h-4`}),onClick:()=>ne(!0)},{label:``,divider:!0,onClick:()=>{}},{label:e.is_favorite?d(`archives.menu.removeFromFavorites`):d(`archives.menu.addToFavorites`),icon:(0,K.jsx)(su,{className:`w-4 h-4 ${e.is_favorite?`fill-yellow-400 text-yellow-400`:``}`}),onClick:()=>Ie.mutate(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.edit`),icon:(0,K.jsx)(vl,{className:`w-4 h-4`}),onClick:()=>A(!0),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.printLog`),icon:(0,K.jsx)(kc,{className:`w-4 h-4`}),onClick:()=>M(!0)},...e.project_id&&e.project_name?[{label:d(`archives.menu.goToProject`,{name:e.project_name}),icon:(0,K.jsx)(sc,{className:`w-4 h-4 text-bambu-green`}),onClick:()=>window.location.href=`/projects`}]:[],{label:d(`archives.menu.addToProject`),icon:(0,K.jsx)(sc,{className:`w-4 h-4`}),onClick:()=>{},disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`),submenuSearchPlaceholder:(a?.filter(e=>e.status===`active`).length??0)>5?d(`archives.menu.searchProjects`):void 0,submenu:(()=>{let t=[];if(e.project_id&&t.push({label:d(`archives.menu.removeFromProject`),icon:(0,K.jsx)(Ru,{className:`w-4 h-4`}),onClick:()=>Re.mutate(null),disabled:!g(`archives`,`update`,e.created_by_id)}),!a)t.push({label:d(`archives.menu.loading`),icon:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),onClick:()=>{},disabled:!0});else{let n=a.filter(e=>e.status===`active`).sort((e,t)=>e.name.localeCompare(t.name));n.length===0?t.push({label:d(`archives.menu.noProjectsAvailable`),icon:(0,K.jsx)(sc,{className:`w-4 h-4 opacity-50`}),onClick:()=>{},disabled:!0}):n.forEach(n=>{t.push({label:n.name,icon:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:n.color||`#888`}}),onClick:()=>Re.mutate(n.id),disabled:e.project_id===n.id||!g(`archives`,`update`,e.created_by_id)})})}return t})()},{label:d(n?`archives.menu.deselect`:`archives.menu.select`),icon:n?(0,K.jsx)(iu,{className:`w-4 h-4`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),onClick:()=>r(e.id)},{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.delete`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>T(!0),danger:!0,disabled:!g(`archives`,`delete`,e.created_by_id),title:g(`archives`,`delete`,e.created_by_id)?void 0:d(`archives.permission.noDelete`)}];return(0,K.jsxs)(_d,{"data-archive-id":e.id,className:`relative flex flex-col group ${n?`ring-2 ring-bambu-green`:``} ${i?`cursor-pointer`:``}`,style:o?{outline:`4px solid #facc15`,outlineOffset:`2px`}:void 0,onContextMenu:ze,onClick:i?()=>r(e.id):void 0,children:[i&&(0,K.jsx)(`button`,{className:`absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors`,onClick:t=>{t.stopPropagation(),r(e.id)},children:n?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5 text-white`})}),(0,K.jsxs)(`div`,{className:`aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl`,onMouseEnter:()=>me(!0),onMouseLeave:()=>me(!1),children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:de!==null&&Ce.length>0?Q.getArchivePlateThumbnail(e.id,Ce[Te]?.index??0):Q.getArchiveThumbnail(e.id),alt:e.print_name||e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(Mc,{className:`w-12 h-12 text-bambu-dark-tertiary`})}),we&&Ce.length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>{e.stopPropagation(),fe(e=>{let t=e??0;return t>0?t-1:Ce.length-1})},title:d(`archives.card.previousPlate`),children:(0,K.jsx)(ss,{className:`w-4 h-4 text-white`})}),(0,K.jsx)(`button`,{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>{e.stopPropagation(),fe(e=>{let t=e??0;return t(0,K.jsx)(`button`,{className:`w-2 h-2 rounded-full transition-colors ${t===Te?`bg-bambu-green`:`bg-white/50 hover:bg-white/80`}`,onClick:e=>{e.stopPropagation(),fe(t)},title:e.name||d(`archives.card.plateNumber`,{index:e.index})},e.index))})]}),(0,K.jsx)(`button`,{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`} ${i?`left-10`:``}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();ue({x:t.left,y:t.bottom+4})},title:d(`archives.card.moreOptions`),children:(0,K.jsx)(Ws,{className:`w-5 h-5 text-white`})}),(0,K.jsx)(`button`,{className:`absolute top-2 right-2 p-1 rounded transition-colors ${g(`archives`,`update`,e.created_by_id)?`bg-black/50 hover:bg-black/70`:`bg-black/30 cursor-not-allowed`}`,onClick:t=>{t.stopPropagation(),g(`archives`,`update`,e.created_by_id)&&Ie.mutate()},disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?e.is_favorite?d(`archives.card.removeFromFavorites`):d(`archives.card.addToFavorites`):d(`archives.permission.noUpdateArchives`),children:(0,K.jsx)(su,{className:`w-5 h-5 ${e.is_favorite?`text-yellow-400 fill-yellow-400`:`text-white`} ${g(`archives`,`update`,e.created_by_id)?``:`opacity-50`}`})}),(e.status===`failed`||e.status===`aborted`)&&(0,K.jsx)(`div`,{className:`absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white`,children:e.status===`aborted`?d(`archives.card.cancelled`):d(`archives.card.failed`)}),e.duplicate_count>0&&xe>0&&Se&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f?.(Se)},className:`absolute top-2 right-12 px-2 py-1 rounded text-xs bg-purple-500/80 hover:bg-purple-600/90 text-white flex items-center gap-1 transition-colors cursor-pointer`,title:d(`archives.viewOriginalPrint`,{id:Se}),children:[(0,K.jsx)(Ms,{className:`w-3 h-3`}),`#`,xe]}),e.duplicate_count>0&&xe===0&&(0,K.jsxs)(`span`,{className:`absolute top-2 right-12 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1`,title:`${e.duplicate_count} reprint${e.duplicate_count===1?``:`s`}`,children:[(0,K.jsx)(_c,{className:`w-3 h-3`}),`+`,e.duplicate_count]}),e.source_3mf_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:t=>{t.stopPropagation();let n=(e.print_name||e.filename||`source`).replace(/\.gcode\.3mf$/i,``)+`_source`;e2(e.id,n,`source`,c)},title:d(`archives.card.openSource3mf`),children:(0,K.jsx)($s,{className:`w-4 h-4 text-orange-400`})}),e.f3d_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 ${e.source_3mf_path?`left-12`:`left-2`} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:t=>{t.stopPropagation(),Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})},title:d(`archives.card.downloadF3d`),children:(0,K.jsx)(Wo,{className:`w-4 h-4 text-cyan-400`})}),(0,K.jsx)(`button`,{className:`absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),Ee()},title:d(`archives.card.preview3d`),children:(0,K.jsx)(Rc,{className:`w-4 h-4 text-white`})}),e.timelapse_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 right-12 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),P(!0)},title:d(`archives.card.viewTimelapse`),children:(0,K.jsx)(ic,{className:`w-4 h-4 text-bambu-green`})}),e.photos&&e.photos.length>0&&(0,K.jsxs)(`button`,{className:`absolute bottom-2 ${e.timelapse_path?`right-[5.5rem]`:`right-12`} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),ee(!0)},title:e.photos.length===1?d(`archives.card.viewPhoto`):d(`archives.card.viewPhotos`,{count:e.photos.length}),children:[(0,K.jsx)(Qo,{className:`w-4 h-4 text-blue-400`}),e.photos.length>1&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center`,children:e.photos.length})]}),Le&&Le.length>0&&(0,K.jsx)(wi,{to:`/files?folder=${Le[0].id}`,className:`absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>e.stopPropagation(),title:d(`archives.card.openFolder`,{name:Le[0].name}),style:{left:e.source_3mf_path?e.f3d_path?`5.5rem`:`3rem`:e.f3d_path?`3rem`:`0.5rem`},children:(0,K.jsx)(cc,{className:`w-4 h-4 text-yellow-400`})})]}),(0,K.jsxs)(yd,{className:`p-4 flex-1 flex flex-col`,children:[(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray/70 mb-1`,children:[`#`,e.id]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,K.jsx)(`h3`,{className:`min-w-0 font-medium text-white truncate`,children:e.print_name||e.filename}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,className:`p-1 sm:p-1.5 shrink-0`,onClick:()=>A(!0),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?d(`archives.card.edit`):d(`archives.card.noPermissionEdit`),children:(0,K.jsx)(vl,{className:`w-3 h-3 sm:w-4 sm:h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:t}),(()=>{let t=QU(e.bed_type);return t?(0,K.jsx)(`img`,{src:t.icon,alt:t.label,title:t.label,className:`w-4 h-4 flex-shrink-0`}):null})(),(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${$0(e)?`bg-bambu-green/20 text-bambu-green`:`bg-orange-500/20 text-orange-400`}`,title:$0(e)?d(`archives.card.slicedFile`):d(`archives.card.sourceFile`),children:$0(e)?d(`archives.card.gcode`):d(`archives.card.source`)}),e.content_hash&&(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded font-mono bg-bambu-dark-tertiary/50 text-bambu-gray-light opacity-0 transition-opacity duration-150 group-hover:opacity-100`,title:`SHA256: ${e.content_hash}`,children:e.content_hash.slice(0,8).toUpperCase()}),e.project_name&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]`,style:{backgroundColor:`${a?.find(t=>t.id===e.project_id)?.color||`#6b7280`}20`,color:a?.find(t=>t.id===e.project_id)?.color||`#6b7280`},title:d(`archives.card.project`,{name:e.project_name}),children:e.project_name}),e.run_count>1&&(0,K.jsx)(`button`,{className:`text-[10px] px-1.5 py-0.5 rounded font-medium bg-bambu-orange/20 text-bambu-orange hover:bg-bambu-orange/30 transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),M(!0)},title:d(`archives.card.runsBadgeTitle`,{count:e.run_count,successful:e.successful_run_count,failed:e.failed_run_count}),children:d(`archives.card.runsBadge`,{count:e.run_count})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]`,children:[(e.print_time_seconds||e.actual_time_seconds)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:e.time_accuracy?`Estimated: ${Cf(e.print_time_seconds||0)}\nActual: ${Cf(e.actual_time_seconds||0)}\nAccuracy: ${e.time_accuracy.toFixed(0)}%`:e.actual_time_seconds?`Actual: ${Cf(e.actual_time_seconds)}`:`Estimated: ${Cf(e.print_time_seconds||0)}`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(e.actual_time_seconds||e.print_time_seconds||0),e.time_accuracy&&(0,K.jsxs)(`span`,{className:`text-[10px] px-1 rounded ${e.time_accuracy>=95&&e.time_accuracy<=105?`bg-bambu-green/20 text-bambu-green`:e.time_accuracy>105?`bg-blue-500/20 text-blue-400`:`bg-orange-500/20 text-orange-400`}`,children:[e.time_accuracy>100?`+`:``,(e.time_accuracy-100).toFixed(0),`%`]})]}),e.filament_used_grams&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-3 h-3`}),e.filament_used_grams.toFixed(1),`g`]}),(e.cost!=null||e.energy_cost!=null)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-bambu-gray`,children:[e.cost!=null&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Os,{className:`w-3 h-3`}),u,e.cost.toFixed(2)]}),e.energy_cost!=null&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:`${d(`stats.energyUsed`)}: ${e.energy_kwh?.toFixed(3)||`N/A`} kWh`,children:[(0,K.jsx)(Bu,{className:`w-3 h-3`}),u,e.energy_cost.toFixed(2)]})]}),(e.layer_height||e.total_layers)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),e.total_layers&&(0,K.jsx)(`span`,{children:e.total_layers===1?d(`archives.card.layer`,{count:e.total_layers}):d(`archives.card.layers`,{count:e.total_layers})}),e.total_layers&&e.layer_height&&(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`·`}),e.layer_height&&(0,K.jsxs)(`span`,{children:[e.layer_height,`mm`]})]}),e.object_count!=null&&e.object_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:e.object_count===1?d(`archives.card.object`,{count:e.object_count}):d(`archives.card.objects`,{count:e.object_count}),children:[(0,K.jsx)(Wo,{className:`w-3 h-3`}),e.object_count===1?d(`archives.card.object`,{count:e.object_count}):d(`archives.card.objects`,{count:e.object_count})]}),e.sliced_for_model&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:d(`archives.card.slicedFor`,{model:e.sliced_for_model}),children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),e.sliced_for_model]}),e.filament_type&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 col-span-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.filament_type}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e},title:e},t))})]})]}),(e.tags||e.notes)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,children:[e.notes&&(0,K.jsx)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs`,title:e.notes,children:(0,K.jsx)(lu,{className:`w-3 h-3`})}),e.tags?.split(`,`).map((e,t)=>(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs`,children:e.trim()},t))]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`span`,{children:bf(e.created_at,s)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.created_by_username&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,title:d(`archives.card.uploadedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]}),(0,K.jsx)(`span`,{children:Cd(e.file_size)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 mt-3`,children:[$0(e)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>x(!0),disabled:!e.file_path||!g(`archives`,`reprint`,e.created_by_id),title:e.file_path?g(`archives`,`reprint`,e.created_by_id)?void 0:d(`archives.card.noPermissionReprint`):d(`archives.card.noFileForReprint`),children:[(0,K.jsx)(Tl,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.reprint`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>ie(!0),disabled:!e.file_path||!h(`queue:create`),title:e.file_path?h(`queue:create`)?d(`archives.card.schedulePrint`):d(`archives.permission.noAddToQueue`):d(`archives.card.noFileForReprint`),children:[(0,K.jsx)(Zo,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.schedule`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)},title:d(`archives.card.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-3 h-3 sm:w-4 sm:h-4`})})]}):(0,K.jsxs)($,{variant:`primary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>{if(l)C(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)}},title:d(l?`slice.title`:`archives.card.openInBambuStudioToSlice`),children:[l?(0,K.jsx)(ks,{className:`w-3 h-3 flex-shrink-0`}):(0,K.jsx)(Js,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.slice`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url,title:e.external_url?d(`archives.card.externalLink`):e.makerworld_url?d(`archives.card.makerWorld`,{designer:e.designer||d(`archives.card.viewProject`)}):d(`archives.card.noExternalLink`),children:(0,K.jsx)(bc,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!e.external_url&&!e.makerworld_url?`opacity-20`:``}`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},title:d(`archives.card.download`),children:(0,K.jsx)(Vs,{className:`w-3 h-3 sm:w-4 sm:h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>T(!0),disabled:!g(`archives`,`delete`,e.created_by_id),title:g(`archives`,`delete`,e.created_by_id)?d(`archives.card.delete`):d(`archives.card.noPermissionDelete`),children:(0,K.jsx)(bu,{className:`w-3 h-3 sm:w-4 sm:h-4 text-red-400`})})]})]}),k&&(0,K.jsx)(qW,{archive:e,onClose:()=>A(!1)}),j&&(0,K.jsx)(JW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>M(!1)}),he&&(0,K.jsx)(NW,{plates:he,onSelect:t=>{ge(null),v(`/gcode-viewer?archive=${e.id}&plate=${t}`)},onClose:()=>ge(null)}),b&&(0,K.jsx)(oW,{mode:`reprint`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>x(!1)}),S&&(0,K.jsx)(RW,{source:{kind:`archive`,id:e.id,filename:e.print_name||e.filename||`model`},onClose:()=>C(!1)}),w&&(0,K.jsxs)(Ad,{title:d(`archives.modal.deleteArchive`),message:d(`archives.modal.deleteConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.deleteButton`),variant:`danger`,confirmDisabled:(O.data?.currently_printing??0)>0,onConfirm:()=>{Fe.mutate(E),T(!1),D(!1)},onCancel:()=>{T(!1),D(!1)},children:[(O.data?.related_queue_items??0)>0&&(0,K.jsx)(`div`,{className:(O.data?.currently_printing??0)>0?`text-sm text-red-400 mb-2`:`text-sm text-amber-400 mb-2`,children:(O.data?.currently_printing??0)>0?d(`archives.modal.deleteBlockedByPrinting`,{count:O.data.currently_printing}):d(`archives.modal.deleteQueueItemsWarning`,{count:O.data.related_queue_items})}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer text-sm text-bambu-gray`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 accent-red-500`,checked:E,onChange:e=>D(e.target.checked)}),(0,K.jsx)(`span`,{children:d(`archives.modal.deletePurgeStats`)})]})]}),H&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeSource3mf`),message:d(`archives.modal.removeSource3mfConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{Ae.mutate(),ae(!1)},onCancel:()=>ae(!1)}),oe&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeF3d`),message:d(`archives.modal.removeF3dConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{Me.mutate(),U(!1)},onCancel:()=>U(!1)}),se&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeTimelapse`),message:d(`archives.modal.removeTimelapseConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{De.mutate(),ce(!1)},onCancel:()=>ce(!1)}),le&&(0,K.jsx)(YW,{x:le.x,y:le.y,items:Be,onClose:()=>ue(null)}),N&&e.timelapse_path&&(0,K.jsx)(Q0,{src:Q.getArchiveTimelapse(e.id),title:d(`archives.modal.timelapse`,{name:e.print_name||e.filename}),downloadFilename:`${e.print_name||e.filename}_timelapse.mp4`,archiveId:e.id,onClose:()=>P(!1),onEdit:()=>{p.invalidateQueries({queryKey:[`archives`]}),P(!1)}}),F&&L.length>0&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:d(`archives.modal.selectTimelapse`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 mt-1`,children:d(`archives.modal.selectTimelapseDesc`)})]}),(0,K.jsx)(`button`,{onClick:()=>{I(!1),R([])},className:`text-gray-400 hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 p-2`,children:L.map(e=>(0,K.jsxs)(`button`,{onClick:()=>Pe.mutate(e.name),disabled:Pe.isPending,className:`w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50`,children:[(0,K.jsx)(ic,{className:`w-8 h-8 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-400`,children:[Cd(e.size),e.mtime&&` • ${bf(e.mtime,s)}`]})]})]},e.name))}),(0,K.jsx)(`div`,{className:`p-4 border-t border-gray-700`,children:(0,K.jsx)($,{variant:`secondary`,onClick:()=>{I(!1),R([])},className:`w-full`,children:`Cancel`})})]})}),z&&(0,K.jsx)(XW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>B(!1)}),V&&e.photos&&e.photos.length>0&&(0,K.jsx)(ZW,{archiveId:e.id,archiveName:e.print_name||e.filename,photos:e.photos,onClose:()=>ee(!1),onDelete:async t=>{try{await Q.deleteArchivePhoto(e.id,t),p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.photoDeleted`))}catch{m(d(`archives.toast.failedDeletePhoto`),`error`)}}}),te&&(0,K.jsx)(Z0,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>ne(!1)}),re&&(0,K.jsx)(oW,{mode:`add-to-queue`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>ie(!1)}),(0,K.jsx)(`input`,{ref:_e,type:`file`,accept:`.3mf`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&ke.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ve,type:`file`,accept:`.f3d`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&je.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ye,type:`file`,accept:`.mp4,.avi,.mkv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Oe.mutate(t),e.target.value=``}})]})}function fze({archive:e,printerName:t,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,preferredSlicer:s=`bambu_studio`,useSlicerApi:c=!1,t:l,onNavigateToArchive:u}){let d=no(),{showToast:f}=Td(),{hasPermission:p,canModify:m}=dd(),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),w=q({queryKey:[`archive`,e.id,`delete-impact`],queryFn:()=>Q.getArchiveDeleteImpact(e.id),enabled:b,staleTime:0}),T=$n(),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)([]),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!1),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(!1),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(null),ce=(0,y.useRef)(null),le=(0,y.useRef)(null),ue=(0,y.useRef)(null),[de,fe]=(0,y.useState)(null),pe=e.duplicate_sequence??0,me=e.original_archive_id??null,he=async()=>{try{let t=await Q.getArchivePlates(e.id);if(t.is_multi_plate&&t.plates.length>1){fe(t.plates);return}}catch{}T(`/gcode-viewer?archive=${e.id}`)},ge=J({mutationFn:()=>Q.deleteArchiveTimelapse(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveTimelapse`),`error`)}}),_e=J({mutationFn:t=>Q.uploadArchiveTimelapse(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseUploaded`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadTimelapse`),`error`)}}),ve=J({mutationFn:t=>Q.uploadSource3mf(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.source3mfAttached`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadSource3mf`),`error`)}}),ye=J({mutationFn:()=>Q.deleteSource3mf(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.source3mfRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveSource3mf`),`error`)}}),be=J({mutationFn:t=>Q.uploadF3d(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.f3dAttached`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadF3d`),`error`)}}),xe=J({mutationFn:()=>Q.deleteF3d(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.f3dRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveF3d`),`error`)}}),Se=J({mutationFn:()=>Q.scanArchiveTimelapse(e.id),onSuccess:e=>{e.status===`attached`?(d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseAttached`,{filename:e.filename}))):e.status===`exists`?f(l(`archives.toast.timelapseAlreadyAttached`)):e.status===`not_found`&&e.available_files&&e.available_files.length>0?(L(e.available_files),F(!0)):f(e.message||l(`archives.toast.noMatchingTimelapse`),`warning`)},onError:e=>{f(e.message||l(`archives.toast.failedScanTimelapse`),`error`)}}),Ce=J({mutationFn:t=>Q.selectArchiveTimelapse(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseAttached`,{filename:e.filename})),F(!1),L([])},onError:e=>{f(e.message||l(`archives.toast.failedAttachTimelapse`),`error`)}}),we=J({mutationFn:t=>Q.deleteArchive(e.id,t),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.archiveDeleted`))},onError:()=>{f(l(`archives.toast.failedDeleteArchive`),`error`)}}),Te=J({mutationFn:()=>Q.toggleFavorite(e.id),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(e.is_favorite?l(`archives.toast.addedToFavorites`):l(`archives.toast.removedFromFavorites`))}}),{data:Ee}=q({queryKey:[`archive-folders`,e.id],queryFn:()=>Q.getLibraryFoldersByArchive(e.id)}),De=J({mutationFn:t=>Q.updateArchive(e.id,{project_id:t}),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),d.invalidateQueries({queryKey:[`projects`]}),f(l(`archives.toast.projectUpdated`))},onError:()=>{f(l(`archives.toast.failedUpdateProject`),`error`)}}),Oe=e=>{e.preventDefault(),se({x:e.clientX,y:e.clientY})},ke=[...$0(e)?[{label:l(`archives.menu.print`),icon:(0,K.jsx)(Tl,{className:`w-4 h-4`}),onClick:()=>D(!0),disabled:!e.file_path||!m(`archives`,`reprint`,e.created_by_id),title:e.file_path?m(`archives`,`reprint`,e.created_by_id)?void 0:l(`archives.permission.noReprint`):l(`archives.card.noFileForReprint`)},{label:l(`archives.menu.schedule`),icon:(0,K.jsx)(Zo,{className:`w-4 h-4`}),onClick:()=>j(!0),disabled:!e.file_path||!p(`queue:create`),title:e.file_path?p(`queue:create`)?void 0:l(`archives.permission.noAddToQueue`):l(`archives.card.noFileForReprint`)},{label:l(`archives.menu.openInBambuStudio`),icon:(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)},disabled:!e.file_path,title:e.file_path?void 0:l(`archives.card.noFileForReprint`)}]:[{label:l(`archives.menu.slice`),icon:c?(0,K.jsx)(ks,{className:`w-4 h-4`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{if(c)k(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)}}}],{label:e.external_url?l(`archives.menu.externalLink`):l(`archives.menu.viewOnMakerWorld`),icon:(0,K.jsx)(bc,{className:`w-4 h-4`}),onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url},{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.preview3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>{he()}},{label:l(`archives.menu.viewTimelapse`),icon:(0,K.jsx)(ic,{className:`w-4 h-4`}),onClick:()=>N(!0),disabled:!e.timelapse_path},{label:l(`archives.menu.scanForTimelapse`),icon:(0,K.jsx)(Il,{className:`w-4 h-4`}),onClick:()=>Se.mutate(),disabled:!e.printer_id||!!e.timelapse_path||Se.isPending||!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.uploadTimelapse`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ue.current?.click(),disabled:!!e.timelapse_path||!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},...e.timelapse_path?[{label:l(`archives.menu.removeTimelapse`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>oe(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:e.source_3mf_path?l(`archives.menu.downloadSource3mf`):l(`archives.menu.uploadSource3mf`),icon:(0,K.jsx)($s,{className:`w-4 h-4`}),onClick:()=>{e.source_3mf_path?Q.downloadSource3mf(e.id).catch(e=>{console.error(`Source 3MF download failed:`,e)}):ce.current?.click()},disabled:!e.source_3mf_path&&!m(`archives`,`update`,e.created_by_id),title:!e.source_3mf_path&&!m(`archives`,`update`,e.created_by_id)?l(`archives.permission.noUploadFiles`):void 0},...e.source_3mf_path?[{label:l(`archives.menu.replaceSource3mf`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ce.current?.click(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.removeSource3mf`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>re(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:e.f3d_path?l(`archives.menu.replaceF3d`):l(`archives.menu.uploadF3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>le.current?.click(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},...e.f3d_path?[{label:l(`archives.menu.downloadF3d`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})}},{label:l(`archives.menu.removeF3d`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>H(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.download`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},disabled:!p(`archives:read`),title:p(`archives:read`)?void 0:l(`archives.permission.noDownload`)},{label:l(`archives.menu.copyDownloadLink`),icon:(0,K.jsx)(Ms,{className:`w-4 h-4`}),onClick:()=>{let t=`${window.location.origin}${Q.getArchiveDownload(e.id)}`;navigator.clipboard.writeText(t).then(()=>{f(l(`archives.toast.linkCopied`))}).catch(()=>{f(l(`archives.toast.failedCopyLink`),`error`)})},disabled:!p(`archives:read`),title:p(`archives:read`)?void 0:l(`archives.permission.noCopyLink`)},{label:l(`archives.menu.qrCode`),icon:(0,K.jsx)(El,{className:`w-4 h-4`}),onClick:()=>z(!0)},{label:e.photos?.length?l(`archives.menu.viewPhotosCount`,{count:e.photos.length}):l(`archives.menu.viewPhotos`),icon:(0,K.jsx)(Qo,{className:`w-4 h-4`}),onClick:()=>V(!0),disabled:!e.photos?.length},{label:l(`archives.menu.projectPage`),icon:(0,K.jsx)(nc,{className:`w-4 h-4`}),onClick:()=>te(!0)},{label:``,divider:!0,onClick:()=>{}},{label:e.is_favorite?l(`archives.menu.removeFromFavorites`):l(`archives.menu.addToFavorites`),icon:(0,K.jsx)(su,{className:`w-4 h-4 ${e.is_favorite?`fill-yellow-400 text-yellow-400`:``}`}),onClick:()=>Te.mutate(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.edit`),icon:(0,K.jsx)(vl,{className:`w-4 h-4`}),onClick:()=>g(!0),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.printLog`),icon:(0,K.jsx)(kc,{className:`w-4 h-4`}),onClick:()=>v(!0)},...e.project_id&&e.project_name?[{label:l(`archives.menu.goToProject`,{name:e.project_name}),icon:(0,K.jsx)(sc,{className:`w-4 h-4 text-bambu-green`}),onClick:()=>window.location.href=`/projects`}]:[],{label:l(`archives.menu.addToProject`),icon:(0,K.jsx)(sc,{className:`w-4 h-4`}),onClick:()=>{},submenuSearchPlaceholder:(a?.filter(e=>e.status===`active`).length??0)>5?l(`archives.menu.searchProjects`):void 0,submenu:(()=>{let t=[];if(e.project_id&&t.push({label:l(`archives.menu.removeFromProject`),icon:(0,K.jsx)(Ru,{className:`w-4 h-4`}),onClick:()=>De.mutate(null)}),!a)t.push({label:l(`archives.menu.loading`),icon:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),onClick:()=>{},disabled:!0});else{let n=a.filter(e=>e.status===`active`).sort((e,t)=>e.name.localeCompare(t.name));n.length===0?t.push({label:l(`archives.menu.noProjectsAvailable`),icon:(0,K.jsx)(sc,{className:`w-4 h-4 opacity-50`}),onClick:()=>{},disabled:!0}):n.forEach(n=>{t.push({label:n.name,icon:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:n.color||`#888`}}),onClick:()=>De.mutate(n.id),disabled:e.project_id===n.id})})}return t})()},{label:l(n?`archives.menu.deselect`:`archives.menu.select`),icon:n?(0,K.jsx)(iu,{className:`w-4 h-4`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),onClick:()=>r(e.id)},{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.delete`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>x(!0),danger:!0,disabled:!m(`archives`,`delete`,e.created_by_id),title:m(`archives`,`delete`,e.created_by_id)?void 0:l(`archives.permission.noDelete`)}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"data-archive-id":e.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?`bg-bambu-green/10`:``}`,style:o?{outline:`4px solid #facc15`,outlineOffset:`-4px`}:void 0,onContextMenu:Oe,children:[(0,K.jsxs)(`div`,{className:`col-span-1 flex items-center gap-2`,children:[i&&(0,K.jsx)(`button`,{onClick:()=>r(e.id),children:n?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray`})}),e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:``,className:`w-10 h-10 object-cover rounded`}):(0,K.jsx)(`div`,{className:`w-10 h-10 bg-bambu-dark rounded flex items-center justify-center`,children:(0,K.jsx)(Mc,{className:`w-5 h-5 text-bambu-dark-tertiary`})})]}),(0,K.jsxs)(`div`,{className:`col-span-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-white text-sm truncate`,children:e.print_name||e.filename}),(e.status===`failed`||e.status===`aborted`)&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-status-error/80 text-white flex-shrink-0`,children:e.status===`aborted`?l(`archives.card.cancelled`):l(`archives.card.failed`)}),e.duplicate_count>0&&pe>0&&me&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),u?.(me)},className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-purple-500/80 hover:bg-purple-600/90 text-white flex-shrink-0 transition-colors flex items-center gap-1`,title:l(`archives.viewOriginalPrint`,{id:me}),children:[(0,K.jsx)(Ms,{className:`w-3 h-3`}),`#`,pe]}),e.duplicate_count>0&&pe===0&&(0,K.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-purple-500/80 text-white flex-shrink-0 flex items-center gap-1`,title:`${e.duplicate_count} reprint${e.duplicate_count===1?``:`s`}`,children:[(0,K.jsx)(_c,{className:`w-3 h-3`}),`+`,e.duplicate_count]}),e.timelapse_path&&(0,K.jsx)(`span`,{title:l(`archives.list.hasTimelapse`),children:(0,K.jsx)(ic,{className:`w-3.5 h-3.5 text-bambu-green flex-shrink-0`})}),Ee&&Ee.length>0&&(0,K.jsx)(wi,{to:`/files?folder=${Ee[0].id}`,className:`flex-shrink-0`,title:l(`archives.card.openFolder`,{name:Ee[0].name}),onClick:e=>e.stopPropagation(),children:(0,K.jsx)(cc,{className:`w-3.5 h-3.5 text-yellow-400`})})]}),(e.filament_type||e.sliced_for_model)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[e.sliced_for_model&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex items-center gap-1`,title:l(`archives.card.slicedFor`,{model:e.sliced_for_model}),children:[(0,K.jsx)(Tl,{className:`w-2.5 h-2.5`}),e.sliced_for_model]}),(()=>{let t=QU(e.bed_type);return t?(0,K.jsx)(`img`,{src:t.icon,alt:t.label,title:t.label,className:`w-3.5 h-3.5 flex-shrink-0`}):null})(),e.sliced_for_model&&e.filament_type&&(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`·`}),e.filament_type&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.filament_type}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full border border-black/20`,style:{backgroundColor:e},title:e},t))})]})]}),(0,K.jsx)(`div`,{className:`col-span-2 text-sm text-bambu-gray truncate`,children:t}),(0,K.jsxs)(`div`,{className:`col-span-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(`div`,{children:yf(e.created_at)}),e.created_by_username&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-xs opacity-75`,title:l(`archives.card.uploadedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-sm text-bambu-gray`,children:Cd(e.file_size)}),(0,K.jsxs)(`div`,{className:`col-span-2 flex justify-end gap-1`,children:[$0(e)&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>D(!0),disabled:!m(`archives`,`reprint`,e.created_by_id),title:m(`archives`,`reprint`,e.created_by_id)?l(`archives.card.reprint`):l(`archives.card.noPermissionReprint`),className:`text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)},title:l(`archives.card.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-4 h-4`})}),(e.external_url||e.makerworld_url)&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>window.open(e.external_url||e.makerworld_url,`_blank`),title:e.external_url?l(`archives.card.externalLink`):`MakerWorld`,children:(0,K.jsx)(bc,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},title:l(`archives.card.download`),children:(0,K.jsx)(Vs,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>g(!0),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?l(`archives.card.edit`):l(`archives.card.noPermissionEdit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>x(!0),disabled:!m(`archives`,`delete`,e.created_by_id),title:m(`archives`,`delete`,e.created_by_id)?l(`archives.card.delete`):l(`archives.card.noPermissionDelete`),children:(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();se({x:t.left,y:t.bottom+4})},title:l(`archives.card.moreOptions`),children:(0,K.jsx)(Ws,{className:`w-4 h-4`})})]})]}),h&&(0,K.jsx)(qW,{archive:e,onClose:()=>g(!1)}),_&&(0,K.jsx)(JW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>v(!1)}),de&&(0,K.jsx)(NW,{plates:de,onSelect:t=>{fe(null),T(`/gcode-viewer?archive=${e.id}&plate=${t}`)},onClose:()=>fe(null)}),E&&(0,K.jsx)(oW,{mode:`reprint`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>D(!1)}),O&&(0,K.jsx)(RW,{source:{kind:`archive`,id:e.id,filename:e.print_name||e.filename||`model`},onClose:()=>k(!1)}),b&&(0,K.jsxs)(Ad,{title:l(`archives.modal.deleteArchive`),message:l(`archives.modal.deleteConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.deleteButton`),variant:`danger`,confirmDisabled:(w.data?.currently_printing??0)>0,onConfirm:()=>{we.mutate(S),x(!1),C(!1)},onCancel:()=>{x(!1),C(!1)},children:[(w.data?.related_queue_items??0)>0&&(0,K.jsx)(`div`,{className:(w.data?.currently_printing??0)>0?`text-sm text-red-400 mb-2`:`text-sm text-amber-400 mb-2`,children:(w.data?.currently_printing??0)>0?l(`archives.modal.deleteBlockedByPrinting`,{count:w.data.currently_printing}):l(`archives.modal.deleteQueueItemsWarning`,{count:w.data.related_queue_items})}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer text-sm text-bambu-gray`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 accent-red-500`,checked:S,onChange:e=>C(e.target.checked)}),(0,K.jsx)(`span`,{children:l(`archives.modal.deletePurgeStats`)})]})]}),ne&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeSource3mf`),message:l(`archives.modal.removeSource3mfConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{ye.mutate(),re(!1)},onCancel:()=>re(!1)}),ie&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeF3d`),message:l(`archives.modal.removeF3dConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{xe.mutate(),H(!1)},onCancel:()=>H(!1)}),ae&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeTimelapse`),message:l(`archives.modal.removeTimelapseConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{ge.mutate(),oe(!1)},onCancel:()=>oe(!1)}),U&&(0,K.jsx)(YW,{x:U.x,y:U.y,items:ke,onClose:()=>se(null)}),M&&e.timelapse_path&&(0,K.jsx)(Q0,{src:Q.getArchiveTimelapse(e.id),title:l(`archives.modal.timelapse`,{name:e.print_name||e.filename}),downloadFilename:`${e.print_name||e.filename}_timelapse.mp4`,archiveId:e.id,onClose:()=>N(!1),onEdit:()=>{d.invalidateQueries({queryKey:[`archives`]}),N(!1)}}),P&&I.length>0&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:l(`archives.modal.selectTimelapse`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 mt-1`,children:l(`archives.modal.selectTimelapseDesc`)})]}),(0,K.jsx)(`button`,{onClick:()=>{F(!1),L([])},className:`text-gray-400 hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 p-2`,children:I.map(e=>(0,K.jsxs)(`button`,{onClick:()=>Ce.mutate(e.name),disabled:Ce.isPending,className:`w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1`,children:[(0,K.jsx)(`div`,{className:`font-medium text-white`,children:e.name}),(0,K.jsxs)(`div`,{className:`text-sm text-gray-400 flex gap-3`,children:[(0,K.jsx)(`span`,{children:Cd(e.size)}),e.mtime&&(0,K.jsx)(`span`,{children:yf(e.mtime)})]})]},e.name))})]})}),R&&(0,K.jsx)(XW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>z(!1)}),B&&e.photos&&(0,K.jsx)(ZW,{archiveId:e.id,archiveName:e.print_name||e.filename,photos:e.photos,onClose:()=>V(!1),onDelete:async t=>{try{await Q.deleteArchivePhoto(e.id,t),d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.photoDeleted`))}catch{f(l(`archives.toast.failedDeletePhoto`),`error`)}}}),ee&&(0,K.jsx)(Z0,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>te(!1)}),A&&(0,K.jsx)(oW,{mode:`add-to-queue`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>j(!1)}),(0,K.jsx)(`input`,{ref:ce,type:`file`,accept:`.3mf`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&ve.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:le,type:`file`,accept:`.f3d`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&be.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ue,type:`file`,accept:`.mp4,.avi,.mkv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&_e.mutate(t),e.target.value=``}})]})}var pze=[`completed`,`failed`,`aborted`,`cancelled`,`stopped`],mze=[{id:`all`,label:`All Archives`,icon:(0,K.jsx)(cc,{className:`w-4 h-4`})},{id:`recent`,label:`Last 24 Hours`,icon:(0,K.jsx)(Ss,{className:`w-4 h-4`})},{id:`this-week`,label:`This Week`,icon:(0,K.jsx)(Zo,{className:`w-4 h-4`})},{id:`this-month`,label:`This Month`,icon:(0,K.jsx)(Zo,{className:`w-4 h-4`})},{id:`favorites`,label:`Favorites`,icon:(0,K.jsx)(su,{className:`w-4 h-4`})},{id:`not-printed`,label:`Not Printed`,icon:(0,K.jsx)(Du,{className:`w-4 h-4`})},{id:`printed`,label:`Printed`,icon:(0,K.jsx)(Tl,{className:`w-4 h-4`})},{id:`failed`,label:`Failed Prints`,icon:(0,K.jsx)(ds,{className:`w-4 h-4`})},{id:`duplicates`,label:`Duplicates`,icon:(0,K.jsx)(Ms,{className:`w-4 h-4`})}];function hze(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i}=dd(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(()=>{let e=localStorage.getItem(`archiveFilterPrinter`);return e?Number(e):null}),[u,d]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterMaterial`)),[f,p]=(0,y.useState)(()=>{let e=localStorage.getItem(`archiveFilterColors`);return e?new Set(JSON.parse(e)):new Set}),[m,h]=(0,y.useState)(()=>localStorage.getItem(`archiveColorFilterMode`)||`or`),[g,_]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterFavorites`)===`true`),[v,b]=(0,y.useState)(()=>localStorage.getItem(`archiveHideFailed`)===`true`),[x,S]=(0,y.useState)(()=>localStorage.getItem(`archiveHideDuplicates`)===`true`),[C,w]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterTag`)),[T,E]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterFileType`)||`all`),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(()=>localStorage.getItem(`archiveNo3MFWarningDismissed`)===`true`),{data:F}=q({queryKey:[`archives`,`no-3mf-warning`],queryFn:Q.getNo3MFWarning,staleTime:300*1e3,enabled:!N}),I=()=>{localStorage.setItem(`archiveNo3MFWarningDismissed`,`true`),P(!0)},[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(!1),[V,ee]=(0,y.useState)(!1),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(()=>localStorage.getItem(`archiveViewMode`)||`grid`),[H,ae]=(0,y.useState)(()=>localStorage.getItem(`archiveSortBy`)||`date-desc`),[oe,U]=(0,y.useState)(()=>localStorage.getItem(`archiveCollection`)||`all`),[se,ce]=(0,y.useState)(0),[le,ue]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`archivePageSize`);return e?Number(e):50}catch{return 50}}),[de,fe]=(0,y.useState)(!1),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(!1),[_e,ve]=(0,y.useState)(!1),[ye,be]=(0,y.useState)(!1),[xe,Se]=(0,y.useState)(null),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(()=>localStorage.getItem(`logFilterUser`)||null),[De,Oe]=(0,y.useState)(()=>localStorage.getItem(`logFilterStatus`)),[ke,Ae]=(0,y.useState)(()=>localStorage.getItem(`logFilterDateFrom`)||``),[je,Me]=(0,y.useState)(()=>localStorage.getItem(`logFilterDateTo`)||``),[Ne,Pe]=(0,y.useState)(()=>{let e=localStorage.getItem(`logOffset`);return e?Number(e):0}),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(null),[Ve,He]=(0,y.useState)(``),[Ue,We]=(0,y.useState)(``),[Ge,Ke]=(0,y.useState)(()=>{let e=localStorage.getItem(`logPageSize`);return e?Number(e):25}),qe=(0,y.useCallback)(e=>{we(e),Se(e)},[]);(0,y.useEffect)(()=>{if(xe){let t=setTimeout(()=>{let t=document.querySelector(`[data-archive-id="${xe}"]`);t?t.scrollIntoView({behavior:`smooth`,block:`center`}):Ce===xe&&n(e(`archives.originalPrintNotVisible`),`warning`),Ce===xe&&we(null)},100),r=setTimeout(()=>Se(null),5e3);return()=>{clearTimeout(t),clearTimeout(r)}}},[xe,Ce,n,e]);let{data:Je,isLoading:Ye}=q({queryKey:[`archives`,c],queryFn:()=>Q.getArchives(c||void 0)}),{data:Xe}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Ze}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects()}),{data:Qe}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:$e}=q({queryKey:[`users`],queryFn:Q.getUsers,enabled:re===`log`}),{data:et,isLoading:tt}=q({queryKey:[`print-log`,c,Te,De,ke,je,o,Ne,Ge],queryFn:()=>Q.getPrintLog({search:o||void 0,printerId:c||void 0,username:Te||void 0,status:De||void 0,dateFrom:ke||void 0,dateTo:je||void 0,limit:Ge,offset:Ne}),enabled:re===`log`}),nt=Qe?.time_format||`system`,rt=Qe?.open_in_slicer||Qe?.preferred_slicer||`bambu_studio`,it=Qe?.use_slicer_api??!1,at=$d(Qe?.currency||`USD`),ot=J({mutationFn:async e=>(await Promise.all(e.map(e=>Q.deleteArchive(e))),e.length),onSuccess:e=>{t.invalidateQueries({queryKey:[`archives`]}),M(new Set),n(`${e} archive${e===1?``:`s`} deleted`)},onError:()=>{n(e(`archives.toast.failedDeleteArchives`),`error`)}}),st=J({mutationFn:()=>Q.clearPrintLog(),onSuccess:r=>{t.invalidateQueries({queryKey:[`print-log`]}),Pe(0),n(e(`archives.log.cleared`,{count:r.deleted}))},onError:()=>{n(e(`archives.log.clearFailed`),`error`)}}),ct=J({mutationFn:e=>Q.deletePrintLogEntry(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`print-log`]}),t.invalidateQueries({queryKey:[`archives-stats`]}),n(e(`archives.log.entryDeleted`))},onError:()=>{n(e(`archives.log.entryDeleteFailed`),`error`)}}),lt=J({mutationFn:({id:e,body:t})=>Q.updatePrintLogEntry(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`print-log`]}),t.invalidateQueries({queryKey:[`archives-stats`]}),Be(null),n(e(`archives.log.entryUpdated`))},onError:()=>{n(e(`archives.log.entryUpdateFailed`),`error`)}});(0,y.useEffect)(()=>{c===null?localStorage.removeItem(`archiveFilterPrinter`):localStorage.setItem(`archiveFilterPrinter`,c.toString())},[c]),(0,y.useEffect)(()=>{u?localStorage.setItem(`archiveFilterMaterial`,u):localStorage.removeItem(`archiveFilterMaterial`)},[u]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterColors`,JSON.stringify([...f]))},[f]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveColorFilterMode`,m)},[m]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterFavorites`,g.toString())},[g]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveHideFailed`,v.toString())},[v]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveHideDuplicates`,x.toString())},[x]),(0,y.useEffect)(()=>{C?localStorage.setItem(`archiveFilterTag`,C):localStorage.removeItem(`archiveFilterTag`)},[C]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterFileType`,T)},[T]),(0,y.useEffect)(()=>{ce(0)},[o,c,u,f,m,g,v,x,C,T,H,oe]),(0,y.useEffect)(()=>{try{localStorage.setItem(`archivePageSize`,String(le))}catch{}},[le]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveViewMode`,re)},[re]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveSortBy`,H)},[H]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveCollection`,oe)},[oe]),(0,y.useEffect)(()=>{Te?localStorage.setItem(`logFilterUser`,Te):localStorage.removeItem(`logFilterUser`)},[Te]),(0,y.useEffect)(()=>{De?localStorage.setItem(`logFilterStatus`,De):localStorage.removeItem(`logFilterStatus`)},[De]),(0,y.useEffect)(()=>{ke?localStorage.setItem(`logFilterDateFrom`,ke):localStorage.removeItem(`logFilterDateFrom`)},[ke]),(0,y.useEffect)(()=>{je?localStorage.setItem(`logFilterDateTo`,je):localStorage.removeItem(`logFilterDateTo`)},[je]),(0,y.useEffect)(()=>{localStorage.setItem(`logOffset`,Ne.toString())},[Ne]),(0,y.useEffect)(()=>{localStorage.setItem(`logPageSize`,Ge.toString())},[Ge]);let ut=new Map(Xe?.map(e=>[e.id,e.name])||[]),dt=[...new Set(Je?.flatMap(e=>e.filament_type?.split(`, `)||[]).filter(Boolean)||[])].sort(),ft=[...new Set(Je?.flatMap(e=>e.filament_color?.split(`,`)||[]).filter(Boolean)||[])],pt=[...new Set(Je?.flatMap(e=>e.tags?.split(`,`).map(e=>e.trim())||[]).filter(Boolean)||[])].sort(),mt=Je?.filter(e=>{let t=new Date,n=vf(e.created_at)||new Date(0),r=!0;switch(oe){case`recent`:r=t.getTime()-n.getTime()<1440*60*1e3;break;case`this-week`:r=t.getTime()-n.getTime()<10080*60*1e3;break;case`this-month`:r=n.getMonth()===t.getMonth()&&n.getFullYear()===t.getFullYear();break;case`favorites`:r=e.is_favorite===!0;break;case`not-printed`:r=e.status===`archived`;break;case`printed`:r=pze.includes(e.status);break;case`failed`:r=e.status===`failed`||e.status===`aborted`;break;case`duplicates`:r=e.duplicate_count>0;break}let i=(e.print_name||e.filename).toLowerCase().includes(o.toLowerCase()),a=!u||e.filament_type?.split(`, `).includes(u),s=e.filament_color?.split(`,`)||[],c=f.size===0||(m===`or`?s.some(e=>f.has(e)):[...f].every(e=>s.includes(e))),l=oe===`favorites`||!g||e.is_favorite,d=oe===`failed`||!v||e.status!==`failed`&&e.status!==`aborted`,p=oe===`duplicates`||!x||e.duplicate_count===0||e.duplicate_sequence===0,h=e.tags?.split(`,`).map(e=>e.trim())||[],_=!C||h.includes(C),y=$0(e);return r&&i&&a&&c&&l&&d&&p&&_&&(T===`all`||T===`gcode`&&y||T===`source`&&!y)}).sort((e,t)=>{switch(H){case`date-desc`:return(vf(t.created_at)?.getTime()||0)-(vf(e.created_at)?.getTime()||0);case`date-asc`:return(vf(e.created_at)?.getTime()||0)-(vf(t.created_at)?.getTime()||0);case`name-asc`:return(e.print_name||e.filename).localeCompare(t.print_name||t.filename);case`name-desc`:return(t.print_name||t.filename).localeCompare(e.print_name||e.filename);case`size-desc`:return t.file_size-e.file_size;case`size-asc`:return e.file_size-t.file_size;default:return 0}}),ht=mt?.length||0,gt=le===-1,_t=gt?ht||1:le,vt=Math.max(1,Math.ceil(ht/_t)),yt=gt?mt:mt?.slice(se*_t,(se+1)*_t);(0,y.useEffect)(()=>{if(xe&&mt&&!gt){let e=mt.findIndex(e=>e.id===xe);if(e>=0){let t=Math.floor(e/_t);t!==se&&ce(t)}}},[xe]);let bt=L||j.size>0,xt=e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},St=()=>{mt&&M(new Set(mt.map(e=>e.id)))},Ct=()=>{M(new Set),R(!1)},wt=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Tt=()=>{p(new Set)},Et=()=>{s(``),l(null),d(null),_(!1),b(!1),S(!1),w(null),E(`all`)},Dt=o||c||u||g||v||x||C||T!==`all`,{isDraggingOver:Ot,dragHandlers:kt}=WW({disabled:D,extensions:[`.3mf`],onFiles:e=>{A(e),O(!0)},onRejected:()=>n(e(`archives.page.only3mfSupported`),`warning`)}),At=(0,y.useCallback)(e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable){e.key===`Escape`&&t.blur();return}switch(e.key){case`/`:e.preventDefault(),a.current?.focus();break;case`u`:case`U`:!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),O(!0));break;case`Escape`:bt&&Ct();break}},[bt]);return(0,y.useEffect)(()=>(document.addEventListener(`keydown`,At),()=>document.removeEventListener(`keydown`,At)),[At]),(0,K.jsxs)(`div`,{className:`p-4 md:p-8 relative`,...kt,children:[Ot&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`border-4 border-dashed border-bambu-green rounded-xl p-12 text-center`,children:[(0,K.jsx)(Du,{className:`w-16 h-16 mx-auto mb-4 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-2xl font-semibold text-white mb-2`,children:e(`archives.page.dropFilesHere`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`archives.releaseToUpload`)})]})}),bt&&(0,K.jsxs)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:Ct,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),`Close`]}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[j.size,` selected`]}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:St,children:`Select All`}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ee(!0),disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),`Tags`]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ne(!0),disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),children:[(0,K.jsx)(sc,{className:`w-4 h-4`}),`Project`]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),onClick:()=>{let r=Array.from(j);Promise.all(r.map(e=>Q.toggleFavorite(e))).then(()=>{t.invalidateQueries({queryKey:[`archives`]}),n(`Toggled favorites for ${r.length} archive${r.length===1?``:`s`}`)}).catch(()=>{n(e(`archives.toast.failedUpdateFavorites`),`error`)})},children:[(0,K.jsx)(su,{className:`w-4 h-4`}),`Favorite`]}),(0,K.jsxs)($,{size:`sm`,className:`bg-red-500 hover:bg-red-600`,onClick:()=>B(!0),disabled:!i(`archives:delete_own`,`archives:delete_all`),title:i(`archives:delete_own`,`archives:delete_all`)?void 0:e(`archives.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Delete`]})]}),F?.has_fallback&&!N&&(0,K.jsxs)(`div`,{className:`mb-6 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 flex items-start gap-3`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-amber-200`,children:e(`archives.no3mfBanner.title`)}),(0,K.jsxs)(`div`,{className:`text-xs text-amber-200/80 mt-1`,children:[e(`archives.no3mfBanner.body`),` `,(0,K.jsxs)(`a`,{href:`https://wiki.bambuddy.cool/getting-started/#step-4-enable-store-sent-files-on-external-storage`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-amber-100 inline-flex items-center gap-1`,children:[e(`archives.no3mfBanner.docsLink`),(0,K.jsx)(Js,{className:`w-3 h-3`})]})]})]}),(0,K.jsx)(`button`,{onClick:I,className:`text-amber-200/60 hover:text-amber-200 flex-shrink-0 p-1 -m-1`,title:e(`archives.no3mfBanner.dismissLabel`),"aria-label":e(`archives.no3mfBanner.dismissLabel`),children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Oo,{className:`w-7 h-7 text-bambu-green`}),`Archives`]}),(0,K.jsxs)(`p`,{className:`text-bambu-gray mt-1`,children:[mt?.length||0,` of `,Je?.length||0,` prints`]})]}),(0,K.jsx)(`select`,{className:`mt-0.5 px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none`,value:oe,onChange:e=>U(e.target.value),children:mze.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>fe(!de),disabled:pe,children:[pe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(tc,{className:`w-4 h-4`}),`Export`]}),de&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg`,onClick:async()=>{fe(!1),me(!0);try{let{blob:t,filename:r}=await Q.exportArchives({format:`csv`,printerId:c||void 0,status:oe===`failed`?`failed`:void 0,search:o||void 0}),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),n(e(`archives.toast.exportDownloaded`))}catch{n(e(`archives.toast.exportFailed`),`error`)}finally{me(!1)}},children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),`Export as CSV`]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg`,onClick:async()=>{fe(!1),me(!0);try{let{blob:t,filename:r}=await Q.exportArchives({format:`xlsx`,printerId:c||void 0,status:oe===`failed`?`failed`:void 0,search:o||void 0}),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),n(e(`archives.toast.exportDownloaded`))}catch{n(e(`archives.toast.exportFailed`),`error`)}finally{me(!1)}},children:[(0,K.jsx)(tc,{className:`w-4 h-4`}),`Export as Excel`]})]})]}),j.size>=2&&j.size<=5&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>ge(!0),children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),`Compare (`,j.size,`)`]}),!bt&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>R(!0),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),`Select`]}),(0,K.jsxs)($,{onClick:()=>O(!0),disabled:!r(`archives:create`),title:r(`archives:create`)?void 0:e(`archives.permission.noCreate`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),`Upload 3MF`]}),r(`archives:purge`)&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>be(!0),title:e(`archivePurge.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`archivePurge.headerButton`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0 w-fit mb-4`,children:[(0,K.jsx)(`button`,{className:`p-2 ${re===`grid`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`grid`),title:e(`archives.gridView`),children:(0,K.jsx)(zc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`list`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`list`),title:e(`archives.listView`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`calendar`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`calendar`),title:e(`archives.calendarView`),children:(0,K.jsx)(Yo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`log`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`log`),title:e(`archives.logView`),children:(0,K.jsx)(xs,{className:`w-4 h-4`})})]}),re!==`log`&&(0,K.jsx)(_d,{className:`mb-6`,children:(0,K.jsxs)(yd,{className:`py-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`w-full md:flex-1 relative md:min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{ref:a,type:`text`,placeholder:e(`archives.searchPlaceholder`),className:`w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:o,onChange:e=>s(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c||``,onChange:e=>l(e.target.value?Number(e.target.value):null),children:[(0,K.jsx)(`option`,{value:``,children:`All Printers`}),Xe?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:u||``,onChange:e=>d(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All Materials`}),dt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)($s,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:T,onChange:e=>E(e.target.value),children:[(0,K.jsx)(`option`,{value:`all`,children:`All Files`}),(0,K.jsx)(`option`,{value:`gcode`,children:`Sliced (GCODE)`}),(0,K.jsx)(`option`,{value:`source`,children:`Source Only`})]})]}),(0,K.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${g?`bg-yellow-500/20 border-yellow-500 text-yellow-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(g?`archives.showAll`:`archives.showFavoritesOnly`),children:[(0,K.jsx)(su,{className:`w-4 h-4 ${g?`fill-yellow-400`:``}`}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:`Favorites`})]}),(0,K.jsxs)(`button`,{onClick:()=>b(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?`bg-red-500/20 border-red-500 text-red-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(v?`archives.showFailedPrints`:`archives.hideFailedPrints`),children:[(0,K.jsx)(ds,{className:`w-4 h-4 `}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:`Hide Failed`})]}),(0,K.jsxs)(`button`,{onClick:()=>S(!x),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${x?`bg-purple-500/20 border-purple-500 text-purple-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(`archives.hideDuplicates`),children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:e(`archives.hideDuplicates`)})]}),pt.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:C||``,onChange:e=>w(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All Tags`}),pt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsx)(`button`,{onClick:()=>ve(!0),className:`p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors`,title:e(`archives.manageTags`),children:(0,K.jsx)(Ul,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(Po,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:H,onChange:e=>ae(e.target.value),children:[(0,K.jsx)(`option`,{value:`date-desc`,children:e(`archives.sortNewest`)}),(0,K.jsx)(`option`,{value:`date-asc`,children:e(`archives.sortOldest`)}),(0,K.jsxs)(`option`,{value:`name-asc`,children:[e(`archives.sortName`),` A-Z`]}),(0,K.jsxs)(`option`,{value:`name-desc`,children:[e(`archives.sortName`),` Z-A`]}),(0,K.jsx)(`option`,{value:`size-desc`,children:e(`archives.sortLargest`)}),(0,K.jsx)(`option`,{value:`size-asc`,children:e(`archives.sortSmallest`)})]})]})]}),Dt&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:Et,className:`text-bambu-gray hover:text-white`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),`Reset`]})]}),ft.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Colors:`}),f.size>1&&(0,K.jsx)(`button`,{onClick:()=>h(e=>e===`or`?`and`:`or`),className:`px-2 py-0.5 text-xs rounded transition-colors ${m===`and`?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:m===`or`?`Match ANY selected color`:`Match ALL selected colors`,children:m.toUpperCase()}),(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:ft.map(e=>(0,K.jsx)(`button`,{onClick:()=>wt(e),className:`w-6 h-6 rounded-full border-2 transition-all ${f.has(e)?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:e},title:e},e))}),f.size>0&&(0,K.jsxs)(`button`,{onClick:Tt,className:`text-xs text-bambu-gray hover:text-white flex items-center gap-1`,children:[(0,K.jsx)(Ru,{className:`w-3 h-3`}),`Clear`]})]})]})}),(0,K.jsx)(lze,{}),Ye?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`archives.loadingArchives`)}):mt?.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(o?`archives.noArchivesSearch`:`archives.noArchivesYet`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:`Archives are created automatically when prints complete`})]})}):re===`calendar`?(0,K.jsx)(_d,{className:`p-6`,children:(0,K.jsx)(xAe,{archives:mt||[],onArchiveClick:e=>{s(``),ie(`grid`),Se(e.id)},highlightedArchiveId:xe})}):re===`grid`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6`,children:yt?.map(t=>(0,K.jsx)(dze,{archive:t,printerName:t.printer_id?ut.get(t.printer_id)||`Unknown`:t.sliced_for_model||`No Printer`,isSelected:j.has(t.id),onSelect:xt,selectionMode:bt,projects:Ze,isHighlighted:t.id===xe,timeFormat:nt,preferredSlicer:rt,useSlicerApi:it,currency:at,t:e,onNavigateToArchive:qe},t.id))}),(0,K.jsx)(t2,{pageIndex:se,pageSize:le,totalRows:ht,totalPages:vt,onPageChange:ce,onPageSizeChange:e=>{ue(e),ce(0)},t:e})]}):re===`list`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{children:(0,K.jsxs)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium`,children:[(0,K.jsx)(`div`,{className:`col-span-1`}),(0,K.jsx)(`div`,{className:`col-span-4`,children:`Name`}),(0,K.jsx)(`div`,{className:`col-span-2`,children:`Printer`}),(0,K.jsx)(`div`,{className:`col-span-2`,children:`Date`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Size`}),(0,K.jsx)(`div`,{className:`col-span-2 text-right`,children:`Actions`})]}),yt?.map(t=>(0,K.jsx)(fze,{archive:t,printerName:t.printer_id?ut.get(t.printer_id)||`Unknown`:t.sliced_for_model||`No Printer`,isSelected:j.has(t.id),onSelect:xt,selectionMode:bt,projects:Ze,isHighlighted:t.id===xe,preferredSlicer:rt,useSlicerApi:it,t:e,onNavigateToArchive:qe},t.id))]})}),(0,K.jsx)(t2,{pageIndex:se,pageSize:le,totalRows:ht,totalPages:vt,onPageChange:ce,onPageSizeChange:e=>{ue(e),ce(0)},t:e})]}):re===`log`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-3 md:items-center md:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative md:min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:e(`archives.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:o,onChange:e=>{s(e.target.value),Pe(0)}})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:c||``,onChange:e=>{l(e.target.value?Number(e.target.value):null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allPrinters`)}),Xe?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:Te||``,onChange:e=>{Ee(e.target.value||null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allUsers`)}),$e?.map(e=>(0,K.jsx)(`option`,{value:e.username,children:e.username},e.id))]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:De||``,onChange:e=>{Oe(e.target.value||null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allStatuses`)}),(0,K.jsx)(`option`,{value:`completed`,children:e(`archives.status.completed`)}),(0,K.jsx)(`option`,{value:`failed`,children:e(`archives.status.failed`)}),(0,K.jsx)(`option`,{value:`stopped`,children:e(`archives.status.stopped`)}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`archives.log.cancelled`)}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`archives.log.skipped`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.dateFrom`)}),(0,K.jsx)(`input`,{type:`date`,className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:ke,onChange:e=>{Ae(e.target.value),Pe(0)}})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.dateTo`)}),(0,K.jsx)(`input`,{type:`date`,className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:je,onChange:e=>{Me(e.target.value),Pe(0)}})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>Ie(!0),disabled:!r(`archives:delete_all`)||st.isPending,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`archives.log.clearLog`)]})})]})})}),(0,K.jsx)(_d,{children:tt?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):et?.items.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-bambu-gray text-left`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.date`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.printName`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.printer`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.user`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.status`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.duration`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.filament`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium w-10`,"aria-label":e(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:et.items.map(t=>(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-secondary/50`,children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white whitespace-nowrap`,children:bf(t.started_at||t.created_at,nt)}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.thumbnail_path&&(0,K.jsx)(`img`,{src:Q.getPrintLogThumbnail(t.id),alt:``,className:`w-8 h-8 rounded object-cover flex-shrink-0`,onError:e=>{e.target.style.display=`none`}}),(0,K.jsx)(`span`,{className:`text-white break-words`,title:t.print_name||``,children:t.print_name||`—`})]})}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light`,children:t.printer_name||`—`}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light`,children:t.created_by_username||`—`}),(0,K.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.status===`completed`?`bg-green-500/20 text-green-400`:t.status===`failed`?`bg-red-500/20 text-red-400`:t.status===`stopped`?`bg-yellow-500/20 text-yellow-400`:t.status===`cancelled`?`bg-orange-500/20 text-orange-400`:t.status===`skipped`?`bg-blue-500/20 text-blue-400`:`bg-gray-500/20 text-gray-400`}`,children:t.status}),t.failure_reason&&(0,K.jsx)(`span`,{className:`block text-[10px] text-bambu-gray mt-0.5`,children:e(`editArchive.failureReasons.${t.failure_reason}`,{defaultValue:t.failure_reason})})]}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light whitespace-nowrap`,children:t.duration_seconds?Cf(t.duration_seconds):`—`}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:t.filament_color.split(`,`).map((e,t)=>{let n=e.trim();return(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:n.startsWith(`#`)?n:void 0},title:n},t)})}),(0,K.jsx)(`span`,{className:`text-bambu-gray-light text-xs`,children:t.filament_type||`—`})]})}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,K.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Be(t),He(t.failure_reason||``),We(t.status)},disabled:lt.isPending||!(r(`archives:update_all`)||r(`archives:update_own`)),title:r(`archives:update_all`)||r(`archives:update_own`)?e(`archives.log.editEntryTitle`):e(`archives.permission.noEdit`),className:`text-bambu-gray hover:text-bambu-blue disabled:opacity-40 disabled:hover:text-bambu-gray transition-colors`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>Re(t.id),disabled:ct.isPending||!(r(`archives:delete_all`)||r(`archives:delete_own`)),title:r(`archives:delete_all`)||r(`archives:delete_own`)?e(`archives.log.deleteEntryTitle`):e(`archives.permission.noDelete`),className:`text-bambu-gray hover:text-red-400 disabled:opacity-40 disabled:hover:text-bambu-gray transition-colors`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},t.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t border-bambu-dark-tertiary flex-wrap gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.showing`,{count:Math.min(Ne+Ge,et.total),total:et.total})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:e(`archives.log.rowsPerPage`)}),(0,K.jsxs)(`select`,{className:`px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none`,value:Ge,onChange:e=>{Ke(Number(e.target.value)),Pe(0)},children:[(0,K.jsx)(`option`,{value:10,children:`10`}),(0,K.jsx)(`option`,{value:25,children:`25`}),(0,K.jsx)(`option`,{value:50,children:`50`}),(0,K.jsx)(`option`,{value:100,children:`100`})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`archives.log.page`),` `,Math.floor(Ne/Ge)+1,` / `,Math.max(1,Math.ceil(et.total/Ge))]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Pe(Math.max(0,Ne-Ge)),disabled:Ne===0,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Pe(Ne+Ge),disabled:Ne+Ge>=et.total,children:(0,K.jsx)(as,{className:`w-4 h-4`})})]})]})]}):(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`archives.log.noEntries`)})})]}):null,D&&(0,K.jsx)(cAe,{onClose:()=>{O(!1),A([])},initialFiles:k}),ye&&(0,K.jsx)(uAe,{onClose:()=>be(!1)}),z&&(0,K.jsx)(Ad,{title:e(`archives.modal.deleteArchives`),message:e(`archives.modal.deleteArchivesConfirm`,{count:j.size}),confirmText:e(`archives.modal.deleteCount`,{count:j.size}),variant:`danger`,onConfirm:()=>{ot.mutate(Array.from(j)),B(!1)},onCancel:()=>B(!1)}),V&&(0,K.jsx)(hAe,{selectedIds:Array.from(j),existingTags:pt,onClose:()=>ee(!1)}),te&&(0,K.jsx)(gAe,{selectedIds:Array.from(j),onClose:()=>ne(!1)}),he&&j.size>=2&&j.size<=5&&(0,K.jsx)(aze,{archiveIds:Array.from(j),onClose:()=>{ge(!1),M(new Set),R(!1)}}),_e&&(0,K.jsx)(uze,{onClose:()=>ve(!1)}),Fe&&(0,K.jsx)(Ad,{title:e(`archives.log.clearLogTitle`),message:e(`archives.log.clearLogConfirm`),confirmText:e(`archives.log.clearLogButton`),variant:`danger`,onConfirm:()=>{st.mutate(),Ie(!1)},onCancel:()=>Ie(!1)}),Le!==null&&(0,K.jsx)(Ad,{title:e(`archives.log.deleteEntryTitle`),message:e(`archives.log.deleteEntryConfirm`),confirmText:e(`common.delete`),variant:`danger`,onConfirm:()=>{ct.mutate(Le),Re(null)},onCancel:()=>Re(null)}),ze!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>Be(null),children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-md mx-4 p-6`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-4`,children:e(`archives.log.editEntryTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4`,children:e(`archives.log.editEntryDescription`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`editArchive.status`)}),(0,K.jsxs)(`select`,{value:Ue,onChange:e=>We(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`completed`,children:e(`archives.log.statuses.completed`,{defaultValue:`completed`})}),(0,K.jsx)(`option`,{value:`failed`,children:e(`archives.log.statuses.failed`,{defaultValue:`failed`})}),(0,K.jsx)(`option`,{value:`stopped`,children:e(`archives.log.statuses.stopped`,{defaultValue:`stopped`})}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`archives.log.statuses.cancelled`,{defaultValue:`cancelled`})}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`archives.log.statuses.skipped`,{defaultValue:`skipped`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`editArchive.failureReason`)}),(0,K.jsxs)(`select`,{value:Ve,onChange:e=>He(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:e(`editArchive.selectReason`)}),KW.map(t=>(0,K.jsx)(`option`,{value:t,children:e(`editArchive.failureReasons.${t}`)},t))]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>Be(null),children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,onClick:()=>{let e={};if(Ve!==(ze.failure_reason||``)&&(e.failure_reason=Ve||null),Ue!==ze.status&&(e.status=Ue),Object.keys(e).length===0){Be(null);return}lt.mutate({id:ze.id,body:e})},disabled:lt.isPending,children:lt.isPending?e(`editArchive.saving`):e(`common.save`)})]})]})})]})}function t2({pageIndex:e,pageSize:t,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:a,t:o}){let s=t===-1;if(r<=1&&!s)return null;let c=s?n||1:t;return(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:s?`${n} ${o(`archives.prints`)}`:(0,K.jsxs)(K.Fragment,{children:[o(`archives.pagination.showing`),` `,e*c+1,` `,o(`archives.pagination.to`),` `,Math.min((e+1)*c,n),` `,o(`archives.pagination.of`),` `,n,` `,o(`archives.prints`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:o(`archives.pagination.show`)}),(0,K.jsxs)(`select`,{value:t,onChange:e=>a(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[25,50,100,200].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:o(`archives.pagination.all`)})]}),!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>i(0),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(Math.max(0,e-1)),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[o(`archives.pagination.page`),` `,e+1,` `,o(`archives.pagination.of`),` `,r]}),(0,K.jsx)(`button`,{onClick:()=>i(Math.min(r-1,e+1)),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(r-1),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})}function gze(){var e=[...arguments];return(0,y.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var n2=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function r2(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function i2(e){return`nodeType`in e}function a2(e){return e?r2(e)?e:i2(e)?e.ownerDocument?.defaultView??window:window:window}function o2(e){let{Document:t}=a2(e);return e instanceof t}function s2(e){return r2(e)?!1:e instanceof a2(e).HTMLElement}function c2(e){return e instanceof a2(e).SVGElement}function l2(e){return e?r2(e)?e.document:i2(e)?o2(e)?e:s2(e)||c2(e)?e.ownerDocument:document:document:document}var u2=n2?y.useLayoutEffect:y.useEffect;function d2(e){let t=(0,y.useRef)(e);return u2(()=>{t.current=e}),(0,y.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function _ze(){let e=(0,y.useRef)(null);return[(0,y.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,y.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function f2(e,t){t===void 0&&(t=[e]);let n=(0,y.useRef)(e);return u2(()=>{n.current!==e&&(n.current=e)},t),n}function p2(e,t){let n=(0,y.useRef)();return(0,y.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function m2(e){let t=d2(e),n=(0,y.useRef)(null);return[n,(0,y.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function h2(e){let t=(0,y.useRef)();return(0,y.useEffect)(()=>{t.current=e},[e]),t.current}var g2={};function _2(e,t){return(0,y.useMemo)(()=>{if(t)return t;let n=g2[e]==null?0:g2[e]+1;return g2[e]=n,e+`-`+n},[e,t])}function v2(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var y2=v2(1),b2=v2(-1);function vze(e){return`clientX`in e&&`clientY`in e}function x2(e){if(!e)return!1;let{KeyboardEvent:t}=a2(e.target);return t&&e instanceof t}function yze(e){if(!e)return!1;let{TouchEvent:t}=a2(e.target);return t&&e instanceof t}function S2(e){if(yze(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return vze(e)?{x:e.clientX,y:e.clientY}:null}var C2=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[C2.Translate.toString(e),C2.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),w2=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function bze(e){return e.matches(w2)?e:e.querySelector(w2)}var xze={display:`none`};function Sze(e){let{id:t,value:n}=e;return y.createElement(`div`,{id:t,style:xze},n)}function Cze(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return y.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function wze(){let[e,t]=(0,y.useState)(``);return{announce:(0,y.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var T2=(0,y.createContext)(null);function Tze(e){let t=(0,y.useContext)(T2);(0,y.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of `);return t(e)},[e,t])}function Eze(){let[e]=(0,y.useState)(()=>new Set),t=(0,y.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,y.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Dze={draggable:` + [&::-webkit-slider-thumb]:cursor-pointer`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray w-12`,children:Tf(p)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{let e=o.current;e&&(e.currentTime=Math.max(0,e.currentTime-5))},className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:`Skip back 5s`,children:(0,K.jsx)(Xl,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:_,className:`p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors`,children:s?(0,K.jsx)(hl,{className:`w-5 h-5 text-white`}):(0,K.jsx)(bl,{className:`w-5 h-5 text-white`})}),(0,K.jsx)(`button`,{onClick:()=>{let e=o.current;e&&(e.currentTime=Math.min(p,e.currentTime+5))},className:`p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:`Skip forward 5s`,children:(0,K.jsx)(Zl,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`Speed:`}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:ize.map(e=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`px-2 py-1 text-xs rounded transition-colors ${l===e?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80`}`,children:[e,`x`]},e))})]})]})]})]})]}),h&&r&&(0,K.jsx)(rze,{archiveId:r,timelapseSrc:e,onClose:()=>g(!1),onSave:a})]})}function aze({archiveIds:e,onClose:t}){(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let{data:n,isLoading:r,error:i}=q({queryKey:[`archive-comparison`,e],queryFn:()=>Q.compareArchives(e)});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white`,children:[`Compare Archives (`,e.length,`)`]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-auto p-4 bg-bambu-dark-secondary`,children:r?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):i?(0,K.jsxs)(`div`,{className:`text-center py-12 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12 mx-auto mb-4 opacity-50`}),(0,K.jsx)(`p`,{children:`Failed to load comparison`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:i instanceof Error?i.message:`Unknown error`})]}):n?(0,K.jsx)(oze,{comparison:n}):null}),(0,K.jsx)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`w-full`,children:`Close`})})]})})}function oze({comparison:e}){return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`text-left text-sm text-bambu-gray font-medium pb-2 pr-4 min-w-[150px]`,children:`Setting`}),e.archives.map(e=>(0,K.jsxs)(`th`,{className:`text-left text-sm font-medium pb-2 px-2 min-w-[120px]`,children:[(0,K.jsx)(`div`,{className:`text-white truncate max-w-[150px]`,title:e.print_name,children:e.print_name}),(0,K.jsx)(`div`,{className:`text-xs ${e.status===`completed`?`text-status-ok`:e.status===`failed`?`text-status-error`:`text-bambu-gray`}`,children:e.status})]},e.id))]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-gray/20`,children:e.comparison.map(e=>(0,K.jsxs)(`tr`,{className:e.has_difference?`bg-yellow-500/5`:``,children:[(0,K.jsx)(`td`,{className:`py-2 pr-4 text-sm`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.has_difference&&(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400 flex-shrink-0`}),(0,K.jsx)(`span`,{className:e.has_difference?`text-yellow-400`:`text-bambu-gray`,children:e.label})]})}),e.values.map((t,n)=>(0,K.jsxs)(`td`,{className:`py-2 px-2 text-sm text-white`,children:[t??(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`-`}),e.unit&&t!==null&&(0,K.jsx)(`span`,{className:`text-bambu-gray ml-1`,children:e.unit})]},n))]},e.field))})]})}),e.differences.length>0&&(0,K.jsxs)(`div`,{className:`p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4`}),e.differences.length,` Difference`,e.differences.length>1?`s`:``,` Found`]}),(0,K.jsxs)(`ul`,{className:`text-sm text-white/80 space-y-1`,children:[e.differences.slice(0,5).map(e=>(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`text-yellow-400`,children:e.label}),`: `,e.values.join(` vs `),` `,e.unit||``]},e.field)),e.differences.length>5&&(0,K.jsxs)(`li`,{className:`text-bambu-gray`,children:[`...and `,e.differences.length-5,` more`]})]})]}),e.success_correlation.has_both_outcomes?(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-white mb-3 flex items-center gap-2`,children:[(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),`Success/Failure Analysis`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-3`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-green`,children:[e.success_correlation.successful_count,` successful`]}),(0,K.jsxs)(`span`,{className:`text-red-400`,children:[e.success_correlation.failed_count,` failed`]})]}),e.success_correlation.insights&&e.success_correlation.insights.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:e.success_correlation.insights.map(e=>(0,K.jsxs)(`div`,{className:`text-sm p-2 bg-bambu-dark-secondary rounded`,children:[(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[e.label,`:`]}),` `,(0,K.jsx)(`span`,{className:`text-white/80`,children:e.insight})]},e.field))}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:`No clear correlations found between settings and outcomes.`})]}):(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray`,children:(0,K.jsx)(`p`,{children:e.success_correlation.message||`Need both successful and failed prints for correlation analysis.`})})]})}function sze(e){let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`Just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function cze({upload:e,projects:t,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(e.tags||``),[u,d]=(0,y.useState)(e.notes||``),[f,p]=(0,y.useState)(e.project_id),[m,h]=(0,y.useState)(!1);return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Qs,{className:`w-8 h-8 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,title:e.filename,children:e.display_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:Cd(e.file_size)}),(0,K.jsx)(`span`,{children:`·`}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),sze(e.uploaded_at)]}),e.source_ip&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:`·`}),(0,K.jsxs)(`span`,{children:[`from `,e.source_ip]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>s(!o),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:o?(0,K.jsx)(cs,{className:`w-5 h-5`}):(0,K.jsx)(is,{className:`w-5 h-5`})}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>n(e.id,{tags:c,notes:u,project_id:f||void 0}),disabled:i,children:i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),`Archive`]})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>h(!0),disabled:a,children:a?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})})]})]}),m&&(0,K.jsx)(Ad,{title:`Discard Upload`,message:`Are you sure you want to discard "${e.filename}"? This cannot be undone.`,confirmText:`Discard`,variant:`danger`,onConfirm:()=>{r(e.id),h(!1)},onCancel:()=>h(!1)}),o&&(0,K.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Tags`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`e.g., functional, prototype, gift`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Notes`}),(0,K.jsx)(`textarea`,{value:u,onChange:e=>d(e.target.value),placeholder:`Add notes about this print...`,rows:2,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white placeholder-bambu-gray text-sm resize-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Project`}),(0,K.jsxs)(`select`,{value:f||``,onChange:e=>p(e.target.value?Number(e.target.value):null),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:``,children:`No project`}),t.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]})]})})}function lze(){let e=no(),{showToast:t}=Td(),[n,r]=(0,y.useState)(!1),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(new Set),[c,l]=(0,y.useState)(new Set),{data:u,isLoading:d}=q({queryKey:[`pending-uploads`],queryFn:rd.list,refetchInterval:1e4}),{data:f}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),p=J({mutationFn:({id:e,data:t})=>rd.archive(e,t),onMutate:({id:e})=>{s(t=>new Set(t).add(e))},onSettled:(e,t,{id:n})=>{s(e=>{let t=new Set(e);return t.delete(n),t})},onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),e.invalidateQueries({queryKey:[`archives`]}),t(`Archived: ${n.print_name}`)},onError:e=>{t(e.message||`Failed to archive`,`error`)}}),m=J({mutationFn:e=>rd.discard(e),onMutate:e=>{l(t=>new Set(t).add(e))},onSettled:(e,t,n)=>{l(e=>{let t=new Set(e);return t.delete(n),t})},onSuccess:()=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),t(`Upload discarded`)},onError:e=>{t(e.message||`Failed to discard`,`error`)}}),h=J({mutationFn:rd.archiveAll,onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),e.invalidateQueries({queryKey:[`archives`]}),t(`Archived ${n.archived} files${n.failed>0?`, ${n.failed} failed`:``}`)},onError:e=>{t(e.message||`Failed to archive all`,`error`)}}),g=J({mutationFn:rd.discardAll,onSuccess:n=>{e.invalidateQueries({queryKey:[`pending-uploads`]}),t(`Discarded ${n.discarded} files`)},onError:e=>{t(e.message||`Failed to discard all`,`error`)}});return d?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})}):!u||u.length===0?null:(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(_d,{className:`border-l-4 border-l-yellow-500`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Du,{className:`w-5 h-5 text-yellow-500`}),(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Pending Uploads (`,u.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>r(!0),disabled:h.isPending,children:h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),`Archive All`]})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>a(!0),disabled:g.isPending,children:g.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Discard All`]})})]})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:`These files were uploaded via the virtual printer. Review and archive them to add to your collection.`}),(0,K.jsx)(`div`,{className:`space-y-3`,children:u.map(e=>(0,K.jsx)(cze,{upload:e,projects:f||[],onArchive:(e,t)=>p.mutate({id:e,data:t}),onDiscard:e=>m.mutate(e),isArchiving:o.has(e.id),isDiscarding:c.has(e.id)},e.id))})]})]}),n&&(0,K.jsx)(Ad,{title:`Archive All Uploads`,message:`Are you sure you want to archive all ${u.length} pending uploads?`,confirmText:`Archive All`,onConfirm:()=>{h.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&(0,K.jsx)(Ad,{title:`Discard All Uploads`,message:`Are you sure you want to discard all ${u.length} pending uploads? This cannot be undone.`,confirmText:`Discard All`,variant:`danger`,onConfirm:()=>{g.mutate(),a(!1)},onCancel:()=>a(!1)})]})}function uze({onClose:e}){let t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(`count`);(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(a?o(null):l?u(null):e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,a,l]);let{data:p,isLoading:m}=q({queryKey:[`tags`],queryFn:Q.getTags}),h=J({mutationFn:({oldName:e,newName:t})=>Q.renameTag(e,t),onSuccess:(e,{oldName:r,newName:i})=>{t.invalidateQueries({queryKey:[`tags`]}),t.invalidateQueries({queryKey:[`archives`]}),n(`Renamed "${r}" to "${i}" in ${e.affected} archive${e.affected===1?``:`s`}`),o(null)},onError:e=>{n(e.message||`Failed to rename tag`,`error`)}}),g=J({mutationFn:e=>Q.deleteTag(e),onSuccess:(e,r)=>{t.invalidateQueries({queryKey:[`tags`]}),t.invalidateQueries({queryKey:[`archives`]}),n(`Deleted "${r}" from ${e.affected} archive${e.affected===1?``:`s`}`),u(null)},onError:e=>{n(e.message||`Failed to delete tag`,`error`)}}),_=e=>{o(e.name),c(e.name),u(null)},v=()=>{o(null),c(``)},b=()=>{if(!a||!s.trim())return;let e=s.trim();if(e===a){v();return}h.mutate({oldName:a,newName:e})},x=e=>{e.key===`Enter`?(e.preventDefault(),b()):e.key===`Escape`&&(e.preventDefault(),v())},S=e=>{u(e),o(null)},C=()=>{l&&g.mutate(l)},w=p?.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())).sort((e,t)=>d===`count`&&t.count-e.count||e.name.localeCompare(t.name)),T=p?.reduce((e,t)=>e+t.count,0)||0;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-lg max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:`Manage Tags`})]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Search tags...`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:r,onChange:e=>i(e.target.value)})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:d,onChange:e=>f(e.target.value),children:[(0,K.jsx)(`option`,{value:`count`,children:`Sort by Count`}),(0,K.jsx)(`option`,{value:`name`,children:`Sort by Name`})]})]}),p&&(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:[p.length,` tag`,p.length===1?``:`s`,` across `,T,` usage`,T===1?``:`s`]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0 p-4`,children:m?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-gray`})}):w?.length?(0,K.jsx)(`div`,{className:`space-y-2`,children:w.map(e=>(0,K.jsx)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group`,children:a===e.name?(0,K.jsxs)(`div`,{className:`flex-1 flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:`flex-1 px-2 py-1 bg-bambu-dark-tertiary border border-bambu-green rounded text-white text-sm focus:outline-none`,value:s,onChange:e=>c(e.target.value),onKeyDown:x,autoFocus:!0}),(0,K.jsx)($,{size:`sm`,variant:`primary`,onClick:b,disabled:!s.trim()||h.isPending,className:`p-1.5`,children:h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:v,className:`p-1.5`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):l===e.name?(0,K.jsxs)(`div`,{className:`flex-1 flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray-light flex-1`,children:[`Delete "`,e.name,`" from `,e.count,` archive`,e.count===1?``:`s`,`?`]}),(0,K.jsx)($,{size:`sm`,variant:`danger`,onClick:C,disabled:g.isPending,className:`p-1.5`,children:g.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>u(null),className:`p-1.5`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-white flex-1 truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs`,children:e.count}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(`button`,{onClick:()=>_(e),className:`p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors`,title:`Rename tag`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>S(e.name),className:`p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors`,title:`Delete tag`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})},e.name))}):(0,K.jsx)(`div`,{className:`text-center py-8 text-bambu-gray`,children:r?`No tags match your search`:`No tags found`})}),(0,K.jsx)(`div`,{className:`flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:`Close`})})]})})})}function $0(e){let t=e.filename;if(t){let e=t.toLowerCase();if(e.endsWith(`.gcode`)||e.includes(`.gcode.`))return!0}return!!(e.total_layers||e.print_time_seconds)}async function e2(e,t,n,r){try{if(n===`source`){let{token:n}=await Q.createSourceSlicerToken(e),i=Q.getSourceSlicerDownloadUrl(e,n,t);HW(`${window.location.origin}${i}`,r)}else{let{token:n}=await Q.createArchiveSlicerToken(e),i=Q.getArchiveSlicerDownloadUrl(e,n,t);HW(`${window.location.origin}${i}`,r)}}catch{let i=n===`source`?Q.getSource3mfForSlicer(e,t):Q.getArchiveForSlicer(e,t);HW(`${window.location.origin}${i}`,r)}}function dze({archive:e,printerName:t,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:s=`system`,preferredSlicer:c=`bambu_studio`,useSlicerApi:l=!1,currency:u,t:d,onNavigateToArchive:f}){o&&console.log(`ArchiveCard isHighlighted=true for archive:`,e.id);let p=no(),{showToast:m}=Td(),{hasPermission:h,canModify:g}=dd(),_=WW(),v=$n(),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),O=q({queryKey:[`archive`,e.id,`delete-impact`],queryFn:()=>Q.getArchiveDeleteImpact(e.id),enabled:w,staleTime:0}),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(!1),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)([]),[z,B]=(0,y.useState)(!1),[V,ee]=(0,y.useState)(!1),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(!1),[H,ae]=(0,y.useState)(!1),[oe,U]=(0,y.useState)(!1),[se,ce]=(0,y.useState)(!1),[le,ue]=(0,y.useState)(null),[de,fe]=(0,y.useState)(null),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(null),_e=(0,y.useRef)(null),ve=(0,y.useRef)(null),ye=(0,y.useRef)(null),{data:be}=q({queryKey:[`archive-plates`,e.id],queryFn:()=>Q.getArchivePlates(e.id),enabled:pe,staleTime:300*1e3}),xe=e.duplicate_sequence??0,Se=e.original_archive_id??null,Ce=be?.plates??[],we=be?.is_multi_plate??!1,Te=de??0,Ee=async()=>{try{let t=await Q.getArchivePlates(e.id);if(t.has_gcode===!1){m(d(`archives.platePicker.noGcode`),`info`);return}if(t.is_multi_plate&&t.plates.length>1){ge(t.plates);return}}catch{}v(`/gcode-viewer?archive=${e.id}`)},De=J({mutationFn:()=>Q.deleteArchiveTimelapse(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveTimelapse`),`error`)}}),Oe=J({mutationFn:t=>Q.uploadArchiveTimelapse(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseUploaded`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadTimelapse`),`error`)}}),ke=J({mutationFn:t=>Q.uploadSource3mf(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.source3mfAttached`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadSource3mf`),`error`)}}),Ae=J({mutationFn:()=>Q.deleteSource3mf(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.source3mfRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveSource3mf`),`error`)}}),je=J({mutationFn:t=>Q.uploadF3d(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.f3dAttached`,{filename:e.filename}))},onError:e=>{m(e.message||d(`archives.toast.failedUploadF3d`),`error`)}}),Me=J({mutationFn:()=>Q.deleteF3d(e.id),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.f3dRemoved`))},onError:e=>{m(e.message||d(`archives.toast.failedRemoveF3d`),`error`)}}),Ne=J({mutationFn:()=>Q.scanArchiveTimelapse(e.id),onSuccess:e=>{e.status===`attached`?(p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseAttached`,{filename:e.filename}))):e.status===`exists`?m(d(`archives.toast.timelapseAlreadyAttached`)):e.status===`not_found`&&e.available_files&&e.available_files.length>0?(R(e.available_files),I(!0)):m(e.message||d(`archives.toast.noMatchingTimelapse`),`warning`)},onError:e=>{m(e.message||d(`archives.toast.failedScanTimelapse`),`error`)}}),Pe=J({mutationFn:t=>Q.selectArchiveTimelapse(e.id,t),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.timelapseAttached`,{filename:e.filename})),I(!1),R([])},onError:e=>{m(e.message||d(`archives.toast.failedAttachTimelapse`),`error`)}}),Fe=J({mutationFn:t=>Q.deleteArchive(e.id,t),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.archiveDeleted`))},onError:()=>{m(d(`archives.toast.failedDeleteArchive`),`error`)}}),Ie=J({mutationFn:()=>Q.toggleFavorite(e.id),onSuccess:e=>{p.invalidateQueries({queryKey:[`archives`]}),m(e.is_favorite?d(`archives.toast.addedToFavorites`):d(`archives.toast.removedFromFavorites`))}}),{data:Le}=q({queryKey:[`archive-folders`,e.id],queryFn:()=>Q.getLibraryFoldersByArchive(e.id)}),Re=J({mutationFn:t=>Q.updateArchive(e.id,{project_id:t}),onSuccess:()=>{p.invalidateQueries({queryKey:[`archives`]}),p.invalidateQueries({queryKey:[`projects`]}),m(d(`archives.toast.projectUpdated`))},onError:()=>{m(d(`archives.toast.failedUpdateProject`),`error`)}}),ze=e=>{e.preventDefault(),ue({x:e.clientX,y:e.clientY})},Be=[...$0(e)?[{label:d(`archives.menu.print`),icon:(0,K.jsx)(Tl,{className:`w-4 h-4`}),onClick:()=>x(!0),disabled:!e.file_path||!g(`archives`,`reprint`,e.created_by_id),title:e.file_path?g(`archives`,`reprint`,e.created_by_id)?void 0:d(`archives.permission.noReprint`):d(`archives.card.noFileForReprint`)},{label:d(`archives.menu.schedule`),icon:(0,K.jsx)(Zo,{className:`w-4 h-4`}),onClick:()=>ie(!0),disabled:!e.file_path||!h(`queue:create`),title:e.file_path?h(`queue:create`)?void 0:d(`archives.permission.noAddToQueue`):d(`archives.card.noFileForReprint`)},{label:d(`archives.menu.openInBambuStudio`),icon:(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)},disabled:!e.file_path,title:e.file_path?void 0:d(`archives.card.noFileForReprint`)}]:[{label:d(`archives.menu.slice`),icon:l?(0,K.jsx)(ks,{className:`w-4 h-4`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{if(l)C(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)}}}],{label:e.external_url?d(`archives.menu.externalLink`):d(`archives.menu.viewOnMakerWorld`),icon:(0,K.jsx)(bc,{className:`w-4 h-4`}),onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url},{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.preview3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>{Ee()}},{label:d(`archives.menu.viewTimelapse`),icon:(0,K.jsx)(ic,{className:`w-4 h-4`}),onClick:()=>P(!0),disabled:!e.timelapse_path},{label:d(`archives.menu.scanForTimelapse`),icon:(0,K.jsx)(Il,{className:`w-4 h-4`}),onClick:()=>Ne.mutate(),disabled:!e.printer_id||!!e.timelapse_path||Ne.isPending||!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.uploadTimelapse`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ye.current?.click(),disabled:!!e.timelapse_path||!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},...e.timelapse_path?[{label:d(`archives.menu.removeTimelapse`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>ce(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:e.source_3mf_path?d(`archives.menu.downloadSource3mf`):d(`archives.menu.uploadSource3mf`),icon:(0,K.jsx)($s,{className:`w-4 h-4`}),onClick:()=>{e.source_3mf_path?Q.downloadSource3mf(e.id).catch(e=>{console.error(`Source 3MF download failed:`,e)}):_e.current?.click()},disabled:!e.source_3mf_path&&!g(`archives`,`update`,e.created_by_id),title:!e.source_3mf_path&&!g(`archives`,`update`,e.created_by_id)?d(`archives.permission.noUploadFiles`):void 0},...e.source_3mf_path?[{label:d(`archives.menu.replaceSource3mf`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>_e.current?.click(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.removeSource3mf`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>ae(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:e.f3d_path?d(`archives.menu.replaceF3d`):d(`archives.menu.uploadF3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>ve.current?.click(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},...e.f3d_path?[{label:d(`archives.menu.downloadF3d`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})}},{label:d(`archives.menu.removeF3d`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>U(!0),danger:!0,disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.download`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},disabled:!h(`archives:read`),title:h(`archives:read`)?void 0:d(`archives.permission.noDownload`)},{label:d(`archives.menu.copyDownloadLink`),icon:(0,K.jsx)(Ms,{className:`w-4 h-4`}),onClick:()=>{let t=`${window.location.origin}${Q.getArchiveDownload(e.id)}`;navigator.clipboard.writeText(t).then(()=>{m(d(`archives.toast.linkCopied`))}).catch(()=>{m(d(`archives.toast.failedCopyLink`),`error`)})},disabled:!h(`archives:read`),title:h(`archives:read`)?void 0:d(`archives.permission.noCopyLink`)},{label:d(`archives.menu.qrCode`),icon:(0,K.jsx)(El,{className:`w-4 h-4`}),onClick:()=>B(!0)},{label:e.photos?.length?d(`archives.menu.viewPhotosCount`,{count:e.photos.length}):d(`archives.menu.viewPhotos`),icon:(0,K.jsx)(Qo,{className:`w-4 h-4`}),onClick:()=>ee(!0),disabled:!e.photos?.length},{label:d(`archives.menu.projectPage`),icon:(0,K.jsx)(nc,{className:`w-4 h-4`}),onClick:()=>ne(!0)},{label:``,divider:!0,onClick:()=>{}},{label:e.is_favorite?d(`archives.menu.removeFromFavorites`):d(`archives.menu.addToFavorites`),icon:(0,K.jsx)(su,{className:`w-4 h-4 ${e.is_favorite?`fill-yellow-400 text-yellow-400`:``}`}),onClick:()=>Ie.mutate(),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.edit`),icon:(0,K.jsx)(vl,{className:`w-4 h-4`}),onClick:()=>A(!0),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`)},{label:d(`archives.menu.printLog`),icon:(0,K.jsx)(kc,{className:`w-4 h-4`}),onClick:()=>M(!0)},...e.project_id&&e.project_name?[{label:d(`archives.menu.goToProject`,{name:e.project_name}),icon:(0,K.jsx)(sc,{className:`w-4 h-4 text-bambu-green`}),onClick:()=>window.location.href=`/projects`}]:[],{label:d(`archives.menu.addToProject`),icon:(0,K.jsx)(sc,{className:`w-4 h-4`}),onClick:()=>{},disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?void 0:d(`archives.permission.noUpdateArchives`),submenuSearchPlaceholder:(a?.filter(e=>e.status===`active`).length??0)>5?d(`archives.menu.searchProjects`):void 0,submenu:(()=>{let t=[];if(e.project_id&&t.push({label:d(`archives.menu.removeFromProject`),icon:(0,K.jsx)(Ru,{className:`w-4 h-4`}),onClick:()=>Re.mutate(null),disabled:!g(`archives`,`update`,e.created_by_id)}),!a)t.push({label:d(`archives.menu.loading`),icon:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),onClick:()=>{},disabled:!0});else{let n=a.filter(e=>e.status===`active`).sort((e,t)=>e.name.localeCompare(t.name));n.length===0?t.push({label:d(`archives.menu.noProjectsAvailable`),icon:(0,K.jsx)(sc,{className:`w-4 h-4 opacity-50`}),onClick:()=>{},disabled:!0}):n.forEach(n=>{t.push({label:n.name,icon:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:n.color||`#888`}}),onClick:()=>Re.mutate(n.id),disabled:e.project_id===n.id||!g(`archives`,`update`,e.created_by_id)})})}return t})()},{label:d(n?`archives.menu.deselect`:`archives.menu.select`),icon:n?(0,K.jsx)(iu,{className:`w-4 h-4`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),onClick:()=>r(e.id)},{label:``,divider:!0,onClick:()=>{}},{label:d(`archives.menu.delete`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>T(!0),danger:!0,disabled:!g(`archives`,`delete`,e.created_by_id),title:g(`archives`,`delete`,e.created_by_id)?void 0:d(`archives.permission.noDelete`)}];return(0,K.jsxs)(_d,{"data-archive-id":e.id,className:`relative flex flex-col group ${n?`ring-2 ring-bambu-green`:``} ${i?`cursor-pointer`:``}`,style:o?{outline:`4px solid #facc15`,outlineOffset:`2px`}:void 0,onContextMenu:ze,onClick:i?()=>r(e.id):void 0,children:[i&&(0,K.jsx)(`button`,{className:`absolute top-2 left-2 z-10 p-1 rounded bg-black/50 hover:bg-black/70 transition-colors`,onClick:t=>{t.stopPropagation(),r(e.id)},children:n?(0,K.jsx)(iu,{className:`w-5 h-5 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-5 h-5 text-white`})}),(0,K.jsxs)(`div`,{className:`aspect-video bg-bambu-dark relative flex-shrink-0 overflow-hidden rounded-t-xl`,onMouseEnter:()=>me(!0),onMouseLeave:()=>me(!1),children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:de!==null&&Ce.length>0?Q.getArchivePlateThumbnail(e.id,Ce[Te]?.index??0):Q.getArchiveThumbnail(e.id),alt:e.print_name||e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(Mc,{className:`w-12 h-12 text-bambu-dark-tertiary`})}),we&&Ce.length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{className:`absolute left-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>{e.stopPropagation(),fe(e=>{let t=e??0;return t>0?t-1:Ce.length-1})},title:d(`archives.card.previousPlate`),children:(0,K.jsx)(ss,{className:`w-4 h-4 text-white`})}),(0,K.jsx)(`button`,{className:`absolute right-1 top-1/2 -translate-y-1/2 p-1 rounded-full bg-black/60 hover:bg-black/80 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>{e.stopPropagation(),fe(e=>{let t=e??0;return t(0,K.jsx)(`button`,{className:`w-2 h-2 rounded-full transition-colors ${t===Te?`bg-bambu-green`:`bg-white/50 hover:bg-white/80`}`,onClick:e=>{e.stopPropagation(),fe(t)},title:e.name||d(`archives.card.plateNumber`,{index:e.index})},e.index))})]}),(0,K.jsx)(`button`,{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${_?`opacity-100`:`opacity-0 group-hover:opacity-100`} ${i?`left-10`:``}`,onClick:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect();ue({x:t.left,y:t.bottom+4})},title:d(`archives.card.moreOptions`),children:(0,K.jsx)(Ws,{className:`w-5 h-5 text-white`})}),(0,K.jsx)(`button`,{className:`absolute top-2 right-2 p-1 rounded transition-colors ${g(`archives`,`update`,e.created_by_id)?`bg-black/50 hover:bg-black/70`:`bg-black/30 cursor-not-allowed`}`,onClick:t=>{t.stopPropagation(),g(`archives`,`update`,e.created_by_id)&&Ie.mutate()},disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?e.is_favorite?d(`archives.card.removeFromFavorites`):d(`archives.card.addToFavorites`):d(`archives.permission.noUpdateArchives`),children:(0,K.jsx)(su,{className:`w-5 h-5 ${e.is_favorite?`text-yellow-400 fill-yellow-400`:`text-white`} ${g(`archives`,`update`,e.created_by_id)?``:`opacity-50`}`})}),(e.status===`failed`||e.status===`aborted`)&&(0,K.jsx)(`div`,{className:`absolute top-2 left-12 px-2 py-1 rounded text-xs bg-status-error/80 text-white`,children:e.status===`aborted`?d(`archives.card.cancelled`):d(`archives.card.failed`)}),e.duplicate_count>0&&xe>0&&Se&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f?.(Se)},className:`absolute top-2 right-12 px-2 py-1 rounded text-xs bg-purple-500/80 hover:bg-purple-600/90 text-white flex items-center gap-1 transition-colors cursor-pointer`,title:d(`archives.viewOriginalPrint`,{id:Se}),children:[(0,K.jsx)(Ms,{className:`w-3 h-3`}),`#`,xe]}),e.duplicate_count>0&&xe===0&&(0,K.jsxs)(`span`,{className:`absolute top-2 right-12 px-2 py-1 rounded text-xs bg-purple-500/80 text-white flex items-center gap-1`,title:`${e.duplicate_count} reprint${e.duplicate_count===1?``:`s`}`,children:[(0,K.jsx)(_c,{className:`w-3 h-3`}),`+`,e.duplicate_count]}),e.source_3mf_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 left-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:t=>{t.stopPropagation();let n=(e.print_name||e.filename||`source`).replace(/\.gcode\.3mf$/i,``)+`_source`;e2(e.id,n,`source`,c)},title:d(`archives.card.openSource3mf`),children:(0,K.jsx)($s,{className:`w-4 h-4 text-orange-400`})}),e.f3d_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 ${e.source_3mf_path?`left-12`:`left-2`} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:t=>{t.stopPropagation(),Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})},title:d(`archives.card.downloadF3d`),children:(0,K.jsx)(Wo,{className:`w-4 h-4 text-cyan-400`})}),(0,K.jsx)(`button`,{className:`absolute bottom-2 right-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),Ee()},title:d(`archives.card.preview3d`),children:(0,K.jsx)(Rc,{className:`w-4 h-4 text-white`})}),e.timelapse_path&&(0,K.jsx)(`button`,{className:`absolute bottom-2 right-12 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),P(!0)},title:d(`archives.card.viewTimelapse`),children:(0,K.jsx)(ic,{className:`w-4 h-4 text-bambu-green`})}),e.photos&&e.photos.length>0&&(0,K.jsxs)(`button`,{className:`absolute bottom-2 ${e.timelapse_path?`right-[5.5rem]`:`right-12`} p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>{e.stopPropagation(),ee(!0)},title:e.photos.length===1?d(`archives.card.viewPhoto`):d(`archives.card.viewPhotos`,{count:e.photos.length}),children:[(0,K.jsx)(Qo,{className:`w-4 h-4 text-blue-400`}),e.photos.length>1&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 w-4 h-4 bg-blue-500 rounded-full text-[10px] text-white flex items-center justify-center`,children:e.photos.length})]}),Le&&Le.length>0&&(0,K.jsx)(wi,{to:`/files?folder=${Le[0].id}`,className:`absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors`,onClick:e=>e.stopPropagation(),title:d(`archives.card.openFolder`,{name:Le[0].name}),style:{left:e.source_3mf_path?e.f3d_path?`5.5rem`:`3rem`:e.f3d_path?`3rem`:`0.5rem`},children:(0,K.jsx)(cc,{className:`w-4 h-4 text-yellow-400`})})]}),(0,K.jsxs)(yd,{className:`p-4 flex-1 flex flex-col`,children:[(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray/70 mb-1`,children:[`#`,e.id]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,K.jsx)(`h3`,{className:`min-w-0 font-medium text-white truncate`,children:e.print_name||e.filename}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,className:`p-1 sm:p-1.5 shrink-0`,onClick:()=>A(!0),disabled:!g(`archives`,`update`,e.created_by_id),title:g(`archives`,`update`,e.created_by_id)?d(`archives.card.edit`):d(`archives.card.noPermissionEdit`),children:(0,K.jsx)(vl,{className:`w-3 h-3 sm:w-4 sm:h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:t}),(()=>{let t=$U(e.bed_type);return t?(0,K.jsx)(`img`,{src:t.icon,alt:t.label,title:t.label,className:`w-4 h-4 flex-shrink-0`}):null})(),(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${$0(e)?`bg-bambu-green/20 text-bambu-green`:`bg-orange-500/20 text-orange-400`}`,title:$0(e)?d(`archives.card.slicedFile`):d(`archives.card.sourceFile`),children:$0(e)?d(`archives.card.gcode`):d(`archives.card.source`)}),e.content_hash&&(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded font-mono bg-bambu-dark-tertiary/50 text-bambu-gray-light opacity-0 transition-opacity duration-150 group-hover:opacity-100`,title:`SHA256: ${e.content_hash}`,children:e.content_hash.slice(0,8).toUpperCase()}),e.project_name&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]`,style:{backgroundColor:`${a?.find(t=>t.id===e.project_id)?.color||`#6b7280`}20`,color:a?.find(t=>t.id===e.project_id)?.color||`#6b7280`},title:d(`archives.card.project`,{name:e.project_name}),children:e.project_name}),e.run_count>1&&(0,K.jsx)(`button`,{className:`text-[10px] px-1.5 py-0.5 rounded font-medium bg-bambu-orange/20 text-bambu-orange hover:bg-bambu-orange/30 transition-colors cursor-pointer`,onClick:e=>{e.stopPropagation(),M(!0)},title:d(`archives.card.runsBadgeTitle`,{count:e.run_count,successful:e.successful_run_count,failed:e.failed_run_count}),children:d(`archives.card.runsBadge`,{count:e.run_count})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs mb-4 min-h-[48px]`,children:[(e.print_time_seconds||e.actual_time_seconds)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:e.time_accuracy?`Estimated: ${Cf(e.print_time_seconds||0)}\nActual: ${Cf(e.actual_time_seconds||0)}\nAccuracy: ${e.time_accuracy.toFixed(0)}%`:e.actual_time_seconds?`Actual: ${Cf(e.actual_time_seconds)}`:`Estimated: ${Cf(e.print_time_seconds||0)}`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(e.actual_time_seconds||e.print_time_seconds||0),e.time_accuracy&&(0,K.jsxs)(`span`,{className:`text-[10px] px-1 rounded ${e.time_accuracy>=95&&e.time_accuracy<=105?`bg-bambu-green/20 text-bambu-green`:e.time_accuracy>105?`bg-blue-500/20 text-blue-400`:`bg-orange-500/20 text-orange-400`}`,children:[e.time_accuracy>100?`+`:``,(e.time_accuracy-100).toFixed(0),`%`]})]}),e.filament_used_grams&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-3 h-3`}),e.filament_used_grams.toFixed(1),`g`]}),(e.cost!=null||e.energy_cost!=null)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-bambu-gray`,children:[e.cost!=null&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Os,{className:`w-3 h-3`}),u,e.cost.toFixed(2)]}),e.energy_cost!=null&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:`${d(`stats.energyUsed`)}: ${e.energy_kwh?.toFixed(3)||`N/A`} kWh`,children:[(0,K.jsx)(Bu,{className:`w-3 h-3`}),u,e.energy_cost.toFixed(2)]})]}),(e.layer_height||e.total_layers)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),e.total_layers&&(0,K.jsx)(`span`,{children:e.total_layers===1?d(`archives.card.layer`,{count:e.total_layers}):d(`archives.card.layers`,{count:e.total_layers})}),e.total_layers&&e.layer_height&&(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`·`}),e.layer_height&&(0,K.jsxs)(`span`,{children:[e.layer_height,`mm`]})]}),e.object_count!=null&&e.object_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:e.object_count===1?d(`archives.card.object`,{count:e.object_count}):d(`archives.card.objects`,{count:e.object_count}),children:[(0,K.jsx)(Wo,{className:`w-3 h-3`}),e.object_count===1?d(`archives.card.object`,{count:e.object_count}):d(`archives.card.objects`,{count:e.object_count})]}),e.sliced_for_model&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,title:d(`archives.card.slicedFor`,{model:e.sliced_for_model}),children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),e.sliced_for_model]}),e.filament_type&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 col-span-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.filament_type}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e},title:e},t))})]})]}),(e.tags||e.notes)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,children:[e.notes&&(0,K.jsx)(`div`,{className:`flex items-center gap-1 px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded text-xs`,title:e.notes,children:(0,K.jsx)(lu,{className:`w-3 h-3`})}),e.tags?.split(`,`).map((e,t)=>(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs`,children:e.trim()},t))]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`span`,{children:bf(e.created_at,s)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.created_by_username&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,title:d(`archives.card.uploadedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]}),(0,K.jsx)(`span`,{children:Cd(e.file_size)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 mt-3`,children:[$0(e)?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>x(!0),disabled:!e.file_path||!g(`archives`,`reprint`,e.created_by_id),title:e.file_path?g(`archives`,`reprint`,e.created_by_id)?void 0:d(`archives.card.noPermissionReprint`):d(`archives.card.noFileForReprint`),children:[(0,K.jsx)(Tl,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.reprint`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>ie(!0),disabled:!e.file_path||!h(`queue:create`),title:e.file_path?h(`queue:create`)?d(`archives.card.schedulePrint`):d(`archives.permission.noAddToQueue`):d(`archives.card.noFileForReprint`),children:[(0,K.jsx)(Zo,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.schedule`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)},title:d(`archives.card.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-3 h-3 sm:w-4 sm:h-4`})})]}):(0,K.jsxs)($,{variant:`primary`,size:`sm`,className:`flex-1 min-w-0 overflow-hidden`,onClick:()=>{if(l)C(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,c)}},title:d(l?`slice.title`:`archives.card.openInBambuStudioToSlice`),children:[l?(0,K.jsx)(ks,{className:`w-3 h-3 flex-shrink-0`}):(0,K.jsx)(Js,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`hidden xl:inline truncate`,children:d(`archives.card.slice`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url,title:e.external_url?d(`archives.card.externalLink`):e.makerworld_url?d(`archives.card.makerWorld`,{designer:e.designer||d(`archives.card.viewProject`)}):d(`archives.card.noExternalLink`),children:(0,K.jsx)(bc,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!e.external_url&&!e.makerworld_url?`opacity-20`:``}`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},title:d(`archives.card.download`),children:(0,K.jsx)(Vs,{className:`w-3 h-3 sm:w-4 sm:h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,className:`min-w-0 p-1 sm:p-1.5`,onClick:()=>T(!0),disabled:!g(`archives`,`delete`,e.created_by_id),title:g(`archives`,`delete`,e.created_by_id)?d(`archives.card.delete`):d(`archives.card.noPermissionDelete`),children:(0,K.jsx)(bu,{className:`w-3 h-3 sm:w-4 sm:h-4 text-red-400`})})]})]}),k&&(0,K.jsx)(JW,{archive:e,onClose:()=>A(!1)}),j&&(0,K.jsx)(YW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>M(!1)}),he&&(0,K.jsx)(PW,{plates:he,onSelect:t=>{ge(null),v(`/gcode-viewer?archive=${e.id}&plate=${t}`)},onClose:()=>ge(null)}),b&&(0,K.jsx)(sW,{mode:`reprint`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>x(!1)}),S&&(0,K.jsx)(zW,{source:{kind:`archive`,id:e.id,filename:e.print_name||e.filename||`model`},onClose:()=>C(!1)}),w&&(0,K.jsxs)(Ad,{title:d(`archives.modal.deleteArchive`),message:d(`archives.modal.deleteConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.deleteButton`),variant:`danger`,confirmDisabled:(O.data?.currently_printing??0)>0,onConfirm:()=>{Fe.mutate(E),T(!1),D(!1)},onCancel:()=>{T(!1),D(!1)},children:[(O.data?.related_queue_items??0)>0&&(0,K.jsx)(`div`,{className:(O.data?.currently_printing??0)>0?`text-sm text-red-400 mb-2`:`text-sm text-amber-400 mb-2`,children:(O.data?.currently_printing??0)>0?d(`archives.modal.deleteBlockedByPrinting`,{count:O.data.currently_printing}):d(`archives.modal.deleteQueueItemsWarning`,{count:O.data.related_queue_items})}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer text-sm text-bambu-gray`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 accent-red-500`,checked:E,onChange:e=>D(e.target.checked)}),(0,K.jsx)(`span`,{children:d(`archives.modal.deletePurgeStats`)})]})]}),H&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeSource3mf`),message:d(`archives.modal.removeSource3mfConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{Ae.mutate(),ae(!1)},onCancel:()=>ae(!1)}),oe&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeF3d`),message:d(`archives.modal.removeF3dConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{Me.mutate(),U(!1)},onCancel:()=>U(!1)}),se&&(0,K.jsx)(Ad,{title:d(`archives.modal.removeTimelapse`),message:d(`archives.modal.removeTimelapseConfirm`,{name:e.print_name||e.filename}),confirmText:d(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{De.mutate(),ce(!1)},onCancel:()=>ce(!1)}),le&&(0,K.jsx)(XW,{x:le.x,y:le.y,items:Be,onClose:()=>ue(null)}),N&&e.timelapse_path&&(0,K.jsx)(Q0,{src:Q.getArchiveTimelapse(e.id),title:d(`archives.modal.timelapse`,{name:e.print_name||e.filename}),downloadFilename:`${e.print_name||e.filename}_timelapse.mp4`,archiveId:e.id,onClose:()=>P(!1),onEdit:()=>{p.invalidateQueries({queryKey:[`archives`]}),P(!1)}}),F&&L.length>0&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:d(`archives.modal.selectTimelapse`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 mt-1`,children:d(`archives.modal.selectTimelapseDesc`)})]}),(0,K.jsx)(`button`,{onClick:()=>{I(!1),R([])},className:`text-gray-400 hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 p-2`,children:L.map(e=>(0,K.jsxs)(`button`,{onClick:()=>Pe.mutate(e.name),disabled:Pe.isPending,className:`w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors flex items-center gap-3 disabled:opacity-50`,children:[(0,K.jsx)(ic,{className:`w-8 h-8 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-sm text-gray-400`,children:[Cd(e.size),e.mtime&&` • ${bf(e.mtime,s)}`]})]})]},e.name))}),(0,K.jsx)(`div`,{className:`p-4 border-t border-gray-700`,children:(0,K.jsx)($,{variant:`secondary`,onClick:()=>{I(!1),R([])},className:`w-full`,children:`Cancel`})})]})}),z&&(0,K.jsx)(ZW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>B(!1)}),V&&e.photos&&e.photos.length>0&&(0,K.jsx)(QW,{archiveId:e.id,archiveName:e.print_name||e.filename,photos:e.photos,onClose:()=>ee(!1),onDelete:async t=>{try{await Q.deleteArchivePhoto(e.id,t),p.invalidateQueries({queryKey:[`archives`]}),m(d(`archives.toast.photoDeleted`))}catch{m(d(`archives.toast.failedDeletePhoto`),`error`)}}}),te&&(0,K.jsx)(Z0,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>ne(!1)}),re&&(0,K.jsx)(sW,{mode:`add-to-queue`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>ie(!1)}),(0,K.jsx)(`input`,{ref:_e,type:`file`,accept:`.3mf`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&ke.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ve,type:`file`,accept:`.f3d`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&je.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ye,type:`file`,accept:`.mp4,.avi,.mkv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&Oe.mutate(t),e.target.value=``}})]})}function fze({archive:e,printerName:t,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,preferredSlicer:s=`bambu_studio`,useSlicerApi:c=!1,t:l,onNavigateToArchive:u}){let d=no(),{showToast:f}=Td(),{hasPermission:p,canModify:m}=dd(),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),w=q({queryKey:[`archive`,e.id,`delete-impact`],queryFn:()=>Q.getArchiveDeleteImpact(e.id),enabled:b,staleTime:0}),T=$n(),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)([]),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!1),[ee,te]=(0,y.useState)(!1),[ne,re]=(0,y.useState)(!1),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(null),ce=(0,y.useRef)(null),le=(0,y.useRef)(null),ue=(0,y.useRef)(null),[de,fe]=(0,y.useState)(null),pe=e.duplicate_sequence??0,me=e.original_archive_id??null,he=async()=>{try{let t=await Q.getArchivePlates(e.id);if(t.is_multi_plate&&t.plates.length>1){fe(t.plates);return}}catch{}T(`/gcode-viewer?archive=${e.id}`)},ge=J({mutationFn:()=>Q.deleteArchiveTimelapse(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveTimelapse`),`error`)}}),_e=J({mutationFn:t=>Q.uploadArchiveTimelapse(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseUploaded`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadTimelapse`),`error`)}}),ve=J({mutationFn:t=>Q.uploadSource3mf(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.source3mfAttached`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadSource3mf`),`error`)}}),ye=J({mutationFn:()=>Q.deleteSource3mf(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.source3mfRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveSource3mf`),`error`)}}),be=J({mutationFn:t=>Q.uploadF3d(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.f3dAttached`,{filename:e.filename}))},onError:e=>{f(e.message||l(`archives.toast.failedUploadF3d`),`error`)}}),xe=J({mutationFn:()=>Q.deleteF3d(e.id),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.f3dRemoved`))},onError:e=>{f(e.message||l(`archives.toast.failedRemoveF3d`),`error`)}}),Se=J({mutationFn:()=>Q.scanArchiveTimelapse(e.id),onSuccess:e=>{e.status===`attached`?(d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseAttached`,{filename:e.filename}))):e.status===`exists`?f(l(`archives.toast.timelapseAlreadyAttached`)):e.status===`not_found`&&e.available_files&&e.available_files.length>0?(L(e.available_files),F(!0)):f(e.message||l(`archives.toast.noMatchingTimelapse`),`warning`)},onError:e=>{f(e.message||l(`archives.toast.failedScanTimelapse`),`error`)}}),Ce=J({mutationFn:t=>Q.selectArchiveTimelapse(e.id,t),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.timelapseAttached`,{filename:e.filename})),F(!1),L([])},onError:e=>{f(e.message||l(`archives.toast.failedAttachTimelapse`),`error`)}}),we=J({mutationFn:t=>Q.deleteArchive(e.id,t),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.archiveDeleted`))},onError:()=>{f(l(`archives.toast.failedDeleteArchive`),`error`)}}),Te=J({mutationFn:()=>Q.toggleFavorite(e.id),onSuccess:e=>{d.invalidateQueries({queryKey:[`archives`]}),f(e.is_favorite?l(`archives.toast.addedToFavorites`):l(`archives.toast.removedFromFavorites`))}}),{data:Ee}=q({queryKey:[`archive-folders`,e.id],queryFn:()=>Q.getLibraryFoldersByArchive(e.id)}),De=J({mutationFn:t=>Q.updateArchive(e.id,{project_id:t}),onSuccess:()=>{d.invalidateQueries({queryKey:[`archives`]}),d.invalidateQueries({queryKey:[`projects`]}),f(l(`archives.toast.projectUpdated`))},onError:()=>{f(l(`archives.toast.failedUpdateProject`),`error`)}}),Oe=e=>{e.preventDefault(),se({x:e.clientX,y:e.clientY})},ke=[...$0(e)?[{label:l(`archives.menu.print`),icon:(0,K.jsx)(Tl,{className:`w-4 h-4`}),onClick:()=>D(!0),disabled:!e.file_path||!m(`archives`,`reprint`,e.created_by_id),title:e.file_path?m(`archives`,`reprint`,e.created_by_id)?void 0:l(`archives.permission.noReprint`):l(`archives.card.noFileForReprint`)},{label:l(`archives.menu.schedule`),icon:(0,K.jsx)(Zo,{className:`w-4 h-4`}),onClick:()=>j(!0),disabled:!e.file_path||!p(`queue:create`),title:e.file_path?p(`queue:create`)?void 0:l(`archives.permission.noAddToQueue`):l(`archives.card.noFileForReprint`)},{label:l(`archives.menu.openInBambuStudio`),icon:(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)},disabled:!e.file_path,title:e.file_path?void 0:l(`archives.card.noFileForReprint`)}]:[{label:l(`archives.menu.slice`),icon:c?(0,K.jsx)(ks,{className:`w-4 h-4`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),onClick:()=>{if(c)k(!0);else{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)}}}],{label:e.external_url?l(`archives.menu.externalLink`):l(`archives.menu.viewOnMakerWorld`),icon:(0,K.jsx)(bc,{className:`w-4 h-4`}),onClick:()=>{let t=e.external_url||e.makerworld_url;t&&window.open(t,`_blank`)},disabled:!e.external_url&&!e.makerworld_url},{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.preview3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>{he()}},{label:l(`archives.menu.viewTimelapse`),icon:(0,K.jsx)(ic,{className:`w-4 h-4`}),onClick:()=>N(!0),disabled:!e.timelapse_path},{label:l(`archives.menu.scanForTimelapse`),icon:(0,K.jsx)(Il,{className:`w-4 h-4`}),onClick:()=>Se.mutate(),disabled:!e.printer_id||!!e.timelapse_path||Se.isPending||!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.uploadTimelapse`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ue.current?.click(),disabled:!!e.timelapse_path||!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},...e.timelapse_path?[{label:l(`archives.menu.removeTimelapse`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>oe(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:e.source_3mf_path?l(`archives.menu.downloadSource3mf`):l(`archives.menu.uploadSource3mf`),icon:(0,K.jsx)($s,{className:`w-4 h-4`}),onClick:()=>{e.source_3mf_path?Q.downloadSource3mf(e.id).catch(e=>{console.error(`Source 3MF download failed:`,e)}):ce.current?.click()},disabled:!e.source_3mf_path&&!m(`archives`,`update`,e.created_by_id),title:!e.source_3mf_path&&!m(`archives`,`update`,e.created_by_id)?l(`archives.permission.noUploadFiles`):void 0},...e.source_3mf_path?[{label:l(`archives.menu.replaceSource3mf`),icon:(0,K.jsx)(Du,{className:`w-4 h-4`}),onClick:()=>ce.current?.click(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.removeSource3mf`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>re(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:e.f3d_path?l(`archives.menu.replaceF3d`):l(`archives.menu.uploadF3d`),icon:(0,K.jsx)(Wo,{className:`w-4 h-4`}),onClick:()=>le.current?.click(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},...e.f3d_path?[{label:l(`archives.menu.downloadF3d`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadF3d(e.id).catch(e=>{console.error(`F3D download failed:`,e)})}},{label:l(`archives.menu.removeF3d`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>H(!0),danger:!0,disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)}]:[],{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.download`),icon:(0,K.jsx)(Vs,{className:`w-4 h-4`}),onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},disabled:!p(`archives:read`),title:p(`archives:read`)?void 0:l(`archives.permission.noDownload`)},{label:l(`archives.menu.copyDownloadLink`),icon:(0,K.jsx)(Ms,{className:`w-4 h-4`}),onClick:()=>{let t=`${window.location.origin}${Q.getArchiveDownload(e.id)}`;navigator.clipboard.writeText(t).then(()=>{f(l(`archives.toast.linkCopied`))}).catch(()=>{f(l(`archives.toast.failedCopyLink`),`error`)})},disabled:!p(`archives:read`),title:p(`archives:read`)?void 0:l(`archives.permission.noCopyLink`)},{label:l(`archives.menu.qrCode`),icon:(0,K.jsx)(El,{className:`w-4 h-4`}),onClick:()=>z(!0)},{label:e.photos?.length?l(`archives.menu.viewPhotosCount`,{count:e.photos.length}):l(`archives.menu.viewPhotos`),icon:(0,K.jsx)(Qo,{className:`w-4 h-4`}),onClick:()=>V(!0),disabled:!e.photos?.length},{label:l(`archives.menu.projectPage`),icon:(0,K.jsx)(nc,{className:`w-4 h-4`}),onClick:()=>te(!0)},{label:``,divider:!0,onClick:()=>{}},{label:e.is_favorite?l(`archives.menu.removeFromFavorites`):l(`archives.menu.addToFavorites`),icon:(0,K.jsx)(su,{className:`w-4 h-4 ${e.is_favorite?`fill-yellow-400 text-yellow-400`:``}`}),onClick:()=>Te.mutate(),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.edit`),icon:(0,K.jsx)(vl,{className:`w-4 h-4`}),onClick:()=>g(!0),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?void 0:l(`archives.permission.noUpdateArchives`)},{label:l(`archives.menu.printLog`),icon:(0,K.jsx)(kc,{className:`w-4 h-4`}),onClick:()=>v(!0)},...e.project_id&&e.project_name?[{label:l(`archives.menu.goToProject`,{name:e.project_name}),icon:(0,K.jsx)(sc,{className:`w-4 h-4 text-bambu-green`}),onClick:()=>window.location.href=`/projects`}]:[],{label:l(`archives.menu.addToProject`),icon:(0,K.jsx)(sc,{className:`w-4 h-4`}),onClick:()=>{},submenuSearchPlaceholder:(a?.filter(e=>e.status===`active`).length??0)>5?l(`archives.menu.searchProjects`):void 0,submenu:(()=>{let t=[];if(e.project_id&&t.push({label:l(`archives.menu.removeFromProject`),icon:(0,K.jsx)(Ru,{className:`w-4 h-4`}),onClick:()=>De.mutate(null)}),!a)t.push({label:l(`archives.menu.loading`),icon:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),onClick:()=>{},disabled:!0});else{let n=a.filter(e=>e.status===`active`).sort((e,t)=>e.name.localeCompare(t.name));n.length===0?t.push({label:l(`archives.menu.noProjectsAvailable`),icon:(0,K.jsx)(sc,{className:`w-4 h-4 opacity-50`}),onClick:()=>{},disabled:!0}):n.forEach(n=>{t.push({label:n.name,icon:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:n.color||`#888`}}),onClick:()=>De.mutate(n.id),disabled:e.project_id===n.id})})}return t})()},{label:l(n?`archives.menu.deselect`:`archives.menu.select`),icon:n?(0,K.jsx)(iu,{className:`w-4 h-4`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),onClick:()=>r(e.id)},{label:``,divider:!0,onClick:()=>{}},{label:l(`archives.menu.delete`),icon:(0,K.jsx)(bu,{className:`w-4 h-4`}),onClick:()=>x(!0),danger:!0,disabled:!m(`archives`,`delete`,e.created_by_id),title:m(`archives`,`delete`,e.created_by_id)?void 0:l(`archives.permission.noDelete`)}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{"data-archive-id":e.id,className:`grid grid-cols-12 gap-4 px-4 py-3 items-center hover:bg-bambu-dark-tertiary/30 ${n?`bg-bambu-green/10`:``}`,style:o?{outline:`4px solid #facc15`,outlineOffset:`-4px`}:void 0,onContextMenu:Oe,children:[(0,K.jsxs)(`div`,{className:`col-span-1 flex items-center gap-2`,children:[i&&(0,K.jsx)(`button`,{onClick:()=>r(e.id),children:n?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray`})}),e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:``,className:`w-10 h-10 object-cover rounded`}):(0,K.jsx)(`div`,{className:`w-10 h-10 bg-bambu-dark rounded flex items-center justify-center`,children:(0,K.jsx)(Mc,{className:`w-5 h-5 text-bambu-dark-tertiary`})})]}),(0,K.jsxs)(`div`,{className:`col-span-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`p`,{className:`text-white text-sm truncate`,children:e.print_name||e.filename}),(e.status===`failed`||e.status===`aborted`)&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-status-error/80 text-white flex-shrink-0`,children:e.status===`aborted`?l(`archives.card.cancelled`):l(`archives.card.failed`)}),e.duplicate_count>0&&pe>0&&me&&(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),u?.(me)},className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-purple-500/80 hover:bg-purple-600/90 text-white flex-shrink-0 transition-colors flex items-center gap-1`,title:l(`archives.viewOriginalPrint`,{id:me}),children:[(0,K.jsx)(Ms,{className:`w-3 h-3`}),`#`,pe]}),e.duplicate_count>0&&pe===0&&(0,K.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] leading-tight bg-purple-500/80 text-white flex-shrink-0 flex items-center gap-1`,title:`${e.duplicate_count} reprint${e.duplicate_count===1?``:`s`}`,children:[(0,K.jsx)(_c,{className:`w-3 h-3`}),`+`,e.duplicate_count]}),e.timelapse_path&&(0,K.jsx)(`span`,{title:l(`archives.list.hasTimelapse`),children:(0,K.jsx)(ic,{className:`w-3.5 h-3.5 text-bambu-green flex-shrink-0`})}),Ee&&Ee.length>0&&(0,K.jsx)(wi,{to:`/files?folder=${Ee[0].id}`,className:`flex-shrink-0`,title:l(`archives.card.openFolder`,{name:Ee[0].name}),onClick:e=>e.stopPropagation(),children:(0,K.jsx)(cc,{className:`w-3.5 h-3.5 text-yellow-400`})})]}),(e.filament_type||e.sliced_for_model)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[e.sliced_for_model&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex items-center gap-1`,title:l(`archives.card.slicedFor`,{model:e.sliced_for_model}),children:[(0,K.jsx)(Tl,{className:`w-2.5 h-2.5`}),e.sliced_for_model]}),(()=>{let t=$U(e.bed_type);return t?(0,K.jsx)(`img`,{src:t.icon,alt:t.label,title:t.label,className:`w-3.5 h-3.5 flex-shrink-0`}):null})(),e.sliced_for_model&&e.filament_type&&(0,K.jsx)(`span`,{className:`text-bambu-gray/50`,children:`·`}),e.filament_type&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.filament_type}),e.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:e.filament_color.split(`,`).map((e,t)=>(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full border border-black/20`,style:{backgroundColor:e},title:e},t))})]})]}),(0,K.jsx)(`div`,{className:`col-span-2 text-sm text-bambu-gray truncate`,children:t}),(0,K.jsxs)(`div`,{className:`col-span-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(`div`,{children:yf(e.created_at)}),e.created_by_username&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-xs opacity-75`,title:l(`archives.card.uploadedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]})]}),(0,K.jsx)(`div`,{className:`col-span-1 text-sm text-bambu-gray`,children:Cd(e.file_size)}),(0,K.jsxs)(`div`,{className:`col-span-2 flex justify-end gap-1`,children:[$0(e)&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>D(!0),disabled:!m(`archives`,`reprint`,e.created_by_id),title:m(`archives`,`reprint`,e.created_by_id)?l(`archives.card.reprint`):l(`archives.card.noPermissionReprint`),className:`text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{let t=e.print_name||e.filename||`model`;e2(e.id,t,`file`,s)},title:l(`archives.card.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-4 h-4`})}),(e.external_url||e.makerworld_url)&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>window.open(e.external_url||e.makerworld_url,`_blank`),title:e.external_url?l(`archives.card.externalLink`):`MakerWorld`,children:(0,K.jsx)(bc,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Q.downloadArchive(e.id,`${e.print_name||e.filename}.3mf`).catch(e=>{console.error(`Archive download failed:`,e)})},title:l(`archives.card.download`),children:(0,K.jsx)(Vs,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>g(!0),disabled:!m(`archives`,`update`,e.created_by_id),title:m(`archives`,`update`,e.created_by_id)?l(`archives.card.edit`):l(`archives.card.noPermissionEdit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>x(!0),disabled:!m(`archives`,`delete`,e.created_by_id),title:m(`archives`,`delete`,e.created_by_id)?l(`archives.card.delete`):l(`archives.card.noPermissionDelete`),children:(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();se({x:t.left,y:t.bottom+4})},title:l(`archives.card.moreOptions`),children:(0,K.jsx)(Ws,{className:`w-4 h-4`})})]})]}),h&&(0,K.jsx)(JW,{archive:e,onClose:()=>g(!1)}),_&&(0,K.jsx)(YW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>v(!1)}),de&&(0,K.jsx)(PW,{plates:de,onSelect:t=>{fe(null),T(`/gcode-viewer?archive=${e.id}&plate=${t}`)},onClose:()=>fe(null)}),E&&(0,K.jsx)(sW,{mode:`reprint`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>D(!1)}),O&&(0,K.jsx)(zW,{source:{kind:`archive`,id:e.id,filename:e.print_name||e.filename||`model`},onClose:()=>k(!1)}),b&&(0,K.jsxs)(Ad,{title:l(`archives.modal.deleteArchive`),message:l(`archives.modal.deleteConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.deleteButton`),variant:`danger`,confirmDisabled:(w.data?.currently_printing??0)>0,onConfirm:()=>{we.mutate(S),x(!1),C(!1)},onCancel:()=>{x(!1),C(!1)},children:[(w.data?.related_queue_items??0)>0&&(0,K.jsx)(`div`,{className:(w.data?.currently_printing??0)>0?`text-sm text-red-400 mb-2`:`text-sm text-amber-400 mb-2`,children:(w.data?.currently_printing??0)>0?l(`archives.modal.deleteBlockedByPrinting`,{count:w.data.currently_printing}):l(`archives.modal.deleteQueueItemsWarning`,{count:w.data.related_queue_items})}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer text-sm text-bambu-gray`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 accent-red-500`,checked:S,onChange:e=>C(e.target.checked)}),(0,K.jsx)(`span`,{children:l(`archives.modal.deletePurgeStats`)})]})]}),ne&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeSource3mf`),message:l(`archives.modal.removeSource3mfConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{ye.mutate(),re(!1)},onCancel:()=>re(!1)}),ie&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeF3d`),message:l(`archives.modal.removeF3dConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{xe.mutate(),H(!1)},onCancel:()=>H(!1)}),ae&&(0,K.jsx)(Ad,{title:l(`archives.modal.removeTimelapse`),message:l(`archives.modal.removeTimelapseConfirm`,{name:e.print_name||e.filename}),confirmText:l(`archives.modal.removeButton`),variant:`danger`,onConfirm:()=>{ge.mutate(),oe(!1)},onCancel:()=>oe(!1)}),U&&(0,K.jsx)(XW,{x:U.x,y:U.y,items:ke,onClose:()=>se(null)}),M&&e.timelapse_path&&(0,K.jsx)(Q0,{src:Q.getArchiveTimelapse(e.id),title:l(`archives.modal.timelapse`,{name:e.print_name||e.filename}),downloadFilename:`${e.print_name||e.filename}_timelapse.mp4`,archiveId:e.id,onClose:()=>N(!1),onEdit:()=>{d.invalidateQueries({queryKey:[`archives`]}),N(!1)}}),P&&I.length>0&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:l(`archives.modal.selectTimelapse`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-400 mt-1`,children:l(`archives.modal.selectTimelapseDesc`)})]}),(0,K.jsx)(`button`,{onClick:()=>{F(!1),L([])},className:`text-gray-400 hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 p-2`,children:I.map(e=>(0,K.jsxs)(`button`,{onClick:()=>Ce.mutate(e.name),disabled:Ce.isPending,className:`w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1`,children:[(0,K.jsx)(`div`,{className:`font-medium text-white`,children:e.name}),(0,K.jsxs)(`div`,{className:`text-sm text-gray-400 flex gap-3`,children:[(0,K.jsx)(`span`,{children:Cd(e.size)}),e.mtime&&(0,K.jsx)(`span`,{children:yf(e.mtime)})]})]},e.name))})]})}),R&&(0,K.jsx)(ZW,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>z(!1)}),B&&e.photos&&(0,K.jsx)(QW,{archiveId:e.id,archiveName:e.print_name||e.filename,photos:e.photos,onClose:()=>V(!1),onDelete:async t=>{try{await Q.deleteArchivePhoto(e.id,t),d.invalidateQueries({queryKey:[`archives`]}),f(l(`archives.toast.photoDeleted`))}catch{f(l(`archives.toast.failedDeletePhoto`),`error`)}}}),ee&&(0,K.jsx)(Z0,{archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>te(!1)}),A&&(0,K.jsx)(sW,{mode:`add-to-queue`,archiveId:e.id,archiveName:e.print_name||e.filename,onClose:()=>j(!1)}),(0,K.jsx)(`input`,{ref:ce,type:`file`,accept:`.3mf`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&ve.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:le,type:`file`,accept:`.f3d`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&be.mutate(t),e.target.value=``}}),(0,K.jsx)(`input`,{ref:ue,type:`file`,accept:`.mp4,.avi,.mkv`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&_e.mutate(t),e.target.value=``}})]})}var pze=[`completed`,`failed`,`aborted`,`cancelled`,`stopped`],mze=[{id:`all`,label:`All Archives`,icon:(0,K.jsx)(cc,{className:`w-4 h-4`})},{id:`recent`,label:`Last 24 Hours`,icon:(0,K.jsx)(Ss,{className:`w-4 h-4`})},{id:`this-week`,label:`This Week`,icon:(0,K.jsx)(Zo,{className:`w-4 h-4`})},{id:`this-month`,label:`This Month`,icon:(0,K.jsx)(Zo,{className:`w-4 h-4`})},{id:`favorites`,label:`Favorites`,icon:(0,K.jsx)(su,{className:`w-4 h-4`})},{id:`not-printed`,label:`Not Printed`,icon:(0,K.jsx)(Du,{className:`w-4 h-4`})},{id:`printed`,label:`Printed`,icon:(0,K.jsx)(Tl,{className:`w-4 h-4`})},{id:`failed`,label:`Failed Prints`,icon:(0,K.jsx)(ds,{className:`w-4 h-4`})},{id:`duplicates`,label:`Duplicates`,icon:(0,K.jsx)(Ms,{className:`w-4 h-4`})}];function hze(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i}=dd(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(()=>{let e=localStorage.getItem(`archiveFilterPrinter`);return e?Number(e):null}),[u,d]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterMaterial`)),[f,p]=(0,y.useState)(()=>{let e=localStorage.getItem(`archiveFilterColors`);return e?new Set(JSON.parse(e)):new Set}),[m,h]=(0,y.useState)(()=>localStorage.getItem(`archiveColorFilterMode`)||`or`),[g,_]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterFavorites`)===`true`),[v,b]=(0,y.useState)(()=>localStorage.getItem(`archiveHideFailed`)===`true`),[x,S]=(0,y.useState)(()=>localStorage.getItem(`archiveHideDuplicates`)===`true`),[C,w]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterTag`)),[T,E]=(0,y.useState)(()=>localStorage.getItem(`archiveFilterFileType`)||`all`),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(()=>localStorage.getItem(`archiveNo3MFWarningDismissed`)===`true`),{data:F}=q({queryKey:[`archives`,`no-3mf-warning`],queryFn:Q.getNo3MFWarning,staleTime:300*1e3,enabled:!N}),I=()=>{localStorage.setItem(`archiveNo3MFWarningDismissed`,`true`),P(!0)},[L,R]=(0,y.useState)(!1),[z,B]=(0,y.useState)(!1),[V,ee]=(0,y.useState)(!1),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(()=>localStorage.getItem(`archiveViewMode`)||`grid`),[H,ae]=(0,y.useState)(()=>localStorage.getItem(`archiveSortBy`)||`date-desc`),[oe,U]=(0,y.useState)(()=>localStorage.getItem(`archiveCollection`)||`all`),[se,ce]=(0,y.useState)(0),[le,ue]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`archivePageSize`);return e?Number(e):50}catch{return 50}}),[de,fe]=(0,y.useState)(!1),[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(!1),[_e,ve]=(0,y.useState)(!1),[ye,be]=(0,y.useState)(!1),[xe,Se]=(0,y.useState)(null),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(()=>localStorage.getItem(`logFilterUser`)||null),[De,Oe]=(0,y.useState)(()=>localStorage.getItem(`logFilterStatus`)),[ke,Ae]=(0,y.useState)(()=>localStorage.getItem(`logFilterDateFrom`)||``),[je,Me]=(0,y.useState)(()=>localStorage.getItem(`logFilterDateTo`)||``),[Ne,Pe]=(0,y.useState)(()=>{let e=localStorage.getItem(`logOffset`);return e?Number(e):0}),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(null),[ze,Be]=(0,y.useState)(null),[Ve,He]=(0,y.useState)(``),[Ue,We]=(0,y.useState)(``),[Ge,Ke]=(0,y.useState)(()=>{let e=localStorage.getItem(`logPageSize`);return e?Number(e):25}),qe=(0,y.useCallback)(e=>{we(e),Se(e)},[]);(0,y.useEffect)(()=>{if(xe){let t=setTimeout(()=>{let t=document.querySelector(`[data-archive-id="${xe}"]`);t?t.scrollIntoView({behavior:`smooth`,block:`center`}):Ce===xe&&n(e(`archives.originalPrintNotVisible`),`warning`),Ce===xe&&we(null)},100),r=setTimeout(()=>Se(null),5e3);return()=>{clearTimeout(t),clearTimeout(r)}}},[xe,Ce,n,e]);let{data:Je,isLoading:Ye}=q({queryKey:[`archives`,c],queryFn:()=>Q.getArchives(c||void 0)}),{data:Xe}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Ze}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects()}),{data:Qe}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:$e}=q({queryKey:[`users`],queryFn:Q.getUsers,enabled:re===`log`}),{data:et,isLoading:tt}=q({queryKey:[`print-log`,c,Te,De,ke,je,o,Ne,Ge],queryFn:()=>Q.getPrintLog({search:o||void 0,printerId:c||void 0,username:Te||void 0,status:De||void 0,dateFrom:ke||void 0,dateTo:je||void 0,limit:Ge,offset:Ne}),enabled:re===`log`}),nt=Qe?.time_format||`system`,rt=Qe?.open_in_slicer||Qe?.preferred_slicer||`bambu_studio`,it=Qe?.use_slicer_api??!1,at=$d(Qe?.currency||`USD`),ot=J({mutationFn:async e=>(await Promise.all(e.map(e=>Q.deleteArchive(e))),e.length),onSuccess:e=>{t.invalidateQueries({queryKey:[`archives`]}),M(new Set),n(`${e} archive${e===1?``:`s`} deleted`)},onError:()=>{n(e(`archives.toast.failedDeleteArchives`),`error`)}}),st=J({mutationFn:()=>Q.clearPrintLog(),onSuccess:r=>{t.invalidateQueries({queryKey:[`print-log`]}),Pe(0),n(e(`archives.log.cleared`,{count:r.deleted}))},onError:()=>{n(e(`archives.log.clearFailed`),`error`)}}),ct=J({mutationFn:e=>Q.deletePrintLogEntry(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`print-log`]}),t.invalidateQueries({queryKey:[`archives-stats`]}),n(e(`archives.log.entryDeleted`))},onError:()=>{n(e(`archives.log.entryDeleteFailed`),`error`)}}),lt=J({mutationFn:({id:e,body:t})=>Q.updatePrintLogEntry(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`print-log`]}),t.invalidateQueries({queryKey:[`archives-stats`]}),Be(null),n(e(`archives.log.entryUpdated`))},onError:()=>{n(e(`archives.log.entryUpdateFailed`),`error`)}});(0,y.useEffect)(()=>{c===null?localStorage.removeItem(`archiveFilterPrinter`):localStorage.setItem(`archiveFilterPrinter`,c.toString())},[c]),(0,y.useEffect)(()=>{u?localStorage.setItem(`archiveFilterMaterial`,u):localStorage.removeItem(`archiveFilterMaterial`)},[u]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterColors`,JSON.stringify([...f]))},[f]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveColorFilterMode`,m)},[m]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterFavorites`,g.toString())},[g]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveHideFailed`,v.toString())},[v]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveHideDuplicates`,x.toString())},[x]),(0,y.useEffect)(()=>{C?localStorage.setItem(`archiveFilterTag`,C):localStorage.removeItem(`archiveFilterTag`)},[C]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveFilterFileType`,T)},[T]),(0,y.useEffect)(()=>{ce(0)},[o,c,u,f,m,g,v,x,C,T,H,oe]),(0,y.useEffect)(()=>{try{localStorage.setItem(`archivePageSize`,String(le))}catch{}},[le]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveViewMode`,re)},[re]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveSortBy`,H)},[H]),(0,y.useEffect)(()=>{localStorage.setItem(`archiveCollection`,oe)},[oe]),(0,y.useEffect)(()=>{Te?localStorage.setItem(`logFilterUser`,Te):localStorage.removeItem(`logFilterUser`)},[Te]),(0,y.useEffect)(()=>{De?localStorage.setItem(`logFilterStatus`,De):localStorage.removeItem(`logFilterStatus`)},[De]),(0,y.useEffect)(()=>{ke?localStorage.setItem(`logFilterDateFrom`,ke):localStorage.removeItem(`logFilterDateFrom`)},[ke]),(0,y.useEffect)(()=>{je?localStorage.setItem(`logFilterDateTo`,je):localStorage.removeItem(`logFilterDateTo`)},[je]),(0,y.useEffect)(()=>{localStorage.setItem(`logOffset`,Ne.toString())},[Ne]),(0,y.useEffect)(()=>{localStorage.setItem(`logPageSize`,Ge.toString())},[Ge]);let ut=new Map(Xe?.map(e=>[e.id,e.name])||[]),dt=[...new Set(Je?.flatMap(e=>e.filament_type?.split(`, `)||[]).filter(Boolean)||[])].sort(),ft=[...new Set(Je?.flatMap(e=>e.filament_color?.split(`,`)||[]).filter(Boolean)||[])],pt=[...new Set(Je?.flatMap(e=>e.tags?.split(`,`).map(e=>e.trim())||[]).filter(Boolean)||[])].sort(),mt=Je?.filter(e=>{let t=new Date,n=vf(e.created_at)||new Date(0),r=!0;switch(oe){case`recent`:r=t.getTime()-n.getTime()<1440*60*1e3;break;case`this-week`:r=t.getTime()-n.getTime()<10080*60*1e3;break;case`this-month`:r=n.getMonth()===t.getMonth()&&n.getFullYear()===t.getFullYear();break;case`favorites`:r=e.is_favorite===!0;break;case`not-printed`:r=e.status===`archived`;break;case`printed`:r=pze.includes(e.status);break;case`failed`:r=e.status===`failed`||e.status===`aborted`;break;case`duplicates`:r=e.duplicate_count>0;break}let i=(e.print_name||e.filename).toLowerCase().includes(o.toLowerCase()),a=!u||e.filament_type?.split(`, `).includes(u),s=e.filament_color?.split(`,`)||[],c=f.size===0||(m===`or`?s.some(e=>f.has(e)):[...f].every(e=>s.includes(e))),l=oe===`favorites`||!g||e.is_favorite,d=oe===`failed`||!v||e.status!==`failed`&&e.status!==`aborted`,p=oe===`duplicates`||!x||e.duplicate_count===0||e.duplicate_sequence===0,h=e.tags?.split(`,`).map(e=>e.trim())||[],_=!C||h.includes(C),y=$0(e);return r&&i&&a&&c&&l&&d&&p&&_&&(T===`all`||T===`gcode`&&y||T===`source`&&!y)}).sort((e,t)=>{switch(H){case`date-desc`:return(vf(t.created_at)?.getTime()||0)-(vf(e.created_at)?.getTime()||0);case`date-asc`:return(vf(e.created_at)?.getTime()||0)-(vf(t.created_at)?.getTime()||0);case`name-asc`:return(e.print_name||e.filename).localeCompare(t.print_name||t.filename);case`name-desc`:return(t.print_name||t.filename).localeCompare(e.print_name||e.filename);case`size-desc`:return t.file_size-e.file_size;case`size-asc`:return e.file_size-t.file_size;default:return 0}}),ht=mt?.length||0,gt=le===-1,_t=gt?ht||1:le,vt=Math.max(1,Math.ceil(ht/_t)),yt=gt?mt:mt?.slice(se*_t,(se+1)*_t);(0,y.useEffect)(()=>{if(xe&&mt&&!gt){let e=mt.findIndex(e=>e.id===xe);if(e>=0){let t=Math.floor(e/_t);t!==se&&ce(t)}}},[xe]);let bt=L||j.size>0,xt=e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},St=()=>{mt&&M(new Set(mt.map(e=>e.id)))},Ct=()=>{M(new Set),R(!1)},wt=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Tt=()=>{p(new Set)},Et=()=>{s(``),l(null),d(null),_(!1),b(!1),S(!1),w(null),E(`all`)},Dt=o||c||u||g||v||x||C||T!==`all`,{isDraggingOver:Ot,dragHandlers:kt}=GW({disabled:D,extensions:[`.3mf`],onFiles:e=>{A(e),O(!0)},onRejected:()=>n(e(`archives.page.only3mfSupported`),`warning`)}),At=(0,y.useCallback)(e=>{let t=e.target;if(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable){e.key===`Escape`&&t.blur();return}switch(e.key){case`/`:e.preventDefault(),a.current?.focus();break;case`u`:case`U`:!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),O(!0));break;case`Escape`:bt&&Ct();break}},[bt]);return(0,y.useEffect)(()=>(document.addEventListener(`keydown`,At),()=>document.removeEventListener(`keydown`,At)),[At]),(0,K.jsxs)(`div`,{className:`p-4 md:p-8 relative`,...kt,children:[Ot&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`border-4 border-dashed border-bambu-green rounded-xl p-12 text-center`,children:[(0,K.jsx)(Du,{className:`w-16 h-16 mx-auto mb-4 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-2xl font-semibold text-white mb-2`,children:e(`archives.page.dropFilesHere`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`archives.releaseToUpload`)})]})}),bt&&(0,K.jsxs)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-4`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:Ct,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),`Close`]}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[j.size,` selected`]}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:St,children:`Select All`}),(0,K.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ee(!0),disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),`Tags`]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ne(!0),disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),children:[(0,K.jsx)(sc,{className:`w-4 h-4`}),`Project`]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:!i(`archives:update_own`,`archives:update_all`),title:i(`archives:update_own`,`archives:update_all`)?void 0:e(`archives.permission.noUpdateArchives`),onClick:()=>{let r=Array.from(j);Promise.all(r.map(e=>Q.toggleFavorite(e))).then(()=>{t.invalidateQueries({queryKey:[`archives`]}),n(`Toggled favorites for ${r.length} archive${r.length===1?``:`s`}`)}).catch(()=>{n(e(`archives.toast.failedUpdateFavorites`),`error`)})},children:[(0,K.jsx)(su,{className:`w-4 h-4`}),`Favorite`]}),(0,K.jsxs)($,{size:`sm`,className:`bg-red-500 hover:bg-red-600`,onClick:()=>B(!0),disabled:!i(`archives:delete_own`,`archives:delete_all`),title:i(`archives:delete_own`,`archives:delete_all`)?void 0:e(`archives.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Delete`]})]}),F?.has_fallback&&!N&&(0,K.jsxs)(`div`,{className:`mb-6 rounded-lg border border-amber-500/30 bg-amber-500/10 px-4 py-3 flex items-start gap-3`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-amber-200`,children:e(`archives.no3mfBanner.title`)}),(0,K.jsxs)(`div`,{className:`text-xs text-amber-200/80 mt-1`,children:[e(`archives.no3mfBanner.body`),` `,(0,K.jsxs)(`a`,{href:`https://wiki.bambuddy.cool/getting-started/#step-4-enable-store-sent-files-on-external-storage`,target:`_blank`,rel:`noreferrer`,className:`underline hover:text-amber-100 inline-flex items-center gap-1`,children:[e(`archives.no3mfBanner.docsLink`),(0,K.jsx)(Js,{className:`w-3 h-3`})]})]})]}),(0,K.jsx)(`button`,{onClick:I,className:`text-amber-200/60 hover:text-amber-200 flex-shrink-0 p-1 -m-1`,title:e(`archives.no3mfBanner.dismissLabel`),"aria-label":e(`archives.no3mfBanner.dismissLabel`),children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-8`,children:[(0,K.jsx)(`div`,{children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Oo,{className:`w-7 h-7 text-bambu-green`}),`Archives`]}),(0,K.jsxs)(`p`,{className:`text-bambu-gray mt-1`,children:[mt?.length||0,` of `,Je?.length||0,` prints`]})]}),(0,K.jsx)(`select`,{className:`mt-0.5 px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray-light text-sm focus:border-bambu-green focus:outline-none`,value:oe,onChange:e=>U(e.target.value),children:mze.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.label},e.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>fe(!de),disabled:pe,children:[pe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(tc,{className:`w-4 h-4`}),`Export`]}),de&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg`,onClick:async()=>{fe(!1),me(!0);try{let{blob:t,filename:r}=await Q.exportArchives({format:`csv`,printerId:c||void 0,status:oe===`failed`?`failed`:void 0,search:o||void 0}),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),n(e(`archives.toast.exportDownloaded`))}catch{n(e(`archives.toast.exportFailed`),`error`)}finally{me(!1)}},children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),`Export as CSV`]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg`,onClick:async()=>{fe(!1),me(!0);try{let{blob:t,filename:r}=await Q.exportArchives({format:`xlsx`,printerId:c||void 0,status:oe===`failed`?`failed`:void 0,search:o||void 0}),i=URL.createObjectURL(t),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),n(e(`archives.toast.exportDownloaded`))}catch{n(e(`archives.toast.exportFailed`),`error`)}finally{me(!1)}},children:[(0,K.jsx)(tc,{className:`w-4 h-4`}),`Export as Excel`]})]})]}),j.size>=2&&j.size<=5&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>ge(!0),children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),`Compare (`,j.size,`)`]}),!bt&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>R(!0),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),`Select`]}),(0,K.jsxs)($,{onClick:()=>O(!0),disabled:!r(`archives:create`),title:r(`archives:create`)?void 0:e(`archives.permission.noCreate`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),`Upload 3MF`]}),r(`archives:purge`)&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>be(!0),title:e(`archivePurge.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`archivePurge.headerButton`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0 w-fit mb-4`,children:[(0,K.jsx)(`button`,{className:`p-2 ${re===`grid`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`grid`),title:e(`archives.gridView`),children:(0,K.jsx)(zc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`list`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`list`),title:e(`archives.listView`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`calendar`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`calendar`),title:e(`archives.calendarView`),children:(0,K.jsx)(Yo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{className:`p-2 ${re===`log`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,onClick:()=>ie(`log`),title:e(`archives.logView`),children:(0,K.jsx)(xs,{className:`w-4 h-4`})})]}),re!==`log`&&(0,K.jsx)(_d,{className:`mb-6`,children:(0,K.jsxs)(yd,{className:`py-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`w-full md:flex-1 relative md:min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{ref:a,type:`text`,placeholder:e(`archives.searchPlaceholder`),className:`w-full pl-10 pr-4 py-3 md:py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:o,onChange:e=>s(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 md:gap-4 overflow-x-auto pb-1 md:pb-0 -mx-4 px-4 md:mx-0 md:px-0 md:flex-wrap scrollbar-hide`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c||``,onChange:e=>l(e.target.value?Number(e.target.value):null),children:[(0,K.jsx)(`option`,{value:``,children:`All Printers`}),Xe?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:u||``,onChange:e=>d(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All Materials`}),dt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)($s,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:T,onChange:e=>E(e.target.value),children:[(0,K.jsx)(`option`,{value:`all`,children:`All Files`}),(0,K.jsx)(`option`,{value:`gcode`,children:`Sliced (GCODE)`}),(0,K.jsx)(`option`,{value:`source`,children:`Source Only`})]})]}),(0,K.jsxs)(`button`,{onClick:()=>_(!g),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${g?`bg-yellow-500/20 border-yellow-500 text-yellow-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(g?`archives.showAll`:`archives.showFavoritesOnly`),children:[(0,K.jsx)(su,{className:`w-4 h-4 ${g?`fill-yellow-400`:``}`}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:`Favorites`})]}),(0,K.jsxs)(`button`,{onClick:()=>b(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?`bg-red-500/20 border-red-500 text-red-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(v?`archives.showFailedPrints`:`archives.hideFailedPrints`),children:[(0,K.jsx)(ds,{className:`w-4 h-4 `}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:`Hide Failed`})]}),(0,K.jsxs)(`button`,{onClick:()=>S(!x),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${x?`bg-purple-500/20 border-purple-500 text-purple-400`:`bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:e(`archives.hideDuplicates`),children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm hidden md:inline`,children:e(`archives.hideDuplicates`)})]}),pt.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:C||``,onChange:e=>w(e.target.value||null),children:[(0,K.jsx)(`option`,{value:``,children:`All Tags`}),pt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsx)(`button`,{onClick:()=>ve(!0),className:`p-2 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-green transition-colors`,title:e(`archives.manageTags`),children:(0,K.jsx)(Ul,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(Po,{className:`w-4 h-4 text-bambu-gray hidden md:block`}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:H,onChange:e=>ae(e.target.value),children:[(0,K.jsx)(`option`,{value:`date-desc`,children:e(`archives.sortNewest`)}),(0,K.jsx)(`option`,{value:`date-asc`,children:e(`archives.sortOldest`)}),(0,K.jsxs)(`option`,{value:`name-asc`,children:[e(`archives.sortName`),` A-Z`]}),(0,K.jsxs)(`option`,{value:`name-desc`,children:[e(`archives.sortName`),` Z-A`]}),(0,K.jsx)(`option`,{value:`size-desc`,children:e(`archives.sortLargest`)}),(0,K.jsx)(`option`,{value:`size-asc`,children:e(`archives.sortSmallest`)})]})]})]}),Dt&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:Et,className:`text-bambu-gray hover:text-white`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),`Reset`]})]}),ft.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`Colors:`}),f.size>1&&(0,K.jsx)(`button`,{onClick:()=>h(e=>e===`or`?`and`:`or`),className:`px-2 py-0.5 text-xs rounded transition-colors ${m===`and`?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,title:m===`or`?`Match ANY selected color`:`Match ALL selected colors`,children:m.toUpperCase()}),(0,K.jsx)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:ft.map(e=>(0,K.jsx)(`button`,{onClick:()=>wt(e),className:`w-6 h-6 rounded-full border-2 transition-all ${f.has(e)?`border-bambu-green scale-110`:`border-white/20 hover:border-white/40`}`,style:{backgroundColor:e},title:e},e))}),f.size>0&&(0,K.jsxs)(`button`,{onClick:Tt,className:`text-xs text-bambu-gray hover:text-white flex items-center gap-1`,children:[(0,K.jsx)(Ru,{className:`w-3 h-3`}),`Clear`]})]})]})}),(0,K.jsx)(lze,{}),Ye?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`archives.loadingArchives`)}):mt?.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(o?`archives.noArchivesSearch`:`archives.noArchivesYet`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:`Archives are created automatically when prints complete`})]})}):re===`calendar`?(0,K.jsx)(_d,{className:`p-6`,children:(0,K.jsx)(bAe,{archives:mt||[],onArchiveClick:e=>{s(``),ie(`grid`),Se(e.id)},highlightedArchiveId:xe})}):re===`grid`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6`,children:yt?.map(t=>(0,K.jsx)(dze,{archive:t,printerName:t.printer_id?ut.get(t.printer_id)||`Unknown`:t.sliced_for_model||`No Printer`,isSelected:j.has(t.id),onSelect:xt,selectionMode:bt,projects:Ze,isHighlighted:t.id===xe,timeFormat:nt,preferredSlicer:rt,useSlicerApi:it,currency:at,t:e,onNavigateToArchive:qe},t.id))}),(0,K.jsx)(t2,{pageIndex:se,pageSize:le,totalRows:ht,totalPages:vt,onPageChange:ce,onPageSizeChange:e=>{ue(e),ce(0)},t:e})]}):re===`list`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{children:(0,K.jsxs)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium`,children:[(0,K.jsx)(`div`,{className:`col-span-1`}),(0,K.jsx)(`div`,{className:`col-span-4`,children:`Name`}),(0,K.jsx)(`div`,{className:`col-span-2`,children:`Printer`}),(0,K.jsx)(`div`,{className:`col-span-2`,children:`Date`}),(0,K.jsx)(`div`,{className:`col-span-1`,children:`Size`}),(0,K.jsx)(`div`,{className:`col-span-2 text-right`,children:`Actions`})]}),yt?.map(t=>(0,K.jsx)(fze,{archive:t,printerName:t.printer_id?ut.get(t.printer_id)||`Unknown`:t.sliced_for_model||`No Printer`,isSelected:j.has(t.id),onSelect:xt,selectionMode:bt,projects:Ze,isHighlighted:t.id===xe,preferredSlicer:rt,useSlicerApi:it,t:e,onNavigateToArchive:qe},t.id))]})}),(0,K.jsx)(t2,{pageIndex:se,pageSize:le,totalRows:ht,totalPages:vt,onPageChange:ce,onPageSizeChange:e=>{ue(e),ce(0)},t:e})]}):re===`log`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row gap-3 md:items-center md:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`flex-1 relative md:min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:e(`archives.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:o,onChange:e=>{s(e.target.value),Pe(0)}})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:c||``,onChange:e=>{l(e.target.value?Number(e.target.value):null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allPrinters`)}),Xe?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:Te||``,onChange:e=>{Ee(e.target.value||null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allUsers`)}),$e?.map(e=>(0,K.jsx)(`option`,{value:e.username,children:e.username},e.id))]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:De||``,onChange:e=>{Oe(e.target.value||null),Pe(0)},children:[(0,K.jsx)(`option`,{value:``,children:e(`archives.log.allStatuses`)}),(0,K.jsx)(`option`,{value:`completed`,children:e(`archives.status.completed`)}),(0,K.jsx)(`option`,{value:`failed`,children:e(`archives.status.failed`)}),(0,K.jsx)(`option`,{value:`stopped`,children:e(`archives.status.stopped`)}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`archives.log.cancelled`)}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`archives.log.skipped`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.dateFrom`)}),(0,K.jsx)(`input`,{type:`date`,className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:ke,onChange:e=>{Ae(e.target.value),Pe(0)}})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.dateTo`)}),(0,K.jsx)(`input`,{type:`date`,className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:je,onChange:e=>{Me(e.target.value),Pe(0)}})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>Ie(!0),disabled:!r(`archives:delete_all`)||st.isPending,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`archives.log.clearLog`)]})})]})})}),(0,K.jsx)(_d,{children:tt?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):et?.items.length?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-bambu-gray text-left`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.date`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.printName`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.printer`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.user`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.status`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.duration`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:e(`archives.log.filament`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium w-10`,"aria-label":e(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:et.items.map(t=>(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-secondary/50`,children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white whitespace-nowrap`,children:bf(t.started_at||t.created_at,nt)}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.thumbnail_path&&(0,K.jsx)(`img`,{src:Q.getPrintLogThumbnail(t.id),alt:``,className:`w-8 h-8 rounded object-cover flex-shrink-0`,onError:e=>{e.target.style.display=`none`}}),(0,K.jsx)(`span`,{className:`text-white break-words`,title:t.print_name||``,children:t.print_name||`—`})]})}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light`,children:t.printer_name||`—`}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light`,children:t.created_by_username||`—`}),(0,K.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.status===`completed`?`bg-green-500/20 text-green-400`:t.status===`failed`?`bg-red-500/20 text-red-400`:t.status===`stopped`?`bg-yellow-500/20 text-yellow-400`:t.status===`cancelled`?`bg-orange-500/20 text-orange-400`:t.status===`skipped`?`bg-blue-500/20 text-blue-400`:`bg-gray-500/20 text-gray-400`}`,children:t.status}),t.failure_reason&&(0,K.jsx)(`span`,{className:`block text-[10px] text-bambu-gray mt-0.5`,children:e(`editArchive.failureReasons.${t.failure_reason}`,{defaultValue:t.failure_reason})})]}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-bambu-gray-light whitespace-nowrap`,children:t.duration_seconds?Cf(t.duration_seconds):`—`}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[t.filament_color&&(0,K.jsx)(`div`,{className:`flex items-center gap-0.5 flex-wrap`,children:t.filament_color.split(`,`).map((e,t)=>{let n=e.trim();return(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:{backgroundColor:n.startsWith(`#`)?n:void 0},title:n},t)})}),(0,K.jsx)(`span`,{className:`text-bambu-gray-light text-xs`,children:t.filament_type||`—`})]})}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,K.jsxs)(`div`,{className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Be(t),He(t.failure_reason||``),We(t.status)},disabled:lt.isPending||!(r(`archives:update_all`)||r(`archives:update_own`)),title:r(`archives:update_all`)||r(`archives:update_own`)?e(`archives.log.editEntryTitle`):e(`archives.permission.noEdit`),className:`text-bambu-gray hover:text-bambu-blue disabled:opacity-40 disabled:hover:text-bambu-gray transition-colors`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>Re(t.id),disabled:ct.isPending||!(r(`archives:delete_all`)||r(`archives:delete_own`)),title:r(`archives:delete_all`)||r(`archives:delete_own`)?e(`archives.log.deleteEntryTitle`):e(`archives.permission.noDelete`),className:`text-bambu-gray hover:text-red-400 disabled:opacity-40 disabled:hover:text-bambu-gray transition-colors`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},t.id))})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-t border-bambu-dark-tertiary flex-wrap gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e(`archives.log.showing`,{count:Math.min(Ne+Ge,et.total),total:et.total})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:e(`archives.log.rowsPerPage`)}),(0,K.jsxs)(`select`,{className:`px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none`,value:Ge,onChange:e=>{Ke(Number(e.target.value)),Pe(0)},children:[(0,K.jsx)(`option`,{value:10,children:`10`}),(0,K.jsx)(`option`,{value:25,children:`25`}),(0,K.jsx)(`option`,{value:50,children:`50`}),(0,K.jsx)(`option`,{value:100,children:`100`})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`archives.log.page`),` `,Math.floor(Ne/Ge)+1,` / `,Math.max(1,Math.ceil(et.total/Ge))]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Pe(Math.max(0,Ne-Ge)),disabled:Ne===0,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Pe(Ne+Ge),disabled:Ne+Ge>=et.total,children:(0,K.jsx)(as,{className:`w-4 h-4`})})]})]})]}):(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`archives.log.noEntries`)})})]}):null,D&&(0,K.jsx)(sAe,{onClose:()=>{O(!1),A([])},initialFiles:k}),ye&&(0,K.jsx)(lAe,{onClose:()=>be(!1)}),z&&(0,K.jsx)(Ad,{title:e(`archives.modal.deleteArchives`),message:e(`archives.modal.deleteArchivesConfirm`,{count:j.size}),confirmText:e(`archives.modal.deleteCount`,{count:j.size}),variant:`danger`,onConfirm:()=>{ot.mutate(Array.from(j)),B(!1)},onCancel:()=>B(!1)}),V&&(0,K.jsx)(mAe,{selectedIds:Array.from(j),existingTags:pt,onClose:()=>ee(!1)}),te&&(0,K.jsx)(hAe,{selectedIds:Array.from(j),onClose:()=>ne(!1)}),he&&j.size>=2&&j.size<=5&&(0,K.jsx)(aze,{archiveIds:Array.from(j),onClose:()=>{ge(!1),M(new Set),R(!1)}}),_e&&(0,K.jsx)(uze,{onClose:()=>ve(!1)}),Fe&&(0,K.jsx)(Ad,{title:e(`archives.log.clearLogTitle`),message:e(`archives.log.clearLogConfirm`),confirmText:e(`archives.log.clearLogButton`),variant:`danger`,onConfirm:()=>{st.mutate(),Ie(!1)},onCancel:()=>Ie(!1)}),Le!==null&&(0,K.jsx)(Ad,{title:e(`archives.log.deleteEntryTitle`),message:e(`archives.log.deleteEntryConfirm`),confirmText:e(`common.delete`),variant:`danger`,onConfirm:()=>{ct.mutate(Le),Re(null)},onCancel:()=>Re(null)}),ze!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>Be(null),children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-md mx-4 p-6`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-4`,children:e(`archives.log.editEntryTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4`,children:e(`archives.log.editEntryDescription`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`editArchive.status`)}),(0,K.jsxs)(`select`,{value:Ue,onChange:e=>We(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`completed`,children:e(`archives.log.statuses.completed`,{defaultValue:`completed`})}),(0,K.jsx)(`option`,{value:`failed`,children:e(`archives.log.statuses.failed`,{defaultValue:`failed`})}),(0,K.jsx)(`option`,{value:`stopped`,children:e(`archives.log.statuses.stopped`,{defaultValue:`stopped`})}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`archives.log.statuses.cancelled`,{defaultValue:`cancelled`})}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`archives.log.statuses.skipped`,{defaultValue:`skipped`})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`editArchive.failureReason`)}),(0,K.jsxs)(`select`,{value:Ve,onChange:e=>He(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:e(`editArchive.selectReason`)}),qW.map(t=>(0,K.jsx)(`option`,{value:t,children:e(`editArchive.failureReasons.${t}`)},t))]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 mt-6`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>Be(null),children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,onClick:()=>{let e={};if(Ve!==(ze.failure_reason||``)&&(e.failure_reason=Ve||null),Ue!==ze.status&&(e.status=Ue),Object.keys(e).length===0){Be(null);return}lt.mutate({id:ze.id,body:e})},disabled:lt.isPending,children:lt.isPending?e(`editArchive.saving`):e(`common.save`)})]})]})})]})}function t2({pageIndex:e,pageSize:t,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:a,t:o}){let s=t===-1;if(r<=1&&!s)return null;let c=s?n||1:t;return(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:s?`${n} ${o(`archives.prints`)}`:(0,K.jsxs)(K.Fragment,{children:[o(`archives.pagination.showing`),` `,e*c+1,` `,o(`archives.pagination.to`),` `,Math.min((e+1)*c,n),` `,o(`archives.pagination.of`),` `,n,` `,o(`archives.prints`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:o(`archives.pagination.show`)}),(0,K.jsxs)(`select`,{value:t,onChange:e=>a(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[25,50,100,200].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:o(`archives.pagination.all`)})]}),!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>i(0),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(Math.max(0,e-1)),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[o(`archives.pagination.page`),` `,e+1,` `,o(`archives.pagination.of`),` `,r]}),(0,K.jsx)(`button`,{onClick:()=>i(Math.min(r-1,e+1)),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(r-1),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})}function gze(){var e=[...arguments];return(0,y.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var n2=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function r2(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function i2(e){return`nodeType`in e}function a2(e){return e?r2(e)?e:i2(e)?e.ownerDocument?.defaultView??window:window:window}function o2(e){let{Document:t}=a2(e);return e instanceof t}function s2(e){return r2(e)?!1:e instanceof a2(e).HTMLElement}function c2(e){return e instanceof a2(e).SVGElement}function l2(e){return e?r2(e)?e.document:i2(e)?o2(e)?e:s2(e)||c2(e)?e.ownerDocument:document:document:document}var u2=n2?y.useLayoutEffect:y.useEffect;function d2(e){let t=(0,y.useRef)(e);return u2(()=>{t.current=e}),(0,y.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function _ze(){let e=(0,y.useRef)(null);return[(0,y.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,y.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function f2(e,t){t===void 0&&(t=[e]);let n=(0,y.useRef)(e);return u2(()=>{n.current!==e&&(n.current=e)},t),n}function p2(e,t){let n=(0,y.useRef)();return(0,y.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function m2(e){let t=d2(e),n=(0,y.useRef)(null);return[n,(0,y.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function h2(e){let t=(0,y.useRef)();return(0,y.useEffect)(()=>{t.current=e},[e]),t.current}var g2={};function _2(e,t){return(0,y.useMemo)(()=>{if(t)return t;let n=g2[e]==null?0:g2[e]+1;return g2[e]=n,e+`-`+n},[e,t])}function v2(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var y2=v2(1),b2=v2(-1);function vze(e){return`clientX`in e&&`clientY`in e}function x2(e){if(!e)return!1;let{KeyboardEvent:t}=a2(e.target);return t&&e instanceof t}function yze(e){if(!e)return!1;let{TouchEvent:t}=a2(e.target);return t&&e instanceof t}function S2(e){if(yze(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return vze(e)?{x:e.clientX,y:e.clientY}:null}var C2=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[C2.Translate.toString(e),C2.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),w2=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function bze(e){return e.matches(w2)?e:e.querySelector(w2)}var xze={display:`none`};function Sze(e){let{id:t,value:n}=e;return y.createElement(`div`,{id:t,style:xze},n)}function Cze(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return y.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function wze(){let[e,t]=(0,y.useState)(``);return{announce:(0,y.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var T2=(0,y.createContext)(null);function Tze(e){let t=(0,y.useContext)(T2);(0,y.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of `);return t(e)},[e,t])}function Eze(){let[e]=(0,y.useState)(()=>new Set),t=(0,y.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,y.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Dze={draggable:` To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel. @@ -8698,15 +8698,15 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content: ${l&&M?`sm:border-bambu-dark-tertiary border-bambu-green/40`:``} ${!l&&!k?`border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80`:``} ${M?`sm:cursor-default`:``} - `,onClick:M?()=>{window.innerWidth<640&&u()}:void 0,children:[M&&l&&(0,K.jsx)(`div`,{className:`sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green`}),(0,K.jsxs)(`div`,{className:`flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4`,children:[A&&u&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${l?`bg-bambu-green border-bambu-green text-white`:`border-white/30 bg-black/30 hover:border-bambu-green/50`}`,children:l&&(0,K.jsx)(rs,{className:`w-4 h-4`})}),A?(0,K.jsx)(`div`,{...S,...C,className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0`,children:(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray`})}):t===void 0?(0,K.jsx)(`div`,{className:`hidden sm:block w-8 shrink-0`}):(0,K.jsxs)(`div`,{className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0`,children:[`#`,t]}),(0,K.jsx)(`div`,{className:`w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden`,children:e.archive_thumbnail?(0,K.jsx)(`img`,{src:e.plate_id==null?Q.getArchiveThumbnail(e.archive_id):Q.getArchivePlateThumbnail(e.archive_id,e.plate_id),alt:``,className:`w-full h-full object-cover`}):e.library_file_thumbnail?(0,K.jsx)(`img`,{src:e.plate_id==null?Q.getLibraryFileThumbnailUrl(e.library_file_id):Q.getLibraryFilePlateThumbnail(e.library_file_id,e.plate_id),alt:``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 sm:w-6 sm:h-6`})})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm sm:text-base text-white font-medium truncate`,children:[e.archive_name||e.library_file_name||`File #${e.archive_id||e.library_file_id}`,(y?.is_multi_plate??!1)&&e.plate_id!==void 0&&e.plate_id!==null&&` • ${b.find(t=>t.index===e.plate_id)?.name||m(`queue.plateNumber`,{index:e.plate_id})}`]}),e.archive_id?(0,K.jsx)(wi,{to:`/archives?highlight=${e.archive_id}`,className:`text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:m(`queue.viewArchive`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):e.library_file_id?(0,K.jsx)(wi,{to:`/library?highlight=${e.library_file_id}`,className:`text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:m(`queue.viewInFileManager`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):null,e.batch_name&&(0,K.jsx)(`span`,{className:`flex-shrink-0 px-1.5 py-0.5 text-[10px] sm:text-xs bg-cyan-500/20 text-cyan-300 rounded border border-cyan-500/30`,children:e.batch_name})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5 ${e.printer_id===null&&!e.target_model?`text-orange-400`:``} ${e.target_model&&!e.printer_id?`text-blue-400`:``}`,children:[(0,K.jsx)(Tl,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),(0,K.jsx)(`span`,{className:`truncate max-w-[120px] sm:max-w-none`,children:e.target_model&&!e.printer_id?`${m(`queue.filter.any`)} ${e.target_model}${e.target_location?` @ ${e.target_location}`:``}${e.required_filament_types?.length?` (${e.required_filament_types.join(`, `)})`:``}`:e.printer_id===null?m(`queue.filter.unassigned`):e.printer_name||`${m(`common.printer`)} #${e.printer_id}`})]}),e.print_time_seconds&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(yu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),Cf(e.print_time_seconds)]}),e.filament_used_grams&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(Nu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),t3(e.filament_used_grams)]}),(()=>{let t=QU(e.bed_type);return t?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,title:t.label,children:[(0,K.jsx)(`img`,{src:t.icon,alt:``,className:`w-3.5 h-3.5 sm:w-4 sm:h-4 object-contain`}),(0,K.jsx)(`span`,{className:`truncate max-w-[120px]`,children:t.label})]}):null})(),e.created_by_username&&(0,K.jsxs)(`span`,{className:`hidden sm:flex items-center gap-1.5`,title:m(`queue.addedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3.5 h-3.5`}),e.created_by_username]}),A&&!e.manual_start&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),e.scheduled_time?(vf(e.scheduled_time)?.getTime()??0)-Date.now()<-6e4?m?.(`queue.time.overdue`)??`Overdue`:wf(e.scheduled_time,c,m):m?.(`queue.time.asap`)??`ASAP`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2`,children:[e.manual_start&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1`,children:[(0,K.jsx)(Cc,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.staged`)]}),e.require_previous_success&&(0,K.jsx)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20`,children:m(`queue.badges.requiresPrevious`)}),e.auto_off_after&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1`,children:[(0,K.jsx)(wl,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.autoPowerOff`)]}),e.gcode_injection&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-emerald-500/10 text-emerald-400 rounded-full border border-emerald-500/20 flex items-center gap-1`,children:[(0,K.jsx)(Es,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.gcodeInjection`)]})]}),k&&h&&(()=>{let e=h.state===`RUNNING`||h.state===`PAUSE`,t=e&&h.progress||0,n=e?h.remaining_time:null,r=e?h.layer_num:null,i=e?h.total_layers:null;return(0,K.jsxs)(`div`,{className:`mt-2 sm:mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs sm:text-sm`,children:[(0,K.jsx)(`div`,{className:`flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all`,style:{width:`${t}%`}})}),(0,K.jsxs)(`span`,{className:`text-white`,children:[Math.round(t),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray`,children:[n!=null&&n>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(n*60)]}),(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,title:m(`printers.estimatedCompletion`),children:[`ETA `,Sf(n,c,m)]})]}),r!=null&&i!=null&&i>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),r,`/`,i]})]})]})})(),e.waiting_reason&&e.status===`pending`&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:e.waiting_reason})]}),e.filament_short&&e.status===`pending`&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-yellow-400 mt-1.5 sm:mt-2 flex items-start gap-1`,title:m(`queue.filamentShort.rowTooltip`),children:[(0,K.jsx)(ds,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:m(`queue.filamentShort.rowBadge`)})]}),e.error_message&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),e.error_message]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(uVe,{status:e.status,waitingReason:e.waiting_reason,printerState:p,t:m}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1`,children:[k&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:a,disabled:!d(`printers:control`),title:d(`printers:control`)?m(`queue.actions.stopPrint`):m(`queue.permissions.noStopPrint`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(vs,{className:`w-4 h-4`})}),A&&(0,K.jsxs)(K.Fragment,{children:[e.manual_start&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:s,disabled:!d(`printers:control`),title:d(`printers:control`)?m(`queue.actions.startPrint`):m(`queue.permissions.noStartPrint`),className:`text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:n,disabled:!f(`queue`,`update`,e.created_by_id),title:f(`queue`,`update`,e.created_by_id)?m(`common.edit`):m(`queue.permissions.noEdit`),className:`p-1.5 sm:p-2`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,disabled:!f(`queue`,`delete`,e.created_by_id),title:f(`queue`,`delete`,e.created_by_id)?m(`common.cancel`):m(`queue.permissions.noCancel`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),j&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:o,disabled:!d(`queue:create`),title:d(`queue:create`)?m(`queue.actions.requeue`):m(`queue.permissions.noRequeue`),className:`text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Ol,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,disabled:!f(`queue`,`delete`,e.created_by_id),title:f(`queue`,`delete`,e.created_by_id)?m(`common.remove`):m(`queue.permissions.noRemove`),className:`p-1.5 sm:p-2`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})]})]})}function i3(e){let{row:t,setEditItem:n,setConfirmAction:r,startMutation:i,selectedItems:a,handleToggleSelect:o,timeFormat:s,hasPermission:c,canModify:l,t:u}=e;return t.kind===`item`?(0,K.jsx)(r3,{item:t.item,onEdit:()=>n(t.item),onCancel:()=>r({type:`cancel`,item:t.item}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>i.mutate({id:t.item.id}),timeFormat:s,isSelected:a.includes(t.item.id),onToggleSelect:()=>o(t.item.id),hasPermission:c,canModify:l,t:u}):(0,K.jsx)(fVe,{...e})}function fVe({row:e,collapsed:t,onToggleBatch:n,onUngroup:r,setEditItem:i,setConfirmAction:a,startMutation:o,selectedItems:s,handleToggleSelect:c,timeFormat:l,hasPermission:u,canModify:d,t:f,aggregateForRows:p}){let m=e,h=u(`queue:reorder`),{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=G4({id:`batch-${m.batchId}`,disabled:!h}),S={transform:C2.Transform.toString(y),transition:b},C=p([m]),w=m.items.map(e=>e.id),T=w.length>0&&w.every(e=>s.includes(e)),E=new Set(m.items.map(e=>e.status)),D=E.has(`failed`)?`failed`:E.has(`printing`)?`printing`:`pending`,O=m.items.filter(e=>e.status===`pending`).length;return(0,K.jsxs)(`div`,{ref:v,style:S,className:`bg-bambu-dark-secondary rounded-xl border border-l-[3px] border-l-cyan-400 border-bambu-dark-tertiary overflow-hidden ${x?`opacity-50 scale-[1.01] shadow-xl z-50`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 p-3 sm:p-4`,children:[(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w.forEach(e=>{(T&&s.includes(e)||!T&&!s.includes(e))&&c(e)})},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${T?`bg-bambu-green border-bambu-green text-white`:`border-white/30 bg-black/30 hover:border-bambu-green/50`}`,title:f(T?`queue.bulkEdit.deselectAll`:`queue.bulkEdit.selectAll`),children:T&&(0,K.jsx)(rs,{className:`w-4 h-4`})}),h&&(0,K.jsx)(`div`,{...g,..._,className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0`,title:f(`queue.batch.dragGroup`,{defaultValue:`Drag group`}),children:(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:n,className:`flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors shrink-0`,title:f(t?`queue.batch.expand`:`queue.batch.collapse`),children:t?(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`div`,{className:`w-10 h-10 sm:w-12 sm:h-12 flex-shrink-0 bg-bambu-dark rounded-lg flex items-center justify-center`,children:t?(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300`}):(0,K.jsx)(fl,{className:`w-5 h-5 text-cyan-300`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`p`,{className:`text-sm sm:text-base text-white font-medium truncate`,children:m.batchName}),(0,K.jsx)(`span`,{className:`flex-shrink-0 px-1.5 py-0.5 text-[10px] sm:text-xs bg-cyan-500/15 text-cyan-300 rounded border border-cyan-500/30`,children:f(`queue.batch.label`,{count:C.count})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray`,children:[C.time>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(yu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),Cf(C.time)]}),C.weight>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(Nu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),t3(C.weight)]}),O>0&&D===`pending`&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5 text-yellow-400`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),f(`queue.batch.pendingCount`,{count:O})]})]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:r&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,title:f(`queue.batch.ungroup`),className:`text-cyan-300 hover:text-cyan-200 hover:bg-cyan-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Tu,{className:`w-4 h-4`})})})]}),!t&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary bg-black/20 p-2 sm:p-3 space-y-2`,children:m.items.map(e=>(0,K.jsx)(r3,{item:e,onEdit:()=>i(e),onCancel:()=>a({type:`cancel`,item:e}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>o.mutate({id:e.id}),timeFormat:l,isSelected:s.includes(e.id),onToggleSelect:()=>c(e.id),hasPermission:u,canModify:d,t:f},e.id))})]})}function pVe({items:e,sortBy:t,sortAsc:n,onSortByChange:r,onSortAscToggle:i,onRemove:a,onRequeue:o,timeFormat:s,batchCollapsed:c,toggleBatchCollapsed:l,hasPermission:u,canModify:d,t:f}){if(e.length===0)return(0,K.jsxs)(_d,{className:`p-12 text-center border-dashed`,children:[(0,K.jsx)(Uc,{className:`w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50`}),(0,K.jsx)(`h3`,{className:`text-xl font-medium text-white mb-2`,children:f(`queue.history.emptyTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray max-w-md mx-auto`,children:f(`queue.history.emptyDescription`)})]});let p=[],m=new Set;for(let t of e.slice(0,50))if(t.batch_id!=null){if(m.has(t.batch_id))continue;m.add(t.batch_id);let n=e.filter(e=>e.batch_id===t.batch_id);p.push({kind:`batch`,batchId:t.batch_id,batchName:t.batch_name||f(`queue.batch.defaultName`),items:n})}else p.push({kind:`item`,item:t});return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white flex items-center gap-2`,children:[f(`queue.sections.history`),(0,K.jsxs)(`span`,{className:`text-xs sm:text-sm font-normal text-bambu-gray`,children:[`(`,f(`queue.itemCount`,{count:e.length}),`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:t,onChange:e=>r(e.target.value),children:[(0,K.jsx)(`option`,{value:`date`,children:f(`queue.sort.byDate`)}),(0,K.jsx)(`option`,{value:`name`,children:f(`queue.sort.byName`)}),(0,K.jsx)(`option`,{value:`printer`,children:f(`queue.sort.byPrinter`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,title:f(n?`queue.sort.ascendingOldest`:`queue.sort.descendingNewest`),className:`px-2`,children:n?(0,K.jsx)(Io,{className:`w-4 h-4`}):(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:p.map(e=>{if(e.kind===`item`)return(0,K.jsx)(X4,{item:e.item,onRemove:()=>a(e.item),onRequeue:()=>o(e.item),timeFormat:s,hasPermission:u,canModify:d,t:f},e.item.id);let t=c[e.batchId]??!0,n=e.items.filter(e=>e.status===`completed`).length,r=e.items.filter(e=>e.status===`failed`).length,i=e.items.filter(e=>e.status===`skipped`).length,p=e.items.filter(e=>e.status===`cancelled`).length,m=e.items.map(e=>e.completed_at||e.created_at).filter(e=>!!e).sort().at(-1);return(0,K.jsxs)(`div`,{className:`md:col-span-2 xl:col-span-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary border-l-[3px] border-l-cyan-400`,children:[(0,K.jsxs)(`button`,{onClick:()=>l(e.batchId),className:`w-full flex items-center gap-2 sm:gap-3 px-3 py-2 hover:bg-bambu-dark/30 transition-colors text-left`,title:f(t?`queue.batch.expand`:`queue.batch.collapse`),children:[t?(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray shrink-0`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0`}),t?(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300 shrink-0`}):(0,K.jsx)(fl,{className:`w-5 h-5 text-cyan-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium truncate min-w-0 flex-1`,children:e.batchName}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray shrink-0`,children:[n>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-emerald-400`,children:[(0,K.jsx)(ps,{className:`w-3 h-3`}),n]}),r>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-3 h-3`}),r]}),i>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-orange-400`,children:[(0,K.jsx)(Zl,{className:`w-3 h-3`}),i]}),p>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-gray-400`,children:[(0,K.jsx)(Lo,{className:`w-3 h-3`}),p]}),(0,K.jsx)(`span`,{title:m??void 0,children:m?wf(m,s,f):null})]})]}),!t&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary bg-black/20 p-2 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:e.items.map(e=>(0,K.jsx)(X4,{item:e,onRemove:()=>a(e),onRequeue:()=>o(e),timeFormat:s,hasPermission:u,canModify:d,t:f},e.id))})]},`batch-${e.batchId}`)})})]})}function mVe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i,canModify:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)([]),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(null),[D,O]=(0,y.useState)(()=>localStorage.getItem(`queue.historySortBy`)||`date`),[k,A]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.historySortAsc`);return e===null?!1:e===`true`}),[j,M]=(0,y.useState)(()=>localStorage.getItem(`queue.pendingSortBy`)||`position`),[N,P]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.pendingSortAsc`);return e===null?!0:e===`true`}),[F,I]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.activeTab`);return e===`history`||e===`timeline`?e:`queue`}),[L,R]=(0,y.useState)(()=>localStorage.getItem(`queue.activeLayout`)===`printer`?`printer`:`position`),[z,B]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`queue.batchCollapsed`);return e?JSON.parse(e):{}}catch{return{}}}),[V,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(null);(0,y.useEffect)(()=>{localStorage.setItem(`queue.historySortBy`,D)},[D]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.historySortAsc`,String(k))},[k]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.pendingSortBy`,j)},[j]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.pendingSortAsc`,String(N))},[N]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.activeTab`,F)},[F]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.activeLayout`,L)},[L]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.batchCollapsed`,JSON.stringify(z))},[z]);let H=k2(O2(l4,{activationConstraint:{distance:8}}),O2(a4,{coordinateGetter:q4})),{data:ae}=q({queryKey:[`settings`],queryFn:Q.getSettings}),oe=ae?.time_format||`system`,{data:U,isLoading:se}=q({queryKey:[`queue`,o,c],queryFn:()=>Q.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:ce}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),le=J({mutationFn:e=>Q.updateSettings({queue_shortest_first:e}),onSuccess:()=>{t.invalidateQueries({queryKey:[`settings`]})}}),ue=J({mutationFn:e=>Q.cancelQueueItem(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.cancelled`))},onError:()=>n(e(`queue.toast.cancelFailed`),`error`)}),de=J({mutationFn:e=>Q.removeFromQueue(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.removed`))},onError:()=>n(e(`queue.toast.removeFailed`),`error`)}),fe=J({mutationFn:e=>Q.stopQueueItem(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.stopped`))},onError:()=>n(e(`queue.toast.stopFailed`),`error`)}),[pe,me]=(0,y.useState)(null),he=J({mutationFn:({id:e,skipFilamentCheck:t})=>Q.startQueueItem(e,{skipFilamentCheck:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.released`)),me(null)},onError:(t,r)=>{if(t instanceof Uu&&t.status===409&&t.code===`insufficient_filament`){let e=t.detail?.deficit??[];me({itemId:r.id,deficit:e});return}n(e(`queue.toast.startFailed`),`error`)}}),ge=J({mutationFn:e=>Q.reorderQueue(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]})},onError:()=>n(e(`queue.toast.reorderFailed`),`error`)}),_e=J({mutationFn:async()=>{let e=U?.filter(e=>[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status))||[];for(let t of e)await Q.removeFromQueue(t.id);return e.length},onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.historyCleared`,{count:r}))},onError:()=>n(e(`queue.toast.clearHistoryFailed`),`error`)}),ve=J({mutationFn:e=>Q.bulkUpdateQueue(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),w(!1),n(e.message)},onError:()=>n(e(`queue.toast.updateFailed`),`error`)}),ye=J({mutationFn:async e=>{for(let t of e)await Q.cancelQueueItem(t);return e.length},onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),n(e(`queue.toast.bulkCancelled`,{count:r}))},onError:()=>n(e(`queue.toast.bulkCancelFailed`),`error`)}),be=J({mutationFn:e=>Q.resumeQueueAfterFailure(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),E(null),n(e(`queue.toast.resumedAfterFailure`,{restored:r.restored,acknowledged:r.acknowledged}))},onError:()=>n(e(`queue.toast.resumeAfterFailureFailed`),`error`)}),xe=J({mutationFn:e=>Q.createBatch(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),ne(!1),B(e=>({...e,[r.id]:!1})),n(e(`queue.toast.batchCreated`,{name:r.name}))},onError:()=>n(e(`queue.toast.batchCreateFailed`),`error`)}),Se=J({mutationFn:e=>Q.ungroupBatch(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),ie(null),n(e(`queue.toast.batchUngrouped`,{count:r.ungrouped_count}))},onError:()=>n(e(`queue.toast.batchUngroupFailed`),`error`)}),Ce=e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},we=(0,y.useMemo)(()=>{let e=new Set;return ce?.forEach(t=>{t.location&&e.add(t.location)}),U?.forEach(t=>{t.target_location&&e.add(t.target_location)}),Array.from(e).sort()},[ce,U]),Te=(0,y.useCallback)(e=>u?e.target_location?e.target_location===u:e.printer_id?ce?.find(t=>t.id===e.printer_id)?.location===u:!1:!0,[u,ce]),Ee=(0,y.useMemo)(()=>{let e=U?.filter(e=>e.status===`pending`)||[];u&&(e=e.filter(Te));let t=e=>{if(!e.scheduled_time)return 0;let t=vf(e.scheduled_time)?.getTime()??0;return t>Date.now()+4320*60*60*1e3?0:t};return ae?.queue_shortest_first?[...e].sort((e,t)=>{let n=e.printer_id??-(e.target_model?.charCodeAt(0)??0),r=t.printer_id??-(t.target_model?.charCodeAt(0)??0);if(n!==r)return n-r;let i=+!!e.been_jumped,a=+!!t.been_jumped;if(i!==a)return a-i;let o=e.print_time_seconds??1/0,s=t.print_time_seconds??1/0;return o===s?e.position-t.position:o-s}):[...e].sort((e,n)=>{let r;if(j===`name`){let t=e.archive_name||e.library_file_name||``,i=n.archive_name||n.library_file_name||``;r=t.localeCompare(i)}else r=j===`printer`?(e.printer_name||``).localeCompare(n.printer_name||``):j===`time`?t(e)-t(n):e.position-n.position;return N?r:-r})},[U,j,N,Te,u,ae?.queue_shortest_first]),De=()=>{let e=Ee.map(e=>e.id);x.length===e.length?S([]):S(e)},Oe=(0,y.useMemo)(()=>{let e=U?.filter(e=>e.status===`printing`)||[];return u&&(e=e.filter(Te)),e},[U,u,Te]),ke=(0,y.useMemo)(()=>{let e=new Set;return Oe.forEach(t=>{t.printer_id&&e.add(t.printer_id)}),Array.from(e)},[Oe]),Ae=_o({queries:ke.map(e=>({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:5e3}))}),je=(0,y.useMemo)(()=>{let e={};return ke.forEach((t,n)=>{let r=Ae[n];r?.data?.state&&(e[t]=r.data.state)}),e},[ke,Ae]),Me=(0,y.useMemo)(()=>{let e={};return ke.forEach((t,n)=>{let r=Ae[n];r?.data&&(e[t]={progress:r.data.progress??void 0,remaining_time:r.data.remaining_time??void 0,state:r.data.state??void 0})}),e},[ke,Ae]),Ne=(0,y.useMemo)(()=>{let e=U?.filter(e=>[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status))||[];return u&&(e=e.filter(Te)),[...e].sort((e,t)=>{let n;if(D===`name`){let r=e.archive_name||e.library_file_name||``,i=t.archive_name||t.library_file_name||``;n=r.localeCompare(i)}else n=D===`printer`?(e.printer_name||``).localeCompare(t.printer_name||``):(vf(t.completed_at||t.created_at)?.getTime()??0)-(vf(e.completed_at||e.created_at)?.getTime()??0);return k?-n:n})},[U,D,k,Te,u]),Pe=(0,y.useMemo)(()=>Ee.reduce((e,t)=>e+(t.print_time_seconds||0),0),[Ee]),Fe=(0,y.useMemo)(()=>Ee.reduce((e,t)=>e+(t.filament_used_grams||0),0),[Ee]),Ie=e=>{let t=e.active.id;ee(typeof t==`number`||typeof t==`string`?t:null)},Le=e=>{let{active:t,over:n}=e;if(ee(null),!n||t.id===n.id)return;let r,i=t.id;if(typeof i==`string`&&i.startsWith(`batch-`)){let e=Number(i.slice(6));r=Ee.filter(t=>t.batch_id===e).map(e=>e.id)}else{let e=i;r=x.includes(e)&&x.length>1?x.slice().sort((e,t)=>Ee.findIndex(t=>t.id===e)-Ee.findIndex(e=>e.id===t)):[e]}if(r.length===0)return;let a,o=n.id;if(typeof o==`string`&&o.startsWith(`batch-`)){let e=Number(o.slice(6));a=Ee.findIndex(t=>t.batch_id===e)}else a=Ee.findIndex(e=>e.id===o);if(a===-1)return;let s=Ee[a],c=Ee.filter(e=>!r.includes(e.id)),l=c.findIndex(e=>e.id===s.id);l===-1&&(l=a),Ee.findIndex(e=>e.id===r[0])Ee.find(t=>t.id===e)).filter(e=>!!e),...c.slice(l)].map((e,t)=>({id:e.id,position:t+1}));ge.mutate(u)},Re=(0,y.useMemo)(()=>{let t=[],n=new Set;for(let r of Ee)if(r.batch_id!=null){if(n.has(r.batch_id))continue;n.add(r.batch_id);let i=Ee.filter(e=>e.batch_id===r.batch_id);t.push({kind:`batch`,batchId:r.batch_id,batchName:r.batch_name||e(`queue.batch.defaultName`),items:i})}else t.push({kind:`item`,item:r});return t},[Ee,e]),ze=(0,y.useMemo)(()=>{let e=[];for(let t of Re)if(t.kind===`item`)e.push(t.item.id);else if(e.push(`batch-${t.batchId}`),!(z[t.batchId]??!0))for(let n of t.items)e.push(n.id);return e},[Re,z]),Be=(0,y.useMemo)(()=>x.length<2?!1:x.every(e=>{let t=Ee.find(t=>t.id===e);return t&&t.batch_id==null}),[x,Ee]),Ve=e=>{B(t=>({...t,[e]:!(t[e]??!0)}))},He=(0,y.useMemo)(()=>{let t=new Map,n=t=>t.printer_id?{key:`printer:${t.printer_id}`,label:t.printer_name||`Printer #${t.printer_id}`,printerId:t.printer_id,targetModel:null,isUnassigned:!1}:t.target_model?{key:`model:${t.target_model}`,label:`${e(`queue.filter.any`)} ${t.target_model}`,printerId:null,targetModel:t.target_model,isUnassigned:!1}:{key:`unassigned`,label:e(`queue.filter.unassigned`),printerId:null,targetModel:null,isUnassigned:!0};for(let e of Re){let r=e.kind===`item`?e.item:e.items[0];if(!r)continue;let i=n(r);t.has(i.key)||t.set(i.key,{...i,rows:[]}),t.get(i.key).rows.push(e)}return Array.from(t.values()).sort((e,t)=>e.isUnassigned&&!t.isUnassigned?1:!e.isUnassigned&&t.isUnassigned?-1:e.label.localeCompare(t.label))},[Re,e]),Ue=(0,y.useMemo)(()=>{let e=new Map;return U?.forEach(t=>{if(t.status===`skipped`&&t.error_message===`Previous print failed or was aborted`&&t.printer_id){let n=e.get(t.printer_id);n?n.count+=1:e.set(t.printer_id,{name:t.printer_name||`Printer #${t.printer_id}`,count:1})}}),Array.from(e.entries()).map(([e,{name:t,count:n}])=>({printerId:e,printerName:t,skippedCount:n})).sort((e,t)=>e.printerName.localeCompare(t.printerName))},[U]),We=e=>{let t=0,n=0,r=0;for(let i of e){let e=i.kind===`item`?[i.item]:i.items;for(let i of e)t+=1,n+=i.print_time_seconds||0,r+=i.filament_used_grams||0}return{count:t,time:n,weight:r}};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Uc,{className:`w-7 h-7 text-bambu-green`}),e(`queue.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`queue.subtitle`)})]})}),(0,K.jsx)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary mb-6 overflow-x-auto`,children:[{id:`queue`,label:e(`queue.tabs.queue`),icon:Ss,count:Ee.length+Oe.length},{id:`history`,label:e(`queue.tabs.history`),icon:Uc,count:Ne.length},{id:`timeline`,label:e(`queue.tabs.timeline`),icon:ns,count:null}].map(({id:e,label:t,icon:n,count:r})=>(0,K.jsxs)(`button`,{onClick:()=>I(e),className:`px-4 py-2.5 text-sm flex items-center gap-2 border-b-2 -mb-px transition-colors whitespace-nowrap ${F===e?`text-white border-bambu-green font-medium`:`text-bambu-gray border-transparent hover:text-white`}`,children:[(0,K.jsx)(n,{className:`w-4 h-4`}),t,r!==null&&r>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${F===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:r})]},e))}),(0,K.jsx)(iVe,{activeCount:Oe.length,pendingCount:Ee.length,totalTime:Pe,totalWeight:Fe,historyCount:Ne.length,t:e}),F===`queue`&&Ue.length>0&&r(`queue:update_all`)&&(0,K.jsx)(`div`,{className:`mb-4 space-y-2`,children:Ue.map(({printerId:t,printerName:n,skippedCount:r})=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-orange-500/10 border border-orange-500/30 rounded-lg`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-orange-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-orange-200`,children:e(`queue.resumeAfterFailure.banner`,{printer:n,count:r})}),(0,K.jsx)(`div`,{className:`text-xs text-orange-200/70 mt-0.5`,children:e(`queue.resumeAfterFailure.bannerHint`)})]}),(0,K.jsxs)(`button`,{onClick:()=>E({printerId:t,printerName:n,skippedCount:r}),className:`flex items-center gap-1.5 px-3 py-1.5 bg-orange-500/20 hover:bg-orange-500/30 text-orange-100 text-sm rounded-md border border-orange-500/40 transition-colors flex-shrink-0`,children:[(0,K.jsx)(_s,{className:`w-4 h-4`}),e(`queue.resumeAfterFailure.button`)]})]},t))}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-4 mb-6`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:o===-1?`unassigned`:o||``,onChange:e=>{let t=e.target.value;s(t===`unassigned`?-1:t===``?null:Number(t))},children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allPrinters`)}),(0,K.jsx)(`option`,{value:`unassigned`,children:e(`queue.filter.unassigned`)}),ce?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allStatus`)}),(0,K.jsx)(`option`,{value:`pending`,children:e(`queue.status.pending`)}),(0,K.jsx)(`option`,{value:`printing`,children:e(`queue.status.printing`)}),(0,K.jsx)(`option`,{value:`completed`,children:e(`queue.status.completed`)}),(0,K.jsx)(`option`,{value:`failed`,children:e(`queue.status.failed`)}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`queue.status.skipped`)}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`queue.status.cancelled`)})]}),we.length>0&&(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:u,onChange:e=>d(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allLocations`)}),we.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsx)(`div`,{className:`hidden sm:block flex-1`}),F===`history`&&Ne.length>0&&(0,K.jsxs)($,{className:`w-full sm:w-auto`,variant:`secondary`,size:`sm`,onClick:()=>p(!0),disabled:!r(`queue:delete_all`),title:r(`queue:delete_all`)?void 0:e(`queue.permissions.noClearHistory`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`queue.clearHistory`)]})]}),F===`queue`&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-6`,children:[(0,K.jsxs)(`div`,{className:`inline-flex items-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-0.5`,children:[(0,K.jsxs)(`button`,{className:`px-3 py-1.5 text-xs sm:text-sm rounded-md transition-colors flex items-center gap-1.5 ${L===`position`?`bg-bambu-dark-tertiary text-white`:`text-bambu-gray hover:text-white`}`,onClick:()=>R(`position`),title:e(`queue.layout.flatList`),children:[(0,K.jsx)(Gc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.layout.flatList`)})]}),(0,K.jsxs)(`button`,{className:`px-3 py-1.5 text-xs sm:text-sm rounded-md transition-colors flex items-center gap-1.5 ${L===`printer`?`bg-bambu-dark-tertiary text-white`:`text-bambu-gray hover:text-white`}`,onClick:()=>R(`printer`),title:e(`queue.layout.groupByPrinter`),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.layout.byPrinter`)})]})]}),(0,K.jsxs)(`button`,{onClick:()=>{let e=!(ae?.queue_shortest_first??!1);le.mutate(e)},className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded-lg border transition-colors ${ae?.queue_shortest_first?`bg-bambu-green/20 border-bambu-green text-bambu-green`:`bg-bambu-dark-secondary border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,title:e(`queue.sjf.tooltip`,`Shortest Job First — scheduler prioritizes shorter prints`),children:[(0,K.jsx)(tu,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.sjf.label`,`SJF`)}),(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${ae?.queue_shortest_first?`bg-bambu-green`:`bg-bambu-gray`}`})]})]}),se?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):U?.length===0?(0,K.jsxs)(_d,{className:`p-12 text-center border-dashed`,children:[(0,K.jsx)(Zo,{className:`w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50`}),(0,K.jsx)(`h3`,{className:`text-xl font-medium text-white mb-2`,children:e(`queue.empty.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray max-w-md mx-auto`,children:e(`queue.empty.description`)})]}):F===`timeline`?(0,K.jsx)(lVe,{queueItems:U||[],printers:ce||[],printerStatuses:Me,onItemClick:e=>{[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status)?_(e):e.status===`pending`?h(e):e.status===`printing`&&b({type:`stop`,item:e})},t:e}):F===`history`?(0,K.jsx)(pVe,{items:Ne,collapsed:!1,sortBy:D,sortAsc:k,onSortByChange:O,onSortAscToggle:()=>A(!k),onRemove:e=>b({type:`remove`,item:e}),onRequeue:_,timeFormat:oe,batchCollapsed:z,toggleBatchCollapsed:Ve,hasPermission:r,canModify:a,t:e}):(0,K.jsxs)(`div`,{className:`space-y-6 sm:space-y-8`,children:[Oe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white mb-3 sm:mb-4 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-blue-400 animate-pulse`}),e(`queue.sections.currentlyPrinting`)]}),(0,K.jsx)(`div`,{className:`space-y-2 sm:space-y-3`,children:Oe.map(t=>(0,K.jsx)(r3,{item:t,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>b({type:`stop`,item:t}),onRequeue:()=>{},onStart:()=>{},timeFormat:oe,hasPermission:r,canModify:a,printerState:t.printer_id?je[t.printer_id]:null,t:e},t.id))})]}),Ee.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 sm:w-5 sm:h-5 text-yellow-400`}),e(`queue.sections.queued`),(0,K.jsxs)(`span`,{className:`text-xs sm:text-sm font-normal text-bambu-gray`,children:[`(`,e(`queue.itemCount`,{count:Ee.length}),`)`]}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-xs text-bambu-gray ml-2`,title:e(`queue.reorderHint`),children:e(`queue.dragToReorder`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:j,onChange:e=>M(e.target.value),children:[(0,K.jsx)(`option`,{value:`position`,children:e(`queue.sort.byPosition`)}),(0,K.jsx)(`option`,{value:`name`,children:e(`queue.sort.byName`)}),(0,K.jsx)(`option`,{value:`printer`,children:e(`queue.sort.byPrinter`)}),(0,K.jsx)(`option`,{value:`time`,children:e(`queue.sort.bySchedule`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>P(!N),title:e(N?`common.ascending`:`common.descending`),className:`px-2`,children:N?(0,K.jsx)(Io,{className:`w-4 h-4`}):(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:De,className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm`,children:[x.length===Ee.length&&Ee.length>0?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),x.length===Ee.length&&Ee.length>0?e(`queue.bulkEdit.deselectAll`):e(`queue.bulkEdit.selectAll`)]}),x.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-xs sm:text-sm text-bambu-gray`,children:e(`queue.bulkEdit.selected`,{count:x.length})}),(0,K.jsx)(`div`,{className:`hidden sm:block h-4 w-px bg-bambu-dark-tertiary`}),Be&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>ne(!0),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-cyan-300 hover:text-cyan-200`,title:e(`queue.batch.groupAsBatch`),children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.batch.groupAsBatch`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light`,disabled:!i(`queue:update_own`,`queue:update_all`),title:i(`queue:update_own`,`queue:update_all`)?e(`queue.bulkEdit.editSelected`):e(`queue.permissions.noEditItems`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.bulkEdit.editSelected`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>ye.mutate(x),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300`,disabled:ye.isPending||!i(`queue:delete_own`,`queue:delete_all`),title:i(`queue:delete_own`,`queue:delete_all`)?e(`queue.bulkEdit.cancelSelected`):e(`queue.permissions.noCancelItems`),children:[(0,K.jsx)(Ru,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.bulkEdit.cancelSelected`)})]})]})]}),(0,K.jsxs)(N4,{sensors:H,collisionDetection:I2,onDragStart:Ie,onDragEnd:Le,children:[(0,K.jsx)(U4,{items:ze,strategy:KBe,children:L===`position`?(0,K.jsx)(`div`,{className:`space-y-2 sm:space-y-3`,children:Re.map(t=>(0,K.jsx)(i3,{row:t,collapsed:t.kind===`batch`?z[t.batchId]??!0:!1,onToggleBatch:t.kind===`batch`?()=>Ve(t.batchId):void 0,onUngroup:t.kind===`batch`?()=>ie(t.batchId):void 0,setEditItem:h,setConfirmAction:b,startMutation:he,selectedItems:x,handleToggleSelect:Ce,timeFormat:oe,hasPermission:r,canModify:a,t:e,aggregateForRows:We},t.kind===`item`?`item-${t.item.id}`:`batch-${t.batchId}`))}):(0,K.jsx)(`div`,{className:`space-y-4`,children:He.map(t=>{let n=We(t.rows);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-t-lg`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 ${t.isUnassigned?`text-orange-400`:t.targetModel?`text-blue-400`:`text-bambu-green`}`}),(0,K.jsx)(`span`,{className:`font-semibold text-white text-sm`,children:t.label}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex flex-wrap gap-x-3`,children:[(0,K.jsx)(`span`,{children:e(`queue.itemCount`,{count:n.count})}),n.time>0&&(0,K.jsx)(`span`,{children:Cf(n.time)}),n.weight>0&&(0,K.jsx)(`span`,{children:t3(n.weight)})]})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark/40 border border-t-0 border-bambu-dark-tertiary rounded-b-lg p-2 space-y-2`,children:t.rows.map(t=>(0,K.jsx)(i3,{row:t,collapsed:t.kind===`batch`?z[t.batchId]??!0:!1,onToggleBatch:t.kind===`batch`?()=>Ve(t.batchId):void 0,onUngroup:t.kind===`batch`?()=>ie(t.batchId):void 0,setEditItem:h,setConfirmAction:b,startMutation:he,selectedItems:x,handleToggleSelect:Ce,timeFormat:oe,hasPermission:r,canModify:a,t:e,aggregateForRows:We},t.kind===`item`?`item-${t.item.id}`:`batch-${t.batchId}`))})]},t.key)})})}),(0,K.jsx)(HBe,{children:(()=>{if(V===null)return null;if(typeof V==`string`&&V.startsWith(`batch-`)){let t=Number(V.slice(6)),n=Ee.filter(e=>e.batch_id===t);if(n.length===0)return null;let r=n[0].batch_name||e(`queue.batch.defaultName`);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border-2 border-cyan-400 rounded-lg shadow-2xl`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-cyan-300`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e(`queue.dragGhost.batch`,{defaultValue:`{{name}} ({{count}} copies)`,name:r,count:n.length})})]})}return typeof V==`number`&&x.includes(V)&&x.length>1?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border-2 border-cyan-400 rounded-lg shadow-2xl`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-cyan-300`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e(`queue.dragGhost.multiCount`,{count:x.length})})]}):null})()})]})]})]}),m&&(0,K.jsx)(oW,{mode:`edit-queue-item`,archiveId:m.archive_id??void 0,libraryFileId:m.library_file_id??void 0,archiveName:m.archive_name||m.library_file_name||`File #${m.archive_id||m.library_file_id}`,queueItem:m,onClose:()=>h(null)}),g&&(0,K.jsx)(oW,{mode:`add-to-queue`,archiveId:g.archive_id??void 0,libraryFileId:g.library_file_id??void 0,archiveName:g.archive_name||g.library_file_name||`File #${g.archive_id||g.library_file_id}`,onClose:()=>_(null)}),pe&&(0,K.jsx)(Ad,{title:e(`queue.filamentShort.confirmTitle`),message:e(`queue.filamentShort.confirmIntro`)+` + `,onClick:M?()=>{window.innerWidth<640&&u()}:void 0,children:[M&&l&&(0,K.jsx)(`div`,{className:`sm:hidden absolute left-0 top-3 bottom-3 w-1 rounded-full bg-bambu-green`}),(0,K.jsxs)(`div`,{className:`flex items-start sm:items-center gap-2 sm:gap-4 p-3 sm:p-4`,children:[A&&u&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),u()},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${l?`bg-bambu-green border-bambu-green text-white`:`border-white/30 bg-black/30 hover:border-bambu-green/50`}`,children:l&&(0,K.jsx)(rs,{className:`w-4 h-4`})}),A?(0,K.jsx)(`div`,{...S,...C,className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0`,children:(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray`})}):t===void 0?(0,K.jsx)(`div`,{className:`hidden sm:block w-8 shrink-0`}):(0,K.jsxs)(`div`,{className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark text-bambu-gray text-sm font-medium shrink-0`,children:[`#`,t]}),(0,K.jsx)(`div`,{className:`w-10 h-10 sm:w-14 sm:h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden`,children:e.archive_thumbnail?(0,K.jsx)(`img`,{src:e.plate_id==null?Q.getArchiveThumbnail(e.archive_id):Q.getArchivePlateThumbnail(e.archive_id,e.plate_id),alt:``,className:`w-full h-full object-cover`}):e.library_file_thumbnail?(0,K.jsx)(`img`,{src:e.plate_id==null?Q.getLibraryFileThumbnailUrl(e.library_file_id):Q.getLibraryFilePlateThumbnail(e.library_file_id,e.plate_id),alt:``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:(0,K.jsx)(Rc,{className:`w-5 h-5 sm:w-6 sm:h-6`})})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm sm:text-base text-white font-medium truncate`,children:[e.archive_name||e.library_file_name||`File #${e.archive_id||e.library_file_id}`,(y?.is_multi_plate??!1)&&e.plate_id!==void 0&&e.plate_id!==null&&` • ${b.find(t=>t.index===e.plate_id)?.name||m(`queue.plateNumber`,{index:e.plate_id})}`]}),e.archive_id?(0,K.jsx)(wi,{to:`/archives?highlight=${e.archive_id}`,className:`text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:m(`queue.viewArchive`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):e.library_file_id?(0,K.jsx)(wi,{to:`/library?highlight=${e.library_file_id}`,className:`text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:m(`queue.viewInFileManager`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):null,e.batch_name&&(0,K.jsx)(`span`,{className:`flex-shrink-0 px-1.5 py-0.5 text-[10px] sm:text-xs bg-cyan-500/20 text-cyan-300 rounded border border-cyan-500/30`,children:e.batch_name})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5 ${e.printer_id===null&&!e.target_model?`text-orange-400`:``} ${e.target_model&&!e.printer_id?`text-blue-400`:``}`,children:[(0,K.jsx)(Tl,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),(0,K.jsx)(`span`,{className:`truncate max-w-[120px] sm:max-w-none`,children:e.target_model&&!e.printer_id?`${m(`queue.filter.any`)} ${e.target_model}${e.target_location?` @ ${e.target_location}`:``}${e.required_filament_types?.length?` (${e.required_filament_types.join(`, `)})`:``}`:e.printer_id===null?m(`queue.filter.unassigned`):e.printer_name||`${m(`common.printer`)} #${e.printer_id}`})]}),e.print_time_seconds&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(yu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),Cf(e.print_time_seconds)]}),e.filament_used_grams&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(Nu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),t3(e.filament_used_grams)]}),(()=>{let t=$U(e.bed_type);return t?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,title:t.label,children:[(0,K.jsx)(`img`,{src:t.icon,alt:``,className:`w-3.5 h-3.5 sm:w-4 sm:h-4 object-contain`}),(0,K.jsx)(`span`,{className:`truncate max-w-[120px]`,children:t.label})]}):null})(),e.created_by_username&&(0,K.jsxs)(`span`,{className:`hidden sm:flex items-center gap-1.5`,title:m(`queue.addedBy`,{name:e.created_by_username}),children:[(0,K.jsx)(Ou,{className:`w-3.5 h-3.5`}),e.created_by_username]}),A&&!e.manual_start&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),e.scheduled_time?(vf(e.scheduled_time)?.getTime()??0)-Date.now()<-6e4?m?.(`queue.time.overdue`)??`Overdue`:wf(e.scheduled_time,c,m):m?.(`queue.time.asap`)??`ASAP`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 sm:gap-2 mt-1.5 sm:mt-2`,children:[e.manual_start&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-purple-500/10 text-purple-400 rounded-full border border-purple-500/20 flex items-center gap-1`,children:[(0,K.jsx)(Cc,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.staged`)]}),e.require_previous_success&&(0,K.jsx)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-orange-500/10 text-orange-400 rounded-full border border-orange-500/20`,children:m(`queue.badges.requiresPrevious`)}),e.auto_off_after&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-blue-500/10 text-blue-400 rounded-full border border-blue-500/20 flex items-center gap-1`,children:[(0,K.jsx)(wl,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.autoPowerOff`)]}),e.gcode_injection&&(0,K.jsxs)(`span`,{className:`text-[10px] sm:text-xs px-1.5 sm:px-2 py-0.5 bg-emerald-500/10 text-emerald-400 rounded-full border border-emerald-500/20 flex items-center gap-1`,children:[(0,K.jsx)(Es,{className:`w-2.5 h-2.5 sm:w-3 sm:h-3`}),m(`queue.badges.gcodeInjection`)]})]}),k&&h&&(()=>{let e=h.state===`RUNNING`||h.state===`PAUSE`,t=e&&h.progress||0,n=e?h.remaining_time:null,r=e?h.layer_num:null,i=e?h.total_layers:null;return(0,K.jsxs)(`div`,{className:`mt-2 sm:mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs sm:text-sm`,children:[(0,K.jsx)(`div`,{className:`flex-1 bg-bambu-dark-tertiary rounded-full h-1.5 sm:h-2 mr-3`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-1.5 sm:h-2 rounded-full transition-all`,style:{width:`${t}%`}})}),(0,K.jsxs)(`span`,{className:`text-white`,children:[Math.round(t),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mt-1.5 sm:mt-2 text-[10px] sm:text-xs text-bambu-gray`,children:[n!=null&&n>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(n*60)]}),(0,K.jsxs)(`span`,{className:`text-bambu-green font-medium`,title:m(`printers.estimatedCompletion`),children:[`ETA `,Sf(n,c,m)]})]}),r!=null&&i!=null&&i>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Rc,{className:`w-3 h-3`}),r,`/`,i]})]})]})})(),e.waiting_reason&&e.status===`pending`&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-purple-400 mt-1.5 sm:mt-2 flex items-start gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:e.waiting_reason})]}),e.filament_short&&e.status===`pending`&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-yellow-400 mt-1.5 sm:mt-2 flex items-start gap-1`,title:m(`queue.filamentShort.rowTooltip`),children:[(0,K.jsx)(ds,{className:`w-3 h-3 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:m(`queue.filamentShort.rowBadge`)})]}),e.error_message&&(0,K.jsxs)(`p`,{className:`text-[10px] sm:text-xs text-red-400 mt-1.5 sm:mt-2 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),e.error_message]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2 sm:gap-1 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(uVe,{status:e.status,waitingReason:e.waiting_reason,printerState:p,t:m}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1`,children:[k&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:a,disabled:!d(`printers:control`),title:d(`printers:control`)?m(`queue.actions.stopPrint`):m(`queue.permissions.noStopPrint`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(vs,{className:`w-4 h-4`})}),A&&(0,K.jsxs)(K.Fragment,{children:[e.manual_start&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:s,disabled:!d(`printers:control`),title:d(`printers:control`)?m(`queue.actions.startPrint`):m(`queue.permissions.noStartPrint`),className:`text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10 p-1.5 sm:p-2`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:n,disabled:!f(`queue`,`update`,e.created_by_id),title:f(`queue`,`update`,e.created_by_id)?m(`common.edit`):m(`queue.permissions.noEdit`),className:`p-1.5 sm:p-2`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,disabled:!f(`queue`,`delete`,e.created_by_id),title:f(`queue`,`delete`,e.created_by_id)?m(`common.cancel`):m(`queue.permissions.noCancel`),className:`text-red-400 hover:text-red-300 hover:bg-red-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),j&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:o,disabled:!d(`queue:create`),title:d(`queue:create`)?m(`queue.actions.requeue`):m(`queue.permissions.noRequeue`),className:`text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Ol,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,disabled:!f(`queue`,`delete`,e.created_by_id),title:f(`queue`,`delete`,e.created_by_id)?m(`common.remove`):m(`queue.permissions.noRemove`),className:`p-1.5 sm:p-2`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})]})]})}function i3(e){let{row:t,setEditItem:n,setConfirmAction:r,startMutation:i,selectedItems:a,handleToggleSelect:o,timeFormat:s,hasPermission:c,canModify:l,t:u}=e;return t.kind===`item`?(0,K.jsx)(r3,{item:t.item,onEdit:()=>n(t.item),onCancel:()=>r({type:`cancel`,item:t.item}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>i.mutate({id:t.item.id}),timeFormat:s,isSelected:a.includes(t.item.id),onToggleSelect:()=>o(t.item.id),hasPermission:c,canModify:l,t:u}):(0,K.jsx)(fVe,{...e})}function fVe({row:e,collapsed:t,onToggleBatch:n,onUngroup:r,setEditItem:i,setConfirmAction:a,startMutation:o,selectedItems:s,handleToggleSelect:c,timeFormat:l,hasPermission:u,canModify:d,t:f,aggregateForRows:p}){let m=e,h=u(`queue:reorder`),{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=G4({id:`batch-${m.batchId}`,disabled:!h}),S={transform:C2.Transform.toString(y),transition:b},C=p([m]),w=m.items.map(e=>e.id),T=w.length>0&&w.every(e=>s.includes(e)),E=new Set(m.items.map(e=>e.status)),D=E.has(`failed`)?`failed`:E.has(`printing`)?`printing`:`pending`,O=m.items.filter(e=>e.status===`pending`).length;return(0,K.jsxs)(`div`,{ref:v,style:S,className:`bg-bambu-dark-secondary rounded-xl border border-l-[3px] border-l-cyan-400 border-bambu-dark-tertiary overflow-hidden ${x?`opacity-50 scale-[1.01] shadow-xl z-50`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 sm:gap-3 p-3 sm:p-4`,children:[(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w.forEach(e=>{(T&&s.includes(e)||!T&&!s.includes(e))&&c(e)})},className:`hidden sm:flex items-center justify-center w-6 h-6 rounded border transition-colors shrink-0 ${T?`bg-bambu-green border-bambu-green text-white`:`border-white/30 bg-black/30 hover:border-bambu-green/50`}`,title:f(T?`queue.bulkEdit.deselectAll`:`queue.bulkEdit.selectAll`),children:T&&(0,K.jsx)(rs,{className:`w-4 h-4`})}),h&&(0,K.jsx)(`div`,{...g,..._,className:`hidden sm:flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark cursor-grab active:cursor-grabbing hover:bg-bambu-dark-tertiary transition-colors touch-manipulation shrink-0`,title:f(`queue.batch.dragGroup`,{defaultValue:`Drag group`}),children:(0,K.jsx)(xc,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:n,className:`flex items-center justify-center w-8 h-8 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors shrink-0`,title:f(t?`queue.batch.expand`:`queue.batch.collapse`),children:t?(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`div`,{className:`w-10 h-10 sm:w-12 sm:h-12 flex-shrink-0 bg-bambu-dark rounded-lg flex items-center justify-center`,children:t?(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300`}):(0,K.jsx)(fl,{className:`w-5 h-5 text-cyan-300`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`p`,{className:`text-sm sm:text-base text-white font-medium truncate`,children:m.batchName}),(0,K.jsx)(`span`,{className:`flex-shrink-0 px-1.5 py-0.5 text-[10px] sm:text-xs bg-cyan-500/15 text-cyan-300 rounded border border-cyan-500/30`,children:f(`queue.batch.label`,{count:C.count})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs sm:text-sm text-bambu-gray`,children:[C.time>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(yu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),Cf(C.time)]}),C.weight>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5`,children:[(0,K.jsx)(Nu,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),t3(C.weight)]}),O>0&&D===`pending`&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 sm:gap-1.5 text-yellow-400`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 sm:w-3.5 sm:h-3.5`}),f(`queue.batch.pendingCount`,{count:O})]})]})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:r&&(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,title:f(`queue.batch.ungroup`),className:`text-cyan-300 hover:text-cyan-200 hover:bg-cyan-500/10 p-1.5 sm:p-2`,children:(0,K.jsx)(Tu,{className:`w-4 h-4`})})})]}),!t&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary bg-black/20 p-2 sm:p-3 space-y-2`,children:m.items.map(e=>(0,K.jsx)(r3,{item:e,onEdit:()=>i(e),onCancel:()=>a({type:`cancel`,item:e}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>o.mutate({id:e.id}),timeFormat:l,isSelected:s.includes(e.id),onToggleSelect:()=>c(e.id),hasPermission:u,canModify:d,t:f},e.id))})]})}function pVe({items:e,sortBy:t,sortAsc:n,onSortByChange:r,onSortAscToggle:i,onRemove:a,onRequeue:o,timeFormat:s,batchCollapsed:c,toggleBatchCollapsed:l,hasPermission:u,canModify:d,t:f}){if(e.length===0)return(0,K.jsxs)(_d,{className:`p-12 text-center border-dashed`,children:[(0,K.jsx)(Uc,{className:`w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50`}),(0,K.jsx)(`h3`,{className:`text-xl font-medium text-white mb-2`,children:f(`queue.history.emptyTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray max-w-md mx-auto`,children:f(`queue.history.emptyDescription`)})]});let p=[],m=new Set;for(let t of e.slice(0,50))if(t.batch_id!=null){if(m.has(t.batch_id))continue;m.add(t.batch_id);let n=e.filter(e=>e.batch_id===t.batch_id);p.push({kind:`batch`,batchId:t.batch_id,batchName:t.batch_name||f(`queue.batch.defaultName`),items:n})}else p.push({kind:`item`,item:t});return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white flex items-center gap-2`,children:[f(`queue.sections.history`),(0,K.jsxs)(`span`,{className:`text-xs sm:text-sm font-normal text-bambu-gray`,children:[`(`,f(`queue.itemCount`,{count:e.length}),`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:t,onChange:e=>r(e.target.value),children:[(0,K.jsx)(`option`,{value:`date`,children:f(`queue.sort.byDate`)}),(0,K.jsx)(`option`,{value:`name`,children:f(`queue.sort.byName`)}),(0,K.jsx)(`option`,{value:`printer`,children:f(`queue.sort.byPrinter`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,title:f(n?`queue.sort.ascendingOldest`:`queue.sort.descendingNewest`),className:`px-2`,children:n?(0,K.jsx)(Io,{className:`w-4 h-4`}):(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:p.map(e=>{if(e.kind===`item`)return(0,K.jsx)(X4,{item:e.item,onRemove:()=>a(e.item),onRequeue:()=>o(e.item),timeFormat:s,hasPermission:u,canModify:d,t:f},e.item.id);let t=c[e.batchId]??!0,n=e.items.filter(e=>e.status===`completed`).length,r=e.items.filter(e=>e.status===`failed`).length,i=e.items.filter(e=>e.status===`skipped`).length,p=e.items.filter(e=>e.status===`cancelled`).length,m=e.items.map(e=>e.completed_at||e.created_at).filter(e=>!!e).sort().at(-1);return(0,K.jsxs)(`div`,{className:`md:col-span-2 xl:col-span-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary border-l-[3px] border-l-cyan-400`,children:[(0,K.jsxs)(`button`,{onClick:()=>l(e.batchId),className:`w-full flex items-center gap-2 sm:gap-3 px-3 py-2 hover:bg-bambu-dark/30 transition-colors text-left`,title:f(t?`queue.batch.expand`:`queue.batch.collapse`),children:[t?(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray shrink-0`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0`}),t?(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300 shrink-0`}):(0,K.jsx)(fl,{className:`w-5 h-5 text-cyan-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium truncate min-w-0 flex-1`,children:e.batchName}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray shrink-0`,children:[n>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-emerald-400`,children:[(0,K.jsx)(ps,{className:`w-3 h-3`}),n]}),r>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-3 h-3`}),r]}),i>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-orange-400`,children:[(0,K.jsx)(Zl,{className:`w-3 h-3`}),i]}),p>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-gray-400`,children:[(0,K.jsx)(Lo,{className:`w-3 h-3`}),p]}),(0,K.jsx)(`span`,{title:m??void 0,children:m?wf(m,s,f):null})]})]}),!t&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary bg-black/20 p-2 grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:e.items.map(e=>(0,K.jsx)(X4,{item:e,onRemove:()=>a(e),onRequeue:()=>o(e),timeFormat:s,hasPermission:u,canModify:d,t:f},e.id))})]},`batch-${e.batchId}`)})})]})}function mVe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i,canModify:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)([]),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)(null),[D,O]=(0,y.useState)(()=>localStorage.getItem(`queue.historySortBy`)||`date`),[k,A]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.historySortAsc`);return e===null?!1:e===`true`}),[j,M]=(0,y.useState)(()=>localStorage.getItem(`queue.pendingSortBy`)||`position`),[N,P]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.pendingSortAsc`);return e===null?!0:e===`true`}),[F,I]=(0,y.useState)(()=>{let e=localStorage.getItem(`queue.activeTab`);return e===`history`||e===`timeline`?e:`queue`}),[L,R]=(0,y.useState)(()=>localStorage.getItem(`queue.activeLayout`)===`printer`?`printer`:`position`),[z,B]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`queue.batchCollapsed`);return e?JSON.parse(e):{}}catch{return{}}}),[V,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(!1),[re,ie]=(0,y.useState)(null);(0,y.useEffect)(()=>{localStorage.setItem(`queue.historySortBy`,D)},[D]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.historySortAsc`,String(k))},[k]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.pendingSortBy`,j)},[j]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.pendingSortAsc`,String(N))},[N]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.activeTab`,F)},[F]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.activeLayout`,L)},[L]),(0,y.useEffect)(()=>{localStorage.setItem(`queue.batchCollapsed`,JSON.stringify(z))},[z]);let H=k2(O2(l4,{activationConstraint:{distance:8}}),O2(a4,{coordinateGetter:q4})),{data:ae}=q({queryKey:[`settings`],queryFn:Q.getSettings}),oe=ae?.time_format||`system`,{data:U,isLoading:se}=q({queryKey:[`queue`,o,c],queryFn:()=>Q.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:ce}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),le=J({mutationFn:e=>Q.updateSettings({queue_shortest_first:e}),onSuccess:()=>{t.invalidateQueries({queryKey:[`settings`]})}}),ue=J({mutationFn:e=>Q.cancelQueueItem(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.cancelled`))},onError:()=>n(e(`queue.toast.cancelFailed`),`error`)}),de=J({mutationFn:e=>Q.removeFromQueue(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.removed`))},onError:()=>n(e(`queue.toast.removeFailed`),`error`)}),fe=J({mutationFn:e=>Q.stopQueueItem(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.stopped`))},onError:()=>n(e(`queue.toast.stopFailed`),`error`)}),[pe,me]=(0,y.useState)(null),he=J({mutationFn:({id:e,skipFilamentCheck:t})=>Q.startQueueItem(e,{skipFilamentCheck:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.released`)),me(null)},onError:(t,r)=>{if(t instanceof Uu&&t.status===409&&t.code===`insufficient_filament`){let e=t.detail?.deficit??[];me({itemId:r.id,deficit:e});return}n(e(`queue.toast.startFailed`),`error`)}}),ge=J({mutationFn:e=>Q.reorderQueue(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`queue`]})},onError:()=>n(e(`queue.toast.reorderFailed`),`error`)}),_e=J({mutationFn:async()=>{let e=U?.filter(e=>[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status))||[];for(let t of e)await Q.removeFromQueue(t.id);return e.length},onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),n(e(`queue.toast.historyCleared`,{count:r}))},onError:()=>n(e(`queue.toast.clearHistoryFailed`),`error`)}),ve=J({mutationFn:e=>Q.bulkUpdateQueue(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),w(!1),n(e.message)},onError:()=>n(e(`queue.toast.updateFailed`),`error`)}),ye=J({mutationFn:async e=>{for(let t of e)await Q.cancelQueueItem(t);return e.length},onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),n(e(`queue.toast.bulkCancelled`,{count:r}))},onError:()=>n(e(`queue.toast.bulkCancelFailed`),`error`)}),be=J({mutationFn:e=>Q.resumeQueueAfterFailure(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),E(null),n(e(`queue.toast.resumedAfterFailure`,{restored:r.restored,acknowledged:r.acknowledged}))},onError:()=>n(e(`queue.toast.resumeAfterFailureFailed`),`error`)}),xe=J({mutationFn:e=>Q.createBatch(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),S([]),ne(!1),B(e=>({...e,[r.id]:!1})),n(e(`queue.toast.batchCreated`,{name:r.name}))},onError:()=>n(e(`queue.toast.batchCreateFailed`),`error`)}),Se=J({mutationFn:e=>Q.ungroupBatch(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`queue`]}),ie(null),n(e(`queue.toast.batchUngrouped`,{count:r.ungrouped_count}))},onError:()=>n(e(`queue.toast.batchUngroupFailed`),`error`)}),Ce=e=>{S(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},we=(0,y.useMemo)(()=>{let e=new Set;return ce?.forEach(t=>{t.location&&e.add(t.location)}),U?.forEach(t=>{t.target_location&&e.add(t.target_location)}),Array.from(e).sort()},[ce,U]),Te=(0,y.useCallback)(e=>u?e.target_location?e.target_location===u:e.printer_id?ce?.find(t=>t.id===e.printer_id)?.location===u:!1:!0,[u,ce]),Ee=(0,y.useMemo)(()=>{let e=U?.filter(e=>e.status===`pending`)||[];u&&(e=e.filter(Te));let t=e=>{if(!e.scheduled_time)return 0;let t=vf(e.scheduled_time)?.getTime()??0;return t>Date.now()+4320*60*60*1e3?0:t};return ae?.queue_shortest_first?[...e].sort((e,t)=>{let n=e.printer_id??-(e.target_model?.charCodeAt(0)??0),r=t.printer_id??-(t.target_model?.charCodeAt(0)??0);if(n!==r)return n-r;let i=+!!e.been_jumped,a=+!!t.been_jumped;if(i!==a)return a-i;let o=e.print_time_seconds??1/0,s=t.print_time_seconds??1/0;return o===s?e.position-t.position:o-s}):[...e].sort((e,n)=>{let r;if(j===`name`){let t=e.archive_name||e.library_file_name||``,i=n.archive_name||n.library_file_name||``;r=t.localeCompare(i)}else r=j===`printer`?(e.printer_name||``).localeCompare(n.printer_name||``):j===`time`?t(e)-t(n):e.position-n.position;return N?r:-r})},[U,j,N,Te,u,ae?.queue_shortest_first]),De=()=>{let e=Ee.map(e=>e.id);x.length===e.length?S([]):S(e)},Oe=(0,y.useMemo)(()=>{let e=U?.filter(e=>e.status===`printing`)||[];return u&&(e=e.filter(Te)),e},[U,u,Te]),ke=(0,y.useMemo)(()=>{let e=new Set;return Oe.forEach(t=>{t.printer_id&&e.add(t.printer_id)}),Array.from(e)},[Oe]),Ae=_o({queries:ke.map(e=>({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),refetchInterval:5e3}))}),je=(0,y.useMemo)(()=>{let e={};return ke.forEach((t,n)=>{let r=Ae[n];r?.data?.state&&(e[t]=r.data.state)}),e},[ke,Ae]),Me=(0,y.useMemo)(()=>{let e={};return ke.forEach((t,n)=>{let r=Ae[n];r?.data&&(e[t]={progress:r.data.progress??void 0,remaining_time:r.data.remaining_time??void 0,state:r.data.state??void 0})}),e},[ke,Ae]),Ne=(0,y.useMemo)(()=>{let e=U?.filter(e=>[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status))||[];return u&&(e=e.filter(Te)),[...e].sort((e,t)=>{let n;if(D===`name`){let r=e.archive_name||e.library_file_name||``,i=t.archive_name||t.library_file_name||``;n=r.localeCompare(i)}else n=D===`printer`?(e.printer_name||``).localeCompare(t.printer_name||``):(vf(t.completed_at||t.created_at)?.getTime()??0)-(vf(e.completed_at||e.created_at)?.getTime()??0);return k?-n:n})},[U,D,k,Te,u]),Pe=(0,y.useMemo)(()=>Ee.reduce((e,t)=>e+(t.print_time_seconds||0),0),[Ee]),Fe=(0,y.useMemo)(()=>Ee.reduce((e,t)=>e+(t.filament_used_grams||0),0),[Ee]),Ie=e=>{let t=e.active.id;ee(typeof t==`number`||typeof t==`string`?t:null)},Le=e=>{let{active:t,over:n}=e;if(ee(null),!n||t.id===n.id)return;let r,i=t.id;if(typeof i==`string`&&i.startsWith(`batch-`)){let e=Number(i.slice(6));r=Ee.filter(t=>t.batch_id===e).map(e=>e.id)}else{let e=i;r=x.includes(e)&&x.length>1?x.slice().sort((e,t)=>Ee.findIndex(t=>t.id===e)-Ee.findIndex(e=>e.id===t)):[e]}if(r.length===0)return;let a,o=n.id;if(typeof o==`string`&&o.startsWith(`batch-`)){let e=Number(o.slice(6));a=Ee.findIndex(t=>t.batch_id===e)}else a=Ee.findIndex(e=>e.id===o);if(a===-1)return;let s=Ee[a],c=Ee.filter(e=>!r.includes(e.id)),l=c.findIndex(e=>e.id===s.id);l===-1&&(l=a),Ee.findIndex(e=>e.id===r[0])Ee.find(t=>t.id===e)).filter(e=>!!e),...c.slice(l)].map((e,t)=>({id:e.id,position:t+1}));ge.mutate(u)},Re=(0,y.useMemo)(()=>{let t=[],n=new Set;for(let r of Ee)if(r.batch_id!=null){if(n.has(r.batch_id))continue;n.add(r.batch_id);let i=Ee.filter(e=>e.batch_id===r.batch_id);t.push({kind:`batch`,batchId:r.batch_id,batchName:r.batch_name||e(`queue.batch.defaultName`),items:i})}else t.push({kind:`item`,item:r});return t},[Ee,e]),ze=(0,y.useMemo)(()=>{let e=[];for(let t of Re)if(t.kind===`item`)e.push(t.item.id);else if(e.push(`batch-${t.batchId}`),!(z[t.batchId]??!0))for(let n of t.items)e.push(n.id);return e},[Re,z]),Be=(0,y.useMemo)(()=>x.length<2?!1:x.every(e=>{let t=Ee.find(t=>t.id===e);return t&&t.batch_id==null}),[x,Ee]),Ve=e=>{B(t=>({...t,[e]:!(t[e]??!0)}))},He=(0,y.useMemo)(()=>{let t=new Map,n=t=>t.printer_id?{key:`printer:${t.printer_id}`,label:t.printer_name||`Printer #${t.printer_id}`,printerId:t.printer_id,targetModel:null,isUnassigned:!1}:t.target_model?{key:`model:${t.target_model}`,label:`${e(`queue.filter.any`)} ${t.target_model}`,printerId:null,targetModel:t.target_model,isUnassigned:!1}:{key:`unassigned`,label:e(`queue.filter.unassigned`),printerId:null,targetModel:null,isUnassigned:!0};for(let e of Re){let r=e.kind===`item`?e.item:e.items[0];if(!r)continue;let i=n(r);t.has(i.key)||t.set(i.key,{...i,rows:[]}),t.get(i.key).rows.push(e)}return Array.from(t.values()).sort((e,t)=>e.isUnassigned&&!t.isUnassigned?1:!e.isUnassigned&&t.isUnassigned?-1:e.label.localeCompare(t.label))},[Re,e]),Ue=(0,y.useMemo)(()=>{let e=new Map;return U?.forEach(t=>{if(t.status===`skipped`&&t.error_message===`Previous print failed or was aborted`&&t.printer_id){let n=e.get(t.printer_id);n?n.count+=1:e.set(t.printer_id,{name:t.printer_name||`Printer #${t.printer_id}`,count:1})}}),Array.from(e.entries()).map(([e,{name:t,count:n}])=>({printerId:e,printerName:t,skippedCount:n})).sort((e,t)=>e.printerName.localeCompare(t.printerName))},[U]),We=e=>{let t=0,n=0,r=0;for(let i of e){let e=i.kind===`item`?[i.item]:i.items;for(let i of e)t+=1,n+=i.print_time_seconds||0,r+=i.filament_used_grams||0}return{count:t,time:n,weight:r}};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-6`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Uc,{className:`w-7 h-7 text-bambu-green`}),e(`queue.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`queue.subtitle`)})]})}),(0,K.jsx)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary mb-6 overflow-x-auto`,children:[{id:`queue`,label:e(`queue.tabs.queue`),icon:Ss,count:Ee.length+Oe.length},{id:`history`,label:e(`queue.tabs.history`),icon:Uc,count:Ne.length},{id:`timeline`,label:e(`queue.tabs.timeline`),icon:ns,count:null}].map(({id:e,label:t,icon:n,count:r})=>(0,K.jsxs)(`button`,{onClick:()=>I(e),className:`px-4 py-2.5 text-sm flex items-center gap-2 border-b-2 -mb-px transition-colors whitespace-nowrap ${F===e?`text-white border-bambu-green font-medium`:`text-bambu-gray border-transparent hover:text-white`}`,children:[(0,K.jsx)(n,{className:`w-4 h-4`}),t,r!==null&&r>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${F===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:r})]},e))}),(0,K.jsx)(iVe,{activeCount:Oe.length,pendingCount:Ee.length,totalTime:Pe,totalWeight:Fe,historyCount:Ne.length,t:e}),F===`queue`&&Ue.length>0&&r(`queue:update_all`)&&(0,K.jsx)(`div`,{className:`mb-4 space-y-2`,children:Ue.map(({printerId:t,printerName:n,skippedCount:r})=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 bg-orange-500/10 border border-orange-500/30 rounded-lg`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-orange-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-orange-200`,children:e(`queue.resumeAfterFailure.banner`,{printer:n,count:r})}),(0,K.jsx)(`div`,{className:`text-xs text-orange-200/70 mt-0.5`,children:e(`queue.resumeAfterFailure.bannerHint`)})]}),(0,K.jsxs)(`button`,{onClick:()=>E({printerId:t,printerName:n,skippedCount:r}),className:`flex items-center gap-1.5 px-3 py-1.5 bg-orange-500/20 hover:bg-orange-500/30 text-orange-100 text-sm rounded-md border border-orange-500/40 transition-colors flex-shrink-0`,children:[(0,K.jsx)(_s,{className:`w-4 h-4`}),e(`queue.resumeAfterFailure.button`)]})]},t))}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-4 mb-6`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:o===-1?`unassigned`:o||``,onChange:e=>{let t=e.target.value;s(t===`unassigned`?-1:t===``?null:Number(t))},children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allPrinters`)}),(0,K.jsx)(`option`,{value:`unassigned`,children:e(`queue.filter.unassigned`)}),ce?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allStatus`)}),(0,K.jsx)(`option`,{value:`pending`,children:e(`queue.status.pending`)}),(0,K.jsx)(`option`,{value:`printing`,children:e(`queue.status.printing`)}),(0,K.jsx)(`option`,{value:`completed`,children:e(`queue.status.completed`)}),(0,K.jsx)(`option`,{value:`failed`,children:e(`queue.status.failed`)}),(0,K.jsx)(`option`,{value:`skipped`,children:e(`queue.status.skipped`)}),(0,K.jsx)(`option`,{value:`cancelled`,children:e(`queue.status.cancelled`)})]}),we.length>0&&(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-2 text-sm sm:text-base bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none min-w-0 flex-1 sm:flex-none`,value:u,onChange:e=>d(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`queue.filter.allLocations`)}),we.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsx)(`div`,{className:`hidden sm:block flex-1`}),F===`history`&&Ne.length>0&&(0,K.jsxs)($,{className:`w-full sm:w-auto`,variant:`secondary`,size:`sm`,onClick:()=>p(!0),disabled:!r(`queue:delete_all`),title:r(`queue:delete_all`)?void 0:e(`queue.permissions.noClearHistory`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`queue.clearHistory`)]})]}),F===`queue`&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mb-6`,children:[(0,K.jsxs)(`div`,{className:`inline-flex items-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-0.5`,children:[(0,K.jsxs)(`button`,{className:`px-3 py-1.5 text-xs sm:text-sm rounded-md transition-colors flex items-center gap-1.5 ${L===`position`?`bg-bambu-dark-tertiary text-white`:`text-bambu-gray hover:text-white`}`,onClick:()=>R(`position`),title:e(`queue.layout.flatList`),children:[(0,K.jsx)(Gc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.layout.flatList`)})]}),(0,K.jsxs)(`button`,{className:`px-3 py-1.5 text-xs sm:text-sm rounded-md transition-colors flex items-center gap-1.5 ${L===`printer`?`bg-bambu-dark-tertiary text-white`:`text-bambu-gray hover:text-white`}`,onClick:()=>R(`printer`),title:e(`queue.layout.groupByPrinter`),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.layout.byPrinter`)})]})]}),(0,K.jsxs)(`button`,{onClick:()=>{let e=!(ae?.queue_shortest_first??!1);le.mutate(e)},className:`flex items-center gap-1 px-2 py-1.5 text-xs rounded-lg border transition-colors ${ae?.queue_shortest_first?`bg-bambu-green/20 border-bambu-green text-bambu-green`:`bg-bambu-dark-secondary border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,title:e(`queue.sjf.tooltip`,`Shortest Job First — scheduler prioritizes shorter prints`),children:[(0,K.jsx)(tu,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.sjf.label`,`SJF`)}),(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${ae?.queue_shortest_first?`bg-bambu-green`:`bg-bambu-gray`}`})]})]}),se?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):U?.length===0?(0,K.jsxs)(_d,{className:`p-12 text-center border-dashed`,children:[(0,K.jsx)(Zo,{className:`w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50`}),(0,K.jsx)(`h3`,{className:`text-xl font-medium text-white mb-2`,children:e(`queue.empty.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray max-w-md mx-auto`,children:e(`queue.empty.description`)})]}):F===`timeline`?(0,K.jsx)(lVe,{queueItems:U||[],printers:ce||[],printerStatuses:Me,onItemClick:e=>{[`completed`,`failed`,`skipped`,`cancelled`].includes(e.status)?_(e):e.status===`pending`?h(e):e.status===`printing`&&b({type:`stop`,item:e})},t:e}):F===`history`?(0,K.jsx)(pVe,{items:Ne,collapsed:!1,sortBy:D,sortAsc:k,onSortByChange:O,onSortAscToggle:()=>A(!k),onRemove:e=>b({type:`remove`,item:e}),onRequeue:_,timeFormat:oe,batchCollapsed:z,toggleBatchCollapsed:Ve,hasPermission:r,canModify:a,t:e}):(0,K.jsxs)(`div`,{className:`space-y-6 sm:space-y-8`,children:[Oe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white mb-3 sm:mb-4 flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-blue-400 animate-pulse`}),e(`queue.sections.currentlyPrinting`)]}),(0,K.jsx)(`div`,{className:`space-y-2 sm:space-y-3`,children:Oe.map(t=>(0,K.jsx)(r3,{item:t,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>b({type:`stop`,item:t}),onRequeue:()=>{},onStart:()=>{},timeFormat:oe,hasPermission:r,canModify:a,printerState:t.printer_id?je[t.printer_id]:null,t:e},t.id))})]}),Ee.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 mb-3 sm:mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-base sm:text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 sm:w-5 sm:h-5 text-yellow-400`}),e(`queue.sections.queued`),(0,K.jsxs)(`span`,{className:`text-xs sm:text-sm font-normal text-bambu-gray`,children:[`(`,e(`queue.itemCount`,{count:Ee.length}),`)`]}),(0,K.jsx)(`span`,{className:`hidden sm:inline text-xs text-bambu-gray ml-2`,title:e(`queue.reorderHint`),children:e(`queue.dragToReorder`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{className:`px-2 sm:px-3 py-1.5 text-xs sm:text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:j,onChange:e=>M(e.target.value),children:[(0,K.jsx)(`option`,{value:`position`,children:e(`queue.sort.byPosition`)}),(0,K.jsx)(`option`,{value:`name`,children:e(`queue.sort.byName`)}),(0,K.jsx)(`option`,{value:`printer`,children:e(`queue.sort.byPrinter`)}),(0,K.jsx)(`option`,{value:`time`,children:e(`queue.sort.bySchedule`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>P(!N),title:e(N?`common.ascending`:`common.descending`),className:`px-2`,children:N?(0,K.jsx)(Io,{className:`w-4 h-4`}):(0,K.jsx)(Ao,{className:`w-4 h-4`})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mb-3 sm:mb-4 p-2 sm:p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:De,className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm`,children:[x.length===Ee.length&&Ee.length>0?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4`}),x.length===Ee.length&&Ee.length>0?e(`queue.bulkEdit.deselectAll`):e(`queue.bulkEdit.selectAll`)]}),x.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-xs sm:text-sm text-bambu-gray`,children:e(`queue.bulkEdit.selected`,{count:x.length})}),(0,K.jsx)(`div`,{className:`hidden sm:block h-4 w-px bg-bambu-dark-tertiary`}),Be&&(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>ne(!0),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-cyan-300 hover:text-cyan-200`,title:e(`queue.batch.groupAsBatch`),children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.batch.groupAsBatch`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-bambu-green hover:text-bambu-green-light`,disabled:!i(`queue:update_own`,`queue:update_all`),title:i(`queue:update_own`,`queue:update_all`)?e(`queue.bulkEdit.editSelected`):e(`queue.permissions.noEditItems`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.bulkEdit.editSelected`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>ye.mutate(x),className:`flex items-center gap-1.5 sm:gap-2 text-xs sm:text-sm text-red-400 hover:text-red-300`,disabled:ye.isPending||!i(`queue:delete_own`,`queue:delete_all`),title:i(`queue:delete_own`,`queue:delete_all`)?e(`queue.bulkEdit.cancelSelected`):e(`queue.permissions.noCancelItems`),children:[(0,K.jsx)(Ru,{className:`w-3.5 h-3.5 sm:w-4 sm:h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`queue.bulkEdit.cancelSelected`)})]})]})]}),(0,K.jsxs)(N4,{sensors:H,collisionDetection:I2,onDragStart:Ie,onDragEnd:Le,children:[(0,K.jsx)(U4,{items:ze,strategy:KBe,children:L===`position`?(0,K.jsx)(`div`,{className:`space-y-2 sm:space-y-3`,children:Re.map(t=>(0,K.jsx)(i3,{row:t,collapsed:t.kind===`batch`?z[t.batchId]??!0:!1,onToggleBatch:t.kind===`batch`?()=>Ve(t.batchId):void 0,onUngroup:t.kind===`batch`?()=>ie(t.batchId):void 0,setEditItem:h,setConfirmAction:b,startMutation:he,selectedItems:x,handleToggleSelect:Ce,timeFormat:oe,hasPermission:r,canModify:a,t:e,aggregateForRows:We},t.kind===`item`?`item-${t.item.id}`:`batch-${t.batchId}`))}):(0,K.jsx)(`div`,{className:`space-y-4`,children:He.map(t=>{let n=We(t.rows);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-t-lg`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 ${t.isUnassigned?`text-orange-400`:t.targetModel?`text-blue-400`:`text-bambu-green`}`}),(0,K.jsx)(`span`,{className:`font-semibold text-white text-sm`,children:t.label}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex flex-wrap gap-x-3`,children:[(0,K.jsx)(`span`,{children:e(`queue.itemCount`,{count:n.count})}),n.time>0&&(0,K.jsx)(`span`,{children:Cf(n.time)}),n.weight>0&&(0,K.jsx)(`span`,{children:t3(n.weight)})]})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark/40 border border-t-0 border-bambu-dark-tertiary rounded-b-lg p-2 space-y-2`,children:t.rows.map(t=>(0,K.jsx)(i3,{row:t,collapsed:t.kind===`batch`?z[t.batchId]??!0:!1,onToggleBatch:t.kind===`batch`?()=>Ve(t.batchId):void 0,onUngroup:t.kind===`batch`?()=>ie(t.batchId):void 0,setEditItem:h,setConfirmAction:b,startMutation:he,selectedItems:x,handleToggleSelect:Ce,timeFormat:oe,hasPermission:r,canModify:a,t:e,aggregateForRows:We},t.kind===`item`?`item-${t.item.id}`:`batch-${t.batchId}`))})]},t.key)})})}),(0,K.jsx)(HBe,{children:(()=>{if(V===null)return null;if(typeof V==`string`&&V.startsWith(`batch-`)){let t=Number(V.slice(6)),n=Ee.filter(e=>e.batch_id===t);if(n.length===0)return null;let r=n[0].batch_name||e(`queue.batch.defaultName`);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border-2 border-cyan-400 rounded-lg shadow-2xl`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-cyan-300`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e(`queue.dragGhost.batch`,{defaultValue:`{{name}} ({{count}} copies)`,name:r,count:n.length})})]})}return typeof V==`number`&&x.includes(V)&&x.length>1?(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-2 bg-bambu-dark-secondary border-2 border-cyan-400 rounded-lg shadow-2xl`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-cyan-300`}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e(`queue.dragGhost.multiCount`,{count:x.length})})]}):null})()})]})]})]}),m&&(0,K.jsx)(sW,{mode:`edit-queue-item`,archiveId:m.archive_id??void 0,libraryFileId:m.library_file_id??void 0,archiveName:m.archive_name||m.library_file_name||`File #${m.archive_id||m.library_file_id}`,queueItem:m,onClose:()=>h(null)}),g&&(0,K.jsx)(sW,{mode:`add-to-queue`,archiveId:g.archive_id??void 0,libraryFileId:g.library_file_id??void 0,archiveName:g.archive_name||g.library_file_name||`File #${g.archive_id||g.library_file_id}`,onClose:()=>_(null)}),pe&&(0,K.jsx)(Ad,{title:e(`queue.filamentShort.confirmTitle`),message:e(`queue.filamentShort.confirmIntro`)+` `+pe.deficit.map(t=>e(`queue.filamentShort.lineItem`,{slot:t.slot_id,required:Math.round(t.required_grams),remaining:t.remaining_grams==null?e(`queue.filamentShort.unknown`):Math.round(t.remaining_grams)})).join(` -`),confirmText:e(`queue.filamentShort.printAnyway`),variant:`warning`,onConfirm:()=>{he.mutate({id:pe.itemId,skipFilamentCheck:!0})},onCancel:()=>me(null)}),v&&(0,K.jsx)(Ad,{title:v.type===`cancel`?e(`queue.confirm.cancelTitle`):v.type===`stop`?e(`queue.confirm.stopTitle`):e(`queue.confirm.removeTitle`),message:v.type===`cancel`?e(`queue.confirm.cancelMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisPrint`)}):v.type===`stop`?e(`queue.confirm.stopMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisPrint`)}):e(`queue.confirm.removeMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisItem`)}),confirmText:v.type===`cancel`?e(`queue.confirm.cancelButton`):v.type===`stop`?e(`queue.confirm.stopButton`):e(`common.remove`),variant:`danger`,onConfirm:()=>{v.type===`cancel`?ue.mutate(v.item.id):v.type===`stop`?fe.mutate(v.item.id):de.mutate(v.item.id),b(null)},onCancel:()=>b(null)}),T&&(0,K.jsx)(Ad,{title:e(`queue.resumeAfterFailure.confirmTitle`),message:e(`queue.resumeAfterFailure.confirmMessage`,{printer:T.printerName,count:T.skippedCount}),confirmText:e(`queue.resumeAfterFailure.button`),variant:`warning`,onConfirm:()=>be.mutate(T.printerId),onCancel:()=>E(null)}),f&&(0,K.jsx)(Ad,{title:e(`queue.confirm.clearHistoryTitle`),message:e(`queue.confirm.clearHistoryMessage`,{count:Ne.length}),confirmText:e(`queue.clearHistory`),variant:`danger`,onConfirm:()=>{_e.mutate(),p(!1)},onCancel:()=>p(!1)}),C&&(0,K.jsx)(dVe,{selectedCount:x.length,printers:ce?.map(e=>({id:e.id,name:e.name,nozzle_count:e.nozzle_count}))||[],onSave:e=>{Object.keys(e).length>0&&ve.mutate({item_ids:x,...e})},onClose:()=>w(!1),isSaving:ve.isPending,canControlPrinter:r(`printers:control`),t:e}),te&&(0,K.jsx)(hVe,{itemCount:x.length,isSaving:xe.isPending,defaultName:(()=>{let t=Ee.find(e=>x.includes(e.id)),n=(t?.archive_name||t?.library_file_name||``).replace(/\.gcode\.3mf$/i,``).replace(/\.3mf$/i,``);return n?`${n}`:e(`queue.batch.defaultName`)})(),onSave:e=>xe.mutate({name:e,item_ids:x}),onClose:()=>ne(!1),t:e}),re!==null&&(0,K.jsx)(Ad,{title:e(`queue.batch.ungroupConfirmTitle`),message:e(`queue.batch.ungroupConfirmMessage`),confirmText:e(`queue.batch.ungroup`),variant:`warning`,onConfirm:()=>Se.mutate(re),onCancel:()=>ie(null)})]})}function hVe({itemCount:e,defaultName:t,isSaving:n,onSave:r,onClose:i,t:a}){let[o,s]=(0,y.useState)(t);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 w-full max-w-md`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white mb-2 flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300`}),a(`queue.batch.groupAsBatch`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:a(`queue.batch.groupAsBatchDescription`,{count:e})}),(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:a(`queue.batch.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:a(`queue.batch.namePlaceholder`),maxLength:120,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none mb-5`}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,disabled:n,children:a(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>{let e=o.trim();e&&r(e)},disabled:n||!o.trim(),children:a(n?`common.saving`:`queue.batch.create`)})]})]})})}function gVe({printDates:e,months:t=3}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(e=>{i(e[0]?.contentRect.width||0)});return t.observe(e),()=>t.disconnect()},[]);let{weeks:a,monthLabels:o,printCounts:s}=(0,y.useMemo)(()=>{let n={};e.forEach(e=>{let t=Df(e);t&&(n[t]=(n[t]||0)+1)});let r=new Date,i=new Date(r);i.setMonth(i.getMonth()-t),i.setDate(i.getDate()-i.getDay());let a=[],o=[],s=[],c=-1,l=new Date(i),u=0;for(;l<=r;)l.getDay()===0&&s.length>0&&(a.push(s),s=[],u++),l.getMonth()!==c&&(o.push({month:l.toLocaleDateString(`en-US`,{month:`short`}),weekIndex:u}),c=l.getMonth()),s.push(new Date(l)),l.setDate(l.getDate()+1);return s.length>0&&a.push(s),{weeks:a,monthLabels:o,printCounts:n}},[e,t]),c=Math.max(1,...Object.values(s)),l=e=>{if(e===0)return`bg-bambu-dark`;let t=e/c;return t<=.25?`bg-bambu-green/30`:t<=.5?`bg-bambu-green/50`:t<=.75?`bg-bambu-green/75`:`bg-bambu-green`},u=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],d=a.length,f=r-32-16,p=d>0?Math.floor((f-(d-1)*2)/d):12,m=Math.max(8,Math.min(20,p)),h=m<=10?10:12;return(0,K.jsx)(`div`,{ref:n,className:`w-full flex justify-center`,children:r>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex mb-1`,style:{marginLeft:36},children:o.map(({month:e,weekIndex:t},n)=>(0,K.jsx)(`div`,{className:`text-bambu-gray`,style:{fontSize:h,marginLeft:n===0?0:`${(t-(o[n-1]?.weekIndex||0))*(m+2)-24}px`},children:e},n))}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`flex flex-col`,style:{gap:2,marginRight:4,width:32},children:u.map((e,t)=>(0,K.jsx)(`div`,{className:`text-bambu-gray flex items-center`,style:{width:32,height:m,fontSize:h,visibility:t%2==1?`visible`:`hidden`},children:e},e))}),a.map((e,t)=>(0,K.jsx)(`div`,{className:`flex flex-col`,style:{gap:2},children:[0,1,2,3,4,5,6].map(t=>{let n=e.find(e=>e.getDay()===t);if(!n)return(0,K.jsx)(`div`,{style:{width:m,height:m}},t);let r=Df(n),i=s[r]||0,a=r===Df(new Date);return(0,K.jsx)(`div`,{className:`rounded-sm ${l(i)} ${a?`ring-1 ring-white`:``}`,style:{width:m,height:m},title:`${n.toLocaleDateString()}: ${i} print${i===1?``:`s`}`},t)})},t))]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-bambu-gray`,style:{fontSize:h},children:[(0,K.jsx)(`span`,{children:`Less`}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-dark`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/30`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/50`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/75`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green`,style:{width:m,height:m}})]}),(0,K.jsx)(`span`,{children:`More`})]})]})})}var a3=[`weight`,`prints`,`time`];function o3({value:e,onChange:t,exclude:n}){let{t:r}=W(),i={weight:r(`stats.filamentByWeight`),prints:r(`stats.filamentByPrints`),time:r(`stats.filamentByTime`)};return(0,K.jsx)(`div`,{className:`flex gap-0.5 bg-bambu-dark rounded-lg p-0.5`,children:(n?a3.filter(e=>!n.includes(e)):a3).map(n=>(0,K.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-0.5 text-xs rounded-md transition-colors ${e===n?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:i[n]},n))})}function s3(e){if(e>=1e6){let t=e/1e6;return`${t%1==0?t.toFixed(0):t.toFixed(1)}t`}if(e>=1e3){let t=e/1e3;return`${t%1==0?t.toFixed(0):t.toFixed(1)}kg`}return`${Math.round(e)}g`}var c3=[`#00ae42`,`#3b82f6`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#ec4899`,`#14b8a6`,`#f97316`],_Ve=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],l3=[`12am`,`1am`,`2am`,`3am`,`4am`,`5am`,`6am`,`7am`,`8am`,`9am`,`10am`,`11am`,`12pm`,`1pm`,`2pm`,`3pm`,`4pm`,`5pm`,`6pm`,`7pm`,`8pm`,`9pm`,`10pm`,`11pm`];function vVe({archives:e,currency:t=`$`,dateFrom:n,dateTo:r}){let{t:i}=W(),[a,o]=(0,y.useState)(`weight`),[s,c]=(0,y.useState)(`weight`),l=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`,i=t.get(r)||{date:r,filament:0,cost:0,prints:0};i.filament+=e.filament_used_grams||0,i.cost+=e.cost||0,i.prints+=e.quantity||1,t.set(r,i)}),Array.from(t.values()).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>({...e,dateLabel:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}))},[e]),u=(0,y.useMemo)(()=>{if(n&&r)return Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1;if(n)return Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1;if(e.length<2)return 0;let t=e.map(e=>new Date(e.completed_at||e.created_at).getTime());return(Math.max(...t)-Math.min(...t))/864e5},[e,n,r]),d=(0,y.useMemo)(()=>{if(u>7)return[];let t=new Map,n=u>1;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=n.getHours(),i=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}T${String(r).padStart(2,`0`)}`,a=t.get(i)||{date:i,filament:0,cost:0,prints:0};a.filament+=e.filament_used_grams||0,a.cost+=e.cost||0,a.prints+=e.quantity||1,t.set(i,a)}),Array.from(t.values()).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{let[t,r]=e.date.split(`T`),i=new Date(t),a=parseInt(r,10),o=n?`${_Ve[i.getDay()]} ${l3[a]}`:l3[a];return{...e,dateLabel:o}})},[e,u]),f=(0,y.useMemo)(()=>{if(l.length<=60)return l;let e=new Map;return l.forEach(t=>{let n=new Date(t.date),r=new Date(n);r.setDate(n.getDate()-n.getDay());let i=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,a=e.get(i)||{week:i,filament:0,cost:0,prints:0};a.filament+=t.filament,a.cost+=t.cost,a.prints+=t.prints,e.set(i,a)}),Array.from(e.values()).sort((e,t)=>e.week.localeCompare(t.week)).map(e=>({date:e.week,dateLabel:`Week of ${new Date(e.week).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`,...e}))},[l]),p=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=(e.filament_type||`Unknown`).split(`, `);n.forEach(r=>{let i=(e.filament_used_grams||0)/n.length;t.set(r,(t.get(r)||0)+i)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:Math.round(t)})).sort((e,t)=>t.value-e.value)},[e]),m=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{(e.filament_type||`Unknown`).split(`, `).forEach(e=>{t.set(e,(t.get(e)||0)+1)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value-e.value)},[e]),h=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=(e.filament_type||`Unknown`).split(`, `),r=(e.actual_time_seconds||e.print_time_seconds||0)/n.length;n.forEach(e=>{t.set(e,(t.get(e)||0)+r)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:Math.round(t/3600*10)/10})).sort((e,t)=>t.value-e.value)},[e]),g=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{e.status!==`completed`&&e.status!==`failed`||(e.filament_type||`Unknown`).split(`, `).forEach(n=>{let r=t.get(n)||{completed:0,failed:0};e.status===`completed`?r.completed++:r.failed++,t.set(n,r)})}),Array.from(t.entries()).filter(([,e])=>e.completed+e.failed>=2).map(([e,t])=>{let n=t.completed+t.failed;return{name:e,rate:Math.round(t.completed/n*100),total:n}}).sort((e,t)=>t.rate-e.rate)},[e]),_=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{if(!e.filament_color)return;let n=e.filament_color.split(`,`).map(e=>e.trim()),r=(e.filament_used_grams||0)/n.length;n.forEach(e=>{let n=t.get(e)||{count:0,weight:0};n.count++,n.weight+=r,t.set(e,n)})}),Array.from(t.entries()).map(([e,t])=>({hex:e,value:s===`prints`?t.count:Math.round(t.weight)})).sort((e,t)=>t.value-e.value)},[e,s]),v=a===`weight`?p:a===`prints`?m:h,b=u<=7&&d.length>0?d:f,x=e.reduce((e,t)=>e+(t.filament_used_grams||0),0),S=e.reduce((e,t)=>e+(t.cost||0),0),C=e.reduce((e,t)=>e+(t.quantity||1),0),w=new Set(e.map(e=>e.printer_id).filter(Boolean)).size;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-[640px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.periodFilament`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:s3(x)})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[w,` `,i(`nav.printers`).toLowerCase()]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.periodCost`)}),(0,K.jsxs)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:[t,S.toFixed(2)]})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[C,` `,i(`common.prints`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.avgPerPrint`)}),(0,K.jsxs)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:[C>0?(x/C).toFixed(0):0,`g`]})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[t,C>0?(S/C).toFixed(2):`0.00`,` avg`]})]})]}),b.length>0?(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-4`,children:i(`stats.usageOverTime`)}),(0,K.jsx)(pA,{width:`100%`,height:250,children:(0,K.jsxs)(oU,{data:b,children:[(0,K.jsx)(`defs`,{children:(0,K.jsxs)(`linearGradient`,{id:`colorFilament`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,K.jsx)(`stop`,{offset:`5%`,stopColor:`#00ae42`,stopOpacity:.3}),(0,K.jsx)(`stop`,{offset:`95%`,stopColor:`#00ae42`,stopOpacity:0})]})}),(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(gH,{dataKey:`dateLabel`,stroke:`#9ca3af`,tick:{fontSize:12},interval:`preserveStartEnd`}),(0,K.jsx)(xH,{stroke:`#9ca3af`,tick:{fontSize:12},tickFormatter:e=>`${e}g`}),(0,K.jsx)(cz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},labelStyle:{color:`#fff`},formatter:e=>[`${Number(e??0).toFixed(0)}g`,`Filament`]}),(0,K.jsx)(JV,{type:`monotone`,dataKey:`filament`,stroke:`#00ae42`,strokeWidth:2,fillOpacity:1,fill:`url(#colorFilament)`})]})})]}):(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray`,children:i(`stats.noPrintDataInRange`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:i(`stats.byMaterial`)}),(0,K.jsx)(o3,{value:a,onChange:o})]}),v.length>0?(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(pA,{width:160,height:160,children:(0,K.jsxs)(aU,{children:[(0,K.jsx)(VB,{data:v,cx:`50%`,cy:`50%`,innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:`value`,children:v.map((e,t)=>(0,K.jsx)(lz,{fill:c3[t%c3.length]},`cell-${t}`))}),(0,K.jsx)(cz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},formatter:e=>[a===`weight`?s3(Number(e??0)):a===`time`?`${Number(e??0)}h`:`${e??0}`,a===`weight`?`Usage`:a===`time`?`Time`:`Prints`]})]})}),(0,K.jsx)(`div`,{className:`flex-1 space-y-2 overflow-hidden`,children:v.map((e,t)=>{let n=v.reduce((e,t)=>e+t.value,0),r=n>0?(e.value/n*100).toFixed(0):0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-sm flex-shrink-0`,style:{backgroundColor:c3[t%c3.length]}}),(0,K.jsx)(`span`,{className:`text-white truncate flex-1`,children:e.name}),(0,K.jsxs)(`span`,{className:`text-bambu-gray flex-shrink-0`,children:[a===`weight`?s3(e.value):a===`time`?`${e.value}h`:e.value,` · `,r,`%`]})]},e.name)})})]}):(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noFilamentData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-4`,children:i(`stats.filamentSuccess`)}),g.length>0?(0,K.jsx)(`div`,{className:`space-y-1.5`,children:g.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white truncate w-20 flex-shrink-0`,children:e.name}),(0,K.jsx)(`div`,{className:`flex-1 h-1.5 bg-bambu-dark-secondary rounded-full`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all ${e.rate>=90?`bg-status-ok`:e.rate>=70?`bg-status-warning`:`bg-status-error`}`,style:{width:`${e.rate}%`}})}),(0,K.jsxs)(`span`,{className:`font-medium flex-shrink-0 tabular-nums ${e.rate>=90?`text-status-ok`:e.rate>=70?`text-status-warning`:`text-status-error`}`,children:[e.rate,`%`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray flex-shrink-0 text-xs`,children:[`(`,e.total,`)`]})]},e.name))}):(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:i(`stats.colorDistribution`)}),(0,K.jsx)(o3,{value:s,onChange:c,exclude:[`time`]})]}),_.length>0?(()=>{let e=_.reduce((e,t)=>e+t.value,0);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`relative mx-auto`,style:{width:160,height:160},children:[(0,K.jsx)(pA,{width:`100%`,height:`100%`,children:(0,K.jsxs)(aU,{children:[(0,K.jsx)(VB,{data:_,cx:`50%`,cy:`50%`,innerRadius:45,outerRadius:70,paddingAngle:2,dataKey:`value`,children:_.map((e,t)=>(0,K.jsx)(lz,{fill:e.hex,stroke:`#1a1a1a`,strokeWidth:1},`color-${t}`))}),(0,K.jsx)(cz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},formatter:e=>[s===`weight`?s3(Number(e??0)):`${e??0}`,i(s===`weight`?`stats.filamentByWeight`:`stats.filamentByPrints`)]})]})}),(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`span`,{className:`text-lg font-bold text-white`,children:s===`weight`?s3(e):e}),(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray`,children:[_.length,` `,_.length===1?`color`:`colors`]})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 mt-2`,children:_.slice(0,8).map(t=>{let n=e>0?(t.value/e*100).toFixed(0):0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs min-w-0`,children:[(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 border border-black/20`,style:{backgroundColor:t.hex}}),(0,K.jsxs)(`span`,{className:`text-bambu-gray truncate`,children:[n,`%`]})]},t.hex)})}),_.length>8&&(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray mt-1 text-center`,children:[`+`,_.length-8,` more`]})]})})():(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noColorData`)})]})]})]})}function yVe({id:e,title:t,component:n,isHidden:r,size:i,columnSpan:a,onToggleVisibility:o,onToggleSize:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=G4({id:e}),m={transform:C2.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:(0,K.jsxs)(`div`,{ref:u,style:{...m,gridColumn:`span ${a}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?`ring-2 ring-bambu-green shadow-lg`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{...c,...l,className:`cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Drag to reorder`,children:(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray`})}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:s,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Size: ${i===1?`1/4`:i===2?`1/2`:`Full`} - Click to cycle`,children:i===4?(0,K.jsx)(rl,{className:`w-4 h-4 text-bambu-gray hover:text-white`}):(0,K.jsx)($c,{className:`w-4 h-4 text-bambu-gray hover:text-white`})}),(0,K.jsx)(`button`,{onClick:o,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Hide widget`,children:(0,K.jsx)(Ys,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]})]}),(0,K.jsx)(`div`,{className:`p-4`,children:typeof n==`function`?n(i):n})]})}function bVe({widgets:e,storageKey:t,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:a,renderControls:o}){let s=()=>{let t={};return e.forEach(e=>{t[e.id]=e.defaultSize||4}),t},[c,l]=(0,y.useState)(()=>{let n=localStorage.getItem(t);if(n)try{let e=JSON.parse(n);if(!e.sizes)e.sizes=s();else{let t=s();for(let n in t)n in e.sizes||(e.sizes[n]=t[n])}return e}catch{}return{order:e.map(e=>e.id),hidden:e.filter(e=>e.defaultVisible===!1).map(e=>e.id),sizes:s()}}),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!r)return;let e=window.matchMedia(`(max-width: ${r}px)`),t=e=>{p(e.matches)};t(e);let n=e=>t(e);return e.addEventListener?e.addEventListener(`change`,n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener(`change`,n):e.removeListener(n)}},[r]);let m=r&&f?1:n;(0,y.useEffect)(()=>{let e=()=>d(e=>!e);return window.addEventListener(`toggle-hidden-panel`,e),()=>window.removeEventListener(`toggle-hidden-panel`,e)},[]),(0,y.useEffect)(()=>{localStorage.setItem(t,JSON.stringify(c))},[c,t]),(0,y.useEffect)(()=>{let t=e.map(e=>e.id).filter(e=>!c.order.includes(e));t.length>0&&l(e=>({...e,order:[...e.order,...t]}))},[e,c.order]);let h=k2(O2(l4,{activationConstraint:{distance:8}}),O2(a4,{coordinateGetter:q4})),g=e=>{let{active:t,over:n}=e;n&&t.id!==n.id&&l(e=>{let r=e.order.indexOf(t.id),i=e.order.indexOf(n.id);return{...e,order:L4(e.order,r,i)}})},_=e=>{l(t=>({...t,hidden:t.hidden.includes(e)?t.hidden.filter(t=>t!==e):[...t.hidden,e]}))},v=e=>{l(t=>{let n=t.sizes[e]||4,r=n===1?2:n===2?4:1;return{...t,sizes:{...t.sizes,[e]:r}}})},b=()=>{l({order:e.map(e=>e.id),hidden:e.filter(e=>e.defaultVisible===!1).map(e=>e.id),sizes:s()}),a?.()},x=c.order.map(t=>e.find(e=>e.id===t)).filter(Boolean),S=x.filter(e=>!c.hidden.includes(e.id)),C=x.filter(e=>c.hidden.includes(e.id)),w=o?.({hiddenCount:C.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[w,!i&&!o&&(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:b,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),`Reset Layout`]}),C.length>0&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>d(!u),children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),C.length,` Hidden`]})]}),u&&C.length>0&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:`Hidden widgets (click to show):`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(e=>(0,K.jsxs)(`button`,{onClick:()=>_(e.id),className:`px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-3 h-3`}),e.title]},e.id))})]}),(0,K.jsx)(N4,{sensors:h,collisionDetection:I2,onDragEnd:g,children:(0,K.jsx)(U4,{items:S.map(e=>e.id),strategy:z4,children:(0,K.jsx)(`div`,{className:`grid gap-6`,style:{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`},children:S.map(e=>{let t=c.sizes[e.id]||2,n=Math.min(t,m);return(0,K.jsx)(yVe,{id:e.id,title:e.title,component:e.component,isHidden:c.hidden.includes(e.id),size:t,columnSpan:n,onToggleVisibility:()=>_(e.id),onToggleSize:()=>v(e.id)},e.id)})})})}),S.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:`All widgets are hidden.`}),(0,K.jsx)($,{className:`mt-4`,onClick:b,children:`Reset Layout`})]})]})}function xVe(e){let t=new Date,n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=e=>e.toISOString().split(`T`)[0],o=a(t);switch(e){case`today`:return{dateFrom:o,dateTo:o};case`this-week`:{let e=t.getUTCDay();return{dateFrom:a(new Date(Date.UTC(n,r,i-(e===0?6:e-1)))),dateTo:o}}case`this-month`:return{dateFrom:a(new Date(Date.UTC(n,r,1))),dateTo:o};case`last-7`:return{dateFrom:a(new Date(Date.UTC(n,r,i-6))),dateTo:o};case`last-30`:return{dateFrom:a(new Date(Date.UTC(n,r,i-29))),dateTo:o};case`last-90`:return{dateFrom:a(new Date(Date.UTC(n,r,i-89))),dateTo:o};case`this-year`:return{dateFrom:a(new Date(Date.UTC(n,0,1))),dateTo:o};case`all-time`:return{dateFrom:void 0,dateTo:void 0};case`custom`:return{}}}var SVe=[`today`,`this-week`,`this-month`,`last-7`,`last-30`,`last-90`,`this-year`,`all-time`],CVe=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],u3=[`12am`,`1am`,`2am`,`3am`,`4am`,`5am`,`6am`,`7am`,`8am`,`9am`,`10am`,`11am`,`12pm`,`1pm`,`2pm`,`3pm`,`4pm`,`5pm`,`6pm`,`7pm`,`8pm`,`9pm`,`10pm`,`11pm`],d3=[{key:`<30m`,max:1800},{key:`30m-1h`,max:3600},{key:`1-2h`,max:7200},{key:`2-4h`,max:14400},{key:`4-8h`,max:28800},{key:`8-12h`,max:43200},{key:`12-24h`,max:86400},{key:`24h+`,max:1/0}],f3={backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`};function wVe({stats:e,currency:t}){let{t:n}=W(),r=e?.energy_data_warming_up===!0,i=r?n(`stats.energyWarmingUpTooltip`):void 0;return(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-4`,children:[{icon:pl,color:`text-bambu-green`,label:n(`stats.totalPrints`),value:`${e?.total_prints||0}`},{icon:Ss,color:`text-blue-400`,label:n(`stats.printTime`),value:`${e?.total_print_time_hours?.toFixed(1)??`0`}h`},{icon:pl,color:`text-orange-400`,label:n(`stats.filamentUsed`),value:s3(e?.total_filament_grams||0)},{icon:Rs,color:`text-green-400`,label:n(`stats.filamentCost`),value:`${t} ${e?.total_cost?.toFixed(2)??`0.00`}`},{icon:Bu,color:`text-yellow-400`,label:n(`stats.energyUsed`),value:`${e?.total_energy_kwh?.toFixed(3)??`0.000`} kWh`,warning:r,tooltip:i},{icon:Rs,color:`text-yellow-500`,label:n(`stats.energyCost`),value:`${t} ${e?.total_energy_cost?.toFixed(2)??`0.00`}`,warning:r,tooltip:i}].map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,title:e.tooltip,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark ${e.color}`,children:(0,K.jsx)(e.icon,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray flex items-center gap-1`,children:[e.label,e.warning&&(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`,"aria-label":e.tooltip})]}),(0,K.jsx)(`p`,{className:`text-xl font-bold text-white`,children:e.value})]})]},e.label))})}function TVe({stats:e,printerMap:t,size:n=1}){let{t:r}=W(),i=(e?.successful_prints||0)+(e?.failed_prints||0),a=i?Math.round((e?.successful_prints||0)/i*100):0,o=n===1?112:n===2?128:144,s=o/2-8,c=s*2*Math.PI;return(0,K.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,style:{width:o,height:o},children:[(0,K.jsxs)(`svg`,{className:`w-full h-full -rotate-90`,children:[(0,K.jsx)(`circle`,{cx:o/2,cy:o/2,r:s,fill:`none`,stroke:`#3d3d3d`,strokeWidth:`10`}),(0,K.jsx)(`circle`,{cx:o/2,cy:o/2,r:s,fill:`none`,stroke:`#00ae42`,strokeWidth:`10`,strokeLinecap:`round`,strokeDasharray:`${a/100*c} ${c}`})]}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsxs)(`span`,{className:`font-bold text-white ${n>=2?`text-2xl`:`text-xl`}`,children:[a,`%`]})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-status-ok flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.successful`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.successful_prints||0})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 text-status-error flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.failed`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.failed_prints||0})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Lo,{className:`w-4 h-4 text-status-warning flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.cancelled`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.cancelled_prints||0})]})]}),n>=2&&e?.prints_by_printer&&Object.keys(e.prints_by_printer).length>0&&(0,K.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-medium mb-2`,children:r(`stats.printsByPrinter`)}),(0,K.jsx)(`div`,{className:`grid gap-x-6 gap-y-1 ${n===4?`grid-cols-3`:`grid-cols-2`}`,style:{width:`fit-content`},children:Object.entries(e.prints_by_printer).map(([e,n])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray truncate max-w-[120px]`,children:t.get(e)||`${r(`common.printer`)} ${e}`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n})]},e))})]})]})]})}function EVe({stats:e,printerMap:t,size:n=1}){let{t:r}=W(),i=e?.average_time_accuracy;if(i==null)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noTimeAccuracyData`)})});let a=(Math.min(150,Math.max(50,i))-50)/100*100,o=(e=>e>=95&&e<=105?`#00ae42`:e>105?`#3b82f6`:`#f97316`)(i),s=i-100,c=n===1?112:n===2?128:144,l=c/2-8,u=l*2*Math.PI,d=n===1?3:n===2?6:999,f=e?.time_accuracy_by_printer?Object.entries(e.time_accuracy_by_printer).slice(0,d):[];return(0,K.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,style:{width:c,height:c},children:[(0,K.jsxs)(`svg`,{className:`w-full h-full -rotate-90`,children:[(0,K.jsx)(`circle`,{cx:c/2,cy:c/2,r:l,fill:`none`,stroke:`#3d3d3d`,strokeWidth:`10`}),(0,K.jsx)(`circle`,{cx:c/2,cy:c/2,r:l,fill:`none`,stroke:o,strokeWidth:`10`,strokeLinecap:`round`,strokeDasharray:`${a/100*u} ${u}`})]}),(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,K.jsxs)(`span`,{className:`font-bold text-white ${n>=2?`text-2xl`:`text-xl`}`,children:[i.toFixed(0),`%`]}),(0,K.jsxs)(`span`,{className:`text-xs ${s>=0?`text-blue-400`:`text-orange-400`}`,children:[s>=0?`+`:``,s.toFixed(0),`%`]})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:[(0,K.jsx)(pu,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{children:r(`stats.perfectEstimate`)})]}),f.length>0&&(0,K.jsx)(`div`,{className:`mt-2 ${n===4?`grid grid-cols-3 gap-x-6 gap-y-1`:n===2?`grid grid-cols-2 gap-x-6 gap-y-1`:`space-y-1`}`,style:{width:`fit-content`},children:f.map(([e,n])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray truncate max-w-[100px]`,children:t.get(e)||`${r(`common.printer`)} ${e}`}),(0,K.jsxs)(`span`,{className:`font-medium ${n>=95&&n<=105?`text-status-ok`:n>105?`text-blue-400`:`text-status-warning`}`,children:[n.toFixed(0),`%`]})]},e))})]})]})}function DVe({printDates:e,dateFrom:t,dateTo:n}){let{days:r,hourlyCounts:i,maxCount:a}=(0,y.useMemo)(()=>{let r=new Date(t+`T00:00:00`),i=new Date(n+`T00:00:00`),a=[],o=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,s=new Date(r);for(;s<=i;)a.push({key:o(s),label:s.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),s.setDate(s.getDate()+1);let c={},l=0;return e.forEach(e=>{let t=vf(e);if(!t)return;let n=`${`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}-${t.getHours()}`;c[n]=(c[n]||0)+1,c[n]>l&&(l=c[n])}),{days:a,hourlyCounts:c,maxCount:Math.max(1,l)}},[e,t,n]),o=e=>{if(e===0)return`bg-bambu-dark`;let t=e/a;return t<=.25?`bg-bambu-green/30`:t<=.5?`bg-bambu-green/50`:t<=.75?`bg-bambu-green/75`:`bg-bambu-green`};return(0,K.jsxs)(`div`,{className:`w-full overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`inline-flex flex-col`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`flex`,style:{gap:2,marginLeft:84},children:u3.map((e,t)=>(0,K.jsx)(`div`,{className:`text-bambu-gray text-[10px] text-center`,style:{width:20,visibility:t%2==0?`visible`:`hidden`},children:e},t))}),r.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`text-bambu-gray text-[10px] flex-shrink-0 truncate`,style:{width:80},children:e.label}),Array.from({length:24},(t,n)=>{let r=i[`${e.key}-${n}`]||0;return(0,K.jsx)(`div`,{className:`rounded-sm ${o(r)}`,style:{width:20,height:20},title:`${e.label} ${u3[n]}: ${r} print${r===1?``:`s`}`},n)})]},e.key))]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-bambu-gray text-xs`,children:[(0,K.jsx)(`span`,{children:`Less`}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-dark`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/30`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/50`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/75`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green`,style:{width:20,height:20}})]}),(0,K.jsx)(`span`,{children:`More`})]})]})}function OVe({printDates:e,size:t=2,dateFrom:n,dateTo:r}){let i=(0,y.useMemo)(()=>n&&r?Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1:n?Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1:1/0,[n,r]);return i<=7&&n&&r?(0,K.jsx)(DVe,{printDates:e,dateFrom:n,dateTo:r}):(0,K.jsx)(gVe,{printDates:e,months:i===1/0?t===1?3:t===2?6:12:Math.max(1,Math.ceil(i/30))})}function kVe({stats:e,archives:t,printerMap:n}){let{t:r}=W(),[i,a]=(0,y.useState)(`weight`),[o,s]=(0,y.useState)(`weight`),c=(0,y.useMemo)(()=>{let a=new Map;return e?.prints_by_printer&&Object.entries(e.prints_by_printer).forEach(([e,t])=>{let n=a.get(e)||{prints:0,weight:0,time:0};n.prints=t,a.set(e,n)}),t.forEach(t=>{if(!t.printer_id)return;let n=String(t.printer_id),r=a.get(n)||{prints:0,weight:0,time:0};r.weight+=t.filament_used_grams||0,r.time+=t.actual_time_seconds||t.print_time_seconds||0,e?.prints_by_printer||r.prints++,a.set(n,r)}),Array.from(a.entries()).map(([e,t])=>({name:n.get(e)||`${r(`common.printer`)} ${e}`,value:i===`prints`?t.prints:i===`weight`?Math.round(t.weight):Math.round(t.time/3600*10)/10})).sort((e,t)=>t.value-e.value)},[e,t,n,i,r]),l=(0,y.useMemo)(()=>{let e=Array.from({length:24},(e,t)=>({hour:t,label:u3[t],total:0,failures:0}));return t.forEach(t=>{if(!t.started_at)return;let n=vf(t.started_at);if(!n)return;let r=n.getHours();e[r].total++,t.status===`failed`&&e[r].failures++}),e},[t]),u=(0,y.useMemo)(()=>{let e=d3.map(e=>({name:e.key,count:0}));return t.forEach(t=>{let n=t.actual_time_seconds||t.print_time_seconds;if(!(!n||n<=0)){for(let t=0;t{let e=[0,0,0,0,0,0,0],n=new Set;t.forEach(t=>{let r=vf(t.created_at)||new Date(t.created_at),i=r.getDay()-1;i<0&&(i=6),o===`prints`?e[i]++:o===`weight`?e[i]+=t.filament_used_grams||0:e[i]+=(t.actual_time_seconds||t.print_time_seconds||0)/3600;let a=new Date(r);a.setDate(r.getDate()-(r.getDay()+6)%7),n.add(`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,`0`)}-${String(a.getDate()).padStart(2,`0`)}`)});let r=Math.max(n.size,1);return CVe.map((t,n)=>({name:t,avg:Math.round(e[n]/r*10)/10}))},[t,o]),f=e=>({unit:e===`weight`?`g`:e===`time`?`h`:``,color:e===`weight`?`#00ae42`:e===`time`?`#3b82f6`:`#f59e0b`}),p=f(i),m=r(i===`weight`?`stats.filamentByWeight`:i===`time`?`stats.hours`:`common.prints`),h=f(o),g=r(o===`weight`?`stats.avgWeight`:o===`time`?`stats.avgTime`:`stats.avgPrints`);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:r(`stats.printsByPrinter`)}),(0,K.jsx)(o3,{value:i,onChange:a})]}),c.length>0?(0,K.jsx)(pA,{width:`100%`,height:Math.max(140,c.length*40),children:(0,K.jsxs)(eU,{data:c,layout:`vertical`,margin:{left:10},children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(gH,{type:`number`,stroke:`#9ca3af`,tick:{fontSize:11},unit:p.unit}),(0,K.jsx)(xH,{type:`category`,dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11},width:100}),(0,K.jsx)(cz,{contentStyle:f3,formatter:e=>[i===`weight`?s3(Number(e??0)):`${e??0}${p.unit}`,m]}),(0,K.jsx)(cH,{dataKey:`value`,fill:p.color,radius:[0,4,4,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noPrinterData`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:r(`stats.printDuration`)}),t.length>0?(0,K.jsx)(pA,{width:`100%`,height:160,children:(0,K.jsxs)(eU,{data:u,children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(gH,{dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11}}),(0,K.jsx)(xH,{stroke:`#9ca3af`,tick:{fontSize:11},allowDecimals:!1}),(0,K.jsx)(cz,{contentStyle:f3}),(0,K.jsx)(cH,{dataKey:`count`,name:r(`common.prints`),fill:`#00ae42`,radius:[4,4,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:r(`stats.printHabits`)}),(0,K.jsx)(o3,{value:o,onChange:s})]}),t.length>0?(0,K.jsx)(pA,{width:`100%`,height:160,children:(0,K.jsxs)(eU,{data:d,children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(gH,{dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11}}),(0,K.jsx)(xH,{stroke:`#9ca3af`,tick:{fontSize:11},unit:h.unit}),(0,K.jsx)(cz,{contentStyle:f3,formatter:e=>[`${e??0}${h.unit}`,g]}),(0,K.jsx)(cH,{dataKey:`avg`,fill:h.color,radius:[4,4,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:r(`stats.printTimeOfDay`)}),t.length>0?(0,K.jsx)(pA,{width:`100%`,height:160,children:(0,K.jsxs)(eU,{data:l,children:[(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(gH,{dataKey:`label`,stroke:`#9ca3af`,tick:{fontSize:10},interval:5}),(0,K.jsx)(xH,{stroke:`#9ca3af`,tick:{fontSize:11},allowDecimals:!1}),(0,K.jsx)(cz,{contentStyle:f3}),(0,K.jsx)(cH,{dataKey:`total`,name:r(`stats.totalPrints`),fill:`#00ae42`,radius:[2,2,0,0]}),(0,K.jsx)(cH,{dataKey:`failures`,name:r(`stats.failed`),fill:`#ef4444`,radius:[2,2,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]})]})]})}function AVe({archives:e,currency:t,dateFrom:n,dateTo:r}){let{t:i}=W();return!e||e.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:i(`stats.noPrintData`)}):(0,K.jsx)(vVe,{archives:e,currency:t,dateFrom:n,dateTo:r})}function jVe({size:e=1,dateFrom:t,dateTo:n,createdById:r}){let{t:i}=W(),a=!!(t||n),{data:o,isLoading:s}=q({queryKey:[`failureAnalysis`,t,n,r??`all`],queryFn:()=>Q.getFailureAnalysis({...a?{dateFrom:t,dateTo:n}:{days:30},createdById:r})});if(s)return(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})});if(!o||o.total_prints===0)return(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:i(a?`stats.noPrintDataInRange`:`stats.noPrintDataLast30Days`)});let c=e===1?5:e===2?8:999,l=Object.entries(o.failures_by_reason).sort(([,e],[,t])=>t-e),u=l.slice(0,c),d=l.length>c;return(0,K.jsxs)(`div`,{className:`${e>=2?`flex gap-8`:`space-y-4`}`,children:[(0,K.jsxs)(`div`,{className:e>=2?`flex-shrink-0`:``,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 ${o.failure_rate>20?`text-status-error`:o.failure_rate>10?`text-status-warning`:`text-status-ok`}`}),(0,K.jsxs)(`span`,{className:`font-bold text-white ${e>=2?`text-3xl`:`text-2xl`}`,children:[o.failure_rate.toFixed(1),`%`]})]})}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray mt-1`,children:i(`stats.failedPrintsCount`,{failed:o.failed_prints,total:o.total_prints})}),o.trend&&o.trend.length>=2&&(0,K.jsx)(`div`,{className:`${e>=2?`mt-4`:`mt-2 pt-2 border-t border-bambu-dark-tertiary`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 ${o.trend[o.trend.length-1].failure_rate0&&(0,K.jsxs)(`div`,{className:`flex-1 ${e>=2?`border-l border-bambu-dark-tertiary pl-8`:`pt-2`}`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-medium mb-2`,children:i(e>=2?`stats.failureReasons`:`stats.topFailureReasons`)}),(0,K.jsx)(`div`,{className:`${e===4?`grid grid-cols-2 gap-x-6 gap-y-1`:`space-y-1`}`,children:u.map(([t,n])=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white truncate ${e===4?`max-w-[200px]`:`max-w-[160px]`}`,children:t?i(`editArchive.failureReasons.${t}`,{defaultValue:t}):i(`common.unknown`)}),(0,K.jsx)(`span`,{className:`text-bambu-gray ml-2`,children:n})]},t))}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`common.more`,{count:l.length-c})})]})]})}function MVe({archives:e,currency:t}){let{t:n}=W(),r=(0,y.useMemo)(()=>{let r=[];if(e.length===0)return r;let i=t=>{let n=null,r=0;return e.forEach(e=>{let i=t(e);i&&i>r&&(r=i,n=e)}),{archive:n,value:r}},a=i(e=>e.status===`completed`?e.actual_time_seconds:null);a.archive&&r.push({icon:Ss,iconColor:`text-blue-400`,label:n(`stats.longestPrint`),value:Cf(a.value),detail:a.archive.print_name||null});let o=i(e=>e.filament_used_grams);o.archive&&r.push({icon:pl,iconColor:`text-orange-400`,label:n(`stats.heaviestPrint`),value:s3(o.value),detail:o.archive.print_name||null});let s=i(e=>e.cost);s.archive&&r.push({icon:Rs,iconColor:`text-green-400`,label:n(`stats.mostExpensivePrint`),value:`${t}${s.value.toFixed(2)}`,detail:s.archive.print_name||null});let c=new Map;e.forEach(e=>{let t=vf(e.created_at)||new Date(e.created_at),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;c.set(n,(c.get(n)||0)+1)});let l=``,u=0;c.forEach((e,t)=>{e>u&&(u=e,l=t)}),u>1&&r.push({icon:Zo,iconColor:`text-purple-400`,label:n(`stats.busiestDay`),value:`${u} ${n(`common.prints`)}`,detail:(()=>{let[e,t,n]=l.split(`-`).map(Number);return new Date(e,t-1,n).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})})()});let d=[...e].filter(e=>e.status===`completed`||e.status===`failed`).sort((e,t)=>new Date(t.completed_at||t.created_at).getTime()-new Date(e.completed_at||e.created_at).getTime()),f=0;for(let e of d)if(e.status===`completed`)f++;else break;return f>0&&r.push({icon:Bu,iconColor:`text-yellow-400`,label:n(`stats.successStreak`),value:`${f}`,detail:f===1?n(`stats.streakPrint`):n(`stats.streakPrints`,{count:f})}),r},[e,t,n]);return r.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:n(`stats.noArchiveData`)}):(0,K.jsx)(`div`,{className:`space-y-3`,children:r.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-1.5 rounded-lg bg-bambu-dark ${e.iconColor}`,children:(0,K.jsx)(e.icon,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.label}),(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-bold text-white`,children:e.value}),e.detail&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.detail})]})]})]},t))})}function NVe(){let{t:e}=W(),{showToast:t}=Td(),{hasPermission:n,authEnabled:r}=dd(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(0),[u,d]=(0,y.useState)(0),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),v=r&&n(`stats:filter_by_user`),[b,x]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`bambusy-stats-timeframe`);if(e){let t=JSON.parse(e);if(t.preset)return t}}catch{}return{preset:`all-time`,dateFrom:void 0,dateTo:void 0}}),[S,C]=(0,y.useState)(!1);(0,y.useEffect)(()=>{localStorage.setItem(`bambusy-stats-timeframe`,JSON.stringify(b))},[b]);let w=(0,y.useMemo)(()=>b.preset===`custom`?{dateFrom:b.dateFrom,dateTo:b.dateTo}:xVe(b.preset),[b]);(0,y.useEffect)(()=>{let e=()=>{try{let e=localStorage.getItem(`bambusy-dashboard-layout-v2`);e&&d(JSON.parse(e).hidden?.length||0)}catch{d(0)}};e(),window.addEventListener(`storage`,e);let t=setInterval(e,2e3);return()=>{window.removeEventListener(`storage`,e),clearInterval(t)}},[c]);let T=m===null?void 0:m,{data:E,isLoading:D,isFetching:O,refetch:k}=q({queryKey:[`archiveStats`,w.dateFrom,w.dateTo,T??`all`],queryFn:()=>Q.getArchiveStats({dateFrom:w.dateFrom,dateTo:w.dateTo,createdById:T})}),{data:A}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:j,isFetching:M,refetch:N}=q({queryKey:[`archivesSlim`,w.dateFrom,w.dateTo,T??`all`],queryFn:()=>Q.getArchivesSlim(w.dateFrom,w.dateTo,T)}),{data:P}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:F}=q({queryKey:[`users`],queryFn:Q.getUsers,enabled:v}),I=(0,y.useMemo)(()=>m===null?e(`stats.allUsers`,`All Users`):m===-1?e(`stats.noUser`,`No User (System)`):F?.find(e=>e.id===m)?.username??`?`,[m,F,e]),L=async n=>{s(!1),a(!0);try{let{blob:r,filename:i}=await Q.exportStats({format:n,days:90,createdById:T}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a),t(e(`stats.exportDownloaded`))}catch{t(e(`stats.exportFailed`),`error`)}finally{a(!1)}},R=async()=>{p(!0);try{let n=await Q.recalculateCosts();await Promise.all([k(),N()]),t(e(`stats.recalculatedCosts`,{count:n.updated}))}catch{t(e(`stats.recalculateFailed`),`error`)}finally{p(!1)}},z=(O||M)&&!D,B=$d(P?.currency||`USD`),V=new Map(A?.map(e=>[String(e.id),e.name])||[]),ee=(0,y.useMemo)(()=>j?.map(e=>e.created_at)||[],[j]);if(D)return(0,K.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`stats.loadingStats`)})});let te=[{id:`quick-stats`,title:e(`stats.quickStats`),component:(0,K.jsx)(wVe,{stats:E,currency:B}),defaultSize:2},{id:`success-rate`,title:e(`stats.successRate`),component:e=>(0,K.jsx)(TVe,{stats:E,printerMap:V,size:e}),defaultSize:1},{id:`time-accuracy`,title:e(`stats.timeAccuracy`),component:e=>(0,K.jsx)(EVe,{stats:E,printerMap:V,size:e}),defaultSize:1},{id:`failure-analysis`,title:e(`stats.failureAnalysis`),component:e=>(0,K.jsx)(jVe,{size:e,dateFrom:w.dateFrom,dateTo:w.dateTo,createdById:T}),defaultSize:1},{id:`print-activity`,title:e(`stats.printActivity`),component:e=>(0,K.jsx)(OVe,{printDates:ee,size:e,dateFrom:w.dateFrom,dateTo:w.dateTo}),defaultSize:2},{id:`records`,title:e(`stats.records`),component:(0,K.jsx)(MVe,{archives:j||[],currency:B}),defaultSize:1},{id:`printer-stats`,title:e(`stats.printerStats`),component:(0,K.jsx)(kVe,{stats:E,archives:j||[],printerMap:V}),defaultSize:4},{id:`filament-trends`,title:e(`stats.filamentTrends`),component:(0,K.jsx)(AVe,{archives:j||[],currency:B,dateFrom:w.dateFrom,dateTo:w.dateTo}),defaultSize:4}];return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)($o,{className:`w-7 h-7 text-bambu-green`}),e(`stats.title`)]}),z&&(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`stats.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u>0&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{window.dispatchEvent(new CustomEvent(`toggle-hidden-panel`))},children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),e(`stats.hiddenCount`,{count:u})]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{localStorage.removeItem(`bambusy-dashboard-layout-v2`),l(e=>e+1),t(e(`stats.layoutReset`))},disabled:!n(`settings:update`),title:n(`settings:update`)?void 0:e(`stats.noPermissionResetLayout`),children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),e(`stats.resetLayout`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:R,disabled:f||!n(`archives:update_all`),title:n(`archives:update_all`)?e(`stats.recalculateCostsHint`):e(`stats.noPermissionRecalculate`),children:[f?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Jo,{className:`w-4 h-4`}),e(`stats.recalculateCosts`)]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s(!o),disabled:i,children:[i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(tc,{className:`w-4 h-4`}),e(`stats.exportStats`)]}),o&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg`,onClick:()=>L(`csv`),children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),e(`stats.exportAsCsv`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg`,onClick:()=>L(`xlsx`),children:[(0,K.jsx)(tc,{className:`w-4 h-4`}),e(`stats.exportAsExcel`)]})]})]}),v&&F&&F.length>0&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>_(!g),children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),I,(0,K.jsx)(is,{className:`w-3 h-3`})]}),g&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>_(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2 max-h-64 overflow-y-auto`,children:[(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===null?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(null),_(!1)},children:e(`stats.allUsers`,`All Users`)}),(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===-1?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(-1),_(!1)},children:e(`stats.noUser`,`No User (System)`)}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary my-1`}),F.map(e=>(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===e.id?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(e.id),_(!1)},children:e.username},e.id))]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!S),children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),e(`stats.timeframe.${b.preset}`),(0,K.jsx)(is,{className:`w-3 h-3`})]}),S&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>C(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-64 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2`,children:[SVe.map(t=>(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${b.preset===t?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{x({preset:t,dateFrom:void 0,dateTo:void 0}),C(!1)},children:e(`stats.timeframe.${t}`)},t)),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary my-2`}),(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${b.preset===`custom`?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>x(e=>({...e,preset:`custom`})),children:e(`stats.timeframe.custom`)}),b.preset===`custom`&&(0,K.jsxs)(`div`,{className:`mt-2 px-1 pb-1 space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray block mb-1`,children:e(`stats.timeframe.from`)}),(0,K.jsx)(`input`,{type:`date`,value:b.dateFrom||``,max:b.dateTo||new Date().toISOString().split(`T`)[0],onChange:e=>x(t=>({...t,dateFrom:e.target.value||void 0})),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray block mb-1`,children:e(`stats.timeframe.to`)}),(0,K.jsx)(`input`,{type:`date`,value:b.dateTo||``,min:b.dateFrom,max:new Date().toISOString().split(`T`)[0],onChange:e=>x(t=>({...t,dateTo:e.target.value||void 0})),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]`})]}),(0,K.jsx)($,{variant:`primary`,onClick:()=>C(!1),className:`w-full`,children:e(`common.apply`)})]})]})]})]})]})]}),(0,K.jsx)(bVe,{widgets:te,storageKey:`bambusy-dashboard-layout-v2`,stackBelow:640,hideControls:!0},c)]})}function p3(e){return e.length<8?`tooShort`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/\d/.test(e)?/[^A-Za-z0-9]/.test(e)?null:`needsSpecial`:`needsDigit`:`needsLowercase`:`needsUppercase`}function PVe(){let{t:e}=W();return(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray`}),e(`settings.slicerBundlesRemoved.title`,{defaultValue:`Slicer Bundles (removed)`})]})}),(0,K.jsxs)(yd,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.description`,{defaultValue:`Printer Preset Bundle (.bbscfg) import was removed. BambuStudio's bundle export only includes user-customised presets, so the import never delivered standard processes / filaments and slicing fell back to embedded settings.`})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.alternatives`,{defaultValue:`Use Single Preset Import for individual customs, or sync via Bambu Cloud / Orca Cloud. Stock presets come from the slicer sidecar automatically.`})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.lookupOrder`,{defaultValue:`Slice-time preset lookup order: 1) Imported (local), 2) Orca Cloud, 3) Bambu Cloud, 4) Standard (sidecar fallback).`})})]})]})}var m3=90,h3=365;function g3(e){if(!e)return`—`;let t=vf(e);return t?t.toLocaleString():`—`}function FVe(e){let t=vf(e);return t?t.getTime(){if(s.preventDefault(),r.trim()){c(!0);try{e(await Q.createLongLivedCameraToken({name:r.trim(),expires_in_days:a})),i(``),o(m3),n(t(`cameraTokens.toast.created`,`Token created`))}catch(e){n(e instanceof Error?e.message:t(`cameraTokens.toast.createFailed`,`Failed to create token`),`error`)}finally{c(!1)}}},className:`bg-bambu-dark-secondary rounded-lg p-4 mb-6 border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:t(`cameraTokens.create.title`,`Create new token`)}),(0,K.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_140px_auto]`,children:[(0,K.jsx)(`input`,{type:`text`,maxLength:100,required:!0,value:r,onChange:e=>i(e.target.value),placeholder:t(`cameraTokens.create.namePlaceholder`,`e.g. Home Assistant`),className:`px-3 py-2 bg-bambu-dark rounded-md text-white border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none`,"aria-label":t(`cameraTokens.create.nameLabel`,`Token name`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:h3,required:!0,value:a,onChange:e=>{let t=Number(e.target.value);o(Math.min(Math.max(t,1),h3))},className:`px-3 py-2 bg-bambu-dark rounded-md text-white border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none`,"aria-label":t(`cameraTokens.create.daysLabel`,`Days until expiry`)}),(0,K.jsxs)(`button`,{type:`submit`,disabled:s||!r.trim(),className:`flex items-center gap-2 px-4 py-2 bg-bambu-green text-white rounded-md hover:bg-bambu-green/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),t(`cameraTokens.create.submit`,`Create`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:t(`cameraTokens.create.hint`,`Maximum lifetime is 365 days. The token value is shown only once on creation — copy it now.`)})]})}function LVe({token:e,onConfirm:t,onCancel:n}){let{t:r}=W();return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4`,role:`dialog`,"aria-modal":`true`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full border border-red-500/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-red-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`cameraTokens.confirmRevoke.title`,`Revoke this token?`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`cameraTokens.confirmRevoke.body`,`Any device using "{{name}}" will lose access immediately. This cannot be undone.`,{name:e.name})})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`px-4 py-2 bg-bambu-dark-tertiary text-white rounded-md hover:bg-bambu-dark-tertiary/80`,children:r(`cameraTokens.confirmRevoke.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 bg-red-500 text-white rounded-md hover:bg-red-600`,children:r(`cameraTokens.confirmRevoke.confirm`,`Revoke`)})]})]})})}function RVe({token:e,onClose:t}){let{t:n}=W(),{showToast:r}=Td(),i=e.token??``;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-2xl w-full border border-bambu-green/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`cameraTokens.created.title`,`Token created — copy it now`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:n(`cameraTokens.created.warning`,`This is the only time this token will be visible. After you close this dialog you can never view it again.`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(`code`,{className:`flex-1 px-3 py-2 bg-bambu-dark rounded-md text-bambu-green text-xs break-all font-mono select-all`,children:i}),(0,K.jsxs)(`button`,{type:`button`,onClick:async()=>{if(i)try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{let e=document.createElement(`textarea`);e.value=i,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e);try{e.select(),document.execCommand(`copy`)}finally{document.body.removeChild(e)}}r(n(`cameraTokens.toast.copied`,`Copied to clipboard`))}catch{r(n(`cameraTokens.toast.copyFailed`,`Copy failed — select and copy manually`),`error`)}},className:`flex items-center gap-2 px-3 py-2 bg-bambu-green text-white rounded-md hover:bg-bambu-green/90`,children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),n(`cameraTokens.created.copy`,`Copy`)]})]}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 bg-bambu-dark-tertiary text-white rounded-md hover:bg-bambu-dark-tertiary/80`,children:n(`cameraTokens.created.dismiss`,`I've saved it`)})})]})})}function zVe({token:e,showOwner:t,ownerLabel:n,onRevoke:r}){let{t:i}=W(),a=FVe(e.expires_at);return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary last:border-b-0`,children:[(0,K.jsx)(`td`,{className:`py-3 px-3 text-white`,children:e.name}),t&&(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:n}),(0,K.jsxs)(`td`,{className:`py-3 px-3 text-bambu-gray font-mono text-xs`,children:[e.lookup_prefix,`…`]}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:g3(e.created_at)}),(0,K.jsxs)(`td`,{className:`py-3 px-3 ${a?`text-red-400`:`text-bambu-gray`}`,children:[g3(e.expires_at),a&&(0,K.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-xs bg-red-500/20 text-red-300 rounded`,children:i(`cameraTokens.list.expired`,`Expired`)})]}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:g3(e.last_used_at)}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-right`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`inline-flex items-center gap-1 px-2 py-1 text-sm text-red-400 hover:text-red-300`,title:i(`cameraTokens.list.revoke`,`Revoke`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`cameraTokens.list.revoke`,`Revoke`)]})})]})}function _3({tokens:e,showOwner:t,userIdToName:n,onRevoke:r,emptyMessage:i}){let{t:a}=W();return e.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic`,children:i}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`text-bambu-gray text-left border-b border-bambu-dark-tertiary`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.name`,`Name`)}),t&&(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.owner`,`Owner`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.prefix`,`Prefix`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.created`,`Created`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.expires`,`Expires`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.lastUsed`,`Last used`)}),(0,K.jsx)(`th`,{className:`py-2 px-3`})]})}),(0,K.jsx)(`tbody`,{children:e.map(e=>(0,K.jsx)(zVe,{token:e,showOwner:t,ownerLabel:n?.get(e.user_id)??`#${e.user_id}`,onRevoke:r},e.id))})]})})}function BVe(){let{t:e}=W(),{user:t,isAdmin:n}=dd(),{showToast:r}=Td(),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(new Map),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),g=async()=>{d(!0);try{if(a(await Q.listMyLongLivedCameraTokens()),n){s(await Q.listAllLongLivedCameraTokens());try{let e=await Q.getUsers();l(new Map(e.map(e=>[e.id,e.username])))}catch{l(new Map)}}}catch(t){r(t instanceof Error?t.message:e(`cameraTokens.toast.loadFailed`,`Failed to load tokens`),`error`)}finally{d(!1)}};(0,y.useEffect)(()=>{g()},[n]);let _=async e=>{let t=[...i,...o].find(t=>t.id===e);t&&h(t)},v=async()=>{if(!m)return;let t=m.id;h(null);try{await Q.revokeLongLivedCameraToken(t),r(e(`cameraTokens.toast.revoked`,`Token revoked`)),await g()}catch(t){r(t instanceof Error?t.message:e(`cameraTokens.toast.revokeFailed`,`Failed to revoke token`),`error`)}},b=(0,y.useMemo)(()=>o.filter(e=>e.user_id!==t?.id),[o,t?.id]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`cameraTokens.description`,`Long-lived tokens for embedding the camera stream into Home Assistant, Frigate, kiosks, or any other tool that needs a stable URL. Each token is camera-stream-only and can be revoked at any time.`)}),(0,K.jsx)(IVe,{onCreated:e=>{p(e),g()}}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:e(`cameraTokens.list.myTitle`,`My tokens`)}),u?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`cameraTokens.loading`,`Loading…`)}):(0,K.jsx)(_3,{tokens:i,onRevoke:_,emptyMessage:e(`cameraTokens.list.empty`,`No tokens yet.`)})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:e(`cameraTokens.list.allTitle`,`All users (admin view)`)}),(0,K.jsx)(_3,{tokens:b,showOwner:!0,userIdToName:c,onRevoke:_,emptyMessage:e(`cameraTokens.list.empty`,`No tokens yet.`)})]}),f&&(0,K.jsx)(RVe,{token:f,onClose:()=>p(null)}),m&&(0,K.jsx)(LVe,{token:m,onConfirm:()=>void v(),onCancel:()=>h(null)})]})}function VVe({plug:e,onEdit:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),{data:p,isLoading:m}=q({queryKey:[`smart-plug-status`,e.id],queryFn:()=>Q.getSmartPlugStatus(e.id),refetchInterval:3e4}),{data:h}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),g=h?.find(t=>t.id===e.printer_id),_=J({mutationFn:t=>Q.controlSmartPlug(e.id,t),onMutate:async t=>{await r.cancelQueries({queryKey:[`smart-plug-status`,e.id]});let n=r.getQueryData([`smart-plug-status`,e.id]),i=t===`on`?`ON`:t===`off`||p?.state===`ON`?`OFF`:`ON`;return r.setQueryData([`smart-plug-status`,e.id],e=>({...e,state:i})),{previousStatus:n}},onError:(t,a,o)=>{o?.previousStatus&&r.setQueryData([`smart-plug-status`,e.id],o.previousStatus),i(n(`smartPlugs.failedToTurn`,{action:a,name:e.name}),`error`)},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:[`smart-plug-status`,e.id]}),r.invalidateQueries({queryKey:[`smart-plugs`]})},1e3)}}),v=J({mutationFn:t=>Q.updateSmartPlug(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),e.printer_id&&(r.invalidateQueries({queryKey:[`smartPlugByPrinter`,e.printer_id]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`,e.printer_id]}))}}),b=J({mutationFn:()=>Q.deleteSmartPlug(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),e.printer_id&&r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`,e.printer_id]})}}),x=p?.state===`ON`,S=e.plug_type===`mqtt`&&p?.energy?.power!==null&&p?.energy?.power!==void 0,C=(p?.reachable??!1)||S,w=_.isPending,T=(()=>{if(e.plug_type!==`tasmota`||!e.ip_address)return null;let t=e.ip_address;return e.username&&e.password?`http://${encodeURIComponent(e.username)}:${encodeURIComponent(e.password)}@${t}/`:`http://${t}/`})();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{className:`relative`,children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg flex-shrink-0 ${e.plug_type===`mqtt`?C?`bg-teal-500/20`:`bg-red-500/20`:C?x?`bg-bambu-green/20`:`bg-bambu-dark`:`bg-red-500/20`}`,children:e.plug_type===`mqtt`?(0,K.jsx)(Dl,{className:`w-5 h-5 ${C?`text-teal-400`:`text-red-400`}`}):e.plug_type===`homeassistant`?(0,K.jsx)(Ac,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`}):e.plug_type===`rest`?(0,K.jsx)(bc,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`}):(0,K.jsx)(xl,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-white truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray truncate`,title:e.plug_type===`mqtt`?e.mqtt_topic??void 0:e.plug_type===`homeassistant`?e.ha_entity_id??void 0:e.plug_type===`rest`?e.rest_on_url??e.rest_off_url??void 0:e.ip_address??void 0,children:e.plug_type===`mqtt`?e.mqtt_topic:e.plug_type===`homeassistant`?e.ha_entity_id:e.plug_type===`rest`?e.rest_on_url||e.rest_off_url:e.ip_address})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-end gap-1 flex-shrink-0`,children:[m?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin`}):e.plug_type===`mqtt`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm whitespace-nowrap`,children:[(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0`,children:`MQTT`}),C&&(0,K.jsx)(`span`,{className:`text-status-ok`,children:`✓`})]}):e.plug_type===`homeassistant`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded`,children:`HA`}),(0,K.jsx)(`span`,{className:C?x?`text-status-ok`:`text-bambu-gray`:`text-status-error`,children:C?p?.state||`?`:n(`smartPlugs.offline`)})]}):e.plug_type===`rest`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-1 py-0.5 bg-purple-500/20 text-purple-400 text-[10px] font-medium rounded`,children:`REST`}),(0,K.jsx)(`span`,{className:C?x?`text-status-ok`:`text-bambu-gray`:`text-status-error`,children:C?p?.state||`?`:n(`smartPlugs.offline`)})]}):C?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4 text-status-ok`}),(0,K.jsx)(`span`,{className:x?`text-status-ok`:`text-bambu-gray`,children:p?.state||n(`smartPlugs.unknown`)})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-status-error`,children:[(0,K.jsx)(Pu,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:n(`smartPlugs.offline`)})]}),T&&(0,K.jsxs)(`a`,{href:T,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors`,title:n(`smartPlugs.openPlugAdminPage`),children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),n(`smartPlugs.admin`)]})]})]}),g&&(0,K.jsxs)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[n(`smartPlugs.linkedTo`),` `]}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:g.name})]}),(e.power_alert_enabled||e.schedule_enabled||e.plug_type===`mqtt`)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.plug_type===`mqtt`&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full`,children:[(0,K.jsx)(Xs,{className:`w-3 h-3`}),n(`smartPlugs.monitorOnly`)]}),e.power_alert_enabled&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full`,children:[(0,K.jsx)(Bo,{className:`w-3 h-3`}),n(`smartPlugs.alerts`)]}),e.schedule_enabled&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),e.schedule_on_time&&e.schedule_off_time?`${e.schedule_on_time} - ${e.schedule_off_time}`:e.schedule_on_time?n(`smartPlugs.scheduleOn`,{time:e.schedule_on_time}):n(`smartPlugs.scheduleOff`,{time:e.schedule_off_time})]})]}),e.plug_type!==`mqtt`&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,K.jsxs)($,{size:`sm`,variant:x?`primary`:`secondary`,disabled:!C||w,onClick:()=>c(!0),className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(wl,{className:`w-4 h-4`}),n(`smartPlugs.on`)]}),(0,K.jsxs)($,{size:`sm`,variant:x?`secondary`:`primary`,disabled:!C||w,onClick:()=>u(!0),className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Cl,{className:`w-4 h-4`}),n(`smartPlugs.off`)]})]}),e.plug_type===`mqtt`&&p?.energy&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg`,children:[p.energy.power!==null&&p.energy.power!==void 0&&(0,K.jsxs)(`div`,{className:`flex-1 text-center`,children:[(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[Math.round(p.energy.power),`W`]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.power`)})]}),p.energy.today!==null&&p.energy.today!==void 0&&(0,K.jsxs)(`div`,{className:`flex-1 text-center border-l border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:p.energy.today.toFixed(3)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.kwhToday`)})]})]}),(0,K.jsxs)(`button`,{onClick:()=>f(!d),className:`w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),e.plug_type===`mqtt`?n(`smartPlugs.settings`):n(`smartPlugs.automationSettings`)]}),(0,K.jsx)(`span`,{children:d?`-`:`+`})]}),d&&(0,K.jsxs)(`div`,{className:`pt-3 border-t border-bambu-dark-tertiary space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.showInSwitchbar`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.quickAccessSidebar`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.show_in_switchbar,onChange:e=>v.mutate({show_in_switchbar:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.plug_type!==`mqtt`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.enabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.enableAutomation`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>v.mutate({enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOn`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOnDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_on,onChange:e=>v.mutate({auto_on:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOff`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off,onChange:e=>v.mutate({auto_off:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOffPersistent`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffPersistentDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off_persistent,onChange:e=>v.mutate({auto_off_persistent:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off&&(0,K.jsxs)(`div`,{className:`space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white mb-2`,children:n(`smartPlugs.turnOffDelayMode`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>v.mutate({off_delay_mode:`time`}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${e.off_delay_mode===`time`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4`}),n(`smartPlugs.time`)]}),(0,K.jsxs)(`button`,{onClick:()=>v.mutate({off_delay_mode:`temperature`}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${e.off_delay_mode===`temperature`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(vu,{className:`w-4 h-4`}),n(`smartPlugs.temp`)]})]})]}),e.off_delay_mode===`time`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.delayMinutes`)}),(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`60`,value:e.off_delay_minutes,onChange:e=>v.mutate({off_delay_minutes:parseInt(e.target.value)||5}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.tempThreshold`)}),(0,K.jsx)(`input`,{type:`number`,min:`30`,max:`100`,value:e.off_temp_threshold,onChange:e=>v.mutate({off_temp_threshold:parseInt(e.target.value)||70}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`smartPlugs.tempThresholdDescription`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOffAfterDrying`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffAfterDryingDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off_after_drying,onChange:e=>v.mutate({auto_off_after_drying:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off_after_drying&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.delayAfterDryingMinutes`)}),(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`120`,value:e.off_delay_after_drying_minutes,onChange:e=>v.mutate({off_delay_after_drying_minutes:parseInt(e.target.value)||10}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>t(e),className:`flex-1`,children:[(0,K.jsx)(_l,{className:`w-4 h-4`}),n(`smartPlugs.edit`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})}),a&&(0,K.jsx)(Ad,{title:n(`smartPlugs.deleteSmartPlug`),message:n(`smartPlugs.deleteConfirm`,{name:e.name}),confirmText:n(`smartPlugs.delete`),variant:`danger`,onConfirm:()=>{b.mutate(),o(!1)},onCancel:()=>o(!1)}),s&&(0,K.jsx)(Ad,{title:n(`smartPlugs.turnOnSmartPlug`),message:n(`smartPlugs.turnOnConfirm`,{name:e.name}),confirmText:n(`smartPlugs.turnOn`),variant:`default`,onConfirm:()=>{_.mutate(`on`),c(!1)},onCancel:()=>c(!1)}),l&&(0,K.jsx)(Ad,{title:n(`smartPlugs.turnOffSmartPlug`),message:n(`smartPlugs.turnOffConfirm`,{name:e.name}),confirmText:n(`smartPlugs.turnOff`),variant:`danger`,onConfirm:()=>{_.mutate(`off`),u(!1)},onCancel:()=>u(!1)})]})}function HVe({plug:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,[a,o]=(0,y.useState)(e?.plug_type||`tasmota`),[s,c]=(0,y.useState)(e?.name||``),[l,u]=(0,y.useState)(e?.ip_address||``),[d,f]=(0,y.useState)(e?.username||``),[p,m]=(0,y.useState)(e?.password||``),[h,g]=(0,y.useState)(e?.ha_entity_id||``),[_,v]=(0,y.useState)(e?.mqtt_power_topic||e?.mqtt_topic||``),[b,x]=(0,y.useState)(e?.mqtt_power_path||``),[S,C]=(0,y.useState)((e?.mqtt_power_multiplier??e?.mqtt_multiplier??1).toString()),[w,T]=(0,y.useState)(e?.mqtt_energy_topic||``),[E,D]=(0,y.useState)(e?.mqtt_energy_path||``),[O,k]=(0,y.useState)((e?.mqtt_energy_multiplier??1).toString()),[A,j]=(0,y.useState)(e?.mqtt_state_topic||``),[M,N]=(0,y.useState)(e?.mqtt_state_path||``),[P,F]=(0,y.useState)(e?.mqtt_state_on_value||``),[I,L]=(0,y.useState)(e?.rest_on_url||``),[R,z]=(0,y.useState)(e?.rest_on_body||``),[B,V]=(0,y.useState)(e?.rest_off_url||``),[ee,te]=(0,y.useState)(e?.rest_off_body||``),[ne,re]=(0,y.useState)(e?.rest_method||`POST`),[ie,H]=(0,y.useState)(e?.rest_headers||``),[ae,oe]=(0,y.useState)(e?.rest_status_url||``),[U,se]=(0,y.useState)(e?.rest_status_path||``),[ce,le]=(0,y.useState)(e?.rest_status_on_value||``),[ue,de]=(0,y.useState)(e?.rest_power_url||``),[fe,pe]=(0,y.useState)(e?.rest_power_path||``),[me,he]=(0,y.useState)((e?.rest_power_multiplier??1).toString()),[ge,_e]=(0,y.useState)(e?.rest_energy_url||``),[ve,ye]=(0,y.useState)(e?.rest_energy_path||``),[be,xe]=(0,y.useState)((e?.rest_energy_multiplier??1).toString()),[Se,Ce]=(0,y.useState)(e?.ha_power_entity||``),[we,Te]=(0,y.useState)(e?.ha_energy_today_entity||``),[Ee,De]=(0,y.useState)(e?.ha_energy_total_entity||``),[Oe,ke]=(0,y.useState)(``),[Ae,je]=(0,y.useState)(``),[Me,Ne]=(0,y.useState)(!1),Pe=(0,y.useRef)(null),[Fe,Ie]=(0,y.useState)(``),[Le,Re]=(0,y.useState)(!1),ze=(0,y.useRef)(null),[Be,Ve]=(0,y.useState)(``),[He,Ue]=(0,y.useState)(!1),We=(0,y.useRef)(null),[Ge,Ke]=(0,y.useState)(``),[qe,Je]=(0,y.useState)(!1),Ye=(0,y.useRef)(null),[Xe,Ze]=(0,y.useState)(e?.printer_id||null),[Qe,$e]=(0,y.useState)(null),[et,tt]=(0,y.useState)(null),[nt,rt]=(0,y.useState)(e?.power_alert_enabled||!1),[it,at]=(0,y.useState)(e?.power_alert_high?.toString()||``),[ot,st]=(0,y.useState)(e?.power_alert_low?.toString()||``),[ct,lt]=(0,y.useState)(e?.schedule_enabled||!1),[ut,dt]=(0,y.useState)(e?.schedule_on_time||``),[ft,pt]=(0,y.useState)(e?.schedule_off_time||``),[mt,ht]=(0,y.useState)(e?.show_in_switchbar||!1),[gt,_t]=(0,y.useState)(e?.show_on_printer_card??!0),[vt,yt]=(0,y.useState)(!1),[bt,xt]=(0,y.useState)({scanned:0,total:0}),[St,Ct]=(0,y.useState)([]),wt=(0,y.useRef)(null),{data:Tt}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Et}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:Dt}=q({queryKey:[`settings`],queryFn:Q.getSettings}),Ot=!!(Dt?.ha_enabled&&Dt?.ha_url&&Dt?.ha_token);(0,y.useEffect)(()=>{let e=setTimeout(()=>{je(Oe)},300);return()=>clearTimeout(e)},[Oe]),(0,y.useEffect)(()=>{let e=e=>{Pe.current&&!Pe.current.contains(e.target)&&Ne(!1),ze.current&&!ze.current.contains(e.target)&&Re(!1),We.current&&!We.current.contains(e.target)&&Ue(!1),Ye.current&&!Ye.current.contains(e.target)&&Je(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let{data:kt,isLoading:At,error:jt}=q({queryKey:[`ha-entities`,Ae],queryFn:()=>Q.getHAEntities(Ae||void 0),enabled:a===`homeassistant`&&Ot,retry:!1,staleTime:0}),{data:Mt}=q({queryKey:[`ha-sensor-entities`],queryFn:Q.getHASensorEntities,enabled:a===`homeassistant`&&Ot,retry:!1,staleTime:0});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),wt.current&&clearInterval(wt.current)}},[t]);let G=async()=>{yt(!0),Ct([]),xt({scanned:0,total:0}),tt(null);try{await Q.startTasmotaScan();let e=async()=>{try{let e=await Q.getTasmotaScanStatus();xt({scanned:e.scanned,total:e.total}),Ct(await Q.getDiscoveredTasmotaDevices()),e.running||(yt(!1),wt.current&&=(clearInterval(wt.current),null))}catch(e){console.error(`Polling error:`,e)}};await e(),wt.current=setInterval(e,500)}catch(e){yt(!1),tt((e instanceof Error?e.message:typeof e==`string`?e:JSON.stringify(e))||n(`smartPlugs.failedToStartScan`))}},Nt=async()=>{try{await Q.stopTasmotaScan()}catch{}yt(!1),wt.current&&=(clearInterval(wt.current),null)},Pt=e=>{u(e.ip_address),c(e.name),$e(null)},Ft=J({mutationFn:()=>Q.testSmartPlugConnection(l,d||null,p||null),onSuccess:e=>{$e(e),tt(null),!s&&e.device_name&&c(e.device_name)},onError:e=>{$e(null),tt(e.message)}}),It=J({mutationFn:e=>Q.createSmartPlug(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`]}),t()},onError:e=>{tt(e.message)}}),Lt=J({mutationFn:t=>Q.updateSmartPlug(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`]}),t()},onError:e=>{tt(e.message)}}),Rt=Tt?.filter(t=>a===`tasmota`?!Et?.some(n=>n.printer_id===t.id&&n.id!==e?.id&&n.plug_type===`tasmota`):!0),zt=e=>{if(e.preventDefault(),tt(null),!s.trim()){tt(n(`smartPlugs.nameRequired`));return}if(a===`tasmota`&&!l.trim()){tt(`IP address is required for Tasmota plugs`);return}if(a===`homeassistant`&&!h){tt(n(`smartPlugs.entityRequired`));return}if(a===`mqtt`){let e=_.trim(),t=w.trim(),r=A.trim();if(!e&&!t&&!r){tt(n(`smartPlugs.mqttTopicRequired`));return}}if(a===`rest`&&!I.trim()&&!B.trim()){tt(n(`smartPlugs.restUrlRequired`));return}let t={name:s.trim(),plug_type:a,ip_address:a===`tasmota`?l.trim():null,ha_entity_id:a===`homeassistant`?h:null,ha_power_entity:a===`homeassistant`&&Se||null,ha_energy_today_entity:a===`homeassistant`&&we||null,ha_energy_total_entity:a===`homeassistant`&&Ee||null,mqtt_power_topic:a===`mqtt`&&_.trim()||null,mqtt_power_path:a===`mqtt`&&b.trim()||null,mqtt_power_multiplier:a===`mqtt`&&parseFloat(S)||1,mqtt_energy_topic:a===`mqtt`&&w.trim()||null,mqtt_energy_path:a===`mqtt`&&E.trim()||null,mqtt_energy_multiplier:a===`mqtt`&&parseFloat(O)||1,mqtt_state_topic:a===`mqtt`&&A.trim()||null,mqtt_state_path:a===`mqtt`&&M.trim()||null,mqtt_state_on_value:a===`mqtt`&&P.trim()||null,rest_on_url:a===`rest`&&I.trim()||null,rest_on_body:a===`rest`&&R.trim()||null,rest_off_url:a===`rest`&&B.trim()||null,rest_off_body:a===`rest`&&ee.trim()||null,rest_method:a===`rest`?ne:null,rest_headers:a===`rest`&&ie.trim()||null,rest_status_url:a===`rest`&&ae.trim()||null,rest_status_path:a===`rest`&&U.trim()||null,rest_status_on_value:a===`rest`&&ce.trim()||null,rest_power_url:a===`rest`&&ue.trim()||null,rest_power_path:a===`rest`&&fe.trim()||null,rest_power_multiplier:a===`rest`&&parseFloat(me)||1,rest_energy_url:a===`rest`&&ge.trim()||null,rest_energy_path:a===`rest`&&ve.trim()||null,rest_energy_multiplier:a===`rest`&&parseFloat(be)||1,username:a===`tasmota`&&d.trim()||null,password:a===`tasmota`&&p.trim()||null,printer_id:Xe,power_alert_enabled:nt,power_alert_high:it?parseFloat(it):null,power_alert_low:ot?parseFloat(ot):null,schedule_enabled:ct,schedule_on_time:ut||null,schedule_off_time:ft||null,show_in_switchbar:mt,show_on_printer_card:gt};i?Lt.mutate(t):It.mutate(t)},Bt=It.isPending||Lt.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(i?`smartPlugs.editTitle`:`smartPlugs.addTitle`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:zt,className:`p-6 space-y-4 overflow-y-auto`,children:[et&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:et}),!i&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`tasmota`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`tasmota`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(xl,{className:`w-4 h-4`}),`Tasmota`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`homeassistant`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`homeassistant`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Ac,{className:`w-4 h-4`}),`HA`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`mqtt`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`mqtt`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Dl,{className:`w-4 h-4`}),`MQTT`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`rest`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`rest`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(bc,{className:`w-4 h-4`}),`REST`]})]}),!i&&a===`tasmota`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[vt?(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:Nt,className:`w-full`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),n(`smartPlugs.stopScanning`)]}):(0,K.jsxs)($,{type:`button`,variant:`primary`,onClick:G,className:`w-full`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4`}),n(`smartPlugs.discoverTasmota`)]}),vt&&bt.total>0&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:n(`smartPlugs.addSmartPlug.scanningNetwork`)}),(0,K.jsxs)(`span`,{children:[bt.scanned,` / `,bt.total]})]}),(0,K.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${bt.scanned/bt.total*100}%`}})})]}),St.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.foundDevices`,{count:St.length})}),(0,K.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:St.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>Pt(e),className:`w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(xl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.ip_address})]})]}),e.state&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${e.state===`ON`?`text-bambu-green`:`text-bambu-gray`}`,children:[(0,K.jsx)(wl,{className:`w-3 h-3`}),e.state]})]},e.ip_address))})]}),!vt&&St.length===0&&bt.total>0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray text-center py-2`,children:n(`smartPlugs.noDevicesFound`)})]}),a===`homeassistant`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!Ot&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400`,children:[n(`smartPlugs.haNotConfigured`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:n(`smartPlugs.haSettingsPath`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1 opacity-50`,children:n(`smartPlugs.selectEntity`)}),(0,K.jsx)(`select`,{disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50`,children:(0,K.jsx)(`option`,{children:n(`smartPlugs.addSmartPlug.chooseEntity`)})})]})]}),Ot&&(0,K.jsxs)(K.Fragment,{children:[At&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),n(`smartPlugs.loadingEntities`)]}),jt&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:n(`smartPlugs.failedToLoadEntities`,{error:jt.message})}),(()=>{let t=Et?.filter(t=>t.ha_entity_id&&t.id!==e?.id).map(e=>e.ha_entity_id)||[],r=(kt||[]).filter(e=>!t.includes(e.entity_id)),i=kt?.find(e=>e.entity_id===h);return(0,K.jsxs)(`div`,{ref:Pe,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.selectEntity`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:Me?Oe:i?`${i.friendly_name} (${i.entity_id})`:``,onChange:e=>{ke(e.target.value),Me||Ne(!0)},onFocus:()=>{Ne(!0),ke(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEntities`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),h&&!Me&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{g(``),ke(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})}),At&&(0,K.jsx)(X,{className:`absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin`})]}),Me&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto`,children:[At&&(0,K.jsxs)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray flex items-center gap-2`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`smartPlugs.loading`)]}),!At&&r.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:Ae?n(`smartPlugs.noEntitiesMatching`,{search:Ae}):n(`smartPlugs.noEntitiesAvailable`)}),!At&&r.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{g(e.entity_id),Ne(!1),ke(``),s||c(e.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${e.entity_id===h?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray flex items-center justify-between`,children:[(0,K.jsx)(`span`,{children:e.entity_id}),(0,K.jsx)(`span`,{className:e.state===`on`?`text-bambu-green`:``,children:e.state})]})]},e.entity_id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(Ae?`smartPlugs.searchingEntities`:`smartPlugs.showingEntities`,{count:r.length})})]})})(),h&&Mt&&Mt.length>0&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:n(`smartPlugs.energyMonitoringOptional`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:n(`smartPlugs.energyMonitoringHint`)})]}),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`W`||e.unit_of_measurement===`kW`||e.unit_of_measurement===`mW`),t=Fe?e.filter(e=>e.entity_id.toLowerCase().includes(Fe.toLowerCase())||e.friendly_name.toLowerCase().includes(Fe.toLowerCase())):e,r=Mt.find(e=>e.entity_id===Se);return(0,K.jsxs)(`div`,{ref:ze,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.powerSensorW`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:Le?Fe:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ie(e.target.value),Le||Re(!0)},onFocus:()=>{Re(!0),Ie(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchPowerSensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),Se&&!Le&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Ce(``),Ie(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),Le&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Ce(``),Re(!1),Ie(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{Ce(e.entity_id),Re(!1),Ie(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===Se?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})(),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`kWh`||e.unit_of_measurement===`Wh`||e.unit_of_measurement===`MWh`),t=Be?e.filter(e=>e.entity_id.toLowerCase().includes(Be.toLowerCase())||e.friendly_name.toLowerCase().includes(Be.toLowerCase())):e,r=Mt.find(e=>e.entity_id===we);return(0,K.jsxs)(`div`,{ref:We,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.energyTodayKwh`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:He?Be:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ve(e.target.value),He||Ue(!0)},onFocus:()=>{Ue(!0),Ve(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEnergySensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),we&&!He&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Te(``),Ve(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),He&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Te(``),Ue(!1),Ve(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{Te(e.entity_id),Ue(!1),Ve(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===we?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})(),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`kWh`||e.unit_of_measurement===`Wh`||e.unit_of_measurement===`MWh`),t=Ge?e.filter(e=>e.entity_id.toLowerCase().includes(Ge.toLowerCase())||e.friendly_name.toLowerCase().includes(Ge.toLowerCase())):e,r=Mt.find(e=>e.entity_id===Ee);return(0,K.jsxs)(`div`,{ref:Ye,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.totalEnergyKwh`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:qe?Ge:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ke(e.target.value),qe||Je(!0)},onFocus:()=>{Je(!0),Ke(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEnergySensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),Ee&&!qe&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{De(``),Ke(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),qe&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{De(``),Je(!1),Ke(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{De(e.entity_id),Je(!1),Ke(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===Ee?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})()]})]})]}),a===`mqtt`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!Dt?.mqtt_broker&&(0,K.jsxs)(`div`,{className:`p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400`,children:[n(`smartPlugs.mqttNotConfigured`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:n(`smartPlugs.mqttSettingsPath`)}),` `,n(`smartPlugs.mqttNotConfiguredSuffix`)]}),Dt?.mqtt_broker&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:n(`smartPlugs.monitorOnly`)}),(0,K.jsx)(`p`,{className:`text-xs opacity-80`,children:n(`smartPlugs.mqttMonitorOnlyDescription`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm`,children:n(`smartPlugs.powerMonitoring`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`zigbee2mqtt/shelly-working-room`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`power_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.multiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttPowerHint`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.energyMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Same as power topic, or different`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`energy_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.multiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttEnergyHint`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.stateMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:`Same as power topic, or different`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:`state_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.onValue`)}),(0,K.jsx)(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:n(`smartPlugs.addSmartPlug.placeholders.mqttStateOnValue`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttStateHint`)})]})]})]}),a===`rest`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm`,children:n(`smartPlugs.restControl`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restMethod`)}),(0,K.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`GET`,children:`GET`}),(0,K.jsx)(`option`,{value:`POST`,children:`POST`}),(0,K.jsx)(`option`,{value:`PUT`,children:`PUT`}),(0,K.jsx)(`option`,{value:`PATCH`,children:`PATCH`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restOnUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:I,onChange:e=>{L(e.target.value),$e(null)},placeholder:`http://openhab:8080/rest/items/MyPlug`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restOnBody`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:n(`smartPlugs.restBodyHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restOffUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:B,onChange:e=>{V(e.target.value),$e(null)},placeholder:`http://openhab:8080/rest/items/MyPlug`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restOffBody`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:n(`smartPlugs.restBodyHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.restHeaders`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`textarea`,{value:ie,onChange:e=>H(e.target.value),placeholder:n(`smartPlugs.restHeadersHint`),rows:2,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none font-mono text-sm`})})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.stateMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),placeholder:n(`smartPlugs.restStatusHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusPath`)}),(0,K.jsx)(`input`,{type:`text`,value:U,onChange:e=>se(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusOnValue`)}),(0,K.jsx)(`input`,{type:`text`,value:ce,onChange:e=>le(e.target.value),placeholder:`ON`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.energyMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restPowerUrl`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ue,onChange:e=>de(e.target.value),placeholder:n(`smartPlugs.restPowerUrlHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restPowerPath`)}),(0,K.jsx)(`input`,{type:`text`,value:fe,onChange:e=>pe(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restPowerMultiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:me,onChange:e=>he(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restEnergyUrl`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ge,onChange:e=>_e(e.target.value),placeholder:n(`smartPlugs.restEnergyUrlHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restEnergyPath`)}),(0,K.jsx)(`input`,{type:`text`,value:ve,onChange:e=>ye(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restEnergyMultiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:be,onChange:e=>xe(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.restEnergyHint`)})]}),(I.trim()||B.trim())&&(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:async()=>{$e(null);try{let e=I.trim()||B.trim(),t=await Q.testRESTConnection(e,ne,ie.trim()||null);$e({success:t.success}),t.success||tt(t.error||n(`smartPlugs.addSmartPlug.connectionFailed`))}catch{$e({success:!1}),tt(n(`smartPlugs.addSmartPlug.connectionFailed`))}},className:`w-full`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4`}),n(`smartPlugs.testConnection`)]})}),Qe&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm ${Qe.success?`text-green-400`:`text-red-400`}`,children:[Qe.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(Pu,{className:`w-4 h-4`}),Qe.success?n(`smartPlugs.connectionSuccess`):n(`smartPlugs.addSmartPlug.connectionFailed`)]})]}),a===`tasmota`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.ipAddress`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>{u(e.target.value),$e(null)},placeholder:`192.168.1.100`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>Ft.mutate(),disabled:!l.trim()||Ft.isPending,children:[Ft.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Fu,{className:`w-4 h-4`}),n(`smartPlugs.test`)]})]})]}),a===`tasmota`&&Qe&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg flex items-center gap-2 ${Qe.success?`bg-bambu-green/20 border border-bambu-green/50 text-bambu-green`:`bg-red-500/20 border border-red-500/50 text-red-400`}`,children:Qe.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-5 h-5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium`,children:n(`smartPlugs.connectedResult`)}),(0,K.jsxs)(`p`,{className:`text-sm opacity-80`,children:[Qe.device_name&&n(`smartPlugs.deviceLabel`,{name:Qe.device_name}),n(`smartPlugs.stateLabel`,{state:Qe.state})]})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Pu,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:n(`smartPlugs.addSmartPlug.connectionFailed`)})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:n(`smartPlugs.addSmartPlug.placeholders.plugName`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),a===`tasmota`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.username`)}),(0,K.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`admin`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.password`)}),(0,K.jsx)(`input`,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`********`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray -mt-2`,children:n(`smartPlugs.authHint`)})]}),a!==`mqtt`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.linkToPrinter`)}),(0,K.jsxs)(`select`,{value:Xe??``,onChange:e=>Ze(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:n(`smartPlugs.noPrinter`)}),Rt?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`smartPlugs.linkingDescription`)})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Bo,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.powerAlerts`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>rt(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),nt&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.alertAbove`)}),(0,K.jsx)(`input`,{type:`number`,value:it,onChange:e=>at(e.target.value),placeholder:`e.g. 200`,min:`0`,max:`5000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.alertBelow`)}),(0,K.jsx)(`input`,{type:`number`,value:ot,onChange:e=>st(e.target.value),placeholder:`e.g. 10`,min:`0`,max:`5000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.alertDescription`)})]})]}),a!==`mqtt`&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.dailySchedule`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:ct,onChange:e=>lt(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),ct&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.turnOnAt`)}),(0,K.jsx)(`input`,{type:`time`,value:ut,onChange:e=>dt(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.turnOffAt`)}),(0,K.jsx)(`input`,{type:`time`,value:ft,onChange:e=>pt(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.scheduleDescription`)})]})]}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.showInSwitchbar`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.quickAccessSidebar`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})}),a===`homeassistant`&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.showOnPrinterCard`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.displayOnPrinterCard`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:gt,onChange:e=>_t(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`smartPlugs.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:Bt,className:`flex-1`,children:[Bt?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),n(i?`smartPlugs.save`:`smartPlugs.add`)]})]})]})]})})}function UVe({provider:e,onEdit:t}){let{t:n}=W(),r=no(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),{data:u}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),d=u?.find(t=>t.id===e.printer_id),f=J({mutationFn:t=>Q.updateNotificationProvider(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]})}}),p=J({mutationFn:()=>Q.deleteNotificationProvider(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]})}}),m=J({mutationFn:()=>Q.testNotificationProvider(e.id),onSuccess:e=>{l(e),r.invalidateQueries({queryKey:[`notification-providers`]})},onError:e=>{l({success:!1,message:e.message})}}),h=e=>e||``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{className:`relative`,children:(0,K.jsxs)(yd,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between ${e.enabled?`mb-3`:`mb-0`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${e.enabled?`bg-bambu-green/20`:`bg-bambu-dark`}`,children:(0,K.jsx)(Bo,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.providerTypes.${e.provider_type}`,e.provider_type)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.last_success&&(0,K.jsx)(`span`,{className:`text-xs text-status-ok hidden sm:inline`,children:n(`notifications.lastSuccess`,{date:yf(e.last_success)})}),e.last_error&&e.last_error_at&&(!e.last_success||(vf(e.last_error_at)?.getTime()||0)>(vf(e.last_success)?.getTime()||0))&&(0,K.jsx)(`span`,{className:`text-xs text-status-error`,title:e.last_error,children:n(`notifications.error`)}),(0,K.jsx)(cU,{checked:e.enabled,onChange:e=>f.mutate({enabled:e})})]})]}),e.enabled&&(0,K.jsxs)(K.Fragment,{children:[d&&(0,K.jsxs)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[n(`notifications.printer`),` `]}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:d.name})]}),!d&&!e.printer_id&&(0,K.jsx)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.allPrinters`)})}),(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-1`,children:[e.on_print_start&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded`,children:n(`notifications.start`)}),e.on_plate_not_empty&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded`,children:n(`notifications.plateCheck`)}),e.on_print_complete&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded`,children:n(`notifications.complete`)}),e.on_print_failed&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded`,children:n(`notifications.failed`)}),e.on_print_stopped&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded`,children:n(`notifications.stopped`)}),e.on_print_progress&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded`,children:n(`notifications.progress`)}),e.on_printer_offline&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded`,children:n(`notifications.offline`)}),e.on_printer_error&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded`,children:n(`notifications.error`)}),e.on_ai_failure_detection&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-fuchsia-500/20 text-fuchsia-300 text-xs rounded`,children:n(`notifications.aiFailureDetection`)}),e.on_filament_low&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded`,children:n(`notifications.lowFilament`)}),e.on_maintenance_due&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded`,children:n(`notifications.maintenance`)}),e.on_ams_humidity_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded`,children:n(`notifications.amsHumidity`)}),e.on_ams_temperature_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded`,children:n(`notifications.amsTemp`)}),e.on_ams_ht_humidity_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded`,children:n(`notifications.amsHtHumidity`)}),e.on_ams_ht_temperature_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded`,children:n(`notifications.amsHtTemp`)}),e.on_bed_cooled&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded`,children:n(`notifications.bedCooled`)}),e.on_first_layer_complete&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-emerald-600/20 text-emerald-300 text-xs rounded`,children:n(`notifications.firstLayer`)}),e.on_print_missing_spool_assignment&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-500/20 text-amber-300 text-xs rounded`,children:n(`notifications.missingSpoolAssignmentLabel`)}),e.on_stock_reorder_alert&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-lime-500/20 text-lime-400 text-xs rounded`,children:n(`notifications.stockReorderAlert`)}),e.on_stock_break_alert&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-red-600/20 text-red-300 text-xs rounded`,children:n(`notifications.stockBreakAlert`)}),e.quiet_hours_enabled&&(0,K.jsxs)(`span`,{className:`px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1`,children:[(0,K.jsx)(sl,{className:`w-3 h-3`}),n(`notifications.quiet`)]}),e.daily_digest_enabled&&(0,K.jsxs)(`span`,{className:`px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),n(`notifications.digest`,{time:e.daily_digest_time})]})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsxs)($,{size:`sm`,variant:`secondary`,disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:`w-full`,children:[m.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),n(`notifications.sendTestNotification`)]})}),c&&(0,K.jsxs)(`div`,{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${c.success?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:[c.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(ys,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:c.message})]})]}),(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors ${e.enabled?`border-t border-bambu-dark-tertiary`:`mt-2 border-t border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),n(`notifications.eventSettings`)]}),o?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`})]}),o&&(0,K.jsxs)(`div`,{className:`pt-3 border-t border-bambu-dark-tertiary space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.enabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.sendFromProvider`)})]}),(0,K.jsx)(cU,{checked:e.enabled,onChange:e=>f.mutate({enabled:e})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printEvents`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printStarted`)}),(0,K.jsx)(cU,{checked:e.on_print_start,onChange:e=>f.mutate({on_print_start:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.plateNotEmpty`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.plateNotEmptyDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_plate_not_empty??!0,onChange:e=>f.mutate({on_plate_not_empty:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printCompleted`)}),(0,K.jsx)(cU,{checked:e.on_print_complete,onChange:e=>f.mutate({on_print_complete:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.bedCooledLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.bedCooledDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_bed_cooled??!1,onChange:e=>f.mutate({on_bed_cooled:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.firstLayerCompleteLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.firstLayerCompleteDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_first_layer_complete??!1,onChange:e=>f.mutate({on_first_layer_complete:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.missingSpoolAssignmentLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.missingSpoolAssignmentDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_print_missing_spool_assignment??!1,onChange:e=>f.mutate({on_print_missing_spool_assignment:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printFailed`)}),(0,K.jsx)(cU,{checked:e.on_print_failed,onChange:e=>f.mutate({on_print_failed:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printStopped`)}),(0,K.jsx)(cU,{checked:e.on_print_stopped,onChange:e=>f.mutate({on_print_stopped:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.progressMilestones`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.progressMilestonesDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_print_progress,onChange:e=>f.mutate({on_print_progress:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printerStatus`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printerOffline`)}),(0,K.jsx)(cU,{checked:e.on_printer_offline,onChange:e=>f.mutate({on_printer_offline:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printerError`)}),(0,K.jsx)(cU,{checked:e.on_printer_error,onChange:e=>f.mutate({on_printer_error:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.aiFailureDetection`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.aiFailureDetectionDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_ai_failure_detection??!1,onChange:e=>f.mutate({on_ai_failure_detection:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.lowFilamentLabel`)}),(0,K.jsx)(cU,{checked:e.on_filament_low,onChange:e=>f.mutate({on_filament_low:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.maintenanceDue`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.maintenanceDueDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_maintenance_due??!1,onChange:e=>f.mutate({on_maintenance_due:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.amsAlarms`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHumidityHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHumidityHighDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_ams_humidity_high??!1,onChange:e=>f.mutate({on_ams_humidity_high:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsTemperatureHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsTemperatureHighDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_ams_temperature_high??!1,onChange:e=>f.mutate({on_ams_temperature_high:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.amsHtAlarms`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHtHumidityHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHtHumidityHighDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_ams_ht_humidity_high??!1,onChange:e=>f.mutate({on_ams_ht_humidity_high:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHtTemperatureHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHtTemperatureHighDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_ams_ht_temperature_high??!1,onChange:e=>f.mutate({on_ams_ht_temperature_high:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.inventoryAlerts`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.stockReorderAlert`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.stockReorderAlertDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_stock_reorder_alert??!1,onChange:e=>f.mutate({on_stock_reorder_alert:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.stockBreakAlert`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.stockBreakAlertDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_stock_break_alert??!1,onChange:e=>f.mutate({on_stock_break_alert:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printQueue`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobAdded`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobAddedDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_added??!1,onChange:e=>f.mutate({on_queue_job_added:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobAssigned`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobAssignedDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_assigned??!1,onChange:e=>f.mutate({on_queue_job_assigned:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobStarted`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobStartedDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_started??!1,onChange:e=>f.mutate({on_queue_job_started:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobWaiting`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobWaitingDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_waiting??!0,onChange:e=>f.mutate({on_queue_job_waiting:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobSkipped`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobSkippedDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_skipped??!0,onChange:e=>f.mutate({on_queue_job_skipped:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobFailed`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobFailedDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_job_failed??!0,onChange:e=>f.mutate({on_queue_job_failed:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.queueComplete`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.queueCompleteDescription`)})]}),(0,K.jsx)(cU,{checked:e.on_queue_completed??!1,onChange:e=>f.mutate({on_queue_completed:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.quietHours`)})]}),(0,K.jsx)(cU,{checked:e.quiet_hours_enabled,onChange:e=>f.mutate({quiet_hours_enabled:e})})]}),e.quiet_hours_enabled&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.noNotificationsDuring`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[h(e.quiet_hours_start)||`22:00`,` - `,h(e.quiet_hours_end)||`07:00`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.editProviderToChangeQuietHours`)})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4 text-emerald-400`}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.dailyDigest`)})]}),(0,K.jsx)(cU,{checked:e.daily_digest_enabled,onChange:e=>f.mutate({daily_digest_enabled:e})})]}),e.daily_digest_enabled&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.batchNotifications`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.sendAt`,{time:h(e.daily_digest_time)||`08:00`})})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.editProviderToChangeDigestTime`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>t(e),className:`flex-1`,children:[(0,K.jsx)(_l,{className:`w-4 h-4`}),n(`notifications.edit`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>a(!0),className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})}),i&&(0,K.jsx)(Ad,{title:n(`notifications.deleteProvider`),message:n(`notifications.deleteConfirm`,{name:e.name}),confirmText:n(`notifications.delete`),variant:`danger`,onConfirm:()=>{p.mutate(),a(!1)},onCancel:()=>a(!1)})]})}var WVe=[`email`,`telegram`,`discord`,`ntfy`,`pushover`,`callmebot`,`webhook`,`homeassistant`];function GVe({provider:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,[a,o]=(0,y.useState)(e?.name||``),[s,c]=(0,y.useState)(e?.provider_type||`email`),[l,u]=(0,y.useState)(e?.printer_id||null),[d,f]=(0,y.useState)(e?.quiet_hours_enabled||!1),[p,m]=(0,y.useState)(e?.quiet_hours_start||`22:00`),[h,g]=(0,y.useState)(e?.quiet_hours_end||`07:00`),[_,v]=(0,y.useState)(e?.daily_digest_enabled||!1),[b,x]=(0,y.useState)(e?.daily_digest_time||`08:00`),[S,C]=(0,y.useState)(e?.on_print_start??!1),[w,T]=(0,y.useState)(e?.on_print_complete??!0),[E,D]=(0,y.useState)(e?.on_print_failed??!0),[O,k]=(0,y.useState)(e?.on_print_stopped??!0),[A,j]=(0,y.useState)(e?.on_print_progress??!1),[M,N]=(0,y.useState)(e?.on_printer_offline??!1),[P,F]=(0,y.useState)(e?.on_printer_error??!1),[I,L]=(0,y.useState)(e?.on_ai_failure_detection??!1),[R,z]=(0,y.useState)(e?.on_filament_low??!1),[B,V]=(0,y.useState)(e?.on_maintenance_due??!1),[ee,te]=(0,y.useState)(e?.on_stock_reorder_alert??!1),[ne,re]=(0,y.useState)(e?.on_stock_break_alert??!1),[ie,H]=(0,y.useState)(e?.on_bed_cooled??!1),[ae,oe]=(0,y.useState)(e?.on_first_layer_complete??!1),[U,se]=(0,y.useState)(e?.config?Object.fromEntries(Object.entries(e.config).filter(([e])=>e!==`event_priorities`).map(([e,t])=>[e,String(t)])):{}),[ce,le]=(0,y.useState)((()=>{let t=e?.config?.event_priorities;if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){let t=Number(r);Number.isInteger(t)&&t>=1&&t<=5&&(n[e]=t)}return n})()),[ue,de]=(0,y.useState)(null),[fe,pe]=(0,y.useState)(null),{data:me}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let he=J({mutationFn:()=>Q.testNotificationConfig({provider_type:s,config:U}),onSuccess:e=>{de(e),pe(null)},onError:e=>{de({success:!1,message:e.message})}}),ge=J({mutationFn:e=>Q.createNotificationProvider(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]}),t()},onError:e=>{pe(e.message)}}),_e=J({mutationFn:t=>Q.updateNotificationProvider(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]}),t()},onError:e=>{pe(e.message)}}),ve=e=>{if(e.preventDefault(),pe(null),!a.trim()){pe(n(`notifications.nameRequired`));return}let t=xe(s);for(let e of t)if(!U[e.key]?.trim()){pe(n(`notifications.fieldRequired`,{field:e.label}));return}let r=s===`ntfy`&&Object.keys(ce).length>0?{...U,event_priorities:ce}:U,o={name:a.trim(),provider_type:s,config:r,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?h:null,daily_digest_enabled:_,daily_digest_time:_?b:null,on_print_start:S,on_print_complete:w,on_print_failed:E,on_print_stopped:O,on_print_progress:A,on_printer_offline:M,on_printer_error:P,on_ai_failure_detection:I,on_filament_low:R,on_maintenance_due:B,on_stock_reorder_alert:ee,on_stock_break_alert:ne,on_bed_cooled:ie,on_first_layer_complete:ae};i?_e.mutate(o):ge.mutate(o)},ye=ge.isPending||_e.isPending,be=e=>{switch(e){case`callmebot`:return[{key:`phone`,label:`Phone Number`,placeholder:`+1234567890`,type:`text`,required:!0},{key:`apikey`,label:`API Key`,placeholder:`Your CallMeBot API key`,type:`text`,required:!0}];case`ntfy`:return[{key:`server`,label:`Server URL`,placeholder:`https://ntfy.sh`,type:`text`,required:!1},{key:`topic`,label:`Topic`,placeholder:`my-bambuddy`,type:`text`,required:!0},{key:`auth_token`,label:`Auth Token`,placeholder:`Optional authentication`,type:`password`,required:!1}];case`pushover`:return[{key:`user_key`,label:`User Key`,placeholder:`Your Pushover user key`,type:`text`,required:!0},{key:`app_token`,label:`App Token`,placeholder:`Your Pushover app token`,type:`text`,required:!0},{key:`priority`,label:`Priority`,placeholder:`0 (normal)`,type:`number`,required:!1}];case`telegram`:return[{key:`bot_token`,label:`Bot Token`,placeholder:`Bot token from @BotFather`,type:`password`,required:!0},{key:`chat_id`,label:`Chat ID`,placeholder:`Your chat or group ID`,type:`text`,required:!0}];case`email`:return[{key:`smtp_server`,label:`SMTP Server`,placeholder:`smtp.gmail.com`,type:`text`,required:!0},{key:`smtp_port`,label:`SMTP Port`,placeholder:`587`,type:`number`,required:!1},{key:`security`,label:`Security`,type:`select`,required:!1,options:[{value:`starttls`,label:`STARTTLS (Port 587)`},{value:`ssl`,label:`SSL/TLS (Port 465)`},{value:`none`,label:`None (Port 25)`}]},{key:`auth_enabled`,label:`Authentication`,type:`select`,required:!1,options:[{value:`true`,label:`Enabled`},{value:`false`,label:`Disabled`}]},{key:`username`,label:`Username`,placeholder:`your@email.com`,type:`text`,required:!1},{key:`password`,label:`Password`,placeholder:`App password`,type:`password`,required:!1},{key:`from_email`,label:`From Email`,placeholder:`your@email.com`,type:`text`,required:!0},{key:`to_email`,label:`To Email`,placeholder:`recipient@email.com`,type:`text`,required:!0}];case`discord`:return[{key:`webhook_url`,label:`Webhook URL`,placeholder:`https://discord.com/api/webhooks/...`,type:`text`,required:!0}];case`webhook`:return[{key:`webhook_url`,label:`Webhook URL`,placeholder:`https://example.com/webhook`,type:`text`,required:!0},{key:`payload_format`,label:`Payload Format`,type:`select`,required:!1,options:[{value:`generic`,label:`Generic JSON`},{value:`slack`,label:`Slack / Mattermost`}]},{key:`auth_header`,label:`Authorization`,placeholder:`Bearer token (optional)`,type:`password`,required:!1},{key:`field_title`,label:`Title Field Name`,placeholder:`title`,type:`text`,required:!1,showIf:e=>e.payload_format!==`slack`},{key:`field_message`,label:`Message Field Name`,placeholder:`message`,type:`text`,required:!1,showIf:e=>e.payload_format!==`slack`}];case`homeassistant`:return[{key:`service`,label:`Home Assistant Service`,placeholder:`notify.mobile_app_myphone`,type:`text`,required:!1}];default:return[]}},xe=e=>be(e).filter(e=>e.required),Se=be(s);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(i?`notifications.editTitle`:`notifications.addTitle`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:ve,className:`p-6 space-y-4`,children:[fe&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:fe}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`notifications.namePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.providerTypeLabel`)}),(0,K.jsx)(`select`,{value:s,onChange:e=>{c(e.target.value),se({}),de(null)},disabled:i,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`,children:WVe.map(e=>(0,K.jsx)(`option`,{value:e,children:n(`notifications.providerTypes.${e}`,e)},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.providerDescriptions.${s}`,``)})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.configuration`)}),Se.filter(e=>!(`showIf`in e)||e.showIf?.(U)!==!1).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[e.label,` `,e.required&&`*`]}),e.type===`select`&&`options`in e&&e.options?(0,K.jsx)(`select`,{value:U[e.key]||e.options[0]?.value||``,onChange:t=>{se({...U,[e.key]:t.target.value}),de(null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:e.options.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,K.jsx)(`input`,{type:e.type,value:U[e.key]||``,onChange:t=>{se({...U,[e.key]:t.target.value}),de(null)},placeholder:e.placeholder,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]},e.key))]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>{de(null),he.mutate()},disabled:he.isPending||xe(s).length>0&&!U[xe(s)[0]?.key],className:`flex-1`,children:[he.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),n(`notifications.testConfiguration`)]})}),ue&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg flex items-center gap-2 ${ue.success?`bg-bambu-green/20 border border-bambu-green/50 text-bambu-green`:`bg-red-500/20 border border-red-500/50 text-red-400`}`,children:ue.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:ue.message})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ys,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:ue.message})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.printerFilter`)}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:n(`notifications.allPrinters`)}),me?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.onlyFromPrinter`)})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-sm text-white`,children:n(`notifications.quietHoursDnd`)}),(0,K.jsx)(cU,{checked:d,onChange:f})]}),d&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.quietStart`)}),(0,K.jsx)(`input`,{type:`time`,value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.quietEnd`)}),(0,K.jsx)(`input`,{type:`time`,value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white`,children:n(`notifications.dailyDigestLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.batchNotifications`)})]}),(0,K.jsx)(cU,{checked:_,onChange:v})]}),_&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.sendDigestAt`)}),(0,K.jsx)(`input`,{type:`time`,value:b,onChange:e=>x(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.digestCollected`)})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.notificationEvents`)}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.printEvents`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.start`)}),(0,K.jsx)(cU,{checked:S,onChange:C})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.complete`)}),(0,K.jsx)(cU,{checked:w,onChange:T})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.failed`)}),(0,K.jsx)(cU,{checked:E,onChange:D})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stopped`)}),(0,K.jsx)(cU,{checked:O,onChange:k})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.progress`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.progressPercent`)})]}),(0,K.jsx)(cU,{checked:A,onChange:j})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.bedCooled`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.bedCooledAfterPrint`)})]}),(0,K.jsx)(cU,{checked:ie,onChange:H})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.firstLayerCompleteLabel`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.firstLayerCompleteDescription`)})]}),(0,K.jsx)(cU,{checked:ae,onChange:oe})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.printerStatus`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.offline`)}),(0,K.jsx)(cU,{checked:M,onChange:N})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.error`)}),(0,K.jsx)(cU,{checked:P,onChange:F})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.aiFailureDetection`)}),(0,K.jsx)(cU,{checked:I,onChange:L})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.lowFilament`)}),(0,K.jsx)(cU,{checked:R,onChange:z})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.maintenance`)}),(0,K.jsx)(cU,{checked:B,onChange:V})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.inventoryAlerts`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stockReorderAlert`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.stockReorderAlertDescription`)})]}),(0,K.jsx)(cU,{checked:ee,onChange:te})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stockBreakAlert`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.stockBreakAlertDescription`)})]}),(0,K.jsx)(cU,{checked:ne,onChange:re})]})]})]}),s===`ntfy`&&(()=>{let e=[];return S&&e.push({key:`on_print_start`,label:n(`notifications.start`)}),w&&e.push({key:`on_print_complete`,label:n(`notifications.complete`)}),E&&e.push({key:`on_print_failed`,label:n(`notifications.failed`)}),O&&e.push({key:`on_print_stopped`,label:n(`notifications.stopped`)}),A&&e.push({key:`on_print_progress`,label:n(`notifications.progress`)}),ie&&e.push({key:`on_bed_cooled`,label:n(`notifications.bedCooled`)}),ae&&e.push({key:`on_first_layer_complete`,label:n(`notifications.firstLayerCompleteLabel`)}),M&&e.push({key:`on_printer_offline`,label:n(`notifications.offline`)}),P&&e.push({key:`on_printer_error`,label:n(`notifications.error`)}),I&&e.push({key:`on_ai_failure_detection`,label:n(`notifications.aiFailureDetection`)}),R&&e.push({key:`on_filament_low`,label:n(`notifications.lowFilament`)}),B&&e.push({key:`on_maintenance_due`,label:n(`notifications.maintenance`)}),ee&&e.push({key:`on_stock_reorder_alert`,label:n(`notifications.stockReorderAlert`)}),ne&&e.push({key:`on_stock_break_alert`,label:n(`notifications.stockBreakAlert`)}),e.length===0?null:(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-1`,children:n(`notifications.eventPriority.sectionTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:n(`notifications.eventPriority.helpNtfy`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.label}),(0,K.jsxs)(`select`,{value:ce[e.key]??3,onChange:t=>{let n=Number(t.target.value);le(t=>({...t,[e.key]:n}))},className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:1,children:n(`notifications.eventPriority.min`)}),(0,K.jsx)(`option`,{value:2,children:n(`notifications.eventPriority.low`)}),(0,K.jsx)(`option`,{value:3,children:n(`notifications.eventPriority.default`)}),(0,K.jsx)(`option`,{value:4,children:n(`notifications.eventPriority.high`)}),(0,K.jsx)(`option`,{value:5,children:n(`notifications.eventPriority.urgent`)})]})]},e.key))})]})})()]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`notifications.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:ye,className:`flex-1`,children:[ye?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),n(i?`notifications.save`:`notifications.add`)]})]})]})]})})}function KVe({template:e,onClose:t}){let{t:n}=W(),r=no(),i=(0,y.useRef)(null),[a,o]=(0,y.useState)(e.title_template),[s,c]=(0,y.useState)(e.body_template),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!0),{data:p}=q({queryKey:[`template-variables`],queryFn:Q.getTemplateVariables}),m=p?.find(t=>t.event_type===e.event_type),{data:h,isLoading:g}=q({queryKey:[`template-preview`,e.event_type,a,s],queryFn:()=>Q.previewTemplate({event_type:e.event_type,title_template:a,body_template:s}),enabled:d&&a.length>0&&s.length>0});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let _=J({mutationFn:t=>Q.updateNotificationTemplate(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-templates`]}),t()},onError:e=>{u(e.message)}}),v=J({mutationFn:()=>Q.resetNotificationTemplate(e.id),onSuccess:e=>{o(e.title_template),c(e.body_template),r.invalidateQueries({queryKey:[`notification-templates`]})},onError:e=>{u(e.message)}}),b=e=>{if(e.preventDefault(),u(null),!a.trim()){u(n(`notifications.titleRequired`));return}if(!s.trim()){u(n(`notifications.bodyRequired`));return}_.mutate({title_template:a,body_template:s})},x=e=>{let t=i.current;if(!t)return;let n=t.selectionStart,r=t.selectionEnd,a=s,o=a.substring(0,n),l=a.substring(r);c(o+`{${e}}`+l),setTimeout(()=>{t.focus();let r=n+e.length+2;t.setSelectionRange(r,r)},0)},S=a!==e.title_template||s!==e.body_template;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`notifications.editTemplate`,{name:e.name})}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`form`,{onSubmit:b,className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[l&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm`,children:l}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:n(`notifications.titleLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green`,placeholder:n(`notifications.titlePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:n(`notifications.bodyLabel`)}),(0,K.jsx)(`textarea`,{ref:i,value:s,onChange:e=>c(e.target.value),rows:4,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none`,placeholder:n(`notifications.bodyPlaceholder`)})]}),m&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-2`,children:n(`notifications.availableVariables`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.variables.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>x(e),className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(Sl,{className:`w-3 h-3`}),e]},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:n(`notifications.clickToInsert`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm font-medium text-bambu-gray flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),n(`notifications.livePreview`)]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>f(!d),className:`text-xs text-bambu-green hover:text-bambu-green-light`,children:n(d?`notifications.hide`:`notifications.show`)})]}),d&&(0,K.jsx)(`div`,{className:`bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2`,children:g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`notifications.loadingPreview`)]}):h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.titlePreview`)}),(0,K.jsx)(`div`,{className:`text-white font-medium`,children:h.title})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.bodyPreview`)}),(0,K.jsx)(`div`,{className:`text-white whitespace-pre-wrap text-sm`,children:h.body})]})]}):(0,K.jsx)(`div`,{className:`text-bambu-gray text-sm`,children:n(`notifications.enterTemplateContent`)})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)($,{type:`button`,variant:`ghost`,onClick:()=>v.mutate(),disabled:v.isPending,className:`text-orange-400 hover:text-orange-300`,children:[v.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Al,{className:`w-4 h-4 mr-2`}),n(`notifications.resetToDefault`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:n(`notifications.cancel`)}),(0,K.jsxs)($,{onClick:b,disabled:_.isPending||!S,children:[_.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Nl,{className:`w-4 h-4 mr-2`}),n(`notifications.save`)]})]})]})]})})}var qVe={print_start:`text-blue-400`,print_complete:`text-bambu-green`,print_failed:`text-red-400`,print_stopped:`text-orange-400`,print_progress:`text-yellow-400`,printer_offline:`text-gray-400`,printer_error:`text-rose-400`,filament_low:`text-cyan-400`,maintenance_due:`text-purple-400`,test:`text-bambu-gray`};function JVe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(7),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),{data:u}=q({queryKey:[`settings`],queryFn:Q.getSettings}),d=u?.time_format||`system`,{data:f,isLoading:p,refetch:m,isRefetching:h}=q({queryKey:[`notification-logs`,i,c],queryFn:()=>Q.getNotificationLogs({days:i,limit:100,success:c?!1:void 0})}),{data:g}=q({queryKey:[`notification-log-stats`,i],queryFn:()=>Q.getNotificationLogStats(i)}),_=J({mutationFn:()=>Q.clearNotificationLogs(30),onSuccess:e=>{r(e.message,`success`),n.invalidateQueries({queryKey:[`notification-logs`]}),n.invalidateQueries({queryKey:[`notification-log-stats`]})},onError:e=>{r(`Failed to clear logs: ${e.message}`,`error`)}}),v=e=>{let n=vf(e);if(!n)return``;let r=new Date().getTime()-n.getTime();return r<6e4?t(`notifications.justNow`):r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:n.toLocaleDateString()+` `+xf(n,d)};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t(`notifications.notificationLog`)})]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:`×`})]}),g&&(0,K.jsx)(`div`,{className:`px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-6 text-sm`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[t(`notifications.statsSummary`,{days:i}),` `,(0,K.jsx)(`span`,{className:`text-white font-medium`,children:g.total}),` `,t(`notifications.statsNotifications`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,K.jsx)(ps,{className:`w-4 h-4`}),t(`notifications.statsSent`,{count:g.success_count})]}),g.failure_count>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-4 h-4`}),t(`notifications.statsFailed`,{count:g.failure_count})]})]})}),(0,K.jsxs)(`div`,{className:`px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4`,children:[(0,K.jsxs)(`select`,{value:i,onChange:e=>a(Number(e.target.value)),className:`px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green`,children:[(0,K.jsx)(`option`,{value:1,children:t(`notifications.last24Hours`)}),(0,K.jsx)(`option`,{value:7,children:t(`notifications.last7Days`)}),(0,K.jsx)(`option`,{value:30,children:t(`notifications.last30Days`)}),(0,K.jsx)(`option`,{value:90,children:t(`notifications.last90Days`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),t(`notifications.showFailedOnly`)]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>m(),disabled:h,children:[h?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),t(`notifications.refresh`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>_.mutate(),disabled:_.isPending,className:`text-red-400 hover:text-red-300`,children:[_.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),t(`notifications.clearOld`)]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:p?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):f&&f.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:f.map(e=>(0,K.jsx)(YVe,{log:e,isExpanded:o===e.id,onToggle:()=>s(o===e.id?null:e.id),formatDate:v,formatFullDate:e=>bf(e,d)},e.id))}):(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(kc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:t(c?`notifications.noFailedNotifications`:`notifications.noNotificationsLogged`)})]})})]})})}function YVe({log:e,isExpanded:t,onToggle:n,formatDate:r,formatFullDate:i}){let{t:a}=W();return(0,K.jsxs)(`div`,{className:`border rounded-lg overflow-hidden transition-colors ${e.success?`border-bambu-dark-tertiary bg-bambu-dark/30`:`border-red-500/30 bg-red-500/5`}`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors`,onClick:n,children:[e.success?(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green shrink-0`}):(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium ${qVe[e.event_type]||`text-bambu-gray`}`,children:a(`notifications.eventTypes.${e.event_type}`,e.event_type)}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate flex-1`,children:e.provider_name||a(`notifications.unknownProvider`)}),e.printer_name&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.printer_name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:r(e.created_at)}),t?(0,K.jsx)(cs,{className:`w-4 h-4 text-bambu-gray shrink-0`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0`})]}),t&&(0,K.jsxs)(`div`,{className:`px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:a(`notifications.logTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.title})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:a(`notifications.logMessage`)}),(0,K.jsx)(`p`,{className:`text-sm text-white whitespace-pre-wrap`,children:e.message})]}),!e.success&&e.error_message&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-red-400 mb-1`,children:a(`notifications.logError`)}),(0,K.jsx)(`p`,{className:`text-sm text-red-300`,children:e.error_message})]}),(0,K.jsxs)(`div`,{className:`flex gap-4 text-xs text-bambu-gray pt-1`,children:[(0,K.jsx)(`span`,{children:a(`notifications.logProvider`,{type:e.provider_type})}),(0,K.jsx)(`span`,{children:a(`notifications.logTime`,{time:i(e.created_at)})})]})]})]})}var XVe=Object.defineProperty,v3=Object.getOwnPropertySymbols,y3=Object.prototype.hasOwnProperty,b3=Object.prototype.propertyIsEnumerable,x3=(e,t,n)=>t in e?XVe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S3=(e,t)=>{for(var n in t||={})y3.call(t,n)&&x3(e,n,t[n]);if(v3)for(var n of v3(t))b3.call(t,n)&&x3(e,n,t[n]);return e},C3=(e,t)=>{var n={};for(var r in e)y3.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&v3)for(var r of v3(e))t.indexOf(r)<0&&b3.call(e,r)&&(n[r]=e[r]);return n},w3;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],et.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.lengthm[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;ne+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.lengtht.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e=1<{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(w3||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(w3||={});var T3=w3,ZVe={L:T3.QrCode.Ecc.LOW,M:T3.QrCode.Ecc.MEDIUM,Q:T3.QrCode.Ecc.QUARTILE,H:T3.QrCode.Ecc.HIGH},E3=128,D3=`L`,O3=`#FFFFFF`,k3=`#000000`,A3=!1,j3=1,QVe=4,$Ve=0,eHe=.1;function M3(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function N3(e,t){return e.slice().map((e,n)=>n=t.y+t.h?e:e.map((e,n)=>n=t.x+t.w?e:!1))}function tHe(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*eHe),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function nHe(e,t){return t==null?e?QVe:$Ve:Math.max(Math.floor(t),0)}function P3({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=y.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...T3.QrSegment.makeSegments(t)),e),[]);return T3.QrCode.encodeSegments(r,ZVe[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=y.useMemo(()=>{let e=c.getModules(),t=nHe(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:tHe(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var rHe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),iHe=y.forwardRef(function(e,t){let n=e,{value:r,size:i=E3,level:a=D3,bgColor:o=O3,fgColor:s=k3,includeMargin:c=A3,minVersion:l=j3,boostLevel:u,marginSize:d,imageSettings:f}=n,p=C3(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=C3(p,[`style`]),g=f?.src,_=y.useRef(null),v=y.useRef(null),b=y.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=y.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=P3({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});y.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=v.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=N3(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,rHe?t.fill(new Path2D(M3(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),y.useEffect(()=>{S(!1)},[g]);let D=S3({height:i,width:i},m),O=null;return g!=null&&(O=y.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:v,crossOrigin:E?.crossOrigin})),y.createElement(y.Fragment,null,y.createElement(`canvas`,S3({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});iHe.displayName=`QRCodeCanvas`;var F3=y.forwardRef(function(e,t){let n=e,{value:r,size:i=E3,level:a=D3,bgColor:o=O3,fgColor:s=k3,includeMargin:c=A3,minVersion:l=j3,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=C3(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=P3({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&v!=null&&(v.excavation!=null&&(b=N3(g,v.excavation)),x=y.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let S=M3(b,h);return y.createElement(`svg`,S3({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&y.createElement(`title`,null,d),y.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),y.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});F3.displayName=`QRCodeSVG`;function aHe(e,t){return`bambuddy://config?v=1&url=${encodeURIComponent(e)}&key=${encodeURIComponent(t)}`}function oHe({apiKey:e,baseUrl:t,onClose:n}){let{t:r}=W(),i=aHe(t??window.location.origin,e);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`settings.apiKeyQrTitle`)}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 flex flex-col items-center`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 text-center`,children:r(`settings.apiKeyQrCaption`)}),(0,K.jsx)(`div`,{className:`bg-white p-4 rounded-lg mb-4`,children:(0,K.jsx)(F3,{value:i,size:256})}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-amber-400 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:r(`settings.apiKeyQrWarning`)})]}),(0,K.jsx)($,{onClick:n,className:`w-full`,children:r(`common.close`)})]})]})})}var sHe=300,I3=2;function L3({onSuccess:e}){let{t}=W(),n=no(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=r.trim();if(e.lengtho(e),sHe);return()=>clearTimeout(t)},[r]),(0,y.useEffect)(()=>{c(null),u(null)},[a]);let d=q({queryKey:[`ldap-search`,a],queryFn:()=>Q.searchLDAPDirectory(a),enabled:a.length>=I3,staleTime:3e4}),f=J({mutationFn:e=>Q.provisionLDAPUser(e),onSuccess:t=>{n.invalidateQueries({queryKey:[`users`]}),e(t)},onError:e=>{u(e.message||t(`users.modal.ldapErrorProvision`))}}),p=(0,y.useMemo)(()=>d.data?.find(e=>e.dn===s)??null,[d.data,s]),m=r.trim().length>0&&r.trim().length=I3,g=!!d.data&&d.data.length>0,_=!h&&!!d.data&&d.data.length===0&&a.length>=I3;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:t(`users.modal.ldapSearchLabel`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2`}),(0,K.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),className:`w-full pl-9 pr-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:t(`users.modal.ldapSearchPlaceholder`),autoComplete:`off`})]}),m&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:t(`users.modal.ldapMinChars`)})]}),(0,K.jsxs)(`div`,{className:`min-h-[8rem] max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[h&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}),(0,K.jsx)(`span`,{children:t(`users.modal.ldapSearching`)})]}),_&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray text-sm`,children:t(`users.modal.ldapNoResults`)}),d.isError&&(0,K.jsx)(`div`,{className:`px-3 py-4 text-sm text-red-400`,children:d.error instanceof Error?d.error.message:t(`users.modal.ldapSearchError`)}),!h&&g&&(0,K.jsx)(`ul`,{className:`divide-y divide-bambu-dark-tertiary`,children:d.data.map(e=>(0,K.jsx)(cHe,{result:e,selected:s===e.dn,onSelect:()=>c(e.dn)},e.dn))}),!h&&!d.data&&!d.isError&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray text-sm`,children:t(`users.modal.ldapTypeToSearch`)})]}),p&&(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[t(`users.modal.ldapSelectedLabel`),`: `]}),(0,K.jsx)(`span`,{className:`font-medium`,children:p.username}),p.display_name&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` — `,p.display_name]})]}),p.email&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:p.email}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray break-all`,children:p.dn})]}),l&&(0,K.jsx)(`div`,{className:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-red-400`,children:l})}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)($,{onClick:()=>{!p||p.already_provisioned||(u(null),f.mutate(p.username))},disabled:!p||p.already_provisioned||f.isPending,children:f.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),t(`users.modal.ldapProvisioning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),t(`users.modal.ldapProvision`)]})})})]})}function cHe({result:e,selected:t,onSelect:n}){let{t:r}=W(),i=e.already_provisioned;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,disabled:i,className:`w-full text-left px-3 py-2 flex items-center gap-3 transition-colors ${i?`opacity-50 cursor-not-allowed`:t?`bg-bambu-green/10`:`hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-white truncate`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.username}),e.display_name&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` — `,e.display_name]})]}),e.email&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.email})]}),i&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray whitespace-nowrap`,children:[(0,K.jsx)(ms,{className:`w-3.5 h-3.5`}),r(`users.modal.ldapAlreadyProvisioned`)]})]})})}function lHe({formData:e,setFormData:t,groups:n,onClose:r,onCreate:i,isCreating:a,isCreateButtonDisabled:o,ldapEnabled:s=!1,onLdapProvisioned:c}){let{t:l}=W(),[u,d]=(0,y.useState)(`local`);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let f=n=>{t({...e,group_ids:e.group_ids.includes(n)?e.group_ids.filter(e=>e!==n):[...e.group_ids,n]})};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:r,children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:l(`users.modal.createUser`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray ml-7`,children:l(`users.modal.advancedAuthSubtitle`)||`with Advanced Authentication`})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[s&&(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-1 p-1 bg-bambu-dark-secondary rounded-lg`,role:`tablist`,"aria-label":l(`users.modal.tabsAriaLabel`),children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`local`,onClick:()=>d(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${u===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:l(`users.modal.localTab`)}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`ldap`,onClick:()=>d(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${u===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:l(`users.modal.ldapTab`)})]}),u===`ldap`&&s?(0,K.jsx)(L3,{onSuccess:e=>{c?.(e)}}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[l(`users.form.username`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:e.username,onChange:n=>t({...e,username:n.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:l(`users.form.usernamePlaceholder`),autoComplete:`username`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[l(`users.form.email`)||`Email`,` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`email`,value:e.email,onChange:n=>t({...e,email:n.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:l(`users.form.emailPlaceholder`)||`user@example.com`,required:!0})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:l(`users.form.autoGeneratedPassword`)||`A secure password will be automatically generated and emailed to the user.`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:l(`users.form.groups`)}),(0,K.jsxs)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[n.map(t=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.group_ids.includes(t.id),onChange:()=>f(t.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:t.name}),t.is_system&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400`,children:[`(`,l(`users.system`),`)`]})]},t.id)),n.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:l(`users.noGroupsAvailable`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:r,children:l(`users.modal.cancel`)}),u===`local`&&(0,K.jsx)($,{onClick:i,disabled:o,children:a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),l(`users.modal.creating`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),l(`users.modal.createUser`)]})})]})]})]})})}function uHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`auto`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!0),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),{data:E,isLoading:D}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings}),{data:O,isLoading:k,refetch:A}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,refetchInterval:3e4}),{data:j}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{E&&(i(E.spoolman_enabled===`true`),o(E.spoolman_url||``),c(E.spoolman_sync_mode||`auto`),u(E.spoolman_disable_weight_sync===`true`),f(E.spoolman_report_partial_usage!==`false`),m(E.auto_add_unknown_rfid!==`false`),v(!0))},[E]),(0,y.useEffect)(()=>{if(!(!_||!E)&&(E.spoolman_enabled===`true`!==r||(E.spoolman_url||``)!==a||(E.spoolman_sync_mode||`auto`)!==s||E.spoolman_disable_weight_sync===`true`!==l||E.spoolman_report_partial_usage!==`false`!==d||E.auto_add_unknown_rfid!==`false`!==p)){let e=setTimeout(()=>{M.mutate()},500);return()=>clearTimeout(e)}},[r,a,s,l,d,p,_]);let M=J({mutationFn:()=>Q.updateSpoolmanSettings({spoolman_enabled:r?`true`:`false`,spoolman_url:a,spoolman_sync_mode:s,spoolman_disable_weight_sync:l?`true`:`false`,spoolman_report_partial_usage:d?`true`:`false`,auto_add_unknown_rfid:p?`true`:`false`}),onSuccess:()=>{t.invalidateQueries({queryKey:[`spoolman-settings`]}),t.invalidateQueries({queryKey:[`spoolman-status`]}),t.invalidateQueries({queryKey:[`spool-assignments`]}),t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`spoolman-inventory-filaments`]}),n(e(`settings.toast.settingsSaved`))},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),N=J({mutationFn:Q.connectSpoolman,onSuccess:()=>{A()},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),P=J({mutationFn:Q.disconnectSpoolman,onSuccess:()=>{A()},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),F=J({mutationFn:Q.syncAllPrintersAms,onSuccess:t=>{n(e(`settings.spoolmanAmsSyncSuccess`,{synced:t.synced_count,skipped:0}),`success`)},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),I=J({mutationFn:e=>Q.syncPrinterAms(e),onSuccess:t=>{n(e(`settings.spoolmanAmsSyncSuccess`,{synced:t.synced_count,skipped:0}),`success`)},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),L=()=>{h===`all`?F.mutate():I.mutate(h)},R=J({mutationFn:Q.syncWeightsFromAms,onSuccess:r=>{t.invalidateQueries({queryKey:[`spools`]}),t.invalidateQueries({queryKey:[`inventory-spools`]}),n(e(`settings.amsSyncSuccess`,{synced:r.synced,skipped:r.skipped}),`success`),C(!1)},onError:()=>{n(e(`settings.amsSyncError`),`error`),C(!1)}}),z=J({mutationFn:Q.syncSpoolmanAmsWeights,onSuccess:r=>{t.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),n(e(`settings.spoolmanAmsSyncSuccess`,{synced:r.synced,skipped:r.skipped}),`success`),T(!1)},onError:t=>{t instanceof Uu&&t.status===503?n(e(`settings.spoolmanAmsSyncErrorUnreachable`),`error`):t instanceof Uu&&t.status===400?n(e(`settings.spoolmanAmsSyncErrorNotConfigured`),`error`):n(e(`settings.spoolmanAmsSyncError`),`error`),T(!1)}}),B=F.isPending||I.isPending,V=h===`all`?F.data:I.data,ee=h===`all`?F.isSuccess:I.isSuccess;return D?(0,K.jsxs)(_d,{id:`card-spoolman`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.filamentTracking`)})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})})})]}):(0,K.jsxs)(_d,{id:`card-spoolman`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.filamentTracking`)})]}),M.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.filamentTrackingDesc`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50`:`border-bambu-green bg-bambu-green/10`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 ${r?`text-bambu-gray`:`text-bambu-green`}`}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${r?`text-bambu-gray`:`text-white`}`,children:e(`settings.trackingModeBuiltIn`)})]}),(0,K.jsx)(`p`,{className:`text-xs ${r?`text-bambu-gray/60`:`text-bambu-gray`}`,children:e(`settings.trackingModeBuiltInDesc`)}),!r&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:e(`common.enabled`)})]})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(Js,{className:`w-4 h-4 ${r?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${r?`text-white`:`text-bambu-gray`}`,children:`Spoolman`})]}),(0,K.jsx)(`p`,{className:`text-xs ${r?`text-bambu-gray`:`text-bambu-gray/60`}`,children:e(`settings.trackingModeSpoolmanDesc`)}),r&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:e(`common.enabled`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`pr-4`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`settings.autoAddUnknownRfid`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.autoAddUnknownRfidDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),!r&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5`}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:(0,K.jsxs)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:[(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureRfid`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureUsage`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureCatalog`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureThirdParty`)})]})})]})}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>C(!0),disabled:R.isPending,children:[R.isPending?(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4 mr-2`}),e(`settings.amsSyncButton`)]})]}),r&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs text-blue-300`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:e(`settings.howSyncWorks`)}),(0,K.jsxs)(`ul`,{className:`list-disc list-inside space-y-0.5 text-blue-300/80`,children:[(0,K.jsx)(`li`,{children:e(`settings.syncInfoRfidOnly`)}),(0,K.jsx)(`li`,{children:e(`settings.syncInfoAutoCreate`)}),(0,K.jsx)(`li`,{children:e(`settings.syncInfoThirdPartySkipped`)})]}),(0,K.jsx)(`p`,{className:`font-medium mt-2 mb-1`,children:e(`settings.linkingExistingSpools`)}),(0,K.jsx)(`p`,{className:`text-blue-300/80`,children:e(`settings.linkingExistingSpoolsDesc`)})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`settings.spoolmanUrl`)}),(0,K.jsx)(`input`,{type:`text`,placeholder:`http://192.168.1.100:7912`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.spoolmanUrlHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`settings.syncMode`)}),(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`auto`,children:e(`settings.syncModeAuto`)}),(0,K.jsx)(`option`,{value:`manual`,children:e(`settings.syncModeManual`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(s===`auto`?`settings.syncModeAutoDesc`:`settings.syncModeManualDesc`)})]}),s===`auto`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`spoolman.disableWeightSync`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`spoolman.disableWeightSyncDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),l&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`spoolman.reportPartialUsage`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`spoolman.reportPartialUsageDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`settings.status`),`:`]}),k?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin`}):O?.connected?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-green-500`,children:[(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`settings.spoolmanConnected`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-red-500`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),e(`settings.spoolmanDisconnected`)]})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:O?.connected?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>P.mutate(),disabled:P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Bc,{className:`w-4 h-4`}),e(`settings.disconnect`)]}):(0,K.jsxs)($,{size:`sm`,onClick:()=>N.mutate(),disabled:N.isPending||!a,children:[N.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vc,{className:`w-4 h-4`}),e(`settings.connect`)]})})]}),(N.isError||P.isError)&&(0,K.jsx)(`div`,{className:`mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:(N.error||P.error).message}),O?.connected&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(`settings.syncAmsData`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e(`settings.syncAmsDataDesc`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value===`all`?`all`:Number(e.target.value)),className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`settings.allPrinters`)}),j?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(is,{className:`absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:L,disabled:B,children:[B?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`spoolman.sync`)]})]})]}),O?.connected&&(0,K.jsx)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(`settings.spoolmanAmsSyncButton`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e(`settings.spoolmanAmsSyncMessage`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>T(!0),disabled:z.isPending,children:[z.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),z.isPending?e(`settings.spoolmanAmsSyncing`):e(`settings.spoolmanAmsSyncButton`)]})]})}),ee&&V&&(0,K.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded text-sm ${V.success?`bg-green-500/20 border border-green-500/50 text-green-400`:`bg-yellow-500/20 border border-yellow-500/50 text-yellow-400`}`,children:V.success?`Synced ${V.synced_count} spool${V.synced_count===1?``:`s`} successfully`:`Synced ${V.synced_count} spool${V.synced_count===1?``:`s`} with ${V.errors.length} error${V.errors.length===1?``:`s`}`}),V.skipped_count>0&&(0,K.jsxs)(`div`,{className:`p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-amber-400 mb-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[V.skipped_count,` spool`,V.skipped_count===1?``:`s`,` skipped`]})]}),V.skipped_count>5&&(0,K.jsx)(`button`,{onClick:()=>x(!b),className:`text-xs text-amber-400 hover:text-amber-300 underline`,children:b?`Show less`:`Show all`})]}),(0,K.jsxs)(`ul`,{className:`text-xs text-amber-300/80 space-y-0.5`,children:[(b?V.skipped:V.skipped.slice(0,5)).map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.color&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:`#${e.color}`}}),(0,K.jsx)(`span`,{children:e.location}),(0,K.jsxs)(`span`,{className:`text-amber-300/60`,children:[`- `,e.reason]})]},t)),!b&&V.skipped_count>5&&(0,K.jsxs)(`li`,{className:`text-amber-300/60 italic`,children:[`...and `,V.skipped_count-5,` more`]})]})]}),V.errors.length>0&&(0,K.jsxs)(`div`,{className:`p-2 bg-red-500/10 border border-red-500/30 rounded text-sm`,children:[(0,K.jsx)(`div`,{className:`text-red-400 font-medium mb-1`,children:`Errors:`}),(0,K.jsx)(`ul`,{className:`text-xs text-red-300/80 space-y-0.5`,children:V.errors.map((e,t)=>(0,K.jsx)(`li`,{children:e},t))})]})]})]})]})]}),S&&(0,K.jsx)(Ad,{title:e(`settings.amsSyncTitle`),message:e(`settings.amsSyncMessage`),confirmText:e(`settings.amsSyncButton`),variant:`warning`,isLoading:R.isPending,loadingText:e(`settings.amsSyncing`),onConfirm:()=>R.mutate(),onCancel:()=>C(!1)}),w&&(0,K.jsx)(Ad,{title:e(`settings.spoolmanAmsSyncTitle`),message:e(`settings.spoolmanAmsSyncMessage`),confirmText:e(`settings.spoolmanAmsSyncButton`),variant:`warning`,isLoading:z.isPending,loadingText:e(`settings.spoolmanAmsSyncing`),onConfirm:()=>z.mutate(),onCancel:()=>T(!1)})]})}function dHe(){let{t:e}=W(),{showToast:t}=Td(),[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(new Set),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(!1),O=(0,y.useCallback)(async()=>{try{r(await Q.getSpoolCatalog())}catch(n){console.error(`SpoolCatalogSettings.loadCatalog failed:`,n),t(e(`settings.catalog.loadFailed`),`error`)}finally{a(!1)}},[t,e]);(0,y.useEffect)(()=>{O()},[O]);let k=n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),A=async()=>{if(!p.trim()||!h){t(e(`settings.catalog.nameWeightRequired`),`error`);return}v(!0);try{let n=await Q.addCatalogEntry({name:p.trim(),weight:parseInt(h)});r(e=>[...e,n].sort((e,t)=>e.name.localeCompare(t.name))),u(!1),m(``),g(``),t(e(`settings.catalog.entryAdded`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleAdd failed:`,n),t(e(`settings.catalog.addFailed`),`error`)}finally{v(!1)}},j=e=>{f(e.id),m(e.name),g(e.weight.toString())},M=()=>{f(null),m(``),g(``)},N=async n=>{if(!p.trim()||!h){t(e(`settings.catalog.nameWeightRequired`),`error`);return}v(!0);try{let i=await Q.updateCatalogEntry(n,{name:p.trim(),weight:parseInt(h)});r(e=>e.map(e=>e.id===n?i:e).sort((e,t)=>e.name.localeCompare(t.name))),f(null),m(``),g(``),t(e(`settings.catalog.entryUpdated`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleUpdate failed:`,n),t(e(`settings.catalog.updateFailed`),`error`)}finally{v(!1)}},P=async()=>{if(w)try{await Q.deleteCatalogEntry(w.id),r(e=>e.filter(e=>e.id!==w.id)),t(e(`settings.catalog.entryDeleted`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleDelete failed:`,n),t(e(`settings.catalog.deleteFailed`),`error`)}finally{T(null)}},F=async()=>{D(!1),a(!0);try{await Q.resetSpoolCatalog(),await O(),t(e(`settings.catalog.resetSuccess`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleReset failed:`,n),t(e(`settings.catalog.resetFailed`),`error`),a(!1)}},I=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(_d,{id:`card-spool-catalog`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.catalog.spoolCatalog`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,n.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>{let r=n.map(({name:e,weight:t})=>({name:e,weight:t})),i=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`spool-catalog.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),t(e(`settings.catalog.exported`,{count:n.length}),`success`)},className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.exportTooltip`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.export`)})]}),(0,K.jsxs)(`button`,{onClick:()=>c.current?.click(),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.importTooltip`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.import`)})]}),(0,K.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,onChange:async i=>{let a=i.target.files?.[0];if(a){try{let i=await a.text(),o=JSON.parse(i);if(!Array.isArray(o))throw Error(`Invalid format`);let s=0,c=0;for(let e of o){if(!e.name||typeof e.weight!=`number`){c++;continue}if(n.some(t=>t.name.toLowerCase()===e.name.toLowerCase())){c++;continue}try{let t=await Q.addCatalogEntry({name:e.name,weight:e.weight});r(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),s++}catch(e){console.error(`SpoolCatalogSettings import item failed:`,e),c++}}t(e(`settings.catalog.imported`,{added:s,skipped:c}),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleImport failed:`,n),t(e(`settings.catalog.importFailed`),`error`)}c.current&&(c.current.value=``)}}}),(0,K.jsxs)(`button`,{onClick:()=>D(!0),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.resetTooltip`),children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.reset`)})]}),(0,K.jsxs)(`button`,{onClick:()=>u(!0),className:`px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.add`)})]})]}),b.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-sm text-red-400`,children:e(`settings.catalog.selectedCount`,{count:b.size})}),(0,K.jsxs)(`button`,{onClick:()=>C(!0),className:`ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.catalog.deleteSelected`)]}),(0,K.jsx)(`button`,{onClick:()=>x(new Set),className:`px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors`,children:e(`common.cancel`)})]})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.catalog.spoolCatalogDescription`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.catalog.searchCatalog`),value:o,onChange:e=>s(e.target.value)})]}),l&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e(`settings.catalog.addNewEntry`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.catalog.namePlaceholder`),value:p,onChange:e=>m(e.target.value)})}),(0,K.jsx)(`input`,{type:`number`,className:`w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none`,placeholder:`g`,value:h,onChange:e=>g(e.target.value)}),(0,K.jsx)(`span`,{className:`text-bambu-gray shrink-0`,children:`g`}),(0,K.jsxs)(`button`,{onClick:A,disabled:_,className:`px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0`,children:[_?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`common.add`)]}),(0,K.jsx)(`button`,{onClick:()=>{u(!1),m(``),g(``)},className:`p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),e(`common.loading`)]}):(0,K.jsx)(`div`,{className:`max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-2 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:k.length>0&&b.size===k.length,onChange:()=>{b.size===k.length?x(new Set):x(new Set(k.map(e=>e.id)))},className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-bambu-gray font-medium`,children:e(`common.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-right text-bambu-gray font-medium w-24`,children:e(`settings.catalog.weight`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-center text-bambu-gray font-medium w-20`,children:e(`settings.catalog.type`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 w-24`})]})}),(0,K.jsx)(`tbody`,{children:k.length===0?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:5,className:`px-4 py-8 text-center text-bambu-gray`,children:e(o?`settings.catalog.noMatch`:`settings.catalog.empty`)})}):k.map(t=>(0,K.jsx)(`tr`,{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${b.has(t.id)?`bg-bambu-dark`:``}`,children:d===t.id?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>I(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none`,value:p,onChange:e=>m(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsx)(`input`,{type:`number`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none`,value:h,onChange:e=>g(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-center`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`-`})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>N(t.id),disabled:_,className:`p-1.5 rounded hover:bg-green-500/20 text-green-500`,children:_?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:M,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>I(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-white`,children:t.name}),(0,K.jsxs)(`td`,{className:`px-4 py-2 text-right font-mono text-white`,children:[t.weight,`g`]}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-center`,children:t.is_default?(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray`,children:e(`settings.catalog.default`)}):(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:e(`settings.catalog.custom`)})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>j(t),className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>T(t),className:`p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})},t.id))})]})})]}),w&&(0,K.jsx)(Ad,{title:e(`settings.catalog.deleteEntry`),message:e(`settings.catalog.deleteConfirm`,{name:w.name}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:P,onCancel:()=>T(null)}),S&&(0,K.jsx)(Ad,{title:e(`settings.catalog.deleteSelected`),message:e(`settings.catalog.bulkDeleteConfirm`,{count:b.size}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:async()=>{if(C(!1),b.size!==0)try{let n=await Q.bulkDeleteCatalogEntries([...b]);r(e=>e.filter(e=>!b.has(e.id))),x(new Set),t(e(`settings.catalog.bulkDeleted`,{count:n.deleted}),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleBulkDelete failed:`,n),t(e(`settings.catalog.bulkDeleteFailed`),`error`)}},onCancel:()=>C(!1)}),E&&(0,K.jsx)(Ad,{title:e(`settings.catalog.resetCatalog`),message:e(`settings.catalog.resetConfirm`),confirmText:e(`common.reset`),variant:`danger`,onConfirm:F,onCancel:()=>D(!1)})]})}var fHe=2166136261,pHe=16777619;function mHe(...e){let t=fHe,n=new TextEncoder,r=n.encode(`__|`);for(let i of e)typeof i==`string`?t=R3(t,n.encode(i+`|`)):i??(t=R3(t,r));return t>>>0}function R3(e,t){for(let n of t)e^=n,e=Math.imul(e,pHe)>>>0;return e}function hHe(e){let t=()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,(t^t>>>14)>>>0},n=(e,n)=>{if(!Number.isFinite(e)||!Number.isFinite(n))throw RangeError(`from and to must be finite numbers`);if(e>n)throw RangeError(`from must be less than or equal to to`);return e===n?e:e+t()/4294967295*(n-e)};return{next:()=>t()/4294967295,floatBetween:(e,t)=>n(e,t),intBetween:(e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t))throw RangeError(`from and to must be integers`);return Math.round(n(e,t))}}}var z3={table:{dotCount:5,dotScale:1},preview:{dotCount:8,dotScale:1.5},card:{dotCount:40,dotScale:2},bar:{dotCount:20,dotScale:2},groupheader:{dotCount:80,dotScale:2}},B3=[{value:``,labelKey:`inventory.colorEffect.none`},{value:`sparkle`,labelKey:`inventory.colorEffect.sparkle`},{value:`wood`,labelKey:`inventory.colorEffect.wood`},{value:`marble`,labelKey:`inventory.colorEffect.marble`},{value:`glow`,labelKey:`inventory.colorEffect.glow`},{value:`matte`,labelKey:`inventory.colorEffect.matte`},{value:`silk`,labelKey:`inventory.colorEffect.silk`},{value:`galaxy`,labelKey:`inventory.colorEffect.galaxy`},{value:`rainbow`,labelKey:`inventory.colorEffect.rainbow`},{value:`metal`,labelKey:`inventory.colorEffect.metal`},{value:`translucent`,labelKey:`inventory.colorEffect.translucent`},{value:`gradient`,labelKey:`inventory.colorEffect.gradient`},{value:`dual-color`,labelKey:`inventory.colorEffect.dualColor`},{value:`tri-color`,labelKey:`inventory.colorEffect.triColor`},{value:`multicolor`,labelKey:`inventory.colorEffect.multicolor`}],gHe=`repeating-conic-gradient(#979797 0% 25%, #f5f5f5 0% 50%)`,_He=`12px 12px`,vHe={sparkle:(e=0,t=`table`)=>{let n=hHe(e),r=z3[t]??z3.table,i=[];for(let e=0;e`repeating-linear-gradient(90deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 6px, rgba(0,0,0,0.08) 6px 7px, transparent 7px 12px)`,marble:()=>`repeating-linear-gradient(135deg, rgba(255,255,255,0.18) 0 2px, transparent 2px 8px), repeating-linear-gradient(45deg, rgba(0,0,0,0.10) 0 1px, transparent 1px 7px)`,glow:()=>`radial-gradient(circle at 50% 50%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 70%)`,matte:()=>`linear-gradient(180deg, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.10) 100%)`,silk:()=>`linear-gradient(110deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.30) 50%, rgba(255,255,255,0) 70%)`,galaxy:()=>`linear-gradient(110deg, rgba(255,255,255,0) 25%, rgba(255,255,255,0.40) 50%, rgba(255,255,255,0) 75%)`,metal:()=>`repeating-linear-gradient(90deg, rgba(255,255,255,0.10) 0 1px, transparent 1px 3px), linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(0,0,0,0.18) 100%)`};function V3(e){let t=e.trim().replace(/^#/,``);return t.length!==6&&t.length!==8||!/^[0-9a-fA-F]+$/.test(t)?null:`#${t}`}function H3(e){return e?e.split(`,`).map(e=>V3(e)).filter(e=>!!e):[]}function yHe(e,t,n,r){let i=e?V3(e):null;if(t.length===0)return`linear-gradient(${i??`#808080`}, ${i??`#808080`})`;let a=t.length===1?[t[0],t[0]]:t,o=(n??``).toLowerCase(),s=(r??``).toLowerCase();if(o===`multicolor`||s===`multicolor`){let e=a.length;return`conic-gradient(from 0deg, ${a.map((t,n)=>`${t} ${(n/e*360).toFixed(3)}deg ${((n+1)/e*360).toFixed(3)}deg`).join(`, `)})`}if(s===`dual-color`||s===`tri-color`){let e=a.length;return`linear-gradient(to right, ${a.map((t,n)=>`${t} ${(n/e*100).toFixed(3)}% ${((n+1)/e*100).toFixed(3)}%`).join(`, `)})`}return`linear-gradient(135deg, ${a.join(`, `)})`}function bHe(e,t,n){let r=vHe[e];return r?r(n,t):null}function U3(e){let t=H3(e.extraColors),n=yHe(e.rgba,t,e.subtype,e.effectType),r=mHe(e.rgba,e.extraColors,e.subtype,e.effectType),i=typeof e.effectType==`string`?bHe(e.effectType,e.effectSize,r):null,a=[];return i&&(Array.isArray(i)?i:[i]).forEach(e=>{a.push({image:e,size:`cover`})}),a.push({image:n,size:`cover`}),a.push({image:gHe,size:_He}),{backgroundImage:a.map(e=>e.image).join(`, `),backgroundSize:a.map(e=>e.size).join(`, `)}}function W3({rgba:e,extraColors:t,effectType:n,subtype:r,className:i=`w-5 h-5`,shape:a=`circle`,style:o,title:s,effectSize:c}){let l=(0,y.useMemo)(()=>H3(t),[t]),u=(0,y.useMemo)(()=>U3({effectSize:c,rgba:e,extraColors:t,effectType:n,subtype:r}),[c,e,t,n,r]),d=u.backgroundImage,f=u.backgroundSize,p=a===`circle`||a===`pill`?`rounded-full`:`rounded`,m=(()=>{if(!e)return;let t=e.replace(/^#/,``);return t.length>=8&&t.substring(6,8).toLowerCase()!==`ff`?`#${t.substring(0,8)}`:`#${t.substring(0,6)}`})(),h=s??(l.length>0?l.join(`, `):m);return(0,K.jsx)(`span`,{"data-testid":`filament-swatch`,className:`${i} ${p} border border-black/20 inline-block flex-shrink-0`,style:{backgroundImage:d,backgroundSize:f,...o},title:h})}function xHe(){let{t:e}=W(),{showToast:t}=Td(),[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),u=(0,y.useRef)(null),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(`#FFFFFF`),[S,C]=(0,y.useState)(``),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(new Set),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(!1),ee=(0,y.useCallback)(async()=>{try{r(await Q.getColorCatalog())}catch{t(e(`settings.colorCatalog.loadFailed`),`error`)}finally{a(!1)}},[t,e]);(0,y.useEffect)(()=>{ee()},[ee]);let te=[...new Set(n.map(e=>e.manufacturer))].sort(),ne=n.filter(e=>{let t=o===``||e.manufacturer.toLowerCase().includes(o.toLowerCase())||e.color_name.toLowerCase().includes(o.toLowerCase())||(e.material?.toLowerCase().includes(o.toLowerCase())??!1),n=c===``||e.manufacturer===c;return t&&n}),re=()=>{g(``),v(``),x(`#FFFFFF`),C(``),T(``),D(``)},ie=async()=>{if(!h.trim()||!_.trim()||!b){t(e(`settings.colorCatalog.fieldsRequired`),`error`);return}k(!0);try{let n=await Q.addColorEntry({manufacturer:h.trim(),color_name:_.trim(),hex_color:b,material:S.trim()||null,extra_colors:w.trim()||null,effect_type:E.trim()||null});r(e=>[...e,n].sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),f(!1),re(),t(e(`settings.colorCatalog.colorAdded`),`success`)}catch{t(e(`settings.colorCatalog.addFailed`),`error`)}finally{k(!1)}},H=e=>{m(e.id),g(e.manufacturer),v(e.color_name),x(e.hex_color),C(e.material||``),T(e.extra_colors||``),D(e.effect_type||``)},ae=()=>{m(null),re()},oe=async n=>{if(!h.trim()||!_.trim()||!b){t(e(`settings.colorCatalog.fieldsRequired`),`error`);return}k(!0);try{let i=await Q.updateColorEntry(n,{manufacturer:h.trim(),color_name:_.trim(),hex_color:b,material:S.trim()||null,extra_colors:w.trim()||null,effect_type:E.trim()||null});r(e=>e.map(e=>e.id===n?i:e).sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),m(null),re(),t(e(`settings.colorCatalog.colorUpdated`),`success`)}catch{t(e(`settings.colorCatalog.updateFailed`),`error`)}finally{k(!1)}},U=async()=>{if(R)try{await Q.deleteColorEntry(R.id),r(e=>e.filter(e=>e.id!==R.id)),t(e(`settings.colorCatalog.colorDeleted`),`success`)}catch{t(e(`settings.colorCatalog.deleteFailed`),`error`)}finally{z(null)}},se=async()=>{V(!1),a(!0);try{await Q.resetColorCatalog(),await ee(),t(e(`settings.colorCatalog.resetSuccess`),`success`)}catch{t(e(`settings.colorCatalog.resetFailed`),`error`),a(!1)}},ce=async()=>{F(!0),L(null);try{let n={},r=Ku();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/v1/inventory/colors/sync`,{method:`POST`,headers:n});if(!i.ok)throw Error(`Failed to start sync`);let a=i.body?.getReader();if(!a)throw Error(`No response body`);let o=new TextDecoder,s=``;for(;;){let{done:n,value:r}=await a.read();if(n)break;s+=o.decode(r,{stream:!0});let i=s.split(` -`);s=i.pop()||``;for(let n of i)if(n.startsWith(`data: `))try{let r=JSON.parse(n.slice(6));r.type===`progress`?L({fetched:r.total_fetched,total:r.total_available}):r.type===`complete`?r.added===0?t(e(`settings.colorCatalog.syncUpToDate`,{count:r.total_fetched}),`success`):t(e(`settings.colorCatalog.syncComplete`,{added:r.added,skipped:r.skipped}),`success`):r.type===`error`&&t(`${e(`settings.colorCatalog.syncError`)}: ${r.error}`,`error`)}catch{}}await ee()}catch{t(e(`settings.colorCatalog.syncFailed`),`error`)}finally{F(!1),L(null)}},le=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(_d,{id:`card-color-catalog`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(ml,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.colorCatalog.title`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,n.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>{let r=n.map(({manufacturer:e,color_name:t,hex_color:n,material:r,extra_colors:i,effect_type:a})=>({manufacturer:e,color_name:t,hex_color:n,material:r,extra_colors:i,effect_type:a})),i=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`color-catalog.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),t(e(`settings.colorCatalog.exported`,{count:n.length}),`success`)},className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.export`)})]}),(0,K.jsxs)(`button`,{onClick:()=>u.current?.click(),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.import`)})]}),(0,K.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,onChange:async i=>{let a=i.target.files?.[0];if(a){try{let i=await a.text(),o=JSON.parse(i);if(!Array.isArray(o))throw Error(`Invalid format`);let s=0,c=0;for(let e of o){if(!e.manufacturer||!e.color_name||!e.hex_color){c++;continue}if(n.some(t=>t.manufacturer.toLowerCase()===e.manufacturer.toLowerCase()&&t.color_name.toLowerCase()===e.color_name.toLowerCase()&&(t.material||``).toLowerCase()===(e.material||``).toLowerCase())){c++;continue}try{let t=await Q.addColorEntry({manufacturer:e.manufacturer,color_name:e.color_name,hex_color:e.hex_color,material:e.material||null,extra_colors:e.extra_colors||null,effect_type:e.effect_type||null});r(e=>[...e,t].sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),s++}catch{c++}}t(e(`settings.colorCatalog.imported`,{added:s,skipped:c}),`success`)}catch{t(e(`settings.colorCatalog.importFailed`),`error`)}u.current&&(u.current.value=``)}}}),(0,K.jsxs)(`button`,{onClick:ce,disabled:P,className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.colorCatalog.syncTooltip`),children:[P?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(ws,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:P?I?`${Math.min(I.fetched,I.total)} / ${I.total}`:e(`settings.colorCatalog.starting`):e(`settings.colorCatalog.sync`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(!0),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.reset`)})]}),(0,K.jsxs)(`button`,{onClick:()=>f(!0),className:`px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.add`)})]})]}),A.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-sm text-red-400`,children:e(`settings.colorCatalog.selectedCount`,{count:A.size})}),(0,K.jsxs)(`button`,{onClick:()=>N(!0),className:`ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.colorCatalog.deleteSelected`)]}),(0,K.jsx)(`button`,{onClick:()=>j(new Set),className:`px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors`,children:e(`common.cancel`)})]})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.colorCatalog.description`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.searchColors`),value:o,onChange:e=>s(e.target.value)})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`settings.colorCatalog.allManufacturers`)}),te.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),d&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e(`settings.colorCatalog.addNewColor`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end`,children:[(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.manufacturer`),value:h,onChange:e=>g(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.colorName`),value:_,onChange:e=>v(e.target.value)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`color`,className:`w-20 h-10 rounded cursor-pointer border border-bambu-dark-tertiary`,value:b,onChange:e=>x(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,className:`w-32 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:`#FFFFFF`,value:b,onChange:e=>x(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`text`,className:`flex-1 max-w-lg min-w-[200px] px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.materialOptional`),value:S,onChange:e=>C(e.target.value)}),(0,K.jsxs)(`button`,{onClick:ie,disabled:O,className:`w-24 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-3`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`common.add`)]}),(0,K.jsx)(`button`,{onClick:()=>{f(!1),re()},className:`p-2 ml-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 mt-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`inventory.extraColorsPlaceholder`),value:w,onChange:e=>T(e.target.value)}),(0,K.jsx)(`select`,{className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:E,onChange:e=>D(e.target.value),children:B3.map(t=>(0,K.jsx)(`option`,{value:t.value,children:e(t.labelKey)},t.value||`none`))})]})]}),(o||c)&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:e(`settings.colorCatalog.showing`,{filtered:ne.length,total:n.length})}),i?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),e(`common.loading`)]}):(0,K.jsx)(`div`,{className:`max-h-[600px] overflow-auto border border-bambu-dark-tertiary rounded-lg`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-2 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:ne.length>0&&A.size===ne.length,onChange:()=>{A.size===ne.length?j(new Set):j(new Set(ne.map(e=>e.id)))},className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium w-12`}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`settings.colorCatalog.manufacturer`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`inventory.material`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`settings.colorCatalog.colorName`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium w-24`,children:e(`settings.colorCatalog.hex`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 w-16`})]})}),(0,K.jsx)(`tbody`,{children:ne.length===0?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:7,className:`px-3 py-8 text-center text-bambu-gray`,children:e(o||c?`settings.colorCatalog.noMatch`:`settings.colorCatalog.empty`)})}):ne.map(t=>(0,K.jsxs)(y.Fragment,{children:[(0,K.jsx)(`tr`,{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${A.has(t.id)?`bg-bambu-dark`:``}`,children:p===t.id?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:A.has(t.id),onChange:()=>le(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`color`,className:`w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary`,value:b,onChange:e=>x(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:h,onChange:e=>g(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:S,onChange:e=>C(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:_,onChange:e=>v(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:b,onChange:e=>x(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>oe(t.id),disabled:O,className:`p-1.5 rounded hover:bg-green-500/20 text-green-500`,children:O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:ae,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:A.has(t.id),onChange:()=>le(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(W3,{rgba:t.hex_color.replace(/^#/,``)+(t.hex_color.length===7?`FF`:``),extraColors:t.extra_colors,effectType:t.effect_type,className:`w-8 h-8`,shape:`square`,title:t.hex_color,effectSize:`table`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:t.manufacturer}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-bambu-gray`,children:t.material||`-`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:t.color_name}),(0,K.jsx)(`td`,{className:`px-3 py-2 font-mono text-xs text-bambu-gray`,children:t.hex_color}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>H(t),className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>z(t),className:`p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})}),p===t.id&&(0,K.jsxs)(`tr`,{className:`border-t border-bambu-dark-tertiary/50 bg-bambu-dark`,children:[(0,K.jsx)(`td`,{colSpan:2}),(0,K.jsx)(`td`,{className:`px-3 py-2`,colSpan:2,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`,placeholder:e(`inventory.extraColorsPlaceholder`),value:w,onChange:e=>T(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,colSpan:2,children:(0,K.jsx)(`select`,{className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:E,onChange:e=>D(e.target.value),children:B3.map(t=>(0,K.jsx)(`option`,{value:t.value,children:e(t.labelKey)},t.value||`none`))})}),(0,K.jsx)(`td`,{})]})]},t.id))})]})})]}),R&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.deleteColor`),message:e(`settings.colorCatalog.deleteConfirm`,{name:`${R.manufacturer} - ${R.color_name}`}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:U,onCancel:()=>z(null)}),M&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.deleteSelected`),message:e(`settings.colorCatalog.bulkDeleteConfirm`,{count:A.size}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:async()=>{if(N(!1),A.size!==0)try{let n=await Q.bulkDeleteColorEntries([...A]);r(e=>e.filter(e=>!A.has(e.id))),j(new Set),t(e(`settings.colorCatalog.bulkDeleted`,{count:n.deleted}),`success`)}catch{t(e(`settings.colorCatalog.bulkDeleteFailed`),`error`)}},onCancel:()=>N(!1)}),B&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.resetCatalog`),message:e(`settings.colorCatalog.resetConfirm`),confirmText:e(`common.reset`),variant:`danger`,onConfirm:se,onCancel:()=>V(!1)})]})}function SHe({link:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,a=(0,y.useRef)(null),[o,s]=(0,y.useState)(e?.name||``),[c,l]=(0,y.useState)(e?.url||``),[u,d]=(0,y.useState)(e?.icon||`link`),[f,p]=(0,y.useState)(e?.open_in_new_tab||!1),[m,h]=(0,y.useState)(!!e?.custom_icon),[g,_]=(0,y.useState)(e?.custom_icon?Q.getExternalLinkIconUrl(e.id):null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let C=J({mutationFn:async e=>{let t=await Q.createExternalLink(e);return v?await Q.uploadExternalLinkIcon(t.id,v):t},onSuccess:()=>{r.invalidateQueries({queryKey:[`external-links`]}),t()},onError:e=>{S(e.message)}}),w=J({mutationFn:async t=>{let n=await Q.updateExternalLink(e.id,t);return v?n=await Q.uploadExternalLinkIcon(e.id,v):!m&&e?.custom_icon&&(n=await Q.deleteExternalLinkIcon(e.id)),n},onSuccess:()=>{r.invalidateQueries({queryKey:[`external-links`]}),t()},onError:e=>{S(e.message)}}),T=e=>{let t=e.target.files?.[0];if(t){if(![`image/png`,`image/jpeg`,`image/gif`,`image/svg+xml`,`image/webp`,`image/x-icon`].includes(t.type)){S(`Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)`);return}if(t.size>1024*1024){S(`Image file must be less than 1MB`);return}b(t),h(!0);let e=new FileReader;e.onload=e=>{_(e.target?.result)},e.readAsDataURL(t)}},E=()=>{b(null),_(null),h(!1),a.current&&(a.current.value=``)},D=e=>{if(e.preventDefault(),S(null),!o.trim()){S(`Name is required`);return}if(!c.trim()){S(`URL is required`);return}if(!c.startsWith(`http://`)&&!c.startsWith(`https://`)){S(`URL must start with http:// or https://`);return}let t={name:o.trim(),url:c.trim(),icon:u,open_in_new_tab:f};i?w.mutate(t):C.mutate(t)},O=C.isPending||w.isPending,k=Pd(u);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-green/20 text-bambu-green`,children:m&&g?(0,K.jsx)(`img`,{src:g,alt:``,className:`w-5 h-5 rounded`}):(0,K.jsx)(k,{className:`w-5 h-5`})}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i?`Edit Link`:`Add External Link`})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:D,className:`p-6 space-y-4`,children:[x&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:x}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Name *`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`My Link`,maxLength:50,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`URL *`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:n(`externalLinks.openInNewTab`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${f?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${f?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray`,children:`Icon`}),(0,K.jsxs)(`div`,{className:`p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:`Custom Icon`}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon`,className:`hidden`,onChange:T}),m&&g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:g,alt:`Custom icon`,className:`w-8 h-8 rounded border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{type:`button`,onClick:E,className:`p-1 text-red-400 hover:text-red-300 transition-colors`,title:`Remove custom icon`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}):(0,K.jsxs)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>a.current?.click(),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),`Upload`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:`PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB.`})]}),!m&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray block mb-2`,children:`Or choose a preset icon`}),(0,K.jsx)(Fd,{value:u,onChange:d})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:`Cancel`}),(0,K.jsxs)($,{type:`submit`,disabled:O,className:`flex-1`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),i?`Save`:`Add`]})]})]})]})})}function CHe(){let{t:e}=W(),t=no(),{authEnabled:n,hasPermission:r}=dd(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(Sp),[_,v]=(0,y.useState)(()=>bp(wp.map(e=>e.id))),{data:b,isLoading:x}=q({queryKey:[`external-links`],queryFn:Q.getExternalLinks}),S=J({mutationFn:e=>Q.deleteExternalLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`external-links`]})}}),{data:C}=q({queryKey:[`settings`],queryFn:Q.getSettings,enabled:n&&r(`settings:update`)}),w=J({mutationFn:e=>Q.updateSettings({default_sidebar_order:e}),onSuccess:(n,r)=>{t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`default-sidebar-order`]}),i(e(r?`settings.sidebarDefaultSet`:`settings.sidebarDefaultCleared`),`success`)},onError:()=>{i(e(`settings.sidebarDefaultFailed`),`error`)}}),T=(0,y.useMemo)(()=>{let e=new Map(wp.map(e=>[e.id,e])),t=new Map((b||[]).map(e=>[`ext-${e.id}`,e])),n=[],r=new Set,i=i=>{if(r.has(i))return;let a=e.get(i);if(a){n.push({type:`system`,id:i,navItem:a}),r.add(i);return}let o=t.get(i);o&&(n.push({type:`external`,id:i,link:o}),r.add(i))};return _.forEach(i),wp.forEach(e=>i(e.id)),(b||[]).forEach(e=>i(`ext-${e.id}`)),n},[b,_]),E=e=>{v(e),xp(e)},D=(e,t)=>{f(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},O=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,m(t)},k=(e,t)=>{if(e.preventDefault(),d===null||d===t){f(null),m(null);return}let n=T.map(e=>e.id),r=n.indexOf(d),i=n.indexOf(t);if(r===-1||i===-1){f(null),m(null);return}n.splice(r,1),n.splice(i,0,d),E(n),f(null),m(null)},A=()=>{f(null),m(null)},j=e=>{u(e)},M=()=>{l&&(S.mutate(l.id),u(null))},N=()=>{let e=[...wp.map(e=>e.id),...(b||[]).map(e=>`ext-${e.id}`)];g([]),v(e),Cp([]),xp(e)},P=e=>{let t=T.map(e=>e.id);w.mutate(e?JSON.stringify({order:t,hiddenSystemItemIds:h}):``)},F=e=>{if(e===`settings`)return;let t=h.includes(e)?h.filter(t=>t!==e):[...h,e];g(t),Cp(t)},I=n&&r(`settings:update`),L=!!C?.default_sidebar_order;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(_d,{id:`card-sidebar-links`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-y-2 gap-x-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`externalLinks.sidebarLayout`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[I&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:e(`settings.setDefault`)}),(0,K.jsx)(cU,{checked:L,onChange:P,disabled:w.isPending})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:N,className:`whitespace-nowrap`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),e(`settings.reset`)]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>o(!0),className:`whitespace-nowrap`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),`Add Link`]})]})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`externalLinks.sidebarLayoutDescription`)}),x?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):(0,K.jsx)(`div`,{className:`space-y-2`,children:T.map(t=>{let n=t.type===`system`&&h.includes(t.id),r=t.id===`settings`;if(t.type===`system`){let i=t.navItem.icon;return(0,K.jsxs)(`div`,{draggable:!0,onDragStart:e=>D(e,t.id),onDragOver:e=>O(e,t.id),onDragLeave:()=>m(null),onDrop:e=>k(e,t.id),onDragEnd:A,className:`relative flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${d===t.id?`opacity-50`:n?`opacity-60`:``} ${p===t.id&&d!==t.id?`before:absolute before:left-3 before:right-3 before:top-0 before:h-0.5 before:bg-bambu-green`:``}`,children:[(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0`}),(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(i,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium truncate block`,children:e(t.navItem.labelKey)}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate block`,children:e(r?`externalLinks.requiredInSidebar`:n?`externalLinks.hiddenFromSidebar`:`externalLinks.visibleInSidebar`)})]}),(0,K.jsx)(`button`,{onClick:()=>F(t.id),disabled:r,className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-bambu-gray`,title:e(r?`externalLinks.settingsCannotBeHidden`:n?`externalLinks.showPage`:`externalLinks.hidePage`),"aria-label":e(r?`externalLinks.settingsCannotBeHidden`:n?`externalLinks.showPage`:`externalLinks.hidePage`),children:n?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]},t.id)}let i=t.link,a=Pd(i.icon);return(0,K.jsxs)(`div`,{draggable:!0,onDragStart:e=>D(e,t.id),onDragOver:e=>O(e,t.id),onDragLeave:()=>m(null),onDrop:e=>k(e,t.id),onDragEnd:A,className:`relative flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${d===t.id?`opacity-50`:``} ${p===t.id&&d!==t.id?`before:absolute before:left-3 before:right-3 before:top-0 before:h-0.5 before:bg-bambu-green`:``}`,children:[(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0`}),(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray`,children:i.custom_icon?(0,K.jsx)(`img`,{src:Q.getExternalLinkIconUrl(i.id),alt:``,className:`w-4 h-4`}):(0,K.jsx)(a,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium truncate`,children:i.name}),(0,K.jsx)(Js,{className:`w-3 h-3 text-bambu-gray flex-shrink-0`})]}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate block`,children:i.url})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,K.jsx)(`button`,{onClick:()=>c(i),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:e(`common.edit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>j(i),disabled:S.isPending,className:`p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50`,title:e(`externalLinks.deleteLink`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},t.id)})})]})]}),(a||s)&&(0,K.jsx)(SHe,{link:s,onClose:()=>{o(!1),c(null)}}),l&&(0,K.jsx)(Ad,{title:`Delete Link`,message:`Are you sure you want to delete "${l.name}"? This action cannot be undone.`,confirmText:`Delete`,cancelText:`Cancel`,variant:`danger`,onConfirm:M,onCancel:()=>u(null)})]})}async function G3(e){if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.parentNode&&t.parentNode.removeChild(t)}}function wHe(e,t,n=`text/plain`){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function THe({status:e}){return e===`pass`?(0,K.jsx)(ms,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}):e===`fail`?(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 flex-shrink-0`}):e===`warn`?(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`})}function EHe({vpId:e,vpName:t,onClose:n}){let{t:r}=W(),i=J({mutationFn:()=>nd.diagnose(e)});(0,y.useEffect)(()=>{i.mutate()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let a=i.data,o=a?.overall===`ok`?`bg-bambu-green/10 border-bambu-green/30 text-bambu-green`:a?.overall===`warnings`?`bg-amber-500/10 border-amber-500/30 text-amber-300`:`bg-red-500/10 border-red-500/30 text-red-300`;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg flex flex-col max-h-[85vh]`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(cu,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:r(`vpDiagnostic.title`,{name:t})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-4 overflow-y-auto`,children:[i.isPending&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:r(`vpDiagnostic.running`)})]}),i.isError&&(0,K.jsx)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`vpDiagnostic.runFailed`,{error:i.error.message})}),a&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`ol`,{className:`space-y-2`,children:a.checks.map(e=>{let t=r(`vpDiagnostic.check.${e.id}.${e.status}`,{...e.params,defaultValue:``});return(0,K.jsxs)(`li`,{className:`flex items-start gap-3 bg-bambu-dark rounded-lg px-4 py-2.5 ${e.status===`skip`?`opacity-60`:``}`,children:[(0,K.jsx)(`div`,{className:`mt-0.5`,children:(0,K.jsx)(THe,{status:e.status})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white`,children:r(`vpDiagnostic.check.${e.id}.title`,e.params)}),t&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-0.5`,children:t})]})]},e.id)})}),(0,K.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${o}`,children:r(`vpDiagnostic.overall.${a.overall}`)})]})]}),(0,K.jsxs)(`div`,{className:`px-6 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>i.mutate(),disabled:i.isPending,className:`px-4 py-2 bg-bambu-dark hover:bg-bambu-dark-tertiary disabled:opacity-50 text-white text-sm rounded-lg transition-colors`,children:r(`vpDiagnostic.retry`)}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 bg-bambu-green hover:bg-bambu-green/90 text-white text-sm rounded-lg transition-colors`,children:r(`common.close`)})]})]})})}var K3={archive:`archive`,review:`review`,queue:`queue`,proxy:`proxy`};function q3(e){return e===`immediate`?`archive`:e===`print_queue`||e===`queue`?`queue`:e===`archive`||e===`review`||e===`proxy`?e:`archive`}function DHe({printer:e,models:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(e.enabled),[l,u]=(0,y.useState)(e.name),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(q3(e.mode)),[h,g]=(0,y.useState)(e.target_printer_id),[_,v]=(0,y.useState)(e.bind_ip||``),[b,x]=(0,y.useState)(e.remote_interface_ip||``),[S,C]=(0,y.useState)(e.model||``),[w,T]=(0,y.useState)(e.auto_dispatch??!0),[E,D]=(0,y.useState)(e.queue_force_color_match??!1),[O,k]=(0,y.useState)(e.gcode_injection??!1),[A,j]=(0,y.useState)(e.tailscale_disabled??!0),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!1),{data:ee}=q({queryKey:[`tailscale-status`],queryFn:nd.getTailscaleStatus,enabled:!A,staleTime:6e4}),te=ee?.available?ee.fqdn:``,ne=ee?.available?ee.tailscale_ips?.[0]??``:``,re=async e=>{e.stopPropagation();let t=te;t&&(await G3(t)?(V(!0),i(n(`printers.copied`)),setTimeout(()=>V(!1),2e3)):i(n(`virtualPrinter.toast.copyFailed`),`error`))};(0,y.useEffect)(()=>{P||(c(e.enabled),m(q3(e.mode)),u(e.name),g(e.target_printer_id),v(e.bind_ip||``),x(e.remote_interface_ip||``),C(e.model||``),T(e.auto_dispatch??!0),D(e.queue_force_color_match??!1),k(e.gcode_injection??!1),j(e.tailscale_disabled??!0))},[e,P]);let{data:ie}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:H}=q({queryKey:[`network-interfaces`],queryFn:()=>Q.getNetworkInterfaces().then(e=>e.interfaces)}),ae=J({mutationFn:t=>nd.update(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`virtual-printers`]}),i(n(`virtualPrinter.toast.updated`)),F(null)},onError:t=>{i(t.message||n(`virtualPrinter.toast.failedToUpdate`),`error`),c(e.enabled),m(q3(e.mode)),g(e.target_printer_id),v(e.bind_ip||``),j(e.tailscale_disabled??!0),F(null)}}),oe=J({mutationFn:()=>nd.remove(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`virtual-printers`]}),i(n(`virtualPrinter.toast.deleted`)),L(!1)},onError:e=>{i(e.message||n(`virtualPrinter.toast.failedToDelete`),`error`),L(!1)}}),U=t=>{t.stopPropagation();let r=!s;if(r){if(!_){i(n(`virtualPrinter.toast.bindIpRequired`),`error`);return}if(p===`proxy`){if(!h){i(n(`virtualPrinter.toast.targetPrinterRequired`),`error`);return}}else if(!d&&!e.access_code_set){i(n(`virtualPrinter.toast.accessCodeRequired`),`error`);return}}c(r),F(`toggle`),ae.mutate({enabled:r})},se=()=>{l.trim()&&(F(`name`),ae.mutate({name:l.trim()}))},ce=()=>{if(!d){i(n(`virtualPrinter.toast.accessCodeEmpty`),`error`);return}if(d.length!==8){i(n(`virtualPrinter.toast.accessCodeLength`),`error`);return}F(`accessCode`),ae.mutate({access_code:d}),f(``)},le=e=>{m(e),F(`mode`),ae.mutate({mode:e})},ue=e=>{C(e),F(`model`),ae.mutate({model:e})},de=e=>{let t=he?.access_code,r=ie?.find(t=>t.id===e)?.access_code;g(e),F(`targetPrinter`),ae.mutate({target_printer_id:e},{onSuccess:()=>{t&&r&&t!==r&&i(n(`virtualPrinter.toast.targetCodeChangedRebind`),`info`)}})},fe=e=>{x(e),F(`remoteInterface`),ae.mutate({remote_interface_ip:e})},pe=e.status?.running||!1,me=n(`virtualPrinter.mode.${K3[p]||`archive`}`),he=ie?.find(e=>e.id===h),ge=he?.name,_e=!!h,ve=_e?he?.access_code??``:``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(_d,{children:[(0,K.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3 cursor-pointer select-none`,onClick:()=>o(!a),children:[(0,K.jsx)(`button`,{className:`text-bambu-gray flex-shrink-0`,children:a?(0,K.jsx)(is,{className:`w-4 h-4`}):(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0 ${pe?`bg-green-400 animate-pulse`:`bg-gray-500`}`}),(0,K.jsx)(`span`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0`,children:me}),e.model_name&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0`,children:e.model_name}),ge&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0 truncate`,children:[p===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3 inline mr-1`}),ge]}),_&&(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray flex-shrink-0 font-mono`,children:_}),b&&(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray flex-shrink-0 font-mono`,children:b}),(0,K.jsx)(`div`,{className:`ml-auto flex items-center gap-2 flex-shrink-0`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(`button`,{onClick:U,disabled:P===`toggle`,className:`relative w-10 h-5 rounded-full transition-colors ${s?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`toggle`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${s?`translate-x-5`:``}`})})})]}),a&&(0,K.jsxs)(yd,{className:`pt-0 space-y-4`,children:[(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),onBlur:se,onKeyDown:e=>e.key===`Enter`&&se(),className:`flex-1 text-sm text-white bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{onClick:()=>z(!0),className:`p-1.5 text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:n(`vpDiagnostic.runButton`),children:(0,K.jsx)(cu,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>L(!0),className:`p-1.5 text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0`,title:n(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 -mt-2`,children:[te&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400/70 min-w-0`,children:[(0,K.jsx)(Gl,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`font-mono text-xs truncate`,children:ne?`${ne} (${te})`:te}),(0,K.jsx)(`button`,{onClick:re,className:`p-0.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0`,title:n(B?`printers.copied`:`printers.copyToClipboard`),children:B?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-mono ml-auto flex-shrink-0`,children:e.serial})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-2`,children:n(`virtualPrinter.mode.title`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`archive`,`review`,`queue`,`proxy`].map(e=>(0,K.jsxs)(`button`,{onClick:()=>le(e),disabled:P===`mode`,className:`p-2 rounded-lg border text-left transition-colors ${p===e?e===`proxy`?`border-blue-500 bg-blue-500/10`:`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-white text-xs font-medium`,children:[e===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3`}),n(`virtualPrinter.mode.${K3[e]}`)]}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.mode.${K3[e]}Desc`)})]},e))})]}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.autoDispatch.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.autoDispatch.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!w;T(e),F(`autoDispatch`),ae.mutate({auto_dispatch:e})},disabled:P===`autoDispatch`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${w?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`autoDispatch`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${w?`translate-x-5`:``}`})})]})}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.queueForceColorMatch.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.queueForceColorMatch.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!E;D(e),F(`queueForceColorMatch`),ae.mutate({queue_force_color_match:e})},disabled:P===`queueForceColorMatch`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${E?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`queueForceColorMatch`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${E?`translate-x-5`:``}`})})]})}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.gcodeInjection.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.gcodeInjection.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!O;k(e),F(`gcodeInjection`),ae.mutate({gcode_injection:e})},disabled:P===`gcodeInjection`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${O?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`gcodeInjection`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${O?`translate-x-5`:``}`})})]})}),(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.tailscaleDisabled.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.tailscaleDisabled.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!A;j(e),F(`tailscaleDisabled`),ae.mutate({tailscale_disabled:e})},disabled:P===`tailscaleDisabled`,className:`relative w-10 h-5 rounded-full transition-colors shrink-0 ${A?`bg-bambu-dark-tertiary`:`bg-bambu-green`} ${P===`tailscaleDisabled`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${A?``:`translate-x-5`}`})})]})}),p!==`proxy`&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-1`,children:n(`virtualPrinter.model.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:n(`virtualPrinter.model.description`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:S,onChange:e=>ue(e.target.value),disabled:P===`model`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:Object.entries(t).map(([e,t])=>(0,K.jsxs)(`option`,{value:e,children:[t,` (`,e,`)`]},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),p===`proxy`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded bg-blue-500/10 border border-blue-500/30`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`virtualPrinter.proxy.accessCodeHint`)})]})}),p!==`proxy`&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.accessCode.title`)}),_e?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-blue-400`,children:[(0,K.jsx)(Pc,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.inheritedFromTarget`)]}):e.access_code_set?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-400`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.isSet`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.notSet`)]})]}),_e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:M?`text`:`password`,value:ve,readOnly:!0,"aria-label":n(`virtualPrinter.accessCode.title`),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm pr-10 font-mono opacity-90 cursor-default`}),(0,K.jsx)(`button`,{onClick:()=>N(!M),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,"aria-label":n(M?`virtualPrinter.accessCode.hide`:`virtualPrinter.accessCode.reveal`),children:M?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`virtualPrinter.accessCode.derivedFromTargetHint`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:M?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e.access_code_set?n(`virtualPrinter.accessCode.placeholderChange`):n(`virtualPrinter.accessCode.placeholder`),maxLength:8,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm placeholder-bambu-gray pr-10 font-mono`}),(0,K.jsx)(`button`,{onClick:()=>N(!M),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:M?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]}),(0,K.jsx)($,{onClick:ce,disabled:!d||P===`accessCode`,variant:`primary`,children:P===`accessCode`?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`common.save`)})]}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:(0,K.jsx)(`span`,{className:d.length===8?`text-green-400`:`text-yellow-400`,children:n(`virtualPrinter.accessCode.charCount`,{count:d.length})})})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-2`,children:n(`virtualPrinter.targetPrinter.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:h??``,onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||de(t)},disabled:P===`targetPrinter`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.targetPrinter.placeholder`)}),ie?.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.ip_address,`)`]},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-1`,children:n(`virtualPrinter.bindIp.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:_,onChange:e=>{v(e.target.value),F(`bindIp`),ae.mutate({bind_ip:e.target.value})},disabled:P===`bindIp`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.bindIp.placeholder`)}),H?.map(e=>(0,K.jsxs)(`option`,{value:e.ip,children:[e.name,` (`,e.ip,`)`,e.is_alias?` [alias]`:``,` - `,e.subnet]},e.ip))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`virtualPrinter.bindIp.hint`)})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.remoteInterface.title`)}),b?(0,K.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-green-400`,children:(0,K.jsx)(rs,{className:`w-3 h-3`})}):(0,K.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray`,title:n(`virtualPrinter.remoteInterface.optional`),children:(0,K.jsx)(Pc,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:b,onChange:e=>fe(e.target.value),disabled:P===`remoteInterface`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.remoteInterface.placeholder`)}),H?.map(e=>(0,K.jsxs)(`option`,{value:e.ip,children:[e.name,` (`,e.ip,`) - `,e.subnet]},e.ip))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]})]}),I&&(0,K.jsx)(Ad,{title:n(`virtualPrinter.deleteConfirm.title`),message:n(`virtualPrinter.deleteConfirm.message`,{name:e.name}),variant:`danger`,confirmText:n(`common.delete`),isLoading:oe.isPending,onConfirm:()=>oe.mutate(),onCancel:()=>L(!1)}),R&&(0,K.jsx)(EHe,{vpId:e.id,vpName:e.name,onClose:()=>z(!1)})]})}var J3={archive:`archive`,review:`review`,queue:`queue`,proxy:`proxy`};function OHe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(`archive`),[c,l]=(0,y.useState)(null),{data:u}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),d=J({mutationFn:()=>nd.create({name:i.trim()||`Bambuddy`,mode:o,target_printer_id:o===`proxy`?c??void 0:void 0}),onSuccess:()=>{n.invalidateQueries({queryKey:[`virtual-printers`]}),r(t(`virtualPrinter.toast.created`)),e()},onError:e=>{r(e.message||t(`virtualPrinter.toast.failedToCreate`),`error`)}});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:e,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6 space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t(`virtualPrinter.addDialog.title`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.addDialog.name`)}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Bambuddy`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm placeholder-bambu-gray`,autoFocus:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.mode.title`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`archive`,`review`,`queue`,`proxy`].map(e=>(0,K.jsxs)(`button`,{onClick:()=>s(e),className:`p-2 rounded-lg border text-left transition-colors ${o===e?e===`proxy`?`border-blue-500 bg-blue-500/10`:`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-white text-xs font-medium`,children:[e===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3`}),t(`virtualPrinter.mode.${J3[e]}`)]}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:t(`virtualPrinter.mode.${J3[e]}Desc`)})]},e))})]}),o===`proxy`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.targetPrinter.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:c??``,onChange:e=>{let t=parseInt(e.target.value,10);l(isNaN(t)?null:t)},className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm appearance-none cursor-pointer pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:t(`virtualPrinter.targetPrinter.placeholder`)}),u?.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.ip_address,`)`]},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:t(`virtualPrinter.addDialog.hint`)}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,disabled:d.isPending,children:t(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,onClick:()=>d.mutate(),className:`flex-1`,disabled:d.isPending,children:d.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):t(`virtualPrinter.addDialog.create`)})]})]})})})}function kHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),{data:a,isLoading:o}=q({queryKey:[`virtual-printers`],queryFn:nd.list,refetchInterval:1e4}),{data:s}=q({queryKey:[`virtual-printer-settings`],queryFn:td.getSettings}),c=J({mutationFn:e=>td.updateSettings({archive_name_source:e}),onSuccess:()=>{t.invalidateQueries({queryKey:[`virtual-printer-settings`]}),n(e(`virtualPrinter.toast.updated`))},onError:t=>{n(t.message||e(`virtualPrinter.toast.failedToUpdate`),`error`)}}),l=s?.archive_name_source===`filename`,{data:u}=q({queryKey:[`vp-ca-certificate`],queryFn:nd.getCaCertificate,staleTime:1/0}),[d,f]=(0,y.useState)(!1),p=async()=>{u&&(await G3(u.pem)?(f(!0),n(e(`virtualPrinter.caCert.copied`)),setTimeout(()=>f(!1),2e3)):n(e(`virtualPrinter.toast.copyFailed`),`error`))},m=()=>{u&&wHe(u.pem,`bambuddy-virtual-printer-ca.crt`,`application/x-pem-file`)};if(o)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})});let h=a?.printers||[],g=a?.models||{};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4 items-stretch`,children:[(0,K.jsx)(_d,{className:`border-l-4 border-l-yellow-500`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`virtualPrinter.setupRequired.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`virtualPrinter.setupRequired.description`)}),(0,K.jsxs)(`a`,{href:`https://wiki.bambuddy.cool/features/virtual-printer/`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 bg-yellow-500/20 border border-yellow-500/50 rounded text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),e(`virtualPrinter.setupRequired.readGuide`)]})]})]})})}),(0,K.jsx)(_d,{className:`lg:col-span-2`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`virtualPrinter.howItWorks.title`)}),(0,K.jsxs)(`ul`,{className:`space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step1`)}),(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step2`)}),(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step3`)})]})]})]})})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4 items-stretch`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-1`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`virtualPrinter.caCert.title`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsxs)(`button`,{onClick:p,disabled:!u,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded bg-bambu-dark-secondary border border-bambu-dark-tertiary text-white hover:border-bambu-gray disabled:opacity-50 transition-colors`,children:[d?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`}),e(d?`virtualPrinter.caCert.copied`:`virtualPrinter.caCert.copy`)]}),(0,K.jsxs)(`button`,{onClick:m,disabled:!u,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded bg-bambu-dark-secondary border border-bambu-dark-tertiary text-white hover:border-bambu-gray disabled:opacity-50 transition-colors`,children:[(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`}),e(`virtualPrinter.caCert.download`)]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`virtualPrinter.caCert.description`)}),u&&(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray font-mono mt-1 truncate`,title:u.fingerprint_sha256,children:[e(`virtualPrinter.caCert.fingerprint`),`: `,u.fingerprint_sha256]})]})]})})}),(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-1`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`virtualPrinter.archiveNameSource.title`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs ${l?`text-bambu-gray`:`text-white`}`,children:e(`virtualPrinter.archiveNameSource.metadata`)}),(0,K.jsx)(cU,{checked:l,onChange:e=>c.mutate(e?`filename`:`metadata`),disabled:c.isPending}),(0,K.jsx)(`span`,{className:`text-xs ${l?`text-white`:`text-bambu-gray`}`,children:e(`virtualPrinter.archiveNameSource.filename`)})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`virtualPrinter.archiveNameSource.description`)})]})]})})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`virtualPrinter.list.title`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,h.length,`)`]})]}),(0,K.jsxs)($,{variant:`primary`,onClick:()=>i(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),e(`virtualPrinter.list.add`)]})]}),h.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-8 text-center`,children:[(0,K.jsx)(Tl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`virtualPrinter.list.empty`)}),(0,K.jsxs)($,{variant:`primary`,onClick:()=>i(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),e(`virtualPrinter.list.addFirst`)]})]})}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start`,children:h.map(e=>(0,K.jsx)(DHe,{printer:e,models:g},e.id))}),r&&(0,K.jsx)(OHe,{onClose:()=>i(!1)})]})}function Y3(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;if(n<24)return r?`${n}h ${r}m`:`${n}h`;let i=Math.floor(n/24),a=n%24;return a?`${i}d ${a}h`:`${i}d`}function X3(e){return e==null?`—`:e>=1024?`${(e/1024).toFixed(1)} GB`:`${Math.round(e)} MB`}function AHe({device:e,onUnregister:t,isDeleting:n}){let{t:r}=W(),{showToast:i}=Td(),a=e.system_stats,o=a?.memory,s=a?.disk,c=e.online,[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=async t=>{f(t);try{t===`update`?await od.triggerUpdate(e.device_id):await od.systemCommand(e.device_id,t),i(r(`settings.spoolbuddy.commandQueued`),`success`)}catch(e){i(e instanceof Error?e.message:r(`settings.spoolbuddy.commandError`),`error`)}finally{f(null),u(null)}},m=[{key:`update`,label:r(`settings.spoolbuddy.update`),icon:Vs},{key:`restart_browser`,label:r(`settings.spoolbuddy.restartBrowser`),icon:ol},{key:`restart_daemon`,label:r(`settings.spoolbuddy.restartDaemon`),icon:Ol},{key:`reboot`,label:r(`settings.spoolbuddy.reboot`),icon:jl},{key:`shutdown`,label:r(`settings.spoolbuddy.shutdown`),icon:wl,variant:`danger`}],h={update:r(`settings.spoolbuddy.updateConfirmTitle`),restart_browser:r(`settings.spoolbuddy.restartBrowserConfirmTitle`),restart_daemon:r(`settings.spoolbuddy.restartDaemonConfirmTitle`),reboot:r(`settings.spoolbuddy.rebootConfirmTitle`),shutdown:r(`settings.spoolbuddy.shutdownConfirmTitle`)},g={update:r(`settings.spoolbuddy.updateConfirmBody`,{hostname:e.hostname}),restart_browser:r(`settings.spoolbuddy.restartBrowserConfirmBody`,{hostname:e.hostname}),restart_daemon:r(`settings.spoolbuddy.restartDaemonConfirmBody`,{hostname:e.hostname}),reboot:r(`settings.spoolbuddy.rebootConfirmBody`,{hostname:e.hostname}),shutdown:r(`settings.spoolbuddy.shutdownConfirmBody`,{hostname:e.hostname})};return(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white truncate`,children:e.hostname}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${c?`bg-green-500/15 text-green-400 border border-green-500/40`:`bg-gray-500/15 text-gray-400 border border-gray-500/40`}`,children:[c?(0,K.jsx)(Fu,{className:`w-3 h-3`}):(0,K.jsx)(Pu,{className:`w-3 h-3`}),r(c?`settings.spoolbuddy.online`:`settings.spoolbuddy.offline`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-mono mt-1 truncate`,children:e.device_id})]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>t(e),disabled:n,"aria-label":r(`settings.spoolbuddy.unregister`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r(`settings.spoolbuddy.unregister`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.ipAddress`)}),(0,K.jsx)(`div`,{className:`text-white font-mono`,children:e.ip_address})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.firmware`)}),(0,K.jsx)(`div`,{className:`text-white`,children:e.firmware_version??`—`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),r(`settings.spoolbuddy.lastSeen`)]}),(0,K.jsx)(`div`,{className:`text-white`,children:e.last_seen?wf(e.last_seen):r(`settings.spoolbuddy.never`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.daemonUptime`)}),(0,K.jsx)(`div`,{className:`text-white`,children:Y3(e.uptime_s)})]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(({key:e,label:t,icon:n,variant:r})=>(0,K.jsxs)($,{variant:r??`secondary`,size:`sm`,onClick:()=>u(e),disabled:!c||d!==null,"aria-label":t,children:[d===e?(0,K.jsx)(X,{className:`w-3.5 h-3.5 animate-spin`}):(0,K.jsx)(n,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs flex-wrap`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[e.nfc_ok?(0,K.jsx)(ms,{className:`w-3.5 h-3.5 text-green-400`}):(0,K.jsx)(ys,{className:`w-3.5 h-3.5 text-red-400`}),r(`settings.spoolbuddy.nfc`),e.nfc_reader_type&&(0,K.jsxs)(`span`,{className:`text-bambu-gray/70`,children:[`(`,e.nfc_reader_type,`)`]})]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[e.scale_ok?(0,K.jsx)(ms,{className:`w-3.5 h-3.5 text-green-400`}):(0,K.jsx)(ys,{className:`w-3.5 h-3.5 text-red-400`}),r(`settings.spoolbuddy.scale`)]})]}),a&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 text-xs`,children:[a.cpu_temp_c!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(vu,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.cpuTemp`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[a.cpu_temp_c.toFixed(1),`°C`]})]})]}),a.load_avg&&a.load_avg.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Eo,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.cpuLoad`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[a.load_avg[0].toFixed(2),a.cpu_count?` / ${a.cpu_count} (${Math.round(a.load_avg[0]/a.cpu_count*100)}%)`:``]})]})]}),o&&o.percent!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ns,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.memory`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[o.percent.toFixed(0),`% (`,X3(o.used_mb),` / `,X3(o.total_mb),`)`]})]})]}),s&&s.percent!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(wc,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.disk`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[s.percent.toFixed(0),`% (`,s.used_gb?.toFixed(1),` / `,s.total_gb?.toFixed(1),` GB)`]})]})]}),a.system_uptime_s!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.systemUptime`)}),(0,K.jsx)(`div`,{className:`text-white`,children:Y3(a.system_uptime_s)})]})]})]}),a.os&&(0,K.jsx)(`div`,{className:`mt-3 text-xs text-bambu-gray font-mono truncate`,children:[a.os.os,a.os.kernel,a.os.arch,a.os.python&&`Python ${a.os.python}`].filter(Boolean).join(` · `)})]})]}),l&&(0,K.jsx)(Ad,{variant:l===`shutdown`||l===`reboot`?`danger`:`default`,title:h[l],message:g[l],confirmText:r(`settings.spoolbuddy.commandConfirm`),isLoading:d!==null,onConfirm:()=>p(l),onCancel:()=>u(null)})]})}function jHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(null),{data:a=[],isLoading:o}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:15e3}),s=J({mutationFn:e=>od.deleteDevice(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`spoolbuddy-devices`]}),n(e(`settings.spoolbuddy.unregisterSuccess`),`success`),i(null)},onError:t=>{n(t.message||e(`settings.spoolbuddy.unregisterError`),`error`)}});if(o)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})});let c=a.length>1;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`settings.spoolbuddy.infoTitle`)}),(0,K.jsx)(`p`,{children:e(`settings.spoolbuddy.infoBody`)})]})]})})}),c&&(0,K.jsx)(_d,{className:`border-l-4 border-l-yellow-500`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`settings.spoolbuddy.duplicatesTitle`,{count:a.length})}),(0,K.jsx)(`p`,{children:e(`settings.spoolbuddy.duplicatesBody`)})]})]})})}),a.length===0?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 text-center text-bambu-gray text-sm`,children:e(`settings.spoolbuddy.empty`)})}):(0,K.jsx)(`div`,{className:`space-y-3`,children:a.map(e=>(0,K.jsx)(AHe,{device:e,onUnregister:i,isDeleting:s.isPending&&s.variables===e.device_id},e.id))}),r&&(0,K.jsx)(Ad,{variant:`danger`,title:e(`settings.spoolbuddy.confirmTitle`),message:e(`settings.spoolbuddy.confirmBody`,{hostname:r.hostname,deviceId:r.device_id}),confirmText:e(`settings.spoolbuddy.unregister`),isLoading:s.isPending,onConfirm:()=>s.mutate(r.device_id),onCancel:()=>i(null)})]})}function Z3(e){if(!e)return`-`;let t=vf(e);return t?t.toLocaleString():`-`}function Q3({status:e}){if(!e)return null;let t={success:`bg-green-500/20 text-green-400`,failed:`bg-red-500/20 text-red-400`,skipped:`bg-yellow-500/20 text-yellow-400`,running:`bg-blue-500/20 text-blue-400`},n={success:(0,K.jsx)(ps,{className:`w-3 h-3`}),failed:(0,K.jsx)(ys,{className:`w-3 h-3`}),skipped:(0,K.jsx)(Zl,{className:`w-3 h-3`}),running:(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})};return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${t[e]||`bg-gray-500/20 text-gray-400`}`,children:[n[e],e.charAt(0).toUpperCase()+e.slice(1)]})}var MHe={github:`backup.repoUrlPlaceholderGitHub`,gitea:`backup.repoUrlPlaceholderGitea`,forgejo:`backup.repoUrlPlaceholderForgejo`,gitlab:`backup.repoUrlPlaceholderGitLab`},NHe={github:`ghp_xxxxxxxxxxxx`,gitea:`your_access_token`,forgejo:`your_access_token`,gitlab:`glpat-xxxxxxxxxxxx`};function $3(e){return JSON.stringify(e)}function PHe(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))e[r]!==t[r]&&(n[r]=e[r]);return n}function FHe(){let e=no(),{showToast:t}=Td(),{t:n}=W(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`main`),[l,u]=(0,y.useState)(`github`),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(`daily`),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(!0),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),ee=(0,y.useRef)(null),[te,ne]=(0,y.useState)(null),[re,ie]=(0,y.useState)(null),[H,ae]=(0,y.useState)(``),{data:oe,refetch:U}=q({queryKey:[`local-backup-status`],queryFn:Q.getLocalBackupStatus,refetchInterval:e=>e.state.data?.is_running?1e3:1e4}),{data:se,refetch:ce}=q({queryKey:[`local-backup-files`],queryFn:Q.getLocalBackups,refetchInterval:3e4});(0,y.useEffect)(()=>{oe?.path!==void 0&&ae(oe.path)},[oe?.path]);let le=J({mutationFn:Q.triggerLocalBackup,onSuccess:e=>{e.success?t(n(`backup.scheduledBackupComplete`)):t(e.message,`error`),U(),ce()},onError:()=>t(n(`backup.scheduledBackupFailed`),`error`)}),ue=J({mutationFn:e=>Q.deleteLocalBackup(e),onSuccess:()=>{ce(),ne(null)}}),de=J({mutationFn:async e=>(ie(null),N(!0),V(null),F(n(`backup.restoring`)),Q.restoreLocalBackup(e)),onSuccess:e=>{N(!1),F(``),e.success?(V({success:!0,message:e.message}),t(n(`backup.backupRestoredRestart`),`success`)):(V({success:!1,message:e.message}),t(e.message,`error`))},onError:e=>{N(!1),F(``);let r=e instanceof Error?e.message:n(`backup.failedToRestore`);V({success:!1,message:r}),t(r,`error`)}});(0,y.useEffect)(()=>{if(A||M){let e=e=>(e.preventDefault(),e.returnValue=`A backup operation is in progress. Are you sure you want to leave?`,e.returnValue);return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)}},[A,M]);let[fe,pe]=(0,y.useState)(!1),[me,he]=(0,y.useState)(null),[ge,_e]=(0,y.useState)(null),ve=(0,y.useRef)(null),ye=(0,y.useRef)(null),be=(0,y.useRef)(null),xe=(0,y.useRef)(null),Se=(0,y.useRef)(``),[Ce,we]=(0,y.useState)(!1),Te=(0,y.useMemo)(()=>({repository_url:r,branch:s,provider:l,allow_insecure_http:E,schedule_enabled:d,schedule_type:p,backup_kprofiles:h,backup_cloud_profiles:_,backup_settings:b,backup_spools:S,backup_archives:w,enabled:O}),[r,s,l,E,d,p,h,_,b,S,w,O]),Ee=(0,y.useMemo)(()=>$3(Te),[Te]),{data:De,isLoading:Oe}=q({queryKey:[`github-backup-config`],queryFn:Q.getGitHubBackupConfig}),{data:ke}=q({queryKey:[`github-backup-status`],queryFn:Q.getGitHubBackupStatus,refetchInterval:e=>e.state.data?.is_running?500:1e4}),{data:Ae}=q({queryKey:[`github-backup-logs`],queryFn:()=>Q.getGitHubBackupLogs(20)}),{data:je}=q({queryKey:[`cloud-status`],queryFn:Q.getCloudStatus}),{data:Me}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),Ne=_o({queries:(Me??[]).map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),staleTime:1e4,refetchInterval:3e4}))}),Pe=(Me??[]).map((e,t)=>({printer:e,connected:Ne[t]?.data?.connected??!1})),Fe=Pe.length,Ie=Pe.filter(e=>e.connected).length,Le=Fe>0&&Ie===0,Re=Ie>0&&Ie(be.current&&clearTimeout(be.current),De?(we(!1),xe.current={repository_url:De.repository_url,branch:De.branch,provider:De.provider??`github`,allow_insecure_http:De.allow_insecure_http??!1,schedule_enabled:De.schedule_enabled,schedule_type:De.schedule_type,backup_kprofiles:De.backup_kprofiles,backup_cloud_profiles:De.backup_cloud_profiles,backup_settings:De.backup_settings,backup_spools:De.backup_spools,backup_archives:De.backup_archives,enabled:De.enabled},i(De.repository_url),c(De.branch),u(De.provider??`github`),f(De.schedule_enabled),m(De.schedule_type),g(De.backup_kprofiles),v(De.backup_cloud_profiles),x(De.backup_settings),C(De.backup_spools),T(De.backup_archives),D(De.allow_insecure_http??!1),k(De.enabled),o(``),be.current=setTimeout(()=>{we(!0)},100)):(we(!1),xe.current=null,o(``)),()=>{be.current&&clearTimeout(be.current)}),[De]);let ze=(0,y.useCallback)(async(r=!1)=>{if(De)try{r&&a?(await Q.saveGitHubBackupConfig({...Te,access_token:a}),o(``),_e(null),t(n(`backup.tokenUpdated`)),Se.current=``):(await Q.updateGitHubBackupConfig(PHe(Te,xe.current)),_e(null),t(n(`backup.settingsSaved`))),xe.current=Te,e.invalidateQueries({queryKey:[`github-backup-config`]}),e.invalidateQueries({queryKey:[`github-backup-status`]})}catch(e){_e(e.message)}},[De,a,Te,e,t,n]),Be=(0,y.useRef)(ze);(0,y.useEffect)(()=>{Be.current=ze},[ze]),(0,y.useEffect)(()=>{if(!(!Ce||!De)&&!(xe.current&&Ee===$3(xe.current)))return ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{ze(!1)},500),()=>{ve.current&&clearTimeout(ve.current)}},[Ce,De,Ee,ze]),(0,y.useEffect)(()=>{if(!(!Ce||!De||!a)&&a!==Se.current)return Se.current=a,ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{Be.current(!0)},1e3),()=>{ye.current&&clearTimeout(ye.current)}},[Ce,a,De]);let Ve=J({mutationFn:e=>Q.saveGitHubBackupConfig(e),onMutate:()=>{_e(null)},onSuccess:()=>{e.invalidateQueries({queryKey:[`github-backup-config`]}),e.invalidateQueries({queryKey:[`github-backup-status`]}),t(n(`backup.githubBackupEnabled`)),o(``),we(!0)},onError:e=>{_e(e.message)}}),He=J({mutationFn:Q.triggerGitHubBackup,onSuccess:r=>{e.invalidateQueries({queryKey:[`github-backup-status`]}),e.invalidateQueries({queryKey:[`github-backup-logs`]}),r.success?r.files_changed>0?t(n(`backup.backupCompleteFiles`,{count:r.files_changed})):t(n(`backup.backupSkippedNoChanges`)):t(n(`backup.backupFailed2`,{message:r.message}),`error`)},onError:e=>{t(n(`backup.backupFailed2`,{message:e.message}),`error`)}}),Ue=J({mutationFn:()=>Q.clearGitHubBackupLogs(0),onSuccess:r=>{e.invalidateQueries({queryKey:[`github-backup-logs`]}),t(n(`backup.clearedLogs`,{count:r.deleted}))},onError:e=>{t(n(`backup.failedToClearLogs`,{message:e.message}),`error`)}}),We=async()=>{pe(!0),he(null);try{let e;if(a){if(!r){t(n(`backup.enterRepoUrl`),`error`),pe(!1);return}e=await Q.testGitHubConnection(r,a,l)}else if(De?.has_token)e=await Q.testGitHubStoredConnection();else{t(n(`backup.enterRepoAndToken`),`error`),pe(!1);return}he({success:e.success,message:e.message,isPrivate:e.is_private})}catch(e){he({success:!1,message:e.message,isPrivate:null})}finally{pe(!1)}};return Oe?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-backup-github`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(yc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.githubBackup`)})]}),De&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`backup.enabled`)}),(0,K.jsx)(cU,{checked:O,onChange:k})]})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.githubDescription`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`git-provider-select`,className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.provider`)}),(0,K.jsxs)(`select`,{id:`git-provider-select`,value:l,onChange:e=>{u(e.target.value),he(null),_e(null)},className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`github`,children:n(`backup.providerGitHub`)}),(0,K.jsx)(`option`,{value:`gitlab`,children:n(`backup.providerGitLab`)}),(0,K.jsx)(`option`,{value:`gitea`,children:n(`backup.providerGitea`)}),(0,K.jsx)(`option`,{value:`forgejo`,children:n(`backup.providerForgejo`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.repositoryUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:r,onChange:e=>{i(e.target.value),he(null),_e(null)},placeholder:n(MHe[l]),className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>{D(e.target.checked),he(null)},className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`backup.allowInsecureHttp`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.allowInsecureHttpHint`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`backup.personalAccessToken`),` `,De?.has_token&&(0,K.jsx)(`span`,{className:`text-green-400`,children:n(`backup.tokenSaved`)})]}),(0,K.jsx)(`input`,{type:`password`,value:a,onChange:e=>{o(e.target.value),he(null),_e(null)},placeholder:De?.has_token?n(`backup.enterNewToken`):NHe[l],className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`backup.tokenHint`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.branch`)}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`main`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.autoBackup`)}),(0,K.jsxs)(`select`,{value:d?p:`disabled`,onChange:e=>{e.target.value===`disabled`?f(!1):(f(!0),m(e.target.value))},className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`disabled`,children:n(`backup.manualOnly`)}),(0,K.jsx)(`option`,{value:`hourly`,children:n(`backup.hourly`)}),(0,K.jsx)(`option`,{value:`daily`,children:n(`backup.daily`)}),(0,K.jsx)(`option`,{value:`weekly`,children:n(`backup.weekly`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:n(`backup.includeInBackup`)}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-start gap-2 ${Le?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`,disabled:Le}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm ${Le?`text-bambu-gray`:`text-white`}`,children:n(`backup.kProfiles`)}),Le&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.noPrintersConnected`)]}),Re&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.printersConnected`,{connected:Ie,total:Fe})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.kProfilesDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 ${je?.is_authenticated?`cursor-pointer`:`cursor-not-allowed opacity-60`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`,disabled:!je?.is_authenticated}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm ${je?.is_authenticated?`text-white`:`text-bambu-gray`}`,children:n(`backup.cloudProfiles`)}),!je?.is_authenticated&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.cloudLoginRequiredShort`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.cloudProfilesDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.appSettings`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.appSettingsDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.spoolInventory`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.spoolInventoryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.printArchives`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.printArchivesDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 space-y-3`,children:[ke?.configured&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:ke.last_backup_at?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{children:[n(`backup.lastBackupAt`),` `,wf(ke.last_backup_at,`system`,n)]}),(0,K.jsx)(Q3,{status:ke.last_backup_status})]}):(0,K.jsx)(`span`,{children:n(`backup.noBackupsYet`)})}),ke.next_scheduled_run&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 inline mr-1`}),n(`backup.next`),` `,wf(ke.next_scheduled_run,`system`,n)]})]}),ge&&(0,K.jsxs)(`div`,{className:`text-sm text-red-400 bg-red-500/10 border border-red-500/30 rounded p-3 flex items-start gap-2`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`div`,{className:`flex-1 leading-relaxed whitespace-pre-wrap break-words`,children:ge}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>_e(null),className:`text-bambu-gray hover:text-white shrink-0`,"aria-label":n(`common.dismiss`,`Dismiss`),children:(0,K.jsx)(ys,{className:`w-4 h-4`})})]}),me&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`text-sm flex items-center gap-1 ${me.success?`text-green-400`:`text-red-400`}`,children:[me.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(ys,{className:`w-4 h-4`}),me.message]}),me.success&&me.isPrivate===!0&&(0,K.jsxs)(`div`,{className:`text-xs flex items-center gap-1 text-green-400`,children:[(0,K.jsx)(ps,{className:`w-3.5 h-3.5`}),n(`backup.repoIsPrivate`,`Repository is private — safe to back up to.`)]}),me.success&&me.isPrivate===!1&&(0,K.jsxs)(`div`,{className:`text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded p-2 flex items-start gap-1.5`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`backup.repoIsPublicWarning`,`Repository is PUBLIC. Bambuddy backups include MQTT credentials, Home Assistant tokens, Prometheus tokens, your Bambu Cloud email, and printer access codes via K-profiles. Saving is blocked until you make the repository private in your provider's settings.`)})]}),me.success&&me.isPrivate===null&&(0,K.jsxs)(`div`,{className:`text-xs text-yellow-400 bg-yellow-500/10 border border-yellow-500/30 rounded p-2 flex items-start gap-1.5`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`backup.repoVisibilityUnknown`,`Could not determine repository visibility. Bambuddy refuses to back up to anything not confirmed private; saving will be blocked.`)})]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:ke?.configured?(0,K.jsx)(K.Fragment,{children:He.isPending||ke.is_running?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{className:`text-sm`,children:ke.progress||n(`backup.startingBackup`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>He.mutate(),disabled:!De?.enabled,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),n(`backup.backupNow`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:We,disabled:fe,children:[fe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),n(`backup.test`)]})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>{if(!r){t(n(`backup.repoRequired`),`error`);return}if(!a){t(n(`backup.tokenRequired`),`error`);return}Ve.mutate({repository_url:r,access_token:a,branch:s,provider:l,allow_insecure_http:E,schedule_enabled:d,schedule_type:p,backup_kprofiles:h,backup_cloud_profiles:_,backup_settings:b,backup_spools:S,backup_archives:w,enabled:O})},disabled:Ve.isPending||!r||!a,children:[Ve.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(ps,{className:`w-4 h-4`}),n(`backup.enableBackup`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:We,disabled:fe||!r||!a,children:[fe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),n(`backup.testConnection`)]})]})})]})]})]}),Ae&&Ae.length>0&&(0,K.jsxs)(_d,{id:`card-backup-history`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.history`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>Ue.mutate(),disabled:Ue.isPending,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),n(`backup.clear`)]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.date`)}),(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.status`)}),(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.commit`)})]})}),(0,K.jsx)(`tbody`,{children:Ae.slice(0,10).map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary`,children:[(0,K.jsx)(`td`,{className:`py-2 px-2 text-white`,children:Z3(e.started_at)}),(0,K.jsx)(`td`,{className:`py-2 px-2`,children:(0,K.jsx)(Q3,{status:e.status})}),(0,K.jsx)(`td`,{className:`py-2 px-2`,children:e.commit_sha?(0,K.jsxs)(`a`,{href:`${De?.repository_url}/commit/${e.commit_sha}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline inline-flex items-center gap-1`,children:[e.commit_sha.substring(0,7),(0,K.jsx)(Js,{className:`w-3 h-3`})]}):(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`-`})})]},e.id))})]})})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-backup-local`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.localBackup`)})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.localBackupDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:n(`backup.downloadBackupLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.completeBackupZip`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:A||M,onClick:async()=>{j(!0),F(n(`backup.preparingBackup`));try{F(n(`backup.creatingArchive`));let{blob:e,filename:r}=await Q.exportBackup();F(n(`backup.downloadingFile`));let i=URL.createObjectURL(e),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),t(n(`backup.backupDownloaded`))}catch(e){t(n(`backup.failedToCreateBackup`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}finally{j(!1),F(``)}},children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),n(`backup.download`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:n(`backup.restoreBackup`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.restoreDescription`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.restoreNote`)})]}),(0,K.jsx)(`input`,{ref:ee,type:`file`,accept:`.zip`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&(z(t),L(!0)),e.target.value=``}}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:M||A,onClick:()=>ee.current?.click(),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`backup.restore`)]})]}),B&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg ${B.success?`bg-green-500/10 border border-green-500/30`:`bg-red-500/10 border border-red-500/30`}`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[B.success?(0,K.jsx)(ps,{className:`w-4 h-4 text-green-400 mt-0.5 flex-shrink-0`}):(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:B.success?`text-green-200`:`text-red-200`,children:[B.message,B.success&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsxs)($,{size:`sm`,onClick:()=>window.location.reload(),children:[(0,K.jsx)(Al,{className:`w-3 h-3`}),n(`backup.reloadNow`)]})})]})]})}),(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`text-yellow-200`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n(`backup.restoreReplacesAll`)}),` `,(0,K.jsx)(`span`,{className:`text-yellow-200/70`,children:n(`backup.restoreReplacesAllDetail`)})]})]})})]})]}),(0,K.jsxs)(_d,{id:`card-backup-scheduled`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(oc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.scheduledBackup`)})]}),(0,K.jsx)(cU,{checked:oe?.enabled??!1,onChange:async r=>{try{await Q.updateSettings({local_backup_enabled:r}),e.invalidateQueries({queryKey:[`settings`]}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.scheduledBackupDescription`)}),oe?.enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.frequency`)}),(0,K.jsxs)(`select`,{value:oe?.schedule??`daily`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onChange:async e=>{try{await Q.updateSettings({local_backup_schedule:e.target.value}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()},children:[(0,K.jsx)(`option`,{value:`hourly`,children:n(`backup.hourly`)}),(0,K.jsx)(`option`,{value:`daily`,children:n(`backup.daily`)}),(0,K.jsx)(`option`,{value:`weekly`,children:n(`backup.weekly`)})]})]}),(oe?.schedule??`daily`)!==`hourly`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.backupTime`)}),(0,K.jsx)(`input`,{type:`time`,value:oe?.time??`03:00`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none [color-scheme:dark]`,onChange:async e=>{try{await Q.updateSettings({local_backup_time:e.target.value}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.localTimeHint`,{tz:oe?.timezone||`UTC`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.retention`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:100,value:oe?.retention??5,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onChange:async e=>{let r=Math.max(1,Math.min(100,parseInt(e.target.value)||5));try{await Q.updateSettings({local_backup_retention:r}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.retentionDescription`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.outputPath`)}),(0,K.jsx)(`input`,{type:`text`,value:H,onChange:e=>ae(e.target.value),className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onBlur:async()=>{try{await Q.updateSettings({local_backup_path:H}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U(),ce()},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:H?n(`backup.outputPathDescription`):(0,K.jsxs)(K.Fragment,{children:[n(`backup.defaultPathLabel`),` `,(0,K.jsx)(`code`,{className:`text-bambu-gray`,children:oe?.default_path||`...`})]})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`text-sm`,children:[oe?.last_backup_at&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsxs)(`span`,{children:[n(`backup.lastBackup`),`:`]}),(0,K.jsx)(Q3,{status:oe.last_status}),(0,K.jsx)(`span`,{children:wf(oe.last_backup_at)})]}),oe?.next_run&&(0,K.jsxs)(`div`,{className:`text-bambu-gray mt-1`,children:[(0,K.jsxs)(`span`,{children:[n(`backup.nextBackup`),`: `]}),(0,K.jsx)(`span`,{children:Z3(oe.next_run)})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:oe?.is_running||le.isPending,onClick:()=>le.mutate(),children:[oe?.is_running||le.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bl,{className:`w-4 h-4`}),oe?.is_running?n(`backup.backupRunning`):n(`backup.runNow`)]})]}),se&&se.length>0&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:n(`backup.backupFiles`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:se.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-bambu-dark-tertiary/50 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-white truncate block`,children:e.filename}),(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[(e.size/1024/1024).toFixed(1),` MB · `,Z3(e.created_at)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-bambu-green p-1`,title:n(`backup.download`),onClick:async()=>{try{let{blob:t,filename:n}=await Q.downloadLocalBackup(e.filename),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}catch{t(n(`backup.scheduledBackupFailed`),`error`)}},children:(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-yellow-400 p-1`,title:n(`backup.restore`),onClick:()=>ie(e.filename),children:(0,K.jsx)(Al,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-red-400 p-1`,onClick:()=>ne(e.filename),title:n(`backup.deleteBackup`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})})]})]},e.filename))})]}),se&&se.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-3 border-t border-bambu-dark-tertiary`,children:n(`backup.noScheduledBackups`)})]})]})]})]}),te&&(0,K.jsx)(Ad,{title:n(`backup.deleteBackup`),message:n(`backup.deleteBackupConfirm`),confirmText:n(`backup.deleteBackup`),variant:`danger`,onConfirm:()=>ue.mutate(te),onCancel:()=>ne(null)}),re&&(0,K.jsx)(Ad,{title:n(`backup.restoreConfirmTitle`),message:n(`backup.restoreConfirmMessage`,{filename:re}),confirmText:n(`backup.restoreConfirmButton`),variant:`danger`,onConfirm:()=>de.mutate(re),onCancel:()=>ie(null)}),I&&R&&(0,K.jsx)(Ad,{title:n(`backup.restoreConfirmTitle`),message:n(`backup.restoreConfirmMessage`,{filename:R.name}),confirmText:n(`backup.restoreConfirmButton`),variant:`danger`,onConfirm:async()=>{L(!1),N(!0),V(null);try{F(n(`backup.uploadingFile`));let e=await Q.importBackup(R);V(e),e.success?t(n(`backup.backupRestoredRestart`),`success`):t(e.message,`error`)}catch(e){let r=e instanceof Error?e.message:n(`backup.failedToRestore`);V({success:!1,message:r}),t(r,`error`)}finally{N(!1),F(``),z(null)}},onCancel:()=>{L(!1),z(null)}}),(A||M)&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-[100]`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center`,children:[(0,K.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full`}),(0,K.jsx)(`div`,{className:`w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin`})]})}),(0,K.jsx)(`h3`,{className:`text-xl font-semibold text-white mb-2`,children:n(A?`backup.creatingBackup`:`backup.restoringBackup`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:P||n(A?`backup.preparing`:`backup.processing`)}),(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-yellow-200 text-left`,children:n(`backup.doNotClosePage`)})]})})]})})]})}function IHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`medium`),[l,u]=(0,y.useState)(`notify`),[d,f]=(0,y.useState)(10),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),{data:b}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:x,refetch:S}=q({queryKey:[`obico-status`],queryFn:Q.getObicoStatus,refetchInterval:1e4}),{data:C}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{if(b){i(b.obico_enabled??!1),o(b.obico_ml_url??``),c(b.obico_sensitivity??`medium`),u(b.obico_action??`notify`),f(b.obico_poll_interval??10);try{let e=b.obico_enabled_printers?JSON.parse(b.obico_enabled_printers):null;m(Array.isArray(e)?e:null)}catch{m(null)}v(!0)}},[b]);let w=J({mutationFn:()=>Q.updateSettings({obico_enabled:r,obico_ml_url:a,obico_sensitivity:s,obico_action:l,obico_poll_interval:d,obico_enabled_printers:p===null?``:JSON.stringify(p)}),onSuccess:()=>{t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`obico-status`]}),n(e(`settings.toast.settingsSaved`))}});(0,y.useEffect)(()=>{if(!_||!b||!(b.obico_enabled!==r||b.obico_ml_url!==a||b.obico_sensitivity!==s||b.obico_action!==l||b.obico_poll_interval!==d||b.obico_enabled_printers!==(p===null?``:JSON.stringify(p))))return;let e=setTimeout(()=>w.mutate(),500);return()=>clearTimeout(e)},[r,a,s,l,d,p,_]);let T=async()=>{g(null);try{let t=await Q.testObicoConnection(a);t.ok?g({ok:!0,message:e(`failureDetection.testSuccess`)}):g({ok:!1,message:t.error||`HTTP ${t.status_code??`?`} — ${t.body??e(`failureDetection.testFailed`)}`})}catch(e){g({ok:!1,message:e instanceof Error?e.message:String(e)})}},E=(e,t)=>{if(p===null){let n=C?.map(e=>e.id)??[];m(t?n:n.filter(t=>t!==e));return}m(t?[...p,e]:p.filter(t=>t!==e))};return(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-fd-ml`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Fl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.title`)})]}),(0,K.jsx)(cU,{checked:r,onChange:i})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:e(`failureDetection.description`)})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.mlUrl`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`http://192.168.1.10:3333`,className:`flex-1 bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,disabled:!r}),(0,K.jsx)($,{onClick:T,disabled:!a||w.isPending,variant:`secondary`,children:e(`failureDetection.test`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.mlUrlHint`)}),h&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 mt-2 text-sm ${h.ok?`text-green-400`:`text-red-400`}`,children:[h.ok?(0,K.jsx)(rs,{className:`w-4 h-4 mt-0.5`}):(0,K.jsx)(Ru,{className:`w-4 h-4 mt-0.5`}),(0,K.jsx)(`span`,{children:h.message})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.sensitivity`)}),(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:`low`,children:e(`failureDetection.sensitivityLow`)}),(0,K.jsx)(`option`,{value:`medium`,children:e(`failureDetection.sensitivityMedium`)}),(0,K.jsx)(`option`,{value:`high`,children:e(`failureDetection.sensitivityHigh`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.sensitivityHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.action`)}),(0,K.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:`notify`,children:e(`failureDetection.actionNotify`)}),(0,K.jsx)(`option`,{value:`pause`,children:e(`failureDetection.actionPause`)}),(0,K.jsx)(`option`,{value:`pause_and_off`,children:e(`failureDetection.actionPauseOff`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.pollInterval`)}),(0,K.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(Math.max(5,Math.min(120,Number(e.target.value)||10))),min:5,max:120,disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.pollIntervalHint`)})]}),x&&!x.external_url_configured&&r&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-amber-900/30 border border-amber-700 rounded text-sm text-amber-200`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e(`failureDetection.externalUrlMissing`)}),(0,K.jsx)(`div`,{className:`text-xs mt-1`,children:e(`failureDetection.externalUrlHint`)})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-fd-perprinter`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.perPrinterTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`failureDetection.perPrinterHint`)})]}),(0,K.jsxs)(yd,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p===null,onChange:e=>m(e.target.checked?null:C?.map(e=>e.id)??[]),disabled:!r}),(0,K.jsx)(`span`,{className:`text-white`,children:e(`failureDetection.monitorAll`)})]}),p!==null&&C&&(0,K.jsx)(`div`,{className:`pl-5 space-y-1 border-l border-gray-700`,children:C.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p.includes(e.id),onChange:t=>E(e.id,t.target.checked),disabled:!r}),(0,K.jsx)(`span`,{className:`text-white`,children:e.name})]},e.id))})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-fd-status`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.statusTitle`)})}),(0,K.jsx)(yd,{children:x?(0,K.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`failureDetection.serviceRunning`)}),(0,K.jsx)(`span`,{className:x.is_running?`text-green-400`:`text-red-400`,children:x.is_running?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`failureDetection.thresholds`)}),(0,K.jsxs)(`span`,{className:`text-white font-mono`,children:[x.thresholds.low.toFixed(2),` / `,x.thresholds.high.toFixed(2)]})]}),x.last_error&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-red-400`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`break-words`,children:x.last_error})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray mb-1`,children:e(`failureDetection.activePrinters`)}),Object.keys(x.per_printer).length===0?(0,K.jsx)(`div`,{className:`text-bambu-gray italic text-xs`,children:e(`failureDetection.noActivePrints`)}):(0,K.jsx)(`div`,{className:`space-y-1`,children:Object.entries(x.per_printer).map(([e,t])=>{let n=C?.find(t=>String(t.id)===e),r=t.class===`failure`?`text-red-400`:t.class===`warning`?`text-amber-400`:`text-green-400`;return(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:n?.name??`Printer ${e}`}),(0,K.jsxs)(`span`,{className:`font-mono ${r}`,children:[t.class,` (`,t.score.toFixed(3),`, `,t.frame_count,`f)`]})]},e)})})]})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:e(`common.loading`)})]})})]}),(0,K.jsxs)(_d,{id:`card-fd-history`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.historyTitle`)}),(0,K.jsx)(`button`,{onClick:()=>S(),className:`text-xs text-bambu-gray hover:text-white`,children:e(`common.refresh`)})]})}),(0,K.jsx)(yd,{children:!x||x.history.length===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:e(`failureDetection.noHistory`)})]}):(0,K.jsx)(`div`,{className:`space-y-1 max-h-96 overflow-y-auto text-xs font-mono`,children:x.history.map((e,t)=>{let n=C?.find(t=>t.id===e.printer_id),r=e.class===`failure`?`text-red-400`:e.class===`warning`?`text-amber-400`:`text-bambu-gray`;return(0,K.jsxs)(`div`,{className:`flex justify-between gap-2 py-1 border-b border-gray-800`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,K.jsx)(`span`,{className:`text-white truncate`,children:n?.name??`#${e.printer_id}`}),(0,K.jsxs)(`span`,{className:r,children:[e.class,` `,e.score.toFixed(3)]})]},t)})})})]})]})]})}var LHe={starttls:587,ssl:465,none:25},RHe={587:`starttls`,465:`ssl`,25:`none`};function zHe(){let{t:e}=W(),{showToast:t}=Td(),n=no(),[r,i]=(0,y.useState)({smtp_host:``,smtp_port:587,smtp_username:``,smtp_password:``,smtp_security:`starttls`,smtp_auth_enabled:!0,smtp_from_email:``,smtp_from_name:`BamBuddy`}),[a,o]=(0,y.useState)(``),{data:s,isLoading:c}=q({queryKey:[`smtpSettings`],queryFn:()=>Q.getSMTPSettings()}),{authEnabled:l}=dd(),{data:u}=q({queryKey:[`advancedAuthStatus`],queryFn:()=>Q.getAdvancedAuthStatus()});(0,y.useEffect)(()=>{s&&i({...s,smtp_password:``})},[s]);let d=e=>{i({...r,smtp_security:e,smtp_port:LHe[e]})},f=e=>{let t=RHe[e];i({...r,smtp_port:e,...t?{smtp_security:t}:{}})},p=e=>{i({...r,smtp_auth_enabled:e,...e?{}:{smtp_username:``,smtp_password:``}})},m=J({mutationFn:e=>Q.saveSMTPSettings(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`smtpSettings`]}),n.invalidateQueries({queryKey:[`advancedAuthStatus`]}),t(e(`settings.email.success.settingsSaved`),`success`)},onError:e=>{t(e.message,`error`)}}),h=J({mutationFn:e=>Q.testSMTP(e),onSuccess:e=>{t(e.message,e.success?`success`:`error`)},onError:e=>{t(e.message,`error`)}}),g=J({mutationFn:e=>e?Q.enableAdvancedAuth():Q.disableAdvancedAuth(),onSuccess:e=>{n.invalidateQueries({queryKey:[`advancedAuthStatus`]}),t(e.message,`success`)},onError:e=>{t(e.message,`error`)}}),_=()=>{if(!r.smtp_host||!r.smtp_from_email){t(e(`settings.email.errors.requiredFields`),`error`);return}if(r.smtp_auth_enabled&&!r.smtp_username){t(e(`settings.email.errors.usernameRequired`),`error`);return}m.mutate(r)},v=()=>{if(!a){t(e(`settings.email.errors.enterTestEmail`),`error`);return}h.mutate({test_recipient:a})},b=()=>{if(!l){t(e(`settings.email.errors.enableAuthFirst`),`error`);return}if(!u?.advanced_auth_enabled&&!u?.smtp_configured){t(e(`settings.email.errors.configureSmtpFirst`),`error`);return}g.mutate(!u?.advanced_auth_enabled)};if(c)return(0,K.jsx)(`div`,{className:`flex items-center justify-center p-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});let x=u?.advanced_auth_enabled??!1,S=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,C=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white/40 placeholder-bambu-gray/40 cursor-not-allowed`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-email-advanced-auth`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.advancedAuth`)||`Advanced Authentication`})]}),(0,K.jsx)($,{onClick:b,disabled:g.isPending,variant:x?`danger`:`primary`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),e(`settings.email.disable`)||`Disable`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),e(`settings.email.enable`)||`Enable`]})})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:x?(0,K.jsx)(`div`,{className:`bg-green-500/10 border border-green-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-green-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.email.advancedAuthEnabled`)||`Advanced Authentication is enabled`}),(0,K.jsxs)(`ul`,{className:`text-sm text-green-300 space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`settings.email.feature1`)||`Passwords are auto-generated and emailed to new users`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature2`)||`Users can login with username or email`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature3`)||`Forgot password feature is available`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature4`)||`Admins can reset user passwords via email`})]})]})]})}):(0,K.jsx)(`div`,{className:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.email.advancedAuthDisabled`)||`Advanced Authentication is disabled`}),(0,K.jsx)(`p`,{className:`text-sm text-yellow-300`,children:e(`settings.email.advancedAuthDisabledDesc`)||`Enable advanced authentication to activate email-based features for user management.`})]})]})})})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsx)(`div`,{className:`lg:col-span-2`,children:(0,K.jsxs)(_d,{id:`card-smtp-config`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.smtpSettings`)||`SMTP Configuration`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.authentication`)||`Authentication`}),(0,K.jsxs)(`select`,{value:r.smtp_auth_enabled?`true`:`false`,onChange:e=>p(e.target.value===`true`),className:S,children:[(0,K.jsx)(`option`,{value:`true`,children:e(`settings.email.authOptions.enabled`)}),(0,K.jsx)(`option`,{value:`false`,children:e(`settings.email.authOptions.disabled`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 transition-opacity ${r.smtp_auth_enabled?``:`opacity-40 pointer-events-none`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.username`)||`Username`}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_username||``,onChange:e=>i({...r,smtp_username:e.target.value}),placeholder:`your.email@gmail.com`,disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?S:C})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.password`)||`Password`}),(0,K.jsx)(`input`,{type:`password`,value:r.smtp_password||``,onChange:e=>i({...r,smtp_password:e.target.value}),placeholder:s?`••••••••`:`App password`,disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?S:C})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:[e(`settings.email.smtpHost`)||`SMTP Server`,` *`]}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_host,onChange:e=>i({...r,smtp_host:e.target.value}),placeholder:`smtp.gmail.com`,className:S})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.smtpPort`)||`SMTP Port`}),(0,K.jsx)(`input`,{type:`number`,value:r.smtp_port,onChange:e=>f(parseInt(e.target.value)||587),placeholder:`587`,className:S})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.security`)||`Security`}),(0,K.jsxs)(`select`,{value:r.smtp_security,onChange:e=>d(e.target.value),className:S,children:[(0,K.jsx)(`option`,{value:`starttls`,children:e(`settings.email.securityOptions.starttls`)}),(0,K.jsx)(`option`,{value:`ssl`,children:e(`settings.email.securityOptions.ssl`)}),(0,K.jsx)(`option`,{value:`none`,children:e(`settings.email.securityOptions.none`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:[e(`settings.email.fromEmail`)||`From Email`,` *`]}),(0,K.jsx)(`input`,{type:`email`,value:r.smtp_from_email,onChange:e=>i({...r,smtp_from_email:e.target.value}),placeholder:`your@email.com`,className:S})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.fromName`)||`From Name`}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_from_name,onChange:e=>i({...r,smtp_from_name:e.target.value}),placeholder:`BamBuddy`,className:S})]})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsx)($,{onClick:_,disabled:m.isPending,className:`flex-1`,children:m.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),e(`settings.email.saving`)||`Saving...`]}):e(`settings.email.save`)||`Save Settings`})})]})})]})}),(0,K.jsx)(`div`,{children:(0,K.jsxs)(_d,{id:`card-email-test`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.testConnection`)||`Test SMTP Connection`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.testRecipient`)||`Test Recipient Email`}),(0,K.jsx)(`input`,{type:`email`,value:a,onChange:e=>o(e.target.value),placeholder:`test@example.com`,className:S})]}),(0,K.jsx)($,{onClick:v,disabled:h.isPending,variant:`secondary`,children:h.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),e(`settings.email.sending`)||`Sending...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zl,{className:`w-4 h-4`}),e(`settings.email.sendTest`)||`Send Test Email`]})})]})})]})})]})]})}var BHe={starttls:`389`,ldaps:`636`};function VHe(){let{t:e}=W(),{showToast:t}=Td(),n=no(),{authEnabled:r}=dd(),[i,a]=(0,y.useState)({ldap_server_url:``,ldap_bind_dn:``,ldap_bind_password:``,ldap_search_base:``,ldap_user_filter:`(sAMAccountName={username})`,ldap_security:`starttls`,ldap_group_mapping:``,ldap_auto_provision:!1,ldap_default_group:``}),{data:o,isLoading:s}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),{data:c}=q({queryKey:[`ldapStatus`],queryFn:()=>Q.getLDAPStatus()}),{data:l=[]}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups()});(0,y.useEffect)(()=>{o&&a({ldap_server_url:o.ldap_server_url||``,ldap_bind_dn:o.ldap_bind_dn||``,ldap_bind_password:``,ldap_search_base:o.ldap_search_base||``,ldap_user_filter:o.ldap_user_filter||`(sAMAccountName={username})`,ldap_security:o.ldap_security||`starttls`,ldap_group_mapping:o.ldap_group_mapping||``,ldap_auto_provision:o.ldap_auto_provision??!1,ldap_default_group:o.ldap_default_group||``})},[o]);let u=J({mutationFn:e=>Q.updateSettings(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`settings`]}),n.invalidateQueries({queryKey:[`ldapStatus`]}),t(e(`settings.ldap.settingsSaved`)||`LDAP settings saved`,`success`)},onError:e=>{t(e.message,`error`)}}),d=J({mutationFn:e=>Q.updateSettings({ldap_enabled:e}),onSuccess:()=>{n.invalidateQueries({queryKey:[`settings`]}),n.invalidateQueries({queryKey:[`ldapStatus`]}),t(c?.ldap_enabled?e(`settings.ldap.disabled`)||`LDAP authentication disabled`:e(`settings.ldap.enabled`)||`LDAP authentication enabled`,`success`)},onError:e=>{t(e.message,`error`)}}),f=J({mutationFn:()=>Q.testLDAP(),onSuccess:e=>{t(e.message,e.success?`success`:`error`)},onError:e=>{t(e.message,`error`)}}),p=()=>{if(!i.ldap_server_url){t(e(`settings.ldap.errors.serverRequired`)||`LDAP server URL is required`,`error`);return}if(!i.ldap_search_base){t(e(`settings.ldap.errors.searchBaseRequired`)||`Search base DN is required`,`error`);return}let n={ldap_server_url:i.ldap_server_url,ldap_bind_dn:i.ldap_bind_dn,ldap_search_base:i.ldap_search_base,ldap_user_filter:i.ldap_user_filter,ldap_security:i.ldap_security,ldap_group_mapping:i.ldap_group_mapping,ldap_auto_provision:i.ldap_auto_provision,ldap_default_group:i.ldap_default_group};i.ldap_bind_password&&(n.ldap_bind_password=i.ldap_bind_password),u.mutate(n)},m=()=>{if(!r){t(e(`settings.ldap.errors.enableAuthFirst`)||`Enable authentication first`,`error`);return}if(!c?.ldap_enabled&&!c?.ldap_configured){t(e(`settings.ldap.errors.configureLdapFirst`)||`Save LDAP settings first`,`error`);return}d.mutate(!c?.ldap_enabled)};if(s)return(0,K.jsx)(`div`,{className:`flex items-center justify-center p-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});let h=c?.ldap_enabled??!1,g=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-ldap-toggle`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.ldap.title`)||`LDAP Authentication`})]}),(0,K.jsx)($,{onClick:m,disabled:d.isPending,variant:h?`danger`:`primary`,children:h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),e(`common.disable`)||`Disable`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),e(`common.enable`)||`Enable`]})})]})}),(0,K.jsx)(yd,{children:h?(0,K.jsx)(`div`,{className:`bg-green-500/10 border border-green-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-green-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.ldap.enabledDesc`)||`LDAP authentication is enabled`}),(0,K.jsxs)(`ul`,{className:`text-sm text-green-300 space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`settings.ldap.feature1`)||`Users can login with LDAP credentials`}),(0,K.jsx)(`li`,{children:e(`settings.ldap.feature2`)||`Local admin account remains as fallback`}),(0,K.jsx)(`li`,{children:e(`settings.ldap.feature3`)||`LDAP groups are mapped to BamBuddy groups on login`})]})]})]})}):(0,K.jsx)(`div`,{className:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.ldap.disabledDesc`)||`LDAP authentication is disabled`}),(0,K.jsx)(`p`,{className:`text-sm text-yellow-300 mt-1`,children:e(`settings.ldap.disabledHint`)||`Configure and save LDAP settings below, then enable.`})]})]})})})]}),(0,K.jsxs)(_d,{id:`card-ldap-server`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.ldap.serverConfig`)||`LDAP Server Configuration`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.serverUrl`)||`Server URL`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`ldaps://ldap.example.com:636`,value:i.ldap_server_url,onChange:e=>a({...i,ldap_server_url:e.target.value})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.serverUrlHint`)||`Use ldaps:// for SSL or ldap:// with StartTLS`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.security`)||`Security`}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:[`starttls`,`ldaps`].map(e=>(0,K.jsx)(`button`,{onClick:()=>a({...i,ldap_security:e}),className:`flex-1 px-2 py-2 rounded-lg text-sm font-medium transition-colors ${i.ldap_security===e?`bg-bambu-green text-black`:`bg-bambu-dark-secondary text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:e===`starttls`?`StartTLS`:`LDAPS`},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.securityHint`)||`Default port: ${BHe[i.ldap_security]}`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.bindDn`)||`Bind DN (Service Account)`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`cn=service-account,ou=service,dc=example,dc=com`,value:i.ldap_bind_dn,onChange:e=>a({...i,ldap_bind_dn:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.bindPassword`)||`Bind Password`}),(0,K.jsx)(`input`,{type:`password`,className:g,placeholder:o?.ldap_bind_dn?`••••••••`:``,value:i.ldap_bind_password,onChange:e=>a({...i,ldap_bind_password:e.target.value})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.searchBase`)||`Search Base DN`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`ou=users,dc=example,dc=com`,value:i.ldap_search_base,onChange:e=>a({...i,ldap_search_base:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.userFilter`)||`User Search Filter`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`(sAMAccountName={username})`,value:i.ldap_user_filter,onChange:e=>a({...i,ldap_user_filter:e.target.value})})]})]}),(0,K.jsx)(lp,{summary:(0,K.jsx)(`span`,{className:`text-sm font-medium text-bambu-gray`,children:e(`settings.ldap.advanced`)||`Advanced`}),className:`border-t border-bambu-dark-tertiary pt-3`,summaryClassName:`py-1`,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white`,children:e(`settings.ldap.autoProvision`)||`Auto-provision users`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e(`settings.ldap.autoProvisionHint`)||`Automatically create a BamBuddy account on first LDAP login`})]}),(0,K.jsx)(`button`,{onClick:()=>a({...i,ldap_auto_provision:!i.ldap_auto_provision}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors flex-shrink-0 ${i.ldap_auto_provision?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i.ldap_auto_provision?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.defaultGroup`)||`Default group`}),(0,K.jsxs)(`select`,{className:g,value:i.ldap_default_group,onChange:e=>a({...i,ldap_default_group:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:e(`settings.ldap.defaultGroupNone`)||`— None (reject login) —`}),l.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.defaultGroupHint`)||`Fallback group assigned when an LDAP user authenticates but is not listed in any mapped group. Leave empty to leave unmapped users without permissions.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.groupMapping`)||`Group Mapping (JSON)`}),(0,K.jsx)(`textarea`,{className:`${g} font-mono text-sm`,rows:4,placeholder:`{ +`),confirmText:e(`queue.filamentShort.printAnyway`),variant:`warning`,onConfirm:()=>{he.mutate({id:pe.itemId,skipFilamentCheck:!0})},onCancel:()=>me(null)}),v&&(0,K.jsx)(Ad,{title:v.type===`cancel`?e(`queue.confirm.cancelTitle`):v.type===`stop`?e(`queue.confirm.stopTitle`):e(`queue.confirm.removeTitle`),message:v.type===`cancel`?e(`queue.confirm.cancelMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisPrint`)}):v.type===`stop`?e(`queue.confirm.stopMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisPrint`)}):e(`queue.confirm.removeMessage`,{name:v.item.archive_name||v.item.library_file_name||e(`queue.confirm.thisItem`)}),confirmText:v.type===`cancel`?e(`queue.confirm.cancelButton`):v.type===`stop`?e(`queue.confirm.stopButton`):e(`common.remove`),variant:`danger`,onConfirm:()=>{v.type===`cancel`?ue.mutate(v.item.id):v.type===`stop`?fe.mutate(v.item.id):de.mutate(v.item.id),b(null)},onCancel:()=>b(null)}),T&&(0,K.jsx)(Ad,{title:e(`queue.resumeAfterFailure.confirmTitle`),message:e(`queue.resumeAfterFailure.confirmMessage`,{printer:T.printerName,count:T.skippedCount}),confirmText:e(`queue.resumeAfterFailure.button`),variant:`warning`,onConfirm:()=>be.mutate(T.printerId),onCancel:()=>E(null)}),f&&(0,K.jsx)(Ad,{title:e(`queue.confirm.clearHistoryTitle`),message:e(`queue.confirm.clearHistoryMessage`,{count:Ne.length}),confirmText:e(`queue.clearHistory`),variant:`danger`,onConfirm:()=>{_e.mutate(),p(!1)},onCancel:()=>p(!1)}),C&&(0,K.jsx)(dVe,{selectedCount:x.length,printers:ce?.map(e=>({id:e.id,name:e.name,nozzle_count:e.nozzle_count}))||[],onSave:e=>{Object.keys(e).length>0&&ve.mutate({item_ids:x,...e})},onClose:()=>w(!1),isSaving:ve.isPending,canControlPrinter:r(`printers:control`),t:e}),te&&(0,K.jsx)(hVe,{itemCount:x.length,isSaving:xe.isPending,defaultName:(()=>{let t=Ee.find(e=>x.includes(e.id)),n=(t?.archive_name||t?.library_file_name||``).replace(/\.gcode\.3mf$/i,``).replace(/\.3mf$/i,``);return n?`${n}`:e(`queue.batch.defaultName`)})(),onSave:e=>xe.mutate({name:e,item_ids:x}),onClose:()=>ne(!1),t:e}),re!==null&&(0,K.jsx)(Ad,{title:e(`queue.batch.ungroupConfirmTitle`),message:e(`queue.batch.ungroupConfirmMessage`),confirmText:e(`queue.batch.ungroup`),variant:`warning`,onConfirm:()=>Se.mutate(re),onCancel:()=>ie(null)})]})}function hVe({itemCount:e,defaultName:t,isSaving:n,onSave:r,onClose:i,t:a}){let[o,s]=(0,y.useState)(t);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 w-full max-w-md`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white mb-2 flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-cyan-300`}),a(`queue.batch.groupAsBatch`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:a(`queue.batch.groupAsBatchDescription`,{count:e})}),(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:a(`queue.batch.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:a(`queue.batch.namePlaceholder`),maxLength:120,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none mb-5`}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,disabled:n,children:a(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:()=>{let e=o.trim();e&&r(e)},disabled:n||!o.trim(),children:a(n?`common.saving`:`queue.batch.create`)})]})]})})}function gVe({printDates:e,months:t=3}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=n.current;if(!e)return;let t=new ResizeObserver(e=>{i(e[0]?.contentRect.width||0)});return t.observe(e),()=>t.disconnect()},[]);let{weeks:a,monthLabels:o,printCounts:s}=(0,y.useMemo)(()=>{let n={};e.forEach(e=>{let t=Df(e);t&&(n[t]=(n[t]||0)+1)});let r=new Date,i=new Date(r);i.setMonth(i.getMonth()-t),i.setDate(i.getDate()-i.getDay());let a=[],o=[],s=[],c=-1,l=new Date(i),u=0;for(;l<=r;)l.getDay()===0&&s.length>0&&(a.push(s),s=[],u++),l.getMonth()!==c&&(o.push({month:l.toLocaleDateString(`en-US`,{month:`short`}),weekIndex:u}),c=l.getMonth()),s.push(new Date(l)),l.setDate(l.getDate()+1);return s.length>0&&a.push(s),{weeks:a,monthLabels:o,printCounts:n}},[e,t]),c=Math.max(1,...Object.values(s)),l=e=>{if(e===0)return`bg-bambu-dark`;let t=e/c;return t<=.25?`bg-bambu-green/30`:t<=.5?`bg-bambu-green/50`:t<=.75?`bg-bambu-green/75`:`bg-bambu-green`},u=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],d=a.length,f=r-32-16,p=d>0?Math.floor((f-(d-1)*2)/d):12,m=Math.max(8,Math.min(20,p)),h=m<=10?10:12;return(0,K.jsx)(`div`,{ref:n,className:`w-full flex justify-center`,children:r>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex mb-1`,style:{marginLeft:36},children:o.map(({month:e,weekIndex:t},n)=>(0,K.jsx)(`div`,{className:`text-bambu-gray`,style:{fontSize:h,marginLeft:n===0?0:`${(t-(o[n-1]?.weekIndex||0))*(m+2)-24}px`},children:e},n))}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`flex flex-col`,style:{gap:2,marginRight:4,width:32},children:u.map((e,t)=>(0,K.jsx)(`div`,{className:`text-bambu-gray flex items-center`,style:{width:32,height:m,fontSize:h,visibility:t%2==1?`visible`:`hidden`},children:e},e))}),a.map((e,t)=>(0,K.jsx)(`div`,{className:`flex flex-col`,style:{gap:2},children:[0,1,2,3,4,5,6].map(t=>{let n=e.find(e=>e.getDay()===t);if(!n)return(0,K.jsx)(`div`,{style:{width:m,height:m}},t);let r=Df(n),i=s[r]||0,a=r===Df(new Date);return(0,K.jsx)(`div`,{className:`rounded-sm ${l(i)} ${a?`ring-1 ring-white`:``}`,style:{width:m,height:m},title:`${n.toLocaleDateString()}: ${i} print${i===1?``:`s`}`},t)})},t))]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-bambu-gray`,style:{fontSize:h},children:[(0,K.jsx)(`span`,{children:`Less`}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-dark`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/30`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/50`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/75`,style:{width:m,height:m}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green`,style:{width:m,height:m}})]}),(0,K.jsx)(`span`,{children:`More`})]})]})})}var a3=[`weight`,`prints`,`time`];function o3({value:e,onChange:t,exclude:n}){let{t:r}=W(),i={weight:r(`stats.filamentByWeight`),prints:r(`stats.filamentByPrints`),time:r(`stats.filamentByTime`)};return(0,K.jsx)(`div`,{className:`flex gap-0.5 bg-bambu-dark rounded-lg p-0.5`,children:(n?a3.filter(e=>!n.includes(e)):a3).map(n=>(0,K.jsx)(`button`,{onClick:()=>t(n),className:`px-2 py-0.5 text-xs rounded-md transition-colors ${e===n?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:i[n]},n))})}function s3(e){if(e>=1e6){let t=e/1e6;return`${t%1==0?t.toFixed(0):t.toFixed(1)}t`}if(e>=1e3){let t=e/1e3;return`${t%1==0?t.toFixed(0):t.toFixed(1)}kg`}return`${Math.round(e)}g`}var c3=[`#00ae42`,`#3b82f6`,`#f59e0b`,`#ef4444`,`#8b5cf6`,`#ec4899`,`#14b8a6`,`#f97316`],_Ve=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],l3=[`12am`,`1am`,`2am`,`3am`,`4am`,`5am`,`6am`,`7am`,`8am`,`9am`,`10am`,`11am`,`12pm`,`1pm`,`2pm`,`3pm`,`4pm`,`5pm`,`6pm`,`7pm`,`8pm`,`9pm`,`10pm`,`11pm`];function vVe({archives:e,currency:t=`$`,dateFrom:n,dateTo:r}){let{t:i}=W(),[a,o]=(0,y.useState)(`weight`),[s,c]=(0,y.useState)(`weight`),l=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}`,i=t.get(r)||{date:r,filament:0,cost:0,prints:0};i.filament+=e.filament_used_grams||0,i.cost+=e.cost||0,i.prints+=e.quantity||1,t.set(r,i)}),Array.from(t.values()).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>({...e,dateLabel:new Date(e.date).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}))},[e]),u=(0,y.useMemo)(()=>{if(n&&r)return Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1;if(n)return Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1;if(e.length<2)return 0;let t=e.map(e=>new Date(e.completed_at||e.created_at).getTime());return(Math.max(...t)-Math.min(...t))/864e5},[e,n,r]),d=(0,y.useMemo)(()=>{if(u>7)return[];let t=new Map,n=u>1;return e.forEach(e=>{let n=vf(e.completed_at||e.created_at)||new Date,r=n.getHours(),i=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,`0`)}-${String(n.getDate()).padStart(2,`0`)}T${String(r).padStart(2,`0`)}`,a=t.get(i)||{date:i,filament:0,cost:0,prints:0};a.filament+=e.filament_used_grams||0,a.cost+=e.cost||0,a.prints+=e.quantity||1,t.set(i,a)}),Array.from(t.values()).sort((e,t)=>e.date.localeCompare(t.date)).map(e=>{let[t,r]=e.date.split(`T`),i=new Date(t),a=parseInt(r,10),o=n?`${_Ve[i.getDay()]} ${l3[a]}`:l3[a];return{...e,dateLabel:o}})},[e,u]),f=(0,y.useMemo)(()=>{if(l.length<=60)return l;let e=new Map;return l.forEach(t=>{let n=new Date(t.date),r=new Date(n);r.setDate(n.getDate()-n.getDay());let i=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,`0`)}-${String(r.getDate()).padStart(2,`0`)}`,a=e.get(i)||{week:i,filament:0,cost:0,prints:0};a.filament+=t.filament,a.cost+=t.cost,a.prints+=t.prints,e.set(i,a)}),Array.from(e.values()).sort((e,t)=>e.week.localeCompare(t.week)).map(e=>({date:e.week,dateLabel:`Week of ${new Date(e.week).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}`,...e}))},[l]),p=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=(e.filament_type||`Unknown`).split(`, `);n.forEach(r=>{let i=(e.filament_used_grams||0)/n.length;t.set(r,(t.get(r)||0)+i)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:Math.round(t)})).sort((e,t)=>t.value-e.value)},[e]),m=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{(e.filament_type||`Unknown`).split(`, `).forEach(e=>{t.set(e,(t.get(e)||0)+1)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:t})).sort((e,t)=>t.value-e.value)},[e]),h=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{let n=(e.filament_type||`Unknown`).split(`, `),r=(e.actual_time_seconds||e.print_time_seconds||0)/n.length;n.forEach(e=>{t.set(e,(t.get(e)||0)+r)})}),Array.from(t.entries()).map(([e,t])=>({name:e,value:Math.round(t/3600*10)/10})).sort((e,t)=>t.value-e.value)},[e]),g=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{e.status!==`completed`&&e.status!==`failed`||(e.filament_type||`Unknown`).split(`, `).forEach(n=>{let r=t.get(n)||{completed:0,failed:0};e.status===`completed`?r.completed++:r.failed++,t.set(n,r)})}),Array.from(t.entries()).filter(([,e])=>e.completed+e.failed>=2).map(([e,t])=>{let n=t.completed+t.failed;return{name:e,rate:Math.round(t.completed/n*100),total:n}}).sort((e,t)=>t.rate-e.rate)},[e]),_=(0,y.useMemo)(()=>{let t=new Map;return e.forEach(e=>{if(!e.filament_color)return;let n=e.filament_color.split(`,`).map(e=>e.trim()),r=(e.filament_used_grams||0)/n.length;n.forEach(e=>{let n=t.get(e)||{count:0,weight:0};n.count++,n.weight+=r,t.set(e,n)})}),Array.from(t.entries()).map(([e,t])=>({hex:e,value:s===`prints`?t.count:Math.round(t.weight)})).sort((e,t)=>t.value-e.value)},[e,s]),v=a===`weight`?p:a===`prints`?m:h,b=u<=7&&d.length>0?d:f,x=e.reduce((e,t)=>e+(t.filament_used_grams||0),0),S=e.reduce((e,t)=>e+(t.cost||0),0),C=e.reduce((e,t)=>e+(t.quantity||1),0),w=new Set(e.map(e=>e.printer_id).filter(Boolean)).size;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 max-[640px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.periodFilament`)}),(0,K.jsx)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:s3(x)})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[w,` `,i(`nav.printers`).toLowerCase()]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.periodCost`)}),(0,K.jsxs)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:[t,S.toFixed(2)]})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[C,` `,i(`common.prints`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray leading-none`,children:i(`stats.avgPerPrint`)}),(0,K.jsxs)(`p`,{className:`text-2xl font-bold text-white leading-none`,children:[C>0?(x/C).toFixed(0):0,`g`]})]}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[t,C>0?(S/C).toFixed(2):`0.00`,` avg`]})]})]}),b.length>0?(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-4`,children:i(`stats.usageOverTime`)}),(0,K.jsx)(mA,{width:`100%`,height:250,children:(0,K.jsxs)(sU,{data:b,children:[(0,K.jsx)(`defs`,{children:(0,K.jsxs)(`linearGradient`,{id:`colorFilament`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,K.jsx)(`stop`,{offset:`5%`,stopColor:`#00ae42`,stopOpacity:.3}),(0,K.jsx)(`stop`,{offset:`95%`,stopColor:`#00ae42`,stopOpacity:0})]})}),(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(_H,{dataKey:`dateLabel`,stroke:`#9ca3af`,tick:{fontSize:12},interval:`preserveStartEnd`}),(0,K.jsx)(SH,{stroke:`#9ca3af`,tick:{fontSize:12},tickFormatter:e=>`${e}g`}),(0,K.jsx)(lz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},labelStyle:{color:`#fff`},formatter:e=>[`${Number(e??0).toFixed(0)}g`,`Filament`]}),(0,K.jsx)(YV,{type:`monotone`,dataKey:`filament`,stroke:`#00ae42`,strokeWidth:2,fillOpacity:1,fill:`url(#colorFilament)`})]})})]}):(0,K.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray`,children:i(`stats.noPrintDataInRange`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:i(`stats.byMaterial`)}),(0,K.jsx)(o3,{value:a,onChange:o})]}),v.length>0?(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(mA,{width:160,height:160,children:(0,K.jsxs)(oU,{children:[(0,K.jsx)(HB,{data:v,cx:`50%`,cy:`50%`,innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:`value`,children:v.map((e,t)=>(0,K.jsx)(uz,{fill:c3[t%c3.length]},`cell-${t}`))}),(0,K.jsx)(lz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},formatter:e=>[a===`weight`?s3(Number(e??0)):a===`time`?`${Number(e??0)}h`:`${e??0}`,a===`weight`?`Usage`:a===`time`?`Time`:`Prints`]})]})}),(0,K.jsx)(`div`,{className:`flex-1 space-y-2 overflow-hidden`,children:v.map((e,t)=>{let n=v.reduce((e,t)=>e+t.value,0),r=n>0?(e.value/n*100).toFixed(0):0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-sm flex-shrink-0`,style:{backgroundColor:c3[t%c3.length]}}),(0,K.jsx)(`span`,{className:`text-white truncate flex-1`,children:e.name}),(0,K.jsxs)(`span`,{className:`text-bambu-gray flex-shrink-0`,children:[a===`weight`?s3(e.value):a===`time`?`${e.value}h`:e.value,` · `,r,`%`]})]},e.name)})})]}):(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noFilamentData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-4`,children:i(`stats.filamentSuccess`)}),g.length>0?(0,K.jsx)(`div`,{className:`space-y-1.5`,children:g.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white truncate w-20 flex-shrink-0`,children:e.name}),(0,K.jsx)(`div`,{className:`flex-1 h-1.5 bg-bambu-dark-secondary rounded-full`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all ${e.rate>=90?`bg-status-ok`:e.rate>=70?`bg-status-warning`:`bg-status-error`}`,style:{width:`${e.rate}%`}})}),(0,K.jsxs)(`span`,{className:`font-medium flex-shrink-0 tabular-nums ${e.rate>=90?`text-status-ok`:e.rate>=70?`text-status-warning`:`text-status-error`}`,children:[e.rate,`%`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray flex-shrink-0 text-xs`,children:[`(`,e.total,`)`]})]},e.name))}):(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:i(`stats.colorDistribution`)}),(0,K.jsx)(o3,{value:s,onChange:c,exclude:[`time`]})]}),_.length>0?(()=>{let e=_.reduce((e,t)=>e+t.value,0);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`relative mx-auto`,style:{width:160,height:160},children:[(0,K.jsx)(mA,{width:`100%`,height:`100%`,children:(0,K.jsxs)(oU,{children:[(0,K.jsx)(HB,{data:_,cx:`50%`,cy:`50%`,innerRadius:45,outerRadius:70,paddingAngle:2,dataKey:`value`,children:_.map((e,t)=>(0,K.jsx)(uz,{fill:e.hex,stroke:`#1a1a1a`,strokeWidth:1},`color-${t}`))}),(0,K.jsx)(lz,{contentStyle:{backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`},formatter:e=>[s===`weight`?s3(Number(e??0)):`${e??0}`,i(s===`weight`?`stats.filamentByWeight`:`stats.filamentByPrints`)]})]})}),(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`span`,{className:`text-lg font-bold text-white`,children:s===`weight`?s3(e):e}),(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray`,children:[_.length,` `,_.length===1?`color`:`colors`]})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1 mt-2`,children:_.slice(0,8).map(t=>{let n=e>0?(t.value/e*100).toFixed(0):0;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs min-w-0`,children:[(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 border border-black/20`,style:{backgroundColor:t.hex}}),(0,K.jsxs)(`span`,{className:`text-bambu-gray truncate`,children:[n,`%`]})]},t.hex)})}),_.length>8&&(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray mt-1 text-center`,children:[`+`,_.length-8,` more`]})]})})():(0,K.jsx)(`div`,{className:`h-[160px] flex items-center justify-center text-bambu-gray`,children:i(`stats.noColorData`)})]})]})]})}function yVe({id:e,title:t,component:n,isHidden:r,size:i,columnSpan:a,onToggleVisibility:o,onToggleSize:s}){let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=G4({id:e}),m={transform:C2.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:(0,K.jsxs)(`div`,{ref:u,style:{...m,gridColumn:`span ${a}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?`ring-2 ring-bambu-green shadow-lg`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`button`,{...c,...l,className:`cursor-grab active:cursor-grabbing p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Drag to reorder`,children:(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray`})}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:t})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:s,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Size: ${i===1?`1/4`:i===2?`1/2`:`Full`} - Click to cycle`,children:i===4?(0,K.jsx)(rl,{className:`w-4 h-4 text-bambu-gray hover:text-white`}):(0,K.jsx)($c,{className:`w-4 h-4 text-bambu-gray hover:text-white`})}),(0,K.jsx)(`button`,{onClick:o,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,title:`Hide widget`,children:(0,K.jsx)(Ys,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]})]}),(0,K.jsx)(`div`,{className:`p-4`,children:typeof n==`function`?n(i):n})]})}function bVe({widgets:e,storageKey:t,columns:n=4,stackBelow:r,hideControls:i=!1,onResetLayout:a,renderControls:o}){let s=()=>{let t={};return e.forEach(e=>{t[e.id]=e.defaultSize||4}),t},[c,l]=(0,y.useState)(()=>{let n=localStorage.getItem(t);if(n)try{let e=JSON.parse(n);if(!e.sizes)e.sizes=s();else{let t=s();for(let n in t)n in e.sizes||(e.sizes[n]=t[n])}return e}catch{}return{order:e.map(e=>e.id),hidden:e.filter(e=>e.defaultVisible===!1).map(e=>e.id),sizes:s()}}),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(!r)return;let e=window.matchMedia(`(max-width: ${r}px)`),t=e=>{p(e.matches)};t(e);let n=e=>t(e);return e.addEventListener?e.addEventListener(`change`,n):e.addListener(n),()=>{e.removeEventListener?e.removeEventListener(`change`,n):e.removeListener(n)}},[r]);let m=r&&f?1:n;(0,y.useEffect)(()=>{let e=()=>d(e=>!e);return window.addEventListener(`toggle-hidden-panel`,e),()=>window.removeEventListener(`toggle-hidden-panel`,e)},[]),(0,y.useEffect)(()=>{localStorage.setItem(t,JSON.stringify(c))},[c,t]),(0,y.useEffect)(()=>{let t=e.map(e=>e.id).filter(e=>!c.order.includes(e));t.length>0&&l(e=>({...e,order:[...e.order,...t]}))},[e,c.order]);let h=k2(O2(l4,{activationConstraint:{distance:8}}),O2(a4,{coordinateGetter:q4})),g=e=>{let{active:t,over:n}=e;n&&t.id!==n.id&&l(e=>{let r=e.order.indexOf(t.id),i=e.order.indexOf(n.id);return{...e,order:L4(e.order,r,i)}})},_=e=>{l(t=>({...t,hidden:t.hidden.includes(e)?t.hidden.filter(t=>t!==e):[...t.hidden,e]}))},v=e=>{l(t=>{let n=t.sizes[e]||4,r=n===1?2:n===2?4:1;return{...t,sizes:{...t.sizes,[e]:r}}})},b=()=>{l({order:e.map(e=>e.id),hidden:e.filter(e=>e.defaultVisible===!1).map(e=>e.id),sizes:s()}),a?.()},x=c.order.map(t=>e.find(e=>e.id===t)).filter(Boolean),S=x.filter(e=>!c.hidden.includes(e.id)),C=x.filter(e=>c.hidden.includes(e.id)),w=o?.({hiddenCount:C.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[w,!i&&!o&&(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:b,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),`Reset Layout`]}),C.length>0&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>d(!u),children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),C.length,` Hidden`]})]}),u&&C.length>0&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:`Hidden widgets (click to show):`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:C.map(e=>(0,K.jsxs)(`button`,{onClick:()=>_(e.id),className:`px-3 py-1.5 bg-bambu-dark-tertiary hover:bg-bambu-green/20 rounded-lg text-sm text-white transition-colors flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-3 h-3`}),e.title]},e.id))})]}),(0,K.jsx)(N4,{sensors:h,collisionDetection:I2,onDragEnd:g,children:(0,K.jsx)(U4,{items:S.map(e=>e.id),strategy:z4,children:(0,K.jsx)(`div`,{className:`grid gap-6`,style:{gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`},children:S.map(e=>{let t=c.sizes[e.id]||2,n=Math.min(t,m);return(0,K.jsx)(yVe,{id:e.id,title:e.title,component:e.component,isHidden:c.hidden.includes(e.id),size:t,columnSpan:n,onToggleVisibility:()=>_(e.id),onToggleSize:()=>v(e.id)},e.id)})})})}),S.length===0&&(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(`p`,{children:`All widgets are hidden.`}),(0,K.jsx)($,{className:`mt-4`,onClick:b,children:`Reset Layout`})]})]})}function xVe(e){let t=new Date,n=t.getUTCFullYear(),r=t.getUTCMonth(),i=t.getUTCDate(),a=e=>e.toISOString().split(`T`)[0],o=a(t);switch(e){case`today`:return{dateFrom:o,dateTo:o};case`this-week`:{let e=t.getUTCDay();return{dateFrom:a(new Date(Date.UTC(n,r,i-(e===0?6:e-1)))),dateTo:o}}case`this-month`:return{dateFrom:a(new Date(Date.UTC(n,r,1))),dateTo:o};case`last-7`:return{dateFrom:a(new Date(Date.UTC(n,r,i-6))),dateTo:o};case`last-30`:return{dateFrom:a(new Date(Date.UTC(n,r,i-29))),dateTo:o};case`last-90`:return{dateFrom:a(new Date(Date.UTC(n,r,i-89))),dateTo:o};case`this-year`:return{dateFrom:a(new Date(Date.UTC(n,0,1))),dateTo:o};case`all-time`:return{dateFrom:void 0,dateTo:void 0};case`custom`:return{}}}var SVe=[`today`,`this-week`,`this-month`,`last-7`,`last-30`,`last-90`,`this-year`,`all-time`],CVe=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],u3=[`12am`,`1am`,`2am`,`3am`,`4am`,`5am`,`6am`,`7am`,`8am`,`9am`,`10am`,`11am`,`12pm`,`1pm`,`2pm`,`3pm`,`4pm`,`5pm`,`6pm`,`7pm`,`8pm`,`9pm`,`10pm`,`11pm`],d3=[{key:`<30m`,max:1800},{key:`30m-1h`,max:3600},{key:`1-2h`,max:7200},{key:`2-4h`,max:14400},{key:`4-8h`,max:28800},{key:`8-12h`,max:43200},{key:`12-24h`,max:86400},{key:`24h+`,max:1/0}],f3={backgroundColor:`#2d2d2d`,border:`1px solid #3d3d3d`,borderRadius:`8px`};function wVe({stats:e,currency:t}){let{t:n}=W(),r=e?.energy_data_warming_up===!0,i=r?n(`stats.energyWarmingUpTooltip`):void 0;return(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-4`,children:[{icon:pl,color:`text-bambu-green`,label:n(`stats.totalPrints`),value:`${e?.total_prints||0}`},{icon:Ss,color:`text-blue-400`,label:n(`stats.printTime`),value:`${e?.total_print_time_hours?.toFixed(1)??`0`}h`},{icon:pl,color:`text-orange-400`,label:n(`stats.filamentUsed`),value:s3(e?.total_filament_grams||0)},{icon:Rs,color:`text-green-400`,label:n(`stats.filamentCost`),value:`${t} ${e?.total_cost?.toFixed(2)??`0.00`}`},{icon:Bu,color:`text-yellow-400`,label:n(`stats.energyUsed`),value:`${e?.total_energy_kwh?.toFixed(3)??`0.000`} kWh`,warning:r,tooltip:i},{icon:Rs,color:`text-yellow-500`,label:n(`stats.energyCost`),value:`${t} ${e?.total_energy_cost?.toFixed(2)??`0.00`}`,warning:r,tooltip:i}].map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,title:e.tooltip,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark ${e.color}`,children:(0,K.jsx)(e.icon,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray flex items-center gap-1`,children:[e.label,e.warning&&(0,K.jsx)(Cu,{className:`w-3 h-3 text-yellow-400`,"aria-label":e.tooltip})]}),(0,K.jsx)(`p`,{className:`text-xl font-bold text-white`,children:e.value})]})]},e.label))})}function TVe({stats:e,printerMap:t,size:n=1}){let{t:r}=W(),i=(e?.successful_prints||0)+(e?.failed_prints||0),a=i?Math.round((e?.successful_prints||0)/i*100):0,o=n===1?112:n===2?128:144,s=o/2-8,c=s*2*Math.PI;return(0,K.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,style:{width:o,height:o},children:[(0,K.jsxs)(`svg`,{className:`w-full h-full -rotate-90`,children:[(0,K.jsx)(`circle`,{cx:o/2,cy:o/2,r:s,fill:`none`,stroke:`#3d3d3d`,strokeWidth:`10`}),(0,K.jsx)(`circle`,{cx:o/2,cy:o/2,r:s,fill:`none`,stroke:`#00ae42`,strokeWidth:`10`,strokeLinecap:`round`,strokeDasharray:`${a/100*c} ${c}`})]}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsxs)(`span`,{className:`font-bold text-white ${n>=2?`text-2xl`:`text-xl`}`,children:[a,`%`]})})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-status-ok flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.successful`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.successful_prints||0})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 text-status-error flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.failed`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.failed_prints||0})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Lo,{className:`w-4 h-4 text-status-warning flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:r(`stats.cancelled`)}),(0,K.jsx)(`span`,{className:`text-sm text-white font-medium`,children:e?.cancelled_prints||0})]})]}),n>=2&&e?.prints_by_printer&&Object.keys(e.prints_by_printer).length>0&&(0,K.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-medium mb-2`,children:r(`stats.printsByPrinter`)}),(0,K.jsx)(`div`,{className:`grid gap-x-6 gap-y-1 ${n===4?`grid-cols-3`:`grid-cols-2`}`,style:{width:`fit-content`},children:Object.entries(e.prints_by_printer).map(([e,n])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray truncate max-w-[120px]`,children:t.get(e)||`${r(`common.printer`)} ${e}`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n})]},e))})]})]})]})}function EVe({stats:e,printerMap:t,size:n=1}){let{t:r}=W(),i=e?.average_time_accuracy;if(i==null)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noTimeAccuracyData`)})});let a=(Math.min(150,Math.max(50,i))-50)/100*100,o=(e=>e>=95&&e<=105?`#00ae42`:e>105?`#3b82f6`:`#f97316`)(i),s=i-100,c=n===1?112:n===2?128:144,l=c/2-8,u=l*2*Math.PI,d=n===1?3:n===2?6:999,f=e?.time_accuracy_by_printer?Object.entries(e.time_accuracy_by_printer).slice(0,d):[];return(0,K.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,K.jsxs)(`div`,{className:`relative flex-shrink-0`,style:{width:c,height:c},children:[(0,K.jsxs)(`svg`,{className:`w-full h-full -rotate-90`,children:[(0,K.jsx)(`circle`,{cx:c/2,cy:c/2,r:l,fill:`none`,stroke:`#3d3d3d`,strokeWidth:`10`}),(0,K.jsx)(`circle`,{cx:c/2,cy:c/2,r:l,fill:`none`,stroke:o,strokeWidth:`10`,strokeLinecap:`round`,strokeDasharray:`${a/100*u} ${u}`})]}),(0,K.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center`,children:[(0,K.jsxs)(`span`,{className:`font-bold text-white ${n>=2?`text-2xl`:`text-xl`}`,children:[i.toFixed(0),`%`]}),(0,K.jsxs)(`span`,{className:`text-xs ${s>=0?`text-blue-400`:`text-orange-400`}`,children:[s>=0?`+`:``,s.toFixed(0),`%`]})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:[(0,K.jsx)(pu,{className:`w-3 h-3 flex-shrink-0`}),(0,K.jsx)(`span`,{children:r(`stats.perfectEstimate`)})]}),f.length>0&&(0,K.jsx)(`div`,{className:`mt-2 ${n===4?`grid grid-cols-3 gap-x-6 gap-y-1`:n===2?`grid grid-cols-2 gap-x-6 gap-y-1`:`space-y-1`}`,style:{width:`fit-content`},children:f.map(([e,n])=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray truncate max-w-[100px]`,children:t.get(e)||`${r(`common.printer`)} ${e}`}),(0,K.jsxs)(`span`,{className:`font-medium ${n>=95&&n<=105?`text-status-ok`:n>105?`text-blue-400`:`text-status-warning`}`,children:[n.toFixed(0),`%`]})]},e))})]})]})}function DVe({printDates:e,dateFrom:t,dateTo:n}){let{days:r,hourlyCounts:i,maxCount:a}=(0,y.useMemo)(()=>{let r=new Date(t+`T00:00:00`),i=new Date(n+`T00:00:00`),a=[],o=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,s=new Date(r);for(;s<=i;)a.push({key:o(s),label:s.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),s.setDate(s.getDate()+1);let c={},l=0;return e.forEach(e=>{let t=vf(e);if(!t)return;let n=`${`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}-${t.getHours()}`;c[n]=(c[n]||0)+1,c[n]>l&&(l=c[n])}),{days:a,hourlyCounts:c,maxCount:Math.max(1,l)}},[e,t,n]),o=e=>{if(e===0)return`bg-bambu-dark`;let t=e/a;return t<=.25?`bg-bambu-green/30`:t<=.5?`bg-bambu-green/50`:t<=.75?`bg-bambu-green/75`:`bg-bambu-green`};return(0,K.jsxs)(`div`,{className:`w-full overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`inline-flex flex-col`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`flex`,style:{gap:2,marginLeft:84},children:u3.map((e,t)=>(0,K.jsx)(`div`,{className:`text-bambu-gray text-[10px] text-center`,style:{width:20,visibility:t%2==0?`visible`:`hidden`},children:e},t))}),r.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`text-bambu-gray text-[10px] flex-shrink-0 truncate`,style:{width:80},children:e.label}),Array.from({length:24},(t,n)=>{let r=i[`${e.key}-${n}`]||0;return(0,K.jsx)(`div`,{className:`rounded-sm ${o(r)}`,style:{width:20,height:20},title:`${e.label} ${u3[n]}: ${r} print${r===1?``:`s`}`},n)})]},e.key))]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-3 text-bambu-gray text-xs`,children:[(0,K.jsx)(`span`,{children:`Less`}),(0,K.jsxs)(`div`,{className:`flex`,style:{gap:2},children:[(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-dark`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/30`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/50`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green/75`,style:{width:20,height:20}}),(0,K.jsx)(`div`,{className:`rounded-sm bg-bambu-green`,style:{width:20,height:20}})]}),(0,K.jsx)(`span`,{children:`More`})]})]})}function OVe({printDates:e,size:t=2,dateFrom:n,dateTo:r}){let i=(0,y.useMemo)(()=>n&&r?Math.max((new Date(r).getTime()-new Date(n).getTime())/864e5,0)+1:n?Math.max((Date.now()-new Date(n).getTime())/864e5,0)+1:1/0,[n,r]);return i<=7&&n&&r?(0,K.jsx)(DVe,{printDates:e,dateFrom:n,dateTo:r}):(0,K.jsx)(gVe,{printDates:e,months:i===1/0?t===1?3:t===2?6:12:Math.max(1,Math.ceil(i/30))})}function kVe({stats:e,archives:t,printerMap:n}){let{t:r}=W(),[i,a]=(0,y.useState)(`weight`),[o,s]=(0,y.useState)(`weight`),c=(0,y.useMemo)(()=>{let a=new Map;return e?.prints_by_printer&&Object.entries(e.prints_by_printer).forEach(([e,t])=>{let n=a.get(e)||{prints:0,weight:0,time:0};n.prints=t,a.set(e,n)}),t.forEach(t=>{if(!t.printer_id)return;let n=String(t.printer_id),r=a.get(n)||{prints:0,weight:0,time:0};r.weight+=t.filament_used_grams||0,r.time+=t.actual_time_seconds||t.print_time_seconds||0,e?.prints_by_printer||r.prints++,a.set(n,r)}),Array.from(a.entries()).map(([e,t])=>({name:n.get(e)||`${r(`common.printer`)} ${e}`,value:i===`prints`?t.prints:i===`weight`?Math.round(t.weight):Math.round(t.time/3600*10)/10})).sort((e,t)=>t.value-e.value)},[e,t,n,i,r]),l=(0,y.useMemo)(()=>{let e=Array.from({length:24},(e,t)=>({hour:t,label:u3[t],total:0,failures:0}));return t.forEach(t=>{if(!t.started_at)return;let n=vf(t.started_at);if(!n)return;let r=n.getHours();e[r].total++,t.status===`failed`&&e[r].failures++}),e},[t]),u=(0,y.useMemo)(()=>{let e=d3.map(e=>({name:e.key,count:0}));return t.forEach(t=>{let n=t.actual_time_seconds||t.print_time_seconds;if(!(!n||n<=0)){for(let t=0;t{let e=[0,0,0,0,0,0,0],n=new Set;t.forEach(t=>{let r=vf(t.created_at)||new Date(t.created_at),i=r.getDay()-1;i<0&&(i=6),o===`prints`?e[i]++:o===`weight`?e[i]+=t.filament_used_grams||0:e[i]+=(t.actual_time_seconds||t.print_time_seconds||0)/3600;let a=new Date(r);a.setDate(r.getDate()-(r.getDay()+6)%7),n.add(`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,`0`)}-${String(a.getDate()).padStart(2,`0`)}`)});let r=Math.max(n.size,1);return CVe.map((t,n)=>({name:t,avg:Math.round(e[n]/r*10)/10}))},[t,o]),f=e=>({unit:e===`weight`?`g`:e===`time`?`h`:``,color:e===`weight`?`#00ae42`:e===`time`?`#3b82f6`:`#f59e0b`}),p=f(i),m=r(i===`weight`?`stats.filamentByWeight`:i===`time`?`stats.hours`:`common.prints`),h=f(o),g=r(o===`weight`?`stats.avgWeight`:o===`time`?`stats.avgTime`:`stats.avgPrints`);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:r(`stats.printsByPrinter`)}),(0,K.jsx)(o3,{value:i,onChange:a})]}),c.length>0?(0,K.jsx)(mA,{width:`100%`,height:Math.max(140,c.length*40),children:(0,K.jsxs)(tU,{data:c,layout:`vertical`,margin:{left:10},children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(_H,{type:`number`,stroke:`#9ca3af`,tick:{fontSize:11},unit:p.unit}),(0,K.jsx)(SH,{type:`category`,dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11},width:100}),(0,K.jsx)(lz,{contentStyle:f3,formatter:e=>[i===`weight`?s3(Number(e??0)):`${e??0}${p.unit}`,m]}),(0,K.jsx)(lH,{dataKey:`value`,fill:p.color,radius:[0,4,4,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noPrinterData`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:r(`stats.printDuration`)}),t.length>0?(0,K.jsx)(mA,{width:`100%`,height:160,children:(0,K.jsxs)(tU,{data:u,children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(_H,{dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11}}),(0,K.jsx)(SH,{stroke:`#9ca3af`,tick:{fontSize:11},allowDecimals:!1}),(0,K.jsx)(lz,{contentStyle:f3}),(0,K.jsx)(lH,{dataKey:`count`,name:r(`common.prints`),fill:`#00ae42`,radius:[4,4,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray`,children:r(`stats.printHabits`)}),(0,K.jsx)(o3,{value:o,onChange:s})]}),t.length>0?(0,K.jsx)(mA,{width:`100%`,height:160,children:(0,K.jsxs)(tU,{data:d,children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(_H,{dataKey:`name`,stroke:`#9ca3af`,tick:{fontSize:11}}),(0,K.jsx)(SH,{stroke:`#9ca3af`,tick:{fontSize:11},unit:h.unit}),(0,K.jsx)(lz,{contentStyle:f3,formatter:e=>[`${e??0}${h.unit}`,g]}),(0,K.jsx)(lH,{dataKey:`avg`,fill:h.color,radius:[4,4,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-bambu-gray mb-3`,children:r(`stats.printTimeOfDay`)}),t.length>0?(0,K.jsx)(mA,{width:`100%`,height:160,children:(0,K.jsxs)(tU,{data:l,children:[(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#3d3d3d`}),(0,K.jsx)(_H,{dataKey:`label`,stroke:`#9ca3af`,tick:{fontSize:10},interval:5}),(0,K.jsx)(SH,{stroke:`#9ca3af`,tick:{fontSize:11},allowDecimals:!1}),(0,K.jsx)(lz,{contentStyle:f3}),(0,K.jsx)(lH,{dataKey:`total`,name:r(`stats.totalPrints`),fill:`#00ae42`,radius:[2,2,0,0]}),(0,K.jsx)(lH,{dataKey:`failures`,name:r(`stats.failed`),fill:`#ef4444`,radius:[2,2,0,0]})]})}):(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:r(`stats.noArchiveData`)})]})]})]})}function AVe({archives:e,currency:t,dateFrom:n,dateTo:r}){let{t:i}=W();return!e||e.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:i(`stats.noPrintData`)}):(0,K.jsx)(vVe,{archives:e,currency:t,dateFrom:n,dateTo:r})}function jVe({size:e=1,dateFrom:t,dateTo:n,createdById:r}){let{t:i}=W(),a=!!(t||n),{data:o,isLoading:s}=q({queryKey:[`failureAnalysis`,t,n,r??`all`],queryFn:()=>Q.getFailureAnalysis({...a?{dateFrom:t,dateTo:n}:{days:30},createdById:r})});if(s)return(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})});if(!o||o.total_prints===0)return(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:i(a?`stats.noPrintDataInRange`:`stats.noPrintDataLast30Days`)});let c=e===1?5:e===2?8:999,l=Object.entries(o.failures_by_reason).sort(([,e],[,t])=>t-e),u=l.slice(0,c),d=l.length>c;return(0,K.jsxs)(`div`,{className:`${e>=2?`flex gap-8`:`space-y-4`}`,children:[(0,K.jsxs)(`div`,{className:e>=2?`flex-shrink-0`:``,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 ${o.failure_rate>20?`text-status-error`:o.failure_rate>10?`text-status-warning`:`text-status-ok`}`}),(0,K.jsxs)(`span`,{className:`font-bold text-white ${e>=2?`text-3xl`:`text-2xl`}`,children:[o.failure_rate.toFixed(1),`%`]})]})}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray mt-1`,children:i(`stats.failedPrintsCount`,{failed:o.failed_prints,total:o.total_prints})}),o.trend&&o.trend.length>=2&&(0,K.jsx)(`div`,{className:`${e>=2?`mt-4`:`mt-2 pt-2 border-t border-bambu-dark-tertiary`}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 ${o.trend[o.trend.length-1].failure_rate0&&(0,K.jsxs)(`div`,{className:`flex-1 ${e>=2?`border-l border-bambu-dark-tertiary pl-8`:`pt-2`}`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-medium mb-2`,children:i(e>=2?`stats.failureReasons`:`stats.topFailureReasons`)}),(0,K.jsx)(`div`,{className:`${e===4?`grid grid-cols-2 gap-x-6 gap-y-1`:`space-y-1`}`,children:u.map(([t,n])=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white truncate ${e===4?`max-w-[200px]`:`max-w-[160px]`}`,children:t?i(`editArchive.failureReasons.${t}`,{defaultValue:t}):i(`common.unknown`)}),(0,K.jsx)(`span`,{className:`text-bambu-gray ml-2`,children:n})]},t))}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`common.more`,{count:l.length-c})})]})]})}function MVe({archives:e,currency:t}){let{t:n}=W(),r=(0,y.useMemo)(()=>{let r=[];if(e.length===0)return r;let i=t=>{let n=null,r=0;return e.forEach(e=>{let i=t(e);i&&i>r&&(r=i,n=e)}),{archive:n,value:r}},a=i(e=>e.status===`completed`?e.actual_time_seconds:null);a.archive&&r.push({icon:Ss,iconColor:`text-blue-400`,label:n(`stats.longestPrint`),value:Cf(a.value),detail:a.archive.print_name||null});let o=i(e=>e.filament_used_grams);o.archive&&r.push({icon:pl,iconColor:`text-orange-400`,label:n(`stats.heaviestPrint`),value:s3(o.value),detail:o.archive.print_name||null});let s=i(e=>e.cost);s.archive&&r.push({icon:Rs,iconColor:`text-green-400`,label:n(`stats.mostExpensivePrint`),value:`${t}${s.value.toFixed(2)}`,detail:s.archive.print_name||null});let c=new Map;e.forEach(e=>{let t=vf(e.created_at)||new Date(e.created_at),n=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`;c.set(n,(c.get(n)||0)+1)});let l=``,u=0;c.forEach((e,t)=>{e>u&&(u=e,l=t)}),u>1&&r.push({icon:Zo,iconColor:`text-purple-400`,label:n(`stats.busiestDay`),value:`${u} ${n(`common.prints`)}`,detail:(()=>{let[e,t,n]=l.split(`-`).map(Number);return new Date(e,t-1,n).toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})})()});let d=[...e].filter(e=>e.status===`completed`||e.status===`failed`).sort((e,t)=>new Date(t.completed_at||t.created_at).getTime()-new Date(e.completed_at||e.created_at).getTime()),f=0;for(let e of d)if(e.status===`completed`)f++;else break;return f>0&&r.push({icon:Bu,iconColor:`text-yellow-400`,label:n(`stats.successStreak`),value:`${f}`,detail:f===1?n(`stats.streakPrint`):n(`stats.streakPrints`,{count:f})}),r},[e,t,n]);return r.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray text-center py-4`,children:n(`stats.noArchiveData`)}):(0,K.jsx)(`div`,{className:`space-y-3`,children:r.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-1.5 rounded-lg bg-bambu-dark ${e.iconColor}`,children:(0,K.jsx)(e.icon,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.label}),(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-bold text-white`,children:e.value}),e.detail&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray truncate`,children:e.detail})]})]})]},t))})}function NVe(){let{t:e}=W(),{showToast:t}=Td(),{hasPermission:n,authEnabled:r}=dd(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(0),[u,d]=(0,y.useState)(0),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(!1),v=r&&n(`stats:filter_by_user`),[b,x]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`bambusy-stats-timeframe`);if(e){let t=JSON.parse(e);if(t.preset)return t}}catch{}return{preset:`all-time`,dateFrom:void 0,dateTo:void 0}}),[S,C]=(0,y.useState)(!1);(0,y.useEffect)(()=>{localStorage.setItem(`bambusy-stats-timeframe`,JSON.stringify(b))},[b]);let w=(0,y.useMemo)(()=>b.preset===`custom`?{dateFrom:b.dateFrom,dateTo:b.dateTo}:xVe(b.preset),[b]);(0,y.useEffect)(()=>{let e=()=>{try{let e=localStorage.getItem(`bambusy-dashboard-layout-v2`);e&&d(JSON.parse(e).hidden?.length||0)}catch{d(0)}};e(),window.addEventListener(`storage`,e);let t=setInterval(e,2e3);return()=>{window.removeEventListener(`storage`,e),clearInterval(t)}},[c]);let T=m===null?void 0:m,{data:E,isLoading:D,isFetching:O,refetch:k}=q({queryKey:[`archiveStats`,w.dateFrom,w.dateTo,T??`all`],queryFn:()=>Q.getArchiveStats({dateFrom:w.dateFrom,dateTo:w.dateTo,createdById:T})}),{data:A}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:j,isFetching:M,refetch:N}=q({queryKey:[`archivesSlim`,w.dateFrom,w.dateTo,T??`all`],queryFn:()=>Q.getArchivesSlim(w.dateFrom,w.dateTo,T)}),{data:P}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:F}=q({queryKey:[`users`],queryFn:Q.getUsers,enabled:v}),I=(0,y.useMemo)(()=>m===null?e(`stats.allUsers`,`All Users`):m===-1?e(`stats.noUser`,`No User (System)`):F?.find(e=>e.id===m)?.username??`?`,[m,F,e]),L=async n=>{s(!1),a(!0);try{let{blob:r,filename:i}=await Q.exportStats({format:n,days:90,createdById:T}),a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=i,o.click(),URL.revokeObjectURL(a),t(e(`stats.exportDownloaded`))}catch{t(e(`stats.exportFailed`),`error`)}finally{a(!1)}},R=async()=>{p(!0);try{let n=await Q.recalculateCosts();await Promise.all([k(),N()]),t(e(`stats.recalculatedCosts`,{count:n.updated}))}catch{t(e(`stats.recalculateFailed`),`error`)}finally{p(!1)}},z=(O||M)&&!D,B=$d(P?.currency||`USD`),V=new Map(A?.map(e=>[String(e.id),e.name])||[]),ee=(0,y.useMemo)(()=>j?.map(e=>e.created_at)||[],[j]);if(D)return(0,K.jsx)(`div`,{className:`p-4 md:p-8`,children:(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`stats.loadingStats`)})});let te=[{id:`quick-stats`,title:e(`stats.quickStats`),component:(0,K.jsx)(wVe,{stats:E,currency:B}),defaultSize:2},{id:`success-rate`,title:e(`stats.successRate`),component:e=>(0,K.jsx)(TVe,{stats:E,printerMap:V,size:e}),defaultSize:1},{id:`time-accuracy`,title:e(`stats.timeAccuracy`),component:e=>(0,K.jsx)(EVe,{stats:E,printerMap:V,size:e}),defaultSize:1},{id:`failure-analysis`,title:e(`stats.failureAnalysis`),component:e=>(0,K.jsx)(jVe,{size:e,dateFrom:w.dateFrom,dateTo:w.dateTo,createdById:T}),defaultSize:1},{id:`print-activity`,title:e(`stats.printActivity`),component:e=>(0,K.jsx)(OVe,{printDates:ee,size:e,dateFrom:w.dateFrom,dateTo:w.dateTo}),defaultSize:2},{id:`records`,title:e(`stats.records`),component:(0,K.jsx)(MVe,{archives:j||[],currency:B}),defaultSize:1},{id:`printer-stats`,title:e(`stats.printerStats`),component:(0,K.jsx)(kVe,{stats:E,archives:j||[],printerMap:V}),defaultSize:4},{id:`filament-trends`,title:e(`stats.filamentTrends`),component:(0,K.jsx)(AVe,{archives:j||[],currency:B,dateFrom:w.dateFrom,dateTo:w.dateTo}),defaultSize:4}];return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)($o,{className:`w-7 h-7 text-bambu-green`}),e(`stats.title`)]}),z&&(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`stats.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u>0&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{window.dispatchEvent(new CustomEvent(`toggle-hidden-panel`))},children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),e(`stats.hiddenCount`,{count:u})]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{localStorage.removeItem(`bambusy-dashboard-layout-v2`),l(e=>e+1),t(e(`stats.layoutReset`))},disabled:!n(`settings:update`),title:n(`settings:update`)?void 0:e(`stats.noPermissionResetLayout`),children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),e(`stats.resetLayout`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:R,disabled:f||!n(`archives:update_all`),title:n(`archives:update_all`)?e(`stats.recalculateCostsHint`):e(`stats.noPermissionRecalculate`),children:[f?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Jo,{className:`w-4 h-4`}),e(`stats.recalculateCosts`)]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s(!o),disabled:i,children:[i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(tc,{className:`w-4 h-4`}),e(`stats.exportStats`)]}),o&&(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20`,children:[(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg`,onClick:()=>L(`csv`),children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),e(`stats.exportAsCsv`)]}),(0,K.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg`,onClick:()=>L(`xlsx`),children:[(0,K.jsx)(tc,{className:`w-4 h-4`}),e(`stats.exportAsExcel`)]})]})]}),v&&F&&F.length>0&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>_(!g),children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),I,(0,K.jsx)(is,{className:`w-3 h-3`})]}),g&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>_(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2 max-h-64 overflow-y-auto`,children:[(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===null?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(null),_(!1)},children:e(`stats.allUsers`,`All Users`)}),(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===-1?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(-1),_(!1)},children:e(`stats.noUser`,`No User (System)`)}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary my-1`}),F.map(e=>(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${m===e.id?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{h(e.id),_(!1)},children:e.username},e.id))]})]})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!S),children:[(0,K.jsx)(Zo,{className:`w-4 h-4`}),e(`stats.timeframe.${b.preset}`),(0,K.jsx)(is,{className:`w-3 h-3`})]}),S&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>C(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-64 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 p-2`,children:[SVe.map(t=>(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${b.preset===t?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>{x({preset:t,dateFrom:void 0,dateTo:void 0}),C(!1)},children:e(`stats.timeframe.${t}`)},t)),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary my-2`}),(0,K.jsx)(`button`,{className:`w-full px-3 py-2 text-left text-sm rounded-md transition-colors ${b.preset===`custom`?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,onClick:()=>x(e=>({...e,preset:`custom`})),children:e(`stats.timeframe.custom`)}),b.preset===`custom`&&(0,K.jsxs)(`div`,{className:`mt-2 px-1 pb-1 space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray block mb-1`,children:e(`stats.timeframe.from`)}),(0,K.jsx)(`input`,{type:`date`,value:b.dateFrom||``,max:b.dateTo||new Date().toISOString().split(`T`)[0],onChange:e=>x(t=>({...t,dateFrom:e.target.value||void 0})),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray block mb-1`,children:e(`stats.timeframe.to`)}),(0,K.jsx)(`input`,{type:`date`,value:b.dateTo||``,min:b.dateFrom,max:new Date().toISOString().split(`T`)[0],onChange:e=>x(t=>({...t,dateTo:e.target.value||void 0})),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-sm text-white [color-scheme:dark]`})]}),(0,K.jsx)($,{variant:`primary`,onClick:()=>C(!1),className:`w-full`,children:e(`common.apply`)})]})]})]})]})]})]}),(0,K.jsx)(bVe,{widgets:te,storageKey:`bambusy-dashboard-layout-v2`,stackBelow:640,hideControls:!0},c)]})}function p3(e){return e.length<8?`tooShort`:/[A-Z]/.test(e)?/[a-z]/.test(e)?/\d/.test(e)?/[^A-Za-z0-9]/.test(e)?null:`needsSpecial`:`needsDigit`:`needsLowercase`:`needsUppercase`}function PVe(){let{t:e}=W();return(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray`}),e(`settings.slicerBundlesRemoved.title`,{defaultValue:`Slicer Bundles (removed)`})]})}),(0,K.jsxs)(yd,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.description`,{defaultValue:`Printer Preset Bundle (.bbscfg) import was removed. BambuStudio's bundle export only includes user-customised presets, so the import never delivered standard processes / filaments and slicing fell back to embedded settings.`})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.alternatives`,{defaultValue:`Use Single Preset Import for individual customs, or sync via Bambu Cloud / Orca Cloud. Stock presets come from the slicer sidecar automatically.`})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.slicerBundlesRemoved.lookupOrder`,{defaultValue:`Slice-time preset lookup order: 1) Imported (local), 2) Orca Cloud, 3) Bambu Cloud, 4) Standard (sidecar fallback).`})})]})]})}var m3=90,h3=365;function g3(e){if(!e)return`—`;let t=vf(e);return t?t.toLocaleString():`—`}function FVe(e){let t=vf(e);return t?t.getTime(){if(s.preventDefault(),r.trim()){c(!0);try{e(await Q.createLongLivedCameraToken({name:r.trim(),expires_in_days:a})),i(``),o(m3),n(t(`cameraTokens.toast.created`,`Token created`))}catch(e){n(e instanceof Error?e.message:t(`cameraTokens.toast.createFailed`,`Failed to create token`),`error`)}finally{c(!1)}}},className:`bg-bambu-dark-secondary rounded-lg p-4 mb-6 border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:t(`cameraTokens.create.title`,`Create new token`)}),(0,K.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_140px_auto]`,children:[(0,K.jsx)(`input`,{type:`text`,maxLength:100,required:!0,value:r,onChange:e=>i(e.target.value),placeholder:t(`cameraTokens.create.namePlaceholder`,`e.g. Home Assistant`),className:`px-3 py-2 bg-bambu-dark rounded-md text-white border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none`,"aria-label":t(`cameraTokens.create.nameLabel`,`Token name`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:h3,required:!0,value:a,onChange:e=>{let t=Number(e.target.value);o(Math.min(Math.max(t,1),h3))},className:`px-3 py-2 bg-bambu-dark rounded-md text-white border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none`,"aria-label":t(`cameraTokens.create.daysLabel`,`Days until expiry`)}),(0,K.jsxs)(`button`,{type:`submit`,disabled:s||!r.trim(),className:`flex items-center gap-2 px-4 py-2 bg-bambu-green text-white rounded-md hover:bg-bambu-green/90 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),t(`cameraTokens.create.submit`,`Create`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:t(`cameraTokens.create.hint`,`Maximum lifetime is 365 days. The token value is shown only once on creation — copy it now.`)})]})}function LVe({token:e,onConfirm:t,onCancel:n}){let{t:r}=W();return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4`,role:`dialog`,"aria-modal":`true`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full border border-red-500/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-red-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`cameraTokens.confirmRevoke.title`,`Revoke this token?`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`cameraTokens.confirmRevoke.body`,`Any device using "{{name}}" will lose access immediately. This cannot be undone.`,{name:e.name})})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`px-4 py-2 bg-bambu-dark-tertiary text-white rounded-md hover:bg-bambu-dark-tertiary/80`,children:r(`cameraTokens.confirmRevoke.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 bg-red-500 text-white rounded-md hover:bg-red-600`,children:r(`cameraTokens.confirmRevoke.confirm`,`Revoke`)})]})]})})}function RVe({token:e,onClose:t}){let{t:n}=W(),{showToast:r}=Td(),i=e.token??``;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-2xl w-full border border-bambu-green/40`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-6 h-6 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`cameraTokens.created.title`,`Token created — copy it now`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:n(`cameraTokens.created.warning`,`This is the only time this token will be visible. After you close this dialog you can never view it again.`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(`code`,{className:`flex-1 px-3 py-2 bg-bambu-dark rounded-md text-bambu-green text-xs break-all font-mono select-all`,children:i}),(0,K.jsxs)(`button`,{type:`button`,onClick:async()=>{if(i)try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{let e=document.createElement(`textarea`);e.value=i,e.style.position=`fixed`,e.style.opacity=`0`,document.body.appendChild(e);try{e.select(),document.execCommand(`copy`)}finally{document.body.removeChild(e)}}r(n(`cameraTokens.toast.copied`,`Copied to clipboard`))}catch{r(n(`cameraTokens.toast.copyFailed`,`Copy failed — select and copy manually`),`error`)}},className:`flex items-center gap-2 px-3 py-2 bg-bambu-green text-white rounded-md hover:bg-bambu-green/90`,children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),n(`cameraTokens.created.copy`,`Copy`)]})]}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 bg-bambu-dark-tertiary text-white rounded-md hover:bg-bambu-dark-tertiary/80`,children:n(`cameraTokens.created.dismiss`,`I've saved it`)})})]})})}function zVe({token:e,showOwner:t,ownerLabel:n,onRevoke:r}){let{t:i}=W(),a=FVe(e.expires_at);return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary last:border-b-0`,children:[(0,K.jsx)(`td`,{className:`py-3 px-3 text-white`,children:e.name}),t&&(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:n}),(0,K.jsxs)(`td`,{className:`py-3 px-3 text-bambu-gray font-mono text-xs`,children:[e.lookup_prefix,`…`]}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:g3(e.created_at)}),(0,K.jsxs)(`td`,{className:`py-3 px-3 ${a?`text-red-400`:`text-bambu-gray`}`,children:[g3(e.expires_at),a&&(0,K.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-xs bg-red-500/20 text-red-300 rounded`,children:i(`cameraTokens.list.expired`,`Expired`)})]}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-bambu-gray`,children:g3(e.last_used_at)}),(0,K.jsx)(`td`,{className:`py-3 px-3 text-right`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`inline-flex items-center gap-1 px-2 py-1 text-sm text-red-400 hover:text-red-300`,title:i(`cameraTokens.list.revoke`,`Revoke`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`cameraTokens.list.revoke`,`Revoke`)]})})]})}function _3({tokens:e,showOwner:t,userIdToName:n,onRevoke:r,emptyMessage:i}){let{t:a}=W();return e.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic`,children:i}):(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`text-bambu-gray text-left border-b border-bambu-dark-tertiary`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.name`,`Name`)}),t&&(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.owner`,`Owner`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.prefix`,`Prefix`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.created`,`Created`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.expires`,`Expires`)}),(0,K.jsx)(`th`,{className:`py-2 px-3 font-medium`,children:a(`cameraTokens.list.lastUsed`,`Last used`)}),(0,K.jsx)(`th`,{className:`py-2 px-3`})]})}),(0,K.jsx)(`tbody`,{children:e.map(e=>(0,K.jsx)(zVe,{token:e,showOwner:t,ownerLabel:n?.get(e.user_id)??`#${e.user_id}`,onRevoke:r},e.id))})]})})}function BVe(){let{t:e}=W(),{user:t,isAdmin:n}=dd(),{showToast:r}=Td(),[i,a]=(0,y.useState)([]),[o,s]=(0,y.useState)([]),[c,l]=(0,y.useState)(new Map),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),g=async()=>{d(!0);try{if(a(await Q.listMyLongLivedCameraTokens()),n){s(await Q.listAllLongLivedCameraTokens());try{let e=await Q.getUsers();l(new Map(e.map(e=>[e.id,e.username])))}catch{l(new Map)}}}catch(t){r(t instanceof Error?t.message:e(`cameraTokens.toast.loadFailed`,`Failed to load tokens`),`error`)}finally{d(!1)}};(0,y.useEffect)(()=>{g()},[n]);let _=async e=>{let t=[...i,...o].find(t=>t.id===e);t&&h(t)},v=async()=>{if(!m)return;let t=m.id;h(null);try{await Q.revokeLongLivedCameraToken(t),r(e(`cameraTokens.toast.revoked`,`Token revoked`)),await g()}catch(t){r(t instanceof Error?t.message:e(`cameraTokens.toast.revokeFailed`,`Failed to revoke token`),`error`)}},b=(0,y.useMemo)(()=>o.filter(e=>e.user_id!==t?.id),[o,t?.id]);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`cameraTokens.description`,`Long-lived tokens for embedding the camera stream into Home Assistant, Frigate, kiosks, or any other tool that needs a stable URL. Each token is camera-stream-only and can be revoked at any time.`)}),(0,K.jsx)(IVe,{onCreated:e=>{p(e),g()}}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:e(`cameraTokens.list.myTitle`,`My tokens`)}),u?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`cameraTokens.loading`,`Loading…`)}):(0,K.jsx)(_3,{tokens:i,onRevoke:_,emptyMessage:e(`cameraTokens.list.empty`,`No tokens yet.`)})]}),n&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white mb-3`,children:e(`cameraTokens.list.allTitle`,`All users (admin view)`)}),(0,K.jsx)(_3,{tokens:b,showOwner:!0,userIdToName:c,onRevoke:_,emptyMessage:e(`cameraTokens.list.empty`,`No tokens yet.`)})]}),f&&(0,K.jsx)(RVe,{token:f,onClose:()=>p(null)}),m&&(0,K.jsx)(LVe,{token:m,onConfirm:()=>void v(),onCancel:()=>h(null)})]})}function VVe({plug:e,onEdit:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),{data:p,isLoading:m}=q({queryKey:[`smart-plug-status`,e.id],queryFn:()=>Q.getSmartPlugStatus(e.id),refetchInterval:3e4}),{data:h}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),g=h?.find(t=>t.id===e.printer_id),_=J({mutationFn:t=>Q.controlSmartPlug(e.id,t),onMutate:async t=>{await r.cancelQueries({queryKey:[`smart-plug-status`,e.id]});let n=r.getQueryData([`smart-plug-status`,e.id]),i=t===`on`?`ON`:t===`off`||p?.state===`ON`?`OFF`:`ON`;return r.setQueryData([`smart-plug-status`,e.id],e=>({...e,state:i})),{previousStatus:n}},onError:(t,a,o)=>{o?.previousStatus&&r.setQueryData([`smart-plug-status`,e.id],o.previousStatus),i(n(`smartPlugs.failedToTurn`,{action:a,name:e.name}),`error`)},onSettled:()=>{setTimeout(()=>{r.invalidateQueries({queryKey:[`smart-plug-status`,e.id]}),r.invalidateQueries({queryKey:[`smart-plugs`]})},1e3)}}),v=J({mutationFn:t=>Q.updateSmartPlug(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),e.printer_id&&(r.invalidateQueries({queryKey:[`smartPlugByPrinter`,e.printer_id]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`,e.printer_id]}))}}),b=J({mutationFn:()=>Q.deleteSmartPlug(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),e.printer_id&&r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`,e.printer_id]})}}),x=p?.state===`ON`,S=e.plug_type===`mqtt`&&p?.energy?.power!==null&&p?.energy?.power!==void 0,C=(p?.reachable??!1)||S,w=_.isPending,T=(()=>{if(e.plug_type!==`tasmota`||!e.ip_address)return null;let t=e.ip_address;return e.username&&e.password?`http://${encodeURIComponent(e.username)}:${encodeURIComponent(e.password)}@${t}/`:`http://${t}/`})();return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{className:`relative`,children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg flex-shrink-0 ${e.plug_type===`mqtt`?C?`bg-teal-500/20`:`bg-red-500/20`:C?x?`bg-bambu-green/20`:`bg-bambu-dark`:`bg-red-500/20`}`,children:e.plug_type===`mqtt`?(0,K.jsx)(Dl,{className:`w-5 h-5 ${C?`text-teal-400`:`text-red-400`}`}):e.plug_type===`homeassistant`?(0,K.jsx)(Ac,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`}):e.plug_type===`rest`?(0,K.jsx)(bc,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`}):(0,K.jsx)(xl,{className:`w-5 h-5 ${C?x?`text-bambu-green`:`text-bambu-gray`:`text-red-400`}`})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`h3`,{className:`font-medium text-white truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray truncate`,title:e.plug_type===`mqtt`?e.mqtt_topic??void 0:e.plug_type===`homeassistant`?e.ha_entity_id??void 0:e.plug_type===`rest`?e.rest_on_url??e.rest_off_url??void 0:e.ip_address??void 0,children:e.plug_type===`mqtt`?e.mqtt_topic:e.plug_type===`homeassistant`?e.ha_entity_id:e.plug_type===`rest`?e.rest_on_url||e.rest_off_url:e.ip_address})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col items-end gap-1 flex-shrink-0`,children:[m?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin`}):e.plug_type===`mqtt`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm whitespace-nowrap`,children:[(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-teal-500/20 text-teal-400 text-[10px] font-medium rounded flex-shrink-0`,children:`MQTT`}),C&&(0,K.jsx)(`span`,{className:`text-status-ok`,children:`✓`})]}):e.plug_type===`homeassistant`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded`,children:`HA`}),(0,K.jsx)(`span`,{className:C?x?`text-status-ok`:`text-bambu-gray`:`text-status-error`,children:C?p?.state||`?`:n(`smartPlugs.offline`)})]}):e.plug_type===`rest`?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-1 py-0.5 bg-purple-500/20 text-purple-400 text-[10px] font-medium rounded`,children:`REST`}),(0,K.jsx)(`span`,{className:C?x?`text-status-ok`:`text-bambu-gray`:`text-status-error`,children:C?p?.state||`?`:n(`smartPlugs.offline`)})]}):C?(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4 text-status-ok`}),(0,K.jsx)(`span`,{className:x?`text-status-ok`:`text-bambu-gray`,children:p?.state||n(`smartPlugs.unknown`)})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm text-status-error`,children:[(0,K.jsx)(Pu,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:n(`smartPlugs.offline`)})]}),T&&(0,K.jsxs)(`a`,{href:T,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 px-2 py-0.5 bg-bambu-dark hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white text-xs rounded-full transition-colors`,title:n(`smartPlugs.openPlugAdminPage`),children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),n(`smartPlugs.admin`)]})]})]}),g&&(0,K.jsxs)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[n(`smartPlugs.linkedTo`),` `]}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:g.name})]}),(e.power_alert_enabled||e.schedule_enabled||e.plug_type===`mqtt`)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 mb-3`,children:[e.plug_type===`mqtt`&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded-full`,children:[(0,K.jsx)(Xs,{className:`w-3 h-3`}),n(`smartPlugs.monitorOnly`)]}),e.power_alert_enabled&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded-full`,children:[(0,K.jsx)(Bo,{className:`w-3 h-3`}),n(`smartPlugs.alerts`)]}),e.schedule_enabled&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded-full`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),e.schedule_on_time&&e.schedule_off_time?`${e.schedule_on_time} - ${e.schedule_off_time}`:e.schedule_on_time?n(`smartPlugs.scheduleOn`,{time:e.schedule_on_time}):n(`smartPlugs.scheduleOff`,{time:e.schedule_off_time})]})]}),e.plug_type!==`mqtt`&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-3`,children:[(0,K.jsxs)($,{size:`sm`,variant:x?`primary`:`secondary`,disabled:!C||w,onClick:()=>c(!0),className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(wl,{className:`w-4 h-4`}),n(`smartPlugs.on`)]}),(0,K.jsxs)($,{size:`sm`,variant:x?`secondary`:`primary`,disabled:!C||w,onClick:()=>u(!0),className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Cl,{className:`w-4 h-4`}),n(`smartPlugs.off`)]})]}),e.plug_type===`mqtt`&&p?.energy&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg`,children:[p.energy.power!==null&&p.energy.power!==void 0&&(0,K.jsxs)(`div`,{className:`flex-1 text-center`,children:[(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[Math.round(p.energy.power),`W`]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.power`)})]}),p.energy.today!==null&&p.energy.today!==void 0&&(0,K.jsxs)(`div`,{className:`flex-1 text-center border-l border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-lg font-semibold text-white`,children:p.energy.today.toFixed(3)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.kwhToday`)})]})]}),(0,K.jsxs)(`button`,{onClick:()=>f(!d),className:`w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),e.plug_type===`mqtt`?n(`smartPlugs.settings`):n(`smartPlugs.automationSettings`)]}),(0,K.jsx)(`span`,{children:d?`-`:`+`})]}),d&&(0,K.jsxs)(`div`,{className:`pt-3 border-t border-bambu-dark-tertiary space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.showInSwitchbar`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.quickAccessSidebar`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.show_in_switchbar,onChange:e=>v.mutate({show_in_switchbar:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.plug_type!==`mqtt`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.enabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.enableAutomation`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:e=>v.mutate({enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOn`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOnDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_on,onChange:e=>v.mutate({auto_on:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOff`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off,onChange:e=>v.mutate({auto_off:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOffPersistent`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffPersistentDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off_persistent,onChange:e=>v.mutate({auto_off_persistent:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off&&(0,K.jsxs)(`div`,{className:`space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white mb-2`,children:n(`smartPlugs.turnOffDelayMode`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>v.mutate({off_delay_mode:`time`}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${e.off_delay_mode===`time`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4`}),n(`smartPlugs.time`)]}),(0,K.jsxs)(`button`,{onClick:()=>v.mutate({off_delay_mode:`temperature`}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${e.off_delay_mode===`temperature`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(vu,{className:`w-4 h-4`}),n(`smartPlugs.temp`)]})]})]}),e.off_delay_mode===`time`?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.delayMinutes`)}),(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`60`,value:e.off_delay_minutes,onChange:e=>v.mutate({off_delay_minutes:parseInt(e.target.value)||5}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]}):(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.tempThreshold`)}),(0,K.jsx)(`input`,{type:`number`,min:`30`,max:`100`,value:e.off_temp_threshold,onChange:e=>v.mutate({off_temp_threshold:parseInt(e.target.value)||70}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`smartPlugs.tempThresholdDescription`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`smartPlugs.autoOffAfterDrying`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.autoOffAfterDryingDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.auto_off_after_drying,onChange:e=>v.mutate({auto_off_after_drying:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.auto_off_after_drying&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`smartPlugs.delayAfterDryingMinutes`)}),(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`120`,value:e.off_delay_after_drying_minutes,onChange:e=>v.mutate({off_delay_after_drying_minutes:parseInt(e.target.value)||10}),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>t(e),className:`flex-1`,children:[(0,K.jsx)(_l,{className:`w-4 h-4`}),n(`smartPlugs.edit`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>o(!0),className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})}),a&&(0,K.jsx)(Ad,{title:n(`smartPlugs.deleteSmartPlug`),message:n(`smartPlugs.deleteConfirm`,{name:e.name}),confirmText:n(`smartPlugs.delete`),variant:`danger`,onConfirm:()=>{b.mutate(),o(!1)},onCancel:()=>o(!1)}),s&&(0,K.jsx)(Ad,{title:n(`smartPlugs.turnOnSmartPlug`),message:n(`smartPlugs.turnOnConfirm`,{name:e.name}),confirmText:n(`smartPlugs.turnOn`),variant:`default`,onConfirm:()=>{_.mutate(`on`),c(!1)},onCancel:()=>c(!1)}),l&&(0,K.jsx)(Ad,{title:n(`smartPlugs.turnOffSmartPlug`),message:n(`smartPlugs.turnOffConfirm`,{name:e.name}),confirmText:n(`smartPlugs.turnOff`),variant:`danger`,onConfirm:()=>{_.mutate(`off`),u(!1)},onCancel:()=>u(!1)})]})}function HVe({plug:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,[a,o]=(0,y.useState)(e?.plug_type||`tasmota`),[s,c]=(0,y.useState)(e?.name||``),[l,u]=(0,y.useState)(e?.ip_address||``),[d,f]=(0,y.useState)(e?.username||``),[p,m]=(0,y.useState)(e?.password||``),[h,g]=(0,y.useState)(e?.ha_entity_id||``),[_,v]=(0,y.useState)(e?.mqtt_power_topic||e?.mqtt_topic||``),[b,x]=(0,y.useState)(e?.mqtt_power_path||``),[S,C]=(0,y.useState)((e?.mqtt_power_multiplier??e?.mqtt_multiplier??1).toString()),[w,T]=(0,y.useState)(e?.mqtt_energy_topic||``),[E,D]=(0,y.useState)(e?.mqtt_energy_path||``),[O,k]=(0,y.useState)((e?.mqtt_energy_multiplier??1).toString()),[A,j]=(0,y.useState)(e?.mqtt_state_topic||``),[M,N]=(0,y.useState)(e?.mqtt_state_path||``),[P,F]=(0,y.useState)(e?.mqtt_state_on_value||``),[I,L]=(0,y.useState)(e?.rest_on_url||``),[R,z]=(0,y.useState)(e?.rest_on_body||``),[B,V]=(0,y.useState)(e?.rest_off_url||``),[ee,te]=(0,y.useState)(e?.rest_off_body||``),[ne,re]=(0,y.useState)(e?.rest_method||`POST`),[ie,H]=(0,y.useState)(e?.rest_headers||``),[ae,oe]=(0,y.useState)(e?.rest_status_url||``),[U,se]=(0,y.useState)(e?.rest_status_path||``),[ce,le]=(0,y.useState)(e?.rest_status_on_value||``),[ue,de]=(0,y.useState)(e?.rest_power_url||``),[fe,pe]=(0,y.useState)(e?.rest_power_path||``),[me,he]=(0,y.useState)((e?.rest_power_multiplier??1).toString()),[ge,_e]=(0,y.useState)(e?.rest_energy_url||``),[ve,ye]=(0,y.useState)(e?.rest_energy_path||``),[be,xe]=(0,y.useState)((e?.rest_energy_multiplier??1).toString()),[Se,Ce]=(0,y.useState)(e?.ha_power_entity||``),[we,Te]=(0,y.useState)(e?.ha_energy_today_entity||``),[Ee,De]=(0,y.useState)(e?.ha_energy_total_entity||``),[Oe,ke]=(0,y.useState)(``),[Ae,je]=(0,y.useState)(``),[Me,Ne]=(0,y.useState)(!1),Pe=(0,y.useRef)(null),[Fe,Ie]=(0,y.useState)(``),[Le,Re]=(0,y.useState)(!1),ze=(0,y.useRef)(null),[Be,Ve]=(0,y.useState)(``),[He,Ue]=(0,y.useState)(!1),We=(0,y.useRef)(null),[Ge,Ke]=(0,y.useState)(``),[qe,Je]=(0,y.useState)(!1),Ye=(0,y.useRef)(null),[Xe,Ze]=(0,y.useState)(e?.printer_id||null),[Qe,$e]=(0,y.useState)(null),[et,tt]=(0,y.useState)(null),[nt,rt]=(0,y.useState)(e?.power_alert_enabled||!1),[it,at]=(0,y.useState)(e?.power_alert_high?.toString()||``),[ot,st]=(0,y.useState)(e?.power_alert_low?.toString()||``),[ct,lt]=(0,y.useState)(e?.schedule_enabled||!1),[ut,dt]=(0,y.useState)(e?.schedule_on_time||``),[ft,pt]=(0,y.useState)(e?.schedule_off_time||``),[mt,ht]=(0,y.useState)(e?.show_in_switchbar||!1),[gt,_t]=(0,y.useState)(e?.show_on_printer_card??!0),[vt,yt]=(0,y.useState)(!1),[bt,xt]=(0,y.useState)({scanned:0,total:0}),[St,Ct]=(0,y.useState)([]),wt=(0,y.useRef)(null),{data:Tt}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Et}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:Dt}=q({queryKey:[`settings`],queryFn:Q.getSettings}),Ot=!!(Dt?.ha_enabled&&Dt?.ha_url&&Dt?.ha_token);(0,y.useEffect)(()=>{let e=setTimeout(()=>{je(Oe)},300);return()=>clearTimeout(e)},[Oe]),(0,y.useEffect)(()=>{let e=e=>{Pe.current&&!Pe.current.contains(e.target)&&Ne(!1),ze.current&&!ze.current.contains(e.target)&&Re(!1),We.current&&!We.current.contains(e.target)&&Ue(!1),Ye.current&&!Ye.current.contains(e.target)&&Je(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let{data:kt,isLoading:At,error:jt}=q({queryKey:[`ha-entities`,Ae],queryFn:()=>Q.getHAEntities(Ae||void 0),enabled:a===`homeassistant`&&Ot,retry:!1,staleTime:0}),{data:Mt}=q({queryKey:[`ha-sensor-entities`],queryFn:Q.getHASensorEntities,enabled:a===`homeassistant`&&Ot,retry:!1,staleTime:0});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e),wt.current&&clearInterval(wt.current)}},[t]);let G=async()=>{yt(!0),Ct([]),xt({scanned:0,total:0}),tt(null);try{await Q.startTasmotaScan();let e=async()=>{try{let e=await Q.getTasmotaScanStatus();xt({scanned:e.scanned,total:e.total}),Ct(await Q.getDiscoveredTasmotaDevices()),e.running||(yt(!1),wt.current&&=(clearInterval(wt.current),null))}catch(e){console.error(`Polling error:`,e)}};await e(),wt.current=setInterval(e,500)}catch(e){yt(!1),tt((e instanceof Error?e.message:typeof e==`string`?e:JSON.stringify(e))||n(`smartPlugs.failedToStartScan`))}},Nt=async()=>{try{await Q.stopTasmotaScan()}catch{}yt(!1),wt.current&&=(clearInterval(wt.current),null)},Pt=e=>{u(e.ip_address),c(e.name),$e(null)},Ft=J({mutationFn:()=>Q.testSmartPlugConnection(l,d||null,p||null),onSuccess:e=>{$e(e),tt(null),!s&&e.device_name&&c(e.device_name)},onError:e=>{$e(null),tt(e.message)}}),It=J({mutationFn:e=>Q.createSmartPlug(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`]}),t()},onError:e=>{tt(e.message)}}),Lt=J({mutationFn:t=>Q.updateSmartPlug(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`smart-plugs`]}),r.invalidateQueries({queryKey:[`scriptPlugsByPrinter`]}),t()},onError:e=>{tt(e.message)}}),Rt=Tt?.filter(t=>a===`tasmota`?!Et?.some(n=>n.printer_id===t.id&&n.id!==e?.id&&n.plug_type===`tasmota`):!0),zt=e=>{if(e.preventDefault(),tt(null),!s.trim()){tt(n(`smartPlugs.nameRequired`));return}if(a===`tasmota`&&!l.trim()){tt(`IP address is required for Tasmota plugs`);return}if(a===`homeassistant`&&!h){tt(n(`smartPlugs.entityRequired`));return}if(a===`mqtt`){let e=_.trim(),t=w.trim(),r=A.trim();if(!e&&!t&&!r){tt(n(`smartPlugs.mqttTopicRequired`));return}}if(a===`rest`&&!I.trim()&&!B.trim()){tt(n(`smartPlugs.restUrlRequired`));return}let t={name:s.trim(),plug_type:a,ip_address:a===`tasmota`?l.trim():null,ha_entity_id:a===`homeassistant`?h:null,ha_power_entity:a===`homeassistant`&&Se||null,ha_energy_today_entity:a===`homeassistant`&&we||null,ha_energy_total_entity:a===`homeassistant`&&Ee||null,mqtt_power_topic:a===`mqtt`&&_.trim()||null,mqtt_power_path:a===`mqtt`&&b.trim()||null,mqtt_power_multiplier:a===`mqtt`&&parseFloat(S)||1,mqtt_energy_topic:a===`mqtt`&&w.trim()||null,mqtt_energy_path:a===`mqtt`&&E.trim()||null,mqtt_energy_multiplier:a===`mqtt`&&parseFloat(O)||1,mqtt_state_topic:a===`mqtt`&&A.trim()||null,mqtt_state_path:a===`mqtt`&&M.trim()||null,mqtt_state_on_value:a===`mqtt`&&P.trim()||null,rest_on_url:a===`rest`&&I.trim()||null,rest_on_body:a===`rest`&&R.trim()||null,rest_off_url:a===`rest`&&B.trim()||null,rest_off_body:a===`rest`&&ee.trim()||null,rest_method:a===`rest`?ne:null,rest_headers:a===`rest`&&ie.trim()||null,rest_status_url:a===`rest`&&ae.trim()||null,rest_status_path:a===`rest`&&U.trim()||null,rest_status_on_value:a===`rest`&&ce.trim()||null,rest_power_url:a===`rest`&&ue.trim()||null,rest_power_path:a===`rest`&&fe.trim()||null,rest_power_multiplier:a===`rest`&&parseFloat(me)||1,rest_energy_url:a===`rest`&&ge.trim()||null,rest_energy_path:a===`rest`&&ve.trim()||null,rest_energy_multiplier:a===`rest`&&parseFloat(be)||1,username:a===`tasmota`&&d.trim()||null,password:a===`tasmota`&&p.trim()||null,printer_id:Xe,power_alert_enabled:nt,power_alert_high:it?parseFloat(it):null,power_alert_low:ot?parseFloat(ot):null,schedule_enabled:ct,schedule_on_time:ut||null,schedule_off_time:ft||null,show_in_switchbar:mt,show_on_printer_card:gt};i?Lt.mutate(t):It.mutate(t)},Bt=It.isPending||Lt.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(i?`smartPlugs.editTitle`:`smartPlugs.addTitle`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:zt,className:`p-6 space-y-4 overflow-y-auto`,children:[et&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:et}),!i&&(0,K.jsxs)(`div`,{className:`flex gap-2 mb-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`tasmota`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`tasmota`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(xl,{className:`w-4 h-4`}),`Tasmota`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`homeassistant`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`homeassistant`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Ac,{className:`w-4 h-4`}),`HA`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`mqtt`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`mqtt`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Dl,{className:`w-4 h-4`}),`MQTT`]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{o(`rest`),$e(null),tt(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2.5 rounded-lg font-medium transition-colors ${a===`rest`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(bc,{className:`w-4 h-4`}),`REST`]})]}),!i&&a===`tasmota`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[vt?(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:Nt,className:`w-full`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),n(`smartPlugs.stopScanning`)]}):(0,K.jsxs)($,{type:`button`,variant:`primary`,onClick:G,className:`w-full`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4`}),n(`smartPlugs.discoverTasmota`)]}),vt&&bt.total>0&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:n(`smartPlugs.addSmartPlug.scanningNetwork`)}),(0,K.jsxs)(`span`,{children:[bt.scanned,` / `,bt.total]})]}),(0,K.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${bt.scanned/bt.total*100}%`}})})]}),St.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.foundDevices`,{count:St.length})}),(0,K.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-1`,children:St.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>Pt(e),className:`w-full flex items-center justify-between p-2 bg-bambu-dark hover:bg-bambu-dark-tertiary rounded-lg transition-colors text-left border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(xl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e.ip_address})]})]}),e.state&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${e.state===`ON`?`text-bambu-green`:`text-bambu-gray`}`,children:[(0,K.jsx)(wl,{className:`w-3 h-3`}),e.state]})]},e.ip_address))})]}),!vt&&St.length===0&&bt.total>0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray text-center py-2`,children:n(`smartPlugs.noDevicesFound`)})]}),a===`homeassistant`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!Ot&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400`,children:[n(`smartPlugs.haNotConfigured`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:n(`smartPlugs.haSettingsPath`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1 opacity-50`,children:n(`smartPlugs.selectEntity`)}),(0,K.jsx)(`select`,{disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed opacity-50`,children:(0,K.jsx)(`option`,{children:n(`smartPlugs.addSmartPlug.chooseEntity`)})})]})]}),Ot&&(0,K.jsxs)(K.Fragment,{children:[At&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-4 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),n(`smartPlugs.loadingEntities`)]}),jt&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:n(`smartPlugs.failedToLoadEntities`,{error:jt.message})}),(()=>{let t=Et?.filter(t=>t.ha_entity_id&&t.id!==e?.id).map(e=>e.ha_entity_id)||[],r=(kt||[]).filter(e=>!t.includes(e.entity_id)),i=kt?.find(e=>e.entity_id===h);return(0,K.jsxs)(`div`,{ref:Pe,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.selectEntity`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:Me?Oe:i?`${i.friendly_name} (${i.entity_id})`:``,onChange:e=>{ke(e.target.value),Me||Ne(!0)},onFocus:()=>{Ne(!0),ke(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEntities`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),h&&!Me&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{g(``),ke(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})}),At&&(0,K.jsx)(X,{className:`absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin`})]}),Me&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-60 overflow-y-auto`,children:[At&&(0,K.jsxs)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray flex items-center gap-2`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`smartPlugs.loading`)]}),!At&&r.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:Ae?n(`smartPlugs.noEntitiesMatching`,{search:Ae}):n(`smartPlugs.noEntitiesAvailable`)}),!At&&r.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{g(e.entity_id),Ne(!1),ke(``),s||c(e.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${e.entity_id===h?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray flex items-center justify-between`,children:[(0,K.jsx)(`span`,{children:e.entity_id}),(0,K.jsx)(`span`,{className:e.state===`on`?`text-bambu-green`:``,children:e.state})]})]},e.entity_id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(Ae?`smartPlugs.searchingEntities`:`smartPlugs.showingEntities`,{count:r.length})})]})})(),h&&Mt&&Mt.length>0&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:n(`smartPlugs.energyMonitoringOptional`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:n(`smartPlugs.energyMonitoringHint`)})]}),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`W`||e.unit_of_measurement===`kW`||e.unit_of_measurement===`mW`),t=Fe?e.filter(e=>e.entity_id.toLowerCase().includes(Fe.toLowerCase())||e.friendly_name.toLowerCase().includes(Fe.toLowerCase())):e,r=Mt.find(e=>e.entity_id===Se);return(0,K.jsxs)(`div`,{ref:ze,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.powerSensorW`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:Le?Fe:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ie(e.target.value),Le||Re(!0)},onFocus:()=>{Re(!0),Ie(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchPowerSensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),Se&&!Le&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Ce(``),Ie(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),Le&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Ce(``),Re(!1),Ie(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{Ce(e.entity_id),Re(!1),Ie(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===Se?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})(),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`kWh`||e.unit_of_measurement===`Wh`||e.unit_of_measurement===`MWh`),t=Be?e.filter(e=>e.entity_id.toLowerCase().includes(Be.toLowerCase())||e.friendly_name.toLowerCase().includes(Be.toLowerCase())):e,r=Mt.find(e=>e.entity_id===we);return(0,K.jsxs)(`div`,{ref:We,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.energyTodayKwh`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:He?Be:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ve(e.target.value),He||Ue(!0)},onFocus:()=>{Ue(!0),Ve(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEnergySensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),we&&!He&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Te(``),Ve(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),He&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{Te(``),Ue(!1),Ve(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{Te(e.entity_id),Ue(!1),Ve(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===we?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})(),(()=>{let e=Mt.filter(e=>e.unit_of_measurement===`kWh`||e.unit_of_measurement===`Wh`||e.unit_of_measurement===`MWh`),t=Ge?e.filter(e=>e.entity_id.toLowerCase().includes(Ge.toLowerCase())||e.friendly_name.toLowerCase().includes(Ge.toLowerCase())):e,r=Mt.find(e=>e.entity_id===Ee);return(0,K.jsxs)(`div`,{ref:Ye,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.totalEnergyKwh`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:qe?Ge:r?`${r.friendly_name} (${r.state} ${r.unit_of_measurement})`:``,onChange:e=>{Ke(e.target.value),qe||Je(!0)},onFocus:()=>{Je(!0),Ke(``)},placeholder:n(`smartPlugs.addSmartPlug.placeholders.searchEnergySensors`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),Ee&&!qe&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{De(``),Ke(``)},className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(Ru,{className:`w-4 h-4 text-bambu-gray hover:text-white`})})]}),qe&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>{De(``),Je(!1),Ke(``)},className:`w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary`,children:n(`smartPlugs.none`)}),t.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>{De(e.entity_id),Je(!1),Ke(``)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.entity_id===Ee?`bg-bambu-green/20 text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e.friendly_name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[e.entity_id,` • `,e.state,` `,e.unit_of_measurement]})]},e.entity_id)),t.length===0&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:n(`smartPlugs.noMatchingSensors`)})]})]})})()]})]})]}),a===`mqtt`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[!Dt?.mqtt_broker&&(0,K.jsxs)(`div`,{className:`p-3 bg-yellow-500/20 border border-yellow-500/50 rounded-lg text-sm text-yellow-400`,children:[n(`smartPlugs.mqttNotConfigured`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:n(`smartPlugs.mqttSettingsPath`)}),` `,n(`smartPlugs.mqttNotConfiguredSuffix`)]}),Dt?.mqtt_broker&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:n(`smartPlugs.monitorOnly`)}),(0,K.jsx)(`p`,{className:`text-xs opacity-80`,children:n(`smartPlugs.mqttMonitorOnlyDescription`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm`,children:n(`smartPlugs.powerMonitoring`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:_,onChange:e=>v(e.target.value),placeholder:`zigbee2mqtt/shelly-working-room`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`power_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.multiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttPowerHint`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.energyMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Same as power topic, or different`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:`energy_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.multiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttEnergyHint`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.stateMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.topic`)}),(0,K.jsx)(`input`,{type:`text`,value:A,onChange:e=>j(e.target.value),placeholder:`Same as power topic, or different`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.jsonPath`)}),(0,K.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),placeholder:`state_l1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.onValue`)}),(0,K.jsx)(`input`,{type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:n(`smartPlugs.addSmartPlug.placeholders.mqttStateOnValue`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,style:{whiteSpace:`pre-line`},children:n(`smartPlugs.mqttStateHint`)})]})]})]}),a===`rest`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm`,children:n(`smartPlugs.restControl`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restMethod`)}),(0,K.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`GET`,children:`GET`}),(0,K.jsx)(`option`,{value:`POST`,children:`POST`}),(0,K.jsx)(`option`,{value:`PUT`,children:`PUT`}),(0,K.jsx)(`option`,{value:`PATCH`,children:`PATCH`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restOnUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:I,onChange:e=>{L(e.target.value),$e(null)},placeholder:`http://openhab:8080/rest/items/MyPlug`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restOnBody`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:n(`smartPlugs.restBodyHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restOffUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:B,onChange:e=>{V(e.target.value),$e(null)},placeholder:`http://openhab:8080/rest/items/MyPlug`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restOffBody`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:n(`smartPlugs.restBodyHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.restHeaders`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`textarea`,{value:ie,onChange:e=>H(e.target.value),placeholder:n(`smartPlugs.restHeadersHint`),rows:2,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none font-mono text-sm`})})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.stateMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),placeholder:n(`smartPlugs.restStatusHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusPath`)}),(0,K.jsx)(`input`,{type:`text`,value:U,onChange:e=>se(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restStatusOnValue`)}),(0,K.jsx)(`input`,{type:`text`,value:ce,onChange:e=>le(e.target.value),placeholder:`ON`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`p`,{className:`text-white font-medium text-sm`,children:[n(`smartPlugs.energyMonitoring`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restPowerUrl`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ue,onChange:e=>de(e.target.value),placeholder:n(`smartPlugs.restPowerUrlHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restPowerPath`)}),(0,K.jsx)(`input`,{type:`text`,value:fe,onChange:e=>pe(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restPowerMultiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:me,onChange:e=>he(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`smartPlugs.restEnergyUrl`),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,n(`smartPlugs.optional`),`)`]})]}),(0,K.jsx)(`input`,{type:`text`,value:ge,onChange:e=>_e(e.target.value),placeholder:n(`smartPlugs.restEnergyUrlHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restEnergyPath`)}),(0,K.jsx)(`input`,{type:`text`,value:ve,onChange:e=>ye(e.target.value),placeholder:n(`smartPlugs.restPathHint`),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.restEnergyMultiplier`)}),(0,K.jsx)(`input`,{type:`text`,value:be,onChange:e=>xe(e.target.value),placeholder:`1`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.restEnergyHint`)})]}),(I.trim()||B.trim())&&(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:async()=>{$e(null);try{let e=I.trim()||B.trim(),t=await Q.testRESTConnection(e,ne,ie.trim()||null);$e({success:t.success}),t.success||tt(t.error||n(`smartPlugs.addSmartPlug.connectionFailed`))}catch{$e({success:!1}),tt(n(`smartPlugs.addSmartPlug.connectionFailed`))}},className:`w-full`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4`}),n(`smartPlugs.testConnection`)]})}),Qe&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm ${Qe.success?`text-green-400`:`text-red-400`}`,children:[Qe.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(Pu,{className:`w-4 h-4`}),Qe.success?n(`smartPlugs.connectionSuccess`):n(`smartPlugs.addSmartPlug.connectionFailed`)]})]}),a===`tasmota`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.ipAddress`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>{u(e.target.value),$e(null)},placeholder:`192.168.1.100`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>Ft.mutate(),disabled:!l.trim()||Ft.isPending,children:[Ft.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Fu,{className:`w-4 h-4`}),n(`smartPlugs.test`)]})]})]}),a===`tasmota`&&Qe&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg flex items-center gap-2 ${Qe.success?`bg-bambu-green/20 border border-bambu-green/50 text-bambu-green`:`bg-red-500/20 border border-red-500/50 text-red-400`}`,children:Qe.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-5 h-5`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium`,children:n(`smartPlugs.connectedResult`)}),(0,K.jsxs)(`p`,{className:`text-sm opacity-80`,children:[Qe.device_name&&n(`smartPlugs.deviceLabel`,{name:Qe.device_name}),n(`smartPlugs.stateLabel`,{state:Qe.state})]})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Pu,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:n(`smartPlugs.addSmartPlug.connectionFailed`)})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:n(`smartPlugs.addSmartPlug.placeholders.plugName`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),a===`tasmota`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.username`)}),(0,K.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`admin`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.password`)}),(0,K.jsx)(`input`,{type:`password`,value:p,onChange:e=>m(e.target.value),placeholder:`********`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray -mt-2`,children:n(`smartPlugs.authHint`)})]}),a!==`mqtt`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.linkToPrinter`)}),(0,K.jsxs)(`select`,{value:Xe??``,onChange:e=>Ze(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:n(`smartPlugs.noPrinter`)}),Rt?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`smartPlugs.linkingDescription`)})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Bo,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.powerAlerts`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:nt,onChange:e=>rt(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),nt&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.alertAbove`)}),(0,K.jsx)(`input`,{type:`number`,value:it,onChange:e=>at(e.target.value),placeholder:`e.g. 200`,min:`0`,max:`5000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.alertBelow`)}),(0,K.jsx)(`input`,{type:`number`,value:ot,onChange:e=>st(e.target.value),placeholder:`e.g. 10`,min:`0`,max:`5000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.alertDescription`)})]})]}),a!==`mqtt`&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.dailySchedule`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:ct,onChange:e=>lt(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),ct&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.turnOnAt`)}),(0,K.jsx)(`input`,{type:`time`,value:ut,onChange:e=>dt(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`smartPlugs.turnOffAt`)}),(0,K.jsx)(`input`,{type:`time`,value:ft,onChange:e=>pt(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.scheduleDescription`)})]})]}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(zc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.showInSwitchbar`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.quickAccessSidebar`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:mt,onChange:e=>ht(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})}),a===`homeassistant`&&(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white font-medium`,children:n(`smartPlugs.showOnPrinterCard`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`smartPlugs.displayOnPrinterCard`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:gt,onChange:e=>_t(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`smartPlugs.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:Bt,className:`flex-1`,children:[Bt?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),n(i?`smartPlugs.save`:`smartPlugs.add`)]})]})]})]})})}function UVe({provider:e,onEdit:t}){let{t:n}=W(),r=no(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),{data:u}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),d=u?.find(t=>t.id===e.printer_id),f=J({mutationFn:t=>Q.updateNotificationProvider(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]})}}),p=J({mutationFn:()=>Q.deleteNotificationProvider(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]})}}),m=J({mutationFn:()=>Q.testNotificationProvider(e.id),onSuccess:e=>{l(e),r.invalidateQueries({queryKey:[`notification-providers`]})},onError:e=>{l({success:!1,message:e.message})}}),h=e=>e||``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{className:`relative`,children:(0,K.jsxs)(yd,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between ${e.enabled?`mb-3`:`mb-0`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${e.enabled?`bg-bambu-green/20`:`bg-bambu-dark`}`,children:(0,K.jsx)(Bo,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.providerTypes.${e.provider_type}`,e.provider_type)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e.last_success&&(0,K.jsx)(`span`,{className:`text-xs text-status-ok hidden sm:inline`,children:n(`notifications.lastSuccess`,{date:yf(e.last_success)})}),e.last_error&&e.last_error_at&&(!e.last_success||(vf(e.last_error_at)?.getTime()||0)>(vf(e.last_success)?.getTime()||0))&&(0,K.jsx)(`span`,{className:`text-xs text-status-error`,title:e.last_error,children:n(`notifications.error`)}),(0,K.jsx)(lU,{checked:e.enabled,onChange:e=>f.mutate({enabled:e})})]})]}),e.enabled&&(0,K.jsxs)(K.Fragment,{children:[d&&(0,K.jsxs)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[n(`notifications.printer`),` `]}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:d.name})]}),!d&&!e.printer_id&&(0,K.jsx)(`div`,{className:`mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.allPrinters`)})}),(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-1`,children:[e.on_print_start&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-blue-500/20 text-blue-400 text-xs rounded`,children:n(`notifications.start`)}),e.on_plate_not_empty&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-rose-600/20 text-rose-300 text-xs rounded`,children:n(`notifications.plateCheck`)}),e.on_print_complete&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded`,children:n(`notifications.complete`)}),e.on_print_failed&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded`,children:n(`notifications.failed`)}),e.on_print_stopped&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded`,children:n(`notifications.stopped`)}),e.on_print_progress&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded`,children:n(`notifications.progress`)}),e.on_printer_offline&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded`,children:n(`notifications.offline`)}),e.on_printer_error&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded`,children:n(`notifications.error`)}),e.on_ai_failure_detection&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-fuchsia-500/20 text-fuchsia-300 text-xs rounded`,children:n(`notifications.aiFailureDetection`)}),e.on_filament_low&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-cyan-500/20 text-cyan-400 text-xs rounded`,children:n(`notifications.lowFilament`)}),e.on_maintenance_due&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-purple-500/20 text-purple-400 text-xs rounded`,children:n(`notifications.maintenance`)}),e.on_ams_humidity_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-blue-600/20 text-blue-300 text-xs rounded`,children:n(`notifications.amsHumidity`)}),e.on_ams_temperature_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-orange-600/20 text-orange-300 text-xs rounded`,children:n(`notifications.amsTemp`)}),e.on_ams_ht_humidity_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-cyan-600/20 text-cyan-300 text-xs rounded`,children:n(`notifications.amsHtHumidity`)}),e.on_ams_ht_temperature_high&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-600/20 text-amber-300 text-xs rounded`,children:n(`notifications.amsHtTemp`)}),e.on_bed_cooled&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-teal-500/20 text-teal-400 text-xs rounded`,children:n(`notifications.bedCooled`)}),e.on_first_layer_complete&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-emerald-600/20 text-emerald-300 text-xs rounded`,children:n(`notifications.firstLayer`)}),e.on_print_missing_spool_assignment&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-amber-500/20 text-amber-300 text-xs rounded`,children:n(`notifications.missingSpoolAssignmentLabel`)}),e.on_stock_reorder_alert&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-lime-500/20 text-lime-400 text-xs rounded`,children:n(`notifications.stockReorderAlert`)}),e.on_stock_break_alert&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-red-600/20 text-red-300 text-xs rounded`,children:n(`notifications.stockBreakAlert`)}),e.quiet_hours_enabled&&(0,K.jsxs)(`span`,{className:`px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1`,children:[(0,K.jsx)(sl,{className:`w-3 h-3`}),n(`notifications.quiet`)]}),e.daily_digest_enabled&&(0,K.jsxs)(`span`,{className:`px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),n(`notifications.digest`,{time:e.daily_digest_time})]})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsxs)($,{size:`sm`,variant:`secondary`,disabled:m.isPending,onClick:()=>{l(null),m.mutate()},className:`w-full`,children:[m.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),n(`notifications.sendTestNotification`)]})}),c&&(0,K.jsxs)(`div`,{className:`mb-3 p-2 rounded-lg flex items-center gap-2 text-sm ${c.success?`bg-bambu-green/20 text-bambu-green`:`bg-red-500/20 text-red-400`}`,children:[c.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(ys,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:c.message})]})]}),(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors ${e.enabled?`border-t border-bambu-dark-tertiary`:`mt-2 border-t border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4`}),n(`notifications.eventSettings`)]}),o?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`})]}),o&&(0,K.jsxs)(`div`,{className:`pt-3 border-t border-bambu-dark-tertiary space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.enabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.sendFromProvider`)})]}),(0,K.jsx)(lU,{checked:e.enabled,onChange:e=>f.mutate({enabled:e})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printEvents`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printStarted`)}),(0,K.jsx)(lU,{checked:e.on_print_start,onChange:e=>f.mutate({on_print_start:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.plateNotEmpty`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.plateNotEmptyDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_plate_not_empty??!0,onChange:e=>f.mutate({on_plate_not_empty:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printCompleted`)}),(0,K.jsx)(lU,{checked:e.on_print_complete,onChange:e=>f.mutate({on_print_complete:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.bedCooledLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.bedCooledDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_bed_cooled??!1,onChange:e=>f.mutate({on_bed_cooled:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.firstLayerCompleteLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.firstLayerCompleteDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_first_layer_complete??!1,onChange:e=>f.mutate({on_first_layer_complete:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.missingSpoolAssignmentLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.missingSpoolAssignmentDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_print_missing_spool_assignment??!1,onChange:e=>f.mutate({on_print_missing_spool_assignment:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printFailed`)}),(0,K.jsx)(lU,{checked:e.on_print_failed,onChange:e=>f.mutate({on_print_failed:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printStopped`)}),(0,K.jsx)(lU,{checked:e.on_print_stopped,onChange:e=>f.mutate({on_print_stopped:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.progressMilestones`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.progressMilestonesDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_print_progress,onChange:e=>f.mutate({on_print_progress:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printerStatus`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printerOffline`)}),(0,K.jsx)(lU,{checked:e.on_printer_offline,onChange:e=>f.mutate({on_printer_offline:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.printerError`)}),(0,K.jsx)(lU,{checked:e.on_printer_error,onChange:e=>f.mutate({on_printer_error:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.aiFailureDetection`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.aiFailureDetectionDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_ai_failure_detection??!1,onChange:e=>f.mutate({on_ai_failure_detection:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.lowFilamentLabel`)}),(0,K.jsx)(lU,{checked:e.on_filament_low,onChange:e=>f.mutate({on_filament_low:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.maintenanceDue`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.maintenanceDueDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_maintenance_due??!1,onChange:e=>f.mutate({on_maintenance_due:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.amsAlarms`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHumidityHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHumidityHighDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_ams_humidity_high??!1,onChange:e=>f.mutate({on_ams_humidity_high:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsTemperatureHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsTemperatureHighDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_ams_temperature_high??!1,onChange:e=>f.mutate({on_ams_temperature_high:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.amsHtAlarms`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHtHumidityHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHtHumidityHighDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_ams_ht_humidity_high??!1,onChange:e=>f.mutate({on_ams_ht_humidity_high:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.amsHtTemperatureHigh`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.amsHtTemperatureHighDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_ams_ht_temperature_high??!1,onChange:e=>f.mutate({on_ams_ht_temperature_high:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.inventoryAlerts`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.stockReorderAlert`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.stockReorderAlertDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_stock_reorder_alert??!1,onChange:e=>f.mutate({on_stock_reorder_alert:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.stockBreakAlert`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.stockBreakAlertDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_stock_break_alert??!1,onChange:e=>f.mutate({on_stock_break_alert:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide`,children:n(`notifications.printQueue`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobAdded`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobAddedDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_added??!1,onChange:e=>f.mutate({on_queue_job_added:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobAssigned`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobAssignedDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_assigned??!1,onChange:e=>f.mutate({on_queue_job_assigned:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobStarted`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobStartedDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_started??!1,onChange:e=>f.mutate({on_queue_job_started:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobWaiting`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobWaitingDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_waiting??!0,onChange:e=>f.mutate({on_queue_job_waiting:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobSkipped`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobSkippedDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_skipped??!0,onChange:e=>f.mutate({on_queue_job_skipped:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.jobFailed`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.jobFailedDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_job_failed??!0,onChange:e=>f.mutate({on_queue_job_failed:e})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.queueComplete`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.queueCompleteDescription`)})]}),(0,K.jsx)(lU,{checked:e.on_queue_completed??!1,onChange:e=>f.mutate({on_queue_completed:e})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(sl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.quietHours`)})]}),(0,K.jsx)(lU,{checked:e.quiet_hours_enabled,onChange:e=>f.mutate({quiet_hours_enabled:e})})]}),e.quiet_hours_enabled&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.noNotificationsDuring`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[h(e.quiet_hours_start)||`22:00`,` - `,h(e.quiet_hours_end)||`07:00`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.editProviderToChangeQuietHours`)})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4 text-emerald-400`}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:n(`notifications.dailyDigest`)})]}),(0,K.jsx)(lU,{checked:e.daily_digest_enabled,onChange:e=>f.mutate({daily_digest_enabled:e})})]}),e.daily_digest_enabled&&(0,K.jsxs)(`div`,{className:`pl-4 border-l-2 border-bambu-dark-tertiary space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.batchNotifications`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.sendAt`,{time:h(e.daily_digest_time)||`08:00`})})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.editProviderToChangeDigestTime`)})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>t(e),className:`flex-1`,children:[(0,K.jsx)(_l,{className:`w-4 h-4`}),n(`notifications.edit`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>a(!0),className:`text-red-400 hover:text-red-300`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})]})}),i&&(0,K.jsx)(Ad,{title:n(`notifications.deleteProvider`),message:n(`notifications.deleteConfirm`,{name:e.name}),confirmText:n(`notifications.delete`),variant:`danger`,onConfirm:()=>{p.mutate(),a(!1)},onCancel:()=>a(!1)})]})}var WVe=[`email`,`telegram`,`discord`,`ntfy`,`pushover`,`callmebot`,`webhook`,`homeassistant`];function GVe({provider:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,[a,o]=(0,y.useState)(e?.name||``),[s,c]=(0,y.useState)(e?.provider_type||`email`),[l,u]=(0,y.useState)(e?.printer_id||null),[d,f]=(0,y.useState)(e?.quiet_hours_enabled||!1),[p,m]=(0,y.useState)(e?.quiet_hours_start||`22:00`),[h,g]=(0,y.useState)(e?.quiet_hours_end||`07:00`),[_,v]=(0,y.useState)(e?.daily_digest_enabled||!1),[b,x]=(0,y.useState)(e?.daily_digest_time||`08:00`),[S,C]=(0,y.useState)(e?.on_print_start??!1),[w,T]=(0,y.useState)(e?.on_print_complete??!0),[E,D]=(0,y.useState)(e?.on_print_failed??!0),[O,k]=(0,y.useState)(e?.on_print_stopped??!0),[A,j]=(0,y.useState)(e?.on_print_progress??!1),[M,N]=(0,y.useState)(e?.on_printer_offline??!1),[P,F]=(0,y.useState)(e?.on_printer_error??!1),[I,L]=(0,y.useState)(e?.on_ai_failure_detection??!1),[R,z]=(0,y.useState)(e?.on_filament_low??!1),[B,V]=(0,y.useState)(e?.on_maintenance_due??!1),[ee,te]=(0,y.useState)(e?.on_stock_reorder_alert??!1),[ne,re]=(0,y.useState)(e?.on_stock_break_alert??!1),[ie,H]=(0,y.useState)(e?.on_bed_cooled??!1),[ae,oe]=(0,y.useState)(e?.on_first_layer_complete??!1),[U,se]=(0,y.useState)(e?.config?Object.fromEntries(Object.entries(e.config).filter(([e])=>e!==`event_priorities`).map(([e,t])=>[e,String(t)])):{}),[ce,le]=(0,y.useState)((()=>{let t=e?.config?.event_priorities;if(!t||typeof t!=`object`)return{};let n={};for(let[e,r]of Object.entries(t)){let t=Number(r);Number.isInteger(t)&&t>=1&&t<=5&&(n[e]=t)}return n})()),[ue,de]=(0,y.useState)(null),[fe,pe]=(0,y.useState)(null),{data:me}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let he=J({mutationFn:()=>Q.testNotificationConfig({provider_type:s,config:U}),onSuccess:e=>{de(e),pe(null)},onError:e=>{de({success:!1,message:e.message})}}),ge=J({mutationFn:e=>Q.createNotificationProvider(e),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]}),t()},onError:e=>{pe(e.message)}}),_e=J({mutationFn:t=>Q.updateNotificationProvider(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-providers`]}),t()},onError:e=>{pe(e.message)}}),ve=e=>{if(e.preventDefault(),pe(null),!a.trim()){pe(n(`notifications.nameRequired`));return}let t=xe(s);for(let e of t)if(!U[e.key]?.trim()){pe(n(`notifications.fieldRequired`,{field:e.label}));return}let r=s===`ntfy`&&Object.keys(ce).length>0?{...U,event_priorities:ce}:U,o={name:a.trim(),provider_type:s,config:r,printer_id:l,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?h:null,daily_digest_enabled:_,daily_digest_time:_?b:null,on_print_start:S,on_print_complete:w,on_print_failed:E,on_print_stopped:O,on_print_progress:A,on_printer_offline:M,on_printer_error:P,on_ai_failure_detection:I,on_filament_low:R,on_maintenance_due:B,on_stock_reorder_alert:ee,on_stock_break_alert:ne,on_bed_cooled:ie,on_first_layer_complete:ae};i?_e.mutate(o):ge.mutate(o)},ye=ge.isPending||_e.isPending,be=e=>{switch(e){case`callmebot`:return[{key:`phone`,label:`Phone Number`,placeholder:`+1234567890`,type:`text`,required:!0},{key:`apikey`,label:`API Key`,placeholder:`Your CallMeBot API key`,type:`text`,required:!0}];case`ntfy`:return[{key:`server`,label:`Server URL`,placeholder:`https://ntfy.sh`,type:`text`,required:!1},{key:`topic`,label:`Topic`,placeholder:`my-bambuddy`,type:`text`,required:!0},{key:`auth_token`,label:`Auth Token`,placeholder:`Optional authentication`,type:`password`,required:!1}];case`pushover`:return[{key:`user_key`,label:`User Key`,placeholder:`Your Pushover user key`,type:`text`,required:!0},{key:`app_token`,label:`App Token`,placeholder:`Your Pushover app token`,type:`text`,required:!0},{key:`priority`,label:`Priority`,placeholder:`0 (normal)`,type:`number`,required:!1}];case`telegram`:return[{key:`bot_token`,label:`Bot Token`,placeholder:`Bot token from @BotFather`,type:`password`,required:!0},{key:`chat_id`,label:`Chat ID`,placeholder:`Your chat or group ID`,type:`text`,required:!0}];case`email`:return[{key:`smtp_server`,label:`SMTP Server`,placeholder:`smtp.gmail.com`,type:`text`,required:!0},{key:`smtp_port`,label:`SMTP Port`,placeholder:`587`,type:`number`,required:!1},{key:`security`,label:`Security`,type:`select`,required:!1,options:[{value:`starttls`,label:`STARTTLS (Port 587)`},{value:`ssl`,label:`SSL/TLS (Port 465)`},{value:`none`,label:`None (Port 25)`}]},{key:`auth_enabled`,label:`Authentication`,type:`select`,required:!1,options:[{value:`true`,label:`Enabled`},{value:`false`,label:`Disabled`}]},{key:`username`,label:`Username`,placeholder:`your@email.com`,type:`text`,required:!1},{key:`password`,label:`Password`,placeholder:`App password`,type:`password`,required:!1},{key:`from_email`,label:`From Email`,placeholder:`your@email.com`,type:`text`,required:!0},{key:`to_email`,label:`To Email`,placeholder:`recipient@email.com`,type:`text`,required:!0}];case`discord`:return[{key:`webhook_url`,label:`Webhook URL`,placeholder:`https://discord.com/api/webhooks/...`,type:`text`,required:!0}];case`webhook`:return[{key:`webhook_url`,label:`Webhook URL`,placeholder:`https://example.com/webhook`,type:`text`,required:!0},{key:`payload_format`,label:`Payload Format`,type:`select`,required:!1,options:[{value:`generic`,label:`Generic JSON`},{value:`slack`,label:`Slack / Mattermost`}]},{key:`auth_header`,label:`Authorization`,placeholder:`Bearer token (optional)`,type:`password`,required:!1},{key:`field_title`,label:`Title Field Name`,placeholder:`title`,type:`text`,required:!1,showIf:e=>e.payload_format!==`slack`},{key:`field_message`,label:`Message Field Name`,placeholder:`message`,type:`text`,required:!1,showIf:e=>e.payload_format!==`slack`}];case`homeassistant`:return[{key:`service`,label:`Home Assistant Service`,placeholder:`notify.mobile_app_myphone`,type:`text`,required:!1}];default:return[]}},xe=e=>be(e).filter(e=>e.required),Se=be(s);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg my-8 max-h-[90vh] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(i?`notifications.editTitle`:`notifications.addTitle`)}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:ve,className:`p-6 space-y-4`,children:[fe&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:fe}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.nameLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`notifications.namePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.providerTypeLabel`)}),(0,K.jsx)(`select`,{value:s,onChange:e=>{c(e.target.value),se({}),de(null)},disabled:i,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`,children:WVe.map(e=>(0,K.jsx)(`option`,{value:e,children:n(`notifications.providerTypes.${e}`,e)},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.providerDescriptions.${s}`,``)})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.configuration`)}),Se.filter(e=>!(`showIf`in e)||e.showIf?.(U)!==!1).map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[e.label,` `,e.required&&`*`]}),e.type===`select`&&`options`in e&&e.options?(0,K.jsx)(`select`,{value:U[e.key]||e.options[0]?.value||``,onChange:t=>{se({...U,[e.key]:t.target.value}),de(null)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:e.options.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))}):(0,K.jsx)(`input`,{type:e.type,value:U[e.key]||``,onChange:t=>{se({...U,[e.key]:t.target.value}),de(null)},placeholder:e.placeholder,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]},e.key))]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>{de(null),he.mutate()},disabled:he.isPending||xe(s).length>0&&!U[xe(s)[0]?.key],className:`flex-1`,children:[he.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),n(`notifications.testConfiguration`)]})}),ue&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg flex items-center gap-2 ${ue.success?`bg-bambu-green/20 border border-bambu-green/50 text-bambu-green`:`bg-red-500/20 border border-red-500/50 text-red-400`}`,children:ue.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:ue.message})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ys,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{children:ue.message})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`notifications.printerFilter`)}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:n(`notifications.allPrinters`)}),me?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.onlyFromPrinter`)})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-sm text-white`,children:n(`notifications.quietHoursDnd`)}),(0,K.jsx)(lU,{checked:d,onChange:f})]}),d&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.quietStart`)}),(0,K.jsx)(`input`,{type:`time`,value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.quietEnd`)}),(0,K.jsx)(`input`,{type:`time`,value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white`,children:n(`notifications.dailyDigestLabel`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`notifications.batchNotifications`)})]}),(0,K.jsx)(lU,{checked:_,onChange:v})]}),_&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:n(`notifications.sendDigestAt`)}),(0,K.jsx)(`input`,{type:`time`,value:b,onChange:e=>x(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`notifications.digestCollected`)})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`notifications.notificationEvents`)}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.printEvents`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.start`)}),(0,K.jsx)(lU,{checked:S,onChange:C})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.complete`)}),(0,K.jsx)(lU,{checked:w,onChange:T})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.failed`)}),(0,K.jsx)(lU,{checked:E,onChange:D})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stopped`)}),(0,K.jsx)(lU,{checked:O,onChange:k})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.progress`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.progressPercent`)})]}),(0,K.jsx)(lU,{checked:A,onChange:j})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.bedCooled`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.bedCooledAfterPrint`)})]}),(0,K.jsx)(lU,{checked:ie,onChange:H})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between col-span-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.firstLayerCompleteLabel`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.firstLayerCompleteDescription`)})]}),(0,K.jsx)(lU,{checked:ae,onChange:oe})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.printerStatus`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.offline`)}),(0,K.jsx)(lU,{checked:M,onChange:N})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.error`)}),(0,K.jsx)(lU,{checked:P,onChange:F})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.aiFailureDetection`)}),(0,K.jsx)(lU,{checked:I,onChange:L})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.lowFilament`)}),(0,K.jsx)(lU,{checked:R,onChange:z})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.maintenance`)}),(0,K.jsx)(lU,{checked:B,onChange:V})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-2`,children:n(`notifications.inventoryAlerts`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stockReorderAlert`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.stockReorderAlertDescription`)})]}),(0,K.jsx)(lU,{checked:ee,onChange:te})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`notifications.stockBreakAlert`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1`,children:n(`notifications.stockBreakAlertDescription`)})]}),(0,K.jsx)(lU,{checked:ne,onChange:re})]})]})]}),s===`ntfy`&&(()=>{let e=[];return S&&e.push({key:`on_print_start`,label:n(`notifications.start`)}),w&&e.push({key:`on_print_complete`,label:n(`notifications.complete`)}),E&&e.push({key:`on_print_failed`,label:n(`notifications.failed`)}),O&&e.push({key:`on_print_stopped`,label:n(`notifications.stopped`)}),A&&e.push({key:`on_print_progress`,label:n(`notifications.progress`)}),ie&&e.push({key:`on_bed_cooled`,label:n(`notifications.bedCooled`)}),ae&&e.push({key:`on_first_layer_complete`,label:n(`notifications.firstLayerCompleteLabel`)}),M&&e.push({key:`on_printer_offline`,label:n(`notifications.offline`)}),P&&e.push({key:`on_printer_error`,label:n(`notifications.error`)}),I&&e.push({key:`on_ai_failure_detection`,label:n(`notifications.aiFailureDetection`)}),R&&e.push({key:`on_filament_low`,label:n(`notifications.lowFilament`)}),B&&e.push({key:`on_maintenance_due`,label:n(`notifications.maintenance`)}),ee&&e.push({key:`on_stock_reorder_alert`,label:n(`notifications.stockReorderAlert`)}),ne&&e.push({key:`on_stock_break_alert`,label:n(`notifications.stockBreakAlert`)}),e.length===0?null:(0,K.jsxs)(`div`,{className:`space-y-2 p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase tracking-wide mb-1`,children:n(`notifications.eventPriority.sectionTitle`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:n(`notifications.eventPriority.helpNtfy`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.label}),(0,K.jsxs)(`select`,{value:ce[e.key]??3,onChange:t=>{let n=Number(t.target.value);le(t=>({...t,[e.key]:n}))},className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:1,children:n(`notifications.eventPriority.min`)}),(0,K.jsx)(`option`,{value:2,children:n(`notifications.eventPriority.low`)}),(0,K.jsx)(`option`,{value:3,children:n(`notifications.eventPriority.default`)}),(0,K.jsx)(`option`,{value:4,children:n(`notifications.eventPriority.high`)}),(0,K.jsx)(`option`,{value:5,children:n(`notifications.eventPriority.urgent`)})]})]},e.key))})]})})()]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`notifications.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:ye,className:`flex-1`,children:[ye?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),n(i?`notifications.save`:`notifications.add`)]})]})]})]})})}function KVe({template:e,onClose:t}){let{t:n}=W(),r=no(),i=(0,y.useRef)(null),[a,o]=(0,y.useState)(e.title_template),[s,c]=(0,y.useState)(e.body_template),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!0),{data:p}=q({queryKey:[`template-variables`],queryFn:Q.getTemplateVariables}),m=p?.find(t=>t.event_type===e.event_type),{data:h,isLoading:g}=q({queryKey:[`template-preview`,e.event_type,a,s],queryFn:()=>Q.previewTemplate({event_type:e.event_type,title_template:a,body_template:s}),enabled:d&&a.length>0&&s.length>0});(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let _=J({mutationFn:t=>Q.updateNotificationTemplate(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`notification-templates`]}),t()},onError:e=>{u(e.message)}}),v=J({mutationFn:()=>Q.resetNotificationTemplate(e.id),onSuccess:e=>{o(e.title_template),c(e.body_template),r.invalidateQueries({queryKey:[`notification-templates`]})},onError:e=>{u(e.message)}}),b=e=>{if(e.preventDefault(),u(null),!a.trim()){u(n(`notifications.titleRequired`));return}if(!s.trim()){u(n(`notifications.bodyRequired`));return}_.mutate({title_template:a,body_template:s})},x=e=>{let t=i.current;if(!t)return;let n=t.selectionStart,r=t.selectionEnd,a=s,o=a.substring(0,n),l=a.substring(r);c(o+`{${e}}`+l),setTimeout(()=>{t.focus();let r=n+e.length+2;t.setSelectionRange(r,r)},0)},S=a!==e.title_template||s!==e.body_template;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`notifications.editTemplate`,{name:e.name})}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark-tertiary rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`form`,{onSubmit:b,className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[l&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm`,children:l}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:n(`notifications.titleLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green`,placeholder:n(`notifications.titlePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:n(`notifications.bodyLabel`)}),(0,K.jsx)(`textarea`,{ref:i,value:s,onChange:e=>c(e.target.value),rows:4,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none`,placeholder:n(`notifications.bodyPlaceholder`)})]}),m&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-2`,children:n(`notifications.availableVariables`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.variables.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>x(e),className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark hover:bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,K.jsx)(Sl,{className:`w-3 h-3`}),e]},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:n(`notifications.clickToInsert`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm font-medium text-bambu-gray flex items-center gap-2`,children:[(0,K.jsx)(Xs,{className:`w-4 h-4`}),n(`notifications.livePreview`)]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>f(!d),className:`text-xs text-bambu-green hover:text-bambu-green-light`,children:n(d?`notifications.hide`:`notifications.show`)})]}),d&&(0,K.jsx)(`div`,{className:`bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2`,children:g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`notifications.loadingPreview`)]}):h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.titlePreview`)}),(0,K.jsx)(`div`,{className:`text-white font-medium`,children:h.title})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n(`notifications.bodyPreview`)}),(0,K.jsx)(`div`,{className:`text-white whitespace-pre-wrap text-sm`,children:h.body})]})]}):(0,K.jsx)(`div`,{className:`text-bambu-gray text-sm`,children:n(`notifications.enterTemplateContent`)})})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0`,children:[(0,K.jsxs)($,{type:`button`,variant:`ghost`,onClick:()=>v.mutate(),disabled:v.isPending,className:`text-orange-400 hover:text-orange-300`,children:[v.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Al,{className:`w-4 h-4 mr-2`}),n(`notifications.resetToDefault`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:n(`notifications.cancel`)}),(0,K.jsxs)($,{onClick:b,disabled:_.isPending||!S,children:[_.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Nl,{className:`w-4 h-4 mr-2`}),n(`notifications.save`)]})]})]})]})})}var qVe={print_start:`text-blue-400`,print_complete:`text-bambu-green`,print_failed:`text-red-400`,print_stopped:`text-orange-400`,print_progress:`text-yellow-400`,printer_offline:`text-gray-400`,printer_error:`text-rose-400`,filament_low:`text-cyan-400`,maintenance_due:`text-purple-400`,test:`text-bambu-gray`};function JVe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(7),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),{data:u}=q({queryKey:[`settings`],queryFn:Q.getSettings}),d=u?.time_format||`system`,{data:f,isLoading:p,refetch:m,isRefetching:h}=q({queryKey:[`notification-logs`,i,c],queryFn:()=>Q.getNotificationLogs({days:i,limit:100,success:c?!1:void 0})}),{data:g}=q({queryKey:[`notification-log-stats`,i],queryFn:()=>Q.getNotificationLogStats(i)}),_=J({mutationFn:()=>Q.clearNotificationLogs(30),onSuccess:e=>{r(e.message,`success`),n.invalidateQueries({queryKey:[`notification-logs`]}),n.invalidateQueries({queryKey:[`notification-log-stats`]})},onError:e=>{r(`Failed to clear logs: ${e.message}`,`error`)}}),v=e=>{let n=vf(e);if(!n)return``;let r=new Date().getTime()-n.getTime();return r<6e4?t(`notifications.justNow`):r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:n.toLocaleDateString()+` `+xf(n,d)};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg w-full max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:t(`notifications.notificationLog`)})]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white transition-colors`,children:`×`})]}),g&&(0,K.jsx)(`div`,{className:`px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-6 text-sm`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[t(`notifications.statsSummary`,{days:i}),` `,(0,K.jsx)(`span`,{className:`text-white font-medium`,children:g.total}),` `,t(`notifications.statsNotifications`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,K.jsx)(ps,{className:`w-4 h-4`}),t(`notifications.statsSent`,{count:g.success_count})]}),g.failure_count>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-4 h-4`}),t(`notifications.statsFailed`,{count:g.failure_count})]})]})}),(0,K.jsxs)(`div`,{className:`px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4`,children:[(0,K.jsxs)(`select`,{value:i,onChange:e=>a(Number(e.target.value)),className:`px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green`,children:[(0,K.jsx)(`option`,{value:1,children:t(`notifications.last24Hours`)}),(0,K.jsx)(`option`,{value:7,children:t(`notifications.last7Days`)}),(0,K.jsx)(`option`,{value:30,children:t(`notifications.last30Days`)}),(0,K.jsx)(`option`,{value:90,children:t(`notifications.last90Days`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),t(`notifications.showFailedOnly`)]}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>m(),disabled:h,children:[h?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),t(`notifications.refresh`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>_.mutate(),disabled:_.isPending,className:`text-red-400 hover:text-red-300`,children:[_.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),t(`notifications.clearOld`)]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:p?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):f&&f.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:f.map(e=>(0,K.jsx)(YVe,{log:e,isExpanded:o===e.id,onToggle:()=>s(o===e.id?null:e.id),formatDate:v,formatFullDate:e=>bf(e,d)},e.id))}):(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(kc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:t(c?`notifications.noFailedNotifications`:`notifications.noNotificationsLogged`)})]})})]})})}function YVe({log:e,isExpanded:t,onToggle:n,formatDate:r,formatFullDate:i}){let{t:a}=W();return(0,K.jsxs)(`div`,{className:`border rounded-lg overflow-hidden transition-colors ${e.success?`border-bambu-dark-tertiary bg-bambu-dark/30`:`border-red-500/30 bg-red-500/5`}`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 flex items-center gap-3 text-left hover:bg-bambu-dark/50 transition-colors`,onClick:n,children:[e.success?(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green shrink-0`}):(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium ${qVe[e.event_type]||`text-bambu-gray`}`,children:a(`notifications.eventTypes.${e.event_type}`,e.event_type)}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate flex-1`,children:e.provider_name||a(`notifications.unknownProvider`)}),e.printer_name&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.printer_name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:r(e.created_at)}),t?(0,K.jsx)(cs,{className:`w-4 h-4 text-bambu-gray shrink-0`}):(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0`})]}),t&&(0,K.jsxs)(`div`,{className:`px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:a(`notifications.logTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.title})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:a(`notifications.logMessage`)}),(0,K.jsx)(`p`,{className:`text-sm text-white whitespace-pre-wrap`,children:e.message})]}),!e.success&&e.error_message&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-red-400 mb-1`,children:a(`notifications.logError`)}),(0,K.jsx)(`p`,{className:`text-sm text-red-300`,children:e.error_message})]}),(0,K.jsxs)(`div`,{className:`flex gap-4 text-xs text-bambu-gray pt-1`,children:[(0,K.jsx)(`span`,{children:a(`notifications.logProvider`,{type:e.provider_type})}),(0,K.jsx)(`span`,{children:a(`notifications.logTime`,{time:i(e.created_at)})})]})]})]})}var XVe=Object.defineProperty,v3=Object.getOwnPropertySymbols,y3=Object.prototype.hasOwnProperty,b3=Object.prototype.propertyIsEnumerable,x3=(e,t,n)=>t in e?XVe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,S3=(e,t)=>{for(var n in t||={})y3.call(t,n)&&x3(e,n,t[n]);if(v3)for(var n of v3(t))b3.call(t,n)&&x3(e,n,t[n]);return e},C3=(e,t)=>{var n={};for(var r in e)y3.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&v3)for(var r of v3(e))t.indexOf(r)<0&&b3.call(e,r)&&(n[r]=e[r]);return n},w3;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],et.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.lengthm[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;ne+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.lengtht.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e=1<{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(w3||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(w3||={});var T3=w3,ZVe={L:T3.QrCode.Ecc.LOW,M:T3.QrCode.Ecc.MEDIUM,Q:T3.QrCode.Ecc.QUARTILE,H:T3.QrCode.Ecc.HIGH},E3=128,D3=`L`,O3=`#FFFFFF`,k3=`#000000`,A3=!1,j3=1,QVe=4,$Ve=0,eHe=.1;function M3(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function N3(e,t){return e.slice().map((e,n)=>n=t.y+t.h?e:e.map((e,n)=>n=t.x+t.w?e:!1))}function tHe(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*eHe),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function nHe(e,t){return t==null?e?QVe:$Ve:Math.max(Math.floor(t),0)}function P3({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=y.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...T3.QrSegment.makeSegments(t)),e),[]);return T3.QrCode.encodeSegments(r,ZVe[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=y.useMemo(()=>{let e=c.getModules(),t=nHe(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:tHe(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var rHe=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),iHe=y.forwardRef(function(e,t){let n=e,{value:r,size:i=E3,level:a=D3,bgColor:o=O3,fgColor:s=k3,includeMargin:c=A3,minVersion:l=j3,boostLevel:u,marginSize:d,imageSettings:f}=n,p=C3(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=C3(p,[`style`]),g=f?.src,_=y.useRef(null),v=y.useRef(null),b=y.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=y.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=P3({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});y.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=v.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=N3(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,rHe?t.fill(new Path2D(M3(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),y.useEffect(()=>{S(!1)},[g]);let D=S3({height:i,width:i},m),O=null;return g!=null&&(O=y.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:v,crossOrigin:E?.crossOrigin})),y.createElement(y.Fragment,null,y.createElement(`canvas`,S3({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});iHe.displayName=`QRCodeCanvas`;var F3=y.forwardRef(function(e,t){let n=e,{value:r,size:i=E3,level:a=D3,bgColor:o=O3,fgColor:s=k3,includeMargin:c=A3,minVersion:l=j3,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=C3(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:v}=P3({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&v!=null&&(v.excavation!=null&&(b=N3(g,v.excavation)),x=y.createElement(`image`,{href:p.src,height:v.h,width:v.w,x:v.x+h,y:v.y+h,preserveAspectRatio:`none`,opacity:v.opacity,crossOrigin:v.crossOrigin}));let S=M3(b,h);return y.createElement(`svg`,S3({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&y.createElement(`title`,null,d),y.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),y.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});F3.displayName=`QRCodeSVG`;function aHe(e,t){return`bambuddy://config?v=1&url=${encodeURIComponent(e)}&key=${encodeURIComponent(t)}`}function oHe({apiKey:e,baseUrl:t,onClose:n}){let{t:r}=W(),i=aHe(t??window.location.origin,e);return(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`settings.apiKeyQrTitle`)}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 flex flex-col items-center`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 text-center`,children:r(`settings.apiKeyQrCaption`)}),(0,K.jsx)(`div`,{className:`bg-white p-4 rounded-lg mb-4`,children:(0,K.jsx)(F3,{value:i,size:256})}),(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs text-amber-400 mb-4`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`span`,{children:r(`settings.apiKeyQrWarning`)})]}),(0,K.jsx)($,{onClick:n,className:`w-full`,children:r(`common.close`)})]})]})})}var sHe=300,I3=2;function L3({onSuccess:e}){let{t}=W(),n=no(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=r.trim();if(e.lengtho(e),sHe);return()=>clearTimeout(t)},[r]),(0,y.useEffect)(()=>{c(null),u(null)},[a]);let d=q({queryKey:[`ldap-search`,a],queryFn:()=>Q.searchLDAPDirectory(a),enabled:a.length>=I3,staleTime:3e4}),f=J({mutationFn:e=>Q.provisionLDAPUser(e),onSuccess:t=>{n.invalidateQueries({queryKey:[`users`]}),e(t)},onError:e=>{u(e.message||t(`users.modal.ldapErrorProvision`))}}),p=(0,y.useMemo)(()=>d.data?.find(e=>e.dn===s)??null,[d.data,s]),m=r.trim().length>0&&r.trim().length=I3,g=!!d.data&&d.data.length>0,_=!h&&!!d.data&&d.data.length===0&&a.length>=I3;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:t(`users.modal.ldapSearchLabel`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2`}),(0,K.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),className:`w-full pl-9 pr-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:t(`users.modal.ldapSearchPlaceholder`),autoComplete:`off`})]}),m&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:t(`users.modal.ldapMinChars`)})]}),(0,K.jsxs)(`div`,{className:`min-h-[8rem] max-h-64 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[h&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}),(0,K.jsx)(`span`,{children:t(`users.modal.ldapSearching`)})]}),_&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray text-sm`,children:t(`users.modal.ldapNoResults`)}),d.isError&&(0,K.jsx)(`div`,{className:`px-3 py-4 text-sm text-red-400`,children:d.error instanceof Error?d.error.message:t(`users.modal.ldapSearchError`)}),!h&&g&&(0,K.jsx)(`ul`,{className:`divide-y divide-bambu-dark-tertiary`,children:d.data.map(e=>(0,K.jsx)(cHe,{result:e,selected:s===e.dn,onSelect:()=>c(e.dn)},e.dn))}),!h&&!d.data&&!d.isError&&(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray text-sm`,children:t(`users.modal.ldapTypeToSearch`)})]}),p&&(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[t(`users.modal.ldapSelectedLabel`),`: `]}),(0,K.jsx)(`span`,{className:`font-medium`,children:p.username}),p.display_name&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` — `,p.display_name]})]}),p.email&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:p.email}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray break-all`,children:p.dn})]}),l&&(0,K.jsx)(`div`,{className:`bg-red-500/10 border border-red-500/30 rounded-lg p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-red-400`,children:l})}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)($,{onClick:()=>{!p||p.already_provisioned||(u(null),f.mutate(p.username))},disabled:!p||p.already_provisioned||f.isPending,children:f.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),t(`users.modal.ldapProvisioning`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),t(`users.modal.ldapProvision`)]})})})]})}function cHe({result:e,selected:t,onSelect:n}){let{t:r}=W(),i=e.already_provisioned;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:n,disabled:i,className:`w-full text-left px-3 py-2 flex items-center gap-3 transition-colors ${i?`opacity-50 cursor-not-allowed`:t?`bg-bambu-green/10`:`hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm text-white truncate`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:e.username}),e.display_name&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` — `,e.display_name]})]}),e.email&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.email})]}),i&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray whitespace-nowrap`,children:[(0,K.jsx)(ms,{className:`w-3.5 h-3.5`}),r(`users.modal.ldapAlreadyProvisioned`)]})]})})}function lHe({formData:e,setFormData:t,groups:n,onClose:r,onCreate:i,isCreating:a,isCreateButtonDisabled:o,ldapEnabled:s=!1,onLdapProvisioned:c}){let{t:l}=W(),[u,d]=(0,y.useState)(`local`);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let f=n=>{t({...e,group_ids:e.group_ids.includes(n)?e.group_ids.filter(e=>e!==n):[...e.group_ids,n]})};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:r,children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:l(`users.modal.createUser`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray ml-7`,children:l(`users.modal.advancedAuthSubtitle`)||`with Advanced Authentication`})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:r,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[s&&(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-1 p-1 bg-bambu-dark-secondary rounded-lg`,role:`tablist`,"aria-label":l(`users.modal.tabsAriaLabel`),children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`local`,onClick:()=>d(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${u===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:l(`users.modal.localTab`)}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":u===`ldap`,onClick:()=>d(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${u===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:l(`users.modal.ldapTab`)})]}),u===`ldap`&&s?(0,K.jsx)(L3,{onSuccess:e=>{c?.(e)}}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[l(`users.form.username`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:e.username,onChange:n=>t({...e,username:n.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:l(`users.form.usernamePlaceholder`),autoComplete:`username`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[l(`users.form.email`)||`Email`,` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`email`,value:e.email,onChange:n=>t({...e,email:n.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:l(`users.form.emailPlaceholder`)||`user@example.com`,required:!0})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:l(`users.form.autoGeneratedPassword`)||`A secure password will be automatically generated and emailed to the user.`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:l(`users.form.groups`)}),(0,K.jsxs)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[n.map(t=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.group_ids.includes(t.id),onChange:()=>f(t.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:t.name}),t.is_system&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400`,children:[`(`,l(`users.system`),`)`]})]},t.id)),n.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:l(`users.noGroupsAvailable`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:r,children:l(`users.modal.cancel`)}),u===`local`&&(0,K.jsx)($,{onClick:i,disabled:o,children:a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),l(`users.modal.creating`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),l(`users.modal.createUser`)]})})]})]})]})})}function uHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`auto`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!0),[p,m]=(0,y.useState)(!0),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),{data:E,isLoading:D}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings}),{data:O,isLoading:k,refetch:A}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,refetchInterval:3e4}),{data:j}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{E&&(i(E.spoolman_enabled===`true`),o(E.spoolman_url||``),c(E.spoolman_sync_mode||`auto`),u(E.spoolman_disable_weight_sync===`true`),f(E.spoolman_report_partial_usage!==`false`),m(E.auto_add_unknown_rfid!==`false`),v(!0))},[E]),(0,y.useEffect)(()=>{if(!(!_||!E)&&(E.spoolman_enabled===`true`!==r||(E.spoolman_url||``)!==a||(E.spoolman_sync_mode||`auto`)!==s||E.spoolman_disable_weight_sync===`true`!==l||E.spoolman_report_partial_usage!==`false`!==d||E.auto_add_unknown_rfid!==`false`!==p)){let e=setTimeout(()=>{M.mutate()},500);return()=>clearTimeout(e)}},[r,a,s,l,d,p,_]);let M=J({mutationFn:()=>Q.updateSpoolmanSettings({spoolman_enabled:r?`true`:`false`,spoolman_url:a,spoolman_sync_mode:s,spoolman_disable_weight_sync:l?`true`:`false`,spoolman_report_partial_usage:d?`true`:`false`,auto_add_unknown_rfid:p?`true`:`false`}),onSuccess:()=>{t.invalidateQueries({queryKey:[`spoolman-settings`]}),t.invalidateQueries({queryKey:[`spoolman-status`]}),t.invalidateQueries({queryKey:[`spool-assignments`]}),t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`spoolman-inventory-filaments`]}),n(e(`settings.toast.settingsSaved`))},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),N=J({mutationFn:Q.connectSpoolman,onSuccess:()=>{A()},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),P=J({mutationFn:Q.disconnectSpoolman,onSuccess:()=>{A()},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),F=J({mutationFn:Q.syncAllPrintersAms,onSuccess:t=>{n(e(`settings.spoolmanAmsSyncSuccess`,{synced:t.synced_count,skipped:0}),`success`)},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),I=J({mutationFn:e=>Q.syncPrinterAms(e),onSuccess:t=>{n(e(`settings.spoolmanAmsSyncSuccess`,{synced:t.synced_count,skipped:0}),`success`)},onError:()=>{n(e(`settings.toast.saveFailed`),`error`)}}),L=()=>{h===`all`?F.mutate():I.mutate(h)},R=J({mutationFn:Q.syncWeightsFromAms,onSuccess:r=>{t.invalidateQueries({queryKey:[`spools`]}),t.invalidateQueries({queryKey:[`inventory-spools`]}),n(e(`settings.amsSyncSuccess`,{synced:r.synced,skipped:r.skipped}),`success`),C(!1)},onError:()=>{n(e(`settings.amsSyncError`),`error`),C(!1)}}),z=J({mutationFn:Q.syncSpoolmanAmsWeights,onSuccess:r=>{t.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),n(e(`settings.spoolmanAmsSyncSuccess`,{synced:r.synced,skipped:r.skipped}),`success`),T(!1)},onError:t=>{t instanceof Uu&&t.status===503?n(e(`settings.spoolmanAmsSyncErrorUnreachable`),`error`):t instanceof Uu&&t.status===400?n(e(`settings.spoolmanAmsSyncErrorNotConfigured`),`error`):n(e(`settings.spoolmanAmsSyncError`),`error`),T(!1)}}),B=F.isPending||I.isPending,V=h===`all`?F.data:I.data,ee=h===`all`?F.isSuccess:I.isSuccess;return D?(0,K.jsxs)(_d,{id:`card-spoolman`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.filamentTracking`)})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})})})]}):(0,K.jsxs)(_d,{id:`card-spoolman`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.filamentTracking`)})]}),M.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-green animate-spin`})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.filamentTrackingDesc`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50`:`border-bambu-green bg-bambu-green/10`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 ${r?`text-bambu-gray`:`text-bambu-green`}`}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${r?`text-bambu-gray`:`text-white`}`,children:e(`settings.trackingModeBuiltIn`)})]}),(0,K.jsx)(`p`,{className:`text-xs ${r?`text-bambu-gray/60`:`text-bambu-gray`}`,children:e(`settings.trackingModeBuiltInDesc`)}),!r&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:e(`common.enabled`)})]})]}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`p-3 rounded-lg border-2 text-left transition-colors ${r?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray/50`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(Js,{className:`w-4 h-4 ${r?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${r?`text-white`:`text-bambu-gray`}`,children:`Spoolman`})]}),(0,K.jsx)(`p`,{className:`text-xs ${r?`text-bambu-gray`:`text-bambu-gray/60`}`,children:e(`settings.trackingModeSpoolmanDesc`)}),r&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-2`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:e(`common.enabled`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`pr-4`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`settings.autoAddUnknownRfid`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.autoAddUnknownRfidDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),!r&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/5 border border-bambu-green/20 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-0.5`}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:(0,K.jsxs)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:[(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureRfid`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureUsage`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureCatalog`)}),(0,K.jsx)(`li`,{children:e(`settings.builtInFeatureThirdParty`)})]})})]})}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>C(!0),disabled:R.isPending,children:[R.isPending?(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4 mr-2`}),e(`settings.amsSyncButton`)]})]}),r&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs text-blue-300`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:e(`settings.howSyncWorks`)}),(0,K.jsxs)(`ul`,{className:`list-disc list-inside space-y-0.5 text-blue-300/80`,children:[(0,K.jsx)(`li`,{children:e(`settings.syncInfoRfidOnly`)}),(0,K.jsx)(`li`,{children:e(`settings.syncInfoAutoCreate`)}),(0,K.jsx)(`li`,{children:e(`settings.syncInfoThirdPartySkipped`)})]}),(0,K.jsx)(`p`,{className:`font-medium mt-2 mb-1`,children:e(`settings.linkingExistingSpools`)}),(0,K.jsx)(`p`,{className:`text-blue-300/80`,children:e(`settings.linkingExistingSpoolsDesc`)})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`settings.spoolmanUrl`)}),(0,K.jsx)(`input`,{type:`text`,placeholder:`http://192.168.1.100:7912`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.spoolmanUrlHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`settings.syncMode`)}),(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`auto`,children:e(`settings.syncModeAuto`)}),(0,K.jsx)(`option`,{value:`manual`,children:e(`settings.syncModeManual`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(s===`auto`?`settings.syncModeAutoDesc`:`settings.syncModeManualDesc`)})]}),s===`auto`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`spoolman.disableWeightSync`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`spoolman.disableWeightSyncDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),l&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:e(`spoolman.reportPartialUsage`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`spoolman.reportPartialUsageDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`settings.status`),`:`]}),k?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin`}):O?.connected?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-green-500`,children:[(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`settings.spoolmanConnected`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-sm text-red-500`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),e(`settings.spoolmanDisconnected`)]})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:O?.connected?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>P.mutate(),disabled:P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Bc,{className:`w-4 h-4`}),e(`settings.disconnect`)]}):(0,K.jsxs)($,{size:`sm`,onClick:()=>N.mutate(),disabled:N.isPending||!a,children:[N.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vc,{className:`w-4 h-4`}),e(`settings.connect`)]})})]}),(N.isError||P.isError)&&(0,K.jsx)(`div`,{className:`mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400`,children:(N.error||P.error).message}),O?.connected&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(`settings.syncAmsData`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e(`settings.syncAmsDataDesc`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value===`all`?`all`:Number(e.target.value)),className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`settings.allPrinters`)}),j?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(is,{className:`absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:L,disabled:B,children:[B?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`spoolman.sync`)]})]})]}),O?.connected&&(0,K.jsx)(`div`,{className:`mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e(`settings.spoolmanAmsSyncButton`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:e(`settings.spoolmanAmsSyncMessage`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>T(!0),disabled:z.isPending,children:[z.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),z.isPending?e(`settings.spoolmanAmsSyncing`):e(`settings.spoolmanAmsSyncButton`)]})]})}),ee&&V&&(0,K.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded text-sm ${V.success?`bg-green-500/20 border border-green-500/50 text-green-400`:`bg-yellow-500/20 border border-yellow-500/50 text-yellow-400`}`,children:V.success?`Synced ${V.synced_count} spool${V.synced_count===1?``:`s`} successfully`:`Synced ${V.synced_count} spool${V.synced_count===1?``:`s`} with ${V.errors.length} error${V.errors.length===1?``:`s`}`}),V.skipped_count>0&&(0,K.jsxs)(`div`,{className:`p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-amber-400 mb-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[V.skipped_count,` spool`,V.skipped_count===1?``:`s`,` skipped`]})]}),V.skipped_count>5&&(0,K.jsx)(`button`,{onClick:()=>x(!b),className:`text-xs text-amber-400 hover:text-amber-300 underline`,children:b?`Show less`:`Show all`})]}),(0,K.jsxs)(`ul`,{className:`text-xs text-amber-300/80 space-y-0.5`,children:[(b?V.skipped:V.skipped.slice(0,5)).map((e,t)=>(0,K.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.color&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:`#${e.color}`}}),(0,K.jsx)(`span`,{children:e.location}),(0,K.jsxs)(`span`,{className:`text-amber-300/60`,children:[`- `,e.reason]})]},t)),!b&&V.skipped_count>5&&(0,K.jsxs)(`li`,{className:`text-amber-300/60 italic`,children:[`...and `,V.skipped_count-5,` more`]})]})]}),V.errors.length>0&&(0,K.jsxs)(`div`,{className:`p-2 bg-red-500/10 border border-red-500/30 rounded text-sm`,children:[(0,K.jsx)(`div`,{className:`text-red-400 font-medium mb-1`,children:`Errors:`}),(0,K.jsx)(`ul`,{className:`text-xs text-red-300/80 space-y-0.5`,children:V.errors.map((e,t)=>(0,K.jsx)(`li`,{children:e},t))})]})]})]})]})]}),S&&(0,K.jsx)(Ad,{title:e(`settings.amsSyncTitle`),message:e(`settings.amsSyncMessage`),confirmText:e(`settings.amsSyncButton`),variant:`warning`,isLoading:R.isPending,loadingText:e(`settings.amsSyncing`),onConfirm:()=>R.mutate(),onCancel:()=>C(!1)}),w&&(0,K.jsx)(Ad,{title:e(`settings.spoolmanAmsSyncTitle`),message:e(`settings.spoolmanAmsSyncMessage`),confirmText:e(`settings.spoolmanAmsSyncButton`),variant:`warning`,isLoading:z.isPending,loadingText:e(`settings.spoolmanAmsSyncing`),onConfirm:()=>z.mutate(),onCancel:()=>T(!1)})]})}function dHe(){let{t:e}=W(),{showToast:t}=Td(),[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(``),c=(0,y.useRef)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(new Set),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(!1),O=(0,y.useCallback)(async()=>{try{r(await Q.getSpoolCatalog())}catch(n){console.error(`SpoolCatalogSettings.loadCatalog failed:`,n),t(e(`settings.catalog.loadFailed`),`error`)}finally{a(!1)}},[t,e]);(0,y.useEffect)(()=>{O()},[O]);let k=n.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),A=async()=>{if(!p.trim()||!h){t(e(`settings.catalog.nameWeightRequired`),`error`);return}v(!0);try{let n=await Q.addCatalogEntry({name:p.trim(),weight:parseInt(h)});r(e=>[...e,n].sort((e,t)=>e.name.localeCompare(t.name))),u(!1),m(``),g(``),t(e(`settings.catalog.entryAdded`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleAdd failed:`,n),t(e(`settings.catalog.addFailed`),`error`)}finally{v(!1)}},j=e=>{f(e.id),m(e.name),g(e.weight.toString())},M=()=>{f(null),m(``),g(``)},N=async n=>{if(!p.trim()||!h){t(e(`settings.catalog.nameWeightRequired`),`error`);return}v(!0);try{let i=await Q.updateCatalogEntry(n,{name:p.trim(),weight:parseInt(h)});r(e=>e.map(e=>e.id===n?i:e).sort((e,t)=>e.name.localeCompare(t.name))),f(null),m(``),g(``),t(e(`settings.catalog.entryUpdated`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleUpdate failed:`,n),t(e(`settings.catalog.updateFailed`),`error`)}finally{v(!1)}},P=async()=>{if(w)try{await Q.deleteCatalogEntry(w.id),r(e=>e.filter(e=>e.id!==w.id)),t(e(`settings.catalog.entryDeleted`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleDelete failed:`,n),t(e(`settings.catalog.deleteFailed`),`error`)}finally{T(null)}},F=async()=>{D(!1),a(!0);try{await Q.resetSpoolCatalog(),await O(),t(e(`settings.catalog.resetSuccess`),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleReset failed:`,n),t(e(`settings.catalog.resetFailed`),`error`),a(!1)}},I=e=>{x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(_d,{id:`card-spool-catalog`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.catalog.spoolCatalog`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,n.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>{let r=n.map(({name:e,weight:t})=>({name:e,weight:t})),i=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`spool-catalog.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),t(e(`settings.catalog.exported`,{count:n.length}),`success`)},className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.exportTooltip`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.export`)})]}),(0,K.jsxs)(`button`,{onClick:()=>c.current?.click(),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.importTooltip`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.import`)})]}),(0,K.jsx)(`input`,{ref:c,type:`file`,accept:`.json`,className:`hidden`,onChange:async i=>{let a=i.target.files?.[0];if(a){try{let i=await a.text(),o=JSON.parse(i);if(!Array.isArray(o))throw Error(`Invalid format`);let s=0,c=0;for(let e of o){if(!e.name||typeof e.weight!=`number`){c++;continue}if(n.some(t=>t.name.toLowerCase()===e.name.toLowerCase())){c++;continue}try{let t=await Q.addCatalogEntry({name:e.name,weight:e.weight});r(e=>[...e,t].sort((e,t)=>e.name.localeCompare(t.name))),s++}catch(e){console.error(`SpoolCatalogSettings import item failed:`,e),c++}}t(e(`settings.catalog.imported`,{added:s,skipped:c}),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleImport failed:`,n),t(e(`settings.catalog.importFailed`),`error`)}c.current&&(c.current.value=``)}}}),(0,K.jsxs)(`button`,{onClick:()=>D(!0),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.catalog.resetTooltip`),children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.reset`)})]}),(0,K.jsxs)(`button`,{onClick:()=>u(!0),className:`px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.add`)})]})]}),b.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-sm text-red-400`,children:e(`settings.catalog.selectedCount`,{count:b.size})}),(0,K.jsxs)(`button`,{onClick:()=>C(!0),className:`ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.catalog.deleteSelected`)]}),(0,K.jsx)(`button`,{onClick:()=>x(new Set),className:`px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors`,children:e(`common.cancel`)})]})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.catalog.spoolCatalogDescription`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.catalog.searchCatalog`),value:o,onChange:e=>s(e.target.value)})]}),l&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e(`settings.catalog.addNewEntry`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.catalog.namePlaceholder`),value:p,onChange:e=>m(e.target.value)})}),(0,K.jsx)(`input`,{type:`number`,className:`w-20 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-center focus:border-bambu-green focus:outline-none`,placeholder:`g`,value:h,onChange:e=>g(e.target.value)}),(0,K.jsx)(`span`,{className:`text-bambu-gray shrink-0`,children:`g`}),(0,K.jsxs)(`button`,{onClick:A,disabled:_,className:`px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center gap-1 shrink-0`,children:[_?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`common.add`)]}),(0,K.jsx)(`button`,{onClick:()=>{u(!1),m(``),g(``)},className:`p-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),i?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),e(`common.loading`)]}):(0,K.jsx)(`div`,{className:`max-h-[600px] overflow-y-auto border border-bambu-dark-tertiary rounded-lg`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-2 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:k.length>0&&b.size===k.length,onChange:()=>{b.size===k.length?x(new Set):x(new Set(k.map(e=>e.id)))},className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-bambu-gray font-medium`,children:e(`common.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-right text-bambu-gray font-medium w-24`,children:e(`settings.catalog.weight`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-center text-bambu-gray font-medium w-20`,children:e(`settings.catalog.type`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 w-24`})]})}),(0,K.jsx)(`tbody`,{children:k.length===0?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:5,className:`px-4 py-8 text-center text-bambu-gray`,children:e(o?`settings.catalog.noMatch`:`settings.catalog.empty`)})}):k.map(t=>(0,K.jsx)(`tr`,{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${b.has(t.id)?`bg-bambu-dark`:``}`,children:d===t.id?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>I(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white focus:border-bambu-green focus:outline-none`,value:p,onChange:e=>m(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsx)(`input`,{type:`number`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-right focus:border-bambu-green focus:outline-none`,value:h,onChange:e=>g(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-center`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`-`})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>N(t.id),disabled:_,className:`p-1.5 rounded hover:bg-green-500/20 text-green-500`,children:_?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:M,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:b.has(t.id),onChange:()=>I(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-white`,children:t.name}),(0,K.jsxs)(`td`,{className:`px-4 py-2 text-right font-mono text-white`,children:[t.weight,`g`]}),(0,K.jsx)(`td`,{className:`px-4 py-2 text-center`,children:t.is_default?(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray`,children:e(`settings.catalog.default`)}):(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:e(`settings.catalog.custom`)})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>j(t),className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>T(t),className:`p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})},t.id))})]})})]}),w&&(0,K.jsx)(Ad,{title:e(`settings.catalog.deleteEntry`),message:e(`settings.catalog.deleteConfirm`,{name:w.name}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:P,onCancel:()=>T(null)}),S&&(0,K.jsx)(Ad,{title:e(`settings.catalog.deleteSelected`),message:e(`settings.catalog.bulkDeleteConfirm`,{count:b.size}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:async()=>{if(C(!1),b.size!==0)try{let n=await Q.bulkDeleteCatalogEntries([...b]);r(e=>e.filter(e=>!b.has(e.id))),x(new Set),t(e(`settings.catalog.bulkDeleted`,{count:n.deleted}),`success`)}catch(n){console.error(`SpoolCatalogSettings.handleBulkDelete failed:`,n),t(e(`settings.catalog.bulkDeleteFailed`),`error`)}},onCancel:()=>C(!1)}),E&&(0,K.jsx)(Ad,{title:e(`settings.catalog.resetCatalog`),message:e(`settings.catalog.resetConfirm`),confirmText:e(`common.reset`),variant:`danger`,onConfirm:F,onCancel:()=>D(!1)})]})}var fHe=2166136261,pHe=16777619;function mHe(...e){let t=fHe,n=new TextEncoder,r=n.encode(`__|`);for(let i of e)typeof i==`string`?t=R3(t,n.encode(i+`|`)):i??(t=R3(t,r));return t>>>0}function R3(e,t){for(let n of t)e^=n,e=Math.imul(e,pHe)>>>0;return e}function hHe(e){let t=()=>{e|=0,e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,(t^t>>>14)>>>0},n=(e,n)=>{if(!Number.isFinite(e)||!Number.isFinite(n))throw RangeError(`from and to must be finite numbers`);if(e>n)throw RangeError(`from must be less than or equal to to`);return e===n?e:e+t()/4294967295*(n-e)};return{next:()=>t()/4294967295,floatBetween:(e,t)=>n(e,t),intBetween:(e,t)=>{if(!Number.isInteger(e)||!Number.isInteger(t))throw RangeError(`from and to must be integers`);return Math.round(n(e,t))}}}var z3={table:{dotCount:5,dotScale:1},preview:{dotCount:8,dotScale:1.5},card:{dotCount:40,dotScale:2},bar:{dotCount:20,dotScale:2},groupheader:{dotCount:80,dotScale:2}},B3=[{value:``,labelKey:`inventory.colorEffect.none`},{value:`sparkle`,labelKey:`inventory.colorEffect.sparkle`},{value:`wood`,labelKey:`inventory.colorEffect.wood`},{value:`marble`,labelKey:`inventory.colorEffect.marble`},{value:`glow`,labelKey:`inventory.colorEffect.glow`},{value:`matte`,labelKey:`inventory.colorEffect.matte`},{value:`silk`,labelKey:`inventory.colorEffect.silk`},{value:`galaxy`,labelKey:`inventory.colorEffect.galaxy`},{value:`rainbow`,labelKey:`inventory.colorEffect.rainbow`},{value:`metal`,labelKey:`inventory.colorEffect.metal`},{value:`translucent`,labelKey:`inventory.colorEffect.translucent`},{value:`gradient`,labelKey:`inventory.colorEffect.gradient`},{value:`dual-color`,labelKey:`inventory.colorEffect.dualColor`},{value:`tri-color`,labelKey:`inventory.colorEffect.triColor`},{value:`multicolor`,labelKey:`inventory.colorEffect.multicolor`}],gHe=`repeating-conic-gradient(#979797 0% 25%, #f5f5f5 0% 50%)`,_He=`12px 12px`,vHe={sparkle:(e=0,t=`table`)=>{let n=hHe(e),r=z3[t]??z3.table,i=[];for(let e=0;e`repeating-linear-gradient(90deg, rgba(0,0,0,0.18) 0 1px, transparent 1px 6px, rgba(0,0,0,0.08) 6px 7px, transparent 7px 12px)`,marble:()=>`repeating-linear-gradient(135deg, rgba(255,255,255,0.18) 0 2px, transparent 2px 8px), repeating-linear-gradient(45deg, rgba(0,0,0,0.10) 0 1px, transparent 1px 7px)`,glow:()=>`radial-gradient(circle at 50% 50%, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 70%)`,matte:()=>`linear-gradient(180deg, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.10) 100%)`,silk:()=>`linear-gradient(110deg, rgba(255,255,255,0) 30%, rgba(255,255,255,0.30) 50%, rgba(255,255,255,0) 70%)`,galaxy:()=>`linear-gradient(110deg, rgba(255,255,255,0) 25%, rgba(255,255,255,0.40) 50%, rgba(255,255,255,0) 75%)`,metal:()=>`repeating-linear-gradient(90deg, rgba(255,255,255,0.10) 0 1px, transparent 1px 3px), linear-gradient(180deg, rgba(255,255,255,0.18) 0%, rgba(0,0,0,0.18) 100%)`};function V3(e){let t=e.trim().replace(/^#/,``);return t.length!==6&&t.length!==8||!/^[0-9a-fA-F]+$/.test(t)?null:`#${t}`}function H3(e){return e?e.split(`,`).map(e=>V3(e)).filter(e=>!!e):[]}function yHe(e,t,n,r){let i=e?V3(e):null;if(t.length===0)return`linear-gradient(${i??`#808080`}, ${i??`#808080`})`;let a=t.length===1?[t[0],t[0]]:t,o=(n??``).toLowerCase(),s=(r??``).toLowerCase();if(o===`multicolor`||s===`multicolor`){let e=a.length;return`conic-gradient(from 0deg, ${a.map((t,n)=>`${t} ${(n/e*360).toFixed(3)}deg ${((n+1)/e*360).toFixed(3)}deg`).join(`, `)})`}if(s===`dual-color`||s===`tri-color`){let e=a.length;return`linear-gradient(to right, ${a.map((t,n)=>`${t} ${(n/e*100).toFixed(3)}% ${((n+1)/e*100).toFixed(3)}%`).join(`, `)})`}return`linear-gradient(135deg, ${a.join(`, `)})`}function bHe(e,t,n){let r=vHe[e];return r?r(n,t):null}function U3(e){let t=H3(e.extraColors),n=yHe(e.rgba,t,e.subtype,e.effectType),r=mHe(e.rgba,e.extraColors,e.subtype,e.effectType),i=typeof e.effectType==`string`?bHe(e.effectType,e.effectSize,r):null,a=[];return i&&(Array.isArray(i)?i:[i]).forEach(e=>{a.push({image:e,size:`cover`})}),a.push({image:n,size:`cover`}),a.push({image:gHe,size:_He}),{backgroundImage:a.map(e=>e.image).join(`, `),backgroundSize:a.map(e=>e.size).join(`, `)}}function W3({rgba:e,extraColors:t,effectType:n,subtype:r,className:i=`w-5 h-5`,shape:a=`circle`,style:o,title:s,effectSize:c}){let l=(0,y.useMemo)(()=>H3(t),[t]),u=(0,y.useMemo)(()=>U3({effectSize:c,rgba:e,extraColors:t,effectType:n,subtype:r}),[c,e,t,n,r]),d=u.backgroundImage,f=u.backgroundSize,p=a===`circle`||a===`pill`?`rounded-full`:`rounded`,m=(()=>{if(!e)return;let t=e.replace(/^#/,``);return t.length>=8&&t.substring(6,8).toLowerCase()!==`ff`?`#${t.substring(0,8)}`:`#${t.substring(0,6)}`})(),h=s??(l.length>0?l.join(`, `):m);return(0,K.jsx)(`span`,{"data-testid":`filament-swatch`,className:`${i} ${p} border border-black/20 inline-block flex-shrink-0`,style:{backgroundImage:d,backgroundSize:f,...o},title:h})}function xHe(){let{t:e}=W(),{showToast:t}=Td(),[n,r]=(0,y.useState)([]),[i,a]=(0,y.useState)(!0),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),u=(0,y.useRef)(null),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)(`#FFFFFF`),[S,C]=(0,y.useState)(``),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(new Set),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(!1),ee=(0,y.useCallback)(async()=>{try{r(await Q.getColorCatalog())}catch{t(e(`settings.colorCatalog.loadFailed`),`error`)}finally{a(!1)}},[t,e]);(0,y.useEffect)(()=>{ee()},[ee]);let te=[...new Set(n.map(e=>e.manufacturer))].sort(),ne=n.filter(e=>{let t=o===``||e.manufacturer.toLowerCase().includes(o.toLowerCase())||e.color_name.toLowerCase().includes(o.toLowerCase())||(e.material?.toLowerCase().includes(o.toLowerCase())??!1),n=c===``||e.manufacturer===c;return t&&n}),re=()=>{g(``),v(``),x(`#FFFFFF`),C(``),T(``),D(``)},ie=async()=>{if(!h.trim()||!_.trim()||!b){t(e(`settings.colorCatalog.fieldsRequired`),`error`);return}k(!0);try{let n=await Q.addColorEntry({manufacturer:h.trim(),color_name:_.trim(),hex_color:b,material:S.trim()||null,extra_colors:w.trim()||null,effect_type:E.trim()||null});r(e=>[...e,n].sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),f(!1),re(),t(e(`settings.colorCatalog.colorAdded`),`success`)}catch{t(e(`settings.colorCatalog.addFailed`),`error`)}finally{k(!1)}},H=e=>{m(e.id),g(e.manufacturer),v(e.color_name),x(e.hex_color),C(e.material||``),T(e.extra_colors||``),D(e.effect_type||``)},ae=()=>{m(null),re()},oe=async n=>{if(!h.trim()||!_.trim()||!b){t(e(`settings.colorCatalog.fieldsRequired`),`error`);return}k(!0);try{let i=await Q.updateColorEntry(n,{manufacturer:h.trim(),color_name:_.trim(),hex_color:b,material:S.trim()||null,extra_colors:w.trim()||null,effect_type:E.trim()||null});r(e=>e.map(e=>e.id===n?i:e).sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),m(null),re(),t(e(`settings.colorCatalog.colorUpdated`),`success`)}catch{t(e(`settings.colorCatalog.updateFailed`),`error`)}finally{k(!1)}},U=async()=>{if(R)try{await Q.deleteColorEntry(R.id),r(e=>e.filter(e=>e.id!==R.id)),t(e(`settings.colorCatalog.colorDeleted`),`success`)}catch{t(e(`settings.colorCatalog.deleteFailed`),`error`)}finally{z(null)}},se=async()=>{V(!1),a(!0);try{await Q.resetColorCatalog(),await ee(),t(e(`settings.colorCatalog.resetSuccess`),`success`)}catch{t(e(`settings.colorCatalog.resetFailed`),`error`),a(!1)}},ce=async()=>{F(!0),L(null);try{let n={},r=Ku();r&&(n.Authorization=`Bearer ${r}`);let i=await fetch(`/api/v1/inventory/colors/sync`,{method:`POST`,headers:n});if(!i.ok)throw Error(`Failed to start sync`);let a=i.body?.getReader();if(!a)throw Error(`No response body`);let o=new TextDecoder,s=``;for(;;){let{done:n,value:r}=await a.read();if(n)break;s+=o.decode(r,{stream:!0});let i=s.split(` +`);s=i.pop()||``;for(let n of i)if(n.startsWith(`data: `))try{let r=JSON.parse(n.slice(6));r.type===`progress`?L({fetched:r.total_fetched,total:r.total_available}):r.type===`complete`?r.added===0?t(e(`settings.colorCatalog.syncUpToDate`,{count:r.total_fetched}),`success`):t(e(`settings.colorCatalog.syncComplete`,{added:r.added,skipped:r.skipped}),`success`):r.type===`error`&&t(`${e(`settings.colorCatalog.syncError`)}: ${r.error}`,`error`)}catch{}}await ee()}catch{t(e(`settings.colorCatalog.syncFailed`),`error`)}finally{F(!1),L(null)}},le=e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(_d,{id:`card-color-catalog`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(ml,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.colorCatalog.title`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,n.length,`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>{let r=n.map(({manufacturer:e,color_name:t,hex_color:n,material:r,extra_colors:i,effect_type:a})=>({manufacturer:e,color_name:t,hex_color:n,material:r,extra_colors:i,effect_type:a})),i=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`color-catalog.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(a),t(e(`settings.colorCatalog.exported`,{count:n.length}),`success`)},className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.export`)})]}),(0,K.jsxs)(`button`,{onClick:()=>u.current?.click(),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.import`)})]}),(0,K.jsx)(`input`,{ref:u,type:`file`,accept:`.json`,className:`hidden`,onChange:async i=>{let a=i.target.files?.[0];if(a){try{let i=await a.text(),o=JSON.parse(i);if(!Array.isArray(o))throw Error(`Invalid format`);let s=0,c=0;for(let e of o){if(!e.manufacturer||!e.color_name||!e.hex_color){c++;continue}if(n.some(t=>t.manufacturer.toLowerCase()===e.manufacturer.toLowerCase()&&t.color_name.toLowerCase()===e.color_name.toLowerCase()&&(t.material||``).toLowerCase()===(e.material||``).toLowerCase())){c++;continue}try{let t=await Q.addColorEntry({manufacturer:e.manufacturer,color_name:e.color_name,hex_color:e.hex_color,material:e.material||null,extra_colors:e.extra_colors||null,effect_type:e.effect_type||null});r(e=>[...e,t].sort((e,t)=>e.manufacturer.localeCompare(t.manufacturer)||(e.material||``).localeCompare(t.material||``)||e.color_name.localeCompare(t.color_name))),s++}catch{c++}}t(e(`settings.colorCatalog.imported`,{added:s,skipped:c}),`success`)}catch{t(e(`settings.colorCatalog.importFailed`),`error`)}u.current&&(u.current.value=``)}}}),(0,K.jsxs)(`button`,{onClick:ce,disabled:P,className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,title:e(`settings.colorCatalog.syncTooltip`),children:[P?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(ws,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:P?I?`${Math.min(I.fetched,I.total)} / ${I.total}`:e(`settings.colorCatalog.starting`):e(`settings.colorCatalog.sync`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(!0),className:`px-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.reset`)})]}),(0,K.jsxs)(`button`,{onClick:()=>f(!0),className:`px-3 py-1.5 text-sm bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.add`)})]})]}),A.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-sm text-red-400`,children:e(`settings.colorCatalog.selectedCount`,{count:A.size})}),(0,K.jsxs)(`button`,{onClick:()=>N(!0),className:`ml-auto px-3 py-1.5 text-sm bg-red-500 text-white rounded-lg hover:bg-red-600 transition-colors flex items-center gap-1.5`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.colorCatalog.deleteSelected`)]}),(0,K.jsx)(`button`,{onClick:()=>j(new Set),className:`px-3 py-1.5 text-sm text-bambu-gray hover:text-white transition-colors`,children:e(`common.cancel`)})]})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`settings.colorCatalog.description`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.searchColors`),value:o,onChange:e=>s(e.target.value)})]}),(0,K.jsxs)(`select`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c,onChange:e=>l(e.target.value),children:[(0,K.jsx)(`option`,{value:``,children:e(`settings.colorCatalog.allManufacturers`)}),te.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]})]}),d&&(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e(`settings.colorCatalog.addNewColor`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-2 items-end`,children:[(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.manufacturer`),value:h,onChange:e=>g(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.colorName`),value:_,onChange:e=>v(e.target.value)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`color`,className:`w-20 h-10 rounded cursor-pointer border border-bambu-dark-tertiary`,value:b,onChange:e=>x(e.target.value)}),(0,K.jsx)(`input`,{type:`text`,className:`w-32 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:`#FFFFFF`,value:b,onChange:e=>x(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`text`,className:`flex-1 max-w-lg min-w-[200px] px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`settings.colorCatalog.materialOptional`),value:S,onChange:e=>C(e.target.value)}),(0,K.jsxs)(`button`,{onClick:ie,disabled:O,className:`w-24 px-3 py-2 bg-bambu-green text-white rounded-lg hover:bg-bambu-green/80 flex items-center justify-center gap-3`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),e(`common.add`)]}),(0,K.jsx)(`button`,{onClick:()=>{f(!1),re()},className:`p-2 ml-2 rounded-lg text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 mt-2`,children:[(0,K.jsx)(`input`,{type:`text`,className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder-bambu-gray focus:border-bambu-green focus:outline-none`,placeholder:e(`inventory.extraColorsPlaceholder`),value:w,onChange:e=>T(e.target.value)}),(0,K.jsx)(`select`,{className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,value:E,onChange:e=>D(e.target.value),children:B3.map(t=>(0,K.jsx)(`option`,{value:t.value,children:e(t.labelKey)},t.value||`none`))})]})]}),(o||c)&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:e(`settings.colorCatalog.showing`,{filtered:ne.length,total:n.length})}),i?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),e(`common.loading`)]}):(0,K.jsx)(`div`,{className:`max-h-[600px] overflow-auto border border-bambu-dark-tertiary rounded-lg`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-2 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:ne.length>0&&A.size===ne.length,onChange:()=>{A.size===ne.length?j(new Set):j(new Set(ne.map(e=>e.id)))},className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium w-12`}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`settings.colorCatalog.manufacturer`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`inventory.material`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium`,children:e(`settings.colorCatalog.colorName`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 text-left text-bambu-gray font-medium w-24`,children:e(`settings.colorCatalog.hex`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 w-16`})]})}),(0,K.jsx)(`tbody`,{children:ne.length===0?(0,K.jsx)(`tr`,{children:(0,K.jsx)(`td`,{colSpan:7,className:`px-3 py-8 text-center text-bambu-gray`,children:e(o||c?`settings.colorCatalog.noMatch`:`settings.colorCatalog.empty`)})}):ne.map(t=>(0,K.jsxs)(y.Fragment,{children:[(0,K.jsx)(`tr`,{className:`border-t border-bambu-dark-tertiary hover:bg-bambu-dark ${A.has(t.id)?`bg-bambu-dark`:``}`,children:p===t.id?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:A.has(t.id),onChange:()=>le(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`color`,className:`w-8 h-8 rounded cursor-pointer border border-bambu-dark-tertiary`,value:b,onChange:e=>x(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:h,onChange:e=>g(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:S,onChange:e=>C(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:_,onChange:e=>v(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:b,onChange:e=>x(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>oe(t.id),disabled:O,className:`p-1.5 rounded hover:bg-green-500/20 text-green-500`,children:O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:ae,className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`td`,{className:`px-2 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:A.has(t.id),onChange:()=>le(t.id),className:`w-4 h-4 accent-bambu-green cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(W3,{rgba:t.hex_color.replace(/^#/,``)+(t.hex_color.length===7?`FF`:``),extraColors:t.extra_colors,effectType:t.effect_type,className:`w-8 h-8`,shape:`square`,title:t.hex_color,effectSize:`table`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:t.manufacturer}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-bambu-gray`,children:t.material||`-`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:t.color_name}),(0,K.jsx)(`td`,{className:`px-3 py-2 font-mono text-xs text-bambu-gray`,children:t.hex_color}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>H(t),className:`p-1.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>z(t),className:`p-1.5 rounded bg-red-500/10 hover:bg-red-500/20 text-red-500`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})}),p===t.id&&(0,K.jsxs)(`tr`,{className:`border-t border-bambu-dark-tertiary/50 bg-bambu-dark`,children:[(0,K.jsx)(`td`,{colSpan:2}),(0,K.jsx)(`td`,{className:`px-3 py-2`,colSpan:2,children:(0,K.jsx)(`input`,{type:`text`,className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`,placeholder:e(`inventory.extraColorsPlaceholder`),value:w,onChange:e=>T(e.target.value)})}),(0,K.jsx)(`td`,{className:`px-3 py-2`,colSpan:2,children:(0,K.jsx)(`select`,{className:`w-full px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,value:E,onChange:e=>D(e.target.value),children:B3.map(t=>(0,K.jsx)(`option`,{value:t.value,children:e(t.labelKey)},t.value||`none`))})}),(0,K.jsx)(`td`,{})]})]},t.id))})]})})]}),R&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.deleteColor`),message:e(`settings.colorCatalog.deleteConfirm`,{name:`${R.manufacturer} - ${R.color_name}`}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:U,onCancel:()=>z(null)}),M&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.deleteSelected`),message:e(`settings.colorCatalog.bulkDeleteConfirm`,{count:A.size}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:async()=>{if(N(!1),A.size!==0)try{let n=await Q.bulkDeleteColorEntries([...A]);r(e=>e.filter(e=>!A.has(e.id))),j(new Set),t(e(`settings.colorCatalog.bulkDeleted`,{count:n.deleted}),`success`)}catch{t(e(`settings.colorCatalog.bulkDeleteFailed`),`error`)}},onCancel:()=>N(!1)}),B&&(0,K.jsx)(Ad,{title:e(`settings.colorCatalog.resetCatalog`),message:e(`settings.colorCatalog.resetConfirm`),confirmText:e(`common.reset`),variant:`danger`,onConfirm:se,onCancel:()=>V(!1)})]})}function SHe({link:e,onClose:t}){let{t:n}=W(),r=no(),i=!!e,a=(0,y.useRef)(null),[o,s]=(0,y.useState)(e?.name||``),[c,l]=(0,y.useState)(e?.url||``),[u,d]=(0,y.useState)(e?.icon||`link`),[f,p]=(0,y.useState)(e?.open_in_new_tab||!1),[m,h]=(0,y.useState)(!!e?.custom_icon),[g,_]=(0,y.useState)(e?.custom_icon?Q.getExternalLinkIconUrl(e.id):null),[v,b]=(0,y.useState)(null),[x,S]=(0,y.useState)(null);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let C=J({mutationFn:async e=>{let t=await Q.createExternalLink(e);return v?await Q.uploadExternalLinkIcon(t.id,v):t},onSuccess:()=>{r.invalidateQueries({queryKey:[`external-links`]}),t()},onError:e=>{S(e.message)}}),w=J({mutationFn:async t=>{let n=await Q.updateExternalLink(e.id,t);return v?n=await Q.uploadExternalLinkIcon(e.id,v):!m&&e?.custom_icon&&(n=await Q.deleteExternalLinkIcon(e.id)),n},onSuccess:()=>{r.invalidateQueries({queryKey:[`external-links`]}),t()},onError:e=>{S(e.message)}}),T=e=>{let t=e.target.files?.[0];if(t){if(![`image/png`,`image/jpeg`,`image/gif`,`image/svg+xml`,`image/webp`,`image/x-icon`].includes(t.type)){S(`Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)`);return}if(t.size>1024*1024){S(`Image file must be less than 1MB`);return}b(t),h(!0);let e=new FileReader;e.onload=e=>{_(e.target?.result)},e.readAsDataURL(t)}},E=()=>{b(null),_(null),h(!1),a.current&&(a.current.value=``)},D=e=>{if(e.preventDefault(),S(null),!o.trim()){S(`Name is required`);return}if(!c.trim()){S(`URL is required`);return}if(!c.startsWith(`http://`)&&!c.startsWith(`https://`)){S(`URL must start with http:// or https://`);return}let t={name:o.trim(),url:c.trim(),icon:u,open_in_new_tab:f};i?w.mutate(t):C.mutate(t)},O=C.isPending||w.isPending,k=Pd(u);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-full bg-bambu-green/20 text-bambu-green`,children:m&&g?(0,K.jsx)(`img`,{src:g,alt:``,className:`w-5 h-5 rounded`}):(0,K.jsx)(k,{className:`w-5 h-5`})}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i?`Edit Link`:`Add External Link`})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:D,className:`p-6 space-y-4`,children:[x&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400`,children:x}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Name *`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:`My Link`,maxLength:50,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`URL *`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`https://example.com`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray`,children:n(`externalLinks.openInNewTab`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>p(!f),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${f?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${f?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray`,children:`Icon`}),(0,K.jsxs)(`div`,{className:`p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:`Custom Icon`}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon`,className:`hidden`,onChange:T}),m&&g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`img`,{src:g,alt:`Custom icon`,className:`w-8 h-8 rounded border border-bambu-dark-tertiary`}),(0,K.jsx)(`button`,{type:`button`,onClick:E,className:`p-1 text-red-400 hover:text-red-300 transition-colors`,title:`Remove custom icon`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}):(0,K.jsxs)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>a.current?.click(),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),`Upload`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:`PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB.`})]}),!m&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray block mb-2`,children:`Or choose a preset icon`}),(0,K.jsx)(Fd,{value:u,onChange:d})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:`Cancel`}),(0,K.jsxs)($,{type:`submit`,disabled:O,className:`flex-1`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Nl,{className:`w-4 h-4`}),i?`Save`:`Add`]})]})]})]})})}function CHe(){let{t:e}=W(),t=no(),{authEnabled:n,hasPermission:r}=dd(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(Sp),[_,v]=(0,y.useState)(()=>bp(wp.map(e=>e.id))),{data:b,isLoading:x}=q({queryKey:[`external-links`],queryFn:Q.getExternalLinks}),S=J({mutationFn:e=>Q.deleteExternalLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`external-links`]})}}),{data:C}=q({queryKey:[`settings`],queryFn:Q.getSettings,enabled:n&&r(`settings:update`)}),w=J({mutationFn:e=>Q.updateSettings({default_sidebar_order:e}),onSuccess:(n,r)=>{t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`default-sidebar-order`]}),i(e(r?`settings.sidebarDefaultSet`:`settings.sidebarDefaultCleared`),`success`)},onError:()=>{i(e(`settings.sidebarDefaultFailed`),`error`)}}),T=(0,y.useMemo)(()=>{let e=new Map(wp.map(e=>[e.id,e])),t=new Map((b||[]).map(e=>[`ext-${e.id}`,e])),n=[],r=new Set,i=i=>{if(r.has(i))return;let a=e.get(i);if(a){n.push({type:`system`,id:i,navItem:a}),r.add(i);return}let o=t.get(i);o&&(n.push({type:`external`,id:i,link:o}),r.add(i))};return _.forEach(i),wp.forEach(e=>i(e.id)),(b||[]).forEach(e=>i(`ext-${e.id}`)),n},[b,_]),E=e=>{v(e),xp(e)},D=(e,t)=>{f(t),e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,t)},O=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`,m(t)},k=(e,t)=>{if(e.preventDefault(),d===null||d===t){f(null),m(null);return}let n=T.map(e=>e.id),r=n.indexOf(d),i=n.indexOf(t);if(r===-1||i===-1){f(null),m(null);return}n.splice(r,1),n.splice(i,0,d),E(n),f(null),m(null)},A=()=>{f(null),m(null)},j=e=>{u(e)},M=()=>{l&&(S.mutate(l.id),u(null))},N=()=>{let e=[...wp.map(e=>e.id),...(b||[]).map(e=>`ext-${e.id}`)];g([]),v(e),Cp([]),xp(e)},P=e=>{let t=T.map(e=>e.id);w.mutate(e?JSON.stringify({order:t,hiddenSystemItemIds:h}):``)},F=e=>{if(e===`settings`)return;let t=h.includes(e)?h.filter(t=>t!==e):[...h,e];g(t),Cp(t)},I=n&&r(`settings:update`),L=!!C?.default_sidebar_order;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(_d,{id:`card-sidebar-links`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-y-2 gap-x-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`externalLinks.sidebarLayout`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[I&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:e(`settings.setDefault`)}),(0,K.jsx)(lU,{checked:L,onChange:P,disabled:w.isPending})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:N,className:`whitespace-nowrap`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),e(`settings.reset`)]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>o(!0),className:`whitespace-nowrap`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),`Add Link`]})]})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`externalLinks.sidebarLayoutDescription`)}),x?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):(0,K.jsx)(`div`,{className:`space-y-2`,children:T.map(t=>{let n=t.type===`system`&&h.includes(t.id),r=t.id===`settings`;if(t.type===`system`){let i=t.navItem.icon;return(0,K.jsxs)(`div`,{draggable:!0,onDragStart:e=>D(e,t.id),onDragOver:e=>O(e,t.id),onDragLeave:()=>m(null),onDrop:e=>k(e,t.id),onDragEnd:A,className:`relative flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${d===t.id?`opacity-50`:n?`opacity-60`:``} ${p===t.id&&d!==t.id?`before:absolute before:left-3 before:right-3 before:top-0 before:h-0.5 before:bg-bambu-green`:``}`,children:[(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0`}),(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray`,children:(0,K.jsx)(i,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium truncate block`,children:e(t.navItem.labelKey)}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate block`,children:e(r?`externalLinks.requiredInSidebar`:n?`externalLinks.hiddenFromSidebar`:`externalLinks.visibleInSidebar`)})]}),(0,K.jsx)(`button`,{onClick:()=>F(t.id),disabled:r,className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent disabled:hover:text-bambu-gray`,title:e(r?`externalLinks.settingsCannotBeHidden`:n?`externalLinks.showPage`:`externalLinks.hidePage`),"aria-label":e(r?`externalLinks.settingsCannotBeHidden`:n?`externalLinks.showPage`:`externalLinks.hidePage`),children:n?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]},t.id)}let i=t.link,a=Pd(i.icon);return(0,K.jsxs)(`div`,{draggable:!0,onDragStart:e=>D(e,t.id),onDragOver:e=>O(e,t.id),onDragLeave:()=>m(null),onDrop:e=>k(e,t.id),onDragEnd:A,className:`relative flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${d===t.id?`opacity-50`:``} ${p===t.id&&d!==t.id?`before:absolute before:left-3 before:right-3 before:top-0 before:h-0.5 before:bg-bambu-green`:``}`,children:[(0,K.jsx)(xc,{className:`w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0`}),(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray`,children:i.custom_icon?(0,K.jsx)(`img`,{src:Q.getExternalLinkIconUrl(i.id),alt:``,className:`w-4 h-4`}):(0,K.jsx)(a,{className:`w-4 h-4`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium truncate`,children:i.name}),(0,K.jsx)(Js,{className:`w-3 h-3 text-bambu-gray flex-shrink-0`})]}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate block`,children:i.url})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,K.jsx)(`button`,{onClick:()=>c(i),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:e(`common.edit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>j(i),disabled:S.isPending,className:`p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50`,title:e(`externalLinks.deleteLink`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},t.id)})})]})]}),(a||s)&&(0,K.jsx)(SHe,{link:s,onClose:()=>{o(!1),c(null)}}),l&&(0,K.jsx)(Ad,{title:`Delete Link`,message:`Are you sure you want to delete "${l.name}"? This action cannot be undone.`,confirmText:`Delete`,cancelText:`Cancel`,variant:`danger`,onConfirm:M,onCancel:()=>u(null)})]})}async function G3(e){if(navigator.clipboard&&window.isSecureContext)try{return await navigator.clipboard.writeText(e),!0}catch{}let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t);try{return t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.parentNode&&t.parentNode.removeChild(t)}}function wHe(e,t,n=`text/plain`){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function THe({status:e}){return e===`pass`?(0,K.jsx)(ms,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}):e===`fail`?(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 flex-shrink-0`}):e===`warn`?(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-5 h-5 text-bambu-gray flex-shrink-0`})}function EHe({vpId:e,vpName:t,onClose:n}){let{t:r}=W(),i=J({mutationFn:()=>nd.diagnose(e)});(0,y.useEffect)(()=>{i.mutate()},[]),(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let a=i.data,o=a?.overall===`ok`?`bg-bambu-green/10 border-bambu-green/30 text-bambu-green`:a?.overall===`warnings`?`bg-amber-500/10 border-amber-500/30 text-amber-300`:`bg-red-500/10 border-red-500/30 text-red-300`;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-lg flex flex-col max-h-[85vh]`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(cu,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:r(`vpDiagnostic.title`,{name:t})})]}),(0,K.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-6 space-y-4 overflow-y-auto`,children:[i.isPending&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:r(`vpDiagnostic.running`)})]}),i.isError&&(0,K.jsx)(`div`,{className:`rounded-lg bg-red-500/10 border border-red-500/30 px-4 py-3 text-sm text-red-300`,children:r(`vpDiagnostic.runFailed`,{error:i.error.message})}),a&&(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`ol`,{className:`space-y-2`,children:a.checks.map(e=>{let t=r(`vpDiagnostic.check.${e.id}.${e.status}`,{...e.params,defaultValue:``});return(0,K.jsxs)(`li`,{className:`flex items-start gap-3 bg-bambu-dark rounded-lg px-4 py-2.5 ${e.status===`skip`?`opacity-60`:``}`,children:[(0,K.jsx)(`div`,{className:`mt-0.5`,children:(0,K.jsx)(THe,{status:e.status})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white`,children:r(`vpDiagnostic.check.${e.id}.title`,e.params)}),t&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-0.5`,children:t})]})]},e.id)})}),(0,K.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${o}`,children:r(`vpDiagnostic.overall.${a.overall}`)})]})]}),(0,K.jsxs)(`div`,{className:`px-6 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>i.mutate(),disabled:i.isPending,className:`px-4 py-2 bg-bambu-dark hover:bg-bambu-dark-tertiary disabled:opacity-50 text-white text-sm rounded-lg transition-colors`,children:r(`vpDiagnostic.retry`)}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 bg-bambu-green hover:bg-bambu-green/90 text-white text-sm rounded-lg transition-colors`,children:r(`common.close`)})]})]})})}var K3={archive:`archive`,review:`review`,queue:`queue`,proxy:`proxy`};function q3(e){return e===`immediate`?`archive`:e===`print_queue`||e===`queue`?`queue`:e===`archive`||e===`review`||e===`proxy`?e:`archive`}function DHe({printer:e,models:t}){let{t:n}=W(),r=no(),{showToast:i}=Td(),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(e.enabled),[l,u]=(0,y.useState)(e.name),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(q3(e.mode)),[h,g]=(0,y.useState)(e.target_printer_id),[_,v]=(0,y.useState)(e.bind_ip||``),[b,x]=(0,y.useState)(e.remote_interface_ip||``),[S,C]=(0,y.useState)(e.model||``),[w,T]=(0,y.useState)(e.auto_dispatch??!0),[E,D]=(0,y.useState)(e.queue_force_color_match??!1),[O,k]=(0,y.useState)(e.gcode_injection??!1),[A,j]=(0,y.useState)(e.tailscale_disabled??!0),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(!1),{data:ee}=q({queryKey:[`tailscale-status`],queryFn:nd.getTailscaleStatus,enabled:!A,staleTime:6e4}),te=ee?.available?ee.fqdn:``,ne=ee?.available?ee.tailscale_ips?.[0]??``:``,re=async e=>{e.stopPropagation();let t=te;t&&(await G3(t)?(V(!0),i(n(`printers.copied`)),setTimeout(()=>V(!1),2e3)):i(n(`virtualPrinter.toast.copyFailed`),`error`))};(0,y.useEffect)(()=>{P||(c(e.enabled),m(q3(e.mode)),u(e.name),g(e.target_printer_id),v(e.bind_ip||``),x(e.remote_interface_ip||``),C(e.model||``),T(e.auto_dispatch??!0),D(e.queue_force_color_match??!1),k(e.gcode_injection??!1),j(e.tailscale_disabled??!0))},[e,P]);let{data:ie}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:H}=q({queryKey:[`network-interfaces`],queryFn:()=>Q.getNetworkInterfaces().then(e=>e.interfaces)}),ae=J({mutationFn:t=>nd.update(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`virtual-printers`]}),i(n(`virtualPrinter.toast.updated`)),F(null)},onError:t=>{i(t.message||n(`virtualPrinter.toast.failedToUpdate`),`error`),c(e.enabled),m(q3(e.mode)),g(e.target_printer_id),v(e.bind_ip||``),j(e.tailscale_disabled??!0),F(null)}}),oe=J({mutationFn:()=>nd.remove(e.id),onSuccess:()=>{r.invalidateQueries({queryKey:[`virtual-printers`]}),i(n(`virtualPrinter.toast.deleted`)),L(!1)},onError:e=>{i(e.message||n(`virtualPrinter.toast.failedToDelete`),`error`),L(!1)}}),U=t=>{t.stopPropagation();let r=!s;if(r){if(!_){i(n(`virtualPrinter.toast.bindIpRequired`),`error`);return}if(p===`proxy`){if(!h){i(n(`virtualPrinter.toast.targetPrinterRequired`),`error`);return}}else if(!d&&!e.access_code_set){i(n(`virtualPrinter.toast.accessCodeRequired`),`error`);return}}c(r),F(`toggle`),ae.mutate({enabled:r})},se=()=>{l.trim()&&(F(`name`),ae.mutate({name:l.trim()}))},ce=()=>{if(!d){i(n(`virtualPrinter.toast.accessCodeEmpty`),`error`);return}if(d.length!==8){i(n(`virtualPrinter.toast.accessCodeLength`),`error`);return}F(`accessCode`),ae.mutate({access_code:d}),f(``)},le=e=>{m(e),F(`mode`),ae.mutate({mode:e})},ue=e=>{C(e),F(`model`),ae.mutate({model:e})},de=e=>{let t=he?.access_code,r=ie?.find(t=>t.id===e)?.access_code;g(e),F(`targetPrinter`),ae.mutate({target_printer_id:e},{onSuccess:()=>{t&&r&&t!==r&&i(n(`virtualPrinter.toast.targetCodeChangedRebind`),`info`)}})},fe=e=>{x(e),F(`remoteInterface`),ae.mutate({remote_interface_ip:e})},pe=e.status?.running||!1,me=n(`virtualPrinter.mode.${K3[p]||`archive`}`),he=ie?.find(e=>e.id===h),ge=he?.name,_e=!!h,ve=_e?he?.access_code??``:``;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(_d,{children:[(0,K.jsxs)(`div`,{className:`px-4 py-3 flex items-center gap-3 cursor-pointer select-none`,onClick:()=>o(!a),children:[(0,K.jsx)(`button`,{className:`text-bambu-gray flex-shrink-0`,children:a?(0,K.jsx)(is,{className:`w-4 h-4`}):(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0 ${pe?`bg-green-400 animate-pulse`:`bg-gray-500`}`}),(0,K.jsx)(`span`,{className:`text-white font-medium truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0`,children:me}),e.model_name&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0`,children:e.model_name}),ge&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray flex-shrink-0 truncate`,children:[p===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3 inline mr-1`}),ge]}),_&&(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray flex-shrink-0 font-mono`,children:_}),b&&(0,K.jsx)(`span`,{className:`text-[10px] text-bambu-gray flex-shrink-0 font-mono`,children:b}),(0,K.jsx)(`div`,{className:`ml-auto flex items-center gap-2 flex-shrink-0`,onClick:e=>e.stopPropagation(),children:(0,K.jsx)(`button`,{onClick:U,disabled:P===`toggle`,className:`relative w-10 h-5 rounded-full transition-colors ${s?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`toggle`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${s?`translate-x-5`:``}`})})})]}),a&&(0,K.jsxs)(yd,{className:`pt-0 space-y-4`,children:[(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),onBlur:se,onKeyDown:e=>e.key===`Enter`&&se(),className:`flex-1 text-sm text-white bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`button`,{onClick:()=>z(!0),className:`p-1.5 text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0`,title:n(`vpDiagnostic.runButton`),children:(0,K.jsx)(cu,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>L(!0),className:`p-1.5 text-bambu-gray hover:text-red-400 transition-colors flex-shrink-0`,title:n(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 -mt-2`,children:[te&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400/70 min-w-0`,children:[(0,K.jsx)(Gl,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`font-mono text-xs truncate`,children:ne?`${ne} (${te})`:te}),(0,K.jsx)(`button`,{onClick:re,className:`p-0.5 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors flex-shrink-0`,title:n(B?`printers.copied`:`printers.copyToClipboard`),children:B?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-mono ml-auto flex-shrink-0`,children:e.serial})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-2`,children:n(`virtualPrinter.mode.title`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`archive`,`review`,`queue`,`proxy`].map(e=>(0,K.jsxs)(`button`,{onClick:()=>le(e),disabled:P===`mode`,className:`p-2 rounded-lg border text-left transition-colors ${p===e?e===`proxy`?`border-blue-500 bg-blue-500/10`:`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-white text-xs font-medium`,children:[e===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3`}),n(`virtualPrinter.mode.${K3[e]}`)]}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.mode.${K3[e]}Desc`)})]},e))})]}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.autoDispatch.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.autoDispatch.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!w;T(e),F(`autoDispatch`),ae.mutate({auto_dispatch:e})},disabled:P===`autoDispatch`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${w?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`autoDispatch`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${w?`translate-x-5`:``}`})})]})}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.queueForceColorMatch.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.queueForceColorMatch.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!E;D(e),F(`queueForceColorMatch`),ae.mutate({queue_force_color_match:e})},disabled:P===`queueForceColorMatch`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${E?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`queueForceColorMatch`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${E?`translate-x-5`:``}`})})]})}),p===`queue`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.gcodeInjection.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.gcodeInjection.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!O;k(e),F(`gcodeInjection`),ae.mutate({gcode_injection:e})},disabled:P===`gcodeInjection`,className:`relative w-10 h-5 rounded-full transition-colors flex-shrink-0 ${O?`bg-bambu-green`:`bg-bambu-dark-tertiary`} ${P===`gcodeInjection`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${O?`translate-x-5`:``}`})})]})}),(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.tailscaleDisabled.title`)}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:n(`virtualPrinter.tailscaleDisabled.description`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=!A;j(e),F(`tailscaleDisabled`),ae.mutate({tailscale_disabled:e})},disabled:P===`tailscaleDisabled`,className:`relative w-10 h-5 rounded-full transition-colors shrink-0 ${A?`bg-bambu-dark-tertiary`:`bg-bambu-green`} ${P===`tailscaleDisabled`?`opacity-50`:``}`,children:(0,K.jsx)(`span`,{className:`absolute top-0.5 left-0.5 w-4 h-4 bg-white rounded-full transition-transform ${A?``:`translate-x-5`}`})})]})}),p!==`proxy`&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-1`,children:n(`virtualPrinter.model.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:n(`virtualPrinter.model.description`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:S,onChange:e=>ue(e.target.value),disabled:P===`model`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:Object.entries(t).map(([e,t])=>(0,K.jsxs)(`option`,{value:e,children:[t,` (`,e,`)`]},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),p===`proxy`&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded bg-blue-500/10 border border-blue-500/30`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`virtualPrinter.proxy.accessCodeHint`)})]})}),p!==`proxy`&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.accessCode.title`)}),_e?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-blue-400`,children:[(0,K.jsx)(Pc,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.inheritedFromTarget`)]}):e.access_code_set?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-400`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.isSet`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`virtualPrinter.accessCode.notSet`)]})]}),_e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:M?`text`:`password`,value:ve,readOnly:!0,"aria-label":n(`virtualPrinter.accessCode.title`),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm pr-10 font-mono opacity-90 cursor-default`}),(0,K.jsx)(`button`,{onClick:()=>N(!M),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,"aria-label":n(M?`virtualPrinter.accessCode.hide`:`virtualPrinter.accessCode.reveal`),children:M?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`virtualPrinter.accessCode.derivedFromTargetHint`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:M?`text`:`password`,value:d,onChange:e=>f(e.target.value),placeholder:e.access_code_set?n(`virtualPrinter.accessCode.placeholderChange`):n(`virtualPrinter.accessCode.placeholder`),maxLength:8,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm placeholder-bambu-gray pr-10 font-mono`}),(0,K.jsx)(`button`,{onClick:()=>N(!M),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:M?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})})]}),(0,K.jsx)($,{onClick:ce,disabled:!d||P===`accessCode`,variant:`primary`,children:P===`accessCode`?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`common.save`)})]}),d&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:(0,K.jsx)(`span`,{className:d.length===8?`text-green-400`:`text-yellow-400`,children:n(`virtualPrinter.accessCode.charCount`,{count:d.length})})})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-2`,children:n(`virtualPrinter.targetPrinter.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:h??``,onChange:e=>{let t=parseInt(e.target.value,10);isNaN(t)||de(t)},disabled:P===`targetPrinter`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.targetPrinter.placeholder`)}),ie?.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.ip_address,`)`]},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium mb-1`,children:n(`virtualPrinter.bindIp.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:_,onChange:e=>{v(e.target.value),F(`bindIp`),ae.mutate({bind_ip:e.target.value})},disabled:P===`bindIp`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.bindIp.placeholder`)}),H?.map(e=>(0,K.jsxs)(`option`,{value:e.ip,children:[e.name,` (`,e.ip,`)`,e.is_alias?` [alias]`:``,` - `,e.subnet]},e.ip))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`virtualPrinter.bindIp.hint`)})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(`div`,{className:`text-white text-sm font-medium`,children:n(`virtualPrinter.remoteInterface.title`)}),b?(0,K.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-green-400`,children:(0,K.jsx)(rs,{className:`w-3 h-3`})}):(0,K.jsx)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray`,title:n(`virtualPrinter.remoteInterface.optional`),children:(0,K.jsx)(Pc,{className:`w-3 h-3`})})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:b,onChange:e=>fe(e.target.value),disabled:P===`remoteInterface`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-1.5 text-white text-sm appearance-none cursor-pointer disabled:opacity-50 pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:n(`virtualPrinter.remoteInterface.placeholder`)}),H?.map(e=>(0,K.jsxs)(`option`,{value:e.ip,children:[e.name,` (`,e.ip,`) - `,e.subnet]},e.ip))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]})]}),I&&(0,K.jsx)(Ad,{title:n(`virtualPrinter.deleteConfirm.title`),message:n(`virtualPrinter.deleteConfirm.message`,{name:e.name}),variant:`danger`,confirmText:n(`common.delete`),isLoading:oe.isPending,onConfirm:()=>oe.mutate(),onCancel:()=>L(!1)}),R&&(0,K.jsx)(EHe,{vpId:e.id,vpName:e.name,onClose:()=>z(!1)})]})}var J3={archive:`archive`,review:`review`,queue:`queue`,proxy:`proxy`};function OHe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(`archive`),[c,l]=(0,y.useState)(null),{data:u}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),d=J({mutationFn:()=>nd.create({name:i.trim()||`Bambuddy`,mode:o,target_printer_id:o===`proxy`?c??void 0:void 0}),onSuccess:()=>{n.invalidateQueries({queryKey:[`virtual-printers`]}),r(t(`virtualPrinter.toast.created`)),e()},onError:e=>{r(e.message||t(`virtualPrinter.toast.failedToCreate`),`error`)}});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:e,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6 space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t(`virtualPrinter.addDialog.title`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.addDialog.name`)}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Bambuddy`,className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm placeholder-bambu-gray`,autoFocus:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.mode.title`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:[`archive`,`review`,`queue`,`proxy`].map(e=>(0,K.jsxs)(`button`,{onClick:()=>s(e),className:`p-2 rounded-lg border text-left transition-colors ${o===e?e===`proxy`?`border-blue-500 bg-blue-500/10`:`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-white text-xs font-medium`,children:[e===`proxy`&&(0,K.jsx)(Mo,{className:`w-3 h-3`}),t(`virtualPrinter.mode.${J3[e]}`)]}),(0,K.jsx)(`div`,{className:`text-[10px] text-bambu-gray`,children:t(`virtualPrinter.mode.${J3[e]}Desc`)})]},e))})]}),o===`proxy`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-sm text-white font-medium block mb-1`,children:t(`virtualPrinter.targetPrinter.title`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:c??``,onChange:e=>{let t=parseInt(e.target.value,10);l(isNaN(t)?null:t)},className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-md px-3 py-2 text-white text-sm appearance-none cursor-pointer pr-10`,children:[(0,K.jsx)(`option`,{value:``,children:t(`virtualPrinter.targetPrinter.placeholder`)}),u?.map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.ip_address,`)`]},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:t(`virtualPrinter.addDialog.hint`)}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,disabled:d.isPending,children:t(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,onClick:()=>d.mutate(),className:`flex-1`,disabled:d.isPending,children:d.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):t(`virtualPrinter.addDialog.create`)})]})]})})})}function kHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),{data:a,isLoading:o}=q({queryKey:[`virtual-printers`],queryFn:nd.list,refetchInterval:1e4}),{data:s}=q({queryKey:[`virtual-printer-settings`],queryFn:td.getSettings}),c=J({mutationFn:e=>td.updateSettings({archive_name_source:e}),onSuccess:()=>{t.invalidateQueries({queryKey:[`virtual-printer-settings`]}),n(e(`virtualPrinter.toast.updated`))},onError:t=>{n(t.message||e(`virtualPrinter.toast.failedToUpdate`),`error`)}}),l=s?.archive_name_source===`filename`,{data:u}=q({queryKey:[`vp-ca-certificate`],queryFn:nd.getCaCertificate,staleTime:1/0}),[d,f]=(0,y.useState)(!1),p=async()=>{u&&(await G3(u.pem)?(f(!0),n(e(`virtualPrinter.caCert.copied`)),setTimeout(()=>f(!1),2e3)):n(e(`virtualPrinter.toast.copyFailed`),`error`))},m=()=>{u&&wHe(u.pem,`bambuddy-virtual-printer-ca.crt`,`application/x-pem-file`)};if(o)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})});let h=a?.printers||[],g=a?.models||{};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4 items-stretch`,children:[(0,K.jsx)(_d,{className:`border-l-4 border-l-yellow-500`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`virtualPrinter.setupRequired.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`virtualPrinter.setupRequired.description`)}),(0,K.jsxs)(`a`,{href:`https://wiki.bambuddy.cool/features/virtual-printer/`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 bg-yellow-500/20 border border-yellow-500/50 rounded text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),e(`virtualPrinter.setupRequired.readGuide`)]})]})]})})}),(0,K.jsx)(_d,{className:`lg:col-span-2`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`virtualPrinter.howItWorks.title`)}),(0,K.jsxs)(`ul`,{className:`space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step1`)}),(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step2`)}),(0,K.jsx)(`li`,{children:e(`virtualPrinter.howItWorks.step3`)})]})]})]})})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4 items-stretch`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-1`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`virtualPrinter.caCert.title`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsxs)(`button`,{onClick:p,disabled:!u,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded bg-bambu-dark-secondary border border-bambu-dark-tertiary text-white hover:border-bambu-gray disabled:opacity-50 transition-colors`,children:[d?(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-bambu-green`}):(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`}),e(d?`virtualPrinter.caCert.copied`:`virtualPrinter.caCert.copy`)]}),(0,K.jsxs)(`button`,{onClick:m,disabled:!u,className:`inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded bg-bambu-dark-secondary border border-bambu-dark-tertiary text-white hover:border-bambu-gray disabled:opacity-50 transition-colors`,children:[(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`}),e(`virtualPrinter.caCert.download`)]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`virtualPrinter.caCert.description`)}),u&&(0,K.jsxs)(`p`,{className:`text-[10px] text-bambu-gray font-mono mt-1 truncate`,title:u.fingerprint_sha256,children:[e(`virtualPrinter.caCert.fingerprint`),`: `,u.fingerprint_sha256]})]})]})})}),(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-green flex-shrink-0 mt-1`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`virtualPrinter.archiveNameSource.title`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,K.jsx)(`span`,{className:`text-xs ${l?`text-bambu-gray`:`text-white`}`,children:e(`virtualPrinter.archiveNameSource.metadata`)}),(0,K.jsx)(lU,{checked:l,onChange:e=>c.mutate(e?`filename`:`metadata`),disabled:c.isPending}),(0,K.jsx)(`span`,{className:`text-xs ${l?`text-white`:`text-bambu-gray`}`,children:e(`virtualPrinter.archiveNameSource.filename`)})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`virtualPrinter.archiveNameSource.description`)})]})]})})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`virtualPrinter.list.title`)}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,h.length,`)`]})]}),(0,K.jsxs)($,{variant:`primary`,onClick:()=>i(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),e(`virtualPrinter.list.add`)]})]}),h.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-8 text-center`,children:[(0,K.jsx)(Tl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`virtualPrinter.list.empty`)}),(0,K.jsxs)($,{variant:`primary`,onClick:()=>i(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),e(`virtualPrinter.list.addFirst`)]})]})}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4 items-start`,children:h.map(e=>(0,K.jsx)(DHe,{printer:e,models:g},e.id))}),r&&(0,K.jsx)(OHe,{onClose:()=>i(!1)})]})}function Y3(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60),r=t%60;if(n<24)return r?`${n}h ${r}m`:`${n}h`;let i=Math.floor(n/24),a=n%24;return a?`${i}d ${a}h`:`${i}d`}function X3(e){return e==null?`—`:e>=1024?`${(e/1024).toFixed(1)} GB`:`${Math.round(e)} MB`}function AHe({device:e,onUnregister:t,isDeleting:n}){let{t:r}=W(),{showToast:i}=Td(),a=e.system_stats,o=a?.memory,s=a?.disk,c=e.online,[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),p=async t=>{f(t);try{t===`update`?await od.triggerUpdate(e.device_id):await od.systemCommand(e.device_id,t),i(r(`settings.spoolbuddy.commandQueued`),`success`)}catch(e){i(e instanceof Error?e.message:r(`settings.spoolbuddy.commandError`),`error`)}finally{f(null),u(null)}},m=[{key:`update`,label:r(`settings.spoolbuddy.update`),icon:Vs},{key:`restart_browser`,label:r(`settings.spoolbuddy.restartBrowser`),icon:ol},{key:`restart_daemon`,label:r(`settings.spoolbuddy.restartDaemon`),icon:Ol},{key:`reboot`,label:r(`settings.spoolbuddy.reboot`),icon:jl},{key:`shutdown`,label:r(`settings.spoolbuddy.shutdown`),icon:wl,variant:`danger`}],h={update:r(`settings.spoolbuddy.updateConfirmTitle`),restart_browser:r(`settings.spoolbuddy.restartBrowserConfirmTitle`),restart_daemon:r(`settings.spoolbuddy.restartDaemonConfirmTitle`),reboot:r(`settings.spoolbuddy.rebootConfirmTitle`),shutdown:r(`settings.spoolbuddy.shutdownConfirmTitle`)},g={update:r(`settings.spoolbuddy.updateConfirmBody`,{hostname:e.hostname}),restart_browser:r(`settings.spoolbuddy.restartBrowserConfirmBody`,{hostname:e.hostname}),restart_daemon:r(`settings.spoolbuddy.restartDaemonConfirmBody`,{hostname:e.hostname}),reboot:r(`settings.spoolbuddy.rebootConfirmBody`,{hostname:e.hostname}),shutdown:r(`settings.spoolbuddy.shutdownConfirmBody`,{hostname:e.hostname})};return(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3 flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white truncate`,children:e.hostname}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${c?`bg-green-500/15 text-green-400 border border-green-500/40`:`bg-gray-500/15 text-gray-400 border border-gray-500/40`}`,children:[c?(0,K.jsx)(Fu,{className:`w-3 h-3`}):(0,K.jsx)(Pu,{className:`w-3 h-3`}),r(c?`settings.spoolbuddy.online`:`settings.spoolbuddy.offline`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray font-mono mt-1 truncate`,children:e.device_id})]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>t(e),disabled:n,"aria-label":r(`settings.spoolbuddy.unregister`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r(`settings.spoolbuddy.unregister`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.ipAddress`)}),(0,K.jsx)(`div`,{className:`text-white font-mono`,children:e.ip_address})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.firmware`)}),(0,K.jsx)(`div`,{className:`text-white`,children:e.firmware_version??`—`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),r(`settings.spoolbuddy.lastSeen`)]}),(0,K.jsx)(`div`,{className:`text-white`,children:e.last_seen?wf(e.last_seen):r(`settings.spoolbuddy.never`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.daemonUptime`)}),(0,K.jsx)(`div`,{className:`text-white`,children:Y3(e.uptime_s)})]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:m.map(({key:e,label:t,icon:n,variant:r})=>(0,K.jsxs)($,{variant:r??`secondary`,size:`sm`,onClick:()=>u(e),disabled:!c||d!==null,"aria-label":t,children:[d===e?(0,K.jsx)(X,{className:`w-3.5 h-3.5 animate-spin`}):(0,K.jsx)(n,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs flex-wrap`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[e.nfc_ok?(0,K.jsx)(ms,{className:`w-3.5 h-3.5 text-green-400`}):(0,K.jsx)(ys,{className:`w-3.5 h-3.5 text-red-400`}),r(`settings.spoolbuddy.nfc`),e.nfc_reader_type&&(0,K.jsxs)(`span`,{className:`text-bambu-gray/70`,children:[`(`,e.nfc_reader_type,`)`]})]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[e.scale_ok?(0,K.jsx)(ms,{className:`w-3.5 h-3.5 text-green-400`}):(0,K.jsx)(ys,{className:`w-3.5 h-3.5 text-red-400`}),r(`settings.spoolbuddy.scale`)]})]}),a&&(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 text-xs`,children:[a.cpu_temp_c!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(vu,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.cpuTemp`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[a.cpu_temp_c.toFixed(1),`°C`]})]})]}),a.load_avg&&a.load_avg.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Eo,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.cpuLoad`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[a.load_avg[0].toFixed(2),a.cpu_count?` / ${a.cpu_count} (${Math.round(a.load_avg[0]/a.cpu_count*100)}%)`:``]})]})]}),o&&o.percent!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ns,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.memory`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[o.percent.toFixed(0),`% (`,X3(o.used_mb),` / `,X3(o.total_mb),`)`]})]})]}),s&&s.percent!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(wc,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.disk`)}),(0,K.jsxs)(`div`,{className:`text-white`,children:[s.percent.toFixed(0),`% (`,s.used_gb?.toFixed(1),` / `,s.total_gb?.toFixed(1),` GB)`]})]})]}),a.system_uptime_s!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5 text-bambu-gray`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:r(`settings.spoolbuddy.systemUptime`)}),(0,K.jsx)(`div`,{className:`text-white`,children:Y3(a.system_uptime_s)})]})]})]}),a.os&&(0,K.jsx)(`div`,{className:`mt-3 text-xs text-bambu-gray font-mono truncate`,children:[a.os.os,a.os.kernel,a.os.arch,a.os.python&&`Python ${a.os.python}`].filter(Boolean).join(` · `)})]})]}),l&&(0,K.jsx)(Ad,{variant:l===`shutdown`||l===`reboot`?`danger`:`default`,title:h[l],message:g[l],confirmText:r(`settings.spoolbuddy.commandConfirm`),isLoading:d!==null,onConfirm:()=>p(l),onCancel:()=>u(null)})]})}function jHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(null),{data:a=[],isLoading:o}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:15e3}),s=J({mutationFn:e=>od.deleteDevice(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`spoolbuddy-devices`]}),n(e(`settings.spoolbuddy.unregisterSuccess`),`success`),i(null)},onError:t=>{n(t.message||e(`settings.spoolbuddy.unregisterError`),`error`)}});if(o)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})})});let c=a.length>1;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`settings.spoolbuddy.infoTitle`)}),(0,K.jsx)(`p`,{children:e(`settings.spoolbuddy.infoBody`)})]})]})})}),c&&(0,K.jsx)(_d,{className:`border-l-4 border-l-yellow-500`,children:(0,K.jsx)(yd,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-xs`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:e(`settings.spoolbuddy.duplicatesTitle`,{count:a.length})}),(0,K.jsx)(`p`,{children:e(`settings.spoolbuddy.duplicatesBody`)})]})]})})}),a.length===0?(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8 text-center text-bambu-gray text-sm`,children:e(`settings.spoolbuddy.empty`)})}):(0,K.jsx)(`div`,{className:`space-y-3`,children:a.map(e=>(0,K.jsx)(AHe,{device:e,onUnregister:i,isDeleting:s.isPending&&s.variables===e.device_id},e.id))}),r&&(0,K.jsx)(Ad,{variant:`danger`,title:e(`settings.spoolbuddy.confirmTitle`),message:e(`settings.spoolbuddy.confirmBody`,{hostname:r.hostname,deviceId:r.device_id}),confirmText:e(`settings.spoolbuddy.unregister`),isLoading:s.isPending,onConfirm:()=>s.mutate(r.device_id),onCancel:()=>i(null)})]})}function Z3(e){if(!e)return`-`;let t=vf(e);return t?t.toLocaleString():`-`}function Q3({status:e}){if(!e)return null;let t={success:`bg-green-500/20 text-green-400`,failed:`bg-red-500/20 text-red-400`,skipped:`bg-yellow-500/20 text-yellow-400`,running:`bg-blue-500/20 text-blue-400`},n={success:(0,K.jsx)(ps,{className:`w-3 h-3`}),failed:(0,K.jsx)(ys,{className:`w-3 h-3`}),skipped:(0,K.jsx)(Zl,{className:`w-3 h-3`}),running:(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})};return(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium ${t[e]||`bg-gray-500/20 text-gray-400`}`,children:[n[e],e.charAt(0).toUpperCase()+e.slice(1)]})}var MHe={github:`backup.repoUrlPlaceholderGitHub`,gitea:`backup.repoUrlPlaceholderGitea`,forgejo:`backup.repoUrlPlaceholderForgejo`,gitlab:`backup.repoUrlPlaceholderGitLab`},NHe={github:`ghp_xxxxxxxxxxxx`,gitea:`your_access_token`,forgejo:`your_access_token`,gitlab:`glpat-xxxxxxxxxxxx`};function $3(e){return JSON.stringify(e)}function PHe(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))e[r]!==t[r]&&(n[r]=e[r]);return n}function FHe(){let e=no(),{showToast:t}=Td(),{t:n}=W(),[r,i]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`main`),[l,u]=(0,y.useState)(`github`),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(`daily`),[h,g]=(0,y.useState)(!0),[_,v]=(0,y.useState)(!0),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!0),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),ee=(0,y.useRef)(null),[te,ne]=(0,y.useState)(null),[re,ie]=(0,y.useState)(null),[H,ae]=(0,y.useState)(``),{data:oe,refetch:U}=q({queryKey:[`local-backup-status`],queryFn:Q.getLocalBackupStatus,refetchInterval:e=>e.state.data?.is_running?1e3:1e4}),{data:se,refetch:ce}=q({queryKey:[`local-backup-files`],queryFn:Q.getLocalBackups,refetchInterval:3e4});(0,y.useEffect)(()=>{oe?.path!==void 0&&ae(oe.path)},[oe?.path]);let le=J({mutationFn:Q.triggerLocalBackup,onSuccess:e=>{e.success?t(n(`backup.scheduledBackupComplete`)):t(e.message,`error`),U(),ce()},onError:()=>t(n(`backup.scheduledBackupFailed`),`error`)}),ue=J({mutationFn:e=>Q.deleteLocalBackup(e),onSuccess:()=>{ce(),ne(null)}}),de=J({mutationFn:async e=>(ie(null),N(!0),V(null),F(n(`backup.restoring`)),Q.restoreLocalBackup(e)),onSuccess:e=>{N(!1),F(``),e.success?(V({success:!0,message:e.message}),t(n(`backup.backupRestoredRestart`),`success`)):(V({success:!1,message:e.message}),t(e.message,`error`))},onError:e=>{N(!1),F(``);let r=e instanceof Error?e.message:n(`backup.failedToRestore`);V({success:!1,message:r}),t(r,`error`)}});(0,y.useEffect)(()=>{if(A||M){let e=e=>(e.preventDefault(),e.returnValue=`A backup operation is in progress. Are you sure you want to leave?`,e.returnValue);return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)}},[A,M]);let[fe,pe]=(0,y.useState)(!1),[me,he]=(0,y.useState)(null),[ge,_e]=(0,y.useState)(null),ve=(0,y.useRef)(null),ye=(0,y.useRef)(null),be=(0,y.useRef)(null),xe=(0,y.useRef)(null),Se=(0,y.useRef)(``),[Ce,we]=(0,y.useState)(!1),Te=(0,y.useMemo)(()=>({repository_url:r,branch:s,provider:l,allow_insecure_http:E,schedule_enabled:d,schedule_type:p,backup_kprofiles:h,backup_cloud_profiles:_,backup_settings:b,backup_spools:S,backup_archives:w,enabled:O}),[r,s,l,E,d,p,h,_,b,S,w,O]),Ee=(0,y.useMemo)(()=>$3(Te),[Te]),{data:De,isLoading:Oe}=q({queryKey:[`github-backup-config`],queryFn:Q.getGitHubBackupConfig}),{data:ke}=q({queryKey:[`github-backup-status`],queryFn:Q.getGitHubBackupStatus,refetchInterval:e=>e.state.data?.is_running?500:1e4}),{data:Ae}=q({queryKey:[`github-backup-logs`],queryFn:()=>Q.getGitHubBackupLogs(20)}),{data:je}=q({queryKey:[`cloud-status`],queryFn:Q.getCloudStatus}),{data:Me}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),Ne=_o({queries:(Me??[]).map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),staleTime:1e4,refetchInterval:3e4}))}),Pe=(Me??[]).map((e,t)=>({printer:e,connected:Ne[t]?.data?.connected??!1})),Fe=Pe.length,Ie=Pe.filter(e=>e.connected).length,Le=Fe>0&&Ie===0,Re=Ie>0&&Ie(be.current&&clearTimeout(be.current),De?(we(!1),xe.current={repository_url:De.repository_url,branch:De.branch,provider:De.provider??`github`,allow_insecure_http:De.allow_insecure_http??!1,schedule_enabled:De.schedule_enabled,schedule_type:De.schedule_type,backup_kprofiles:De.backup_kprofiles,backup_cloud_profiles:De.backup_cloud_profiles,backup_settings:De.backup_settings,backup_spools:De.backup_spools,backup_archives:De.backup_archives,enabled:De.enabled},i(De.repository_url),c(De.branch),u(De.provider??`github`),f(De.schedule_enabled),m(De.schedule_type),g(De.backup_kprofiles),v(De.backup_cloud_profiles),x(De.backup_settings),C(De.backup_spools),T(De.backup_archives),D(De.allow_insecure_http??!1),k(De.enabled),o(``),be.current=setTimeout(()=>{we(!0)},100)):(we(!1),xe.current=null,o(``)),()=>{be.current&&clearTimeout(be.current)}),[De]);let ze=(0,y.useCallback)(async(r=!1)=>{if(De)try{r&&a?(await Q.saveGitHubBackupConfig({...Te,access_token:a}),o(``),_e(null),t(n(`backup.tokenUpdated`)),Se.current=``):(await Q.updateGitHubBackupConfig(PHe(Te,xe.current)),_e(null),t(n(`backup.settingsSaved`))),xe.current=Te,e.invalidateQueries({queryKey:[`github-backup-config`]}),e.invalidateQueries({queryKey:[`github-backup-status`]})}catch(e){_e(e.message)}},[De,a,Te,e,t,n]),Be=(0,y.useRef)(ze);(0,y.useEffect)(()=>{Be.current=ze},[ze]),(0,y.useEffect)(()=>{if(!(!Ce||!De)&&!(xe.current&&Ee===$3(xe.current)))return ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{ze(!1)},500),()=>{ve.current&&clearTimeout(ve.current)}},[Ce,De,Ee,ze]),(0,y.useEffect)(()=>{if(!(!Ce||!De||!a)&&a!==Se.current)return Se.current=a,ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{Be.current(!0)},1e3),()=>{ye.current&&clearTimeout(ye.current)}},[Ce,a,De]);let Ve=J({mutationFn:e=>Q.saveGitHubBackupConfig(e),onMutate:()=>{_e(null)},onSuccess:()=>{e.invalidateQueries({queryKey:[`github-backup-config`]}),e.invalidateQueries({queryKey:[`github-backup-status`]}),t(n(`backup.githubBackupEnabled`)),o(``),we(!0)},onError:e=>{_e(e.message)}}),He=J({mutationFn:Q.triggerGitHubBackup,onSuccess:r=>{e.invalidateQueries({queryKey:[`github-backup-status`]}),e.invalidateQueries({queryKey:[`github-backup-logs`]}),r.success?r.files_changed>0?t(n(`backup.backupCompleteFiles`,{count:r.files_changed})):t(n(`backup.backupSkippedNoChanges`)):t(n(`backup.backupFailed2`,{message:r.message}),`error`)},onError:e=>{t(n(`backup.backupFailed2`,{message:e.message}),`error`)}}),Ue=J({mutationFn:()=>Q.clearGitHubBackupLogs(0),onSuccess:r=>{e.invalidateQueries({queryKey:[`github-backup-logs`]}),t(n(`backup.clearedLogs`,{count:r.deleted}))},onError:e=>{t(n(`backup.failedToClearLogs`,{message:e.message}),`error`)}}),We=async()=>{pe(!0),he(null);try{let e;if(a){if(!r){t(n(`backup.enterRepoUrl`),`error`),pe(!1);return}e=await Q.testGitHubConnection(r,a,l)}else if(De?.has_token)e=await Q.testGitHubStoredConnection();else{t(n(`backup.enterRepoAndToken`),`error`),pe(!1);return}he({success:e.success,message:e.message,isPrivate:e.is_private})}catch(e){he({success:!1,message:e.message,isPrivate:null})}finally{pe(!1)}};return Oe?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-backup-github`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(yc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.githubBackup`)})]}),De&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`backup.enabled`)}),(0,K.jsx)(lU,{checked:O,onChange:k})]})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.githubDescription`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`git-provider-select`,className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.provider`)}),(0,K.jsxs)(`select`,{id:`git-provider-select`,value:l,onChange:e=>{u(e.target.value),he(null),_e(null)},className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`github`,children:n(`backup.providerGitHub`)}),(0,K.jsx)(`option`,{value:`gitlab`,children:n(`backup.providerGitLab`)}),(0,K.jsx)(`option`,{value:`gitea`,children:n(`backup.providerGitea`)}),(0,K.jsx)(`option`,{value:`forgejo`,children:n(`backup.providerForgejo`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.repositoryUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:r,onChange:e=>{i(e.target.value),he(null),_e(null)},placeholder:n(MHe[l]),className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 mt-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>{D(e.target.checked),he(null)},className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:n(`backup.allowInsecureHttp`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.allowInsecureHttpHint`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[n(`backup.personalAccessToken`),` `,De?.has_token&&(0,K.jsx)(`span`,{className:`text-green-400`,children:n(`backup.tokenSaved`)})]}),(0,K.jsx)(`input`,{type:`password`,value:a,onChange:e=>{o(e.target.value),he(null),_e(null)},placeholder:De?.has_token?n(`backup.enterNewToken`):NHe[l],className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`backup.tokenHint`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.branch`)}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:`main`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.autoBackup`)}),(0,K.jsxs)(`select`,{value:d?p:`disabled`,onChange:e=>{e.target.value===`disabled`?f(!1):(f(!0),m(e.target.value))},className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`disabled`,children:n(`backup.manualOnly`)}),(0,K.jsx)(`option`,{value:`hourly`,children:n(`backup.hourly`)}),(0,K.jsx)(`option`,{value:`daily`,children:n(`backup.daily`)}),(0,K.jsx)(`option`,{value:`weekly`,children:n(`backup.weekly`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:n(`backup.includeInBackup`)}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-start gap-2 ${Le?`cursor-not-allowed opacity-60`:`cursor-pointer`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>g(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`,disabled:Le}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm ${Le?`text-bambu-gray`:`text-white`}`,children:n(`backup.kProfiles`)}),Le&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.noPrintersConnected`)]}),Re&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.printersConnected`,{connected:Ie,total:Fe})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.kProfilesDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 ${je?.is_authenticated?`cursor-pointer`:`cursor-not-allowed opacity-60`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`,disabled:!je?.is_authenticated}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm ${je?.is_authenticated?`text-white`:`text-bambu-gray`}`,children:n(`backup.cloudProfiles`)}),!je?.is_authenticated&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),n(`backup.cloudLoginRequiredShort`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.cloudProfilesDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:b,onChange:e=>x(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.appSettings`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.appSettingsDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:S,onChange:e=>C(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.spoolInventory`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.spoolInventoryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),className:`w-4 h-4 mt-0.5 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white text-sm`,children:n(`backup.printArchives`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`backup.printArchivesDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 space-y-3`,children:[ke?.configured&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:ke.last_backup_at?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{children:[n(`backup.lastBackupAt`),` `,wf(ke.last_backup_at,`system`,n)]}),(0,K.jsx)(Q3,{status:ke.last_backup_status})]}):(0,K.jsx)(`span`,{children:n(`backup.noBackupsYet`)})}),ke.next_scheduled_run&&(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3 inline mr-1`}),n(`backup.next`),` `,wf(ke.next_scheduled_run,`system`,n)]})]}),ge&&(0,K.jsxs)(`div`,{className:`text-sm text-red-400 bg-red-500/10 border border-red-500/30 rounded p-3 flex items-start gap-2`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`div`,{className:`flex-1 leading-relaxed whitespace-pre-wrap break-words`,children:ge}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>_e(null),className:`text-bambu-gray hover:text-white shrink-0`,"aria-label":n(`common.dismiss`,`Dismiss`),children:(0,K.jsx)(ys,{className:`w-4 h-4`})})]}),me&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`text-sm flex items-center gap-1 ${me.success?`text-green-400`:`text-red-400`}`,children:[me.success?(0,K.jsx)(ps,{className:`w-4 h-4`}):(0,K.jsx)(ys,{className:`w-4 h-4`}),me.message]}),me.success&&me.isPrivate===!0&&(0,K.jsxs)(`div`,{className:`text-xs flex items-center gap-1 text-green-400`,children:[(0,K.jsx)(ps,{className:`w-3.5 h-3.5`}),n(`backup.repoIsPrivate`,`Repository is private — safe to back up to.`)]}),me.success&&me.isPrivate===!1&&(0,K.jsxs)(`div`,{className:`text-xs text-red-400 bg-red-500/10 border border-red-500/30 rounded p-2 flex items-start gap-1.5`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`backup.repoIsPublicWarning`,`Repository is PUBLIC. Bambuddy backups include MQTT credentials, Home Assistant tokens, Prometheus tokens, your Bambu Cloud email, and printer access codes via K-profiles. Saving is blocked until you make the repository private in your provider's settings.`)})]}),me.success&&me.isPrivate===null&&(0,K.jsxs)(`div`,{className:`text-xs text-yellow-400 bg-yellow-500/10 border border-yellow-500/30 rounded p-2 flex items-start gap-1.5`,children:[(0,K.jsx)(ys,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:n(`backup.repoVisibilityUnknown`,`Could not determine repository visibility. Bambuddy refuses to back up to anything not confirmed private; saving will be blocked.`)})]})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:ke?.configured?(0,K.jsx)(K.Fragment,{children:He.isPending||ke.is_running?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{className:`text-sm`,children:ke.progress||n(`backup.startingBackup`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>He.mutate(),disabled:!De?.enabled,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),n(`backup.backupNow`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:We,disabled:fe,children:[fe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),n(`backup.test`)]})]})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>{if(!r){t(n(`backup.repoRequired`),`error`);return}if(!a){t(n(`backup.tokenRequired`),`error`);return}Ve.mutate({repository_url:r,access_token:a,branch:s,provider:l,allow_insecure_http:E,schedule_enabled:d,schedule_type:p,backup_kprofiles:h,backup_cloud_profiles:_,backup_settings:b,backup_spools:S,backup_archives:w,enabled:O})},disabled:Ve.isPending||!r||!a,children:[Ve.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(ps,{className:`w-4 h-4`}),n(`backup.enableBackup`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:We,disabled:fe||!r||!a,children:[fe?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),n(`backup.testConnection`)]})]})})]})]})]}),Ae&&Ae.length>0&&(0,K.jsxs)(_d,{id:`card-backup-history`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(kc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.history`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>Ue.mutate(),disabled:Ue.isPending,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),n(`backup.clear`)]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.date`)}),(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.status`)}),(0,K.jsx)(`th`,{className:`text-left py-2 px-2`,children:n(`backup.commit`)})]})}),(0,K.jsx)(`tbody`,{children:Ae.slice(0,10).map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary`,children:[(0,K.jsx)(`td`,{className:`py-2 px-2 text-white`,children:Z3(e.started_at)}),(0,K.jsx)(`td`,{className:`py-2 px-2`,children:(0,K.jsx)(Q3,{status:e.status})}),(0,K.jsx)(`td`,{className:`py-2 px-2`,children:e.commit_sha?(0,K.jsxs)(`a`,{href:`${De?.repository_url}/commit/${e.commit_sha}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline inline-flex items-center gap-1`,children:[e.commit_sha.substring(0,7),(0,K.jsx)(Js,{className:`w-3 h-3`})]}):(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`-`})})]},e.id))})]})})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-backup-local`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Is,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.localBackup`)})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.localBackupDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:n(`backup.downloadBackupLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.completeBackupZip`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:A||M,onClick:async()=>{j(!0),F(n(`backup.preparingBackup`));try{F(n(`backup.creatingArchive`));let{blob:e,filename:r}=await Q.exportBackup();F(n(`backup.downloadingFile`));let i=URL.createObjectURL(e),a=document.createElement(`a`);a.href=i,a.download=r,a.click(),URL.revokeObjectURL(i),t(n(`backup.backupDownloaded`))}catch(e){t(n(`backup.failedToCreateBackup`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}finally{j(!1),F(``)}},children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),n(`backup.download`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:n(`backup.restoreBackup`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.restoreDescription`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.restoreNote`)})]}),(0,K.jsx)(`input`,{ref:ee,type:`file`,accept:`.zip`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&(z(t),L(!0)),e.target.value=``}}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:M||A,onClick:()=>ee.current?.click(),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`backup.restore`)]})]}),B&&(0,K.jsx)(`div`,{className:`p-3 rounded-lg ${B.success?`bg-green-500/10 border border-green-500/30`:`bg-red-500/10 border border-red-500/30`}`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[B.success?(0,K.jsx)(ps,{className:`w-4 h-4 text-green-400 mt-0.5 flex-shrink-0`}):(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:B.success?`text-green-200`:`text-red-200`,children:[B.message,B.success&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsxs)($,{size:`sm`,onClick:()=>window.location.reload(),children:[(0,K.jsx)(Al,{className:`w-3 h-3`}),n(`backup.reloadNow`)]})})]})]})}),(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`text-yellow-200`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:n(`backup.restoreReplacesAll`)}),` `,(0,K.jsx)(`span`,{className:`text-yellow-200/70`,children:n(`backup.restoreReplacesAllDetail`)})]})]})})]})]}),(0,K.jsxs)(_d,{id:`card-backup-scheduled`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(oc,{className:`w-5 h-5 text-gray-400`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`backup.scheduledBackup`)})]}),(0,K.jsx)(lU,{checked:oe?.enabled??!1,onChange:async r=>{try{await Q.updateSettings({local_backup_enabled:r}),e.invalidateQueries({queryKey:[`settings`]}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}})]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`backup.scheduledBackupDescription`)}),oe?.enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.frequency`)}),(0,K.jsxs)(`select`,{value:oe?.schedule??`daily`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onChange:async e=>{try{await Q.updateSettings({local_backup_schedule:e.target.value}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()},children:[(0,K.jsx)(`option`,{value:`hourly`,children:n(`backup.hourly`)}),(0,K.jsx)(`option`,{value:`daily`,children:n(`backup.daily`)}),(0,K.jsx)(`option`,{value:`weekly`,children:n(`backup.weekly`)})]})]}),(oe?.schedule??`daily`)!==`hourly`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.backupTime`)}),(0,K.jsx)(`input`,{type:`time`,value:oe?.time??`03:00`,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none [color-scheme:dark]`,onChange:async e=>{try{await Q.updateSettings({local_backup_time:e.target.value}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.localTimeHint`,{tz:oe?.timezone||`UTC`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.retention`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:100,value:oe?.retention??5,className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onChange:async e=>{let r=Math.max(1,Math.min(100,parseInt(e.target.value)||5));try{await Q.updateSettings({local_backup_retention:r}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:n(`backup.retentionDescription`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`backup.outputPath`)}),(0,K.jsx)(`input`,{type:`text`,value:H,onChange:e=>ae(e.target.value),className:`w-full h-10 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,onBlur:async()=>{try{await Q.updateSettings({local_backup_path:H}),t(n(`backup.settingsSaved`))}catch(e){t(n(`backup.failedToSave`,{message:e instanceof Error?e.message:`Unknown error`}),`error`)}U(),ce()},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-light mt-1`,children:H?n(`backup.outputPathDescription`):(0,K.jsxs)(K.Fragment,{children:[n(`backup.defaultPathLabel`),` `,(0,K.jsx)(`code`,{className:`text-bambu-gray`,children:oe?.default_path||`...`})]})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`text-sm`,children:[oe?.last_backup_at&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsxs)(`span`,{children:[n(`backup.lastBackup`),`:`]}),(0,K.jsx)(Q3,{status:oe.last_status}),(0,K.jsx)(`span`,{children:wf(oe.last_backup_at)})]}),oe?.next_run&&(0,K.jsxs)(`div`,{className:`text-bambu-gray mt-1`,children:[(0,K.jsxs)(`span`,{children:[n(`backup.nextBackup`),`: `]}),(0,K.jsx)(`span`,{children:Z3(oe.next_run)})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:oe?.is_running||le.isPending,onClick:()=>le.mutate(),children:[oe?.is_running||le.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bl,{className:`w-4 h-4`}),oe?.is_running?n(`backup.backupRunning`):n(`backup.runNow`)]})]}),se&&se.length>0&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:n(`backup.backupFiles`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:se.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-1.5 px-2 rounded hover:bg-bambu-dark-tertiary/50 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-white truncate block`,children:e.filename}),(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[(e.size/1024/1024).toFixed(1),` MB · `,Z3(e.created_at)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-bambu-green p-1`,title:n(`backup.download`),onClick:async()=>{try{let{blob:t,filename:n}=await Q.downloadLocalBackup(e.filename),r=URL.createObjectURL(t),i=document.createElement(`a`);i.href=r,i.download=n,i.click(),URL.revokeObjectURL(r)}catch{t(n(`backup.scheduledBackupFailed`),`error`)}},children:(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-yellow-400 p-1`,title:n(`backup.restore`),onClick:()=>ie(e.filename),children:(0,K.jsx)(Al,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{className:`text-bambu-gray hover:text-red-400 p-1`,onClick:()=>ne(e.filename),title:n(`backup.deleteBackup`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})})]})]},e.filename))})]}),se&&se.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-3 border-t border-bambu-dark-tertiary`,children:n(`backup.noScheduledBackups`)})]})]})]})]}),te&&(0,K.jsx)(Ad,{title:n(`backup.deleteBackup`),message:n(`backup.deleteBackupConfirm`),confirmText:n(`backup.deleteBackup`),variant:`danger`,onConfirm:()=>ue.mutate(te),onCancel:()=>ne(null)}),re&&(0,K.jsx)(Ad,{title:n(`backup.restoreConfirmTitle`),message:n(`backup.restoreConfirmMessage`,{filename:re}),confirmText:n(`backup.restoreConfirmButton`),variant:`danger`,onConfirm:()=>de.mutate(re),onCancel:()=>ie(null)}),I&&R&&(0,K.jsx)(Ad,{title:n(`backup.restoreConfirmTitle`),message:n(`backup.restoreConfirmMessage`,{filename:R.name}),confirmText:n(`backup.restoreConfirmButton`),variant:`danger`,onConfirm:async()=>{L(!1),N(!0),V(null);try{F(n(`backup.uploadingFile`));let e=await Q.importBackup(R);V(e),e.success?t(n(`backup.backupRestoredRestart`),`success`):t(e.message,`error`)}catch(e){let r=e instanceof Error?e.message:n(`backup.failedToRestore`);V({success:!1,message:r}),t(r,`error`)}finally{N(!1),F(``),z(null)}},onCancel:()=>{L(!1),z(null)}}),(A||M)&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-[100]`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center`,children:[(0,K.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full`}),(0,K.jsx)(`div`,{className:`w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin`})]})}),(0,K.jsx)(`h3`,{className:`text-xl font-semibold text-white mb-2`,children:n(A?`backup.creatingBackup`:`backup.restoringBackup`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:P||n(A?`backup.preparing`:`backup.processing`)}),(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-yellow-200 text-left`,children:n(`backup.doNotClosePage`)})]})})]})})]})}function IHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`medium`),[l,u]=(0,y.useState)(`notify`),[d,f]=(0,y.useState)(10),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),{data:b}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:x,refetch:S}=q({queryKey:[`obico-status`],queryFn:Q.getObicoStatus,refetchInterval:1e4}),{data:C}=q({queryKey:[`printers`],queryFn:Q.getPrinters});(0,y.useEffect)(()=>{if(b){i(b.obico_enabled??!1),o(b.obico_ml_url??``),c(b.obico_sensitivity??`medium`),u(b.obico_action??`notify`),f(b.obico_poll_interval??10);try{let e=b.obico_enabled_printers?JSON.parse(b.obico_enabled_printers):null;m(Array.isArray(e)?e:null)}catch{m(null)}v(!0)}},[b]);let w=J({mutationFn:()=>Q.updateSettings({obico_enabled:r,obico_ml_url:a,obico_sensitivity:s,obico_action:l,obico_poll_interval:d,obico_enabled_printers:p===null?``:JSON.stringify(p)}),onSuccess:()=>{t.invalidateQueries({queryKey:[`settings`]}),t.invalidateQueries({queryKey:[`obico-status`]}),n(e(`settings.toast.settingsSaved`))}});(0,y.useEffect)(()=>{if(!_||!b||!(b.obico_enabled!==r||b.obico_ml_url!==a||b.obico_sensitivity!==s||b.obico_action!==l||b.obico_poll_interval!==d||b.obico_enabled_printers!==(p===null?``:JSON.stringify(p))))return;let e=setTimeout(()=>w.mutate(),500);return()=>clearTimeout(e)},[r,a,s,l,d,p,_]);let T=async()=>{g(null);try{let t=await Q.testObicoConnection(a);t.ok?g({ok:!0,message:e(`failureDetection.testSuccess`)}):g({ok:!1,message:t.error||`HTTP ${t.status_code??`?`} — ${t.body??e(`failureDetection.testFailed`)}`})}catch(e){g({ok:!1,message:e instanceof Error?e.message:String(e)})}},E=(e,t)=>{if(p===null){let n=C?.map(e=>e.id)??[];m(t?n:n.filter(t=>t!==e));return}m(t?[...p,e]:p.filter(t=>t!==e))};return(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-fd-ml`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Fl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.title`)})]}),(0,K.jsx)(lU,{checked:r,onChange:i})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-2`,children:e(`failureDetection.description`)})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.mlUrl`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`http://192.168.1.10:3333`,className:`flex-1 bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,disabled:!r}),(0,K.jsx)($,{onClick:T,disabled:!a||w.isPending,variant:`secondary`,children:e(`failureDetection.test`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.mlUrlHint`)}),h&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 mt-2 text-sm ${h.ok?`text-green-400`:`text-red-400`}`,children:[h.ok?(0,K.jsx)(rs,{className:`w-4 h-4 mt-0.5`}):(0,K.jsx)(Ru,{className:`w-4 h-4 mt-0.5`}),(0,K.jsx)(`span`,{children:h.message})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.sensitivity`)}),(0,K.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:`low`,children:e(`failureDetection.sensitivityLow`)}),(0,K.jsx)(`option`,{value:`medium`,children:e(`failureDetection.sensitivityMedium`)}),(0,K.jsx)(`option`,{value:`high`,children:e(`failureDetection.sensitivityHigh`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.sensitivityHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.action`)}),(0,K.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`,children:[(0,K.jsx)(`option`,{value:`notify`,children:e(`failureDetection.actionNotify`)}),(0,K.jsx)(`option`,{value:`pause`,children:e(`failureDetection.actionPause`)}),(0,K.jsx)(`option`,{value:`pause_and_off`,children:e(`failureDetection.actionPauseOff`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`failureDetection.pollInterval`)}),(0,K.jsx)(`input`,{type:`number`,value:d,onChange:e=>f(Math.max(5,Math.min(120,Number(e.target.value)||10))),min:5,max:120,disabled:!r,className:`w-full bg-gray-800 border border-gray-700 rounded px-3 py-2 text-white text-sm`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`failureDetection.pollIntervalHint`)})]}),x&&!x.external_url_configured&&r&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-amber-900/30 border border-amber-700 rounded text-sm text-amber-200`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`font-medium`,children:e(`failureDetection.externalUrlMissing`)}),(0,K.jsx)(`div`,{className:`text-xs mt-1`,children:e(`failureDetection.externalUrlHint`)})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-fd-perprinter`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.perPrinterTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`failureDetection.perPrinterHint`)})]}),(0,K.jsxs)(yd,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p===null,onChange:e=>m(e.target.checked?null:C?.map(e=>e.id)??[]),disabled:!r}),(0,K.jsx)(`span`,{className:`text-white`,children:e(`failureDetection.monitorAll`)})]}),p!==null&&C&&(0,K.jsx)(`div`,{className:`pl-5 space-y-1 border-l border-gray-700`,children:C.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p.includes(e.id),onChange:t=>E(e.id,t.target.checked),disabled:!r}),(0,K.jsx)(`span`,{className:`text-white`,children:e.name})]},e.id))})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-fd-status`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.statusTitle`)})}),(0,K.jsx)(yd,{children:x?(0,K.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`failureDetection.serviceRunning`)}),(0,K.jsx)(`span`,{className:x.is_running?`text-green-400`:`text-red-400`,children:x.is_running?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`failureDetection.thresholds`)}),(0,K.jsxs)(`span`,{className:`text-white font-mono`,children:[x.thresholds.low.toFixed(2),` / `,x.thresholds.high.toFixed(2)]})]}),x.last_error&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 text-red-400`,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`break-words`,children:x.last_error})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-bambu-gray mb-1`,children:e(`failureDetection.activePrinters`)}),Object.keys(x.per_printer).length===0?(0,K.jsx)(`div`,{className:`text-bambu-gray italic text-xs`,children:e(`failureDetection.noActivePrints`)}):(0,K.jsx)(`div`,{className:`space-y-1`,children:Object.entries(x.per_printer).map(([e,t])=>{let n=C?.find(t=>String(t.id)===e),r=t.class===`failure`?`text-red-400`:t.class===`warning`?`text-amber-400`:`text-green-400`;return(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:n?.name??`Printer ${e}`}),(0,K.jsxs)(`span`,{className:`font-mono ${r}`,children:[t.class,` (`,t.score.toFixed(3),`, `,t.frame_count,`f)`]})]},e)})})]})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:e(`common.loading`)})]})})]}),(0,K.jsxs)(_d,{id:`card-fd-history`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`failureDetection.historyTitle`)}),(0,K.jsx)(`button`,{onClick:()=>S(),className:`text-xs text-bambu-gray hover:text-white`,children:e(`common.refresh`)})]})}),(0,K.jsx)(yd,{children:!x||x.history.length===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:e(`failureDetection.noHistory`)})]}):(0,K.jsx)(`div`,{className:`space-y-1 max-h-96 overflow-y-auto text-xs font-mono`,children:x.history.map((e,t)=>{let n=C?.find(t=>t.id===e.printer_id),r=e.class===`failure`?`text-red-400`:e.class===`warning`?`text-amber-400`:`text-bambu-gray`;return(0,K.jsxs)(`div`,{className:`flex justify-between gap-2 py-1 border-b border-gray-800`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:new Date(e.timestamp).toLocaleTimeString()}),(0,K.jsx)(`span`,{className:`text-white truncate`,children:n?.name??`#${e.printer_id}`}),(0,K.jsxs)(`span`,{className:r,children:[e.class,` `,e.score.toFixed(3)]})]},t)})})})]})]})]})}var LHe={starttls:587,ssl:465,none:25},RHe={587:`starttls`,465:`ssl`,25:`none`};function zHe(){let{t:e}=W(),{showToast:t}=Td(),n=no(),[r,i]=(0,y.useState)({smtp_host:``,smtp_port:587,smtp_username:``,smtp_password:``,smtp_security:`starttls`,smtp_auth_enabled:!0,smtp_from_email:``,smtp_from_name:`BamBuddy`}),[a,o]=(0,y.useState)(``),{data:s,isLoading:c}=q({queryKey:[`smtpSettings`],queryFn:()=>Q.getSMTPSettings()}),{authEnabled:l}=dd(),{data:u}=q({queryKey:[`advancedAuthStatus`],queryFn:()=>Q.getAdvancedAuthStatus()});(0,y.useEffect)(()=>{s&&i({...s,smtp_password:``})},[s]);let d=e=>{i({...r,smtp_security:e,smtp_port:LHe[e]})},f=e=>{let t=RHe[e];i({...r,smtp_port:e,...t?{smtp_security:t}:{}})},p=e=>{i({...r,smtp_auth_enabled:e,...e?{}:{smtp_username:``,smtp_password:``}})},m=J({mutationFn:e=>Q.saveSMTPSettings(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`smtpSettings`]}),n.invalidateQueries({queryKey:[`advancedAuthStatus`]}),t(e(`settings.email.success.settingsSaved`),`success`)},onError:e=>{t(e.message,`error`)}}),h=J({mutationFn:e=>Q.testSMTP(e),onSuccess:e=>{t(e.message,e.success?`success`:`error`)},onError:e=>{t(e.message,`error`)}}),g=J({mutationFn:e=>e?Q.enableAdvancedAuth():Q.disableAdvancedAuth(),onSuccess:e=>{n.invalidateQueries({queryKey:[`advancedAuthStatus`]}),t(e.message,`success`)},onError:e=>{t(e.message,`error`)}}),_=()=>{if(!r.smtp_host||!r.smtp_from_email){t(e(`settings.email.errors.requiredFields`),`error`);return}if(r.smtp_auth_enabled&&!r.smtp_username){t(e(`settings.email.errors.usernameRequired`),`error`);return}m.mutate(r)},v=()=>{if(!a){t(e(`settings.email.errors.enterTestEmail`),`error`);return}h.mutate({test_recipient:a})},b=()=>{if(!l){t(e(`settings.email.errors.enableAuthFirst`),`error`);return}if(!u?.advanced_auth_enabled&&!u?.smtp_configured){t(e(`settings.email.errors.configureSmtpFirst`),`error`);return}g.mutate(!u?.advanced_auth_enabled)};if(c)return(0,K.jsx)(`div`,{className:`flex items-center justify-center p-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});let x=u?.advanced_auth_enabled??!1,S=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,C=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white/40 placeholder-bambu-gray/40 cursor-not-allowed`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-email-advanced-auth`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.advancedAuth`)||`Advanced Authentication`})]}),(0,K.jsx)($,{onClick:b,disabled:g.isPending,variant:x?`danger`:`primary`,children:x?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),e(`settings.email.disable`)||`Disable`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),e(`settings.email.enable`)||`Enable`]})})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:x?(0,K.jsx)(`div`,{className:`bg-green-500/10 border border-green-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-green-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.email.advancedAuthEnabled`)||`Advanced Authentication is enabled`}),(0,K.jsxs)(`ul`,{className:`text-sm text-green-300 space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`settings.email.feature1`)||`Passwords are auto-generated and emailed to new users`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature2`)||`Users can login with username or email`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature3`)||`Forgot password feature is available`}),(0,K.jsx)(`li`,{children:e(`settings.email.feature4`)||`Admins can reset user passwords via email`})]})]})]})}):(0,K.jsx)(`div`,{className:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.email.advancedAuthDisabled`)||`Advanced Authentication is disabled`}),(0,K.jsx)(`p`,{className:`text-sm text-yellow-300`,children:e(`settings.email.advancedAuthDisabledDesc`)||`Enable advanced authentication to activate email-based features for user management.`})]})]})})})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,K.jsx)(`div`,{className:`lg:col-span-2`,children:(0,K.jsxs)(_d,{id:`card-smtp-config`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.smtpSettings`)||`SMTP Configuration`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.authentication`)||`Authentication`}),(0,K.jsxs)(`select`,{value:r.smtp_auth_enabled?`true`:`false`,onChange:e=>p(e.target.value===`true`),className:S,children:[(0,K.jsx)(`option`,{value:`true`,children:e(`settings.email.authOptions.enabled`)}),(0,K.jsx)(`option`,{value:`false`,children:e(`settings.email.authOptions.disabled`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 transition-opacity ${r.smtp_auth_enabled?``:`opacity-40 pointer-events-none`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.username`)||`Username`}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_username||``,onChange:e=>i({...r,smtp_username:e.target.value}),placeholder:`your.email@gmail.com`,disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?S:C})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.password`)||`Password`}),(0,K.jsx)(`input`,{type:`password`,value:r.smtp_password||``,onChange:e=>i({...r,smtp_password:e.target.value}),placeholder:s?`••••••••`:`App password`,disabled:!r.smtp_auth_enabled,className:r.smtp_auth_enabled?S:C})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:[e(`settings.email.smtpHost`)||`SMTP Server`,` *`]}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_host,onChange:e=>i({...r,smtp_host:e.target.value}),placeholder:`smtp.gmail.com`,className:S})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.smtpPort`)||`SMTP Port`}),(0,K.jsx)(`input`,{type:`number`,value:r.smtp_port,onChange:e=>f(parseInt(e.target.value)||587),placeholder:`587`,className:S})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.security`)||`Security`}),(0,K.jsxs)(`select`,{value:r.smtp_security,onChange:e=>d(e.target.value),className:S,children:[(0,K.jsx)(`option`,{value:`starttls`,children:e(`settings.email.securityOptions.starttls`)}),(0,K.jsx)(`option`,{value:`ssl`,children:e(`settings.email.securityOptions.ssl`)}),(0,K.jsx)(`option`,{value:`none`,children:e(`settings.email.securityOptions.none`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:[e(`settings.email.fromEmail`)||`From Email`,` *`]}),(0,K.jsx)(`input`,{type:`email`,value:r.smtp_from_email,onChange:e=>i({...r,smtp_from_email:e.target.value}),placeholder:`your@email.com`,className:S})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.fromName`)||`From Name`}),(0,K.jsx)(`input`,{type:`text`,value:r.smtp_from_name,onChange:e=>i({...r,smtp_from_name:e.target.value}),placeholder:`BamBuddy`,className:S})]})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsx)($,{onClick:_,disabled:m.isPending,className:`flex-1`,children:m.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),e(`settings.email.saving`)||`Saving...`]}):e(`settings.email.save`)||`Save Settings`})})]})})]})}),(0,K.jsx)(`div`,{children:(0,K.jsxs)(_d,{id:`card-email-test`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.email.testConnection`)||`Test SMTP Connection`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:e(`settings.email.testRecipient`)||`Test Recipient Email`}),(0,K.jsx)(`input`,{type:`email`,value:a,onChange:e=>o(e.target.value),placeholder:`test@example.com`,className:S})]}),(0,K.jsx)($,{onClick:v,disabled:h.isPending,variant:`secondary`,children:h.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),e(`settings.email.sending`)||`Sending...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(zl,{className:`w-4 h-4`}),e(`settings.email.sendTest`)||`Send Test Email`]})})]})})]})})]})]})}var BHe={starttls:`389`,ldaps:`636`};function VHe(){let{t:e}=W(),{showToast:t}=Td(),n=no(),{authEnabled:r}=dd(),[i,a]=(0,y.useState)({ldap_server_url:``,ldap_bind_dn:``,ldap_bind_password:``,ldap_search_base:``,ldap_user_filter:`(sAMAccountName={username})`,ldap_security:`starttls`,ldap_group_mapping:``,ldap_auto_provision:!1,ldap_default_group:``}),{data:o,isLoading:s}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),{data:c}=q({queryKey:[`ldapStatus`],queryFn:()=>Q.getLDAPStatus()}),{data:l=[]}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups()});(0,y.useEffect)(()=>{o&&a({ldap_server_url:o.ldap_server_url||``,ldap_bind_dn:o.ldap_bind_dn||``,ldap_bind_password:``,ldap_search_base:o.ldap_search_base||``,ldap_user_filter:o.ldap_user_filter||`(sAMAccountName={username})`,ldap_security:o.ldap_security||`starttls`,ldap_group_mapping:o.ldap_group_mapping||``,ldap_auto_provision:o.ldap_auto_provision??!1,ldap_default_group:o.ldap_default_group||``})},[o]);let u=J({mutationFn:e=>Q.updateSettings(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`settings`]}),n.invalidateQueries({queryKey:[`ldapStatus`]}),t(e(`settings.ldap.settingsSaved`)||`LDAP settings saved`,`success`)},onError:e=>{t(e.message,`error`)}}),d=J({mutationFn:e=>Q.updateSettings({ldap_enabled:e}),onSuccess:()=>{n.invalidateQueries({queryKey:[`settings`]}),n.invalidateQueries({queryKey:[`ldapStatus`]}),t(c?.ldap_enabled?e(`settings.ldap.disabled`)||`LDAP authentication disabled`:e(`settings.ldap.enabled`)||`LDAP authentication enabled`,`success`)},onError:e=>{t(e.message,`error`)}}),f=J({mutationFn:()=>Q.testLDAP(),onSuccess:e=>{t(e.message,e.success?`success`:`error`)},onError:e=>{t(e.message,`error`)}}),p=()=>{if(!i.ldap_server_url){t(e(`settings.ldap.errors.serverRequired`)||`LDAP server URL is required`,`error`);return}if(!i.ldap_search_base){t(e(`settings.ldap.errors.searchBaseRequired`)||`Search base DN is required`,`error`);return}let n={ldap_server_url:i.ldap_server_url,ldap_bind_dn:i.ldap_bind_dn,ldap_search_base:i.ldap_search_base,ldap_user_filter:i.ldap_user_filter,ldap_security:i.ldap_security,ldap_group_mapping:i.ldap_group_mapping,ldap_auto_provision:i.ldap_auto_provision,ldap_default_group:i.ldap_default_group};i.ldap_bind_password&&(n.ldap_bind_password=i.ldap_bind_password),u.mutate(n)},m=()=>{if(!r){t(e(`settings.ldap.errors.enableAuthFirst`)||`Enable authentication first`,`error`);return}if(!c?.ldap_enabled&&!c?.ldap_configured){t(e(`settings.ldap.errors.configureLdapFirst`)||`Save LDAP settings first`,`error`);return}d.mutate(!c?.ldap_enabled)};if(s)return(0,K.jsx)(`div`,{className:`flex items-center justify-center p-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});let h=c?.ldap_enabled??!1,g=`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`;return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-ldap-toggle`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.ldap.title`)||`LDAP Authentication`})]}),(0,K.jsx)($,{onClick:m,disabled:d.isPending,variant:h?`danger`:`primary`,children:h?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),e(`common.disable`)||`Disable`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),e(`common.enable`)||`Enable`]})})]})}),(0,K.jsx)(yd,{children:h?(0,K.jsx)(`div`,{className:`bg-green-500/10 border border-green-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-green-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.ldap.enabledDesc`)||`LDAP authentication is enabled`}),(0,K.jsxs)(`ul`,{className:`text-sm text-green-300 space-y-1 list-disc list-inside`,children:[(0,K.jsx)(`li`,{children:e(`settings.ldap.feature1`)||`Users can login with LDAP credentials`}),(0,K.jsx)(`li`,{children:e(`settings.ldap.feature2`)||`Local admin account remains as fallback`}),(0,K.jsx)(`li`,{children:e(`settings.ldap.feature3`)||`LDAP groups are mapped to BamBuddy groups on login`})]})]})]})}):(0,K.jsx)(`div`,{className:`bg-yellow-500/10 border border-yellow-500/30 rounded-lg p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`settings.ldap.disabledDesc`)||`LDAP authentication is disabled`}),(0,K.jsx)(`p`,{className:`text-sm text-yellow-300 mt-1`,children:e(`settings.ldap.disabledHint`)||`Configure and save LDAP settings below, then enable.`})]})]})})})]}),(0,K.jsxs)(_d,{id:`card-ldap-server`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`settings.ldap.serverConfig`)||`LDAP Server Configuration`})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{className:`md:col-span-2`,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.serverUrl`)||`Server URL`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`ldaps://ldap.example.com:636`,value:i.ldap_server_url,onChange:e=>a({...i,ldap_server_url:e.target.value})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.serverUrlHint`)||`Use ldaps:// for SSL or ldap:// with StartTLS`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.security`)||`Security`}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:[`starttls`,`ldaps`].map(e=>(0,K.jsx)(`button`,{onClick:()=>a({...i,ldap_security:e}),className:`flex-1 px-2 py-2 rounded-lg text-sm font-medium transition-colors ${i.ldap_security===e?`bg-bambu-green text-black`:`bg-bambu-dark-secondary text-bambu-gray hover:text-white border border-bambu-dark-tertiary`}`,children:e===`starttls`?`StartTLS`:`LDAPS`},e))}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.securityHint`)||`Default port: ${BHe[i.ldap_security]}`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.bindDn`)||`Bind DN (Service Account)`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`cn=service-account,ou=service,dc=example,dc=com`,value:i.ldap_bind_dn,onChange:e=>a({...i,ldap_bind_dn:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.bindPassword`)||`Bind Password`}),(0,K.jsx)(`input`,{type:`password`,className:g,placeholder:o?.ldap_bind_dn?`••••••••`:``,value:i.ldap_bind_password,onChange:e=>a({...i,ldap_bind_password:e.target.value})})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.searchBase`)||`Search Base DN`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`ou=users,dc=example,dc=com`,value:i.ldap_search_base,onChange:e=>a({...i,ldap_search_base:e.target.value})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.userFilter`)||`User Search Filter`}),(0,K.jsx)(`input`,{type:`text`,className:g,placeholder:`(sAMAccountName={username})`,value:i.ldap_user_filter,onChange:e=>a({...i,ldap_user_filter:e.target.value})})]})]}),(0,K.jsx)(lp,{summary:(0,K.jsx)(`span`,{className:`text-sm font-medium text-bambu-gray`,children:e(`settings.ldap.advanced`)||`Advanced`}),className:`border-t border-bambu-dark-tertiary pt-3`,summaryClassName:`py-1`,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white`,children:e(`settings.ldap.autoProvision`)||`Auto-provision users`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e(`settings.ldap.autoProvisionHint`)||`Automatically create a BamBuddy account on first LDAP login`})]}),(0,K.jsx)(`button`,{onClick:()=>a({...i,ldap_auto_provision:!i.ldap_auto_provision}),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors flex-shrink-0 ${i.ldap_auto_provision?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i.ldap_auto_provision?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.defaultGroup`)||`Default group`}),(0,K.jsxs)(`select`,{className:g,value:i.ldap_default_group,onChange:e=>a({...i,ldap_default_group:e.target.value}),children:[(0,K.jsx)(`option`,{value:``,children:e(`settings.ldap.defaultGroupNone`)||`— None (reject login) —`}),l.map(e=>(0,K.jsx)(`option`,{value:e.name,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`settings.ldap.defaultGroupHint`)||`Fallback group assigned when an LDAP user authenticates but is not listed in any mapped group. Leave empty to leave unmapped users without permissions.`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:e(`settings.ldap.groupMapping`)||`Group Mapping (JSON)`}),(0,K.jsx)(`textarea`,{className:`${g} font-mono text-sm`,rows:4,placeholder:`{ "CN=PrintFarm_Admins,OU=Groups,DC=example,DC=com": "Administrators", "CN=PrintFarm_Users,OU=Groups,DC=example,DC=com": "Operators" }`,value:i.ldap_group_mapping,onChange:e=>a({...i,ldap_group_mapping:e.target.value})}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[e(`settings.ldap.groupMappingHint`)||`Map LDAP group DNs to BamBuddy groups. Available groups: `,l.map(e=>e.name).join(`, `)]})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsxs)($,{onClick:p,disabled:u.isPending,children:[u.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(ps,{className:`w-4 h-4`}),e(`common.save`)||`Save`]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>f.mutate(),disabled:f.isPending,children:[f.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),e(`settings.ldap.testConnection`)||`Test Connection`]})]})]})})]})]})}function e6({value:e,onChange:t,placeholder:n,maxLength:r=6}){return(0,K.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value.toUpperCase().replace(/\s/g,``)),maxLength:r,className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors font-mono tracking-widest text-center`,placeholder:n,autoComplete:`one-time-code`})}function t6({codes:e,onDone:t}){let{t:n}=W(),[r,i]=(0,y.useState)(!1);return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`div`,{className:`bg-amber-500/10 border border-amber-500/30 rounded-lg p-4`,children:(0,K.jsx)(`p`,{className:`text-amber-400 text-sm font-medium`,children:n(`settings.twoFa.backupCodesWarning`)})}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:e.map((e,t)=>(0,K.jsx)(`code`,{className:`bg-bambu-dark-secondary rounded px-3 py-2 text-center font-mono text-sm text-white tracking-widest`,children:e},t))}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(e.join(` -`)),i(!0),setTimeout(()=>i(!1),2e3)},className:`flex items-center gap-2`,children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),n(r?`common.copied`:`common.copy`)]}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:t,className:`flex-1`,children:n(`settings.twoFa.savedCodes`)})]})]})}function HHe({onDone:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(`qr`),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(!1),{data:f,isLoading:p}=q({queryKey:[`totp-setup`],queryFn:()=>Q.setupTOTP(),staleTime:1/0}),m=J({mutationFn:e=>Q.enableTOTP(e),onSuccess:e=>{l(e.backup_codes),a(`backup`),n.invalidateQueries({queryKey:[`2fa-status`]})},onError:()=>r(t(`settings.twoFa.invalidCode`),`error`)});return p||!f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})}):i===`qr`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.setupInstructions`)}),(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(`img`,{src:`data:image/png;base64,${f.qr_code_b64}`,alt:`TOTP QR Code`,className:`w-48 h-48 rounded-lg`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:t(`settings.twoFa.manualEntry`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark-secondary rounded-lg px-3 py-2`,children:[(0,K.jsx)(`code`,{className:`text-white text-xs font-mono flex-1 break-all`,children:u?f.secret:`••••••••••••••••`}),(0,K.jsx)(`button`,{onClick:()=>d(!u),className:`text-bambu-gray hover:text-white`,children:u?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(f.secret)},className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})]}),(0,K.jsx)($,{variant:`primary`,className:`w-full`,onClick:()=>a(`confirm`),children:t(`settings.twoFa.scannedContinue`)})]}):i===`confirm`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.enterCodeToConfirm`)}),(0,K.jsx)(e6,{value:o,onChange:s,placeholder:`000000`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>a(`qr`),className:`flex-1`,children:t(`common.back`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:o.length!==6||m.isPending,onClick:()=>m.mutate(o),children:m.isPending?t(`common.saving`):t(`settings.twoFa.activate`)})]})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:t(`settings.twoFa.backupCodesTitle`)}),(0,K.jsx)(t6,{codes:c,onDone:e})]})}function UHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{user:r}=dd(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(``),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)(!1),{data:D,isLoading:O}=q({queryKey:[`2fa-status`],queryFn:()=>Q.get2FAStatus()}),{data:k}=q({queryKey:[`oidc-links`],queryFn:()=>Q.getOIDCLinks()}),A=J({mutationFn:()=>Q.enableEmailOTP(),onSuccess:e=>{_(e.setup_token),n(e.message,`success`)},onError:t=>{let r=t.message??``;r.toLowerCase().includes(`smtp`)?n(e(`settings.twoFa.smtpRequired`),`error`):n(r,`error`)}}),j=J({mutationFn:()=>Q.confirmEnableEmailOTP(g,v),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),_(null),b(``),n(e(`settings.twoFa.emailOtpEnabled`),`success`)},onError:e=>n(e.message,`error`)}),M=J({mutationFn:e=>Q.disableEmailOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),S(!1),w(``),n(e(`settings.twoFa.emailOtpDisabled`),`success`)},onError:e=>n(e.message,`error`)}),N=J({mutationFn:e=>Q.disableTOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),s(!1),d(``),n(e(`settings.twoFa.totpDisabled`),`success`)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),P=J({mutationFn:e=>Q.regenerateBackupCodes(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`2fa-status`]}),l(!1),p(``),h(e.backup_codes)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),F=J({mutationFn:e=>Q.deleteOIDCLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-links`]}),n(e(`settings.twoFa.oidcUnlinked`),`success`)},onError:e=>n(e.message,`error`)});if(O)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})});let I=!!r?.email;return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-2fa-totp`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.totp_enabled?`bg-green-500/20`:`bg-gray-500/20`}`,children:(0,K.jsx)(eu,{className:`w-5 h-5 ${D?.totp_enabled?`text-green-400`:`text-gray-400`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.totpTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.totpDesc`)})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:D?.totp_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400 text-sm font-medium`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,K.jsx)(Kl,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,K.jsx)(yd,{children:i?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.setupAuthApp`)}),(0,K.jsx)(`button`,{onClick:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})},className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(HHe,{onDone:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})}})]}):o?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.disableConfirmHint`)}),(0,K.jsx)(e6,{value:u,onChange:d,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{s(!1),d(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,className:`flex-1`,disabled:u.length<6||N.isPending,onClick:()=>N.mutate(u),children:N.isPending?e(`common.saving`):e(`settings.twoFa.disableTotp`)})]})]}):c?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.regenBackupHint`)}),(0,K.jsx)(e6,{value:f,onChange:p,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{l(!1),p(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:f.length<6||P.isPending,onClick:()=>P.mutate(f),children:P.isPending?e(`common.saving`):e(`settings.twoFa.regenBackup`)})]})]}):m?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.newBackupCodes`)}),(0,K.jsx)(t6,{codes:m,onDone:()=>h(null)})]}):(0,K.jsx)(`div`,{className:`space-y-3`,children:D?.totp_enabled?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray-light`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),e(`settings.twoFa.backupCodesRemaining`,{count:D.backup_codes_remaining})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>l(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`settings.twoFa.regenBackup`)]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>s(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.twoFa.disableTotp`)]})]}):(0,K.jsxs)($,{variant:`primary`,onClick:()=>a(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(eu,{className:`w-4 h-4`}),e(`settings.twoFa.setupTotp`)]})})})]}),(0,K.jsxs)(_d,{id:`card-2fa-emailotp`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.email_otp_enabled?`bg-green-500/20`:`bg-gray-500/20`}`,children:(0,K.jsx)(Xc,{className:`w-5 h-5 ${D?.email_otp_enabled?`text-green-400`:`text-gray-400`}`})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.emailOtpTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:I?e(`settings.twoFa.emailOtpDesc`,{email:r?.email}):e(`settings.twoFa.emailOtpNoEmail`)})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:D?.email_otp_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400 text-sm font-medium`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,K.jsx)(Kl,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,K.jsx)(yd,{children:I?g?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailSetupEnterCode`)}),(0,K.jsx)(e6,{value:v,onChange:b,placeholder:`000000`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{_(null),b(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:v.length!==6||j.isPending,onClick:()=>j.mutate(),children:j.isPending?e(`common.saving`):e(`settings.twoFa.verifyAndEnable`)})]})]}):x?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailDisablePasswordHint`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:T?`text`:`password`,value:C,onChange:e=>w(e.target.value),placeholder:e(`settings.twoFa.passwordPlaceholder`),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>E(!T),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:T?(0,K.jsx)(Ys,{className:`w-5 h-5`}):(0,K.jsx)(Xs,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{S(!1),w(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,className:`flex-1`,disabled:!C||M.isPending,onClick:()=>M.mutate(C),children:M.isPending?e(`common.saving`):e(`settings.twoFa.disableEmailOtp`)})]})]}):(0,K.jsx)(`div`,{className:`flex gap-3`,children:D?.email_otp_enabled?(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>S(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.twoFa.disableEmailOtp`)]}):(0,K.jsxs)($,{variant:`primary`,disabled:!I||A.isPending,onClick:()=>A.mutate(),className:`flex items-center gap-2`,children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),A.isPending?e(`common.saving`):e(`settings.twoFa.enableEmailOtp`)]})}):(0,K.jsx)(`p`,{className:`text-amber-400 text-sm`,children:e(`settings.twoFa.addEmailFirst`)})})]}),k&&k.length>0&&(0,K.jsxs)(_d,{id:`card-2fa-linked`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.linkedAccounts`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.linkedAccountsDesc`)})]}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:k.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-2 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:e.provider_name}),e.provider_email&&(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:e.provider_email})]}),(0,K.jsx)($,{variant:`danger`,size:`sm`,onClick:()=>F.mutate(e.provider_id),disabled:F.isPending,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]},e.id))})})]})]})}var WHe={name:``,issuer_url:``,client_id:``,client_secret:``,scopes:`openid email profile`,is_enabled:!0,auto_create_users:!1,auto_link_existing_accounts:!1,email_claim:`email`,require_email_verified:!0,icon_url:void 0,default_group_id:null};function n6({initial:e,isEdit:t=!1,groups:n=[],onSave:r,onCancel:i,isPending:a}){let{t:o}=W(),[s,c]=(0,y.useState)(e),[l,u]=(0,y.useState)(!1),d=(e,t)=>c(n=>({...n,[e]:t})),f=`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors text-sm`,p=`block text-sm font-medium text-white mb-1`,m=()=>{let e={...s};t&&!l&&delete e.client_secret,r(e)},h=s.auto_link_existing_accounts===!0,g=s.require_email_verified??!0,_;return _=h?o(`settings.oidc.form.requireEmailVerifiedAutoLink`):g?o(`settings.oidc.form.requireEmailVerifiedDesc`):(0,K.jsx)(`span`,{className:`text-red-400`,children:o(`settings.oidc.form.requireEmailVerifiedWarning`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.name`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.name,onChange:e=>d(`name`,e.target.value),placeholder:`Google`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.issuerUrl`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.issuer_url,onChange:e=>d(`issuer_url`,e.target.value),placeholder:`https://accounts.google.com`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientId`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.client_id,onChange:e=>d(`client_id`,e.target.value),placeholder:`your-client-id`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientSecret`),!t&&(0,K.jsx)(`span`,{className:`text-red-400`,children:` *`}),t&&(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs ml-1`,children:[`(`,o(`settings.oidc.form.secretHint`),`)`]})]}),(0,K.jsx)(`input`,{className:f,type:`password`,value:l?s.client_secret:``,placeholder:t&&!l?`••••••••`:o(`settings.oidc.form.secretPlaceholder`),onChange:e=>{u(!0),d(`client_secret`,e.target.value)}})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.scopes`)}),(0,K.jsx)(`input`,{className:f,value:s.scopes,onChange:e=>d(`scopes`,e.target.value),placeholder:`openid email profile`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.iconUrl`)}),(0,K.jsx)(`input`,{className:f,value:s.icon_url??``,onChange:e=>d(`icon_url`,e.target.value===``?null:e.target.value),placeholder:`https://...`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-6 pt-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(cU,{checked:s.is_enabled??!0,onChange:e=>d(`is_enabled`,e)}),(0,K.jsx)(`span`,{className:`text-white text-sm`,children:o(`settings.oidc.form.enabled`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(cU,{checked:s.auto_create_users??!1,onChange:e=>d(`auto_create_users`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoCreate`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoCreateDesc`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,K.jsx)(cU,{checked:s.auto_link_existing_accounts??!1,onChange:e=>d(`auto_link_existing_accounts`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoLink`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoLinkDesc`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,K.jsx)(cU,{checked:g,onChange:e=>d(`require_email_verified`,e),disabled:h}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.requireEmailVerified`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:_})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.emailClaim`)}),(0,K.jsx)(`input`,{className:f,value:s.email_claim,onChange:e=>d(`email_claim`,e.target.value||`email`),placeholder:o(`settings.oidc.form.emailClaimPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.emailClaimDesc`)}),h&&s.email_claim!==`email`&&(0,K.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:o(`settings.oidc.form.emailClaimCustomClaimAutoLinkWarning`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.defaultGroup`)}),(0,K.jsxs)(`select`,{className:f,value:s.default_group_id??``,onChange:e=>d(`default_group_id`,e.target.value?Number(e.target.value):null),children:[(0,K.jsx)(`option`,{value:``,children:o(`settings.oidc.form.defaultGroupViewersFallback`)}),n.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.defaultGroupDesc`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:i,className:`flex-1`,children:o(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:!s.name||!s.issuer_url||!s.client_id||!t&&!s.client_secret||t&&l&&!s.client_secret||a,onClick:m,children:o(a?`common.saving`:`common.save`)})]})]})}function GHe({provider:e}){let[t,n]=(0,y.useState)(!1);return e.has_icon&&!t?(0,K.jsx)(`img`,{src:Q.oidcProviderIconUrl(e.id),alt:e.name,className:`w-8 h-8 rounded object-contain`,onError:()=>n(!0)}):(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(bc,{className:`w-4 h-4 text-bambu-gray`})})}function KHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),{data:l,isLoading:u}=q({queryKey:[`oidc-providers-all`],queryFn:()=>Q.getOIDCProvidersAll()}),{data:d=[]}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups()}),f=J({mutationFn:e=>Q.createOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),i(!1),n(e(`settings.oidc.created`),`success`)},onError:e=>n(e.message,`error`)}),p=J({mutationFn:({id:e,data:t})=>Q.updateOIDCProvider(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),o(null),n(e(`settings.oidc.updated`),`success`)},onError:e=>n(e.message,`error`)}),m=J({mutationFn:e=>Q.deleteOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),c(null),n(e(`settings.oidc.deleted`),`success`)},onError:e=>n(e.message,`error`)}),h=J({mutationFn:e=>Q.refreshOIDCProviderIcon(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),t.invalidateQueries({queryKey:[`oidc-providers`]}),n(e(`settings.oidc.iconRefreshed`),`success`)},onError:t=>n(t.message||e(`settings.oidc.iconFetchFailed`),`error`)}),g=J({mutationFn:e=>Q.deleteOIDCProviderIcon(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),t.invalidateQueries({queryKey:[`oidc-providers`]}),n(e(`settings.oidc.iconRemoved`),`success`)},onError:e=>n(e.message,`error`)}),_=e=>p.mutate({id:e.id,data:{is_enabled:!e.is_enabled}});return u?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-oidc`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.oidc.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.oidc.desc`)})]}),!r&&(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})}),r&&(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium mb-4`,children:e(`settings.oidc.newProvider`)}),(0,K.jsx)(n6,{initial:WHe,groups:d,onSave:e=>f.mutate(e),onCancel:()=>i(!1),isPending:f.isPending})]})})]}),l&&l.length===0&&!r&&(0,K.jsx)(_d,{id:`card-oidc-empty`,children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`text-center py-8 space-y-3`,children:[(0,K.jsx)(bc,{className:`w-12 h-12 text-bambu-gray mx-auto`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.oidc.empty`)}),(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})})}),l?.map(t=>(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(GHe,{provider:t}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:t.name}),t.is_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-400 bg-green-400/10 px-2 py-0.5 rounded-full`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-0.5 rounded-full`,children:[(0,K.jsx)(Ru,{className:`w-3 h-3`}),` `,e(`common.disabled`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-bambu-gray text-xs mt-0.5`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:t.issuer_url})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.icon_url&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>h.mutate(t.id),disabled:h.isPending,title:e(`settings.oidc.refreshIcon`),"data-testid":`refresh-icon-${t.id}`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h.isPending?`animate-spin`:``}`})}),t.has_icon&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>g.mutate(t.id),disabled:g.isPending,title:e(`settings.oidc.removeIcon`),"data-testid":`remove-icon-${t.id}`,children:(0,K.jsx)(jc,{className:`w-4 h-4`})}),(0,K.jsx)(cU,{checked:t.is_enabled,onChange:()=>_(t),disabled:p.isPending}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>o(a===t.id?null:t.id),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`danger`,size:`sm`,onClick:()=>c(t),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})}),a===t.id&&(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsx)(n6,{isEdit:!0,groups:d,initial:{name:t.name,issuer_url:t.issuer_url,client_id:t.client_id,client_secret:``,scopes:t.scopes,is_enabled:t.is_enabled,auto_create_users:t.auto_create_users,auto_link_existing_accounts:t.auto_link_existing_accounts,email_claim:t.email_claim,require_email_verified:t.require_email_verified,icon_url:t.icon_url??void 0,default_group_id:t.default_group_id??null},onSave:e=>p.mutate({id:t.id,data:e}),onCancel:()=>o(null),isPending:p.isPending})})}),a!==t.id&&(0,K.jsx)(yd,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2 text-sm`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.clientId`)}),(0,K.jsx)(`dd`,{className:`text-white font-mono truncate`,children:t.client_id})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.scopes`)}),(0,K.jsx)(`dd`,{className:`text-white`,children:t.scopes})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoCreate`)}),(0,K.jsx)(`dd`,{className:t.auto_create_users?`text-green-400`:`text-bambu-gray`,children:t.auto_create_users?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoLink`)}),(0,K.jsx)(`dd`,{className:t.auto_link_existing_accounts?`text-green-400`:`text-bambu-gray`,children:t.auto_link_existing_accounts?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.emailClaim`)}),(0,K.jsx)(`dd`,{className:`text-white font-mono`,children:t.email_claim})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.requireEmailVerified`)}),(0,K.jsx)(`dd`,{className:t.require_email_verified?`text-green-400`:`text-red-400`,children:t.require_email_verified?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.defaultGroup`)}),(0,K.jsx)(`dd`,{className:`text-white`,children:t.default_group_id?d.find(e=>e.id===t.default_group_id)?.name??e(`settings.oidc.form.defaultGroupViewersFallback`):e(`settings.oidc.form.defaultGroupViewersFallback`)})]})]})})]},t.id)),s&&(0,K.jsx)(Ad,{title:e(`settings.oidc.deleteTitle`),message:e(`settings.oidc.deleteMessage`,{name:s.name}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:()=>m.mutate(s.id),onCancel:()=>c(null)})]})}var r6=new Map;function i6(e){r6.set(e.anchor,e)}function qHe(){return Array.from(r6.values())}i6({labelKey:`settings.encryption.title`,labelFallback:`MFA Encryption Status`,tab:`users`,subTab:`security`,keywords:`mfa encryption status security backup totp oidc fernet`,anchor:`card-mfa-encryption`});function JHe(){let{t:e}=W(),{data:t,isLoading:n,isError:r,refetch:i}=q({queryKey:[`encryptionStatus`],queryFn:()=>Q.getEncryptionStatus(),refetchInterval:e=>{if(!e.state.error)return 3e4;let t=e.state.fetchFailureCount??0;return t<=3?Math.min(5e3*Math.max(1,t),3e4):!1}});if(n)return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`text-bambu-gray`,size:20}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,"data-testid":`encryption-loading`,children:[(0,K.jsx)(X,{className:`animate-spin`,size:16}),(0,K.jsx)(`span`,{children:e(`common.loading`)})]})})]});if(r||!t)return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`text-bambu-gray`,size:20}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`div`,{className:`text-red-400`,"data-testid":`encryption-error`,children:e(`common.errorLoading`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`mt-2 text-sm text-blue-400 underline hover:text-blue-300`,"data-testid":`encryption-retry-button`,children:e(`common.retry`)})]})]});let a=t.legacy_plaintext_rows.oidc_providers+t.legacy_plaintext_rows.user_totp,o=t.encrypted_rows.oidc_providers+t.encrypted_rows.user_totp,s,c,l,u;t.decryption_broken?(s=`bg-red-500/20 border-red-500/50 text-red-400`,c=(0,K.jsx)(ys,{className:`text-red-400`,size:20}),l=e(`settings.encryption.decryptionBrokenTitle`),u=e(`settings.encryption.decryptionBrokenError`,{count:o})):t.key_source===`generated`?(s=`bg-amber-500/10 border-amber-500/30 text-amber-400`,c=(0,K.jsx)(Gl,{className:`text-amber-400`,size:20}),l=e(`settings.encryption.enabledGenerated`),u=e(`settings.encryption.backupHint`)):a>0?(s=`bg-amber-500/10 border-amber-500/30 text-amber-400`,c=(0,K.jsx)(Cu,{className:`text-amber-400`,size:20}),l=t.key_source===`env`?e(`settings.encryption.enabledFromEnv`):e(`settings.encryption.enabledFromFile`),u=e(`settings.encryption.legacyRowsWarning`,{count:a})):t.key_configured?(s=`bg-green-500/20 border-green-500/30 text-green-400`,c=(0,K.jsx)(Gl,{className:`text-green-400`,size:20}),l=t.key_source===`env`?e(`settings.encryption.enabledFromEnv`):e(`settings.encryption.enabledFromFile`),u=e(`settings.encryption.allEncrypted`)):(s=`bg-gray-500/20 border-gray-500/30 text-gray-400`,c=(0,K.jsx)(Kl,{className:`text-gray-400`,size:20}),l=e(`settings.encryption.notConfigured`),u=e(`settings.encryption.notConfiguredDesc`));let d=t.key_source===`generated`&&a>0;return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`p-3 border rounded-lg ${s}`,"data-testid":`encryption-status`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:l}),(0,K.jsx)(`p`,{className:`text-sm`,children:u})]}),d&&(0,K.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-500/10 border-amber-500/30 text-amber-400`,"data-testid":`encryption-legacy-warning`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.legacyRowsWarning`,{count:a})})}),t.migration_error_count>0&&(0,K.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-500/10 border-amber-500/30 text-amber-400`,"data-testid":`encryption-migration-warning`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.migrationErrorWarning`,{count:t.migration_error_count})})}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 text-sm`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.encryptedRowsLabel`)}),(0,K.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.encrypted_rows.oidc_providers,` · TOTP: `,t.encrypted_rows.user_totp]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.legacyRowsLabel`)}),(0,K.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.legacy_plaintext_rows.oidc_providers,` · TOTP: `,t.legacy_plaintext_rows.user_totp]})]})]})]})]})}var YHe={get:`bg-blue-500/20 text-blue-400 border-blue-500/30`,post:`bg-green-500/20 text-green-400 border-green-500/30`,put:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,patch:`bg-orange-500/20 text-orange-400 border-orange-500/30`,delete:`bg-red-500/20 text-red-400 border-red-500/30`};function XHe(e,t){let n=t.replace(`#/`,``).split(`/`),r=e;for(let e of n)r=r[e];return r}function a6(e,t,n=0){if(n>5)return`...`;if(t.$ref)return a6(e,XHe(e,t.$ref),n+1);if(t.allOf){let r={};for(let i of t.allOf){let t=a6(e,i,n+1);typeof t==`object`&&t&&Object.assign(r,t)}return r}if(t.example!==void 0)return t.example;if(t.default!==void 0)return t.default;switch(t.type){case`string`:return t.enum?t.enum[0]:`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;case`array`:return t.items?[a6(e,t.items,n+1)]:[];case`object`:if(t.properties){let r={};for(let[i,a]of Object.entries(t.properties))r[i]=a6(e,a,n+1);return r}return{};default:return null}}function ZHe({path:e,method:t,spec:n,schema:r,apiKey:i}){let[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)({}),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(a&&n.parameters){let e={};for(let t of n.parameters)t.schema?.default!==void 0&&(e[t.name]=String(t.schema.default));c(t=>({...e,...t}))}},[a,n.parameters]),(0,y.useEffect)(()=>{if(a&&n.requestBody?.content?.[`application/json`]?.schema&&!l){let e=n.requestBody.content[`application/json`].schema,t=a6(r,e);u(JSON.stringify(t,null,2))}},[a,n.requestBody,r,l]);let _=(()=>{let e=[];for(let t of n.parameters||[])if(t.in===`path`||t.required){let n=s[t.name];(n===void 0||n===``)&&e.push(t.name)}return e})(),v=async()=>{if(_.length>0){f({status:0,statusText:`Validation Error`,headers:{},body:`Missing required parameters: ${_.join(`, `)}`,duration:0});return}m(!0),f(null);try{let r=e,a=new URLSearchParams;for(let e of n.parameters||[]){let t=s[e.name];t!==void 0&&t!==``&&(e.in===`path`?r=r.replace(`{${e.name}}`,encodeURIComponent(t)):e.in===`query`&&a.append(e.name,t))}let o=a.toString(),c=`${r}${o?`?${o}`:``}`,u={"Content-Type":`application/json`};i&&(u[`X-API-Key`]=i);let d={method:t.toUpperCase(),headers:u};[`post`,`put`,`patch`].includes(t)&&l&&(d.body=l);let p=performance.now(),m=await fetch(c,d),h=Math.round(performance.now()-p),g={};m.headers.forEach((e,t)=>{g[t]=e});let _;_=m.headers.get(`content-type`)?.includes(`application/json`)?await m.json():await m.text(),f({status:m.status,statusText:m.statusText,headers:g,body:_,duration:h})}catch(e){f({status:0,statusText:`Network Error`,headers:{},body:e instanceof Error?e.message:`Unknown error`,duration:0})}finally{m(!1)}},b=async()=>{if(d){let e=typeof d.body==`string`?d.body:JSON.stringify(d.body,null,2);try{await navigator.clipboard.writeText(e),g(!0),setTimeout(()=>g(!1),2e3)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-999999px`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),g(!0),setTimeout(()=>g(!1),2e3)}}},x=(n.parameters||[]).filter(e=>e.in===`path`),S=(n.parameters||[]).filter(e=>e.in===`query`),C=[`post`,`put`,`patch`].includes(t)&&n.requestBody;return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>o(!a),className:`w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left`,children:[a?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${YHe[t]||`bg-gray-500/20 text-gray-400`}`,children:t}),(0,K.jsx)(`code`,{className:`text-sm text-white font-mono flex-1 truncate`,children:e}),n.summary&&(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate max-w-[40%]`,children:n.summary})]}),a&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50`,children:[n.description&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n.description}),x.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Path Parameters`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,K.jsx)(`span`,{className:`text-red-400 ml-1`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),placeholder:e.description||e.schema?.type||`value`,className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`})]},e.name))})]}),S.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Query Parameters`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,K.jsx)(`span`,{className:`text-red-400 ml-1`,children:`*`})]}),e.schema?.enum?(0,K.jsxs)(`select`,{value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:`-- Select --`}),e.schema.enum.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}):(0,K.jsx)(`input`,{type:`text`,value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),placeholder:e.description||e.schema?.type||`value`,className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`})]},e.name))})]}),C&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Request Body`}),(0,K.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:8,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y`,placeholder:`JSON request body...`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:v,disabled:p,children:[p?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bl,{className:`w-4 h-4`}),`Execute`]}),_.length>0&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Fill in: `,_.join(`, `)]})]}),d&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[`Response`,(0,K.jsxs)(`span`,{className:`px-2 py-0.5 text-xs rounded ${d.status>=200&&d.status<300?`bg-green-500/20 text-green-400`:d.status>=400?`bg-red-500/20 text-red-400`:`bg-yellow-500/20 text-yellow-400`}`,children:[d.status,` `,d.statusText]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[d.duration,`ms`]})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:b,children:h?(0,K.jsx)(ps,{className:`w-3 h-3 text-green-400`}):(0,K.jsx)(Ms,{className:`w-3 h-3`})})]}),(0,K.jsx)(`pre`,{className:`p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary`,children:typeof d.body==`string`?d.body:JSON.stringify(d.body,null,2)})]})]})]})}function QHe({apiKey:e=``}){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(!0),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(``);if((0,y.useEffect)(()=>{async function e(){try{let e=await fetch(`/openapi.json`);if(!e.ok)throw Error(`Failed to fetch OpenAPI schema`);n(await e.json())}catch(e){o(e instanceof Error?e.message:`Unknown error`)}finally{i(!1)}}e()},[]),r)return(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});if(a||!t)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-red-400`,children:[(0,K.jsx)(ds,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{children:`Failed to load API schema`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:a})]})})});let d={};for(let[e,n]of Object.entries(t.paths))for(let[t,r]of Object.entries(n)){if(t===`parameters`)continue;let n=r.tags||[`Other`];for(let i of n)d[i]||(d[i]=[]),d[i].push({path:e,method:t,spec:r})}let f=Object.entries(d).map(([e,t])=>l?{tag:e,endpoints:t.filter(({path:e,method:t,spec:n})=>{let r=l.toLowerCase();return e.toLowerCase().includes(r)||t.toLowerCase().includes(r)||(n.summary?.toLowerCase()||``).includes(r)||(n.description?.toLowerCase()||``).includes(r)})}:{tag:e,endpoints:t}).filter(({endpoints:e})=>e.length>0).sort((e,t)=>e.tag.localeCompare(t.tag)),p=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search endpoints...`,className:`w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set(f.map(e=>e.tag)))},children:`Expand All`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set)},children:`Collapse All`}),(0,K.jsxs)(`a`,{href:`/docs`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-sm text-bambu-green hover:underline`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`Swagger UI`]})]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[f.reduce((e,t)=>e+t.endpoints.length,0),` endpoints in `,f.length,` categories`]}),(0,K.jsx)(`div`,{className:`space-y-3`,children:f.map(({tag:n,endpoints:r})=>(0,K.jsxs)(_d,{children:[(0,K.jsx)(`button`,{onClick:()=>p(n),className:`w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.has(n)?(0,K.jsx)(is,{className:`w-5 h-5 text-bambu-gray`}):(0,K.jsx)(as,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white capitalize`,children:n.replace(/-/g,` `)}),(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray`,children:r.length})]})}),s.has(n)&&(0,K.jsx)(yd,{className:`pt-0 space-y-2`,children:r.map(({path:n,method:r,spec:i})=>(0,K.jsx)(ZHe,{path:n,method:r,spec:i,schema:t,apiKey:e},`${r}-${n}`))})]},n))})]})}var $He=[`general`,`plugs`,`notifications`,`queue`,`filament`,`network`,`apikeys`,`virtual-printer`,`spoolbuddy`,`failure-detection`,`users`,`backup`];i6({labelKey:`settings.general`,tab:`general`,keywords:`language date time format printer model printers cards`,anchor:`card-general`}),i6({labelKey:`settings.appearance`,tab:`general`,keywords:`theme dark light mode colors`,anchor:`card-appearance`}),i6({labelKey:`settings.archiveSettings`,tab:`general`,keywords:`archive auto save thumbnails captures`,anchor:`card-archive`}),i6({labelKey:`settings.camera`,tab:`general`,keywords:`camera external video stream`,anchor:`card-camera`}),i6({labelKey:`settings.costTracking`,tab:`general`,keywords:`currency filament cost energy kwh price`,anchor:`card-cost`}),i6({labelKey:`settings.fileManager`,tab:`general`,keywords:`file manager archive mode disk warning storage`,anchor:`card-filemanager`}),i6({labelKey:`settings.updates`,tab:`general`,keywords:`updates version firmware beta check`,anchor:`card-updates`}),i6({labelKey:`settings.dataManagement`,tab:`general`,keywords:`data reset clear logs notifications preferences`,anchor:`card-data`}),i6({labelKey:`settings.smartPlugs`,tab:`plugs`,keywords:`smart plug energy power automation tapo kasa tplink shelly`,anchor:`card-plugs`}),i6({labelKey:`settings.providers`,tab:`notifications`,keywords:`telegram discord email notification providers webhook`,anchor:`card-providers`}),i6({labelKey:`settings.messageTemplates`,tab:`notifications`,keywords:`message templates notification text edit`,anchor:`card-templates`}),i6({labelKey:`settings.defaultPrintOptions`,labelFallback:`Default Print Options`,tab:`queue`,keywords:`print bed leveling flow calibration vibration first layer timelapse`,anchor:`card-print-options`}),i6({labelKey:`settings.tempFanPresetsTitle`,labelFallback:`Temperature & Fan Presets`,tab:`queue`,keywords:`temperature fan presets nozzle bed chamber quick buttons popover`,anchor:`card-temp-fan-presets`}),i6({labelKey:`settings.staggeredStart`,labelFallback:`Staggered Start`,tab:`queue`,keywords:`staggered batch delay start queue group`,anchor:`card-staggered`}),i6({labelKey:`settings.plateClear`,labelFallback:`Plate-Clear Confirmation`,tab:`queue`,keywords:`plate clear confirm auto queue`,anchor:`card-plate`}),i6({labelKey:`settings.gcodeInjection`,labelFallback:`G-code Injection`,tab:`queue`,keywords:`gcode injection start end autoprint farmloop swapmod autoclear printflow`,anchor:`card-gcode`}),i6({labelKey:`settings.slicerCard`,labelFallback:`Slicer`,tab:`queue`,keywords:`slicer orcaslicer bambustudio orca bambu api sidecar url docker preferred`,anchor:`card-slicer`}),i6({labelKey:`settings.queueDrying`,tab:`queue`,keywords:`drying presets temperature time humidity ams`,anchor:`card-drying`}),i6({labelKey:`settings.filamentChecks`,tab:`filament`,keywords:`filament check warning runout remaining`,anchor:`card-filamentchecks`}),i6({labelKey:`settings.printModal`,tab:`filament`,keywords:`print modal custom mapping`,anchor:`card-printmodal`}),i6({labelKey:`settings.amsDisplayThresholds`,tab:`filament`,keywords:`ams humidity temperature threshold history retention`,anchor:`card-amsthresholds`}),i6({labelKey:`settings.externalUrl`,tab:`network`,keywords:`external url reverse proxy public notification link`,anchor:`card-externalurl`}),i6({labelKey:`settings.ftpRetry`,tab:`network`,keywords:`ftp retry upload retries backoff`,anchor:`card-ftpretry`}),i6({labelKey:`settings.homeAssistant`,tab:`network`,keywords:`home assistant ha hass mqtt integration`,anchor:`card-ha`}),i6({labelKey:`settings.mqttPublishing`,tab:`network`,keywords:`mqtt publish broker topic`,anchor:`card-mqtt`}),i6({labelKey:`settings.prometheusMetrics`,tab:`network`,keywords:`prometheus metrics grafana monitoring bearer token`,anchor:`card-prometheus`}),i6({labelKey:`settings.createNewApiKey`,tab:`apikeys`,keywords:`api key create permission scope`,anchor:`card-createapi`}),i6({labelKey:`settings.webhookEndpoints`,tab:`apikeys`,keywords:`webhook endpoint post http`,anchor:`card-webhooks`}),i6({labelKey:`settings.apiBrowser`,tab:`apikeys`,keywords:`api browser endpoint documentation test`,anchor:`card-apibrowser`}),i6({labelKey:`cameraTokens.title`,tab:`apikeys`,keywords:`camera token long-lived home assistant frigate kiosk stream`,anchor:`card-camera-tokens`}),i6({labelKey:`settings.tabs.virtualPrinter`,tab:`virtual-printer`,keywords:`virtual printer proxy archive slicer bambustudio orcaslicer ip bind`,anchor:`card-vp`}),i6({labelKey:`settings.tabs.spoolbuddy`,tab:`spoolbuddy`,keywords:`spoolbuddy device scale nfc rfid kiosk unregister`,anchor:`card-spoolbuddy`}),i6({labelKey:`settings.currentUser`,tab:`users`,subTab:`users`,keywords:`current user profile password change`,anchor:`card-currentuser`}),i6({labelKey:`settings.users`,tab:`users`,subTab:`users`,keywords:`users accounts list`,anchor:`card-users`}),i6({labelKey:`settings.groups`,tab:`users`,subTab:`users`,keywords:`groups roles permissions administrators operators viewers`,anchor:`card-groups`}),i6({labelKey:`settings.sessionPolicy.title`,labelFallback:`Session Policy`,tab:`users`,subTab:`users`,keywords:`session timeout expiry logout remember me jwt token lifetime`,anchor:`card-session-policy`}),i6({labelKey:`settings.email.smtpSettings`,labelFallback:`SMTP Configuration`,tab:`users`,subTab:`email`,keywords:`smtp email send server port password auth starttls ssl`,anchor:`card-smtp`}),i6({labelKey:`settings.ldap.title`,labelFallback:`LDAP Authentication`,tab:`users`,subTab:`ldap`,keywords:`ldap active directory ad authentication bind dn search base group mapping`,anchor:`card-ldap`}),i6({labelKey:`settings.tabs.backup`,tab:`backup`,keywords:`backup github restore download cloud sync profiles archives`,anchor:`card-backup`}),i6({labelKey:`externalLinks.sidebarLayout`,labelFallback:`Sidebar`,tab:`general`,keywords:`sidebar layout links pages hide show external custom navigation url add`,anchor:`card-sidebar-links`}),i6({labelKey:`settings.filamentTracking`,tab:`filament`,keywords:`spoolman filament tracking inventory sync remote integration`,anchor:`card-spoolman`}),i6({labelKey:`settings.catalog.spoolCatalog`,labelFallback:`Spool Catalog`,tab:`filament`,keywords:`spool catalog entries brand material reset import export`,anchor:`card-spool-catalog`}),i6({labelKey:`settings.colorCatalog.title`,labelFallback:`Color Catalog`,tab:`filament`,keywords:`color catalog hex swatch palette sync reset`,anchor:`card-color-catalog`}),i6({labelKey:`settings.tabs.failureDetection`,labelFallback:`Failure Detection`,tab:`failure-detection`,keywords:`failure detection ai ml obico spaghetti detect monitoring`,anchor:`card-fd-ml`}),i6({labelKey:`failureDetection.perPrinterTitle`,labelFallback:`Per-Printer Settings`,tab:`failure-detection`,keywords:`failure detection per printer enable per-printer sensitivity`,anchor:`card-fd-perprinter`}),i6({labelKey:`failureDetection.statusTitle`,labelFallback:`Detection Status`,tab:`failure-detection`,keywords:`failure detection status running connection`,anchor:`card-fd-status`}),i6({labelKey:`failureDetection.historyTitle`,labelFallback:`Detection History`,tab:`failure-detection`,keywords:`failure detection history log events`,anchor:`card-fd-history`}),i6({labelKey:`settings.email.advancedAuth`,labelFallback:`Advanced Email Authentication`,tab:`users`,subTab:`email`,keywords:`email authentication advanced password reset self-service forgot`,anchor:`card-email-advanced-auth`}),i6({labelKey:`settings.email.testConnection`,labelFallback:`Test SMTP Connection`,tab:`users`,subTab:`email`,keywords:`email smtp test connection send check`,anchor:`card-email-test`}),i6({labelKey:`settings.twoFa.totpTitle`,labelFallback:`Authenticator App (TOTP)`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa totp authenticator app google authy otp`,anchor:`card-2fa-totp`}),i6({labelKey:`settings.twoFa.emailOtpTitle`,labelFallback:`Email One-Time Codes`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa email otp one time code`,anchor:`card-2fa-emailotp`}),i6({labelKey:`settings.twoFa.linkedAccounts`,labelFallback:`Linked Accounts`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa linked accounts sso oidc provider google github`,anchor:`card-2fa-linked`}),i6({labelKey:`settings.oidc.title`,labelFallback:`Single Sign-On (OIDC)`,tab:`users`,subTab:`oidc`,keywords:`sso oidc openid single sign-on pocketid authentik keycloak google okta azure provider`,anchor:`card-oidc`}),i6({labelKey:`settings.ldap.serverConfig`,labelFallback:`LDAP Server Configuration`,tab:`users`,subTab:`ldap`,keywords:`ldap server url bind dn user search base group filter tls`,anchor:`card-ldap-server`}),i6({labelKey:`backup.githubBackup`,labelFallback:`GitHub Backup`,tab:`backup`,keywords:`github backup cloud remote sync profiles token`,anchor:`card-backup-github`}),i6({labelKey:`backup.history`,labelFallback:`Backup History`,tab:`backup`,keywords:`backup history log runs github commits`,anchor:`card-backup-history`}),i6({labelKey:`backup.localBackup`,labelFallback:`Local Backup`,tab:`backup`,keywords:`local backup download zip manual export`,anchor:`card-backup-local`}),i6({labelKey:`backup.scheduledBackup`,labelFallback:`Scheduled Backups`,tab:`backup`,keywords:`scheduled backup automatic hourly daily weekly retention local path`,anchor:`card-backup-scheduled`});var eUe={database:`bg-blue-600`,library_files:`bg-green-500`,library_thumbnails:`bg-teal-500`,library_other:`bg-emerald-700`,archive_timelapses:`bg-red-500`,archive_thumbnails:`bg-amber-500`,archive_files:`bg-sky-500`,virtual_printer_uploads:`bg-purple-500`,virtual_printer_upload_cache:`bg-fuchsia-500`,virtual_printer_certs:`bg-violet-500`,virtual_printer_other:`bg-purple-700`,downloads:`bg-cyan-500`,plate_calibration:`bg-lime-500`,logs:`bg-orange-500`,other_data:`bg-yellow-500`},o6=[`bg-blue-500`,`bg-green-500`,`bg-yellow-500`,`bg-red-500`,`bg-orange-500`,`bg-teal-500`,`bg-cyan-500`,`bg-purple-500`],s6=(e,t)=>eUe[e]||o6[t%o6.length];function tUe(){let e=no(),t=$n(),[n,r]=Mi(),{t:i,i18n:a}=W(),{showToast:o}=Td(),{authEnabled:s,user:c,isAdmin:l,refreshAuth:u,hasPermission:d}=dd(),{mode:f,resolvedMode:p,darkStyle:m,darkBackground:h,darkAccent:g,lightStyle:_,lightBackground:v,lightAccent:b,setMode:x,setDarkStyle:S,setDarkBackground:C,setDarkAccent:w,setLightStyle:T,setLightBackground:E,setLightAccent:D}=md(),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)({}),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(Tp()),U=n.get(`tab`),se=U===`email`,[ce,le]=(0,y.useState)(se?`users`:U&&$He.includes(U)?U:`general`),[ue,de]=(0,y.useState)(se?`email`:`users`),fe=e=>{le(e),e===`users`&&de(`users`),e===`general`?n.delete(`tab`):n.set(`tab`,e),r(n,{replace:!0})},[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(``),[_e,ve]=(0,y.useState)({can_queue:!0,can_control_printer:!1,can_read_status:!0,can_manage_library:!0,can_manage_inventory:!0,can_access_cloud:!1,can_update_energy_cost:!1}),[ye,be]=(0,y.useState)(null),[xe,Se]=(0,y.useState)(!1),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(``),[De,Oe]=(0,y.useState)(!1),[ke,Ae]=(0,y.useState)(!1),[je,Me]=(0,y.useState)(null),[Ne,Pe]=(0,y.useState)(!1),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(!1),[ze,Be]=(0,y.useState)({currentPassword:``,newPassword:``,confirmPassword:``}),[Ve,He]=(0,y.useState)(!1),[Ue,We]=(0,y.useState)(!1),[Ge,Ke]=(0,y.useState)(!1),[qe,Je]=(0,y.useState)(`local`),[Ye,Xe]=(0,y.useState)(!1),[Ze,Qe]=(0,y.useState)(null),[$e,et]=(0,y.useState)(null),[tt,nt]=(0,y.useState)(null),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),[st,ct]=(0,y.useState)(null),[lt,ut]=(0,y.useState)(null),[dt,ft]=(0,y.useState)(!1),[pt,mt]=(0,y.useState)({}),[ht,gt]=(0,y.useState)({}),_t=e=>{oe(e),Ep(e),o(i(`settings.toast.settingsSaved`),`success`)},{data:vt,isLoading:yt}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:bt,isLoading:xt,isFetching:St}=q({queryKey:[`storage-usage`],queryFn:()=>Q.getStorageUsage(),enabled:ce===`general`,staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Ct=async()=>{We(!0);try{let t=await Q.getStorageUsage({refresh:!0});e.setQueryData([`storage-usage`],t)}catch(e){o(e instanceof Error?e.message:`Failed to refresh storage usage`,`error`)}finally{We(!1)}},{data:wt,isLoading:Tt}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:Et,isLoading:Dt}=q({queryKey:[`smart-plugs-energy`,wt?.map(e=>e.id)],queryFn:async()=>{if(!wt||wt.length===0)return null;let e=await Promise.all(wt.filter(e=>e.enabled).map(async e=>{try{return{plug:e,status:await Q.getSmartPlugStatus(e.id)}}catch{return{plug:e,status:null}}})),t=0,n=0,r=0,i=0,a=0;for(let{plug:o,status:s}of e){let e=o.plug_type===`mqtt`&&s?.energy?.power!=null;(s?.reachable||e)&&s?.energy&&(a++,s.energy?.power!=null&&(t+=s.energy.power),s.energy?.today!=null&&(n+=s.energy.today),s.energy?.yesterday!=null&&(r+=s.energy.yesterday),s.energy?.total!=null&&(i+=s.energy.total))}return{totalPower:t,totalToday:n,totalYesterday:r,totalLifetime:i,reachableCount:a,totalPlugs:wt.filter(e=>e.enabled).length}},enabled:ce===`plugs`&&!!wt&&wt.length>0,refetchInterval:ce===`plugs`?1e4:!1}),{data:kt,isLoading:At}=q({queryKey:[`notification-providers`],queryFn:Q.getNotificationProviders}),{data:jt,isLoading:Mt}=q({queryKey:[`api-keys`],queryFn:Q.getAPIKeys}),G=J({mutationFn:e=>Q.createAPIKey(e),onSuccess:t=>{be(t.key||null),me(!1),ge(``),e.invalidateQueries({queryKey:[`api-keys`]}),o(i(`settings.toast.apiKeyCreated`))},onError:e=>{o(`Failed to create API key: ${e.message}`,`error`)}}),Nt=J({mutationFn:e=>Q.deleteAPIKey(e),onSuccess:(t,n)=>{e.setQueryData([`api-keys`],e=>(e??[]).filter(e=>e.id!==n)),o(i(`settings.toast.apiKeyDeleted`))},onError:e=>{o(`Failed to delete API key: ${e.message}`,`error`)}}),{data:Pt}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Ft,isLoading:It}=q({queryKey:[`notification-templates`],queryFn:Q.getNotificationTemplates}),{data:Lt}=q({queryKey:[`virtual-printer-settings`],queryFn:td.getSettings,refetchInterval:1e4}),Rt=Lt?.status?.running??!1,{data:zt}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:15e3}),Bt=zt?.length??0,Vt=zt?.some(e=>e.online)??!1,{data:Ht}=q({queryKey:[`obico-status`],queryFn:Q.getObicoStatus,refetchInterval:15e3}),Ut=!!(Ht?.is_running&&Ht?.enabled),{data:Wt}=q({queryKey:[`ffmpeg-status`],queryFn:Q.checkFfmpeg}),{data:Gt}=q({queryKey:[`version`],queryFn:Q.getVersion}),Kt=!s||d(`library:purge`),{data:qt}=q({queryKey:[`library-trash-settings`],queryFn:()=>Q.getLibraryTrashSettings(),enabled:Kt}),Jt=J({mutationFn:e=>Q.updateLibraryTrashSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`library-trash-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`libraryAutoPurge.saveFailed`),`error`)}),Yt=e=>{qt&&Jt.mutate({retention_days:qt.retention_days,auto_purge_enabled:qt.auto_purge_enabled,auto_purge_days:qt.auto_purge_days,auto_purge_include_never_printed:qt.auto_purge_include_never_printed,...e})},Xt=!s||d(`archives:purge`),{data:Zt}=q({queryKey:[`archive-purge-settings`],queryFn:()=>Q.getArchivePurgeSettings(),enabled:Xt}),Qt=J({mutationFn:e=>Q.updateArchivePurgeSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`archive-purge-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`archiveAutoPurge.saveFailed`),`error`)}),$t=e=>{Zt&&Qt.mutate({enabled:Zt.enabled,days:Zt.days,purge_stats:Zt.purge_stats,...e})},{data:en,refetch:tn,isRefetching:nn}=q({queryKey:[`updateCheck`],queryFn:Q.checkForUpdates,enabled:vt?.check_updates!==!1,staleTime:300*1e3}),{data:rn,refetch:an}=q({queryKey:[`updateStatus`],queryFn:Q.getUpdateStatus,refetchInterval:e=>{let t=e.state.data;return t?.status===`downloading`||t?.status===`installing`?1e3:!1}}),{data:on}=q({queryKey:[`mqtt-status`],queryFn:Q.getMQTTStatus,refetchInterval:ce===`network`?5e3:!1}),{data:sn}=q({queryKey:[`github-backup-status`],queryFn:Q.getGitHubBackupStatus}),{data:cn}=q({queryKey:[`cloud-status`],queryFn:Q.getCloudStatus}),{data:ln={advanced_auth_enabled:!1,smtp_configured:!1}}=q({queryKey:[`advancedAuthStatus`],queryFn:()=>Q.getAdvancedAuthStatus()}),{data:un}=q({queryKey:[`ldapStatus`],queryFn:()=>Q.getLDAPStatus()}),{data:dn}=q({queryKey:[`twoFAStatus`],queryFn:()=>Q.get2FAStatus()}),{data:fn=[]}=q({queryKey:[`oidcProvidersAll`],queryFn:()=>Q.getOIDCProvidersAll(),enabled:l}),{data:pn=[],isLoading:mn}=q({queryKey:[`users`],queryFn:()=>Q.getUsers(),enabled:s&&d(`users:read`)}),{data:hn=[],isLoading:gn}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups(),enabled:s&&d(`groups:read`)}),_n=J({mutationFn:e=>Q.createUser(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userCreated`))},onError:e=>{o(e.message,`error`)}}),vn=J({mutationFn:({id:e,data:t})=>Q.updateUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userUpdated`))},onError:e=>{o(e.message,`error`)}}),yn=J({mutationFn:({id:e,deleteItems:t})=>Q.deleteUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),o(i(`settings.toast.userDeleted`)),et(null),nt(null)},onError:e=>{o(e.message,`error`)}}),bn=J({mutationFn:e=>Q.resetUserPassword({user_id:e}),onSuccess:e=>{o(e.message,`success`)},onError:e=>{o(e.message,`error`)}}),xn=async e=>{et(e),it(!0);try{nt(await Q.getUserItemsCount(e))}catch{nt({archives:0,queue_items:0,library_files:0})}finally{it(!1)}},Sn=J({mutationFn:e=>Q.deleteGroup(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`groups`]}),o(i(`settings.toast.groupDeleted`))},onError:e=>{o(e.message,`error`)}}),Cn=()=>{let e=ln?.advanced_auth_enabled||!1;if(!at.username){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(e&&!at.email){o(`Email is required when advanced authentication is enabled`,`error`);return}if(!e){if(!at.password){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(at.password!==at.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=p3(at.password);if(e){o(i({tooShort:`settings.toast.passwordTooShort`,needsUppercase:`settings.toast.passwordNeedsUppercase`,needsLowercase:`settings.toast.passwordNeedsLowercase`,needsDigit:`settings.toast.passwordNeedsDigit`,needsSpecial:`settings.toast.passwordNeedsSpecial`}[e]),`error`);return}}_n.mutate({username:at.username,password:e?void 0:at.password,email:at.email||void 0,role:at.role,group_ids:at.group_ids.length>0?at.group_ids:void 0})},wn=e=>{if(at.password){if(at.password!==at.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=p3(at.password);if(e){o(i({tooShort:`settings.toast.passwordTooShort`,needsUppercase:`settings.toast.passwordNeedsUppercase`,needsLowercase:`settings.toast.passwordNeedsLowercase`,needsDigit:`settings.toast.passwordNeedsDigit`,needsSpecial:`settings.toast.passwordNeedsSpecial`}[e]),`error`);return}}let t={username:at.username||void 0,password:at.password||void 0,email:at.email||void 0,role:at.role,group_ids:at.group_ids};t.password||delete t.password,vn.mutate({id:e,data:t})},Tn=e=>{Qe(e.id),ot({username:e.username,password:``,email:e.email||``,confirmPassword:``,role:e.role,group_ids:e.groups?.map(e=>e.id)||[]}),Xe(!0)},En=e=>{ot(t=>({...t,group_ids:t.group_ids.includes(e)?t.group_ids.filter(t=>t!==e):[...t.group_ids,e]}))},Dn=J({mutationFn:Q.applyUpdate,onSuccess:e=>{e.is_ha_addon||e.is_docker||e.is_windows_installer?o(e.message,`error`):an()}}),[On,kn]=(0,y.useState)(null),An=J({mutationFn:Q.testAllNotificationProviders,onSuccess:t=>{kn(t),e.invalidateQueries({queryKey:[`notification-providers`]}),t.failed===0?o(`All ${t.tested} providers tested successfully!`,`success`):o(`${t.success}/${t.tested} providers succeeded`,t.failed>0?`error`:`success`)},onError:e=>{o(`Failed to test providers: ${e.message}`,`error`)}}),jn=J({mutationFn:async e=>{if(!wt)return{success:0,failed:0};let t=wt.filter(e=>e.enabled),n=await Promise.all(t.map(async t=>{try{return await Q.controlSmartPlug(t.id,e),{success:!0}}catch{return{success:!1}}}));return{success:n.filter(e=>e.success).length,failed:n.filter(e=>!e.success).length}},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`smart-plugs`]}),e.invalidateQueries({queryKey:[`smart-plugs-energy`]}),t.failed===0?o(`All ${t.success} plugs turned ${n}`,`success`):o(`${t.success} plugs turned ${n}, ${t.failed} failed`,`error`)},onError:e=>{o(`Failed: ${e.message}`,`error`)}}),Mn=(0,y.useRef)(null),Nn=(0,y.useRef)(null),Pn=(0,y.useRef)(!1),Fn=(0,y.useRef)(!0);(0,y.useEffect)(()=>{vt&&!O&&(k({...vt,external_url:vt.external_url||window.location.origin}),setTimeout(()=>{Fn.current=!1},100))},[vt,O]);let In=J({mutationFn:Q.updateSettings,onSuccess:t=>{e.setQueryData([`settings`],t),e.invalidateQueries({queryKey:[`archiveStats`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>{o(`Failed to save: ${e.message}`,`error`)},onSettled:()=>{Pn.current=!1}}),Ln=J({mutationFn:({id:e,data:t})=>Q.updatePrinter(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`printers`]}),o(i(`settings.toast.cameraSettingsSaved`),`success`)},onError:e=>{o(`Failed to update printer: ${e.message}`,`error`)}});(0,y.useEffect)(()=>{if(!(Fn.current||!O||!vt)&&!(s&&!d(`settings:update`))&&(vt.auto_archive!==O.auto_archive||vt.save_thumbnails!==O.save_thumbnails||vt.capture_finish_photo!==O.capture_finish_photo||vt.default_filament_cost!==O.default_filament_cost||vt.currency!==O.currency||vt.energy_cost_per_kwh!==O.energy_cost_per_kwh||vt.energy_tracking_mode!==O.energy_tracking_mode||vt.check_updates!==O.check_updates||(vt.check_printer_firmware??!0)!==(O.check_printer_firmware??!0)||(vt.include_beta_updates??!1)!==(O.include_beta_updates??!1)||vt.notification_language!==O.notification_language||(vt.bed_cooled_threshold??35)!==(O.bed_cooled_threshold??35)||vt.ams_humidity_good!==O.ams_humidity_good||vt.ams_humidity_fair!==O.ams_humidity_fair||vt.ams_temp_good!==O.ams_temp_good||vt.ams_temp_fair!==O.ams_temp_fair||vt.ams_history_retention_days!==O.ams_history_retention_days||vt.disable_filament_warnings!==O.disable_filament_warnings||vt.prefer_lowest_filament!==O.prefer_lowest_filament||(vt.queue_drying_enabled??!1)!==(O.queue_drying_enabled??!1)||(vt.queue_drying_block??!1)!==(O.queue_drying_block??!1)||(vt.ambient_drying_enabled??!1)!==(O.ambient_drying_enabled??!1)||(vt.drying_presets??``)!==(O.drying_presets??``)||(vt.ams_humidity_thresholds??``)!==(O.ams_humidity_thresholds??``)||vt.per_printer_mapping_expanded!==O.per_printer_mapping_expanded||vt.date_format!==O.date_format||vt.time_format!==O.time_format||vt.default_printer_id!==O.default_printer_id||vt.ftp_retry_enabled!==O.ftp_retry_enabled||vt.ftp_retry_count!==O.ftp_retry_count||vt.ftp_retry_delay!==O.ftp_retry_delay||vt.ftp_timeout!==O.ftp_timeout||vt.mqtt_enabled!==O.mqtt_enabled||vt.mqtt_broker!==O.mqtt_broker||vt.mqtt_port!==O.mqtt_port||vt.mqtt_username!==O.mqtt_username||vt.mqtt_password!==O.mqtt_password||vt.mqtt_topic_prefix!==O.mqtt_topic_prefix||vt.mqtt_use_tls!==O.mqtt_use_tls||vt.external_url!==O.external_url||vt.ha_enabled!==O.ha_enabled||vt.ha_url!==O.ha_url||vt.ha_token!==O.ha_token||(vt.library_archive_mode??`ask`)!==(O.library_archive_mode??`ask`)||Number(vt.library_disk_warning_gb??5)!==Number(O.library_disk_warning_gb??5)||(vt.camera_view_mode??`window`)!==(O.camera_view_mode??`window`)||(vt.preferred_slicer??`bambu_studio`)!==(O.preferred_slicer??`bambu_studio`)||(vt.open_in_slicer??null)!==(O.open_in_slicer??null)||(vt.use_slicer_api??!1)!==(O.use_slicer_api??!1)||(vt.orcaslicer_api_url??``)!==(O.orcaslicer_api_url??``)||(vt.bambu_studio_api_url??``)!==(O.bambu_studio_api_url??``)||vt.prometheus_enabled!==O.prometheus_enabled||vt.prometheus_token!==O.prometheus_token||(vt.user_notifications_enabled??!0)!==(O.user_notifications_enabled??!0)||(vt.default_bed_levelling??!0)!==(O.default_bed_levelling??!0)||(vt.default_flow_cali??!1)!==(O.default_flow_cali??!1)||(vt.default_vibration_cali??!0)!==(O.default_vibration_cali??!0)||(vt.default_layer_inspect??!1)!==(O.default_layer_inspect??!1)||(vt.default_timelapse??!1)!==(O.default_timelapse??!1)||(vt.default_nozzle_offset_cali??!0)!==(O.default_nozzle_offset_cali??!0)||(vt.stagger_group_size??2)!==(O.stagger_group_size??2)||(vt.stagger_interval_minutes??5)!==(O.stagger_interval_minutes??5)||(vt.require_plate_clear??!1)!==(O.require_plate_clear??!1)||(vt.nozzle_temp_presets??``)!==(O.nozzle_temp_presets??``)||(vt.bed_temp_presets??``)!==(O.bed_temp_presets??``)||(vt.chamber_temp_presets??``)!==(O.chamber_temp_presets??``)||(vt.fan_speed_presets??``)!==(O.fan_speed_presets??``)||(vt.session_max_hours??24)!==(O.session_max_hours??24))&&!Pn.current)return Mn.current&&clearTimeout(Mn.current),Mn.current=setTimeout(()=>{if(Pn.current)return;Pn.current=!0;let e={auto_archive:O.auto_archive,save_thumbnails:O.save_thumbnails,capture_finish_photo:O.capture_finish_photo,default_filament_cost:O.default_filament_cost,currency:O.currency,energy_cost_per_kwh:O.energy_cost_per_kwh,energy_tracking_mode:O.energy_tracking_mode,check_updates:O.check_updates,check_printer_firmware:O.check_printer_firmware,include_beta_updates:O.include_beta_updates,notification_language:O.notification_language,bed_cooled_threshold:O.bed_cooled_threshold,ams_humidity_good:O.ams_humidity_good,ams_humidity_fair:O.ams_humidity_fair,ams_temp_good:O.ams_temp_good,ams_temp_fair:O.ams_temp_fair,ams_history_retention_days:O.ams_history_retention_days,disable_filament_warnings:O.disable_filament_warnings,prefer_lowest_filament:O.prefer_lowest_filament,queue_drying_enabled:O.queue_drying_enabled,queue_drying_block:O.queue_drying_block,ambient_drying_enabled:O.ambient_drying_enabled,drying_presets:O.drying_presets,ams_humidity_thresholds:O.ams_humidity_thresholds,per_printer_mapping_expanded:O.per_printer_mapping_expanded,date_format:O.date_format,time_format:O.time_format,default_printer_id:O.default_printer_id,ftp_retry_enabled:O.ftp_retry_enabled,ftp_retry_count:O.ftp_retry_count,ftp_retry_delay:O.ftp_retry_delay,ftp_timeout:O.ftp_timeout,mqtt_enabled:O.mqtt_enabled,mqtt_broker:O.mqtt_broker,mqtt_port:O.mqtt_port,mqtt_username:O.mqtt_username,mqtt_password:O.mqtt_password,mqtt_topic_prefix:O.mqtt_topic_prefix,mqtt_use_tls:O.mqtt_use_tls,external_url:O.external_url,ha_enabled:O.ha_enabled,ha_url:O.ha_url,ha_token:O.ha_token,library_archive_mode:O.library_archive_mode,library_disk_warning_gb:O.library_disk_warning_gb,camera_view_mode:O.camera_view_mode,preferred_slicer:O.preferred_slicer,open_in_slicer:O.open_in_slicer,use_slicer_api:O.use_slicer_api,orcaslicer_api_url:O.orcaslicer_api_url,bambu_studio_api_url:O.bambu_studio_api_url,prometheus_enabled:O.prometheus_enabled,prometheus_token:O.prometheus_token,user_notifications_enabled:O.user_notifications_enabled,default_bed_levelling:O.default_bed_levelling,default_flow_cali:O.default_flow_cali,default_vibration_cali:O.default_vibration_cali,default_layer_inspect:O.default_layer_inspect,default_timelapse:O.default_timelapse,default_nozzle_offset_cali:O.default_nozzle_offset_cali,stagger_group_size:O.stagger_group_size,stagger_interval_minutes:O.stagger_interval_minutes,require_plate_clear:O.require_plate_clear,nozzle_temp_presets:O.nozzle_temp_presets,bed_temp_presets:O.bed_temp_presets,chamber_temp_presets:O.chamber_temp_presets,fan_speed_presets:O.fan_speed_presets,session_max_hours:O.session_max_hours};In.mutate(e)},500),()=>{Mn.current&&clearTimeout(Mn.current)}},[O,vt,In,s,d,o,i]);let Rn=(0,y.useCallback)((e,t)=>{if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}k(n=>n?{...n,[e]:t}:null)},[s,d,o,i]),zn=async(e,t,n)=>{if(!t){o(i(`settings.toast.enterCameraUrl`),`error`);return}gt(t=>({...t,[e]:!0})),mt(t=>({...t,[e]:null}));try{let r=await Q.testExternalCamera(e,t,n);mt(t=>({...t,[e]:r})),r.success?o(i(`settings.toast.cameraConnected`,{resolution:r.resolution||``}),`success`):o(r.error||i(`settings.toast.connectionFailed`),`error`)}catch(t){let n=t instanceof Error?t.message:i(`settings.toast.testFailed`);mt(t=>({...t,[e]:{success:!1,error:n}})),o(n,`error`)}finally{gt(t=>({...t,[e]:!1}))}},[Bn,Vn]=(0,y.useState)({}),Hn=(0,y.useRef)({}),Un=(0,y.useRef)(new Set),[Wn,Gn]=(0,y.useState)({}),Kn=(0,y.useRef)({}),qn=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{if(Pt){let e={},t={};Pt.forEach(n=>{n.external_camera_url&&!Un.current.has(n.id)&&(e[n.id]=n.external_camera_url,Un.current.add(n.id)),n.external_camera_snapshot_url&&!qn.current.has(n.id)&&(t[n.id]=n.external_camera_snapshot_url,qn.current.add(n.id))}),Object.keys(e).length>0&&Vn(t=>({...t,...e})),Object.keys(t).length>0&&Gn(e=>({...e,...t}))}},[Pt]);let Jn=(e,t)=>{Vn(n=>({...n,[e]:t})),Hn.current[e]&&clearTimeout(Hn.current[e]),Hn.current[e]=setTimeout(()=>{Ln.mutate({id:e,data:{external_camera_url:t||null}})},800)},Yn=(e,t)=>{Gn(n=>({...n,[e]:t})),Kn.current[e]&&clearTimeout(Kn.current[e]),Kn.current[e]=setTimeout(()=>{Ln.mutate({id:e,data:{external_camera_snapshot_url:t||null}})},800)},Xn=(e,t)=>{let n={};t.type!==void 0&&(n.external_camera_type=t.type||null),t.enabled!==void 0&&(n.external_camera_enabled=t.enabled),t.rotation!==void 0&&(n.camera_rotation=t.rotation),Ln.mutate({id:e,data:n})};if(yt||!O)return(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});let Zn=qHe().map(e=>({...e,label:i(e.labelKey,e.labelFallback??e.labelKey)})),Qn=ne.trim().toLowerCase(),er=Qn?Zn.filter(e=>e.label.toLowerCase().includes(Qn)||e.keywords.toLowerCase().includes(Qn)).slice(0,8):[],tr=e=>{fe(e.tab),e.subTab&&de(e.subTab),re(``),setTimeout(()=>{let t=document.getElementById(e.anchor);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),t.classList.add(`ring-2`,`ring-bambu-green`),setTimeout(()=>t.classList.remove(`ring-2`,`ring-bambu-green`),1500))},50)};return(0,K.jsx)(gd,{density:`dense`,children:(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Ul,{className:`w-7 h-7 text-bambu-green`}),i(`settings.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.configureBambuddy`)})]}),(0,K.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:i(`settings.searchPlaceholder`,`Search settings…`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),ne&&(0,K.jsx)(`button`,{onClick:()=>re(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`})}),er.length>0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-30 overflow-hidden`,children:er.map(e=>(0,K.jsxs)(`button`,{onClick:()=>tr(e),className:`w-full px-3 py-2 text-left hover:bg-bambu-dark-tertiary transition-colors border-b border-bambu-dark-tertiary last:border-b-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.label}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[i(`settings.tabs.${e.tab===`virtual-printer`?`virtualPrinter`:e.tab===`failure-detection`?`failureDetection`:e.tab}`),e.subTab?` › ${i(`settings.tabs.${e.subTab}`,e.subTab)}`:``]})]},e.anchor))}),Qn&&er.length===0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-30 p-3`,children:(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noSearchResults`,`No matching settings.`)})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`nav`,{className:`flex flex-wrap gap-1 border-b border-bambu-dark-tertiary lg:flex-col lg:flex-nowrap lg:gap-0 lg:border-b-0 lg:border-r lg:w-48 lg:flex-shrink-0 lg:self-start lg:sticky lg:top-4`,children:[(0,K.jsxs)(`button`,{onClick:()=>fe(`general`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`general`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Ul,{className:`w-4 h-4`}),i(`settings.tabs.general`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`plugs`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`plugs`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(xl,{className:`w-4 h-4`}),i(`settings.tabs.smartPlugs`),wt&&wt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:wt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`notifications`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`notifications`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Bo,{className:`w-4 h-4`}),i(`settings.tabs.notifications`),kt&&kt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:kt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`queue`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`queue`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Uc,{className:`w-4 h-4`}),i(`settings.tabs.queue`,`Workflow`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`filament`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`filament`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fs,{className:`w-4 h-4`}),i(`settings.tabs.filament`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`network`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`network`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4`}),i(`settings.tabs.network`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on?.enabled?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`apikeys`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`apikeys`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.tabs.apiKeys`),jt&&jt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:jt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`virtual-printer`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`virtual-printer`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),i(`settings.tabs.virtualPrinter`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Rt?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`spoolbuddy`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`spoolbuddy`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Pl,{className:`w-4 h-4`}),i(`settings.tabs.spoolbuddy`),Bt>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Bt}),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Vt?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`failure-detection`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`failure-detection`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fl,{className:`w-4 h-4`}),i(`settings.tabs.failureDetection`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Ut?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`users`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),i(`settings.tabs.users`),s&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`backup`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`backup`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Is,{className:`w-4 h-4`}),i(`settings.tabs.backup`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${cn?.is_authenticated&&sn?.configured&&sn?.enabled||vt?.local_backup_enabled?`bg-green-400`:`bg-gray-500`}`})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[ce===`general`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`a`,{href:`https://bambuddy.cool/sponsors.html?from=app-settings`,target:`_blank`,rel:`noopener noreferrer`,className:`group block mb-4 lg:mb-6 rounded-xl border border-bambu-green/30 bg-gradient-to-br from-bambu-green/15 via-bambu-green/5 to-transparent hover:border-bambu-green/50 hover:from-bambu-green/20 transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row items-start md:items-center gap-4 p-4 md:p-5`,children:[(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-bambu-green/20 text-bambu-green flex-shrink-0`,children:(0,K.jsx)(Oc,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-base font-semibold text-white`,children:i(`sponsors.sectionTitle`,`Independent & community-funded`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:i(`sponsors.tagline`,`Bambuddy is free and stays that way because people choose to support it. No VC, no cloud lock-in.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-bambu-green/20 text-bambu-green group-hover:bg-bambu-green/30 text-sm font-medium whitespace-nowrap self-start md:self-auto`,children:[i(`sponsors.viewSupporters`,`View supporters`),(0,K.jsx)(Js,{className:`w-4 h-4`})]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-general`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.general`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(bc,{className:`w-4 h-4 inline mr-1`}),i(`settings.language`)]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:a.language,onChange:e=>{let t=e.target.value;if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}a.changeLanguage(t),In.mutate({language:t})},className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:Ot.map(e=>(0,K.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.languageDescription`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultView`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:ae,onChange:e=>_t(e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:wp.map(e=>(0,K.jsx)(`option`,{value:e.to,children:i(e.labelKey)},e.id))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultViewDescription`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.dateFormat`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.date_format||`system`,onChange:e=>Rn(`date_format`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,K.jsx)(`option`,{value:`us`,children:i(`settings.dateFormatUs`)}),(0,K.jsx)(`option`,{value:`eu`,children:i(`settings.dateFormatEu`)}),(0,K.jsx)(`option`,{value:`iso`,children:i(`settings.dateFormatIso`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.timeFormat`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.time_format||`system`,onChange:e=>Rn(`time_format`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,K.jsx)(`option`,{value:`12h`,children:i(`settings.timeFormat12`)}),(0,K.jsx)(`option`,{value:`24h`,children:i(`settings.timeFormat24`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultPrinter`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.default_printer_id??``,onChange:e=>Rn(`default_printer_id`,e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:i(`settings.noDefaultPrinter`)}),Pt?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultPrinterDescription`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-appearance`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ml,{className:`w-5 h-5`}),i(`settings.appearance`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray`,children:[i(`settings.theme`),`:`]}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:[{id:`dark`,label:i(`settings.themeDark`)},{id:`light`,label:i(`settings.themeLight`)},{id:`system`,label:i(`settings.themeSystem`)}].map(({id:e,label:t})=>(0,K.jsx)(`button`,{onClick:()=>{x(e),o(i(`settings.toast.settingsSaved`),`success`)},className:`px-3 py-1 text-xs rounded-lg border transition-colors ${f===e?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-gray-300 dark:border-bambu-dark-tertiary text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white cursor-pointer`}`,children:t},e))})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-4 rounded-lg border ${p===`dark`?`border-bambu-green bg-bambu-green/5`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.darkMode`),p===`dark`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,K.jsxs)(`select`,{value:h,onChange:e=>{C(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,K.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,K.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)}),(0,K.jsx)(`option`,{value:`oled`,children:i(`settings.bgOled`)}),(0,K.jsx)(`option`,{value:`slate`,children:i(`settings.bgSlate`)}),(0,K.jsx)(`option`,{value:`forest`,children:i(`settings.bgForest`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,K.jsxs)(`select`,{value:g,onChange:e=>{w(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,K.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,K.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,K.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,K.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,K.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,K.jsxs)(`select`,{value:m,onChange:e=>{S(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,K.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,K.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-4 rounded-lg border ${p===`light`?`border-bambu-green bg-bambu-green/5`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.lightMode`),p===`light`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,K.jsxs)(`select`,{value:v,onChange:e=>{E(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,K.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,K.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,K.jsxs)(`select`,{value:b,onChange:e=>{D(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,K.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,K.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,K.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,K.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,K.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,K.jsxs)(`select`,{value:_,onChange:e=>{T(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,K.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,K.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.themeToggleHint`)})]})]}),(0,K.jsxs)(_d,{id:`card-archive`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.archiveSettings`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.autoArchivePrints`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoArchiveDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.auto_archive,onChange:e=>Rn(`auto_archive`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.saveThumbnails`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.saveThumbnailsDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.save_thumbnails,onChange:e=>Rn(`save_thumbnails`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.captureFinishPhoto`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.captureFinishPhotoDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.capture_finish_photo,onChange:e=>Rn(`capture_finish_photo`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.capture_finish_photo&&Wt&&!Wt.installed&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`text-yellow-500 font-medium`,children:i(`settings.ffmpegNotInstalled`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.ffmpegRequired`)})]})]}),Xt&&Zt&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`archiveAutoPurge.enableLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`archiveAutoPurge.enableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Zt.enabled,onChange:e=>$t({enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`archiveAutoPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!Zt.enabled,value:Zt.days,onChange:e=>$t({days:Math.max(7,Math.min(3650,parseInt(e.target.value||`0`,10)||0))}),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`archiveAutoPurge.days`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`archiveAutoPurge.ageDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,disabled:!Zt.enabled,checked:Zt.purge_stats,onChange:e=>$t({purge_stats:e.target.checked}),className:`mt-0.5 shrink-0 disabled:opacity-50`}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white block`,children:i(`archiveAutoPurge.purgeStatsLabel`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray block mt-0.5`,children:i(`archiveAutoPurge.purgeStatsDescription`)})]})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-md`,children:[(0,K.jsxs)(_d,{id:`card-camera`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Au,{className:`w-5 h-5 text-bambu-green`}),i(`settings.camera`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.cameraViewMode`)}),(0,K.jsxs)(`select`,{value:O.camera_view_mode??`window`,onChange:e=>Rn(`camera_view_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`window`,children:i(`settings.newWindow`)}),(0,K.jsx)(`option`,{value:`embedded`,children:i(`settings.embeddedOverlay`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:O.camera_view_mode===`embedded`?i(`settings.cameraOverlayDescription`):i(`settings.cameraWindowDescription`)})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 mt-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.externalCameras`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:i(`settings.externalCamerasDescription`)}),Pt&&Pt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:Pt.map(e=>(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.external_camera_enabled,onChange:t=>Xn(e.id,{enabled:t.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.external_camera_enabled&&(0,K.jsxs)(`div`,{className:`space-y-2 mt-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:e.external_camera_type===`usb`?i(`settings.cameraPlaceholderUsb`):i(`settings.cameraPlaceholderUrl`),value:Bn[e.id]??e.external_camera_url??``,onChange:t=>Jn(e.id,t.target.value),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`select`,{value:e.external_camera_type||`mjpeg`,onChange:t=>Xn(e.id,{type:t.target.value}),className:`flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`mjpeg`,children:i(`settings.cameraTypeMjpeg`)}),(0,K.jsx)(`option`,{value:`rtsp`,children:i(`settings.cameraTypeRtsp`)}),(0,K.jsx)(`option`,{value:`snapshot`,children:i(`settings.cameraTypeSnapshot`)}),(0,K.jsx)(`option`,{value:`usb`,children:i(`settings.cameraTypeUsb`)})]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>zn(e.id,Bn[e.id]??e.external_camera_url??``,e.external_camera_type||`mjpeg`),disabled:ht[e.id]||!(Bn[e.id]??e.external_camera_url),children:ht[e.id]?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),pt[e.id]&&(0,K.jsx)(`div`,{className:`text-xs flex items-center gap-1 ${pt[e.id]?.success?`text-green-500`:`text-red-500`}`,children:pt[e.id]?.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-3 h-3`}),i(`settings.connected`),pt[e.id]?.resolution&&` (${pt[e.id]?.resolution})`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ys,{className:`w-3 h-3`}),pt[e.id]?.error||i(`settings.toast.connectionFailed`)]})}),(e.external_camera_type===`mjpeg`||e.external_camera_type===`rtsp`||e.external_camera_type===`usb`)&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraSnapshotUrl`,`Snapshot URL (optional)`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:i(`settings.cameraSnapshotUrlPlaceholder`,`http://192.168.1.61:1984/api/frame.jpeg?src=printer`),value:Wn[e.id]??e.external_camera_snapshot_url??``,onChange:t=>Yn(e.id,t.target.value),className:`flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>zn(e.id,Wn[e.id]??e.external_camera_snapshot_url??``,`snapshot`),disabled:ht[e.id]||!(Wn[e.id]??e.external_camera_snapshot_url),children:ht[e.id]?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray opacity-75`,children:i(`settings.cameraSnapshotUrlHelp`,`Single-frame URL used for notification thumbnails, finish photos, timelapse and plate detection. Leave blank to capture from the live stream above. Useful for go2rtc (/api/frame.jpeg) and IP cameras with a dedicated snapshot endpoint.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraRotation`)}),(0,K.jsxs)(`select`,{value:e.camera_rotation||0,onChange:t=>Xn(e.id,{rotation:parseInt(t.target.value)}),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:0,children:`0°`}),(0,K.jsx)(`option`,{value:90,children:`90°`}),(0,K.jsx)(`option`,{value:180,children:`180°`}),(0,K.jsx)(`option`,{value:270,children:`270°`})]})]})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noPrintersConfigured`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-cost`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.costTracking`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.currency`)}),(0,K.jsx)(`select`,{value:O.currency,onChange:e=>Rn(`currency`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:ef.map(e=>(0,K.jsx)(`option`,{value:e.code,children:e.label},e.code))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultFilamentCost`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:$d(O.currency)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:O.default_filament_cost,onChange:e=>Rn(`default_filament_cost`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,$d(O.currency).length*.6+1)}rem`},className:`w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.electricityCost`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:$d(O.currency)}),(0,K.jsx)(`input`,{type:`number`,step:`0.001`,min:`0`,value:O.energy_cost_per_kwh,onChange:e=>Rn(`energy_cost_per_kwh`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,$d(O.currency).length*.6+1)}rem`},className:`w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.energyDisplayMode`)}),(0,K.jsxs)(`select`,{value:O.energy_tracking_mode||`total`,onChange:e=>Rn(`energy_tracking_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`print`,children:i(`settings.printsOnly`)}),(0,K.jsx)(`option`,{value:`total`,children:i(`settings.totalConsumption`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:O.energy_tracking_mode===`print`?i(`settings.energyModePrintDescription`):i(`settings.energyModeTotalDescription`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-filemanager`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.fileManager`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.createArchiveEntry`)}),(0,K.jsxs)(`select`,{value:O.library_archive_mode??`ask`,onChange:e=>Rn(`library_archive_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`always`,children:i(`settings.archiveMode.always`)}),(0,K.jsx)(`option`,{value:`never`,children:i(`settings.archiveMode.never`)}),(0,K.jsx)(`option`,{value:`ask`,children:i(`settings.archiveMode.ask`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.createArchiveEntryDescription`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.lowDiskSpaceWarning`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.5`,value:O.library_disk_warning_gb??5,onChange:e=>Rn(`library_disk_warning_gb`,parseFloat(e.target.value)||5),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`GB`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.lowDiskSpaceDescription`)})]}),Kt&&qt&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`libraryAutoPurge.enableLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`libraryAutoPurge.enableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:qt.auto_purge_enabled,onChange:e=>Yt({auto_purge_enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`libraryAutoPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!qt.auto_purge_enabled,value:qt.auto_purge_days,onChange:e=>Yt({auto_purge_days:Math.max(7,Math.min(3650,parseInt(e.target.value||`0`,10)||0))}),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`libraryAutoPurge.days`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`libraryAutoPurge.ageDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-white cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,disabled:!qt.auto_purge_enabled,checked:qt.auto_purge_include_never_printed,onChange:e=>Yt({auto_purge_include_never_printed:e.target.checked}),className:`rounded border-gray-300 disabled:opacity-50`}),i(`libraryAutoPurge.includeNeverPrinted`)]})]})]})]}),(0,K.jsxs)(_d,{id:`card-data`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.dataManagement`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.clearNotificationLogs`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.clearNotificationLogsDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Oe(!0),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`common.clear`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.resetUiPreferences`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.resetUiPreferencesDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Ae(!0),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`settings.reset`)]})]}),(0,K.jsxs)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.storageUsage`,`Storage Usage`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageDescription`,`Breakdown of data usage by category`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:Ct,disabled:St||Ue,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${St||Ue?`animate-spin`:``}`}),i(`common.refresh`,`Refresh`)]})]}),(0,K.jsx)(`div`,{className:`mt-3`,children:xt?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`common.loading`,`Loading`)]}):bt?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex`,children:bt.categories.filter(e=>e.bytes>0).map((e,t)=>(0,K.jsx)(`div`,{className:`${s6(e.key,t)} h-full`,style:{width:`${e.percent_of_total}%`},title:`${e.label}: ${e.formatted}`},e.key))}),(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:bt.categories.filter(e=>e.bytes>0).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full ${s6(e.key,t)}`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e.label}),(0,K.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]},e.key))}),(0,K.jsxs)(`div`,{className:`mt-2 text-xs text-bambu-gray`,children:[i(`settings.storageUsageTotal`,`Total`),`: `,(0,K.jsx)(`span`,{className:`text-white`,children:bt.total_formatted}),bt.scan_errors>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-amber-400`,children:[i(`settings.storageUsageErrors`,`Scan errors`),`: `,bt.scan_errors]})]}),bt.other_breakdown?.length>0&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.storageUsageOtherBreakdown`,`Other breakdown`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:bt.other_breakdown.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:e.label}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full border ${e.kind===`system`?`border-slate-500 text-slate-300`:`border-bambu-green text-bambu-green`}`,children:e.kind===`system`?i(`settings.storageUsageSystem`,`System`):i(`settings.storageUsageData`,`Data`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,K.jsxs)(`span`,{children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]})]},`${e.bucket}-${e.kind}`))})]})]}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageUnavailable`,`Storage usage data is unavailable`)})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.backupRestore`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.backupRestoreDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>fe(`backup`),children:[(0,K.jsx)(Is,{className:`w-4 h-4`}),i(`settings.goToBackup`)]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-sm`,children:[(0,K.jsxs)(_d,{id:`card-updates`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.updates`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider`,children:i(`settings.printerFirmware`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.checkPrinterFirmware`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.checkFirmwareDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.check_printer_firmware??!0,onChange:e=>Rn(`check_printer_firmware`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4`,children:i(`settings.bambuddySoftware`)})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.checkForUpdatesLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoCheckDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.check_updates,onChange:e=>Rn(`check_updates`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${O.check_updates?``:`opacity-50`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.includeBetaUpdates`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.includeBetaUpdatesDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.include_beta_updates??!1,onChange:e=>Rn(`include_beta_updates`,e.target.checked),disabled:!O.check_updates,className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.currentVersion`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`v`,Gt?.version||`...`]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>tn(),disabled:nn,children:[nn?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),i(`settings.checkNow`)]})]}),en?.update_available?(0,K.jsxs)(`div`,{className:`mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-bambu-green font-medium`,children:[`Update available: v`,en.latest_version]}),en.release_name&&en.release_name!==en.latest_version&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:en.release_name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[en.release_notes&&(0,K.jsx)(`button`,{onClick:()=>Pe(!0),className:`text-bambu-gray hover:text-white transition-colors text-sm underline`,children:i(`settings.releaseNotes`)}),en.release_url&&(0,K.jsx)(`a`,{href:en.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-white transition-colors`,title:i(`settings.viewReleaseOnGitHub`),children:(0,K.jsx)(Js,{className:`w-4 h-4`})})]})]}),rn?.status===`downloading`||rn?.status===`installing`?(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:rn.message})]}),(0,K.jsx)(`div`,{className:`mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${rn.progress}%`}})})]}):rn?.status===`complete`?(0,K.jsx)(`div`,{className:`mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green`,children:rn.message}):rn?.status===`error`?(0,K.jsx)(`div`,{className:`mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400`,children:rn.error||rn.message}):en?.is_ha_addon?(0,K.jsx)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.updateViaHomeAssistant`)})}):en?.is_docker?(0,K.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.updateViaDocker`)}),(0,K.jsx)(`code`,{className:`block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono`,children:`docker compose pull && docker compose up -d`})]}):en?.update_method===`windows_installer`?(0,K.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.updateViaWindowsInstaller`)}),(0,K.jsxs)(`a`,{href:en.installer_download_url||en.release_url||`https://github.com/maziggy/bambuddy/releases/tag/v${en.latest_version}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),i(`settings.downloadWindowsInstaller`,{version:en.latest_version})]})]}):(0,K.jsxs)($,{className:`mt-3`,onClick:()=>Dn.mutate(),disabled:Dn.isPending,children:[Dn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vs,{className:`w-4 h-4`}),i(`settings.installUpdate`)]})]}):en?.error?(0,K.jsx)(`div`,{className:`mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400`,children:i(`settings.failedToCheckUpdates`,{error:en.error})}):en&&!en.update_available?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:i(`settings.latestVersionRunning`)}):null]})]})]}),(0,K.jsx)(CHe,{})]})]})]}),ce===`network`&&O&&(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-externalurl`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(bc,{className:`w-5 h-5 text-blue-400`}),i(`settings.externalUrl`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.externalUrlDescription`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bambuddyUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:O.external_url??``,onChange:e=>Rn(`external_url`,e.target.value),placeholder:`http://192.168.1.100:8000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.externalUrlHint`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-ftpretry`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ol,{className:`w-5 h-5 text-blue-400`}),i(`settings.ftpRetry`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.ftpRetryDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableRetry`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoRetryDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ftp_retry_enabled??!0,onChange:e=>Rn(`ftp_retry_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.ftp_retry_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryAttempts`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_retry_count??3,onChange:e=>Rn(`ftp_retry_count`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[1,2,3,4,5,6,7,8,9,10].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.time`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryDelay`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_retry_delay??2,onChange:e=>Rn(`ftp_retry_delay`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[1,2,3,5,10,15,20,30].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.second`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.connectionTimeout`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_timeout??30,onChange:e=>Rn(`ftp_timeout`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[10,15,20,30,45,60,90,120,180,300].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.nSeconds`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.increaseForWeakWifi`)})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-ha`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ac,{className:`w-5 h-5 text-bambu-green`}),i(`settings.homeAssistant`)]}),O.ha_enabled&<&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${lt.success?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-sm ${lt.success?`text-green-400`:`text-red-400`}`,children:lt.success?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.homeAssistantFullDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableHomeAssistant`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.homeAssistantDescription`)}),O.ha_env_managed&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,K.jsx)(qc,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.autoEnabledViaEnv`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ha_enabled??!1,onChange:e=>Rn(`ha_enabled`,e.target.checked),disabled:O.ha_env_managed,className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green ${O.ha_env_managed?`opacity-60 cursor-not-allowed`:``}`})]})]}),O.ha_enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.homeAssistantUrl`),O.ha_url_from_env&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,value:O.ha_url??``,onChange:e=>Rn(`ha_url`,e.target.value),placeholder:`http://192.168.1.100:8123`,disabled:O.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${O.ha_url_from_env?`opacity-60 cursor-not-allowed`:``}`}),O.ha_url_from_env&&(0,K.jsx)(qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),O.ha_url_from_env&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.urlFromEnvReadOnly`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.longLivedAccessToken`),O.ha_token_from_env&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`password`,value:O.ha_token??``,onChange:e=>Rn(`ha_token`,e.target.value),placeholder:`eyJ0eXAiOiJKV1QiLC...`,disabled:O.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${O.ha_token_from_env?`opacity-60 cursor-not-allowed`:``}`}),O.ha_token_from_env&&(0,K.jsx)(qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),O.ha_token_from_env?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.tokenFromEnvReadOnly`)}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.haTokenHint`)})]}),O.ha_url&&O.ha_token&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:dt,onClick:async()=>{ft(!0),ut(null);try{ut(await Q.testHAConnection(O.ha_url,O.ha_token))}catch(e){ut({success:!1,message:null,error:e instanceof Error?e.message:i(`common.unknownError`)})}finally{ft(!1)}},children:[dt?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Fu,{className:`w-4 h-4`}),i(`settings.testConnection`)]})})]})]})]}),(0,K.jsxs)(_d,{id:`card-mqtt`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Fu,{className:`w-5 h-5 text-blue-400`}),i(`settings.mqttPublishing`)]}),on?.enabled&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${on.connected?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-sm ${on.connected?`text-green-400`:`text-red-400`}`,children:on.connected?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMqtt`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttEnableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.mqtt_enabled??!1,onChange:e=>Rn(`mqtt_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.mqtt_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.brokerHostname`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_broker??``,onChange:e=>Rn(`mqtt_broker`,e.target.value),placeholder:`mqtt.example.com or 192.168.1.100`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-end gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.port`)}),(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`65535`,value:O.mqtt_port??1883,onChange:e=>Rn(`mqtt_port`,Math.min(65535,Math.max(1,parseInt(e.target.value)||1883))),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.mqtt_use_tls??!1,onChange:e=>{let t=e.target.checked;Rn(`mqtt_use_tls`,t);let n=O.mqtt_port??1883;t&&n===1883?Rn(`mqtt_port`,8883):!t&&n===8883&&Rn(`mqtt_port`,1883)},className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]}),(0,K.jsx)(`span`,{className:`text-white text-sm`,children:i(`settings.useTls`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.usernameOptional`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_username??``,onChange:e=>Rn(`mqtt_username`,e.target.value),placeholder:i(`settings.leaveEmptyForAnonymous`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.passwordOptional`)}),(0,K.jsx)(`input`,{type:`password`,value:O.mqtt_password??``,onChange:e=>Rn(`mqtt_password`,e.target.value),placeholder:i(`settings.leaveEmptyForAnonymous`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.topicPrefix`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_topic_prefix??`bambuddy`,onChange:e=>Rn(`mqtt_topic_prefix`,e.target.value),placeholder:`bambuddy`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.topicPrefixHint`,{prefix:O.mqtt_topic_prefix||`bambuddy`})})]}),on&&(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on.connected?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:on.connected?(0,K.jsxs)(K.Fragment,{children:[i(`settings.mqttConnectedTo`),` `,(0,K.jsxs)(`span`,{className:`text-white`,children:[on.broker,`:`,on.port]})]}):i(`settings.spoolmanDisconnected`)})]})})]})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 lg:max-w-md space-y-3`,children:(0,K.jsxs)(_d,{id:`card-prometheus`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Su,{className:`w-5 h-5 text-orange-400`}),i(`settings.prometheusMetrics`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.prometheusEndpointDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMetricsEndpoint`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.prometheusDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.prometheus_enabled??!1,onChange:e=>Rn(`prometheus_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.prometheus_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bearerTokenOptional`)}),(0,K.jsx)(`input`,{type:`password`,value:O.prometheus_token??``,onChange:e=>Rn(`prometheus_token`,e.target.value),placeholder:i(`settings.leaveEmptyForNoAuth`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.bearerTokenHint`)})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white mb-2`,children:i(`settings.availableMetrics`)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray space-y-1`,children:[(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_printer_connected`}),` - `,i(`settings.metricsConnectionStatus`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_printer_state`}),` - `,i(`settings.metricsPrinterState`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_print_progress`}),` - `,i(`settings.metricsPrintProgress`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_bed_temp_celsius`}),` - `,i(`settings.metricsBedTemp`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_nozzle_temp_celsius`}),` - `,i(`settings.metricsNozzleTemp`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_prints_total`}),` - `,i(`settings.metricsPrintsTotal`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray/70 italic`,children:i(`settings.metricsMore`)})]})]})]})]})]})})]}),lt&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[lt.success?(0,K.jsx)(ps,{className:`w-8 h-8 text-green-400`}):(0,K.jsx)(ys,{className:`w-8 h-8 text-red-400`}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white`,children:lt.success?i(`settings.connectionSuccessful`):i(`settings.connectionFailed`)})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:lt.success?lt.message||i(`settings.haConnectionSuccess`):lt.error||i(`settings.haConnectionFailed`)}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)($,{variant:`primary`,onClick:()=>ut(null),children:i(`settings.ok`)})})]})}),ce===`plugs`&&(0,K.jsxs)(`div`,{id:`card-plugs`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(xl,{className:`w-5 h-5 text-bambu-green`}),i(`settings.smartPlugs`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.smartPlugsDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 shrink-0`,children:[wt&&wt.filter(e=>e.enabled).length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Me(`on`),disabled:jn.isPending,title:i(`settings.turnAllPlugsOn`),children:[jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(wl,{className:`w-4 h-4 text-bambu-green`}),i(`settings.allOn`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Me(`off`),disabled:jn.isPending,title:i(`settings.turnAllPlugsOff`),children:[jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Cl,{className:`w-4 h-4 text-red-400`}),i(`settings.allOff`)]})]}),(0,K.jsxs)($,{className:`whitespace-nowrap`,onClick:()=>{F(null),N(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addSmartPlug`)]})]})]}),wt&&wt.length>0&&(0,K.jsxs)(_d,{className:`mb-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-yellow-400`}),i(`settings.energySummary`),Dt&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray ml-2`})]})}),(0,K.jsx)(yd,{children:Et?(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Bu,{className:`w-3 h-3`}),i(`settings.currentPower`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalPower.toFixed(1),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`W`})]}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.plugsOnline`,{reachable:Et.reachableCount,total:Et.totalPlugs})})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),i(`settings.today`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalToday.toFixed(3),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalToday*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Su,{className:`w-3 h-3`}),i(`settings.yesterday`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalYesterday.toFixed(3),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalYesterday*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Rs,{className:`w-3 h-3`}),i(`settings.total`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalLifetime.toFixed(1),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalLifetime*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]})]}):Dt?null:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.enablePlugsForSummary`)})})]}),Tt?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):wt&&wt.length>0?(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:wt.map(e=>(0,K.jsx)(VVe,{plug:e,onEdit:e=>{F(e),N(!0)}},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-12`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(xl,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.noSmartPlugsTitle`)}),(0,K.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.noSmartPlugsDescription`)}),(0,K.jsxs)($,{onClick:()=>{F(null),N(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addFirstSmartPlug`)]})]})})})]}),ce===`notifications`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-providers`,children:[(0,K.jsx)(Bo,{className:`w-5 h-5 text-bambu-green`}),i(`settings.providers`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>H(!0),children:[(0,K.jsx)(kc,{className:`w-4 h-4`}),i(`settings.log`)]}),kt&&kt.length>0&&(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>{kn(null),An.mutate()},disabled:An.isPending,children:[An.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),i(`settings.testAll`)]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>{z(null),L(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addNotificationProvider`)]})]})]}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.notificationLanguage`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.notificationLanguageDescription`)})]}),(0,K.jsx)(`select`,{value:O.notification_language||`en`,onChange:e=>Rn(`notification_language`,e.target.value),className:`px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green`,children:Ot.map(e=>(0,K.jsx)(`option`,{value:e.code,children:e.nativeName},e.code))})]})})}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.bedCooledThreshold`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.bedCooledThresholdDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:20,max:80,step:1,value:O.bed_cooled_threshold??35,onChange:e=>Rn(`bed_cooled_threshold`,Number(e.target.value)),className:`w-16 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm text-center focus:outline-none focus:ring-1 focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`°C`})]})]})})}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${ln?.advanced_auth_enabled?``:`opacity-50`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.userNotificationsEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:ln?.advanced_auth_enabled?i(`settings.userNotificationsEnabledDescription`):i(`settings.userNotificationsDisabledHint`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:O.user_notifications_enabled??!0,disabled:!ln?.advanced_auth_enabled,onChange:e=>Rn(`user_notifications_enabled`,e.target.checked)}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green peer-disabled:cursor-not-allowed`})]})]})})}),On&&(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-white`,children:i(`settings.testResults`)}),(0,K.jsx)(`button`,{onClick:()=>kn(null),className:`text-bambu-gray hover:text-white text-xs`,children:i(`common.dismiss`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-2`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,K.jsx)(ps,{className:`w-4 h-4`}),i(`settings.testPassedCount`,{count:On.success})]}),On.failed>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-4 h-4`}),i(`settings.testFailedCount`,{count:On.failed})]})]}),On.results.filter(e=>!e.success).length>0&&(0,K.jsx)(`div`,{className:`space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary`,children:On.results.filter(e=>!e.success).map(e=>(0,K.jsxs)(`div`,{className:`text-xs text-red-400`,children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.provider_name,`:`]}),` `,e.message]},e.provider_id))})]})}),At?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):kt&&kt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:kt.map(e=>(0,K.jsx)(UVe,{provider:e,onEdit:e=>{z(e),L(!0)}},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(Bo,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.noProvidersTitle`)}),(0,K.jsx)(`p`,{className:`text-xs mb-3`,children:i(`settings.noProvidersDescription`)}),(0,K.jsxs)($,{size:`sm`,onClick:()=>{z(null),L(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addProvider`)]})]})})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-2`,id:`card-templates`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.messageTemplates`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.messageTemplatesDescription`)}),(0,K.jsxs)(`div`,{className:`relative mb-3`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:i(`settings.filterTemplates`,`Filter templates…`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),ee&&(0,K.jsx)(`button`,{onClick:()=>te(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear filter`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`})})]}),It?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Ft&&Ft.length>0?(()=>{let e=ee.trim().toLowerCase(),t=[...Ft].sort((e,t)=>e.name.localeCompare(t.name)).filter(t=>!e||t.name.toLowerCase().includes(e)||(t.title_template||``).toLowerCase().includes(e));return t.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic text-center py-6`,children:i(`settings.noTemplatesMatch`,`No templates match your filter.`)}):(0,K.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,K.jsx)(_d,{className:`cursor-pointer hover:border-bambu-green/50 transition-colors`,onClick:()=>V(e),children:(0,K.jsx)(yd,{className:`py-2.5 px-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs truncate mt-0.5`,children:e.title_template})]}),(0,K.jsx)(`button`,{className:`p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2`,onClick:t=>{t.stopPropagation(),V(e)},children:(0,K.jsx)(_l,{className:`w-4 h-4 text-bambu-gray`})})]})})},e.id))})})():(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(nc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:i(`settings.noTemplatesAvailable`)})]})})})]})]}),ce===`apikeys`&&(0,K.jsxs)(`div`,{className:d(`api_keys:read`)?`grid grid-cols-1 xl:grid-cols-2 gap-4`:`grid grid-cols-1 gap-4`,children:[(0,K.jsxs)(`div`,{children:[d(`api_keys:read`)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-createapi`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiKeys`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiKeysDescription`)})]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>me(!0),className:`flex-shrink-0`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createKey`)]})]}),ye&&(0,K.jsx)(_d,{className:`mb-6 border-bambu-green`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:i(`settings.apiKeyCreated`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyCopyWarning`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark rounded-lg p-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 text-sm text-bambu-green font-mono break-all`,children:ye}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ye);else{let e=document.createElement(`textarea`);e.value=ye,e.style.position=`fixed`,e.style.left=`-999999px`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}o(i(`settings.toast.keyCopied`))}catch{o(i(`settings.toast.copyFailed`),`error`)}},children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 mt-3`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{Ee(ye),o(i(`settings.toast.keyAddedToBrowser`))},children:i(`settings.useInApiBrowser`)}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Se(!0),children:[(0,K.jsx)(El,{className:`w-4 h-4`}),i(`settings.apiKeyQrButton`)]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{Se(!1),be(null)},children:i(`common.dismiss`)})]})]})]})})}),xe&&ye&&(0,K.jsx)(oHe,{apiKey:ye,baseUrl:O?.external_url||void 0,onClose:()=>Se(!1)}),pe&&(0,K.jsxs)(_d,{className:`mb-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:i(`settings.createNewApiKey`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keyName`)}),(0,K.jsx)(`input`,{type:`text`,value:he,onChange:e=>ge(e.target.value),placeholder:i(`settings.keyNamePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`common.permissions`)}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_read_status,onChange:e=>ve(t=>({...t,can_read_status:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.readStatus`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.readStatusDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_queue,onChange:e=>ve(t=>({...t,can_queue:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageQueue`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageQueueDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_control_printer,onChange:e=>ve(t=>({...t,can_control_printer:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.controlPrinter`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.controlPrinterDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_manage_library,onChange:e=>ve(t=>({...t,can_manage_library:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageLibrary`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageLibraryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_manage_inventory,onChange:e=>ve(t=>({...t,can_manage_inventory:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageInventory`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageInventoryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_access_cloud,onChange:e=>ve(t=>({...t,can_access_cloud:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.cloudAccess`,`Allow cloud access`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.cloudAccessDescription`,`Read Bambu Cloud presets and filaments on your behalf. Requires you to be signed into Bambu Cloud.`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_update_energy_cost,onChange:e=>ve(t=>({...t,can_update_energy_cost:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.updateEnergyCost`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.updateEnergyCostDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,K.jsxs)($,{onClick:()=>G.mutate({name:he||i(`settings.unnamedKey`),..._e}),disabled:G.isPending,children:[G.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createKey`)]}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>me(!1),children:i(`common.cancel`)})]})]})]}),Mt?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):jt&&jt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:jt.map(e=>(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.key_prefix,`••••••••`,e.last_used&&` · ${i(`settings.lastUsed`)}: ${yf(e.last_used)}`]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-1 text-xs flex-wrap justify-end`,children:[e.can_read_status&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded`,children:i(`settings.read`)}),e.can_queue&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded`,children:i(`queue.title`)}),e.can_control_printer&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded`,children:i(`settings.control`)}),e.can_manage_library&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-cyan-500/20 text-cyan-400 rounded`,children:i(`settings.libraryBadge`)}),e.can_manage_inventory&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-pink-500/20 text-pink-400 rounded`,children:i(`settings.inventoryBadge`)}),e.can_access_cloud&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-purple-500/20 text-purple-400 rounded`,children:i(`settings.cloudBadge`,`Cloud`)}),e.can_update_energy_cost&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-amber-500/20 text-amber-400 rounded`,children:i(`settings.energyCostBadge`)}),e.user_id===null&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-yellow-500/20 text-yellow-400 rounded`,title:i(`settings.legacyKeyTooltip`,`Created before per-user ownership; recreate to use cloud access`),children:i(`settings.legacyKey`,`Legacy`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>we(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})})]})]})})},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-12`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(Ic,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.apiKeysEmptyTitle`)}),(0,K.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.apiKeysEmptyDescription`)}),(0,K.jsxs)($,{onClick:()=>me(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createFirstKey`)]})]})})}),(0,K.jsxs)(_d,{className:`mt-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,id:`card-webhooks`,children:i(`settings.webhookEndpoints`)})}),(0,K.jsxs)(yd,{className:`space-y-3 text-sm`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:i(`settings.webhookApiKeyHint`)}),(0,K.jsxs)(`div`,{className:`space-y-2 font-mono text-xs`,children:[(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-blue-400`,children:`GET`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getAllStatus`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-blue-400`,children:`GET`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status/:id`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getSpecificStatus`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-green-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/queue`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.addToQueue`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-orange-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/pause`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.pausePrint`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-orange-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/resume`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.resumePrint`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-red-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/stop`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.stopPrint`)]})]})]})]})]})]}),(0,K.jsxs)(_d,{className:`mt-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-camera-tokens`,children:[(0,K.jsx)(Au,{className:`w-4 h-4 text-bambu-green`}),i(`cameraTokens.title`,`Camera API Tokens`)]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(BVe,{})})]})]}),d(`api_keys:read`)&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-apibrowser`,children:[(0,K.jsx)(bc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiBrowser`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiBrowserDescription`)})]}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyForTesting`)}),(0,K.jsx)(`input`,{type:`text`,value:Te,onChange:e=>Ee(e.target.value),placeholder:i(`settings.apiKeyPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`settings.apiKeyHint`)})]})}),(0,K.jsx)(QHe,{apiKey:Te})]})]}),ce===`virtual-printer`&&(0,K.jsx)(`div`,{id:`card-vp`,children:(0,K.jsx)(kHe,{})}),ce===`spoolbuddy`&&(0,K.jsx)(`div`,{id:`card-spoolbuddy`,children:(0,K.jsx)(jHe,{})}),ce===`queue`&&O&&(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-print-options`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Uc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.defaultPrintOptions`,`Default Print Options`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.defaultPrintOptionsDescription`,`Set default values for print options when starting new prints. These can be overridden per print in the print dialog.`)}),[{key:`default_bed_levelling`,label:i(`settings.defaultBedLevelling`,`Bed Levelling`),desc:i(`settings.defaultBedLevellingDesc`,`Auto-level bed before print`),fallback:!0,dualNozzleOnly:!1},{key:`default_flow_cali`,label:i(`settings.defaultFlowCali`,`Flow Calibration`),desc:i(`settings.defaultFlowCaliDesc`,`Calibrate extrusion flow`),fallback:!1,dualNozzleOnly:!1},{key:`default_vibration_cali`,label:i(`settings.defaultVibrationCali`,`Vibration Calibration`),desc:i(`settings.defaultVibrationCaliDesc`,`Reduce ringing artifacts`),fallback:!0,dualNozzleOnly:!1},{key:`default_layer_inspect`,label:i(`settings.defaultLayerInspect`,`First Layer Inspection`),desc:i(`settings.defaultLayerInspectDesc`,`AI inspection of first layer`),fallback:!1,dualNozzleOnly:!1},{key:`default_timelapse`,label:i(`settings.defaultTimelapse`,`Timelapse`),desc:i(`settings.defaultTimelapseDesc`,`Record timelapse video`),fallback:!1,dualNozzleOnly:!1},{key:`default_nozzle_offset_cali`,label:i(`settings.defaultNozzleOffsetCali`,`Nozzle Offset Calibration`),desc:i(`settings.defaultNozzleOffsetCaliDesc`,`Calibrate nozzle offsets between extruders`),fallback:!0,dualNozzleOnly:!0}].filter(({dualNozzleOnly:e})=>!e||(Pt||[]).some(e=>e.nozzle_count===2)).map(({key:e,label:t,desc:n,fallback:r})=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:t}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:n})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O[e]??r,onChange:t=>Rn(e,t.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]},e))]})]}),(0,K.jsxs)(_d,{id:`card-temp-fan-presets`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(vu,{className:`w-4 h-4 text-bambu-green`}),i(`settings.tempFanPresetsTitle`,`Temperature & Fan Presets`)]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.tempFanPresetsDescription`,`Customize the quick-select values shown in printer-card temperature and fan-speed popovers. The Off button is always shown.`)}),Ip.map(e=>{let t=Lp(O?.[e.key]??``,e.defaults,e.lo,e.hi),n=e.unit===`C`?`°C`:`%`;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-white`,children:[i(`settings.${{nozzle_temp_presets:`tempFanPresetsNozzle`,bed_temp_presets:`tempFanPresetsBed`,chamber_temp_presets:`tempFanPresetsChamber`,fan_speed_presets:`tempFanPresetsFan`}[e.key]}`,{nozzle_temp_presets:`Nozzle temperature`,bed_temp_presets:`Bed temperature`,chamber_temp_presets:`Chamber temperature`,fan_speed_presets:`Fan speed`}[e.key]),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,n,` · `,e.lo,`–`,e.hi,`)`]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>Rn(e.key,``),title:i(`settings.tempFanPresetsReset`,`Reset to defaults`),className:`text-bambu-gray hover:text-white transition-colors p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Al,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:[0,1,2].map(n=>(0,K.jsx)(`input`,{type:`number`,min:e.lo,max:e.hi,value:t[n],onChange:r=>{let i=[t[0],t[1],t[2]],a=parseInt(r.target.value,10);i[n]=Math.max(e.lo,Math.min(e.hi,Number.isFinite(a)?a:e.lo)),Rn(e.key,JSON.stringify(i))},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`},n))})]},e.key)})]})]}),(0,K.jsxs)(_d,{id:`card-staggered`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.staggeredStart`,`Staggered Start`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.staggeredStartDescription`,`Default group size and interval when staggering multi-printer batch starts. Can be overridden per batch in the print modal.`)}),(0,K.jsxs)(`div`,{className:`flex gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerGroupSize`,`Group size`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:50,value:O.stagger_group_size??2,onChange:e=>Rn(`stagger_group_size`,Math.max(1,Math.min(50,parseInt(e.target.value)||1))),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerGroupSizeHelp`,`Printers to start simultaneously per group`)})]}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerInterval`,`Interval (minutes)`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:60,value:O.stagger_interval_minutes??5,onChange:e=>Rn(`stagger_interval_minutes`,Math.max(1,Math.min(60,parseInt(e.target.value)||1))),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerIntervalHelp`,`Delay between each group starting`)})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-plate`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-4 h-4 text-bambu-green`}),i(`settings.plateClear`,`Plate-Clear Confirmation`)]})}),(0,K.jsx)(yd,{className:`space-y-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.requirePlateClear`,`Require plate-clear confirmation`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.requirePlateClearDescription`,`When enabled, the scheduler waits for per-printer plate-clear confirmation before starting queued prints on printers with finished jobs. Disabling this also hides the plate status badge and the "Mark plate as cleared" button on printer cards.`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.require_plate_clear??!1,onChange:e=>Rn(`require_plate_clear`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})})]}),(0,K.jsxs)(_d,{id:`card-gcode`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Es,{className:`w-4 h-4 text-bambu-green`}),i(`settings.gcodeInjection`,`G-code Injection`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.gcodeInjectionDescription`,`Configure custom G-code to inject at the start and/or end of prints for auto-print systems like Farmloop, SwapMod, AutoClear, and Printflow 3D. Snippets are configured per printer model and applied when "Inject G-code" is enabled on a queue item.`)}),(()=>{let e=(()=>{try{return O.gcode_snippets?JSON.parse(O.gcode_snippets):{}}catch{return{}}})(),t=[...new Set((Pt||[]).filter(e=>e.model).map(e=>e.model))].sort(),n=(t,n,r)=>{let i={...e};i[t]||(i[t]={start_gcode:``,end_gcode:``}),i[t][n]=r,!i[t].start_gcode&&!i[t].end_gcode&&delete i[t];let a=Object.keys(i).length>0?JSON.stringify(i):``;k(e=>e?{...e,gcode_snippets:a}:null),Nn.current=a},r=()=>{Nn.current!==null&&(In.mutate({gcode_snippets:Nn.current}),Nn.current=null)};return t.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic`,children:i(`settings.gcodeInjectionNoPrinters`,`No printers found. Add printers to configure G-code snippets.`)}):t.map(t=>{let a=e[t]||{start_gcode:``,end_gcode:``},o=!!(a.start_gcode||a.end_gcode);return(0,K.jsx)(lp,{defaultOpen:o,className:`border border-bambu-dark-tertiary rounded-lg px-3 py-2`,summary:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t}),o&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:i(`settings.gcodeConfigured`,`Configured`)})]}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeStartLabel`,`Start G-code`)}),(0,K.jsx)(`textarea`,{value:a.start_gcode,onChange:e=>n(t,`start_gcode`,e.target.value),onBlur:r,placeholder:i(`settings.gcodeStartPlaceholder`,`G-code prepended before the print starts...`),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:outline-none focus:border-bambu-green resize-y`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeEndLabel`,`End G-code`)}),(0,K.jsx)(`textarea`,{value:a.end_gcode,onChange:e=>n(t,`end_gcode`,e.target.value),onBlur:r,placeholder:i(`settings.gcodeEndPlaceholder`,`G-code appended after the print ends...`),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:outline-none focus:border-bambu-green resize-y`})]})]})},t)})})()]})]})]}),(0,K.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-slicer`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ks,{className:`w-4 h-4 text-bambu-green`}),i(`settings.slicerCard`,`Slicer`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.preferredSlicer`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.preferred_slicer??`bambu_studio`,onChange:e=>Rn(`preferred_slicer`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,K.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preferredSlicerDescription`)}),(O.preferred_slicer??`bambu_studio`)===`orcaslicer`&&(0,K.jsx)(`div`,{role:`alert`,className:`text-xs text-amber-200 bg-amber-900/20 border border-amber-700/40 rounded p-2 mt-2`,children:i(`settings.orcaslicerKnownIssuesWarning`,`OrcaSlicer 2.3.2 / 2.4.0-dev have known CLI bugs that block slicing many Bambu-authored 3MFs — see upstream issues #12426 (segfault on painted multi-extruder files) and #13386 (parameter-range strict-validation reject). Bambu Studio is recommended until the upstream fixes land.`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.openInSlicerLabel`,`Open in Slicer`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.open_in_slicer??``,onChange:e=>Rn(`open_in_slicer`,e.target.value===``?null:e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:i(`settings.openInSlicerInherit`,`Same as API slicer`)}),(0,K.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,K.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.openInSlicerDescription`,`Desktop slicer used by the 'Open in Slicer' button. Leave on 'Same as API slicer' to inherit, or pick a different slicer to use locally.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.useSlicerApi`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.useSlicerApiDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center cursor-pointer shrink-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.use_slicer_api??!1,onChange:e=>Rn(`use_slicer_api`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`relative w-11 h-6 bg-bambu-dark-tertiary rounded-full peer peer-checked:bg-bambu-green peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-bambu-green/50 transition-colors after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-transform peer-checked:after:translate-x-5`})]})]}),(O.use_slicer_api??!1)&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:(O.preferred_slicer??`bambu_studio`)===`orcaslicer`?i(`settings.orcaslicerApiUrl`,`OrcaSlicer sidecar URL`):i(`settings.bambuStudioApiUrl`,`Bambu Studio sidecar URL`)}),(0,K.jsx)(`input`,{type:`text`,value:((O.preferred_slicer??`bambu_studio`)===`orcaslicer`?O.orcaslicer_api_url:O.bambu_studio_api_url)??``,onChange:e=>Rn((O.preferred_slicer??`bambu_studio`)===`orcaslicer`?`orcaslicer_api_url`:`bambu_studio_api_url`,e.target.value),placeholder:(O.preferred_slicer??`bambu_studio`)===`orcaslicer`?`http://localhost:3003`:`http://localhost:3001`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none placeholder:text-bambu-gray/40`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.slicerApiUrlDescription`,`URL of the slicer-API sidecar container. Leave blank to use the SLICER_API_URL / BAMBU_STUDIO_API_URL env var defaults.`)})]})]})]}),(O.use_slicer_api??!1)&&(0,K.jsx)(PVe,{}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-drying`,children:[(0,K.jsx)(ac,{className:`w-4 h-4 text-amber-400`}),i(`settings.queueDrying`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.queueDryingDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingEnabledDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.queue_drying_enabled??!1,onChange:e=>Rn(`queue_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.queue_drying_enabled&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingBlock`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingBlockDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.queue_drying_block??!1,onChange:e=>Rn(`queue_drying_block`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-amber-500`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.ambientDryingEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.ambientDryingEnabledDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ambient_drying_enabled??!1,onChange:e=>Rn(`ambient_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.dryingPresets`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.dryingPresetsDescription`)}),(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,K.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS 2 Pro`}),(0,K.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS-HT`})]})}),(0,K.jsx)(`tbody`,{children:(()=>{let e={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}},t={...e};try{if(O.drying_presets){let n=JSON.parse(O.drying_presets);typeof n==`object`&&n&&(t={...e,...n})}}catch{}let n=(e,n,r)=>{let i={...t,[e]:{...t[e],[n]:r}};Rn(`drying_presets`,JSON.stringify(i))};return Object.entries(t).map(([e,t])=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-white font-medium`,children:e}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:30,max:65,value:t.n3f,onChange:t=>n(e,`n3f`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:t.n3f_hours,onChange:t=>n(e,`n3f_hours`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:30,max:85,value:t.n3s,onChange:t=>n(e,`n3s`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:t.n3s_hours,onChange:t=>n(e,`n3s_hours`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})})]},e))})()})]})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.humidityThresholds`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.humidityThresholdsDescription`)}),(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2`,children:i(`settings.humidityThresholdCol`)})]})}),(0,K.jsx)(`tbody`,{children:(()=>{let e=O.ams_humidity_fair??60,t=[`PLA`,`PETG`,`TPU`,`ABS`,`ASA`,`PA`,`PC`,`PVA`],n={};try{if(O.ams_humidity_thresholds){let e=JSON.parse(O.ams_humidity_thresholds);typeof e==`object`&&e&&(n=e)}}catch{}let r=[{key:`default`,label:i(`settings.humidityThresholdDefault`),value:Number(n.default??e),isDefault:!0},...t.map(t=>({key:t,label:t,value:Number(n[t]??n.default??e),isDefault:!1}))],a=(e,t)=>{if(t.trim()===``){let t={...n};delete t[e],Rn(`ams_humidity_thresholds`,JSON.stringify(t));return}let r=parseInt(t,10);if(Number.isNaN(r))return;let i=Math.max(5,Math.min(95,r)),a={...n,[e]:i};Rn(`ams_humidity_thresholds`,JSON.stringify(a))};return r.map(e=>{let t=A[e.key],n=t===void 0?String(e.value):t;return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 font-medium ${e.isDefault?`text-bambu-gray italic`:`text-white`}`,children:e.label}),(0,K.jsx)(`td`,{className:`py-1 pr-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:5,max:95,value:n,onChange:t=>j(n=>({...n,[e.key]:t.target.value})),onBlur:t=>{a(e.key,t.target.value),j(t=>{let n={...t};return delete n[e.key],n})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})})]},e.key)})})()})]})})]})]})]})]})]}),ce===`filament`&&O&&(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`lg:w-1/3 space-y-3`,children:[(0,K.jsx)(uHe,{}),(0,K.jsxs)(_d,{id:`card-filamentchecks`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.filamentChecks`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.disableFilamentWarnings`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.disableFilamentWarningsDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.disable_filament_warnings,onChange:e=>Rn(`disable_filament_warnings`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.preferLowestFilament`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.preferLowestFilamentDesc`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:i(`settings.preferLowestFilamentBackupNote`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.prefer_lowest_filament,onChange:e=>Rn(`prefer_lowest_filament`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-printmodal`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.printModal`)})}),(0,K.jsx)(yd,{className:`space-y-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.expandCustomMapping`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.expandCustomMappingDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.per_printer_mapping_expanded??!1,onChange:e=>Rn(`per_printer_mapping_expanded`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})})]}),(0,K.jsxs)(_d,{id:`card-amsthresholds`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.amsDisplayThresholds`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.amsThresholdsDescription`)}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(Us,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.humidity`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodGreen`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:O.ams_humidity_good??40,onChange:e=>Rn(`ams_humidity_good`,parseInt(e.target.value)||40),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:O.ams_humidity_fair??60,onChange:e=>Rn(`ams_humidity_fair`,parseInt(e.target.value)||60),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairBad`)}),(0,K.jsx)(`p`,{className:`text-xs text-amber-400/70`,children:i(`settings.fairAlsoDryingThreshold`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(vu,{className:`w-4 h-4 text-orange-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.temperature`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodBlue`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:O.ams_temp_good??28,onChange:e=>Rn(`ams_temp_good`,parseFloat(e.target.value)||28),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:O.ams_temp_fair??35,onChange:e=>Rn(`ams_temp_fair`,parseFloat(e.target.value)||35),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairHot`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(Is,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.historyRetention`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keepSensorHistory`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`365`,value:O.ams_history_retention_days??30,onChange:e=>Rn(`ams_history_retention_days`,parseInt(e.target.value)||30),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`common.days`)})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.historyRetentionDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`lg:w-2/3 space-y-3`,children:[(0,K.jsx)(dHe,{}),(0,K.jsx)(xHe,{})]})]})}),Ce!==null&&(0,K.jsx)(Ad,{title:i(`settings.deleteApiKeyTitle`),message:i(`settings.deleteApiKeyMessage`),confirmText:i(`settings.deleteKey`),variant:`danger`,onConfirm:()=>{Nt.mutate(Ce),we(null)},onCancel:()=>we(null)}),M&&(0,K.jsx)(HVe,{plug:P,onClose:()=>{N(!1),F(null)}}),I&&(0,K.jsx)(GVe,{provider:R,onClose:()=>{L(!1),z(null)}}),B&&(0,K.jsx)(KVe,{template:B,onClose:()=>V(null)}),ie&&(0,K.jsx)(JVe,{onClose:()=>H(!1)}),De&&(0,K.jsx)(Ad,{title:i(`settings.clearNotificationLogs`),message:i(`settings.clearLogsMessage`),confirmText:i(`settings.clearLogs`),variant:`warning`,onConfirm:async()=>{Oe(!1);try{o((await Q.clearNotificationLogs(30)).message,`success`)}catch{o(i(`settings.toast.clearLogsFailed`),`error`)}},onCancel:()=>Oe(!1)}),ke&&(0,K.jsx)(Ad,{title:i(`settings.resetUiPreferences`),message:i(`settings.resetUiPreferencesMessage`),confirmText:i(`settings.resetPreferences`),variant:`default`,onConfirm:()=>{Ae(!1),localStorage.clear(),o(i(`settings.toast.uiPreferencesReset`),`success`),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Ae(!1)}),je&&(0,K.jsx)(Ad,{title:`Turn All Plugs ${je===`on`?`On`:`Off`}`,message:`This will turn ${je===`on`?`ON`:`OFF`} all ${wt?.filter(e=>e.enabled).length||0} enabled smart plugs. ${je===`off`?`Any running printers may be affected!`:``}`,confirmText:`Turn All ${je===`on`?`On`:`Off`}`,variant:je===`off`?`danger`:`warning`,onConfirm:()=>{let e=je;Me(null),jn.mutate(e)},onCancel:()=>Me(null)}),Ne&&en?.release_notes&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>Pe(!1),children:(0,K.jsxs)(_d,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(vd,{className:`flex flex-row items-center justify-between shrink-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Release Notes - v`,en.latest_version]}),en.release_name&&en.release_name!==en.latest_version&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:en.release_name})]}),(0,K.jsx)(`button`,{onClick:()=>Pe(!1),className:`p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(yd,{className:`overflow-y-auto flex-1`,children:(0,K.jsx)(`pre`,{className:`text-sm text-bambu-gray whitespace-pre-wrap font-sans`,children:en.release_notes})}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2`,children:[en.release_url&&(0,K.jsx)(`a`,{href:en.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1`,children:(0,K.jsxs)($,{variant:`secondary`,className:`w-full`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`View on GitHub`]})}),(0,K.jsx)($,{onClick:()=>Pe(!1),className:`flex-1`,children:`Close`})]})]})}),ce===`users`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>de(`users`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),i(`settings.tabs.users`)]}),(0,K.jsxs)(`button`,{onClick:()=>de(`email`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`email`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),i(`settings.tabs.emailAuth`)||`Email Authentication`,ln?.advanced_auth_enabled&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>de(`ldap`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`ldap`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.ldap`)||`LDAP`,un?.ldap_enabled&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>de(`twofa`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`twofa`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.twoFa`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${dn?.totp_enabled||dn?.email_otp_enabled?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,K.jsxs)(`button`,{onClick:()=>de(`oidc`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`oidc`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(bc,{className:`w-4 h-4`}),i(`settings.tabs.oidc`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${fn.some(e=>e.is_enabled)?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,K.jsxs)(`button`,{onClick:()=>de(`security`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`security`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.security`)]})]}),ue===`users`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${s?`bg-green-500/20`:`bg-gray-500/20`}`,children:s?(0,K.jsx)(qc,{className:`w-5 h-5 text-green-400`}):(0,K.jsx)(Kc,{className:`w-5 h-5 text-gray-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.authentication`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(s?`settings.authEnabledDescription`:`settings.authDisabledDescription`)})]})]}),s?c?.is_admin&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Ie(!0),children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),i(`common.disable`)]}):(0,K.jsxs)($,{onClick:()=>t(`/setup`),children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),i(`common.enable`)]})]})})}),ln?.advanced_auth_enabled&&(0,K.jsx)(_d,{className:`border-blue-500/30 bg-blue-500/5`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0`,children:(0,K.jsx)(Xc,{className:`w-5 h-5 text-blue-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.email.advancedAuthEnabled`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.email.advancedAuthEnabledDesc`)})]})]})})}),s&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-session-policy`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(qc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.sessionPolicy.title`)]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:i(`settings.sessionPolicy.description`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 mb-4`,children:[[{hours:24,labelKey:`settings.sessionPolicy.preset24h`},{hours:168,labelKey:`settings.sessionPolicy.preset7d`},{hours:720,labelKey:`settings.sessionPolicy.preset30d`}].map(e=>{let t=(O?.session_max_hours??24)===e.hours;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>Rn(`session_max_hours`,e.hours),disabled:s&&!d(`settings:update`),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${t?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark`} disabled:opacity-50 disabled:cursor-not-allowed`,children:i(e.labelKey)},e.hours)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:720,value:O?.session_max_hours??24,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||Rn(`session_max_hours`,Math.max(1,Math.min(720,t)))},disabled:s&&!d(`settings:update`),"aria-label":i(`settings.sessionPolicy.customHoursLabel`),className:`w-20 px-2 py-2 bg-bambu-dark-tertiary text-white text-sm rounded-lg border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`settings.sessionPolicy.hoursSuffix`)})]})]}),(O?.session_max_hours??24)>24&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-xs text-yellow-200`,children:i(`settings.sessionPolicy.warning`)})]})]})]}),c&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-currentuser`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),i(`settings.currentUser`)]}),c.auth_source!==`ldap`&&(0,K.jsxs)($,{size:`sm`,variant:`ghost`,onClick:()=>Re(!0),children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.changePassword`)]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-lg`,children:c.username}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:[c.is_admin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300`,children:i(`settings.admin`)}),c.groups?.map(e=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-500/20 text-purple-300`:e.name===`Operators`?`bg-blue-500/20 text-blue-300`:e.name===`Viewers`?`bg-green-500/20 text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]})})})]}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-users`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),i(`settings.users`)]}),d(`users:create`)&&(0,K.jsxs)($,{size:`sm`,onClick:()=>{Ke(!0),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addUser`)]})]})}),(0,K.jsx)(yd,{children:mn?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):pn.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noUsersFound`)}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:pn.map(e=>(0,K.jsxs)(`div`,{className:`py-3 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.username}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[e.auth_source===`ldap`&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-cyan-500/20 text-cyan-300`,children:`LDAP`}),e.is_admin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300`,children:i(`settings.admin`)}),e.groups?.map(e=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-500/20 text-purple-300`:e.name===`Operators`?`bg-blue-500/20 text-blue-300`:e.name===`Viewers`?`bg-green-500/20 text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[d(`users:update`)&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>Tn(e),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),d(`users:delete`)&&e.id!==c?.id&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>xn(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},e.id))})})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-groups`,children:[(0,K.jsx)(ql,{className:`w-5 h-5 text-bambu-green`}),i(`settings.groups`)]}),d(`groups:create`)&&(0,K.jsxs)($,{size:`sm`,onClick:()=>t(`/groups/new`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addGroup`)]})]})}),(0,K.jsx)(yd,{children:gn?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):hn.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noGroupsFound`)}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:hn.map(e=>(0,K.jsxs)(`div`,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-4 h-4 ${e.name===`Administrators`?`text-purple-400`:e.name===`Operators`?`text-blue-400`:e.name===`Viewers`?`text-green-400`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:e.name}),e.is_system&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:i(`settings.system`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d(`groups:update`)&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>t(`/groups/${e.id}/edit`),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),d(`groups:delete`)&&!e.is_system&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>ct(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1 ml-6`,children:e.description||i(`settings.noDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:i(`settings.userCount`,{count:e.user_count})}),(0,K.jsx)(`span`,{children:i(`settings.permissionCount`,{count:e.permissions.length})})]})]},e.id))})})]})})]}),!s&&(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-6`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Kc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.authDisabledTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 max-w-md mx-auto`,children:i(`settings.authDisabledMessage`)}),(0,K.jsxs)(`ul`,{className:`space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto`,children:[(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature1`)})]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature2`)})]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature3`)})]})]}),(0,K.jsxs)($,{onClick:()=>t(`/setup`),children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),i(`settings.enableAuthentication`)]})]})})})]}),ue===`email`&&(0,K.jsx)(`div`,{className:`max-w-5xl`,id:`card-smtp`,children:(0,K.jsx)(zHe,{})}),ue===`ldap`&&(0,K.jsx)(`div`,{className:`max-w-5xl`,id:`card-ldap`,children:(0,K.jsx)(VHe,{})}),ue===`twofa`&&(0,K.jsx)(`div`,{className:`max-w-2xl`,children:(0,K.jsx)(UHe,{})}),ue===`oidc`&&l&&(0,K.jsx)(`div`,{className:`max-w-3xl`,children:(0,K.jsx)(KHe,{})}),ue===`security`&&l&&(0,K.jsx)(`div`,{className:`max-w-3xl`,children:(0,K.jsx)(JHe,{})})]}),Ge&&!ln?.advanced_auth_enabled&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.createUser`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[un?.ldap_enabled&&(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-1 p-1 bg-bambu-dark-secondary rounded-lg`,role:`tablist`,"aria-label":i(`users.modal.tabsAriaLabel`),children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":qe===`local`,onClick:()=>Je(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${qe===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.localTab`)}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":qe===`ldap`,onClick:()=>Je(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${qe===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.ldapTab`)})]}),qe===`ldap`&&un?.ldap_enabled?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(L3,{onSuccess:e=>{Ke(!1),Je(`local`),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Ke(!1),Je(`local`),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.username`)}),(0,K.jsx)(`input`,{type:`text`,value:at.username,onChange:e=>ot({...at,username:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterUsername`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.password`)}),(0,K.jsx)(`input`,{type:`password`,value:at.password,onChange:e=>ot({...at,password:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterPassword`),autoComplete:`new-password`,minLength:8}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,K.jsx)(`input`,{type:`password`,value:at.confirmPassword,onChange:e=>ot({...at,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmPasswordPlaceholder`),autoComplete:`new-password`,minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.groups`)}),(0,K.jsxs)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[hn.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:at.group_ids.includes(e.id),onChange:()=>En(e.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,K.jsx)(`span`,{className:`text-xs text-yellow-400`,children:i(`settings.systemBadge`)})]},e.id)),hn.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.noGroupsAvailable`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:Cn,disabled:_n.isPending||!at.username||!at.password||at.password!==at.confirmPassword||p3(at.password)!==null,children:_n.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`settings.creating`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createUser`)]})})]})]})]})]})}),Ge&&ln?.advanced_auth_enabled&&(0,K.jsx)(lHe,{formData:at,setFormData:ot,groups:hn,onClose:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},onCreate:Cn,isCreating:_n.isPending,isCreateButtonDisabled:_n.isPending||!at.username||!at.email,ldapEnabled:un?.ldap_enabled,onLdapProvisioned:e=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),Ye&&Ze!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(_l,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.editUser`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`settings.username`),` `,ln?.advanced_auth_enabled&&(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:at.username,onChange:e=>ot({...at,username:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterUsername`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.email`)||`Email`,` `,ln?.advanced_auth_enabled?(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`}):(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.optional`)||`optional`,`)`]})]}),(0,K.jsx)(`input`,{type:`email`,value:at.email,onChange:e=>ot({...at,email:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`users.form.emailPlaceholder`)||`user@example.com`,required:ln?.advanced_auth_enabled})]}),!ln?.advanced_auth_enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.password`)||`Password`,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.leaveBlankToKeep`)||`leave blank to keep current`,`)`]})]}),(0,K.jsx)(`input`,{type:`password`,value:at.password,onChange:e=>ot({...at,password:e.target.value,confirmPassword:``}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterNewPassword`),autoComplete:`new-password`,minLength:8}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),at.password&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,K.jsx)(`input`,{type:`password`,value:at.confirmPassword,onChange:e=>ot({...at,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),ln?.advanced_auth_enabled&&(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`users.form.passwordManagedByAdvancedAuth`)||`Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Ze&&bn.mutate(Ze),disabled:bn.isPending||!at.email,className:`w-full`,children:bn.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`users.form.resettingPassword`)||`Resetting Password...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),i(`users.form.resetPassword`)||`Reset Password`]})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`users.form.groups`)||`Groups`}),(0,K.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:hn.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:at.group_ids.includes(e.id),onChange:()=>En(e.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400`,children:[`(`,i(`users.system`)||`System`,`)`]})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`users.modal.cancel`)||`Cancel`}),(0,K.jsx)($,{onClick:()=>wn(Ze),disabled:vn.isPending||!at.username||ln?.advanced_auth_enabled&&!at.email||!!(!ln?.advanced_auth_enabled&&at.password&&(at.password!==at.confirmPassword||p3(at.password)!==null)),children:vn.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`users.modal.saving`)||`Saving...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),i(`users.modal.saveChanges`)||`Save Changes`]})})]})]})]})}),$e!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:()=>{et(null),nt(null)},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold`,children:i(`settings.deleteUserTitle`)})]})}),(0,K.jsx)(yd,{className:`space-y-3`,children:rt?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent`})}):tt&&tt.archives+tt.queue_items+tt.library_files>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.userHasCreated`)}),(0,K.jsxs)(`ul`,{className:`list-disc list-inside text-bambu-gray space-y-1`,children:[tt.archives>0&&(0,K.jsxs)(`li`,{children:[tt.archives,` archive`,tt.archives===1?``:`s`]}),tt.queue_items>0&&(0,K.jsxs)(`li`,{children:[tt.queue_items,` queue item`,tt.queue_items===1?``:`s`]}),tt.library_files>0&&(0,K.jsxs)(`li`,{children:[tt.library_files,` library file`,tt.library_files===1?``:`s`]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.userItemsQuestion`)}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)($,{variant:`danger`,onClick:()=>yn.mutate({id:$e,deleteItems:!0}),disabled:yn.isPending,className:`justify-center`,children:i(`settings.deleteUserAndItems`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>yn.mutate({id:$e,deleteItems:!1}),disabled:yn.isPending,className:`justify-center`,children:i(`settings.deleteUserKeepItems`)}),(0,K.jsx)($,{variant:`ghost`,onClick:()=>{et(null),nt(null)},disabled:yn.isPending,className:`justify-center`,children:i(`common.cancel`)})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.deleteUserConfirm`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.actionCannotBeUndone`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>{et(null),nt(null)},disabled:yn.isPending,children:i(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,onClick:()=>yn.mutate({id:$e,deleteItems:!1}),disabled:yn.isPending,children:i(`settings.deleteUserTitle`)})]})]})})]})}),st!==null&&(0,K.jsx)(Ad,{title:i(`settings.deleteGroupTitle`),message:i(`settings.deleteGroupMessage`),confirmText:i(`settings.deleteGroup`),variant:`danger`,onConfirm:()=>{Sn.mutate(st),ct(null)},onCancel:()=>ct(null)}),ce===`failure-detection`&&(0,K.jsx)(`div`,{id:`card-failure-detection`,children:(0,K.jsx)(IHe,{})}),ce===`backup`&&(0,K.jsxs)(`div`,{id:`card-backup`,children:[(0,K.jsxs)(`div`,{className:`mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg flex items-start gap-2`,children:[(0,K.jsx)(ql,{className:`text-amber-400 flex-shrink-0 mt-0.5`,size:16}),(0,K.jsx)(`p`,{className:`text-sm text-amber-400`,children:i(`backup.includesEncryptionKey`)})]}),(0,K.jsx)(FHe,{})]}),Fe&&(0,K.jsx)(Ad,{title:i(`settings.disableAuthenticationTitle`),message:i(`settings.disableAuthenticationMessage`),confirmText:i(`settings.disableAuthentication`),variant:`danger`,onConfirm:async()=>{try{await Q.disableAuth(),o(i(`settings.toast.authDisabled`),`success`),await u(),Ie(!1),window.location.href=`/`}catch(e){o(e instanceof Error?e.message:i(`settings.toast.authDisableFailed`),`error`)}},onCancel:()=>Ie(!1)}),Le&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.changePassword`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Current Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.currentPassword,onChange:e=>Be({...ze,currentPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterCurrentPassword`),autoComplete:`current-password`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`New Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.newPassword,onChange:e=>Be({...ze,newPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterNewPasswordMin6`),autoComplete:`new-password`,minLength:6})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Confirm New Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.confirmPassword,onChange:e=>Be({...ze,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ze.confirmPassword&&ze.newPassword!==ze.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),ze.confirmPassword&&ze.newPassword!==ze.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:async()=>{if(ze.newPassword!==ze.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}if(ze.newPassword.length<6){o(i(`settings.toast.passwordTooShort`),`error`);return}He(!0);try{await Q.changePassword(ze.currentPassword,ze.newPassword),o(i(`settings.toast.passwordChanged`),`success`),Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})}catch(e){o(e instanceof Error?e.message:`Failed to change password`,`error`)}finally{He(!1)}},disabled:Ve||!ze.currentPassword||!ze.newPassword||ze.newPassword!==ze.confirmPassword||ze.newPassword.length<6,children:Ve?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`settings.changing`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.changePassword`)]})})]})]})]})})]})]})]})})}var c6=e=>(Math.trunc(parseFloat(e)*1e3)/1e3).toFixed(3),nUe=e=>e.startsWith(`HH`)?`HF`:`S`,rUe=e=>{let t=e.match(/^([A-Z]{2}\d{2})/);return t?t[1]:`HH00`},l6=e=>{for(let t of[`High Flow_`,`High Flow `,`Standard_`,`Standard `,`HF_`,`HF `,`S_`,`S `])if(e.startsWith(t))return e.slice(t.length);let t=e.indexOf(`_`);return t>0?e.slice(t+1):e};function u6({profile:e,onEdit:t,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){let s=nUe(e.nozzle_id),c=e.nozzle_diameter;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,K.jsx)(`button`,{onClick:a,className:`text-bambu-gray hover:text-white transition-colors p-1`,children:i?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4`})}),(0,K.jsxs)(`button`,{onClick:()=>{r&&a?a():t()},className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?`ring-1 ring-bambu-green`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-green font-mono text-sm font-bold whitespace-nowrap`,children:c6(e.k_value)}),(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name||`Unnamed`}),o&&(0,K.jsx)(`span`,{title:`Has note`,children:(0,K.jsx)(lu,{className:`w-3 h-3 text-yellow-500`})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:[s,` `,c]})]}),o&&(0,K.jsxs)(`div`,{className:`text-xs mt-0.5 truncate text-yellow-500/70`,title:o,children:[`Note: `,o.length>50?o.substring(0,50)+`...`:o]})]}),!r&&n&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`text-bambu-gray hover:text-white transition-colors p-1`,title:`Copy profile`,children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})}function d6({profile:e,printerId:t,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],isDualNozzle:a=!1,initialNote:o=``,initialNoteKey:s=null,onClose:c,onSave:l,onSaveNote:u,hasPermission:d}){let{t:f}=W(),{showToast:p}=Td(),[m,h]=(0,y.useState)(e?.name||``),[g,_]=(0,y.useState)(e?.k_value?c6(e.k_value):`0.020`),[v,b]=(0,y.useState)(e?.filament_id||``),[x,S]=(0,y.useState)(e?.nozzle_id?rUe(e.nozzle_id):`HH00`),[C,w]=(0,y.useState)(e?.nozzle_diameter||n),[T,E]=(0,y.useState)(e?[e.extruder_id]:a?[0,1]:[0]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)({current:0,total:0}),[j,M]=(0,y.useState)(o),N=y.useMemo(()=>{let e=new Map;for(let t of i)e.set(t.filament_id,t.name);let t=new Map;for(let n of r)if(n.filament_id&&!t.has(n.filament_id)){let r=e.get(n.filament_id)||l6(n.name||``);t.set(n.filament_id,{id:n.filament_id,name:r||n.filament_id})}return Array.from(t.values()).sort((e,t)=>e.name.localeCompare(t.name))},[r,i]),P=J({mutationFn:e=>(console.log(`[KProfile] Calling API...`),Q.setKProfile(t,e)),onSuccess:t=>{if(console.log(`[KProfile] Save success:`,t),p(f(`kProfiles.toast.profileSaved`)),u&&j!==o){let t;t=j===``&&s?s:e&&e.slot_id>0?e.setting_id||`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`:`name_${m}_${v}`,u(t,j)}O(!0),setTimeout(()=>{O(!1),l()},2500)},onError:e=>{console.error(`[KProfile] Save error:`,e),p(e.message,`error`),O(!1)}}),F=J({mutationFn:e=>(console.log(`[KProfile] Deleting profile...`),Q.deleteKProfile(t,e)),onSuccess:e=>{console.log(`[KProfile] Delete success:`,e),p(f(`kProfiles.toast.profileDeleted`)),O(!0),setTimeout(()=>{O(!1),c()},4e3)},onError:e=>{console.error(`[KProfile] Delete error:`,e),p(e.message,`error`),O(!1)}}),[I,L]=(0,y.useState)(!1),R=()=>{e&&F.mutate({slot_id:e.slot_id,extruder_id:e.extruder_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,filament_id:e.filament_id,setting_id:e.setting_id})};return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:[(0,K.jsxs)(_d,{className:`w-full max-w-md relative`,children:[D&&(0,K.jsxs)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg`,children:[(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:k.total>1?f(`kProfiles.modal.savingExtruder`,{current:k.current,total:k.total}):f(`kProfiles.modal.syncing`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-1`,children:f(`kProfiles.modal.pleaseWait`)})]}),(0,K.jsxs)(yd,{className:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:f(e?`kProfiles.modal.editTitle`:`kProfiles.modal.addTitle`)}),(0,K.jsx)(`button`,{onClick:c,className:`text-bambu-gray hover:text-white transition-colors`,disabled:D,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),a&&!e&&T.length===0){p(f(`kProfiles.toast.selectAtLeastOneExtruder`),`error`);return}let r=parseFloat(g).toFixed(6),i=`${x}-${C}`;if(e||T.length===1){let t={name:m,k_value:r,filament_id:v,nozzle_id:i,nozzle_diameter:C,extruder_id:e?e.extruder_id:T[0],setting_id:e?.setting_id,slot_id:e?.slot_id??0};console.log(`[KProfile] Saving profile:`,t),P.mutate(t);return}O(!0),A({current:1,total:T.length});let o=T.map(e=>({name:m,k_value:r,filament_id:v,nozzle_id:i,nozzle_diameter:C,extruder_id:e,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${o.length} profiles in batch:`,o);try{await Q.setKProfilesBatch(t,o),p(f(`kProfiles.toast.profilesSaved`,{count:T.length})),u&&j&&u(`name_${m}_${v}`,j)}catch(e){console.error(`[KProfile] Failed to save batch:`,e),p(f(`kProfiles.toast.failedToSaveBatch`),`error`),O(!1),A({current:0,total:0});return}A({current:T.length,total:T.length}),setTimeout(()=>{O(!1),A({current:0,total:0}),l()},3e3)},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.profileName`)}),(0,K.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,placeholder:f(`kProfiles.modal.profileNamePlaceholder`),required:!e})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.kValue`)}),(0,K.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:g,onChange:e=>{let t=e.target.value;(t===``||/^\d*\.?\d*$/.test(t))&&_(t)},onBlur:e=>{let t=parseFloat(e.target.value);isNaN(t)||_((Math.trunc(t*1e3)/1e3).toFixed(3))},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono`,placeholder:f(`kProfiles.modal.kValuePlaceholder`),required:!0}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.kValueHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.filament`)}),(0,K.jsxs)(`select`,{value:v,onChange:t=>{let n=t.target.value;if(b(n),!e&&n&&!m){let e=N.find(e=>e.id===n);e&&h(`${x===`HH00`?`HF`:`S`} ${e.name}`)}},disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,required:!e,children:[(0,K.jsx)(`option`,{value:``,children:f(`kProfiles.modal.selectFilament`)}),e?.filament_id&&(0,K.jsx)(`option`,{value:e.filament_id,children:N.find(t=>t.id===e.filament_id)?.name||e.filament_id},e.filament_id),!e&&N.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),!e&&N.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.noFilamentsHelp`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.flowType`)}),(0,K.jsxs)(`select`,{value:x,onChange:t=>{let n=t.target.value;if(S(n),!e&&v&&!m){let e=N.find(e=>e.id===v);e&&h(`${n===`HS00`?`HF`:`S`} ${e.name}`)}},disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,children:[(0,K.jsx)(`option`,{value:`HH00`,children:f(`kProfiles.modal.highFlow`)}),(0,K.jsx)(`option`,{value:`HS00`,children:f(`kProfiles.modal.standard`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.nozzleSize`)}),(0,K.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,children:[(0,K.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,K.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,K.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,K.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]})]}),a&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(e?`kProfiles.modal.extruder`:`kProfiles.modal.extruders`)}),e?(0,K.jsx)(`div`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60`,children:e.extruder_id===1?f(`kProfiles.modal.left`):f(`kProfiles.modal.right`)}):(0,K.jsxs)(`div`,{className:`flex gap-4`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:T.includes(1),onChange:e=>{e.target.checked?E([...T,1]):E(T.filter(e=>e!==1))},className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:f(`kProfiles.modal.left`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:T.includes(0),onChange:e=>{e.target.checked?E([...T,0]):E(T.filter(e=>e!==0))},className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:f(`kProfiles.modal.right`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.notes`)}),(0,K.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:f(`kProfiles.modal.notesPlaceholder`),rows:2,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.notesHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[e&&(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>L(!0),disabled:F.isPending||D||!d(`kprofiles:delete`),title:d(`kprofiles:delete`)?void 0:f(`kProfiles.permission.noDelete`),className:`text-red-500 hover:bg-red-500/10`,children:F.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:c,disabled:D,className:`flex-1`,children:f(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:P.isPending||D||!d(e?`kprofiles:update`:`kprofiles:create`),title:d(e?`kprofiles:update`:`kprofiles:create`)?void 0:f(e?`kProfiles.permission.noUpdate`:`kProfiles.permission.noCreate`),className:`flex-1`,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(hc,{className:`w-4 h-4`}),f(`common.save`)]})]})]})]})]}),I&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-[60]`,children:(0,K.jsx)(_d,{className:`w-full max-w-sm`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(bu,{className:`w-5 h-5 text-red-500`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:f(`kProfiles.deleteConfirm.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:f(`kProfiles.deleteConfirm.cannotUndo`)})]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:f(`kProfiles.deleteConfirm.message`,{name:e?.name})}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>L(!1),className:`flex-1`,children:f(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>{L(!1),R()},disabled:F.isPending,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[F.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),f(`common.delete`)]})]})]})})})]})}var f6={NOZZLE_DIAMETER:`bambusy_kprofiles_nozzle`,SORT_OPTION:`bambusy_kprofiles_sort`};function iUe(){let{t:e}=W(),{showToast:t}=Td(),{hasPermission:n}=dd(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(()=>localStorage.getItem(f6.NOZZLE_DIAMETER)||`0.4`),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(`all`),[b,x]=(0,y.useState)(()=>localStorage.getItem(f6.SORT_OPTION)||`name`),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(new Set),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),A=(0,y.useCallback)(e=>`${e.slot_id}_${e.extruder_id}`,[]);(0,y.useEffect)(()=>{localStorage.setItem(f6.NOZZLE_DIAMETER,a)},[a]),(0,y.useEffect)(()=>{localStorage.setItem(f6.SORT_OPTION,b)},[b]);let{data:j,isLoading:M}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:N,isLoading:P,isFetching:F,error:I,refetch:L}=q({queryKey:[`kprofiles`,r,a],queryFn:async()=>{console.log(`[KProfiles] Fetching profiles for printer`,r,`nozzle`,a);let e=await Q.getKProfiles(r,a);return console.log(`[KProfiles] Received profiles:`,e?.profiles?.length||0,`profiles`),e},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:`always`}),{data:R}=q({queryKey:[`kprofiles`,r,`0.4`],queryFn:()=>Q.getKProfiles(r,`0.4`),enabled:!!r,staleTime:6e4}),{data:z}=q({queryKey:[`builtinFilaments`],queryFn:()=>Q.getBuiltinFilaments(),staleTime:3e5}),{data:B}=q({queryKey:[`filamentIdMap`],queryFn:()=>Q.getFilamentIdMap(),staleTime:3e5}),{data:V,refetch:ee}=q({queryKey:[`kprofile-notes`,r],queryFn:()=>Q.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),te=I?.message?.includes(`not connected`);(0,y.useEffect)(()=>{if(!r&&j&&j.length>0){let e=j.find(e=>e.is_active);e&&i(e.id)}},[r,j]),(0,y.useEffect)(()=>{if(r){let e=setTimeout(()=>{L()},150);return()=>clearTimeout(e)}},[r,a]);let ne=j?.filter(e=>e.is_active)||[],re=y.useMemo(()=>{let e=new Map;if(z)for(let t of z)e.set(t.filament_id,t.name);if(B)for(let[t,n]of Object.entries(B))e.has(t)||e.set(t,n);return e},[z,B]),ie=y.useMemo(()=>Array.from(re.entries()).map(([e,t])=>({filament_id:e,name:t})),[re]),H=y.useCallback(e=>re.get(e.filament_id)||l6(e.name),[re]),ae=y.useMemo(()=>N?.profiles?N.profiles.filter(e=>{let t=p.toLowerCase(),n=!t||e.name.toLowerCase().includes(t)||e.filament_id.toLowerCase().includes(t),r=h===`all`||h===`left`&&e.extruder_id===1||h===`right`&&e.extruder_id===0,i=_===`all`||_===`hf`&&e.nozzle_id.startsWith(`HH`)||_===`s`&&e.nozzle_id.startsWith(`HS`);return n&&r&&i}).sort((e,t)=>{switch(b){case`k_value`:return parseFloat(e.k_value)-parseFloat(t.k_value);case`filament`:return H(e).localeCompare(H(t));default:return e.name.localeCompare(t.name)}}):[],[N?.profiles,p,h,_,b,H]),oe=j?.find(e=>e.id===r),U=oe?.nozzle_count===2;(0,y.useEffect)(()=>{let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement||s||l||d||(e.key===`r`||e.key===`R`?(e.preventDefault(),L()):e.key===`n`||e.key===`N`?(e.preventDefault(),u(!0)):e.key===`Escape`&&S&&(e.preventDefault(),C(!1),T(new Set)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,l,d,S,L]);let se=(0,y.useCallback)(()=>{if(!N?.profiles||N.profiles.length===0){t(e(`kProfiles.toast.noProfilesToExport`),`error`);return}let n={version:1,exported_at:new Date().toISOString(),printer:oe?.name||`Unknown`,nozzle_diameter:a,profiles:N.profiles.map(e=>({name:e.name,k_value:e.k_value,filament_id:e.filament_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,extruder_id:e.extruder_id}))},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=`kprofiles_${oe?.name||`printer`}_${a}mm_${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i),t(e(`kProfiles.toast.exportedProfiles`,{count:N.profiles.length}))},[N?.profiles,oe,a,t,e]),ce=(0,y.useCallback)(()=>{let n=document.createElement(`input`);n.type=`file`,n.accept=`.json`,n.onchange=async n=>{let i=n.target.files?.[0];if(i)try{let n=await i.text(),o=JSON.parse(n);if(!o.profiles||!Array.isArray(o.profiles)){t(e(`kProfiles.toast.invalidFileFormat`),`error`);return}let s=0;for(let e of o.profiles)if(!(!e.name||!e.k_value||!e.filament_id))try{await Q.setKProfile(r,{name:e.name,k_value:parseFloat(e.k_value).toFixed(6),filament_id:e.filament_id,nozzle_id:e.nozzle_id||`HH00-${a}`,nozzle_diameter:e.nozzle_diameter||a,extruder_id:e.extruder_id??0,slot_id:0}),s++,await new Promise(e=>setTimeout(e,500))}catch(t){console.error(`Failed to import profile:`,e.name,t)}t(e(`kProfiles.toast.importedProfiles`,{count:s,total:o.profiles.length})),L()}catch(n){console.error(`Import error:`,n),t(e(`kProfiles.toast.failedToParseImport`),`error`)}},n.click()},[r,a,t,L,e]),le=(0,y.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ue=(0,y.useCallback)(()=>{T(new Set(ae.map(e=>A(e))))},[ae,A]),de=(0,y.useCallback)(()=>{w.size!==0&&D(!0)},[w.size]),fe=(0,y.useCallback)(async()=>{let n=ae.filter(e=>w.has(A(e)));k(!0);let i=0;for(let e of n)try{await Q.deleteKProfile(r,{slot_id:e.slot_id,extruder_id:e.extruder_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,filament_id:e.filament_id,setting_id:e.setting_id}),i++,await new Promise(e=>setTimeout(e,300))}catch(t){console.error(`Failed to delete profile:`,e.name,t)}t(e(`kProfiles.toast.profilesDeleted`,{count:i})),k(!1),D(!1),C(!1),T(new Set),L()},[r,w,ae,t,L,A,e]),pe=(0,y.useCallback)(e=>{let t=[];return e.setting_id&&t.push(e.setting_id),t.push(`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`),t.push(`name_${e.name}_${e.filament_id}`),t},[]),me=(0,y.useCallback)(async(n,i)=>{if(r)try{await Q.setKProfileNote(r,n,i),ee()}catch(n){console.error(`Failed to save note:`,n),t(e(`kProfiles.toast.failedToSaveNote`),`error`)}},[r,ee,t,e]),he=(0,y.useCallback)(e=>{if(!V?.notes)return{note:``,key:null};let t=pe(e);for(let e of t)if(V.notes[e])return{note:V.notes[e],key:e};return{note:``,key:null}},[V,pe]),ge=(0,y.useCallback)(e=>he(e).note,[he]);return M?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):!j||j.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(ds,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noPrintersConfigured`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.addPrinterInSettings`)})]})}):ne.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Tl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noActivePrinters`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.enablePrinterConnection`)})]})}):(0,K.jsxs)(K.Fragment,{children:[F&&!P&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40`,children:[(0,K.jsx)(X,{className:`w-10 h-10 text-bambu-green animate-spin mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`kProfiles.loadingProfiles`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-48`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.printer`)}),(0,K.jsx)(`select`,{value:r||``,onChange:e=>i(parseInt(e.target.value)),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:ne.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,K.jsxs)(`div`,{className:`w-32`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.nozzle`)}),(0,K.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,K.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,K.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,K.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>L(),disabled:F||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noRead`),children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${F?`animate-spin`:``}`}),e(`kProfiles.refresh`)]}),(0,K.jsxs)($,{onClick:()=>u(!0),disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noCreate`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`kProfiles.addProfile`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-48 relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:e(`kProfiles.searchPlaceholder`),className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),U&&(0,K.jsx)(`div`,{className:`w-36`,children:(0,K.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`kProfiles.allExtruders`)}),(0,K.jsx)(`option`,{value:`left`,children:e(`kProfiles.leftOnly`)}),(0,K.jsx)(`option`,{value:`right`,children:e(`kProfiles.rightOnly`)})]})}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`kProfiles.allFlow`)}),(0,K.jsx)(`option`,{value:`hf`,children:e(`kProfiles.hfOnly`)}),(0,K.jsx)(`option`,{value:`s`,children:e(`kProfiles.sOnly`)})]})}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`name`,children:e(`kProfiles.sortName`)}),(0,K.jsx)(`option`,{value:`k_value`,children:e(`kProfiles.sortKValue`)}),(0,K.jsx)(`option`,{value:`filament`,children:e(`kProfiles.sortFilament`)})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:se,disabled:!N?.profiles?.length||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noExport`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),e(`kProfiles.export`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:ce,disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noImport`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),e(`kProfiles.import`)]}),(0,K.jsx)(`div`,{className:`flex-1`}),S?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,onClick:ue,children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),e(`kProfiles.selectAll`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:de,disabled:w.size===0||!n(`kprofiles:delete`),className:`text-red-500 hover:bg-red-500/10`,title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`kProfiles.delete`),` (`,w.size,`)`]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{C(!1),T(new Set)},children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),e(`common.cancel`)]})]}):(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!0),disabled:!ae.length||!n(`kprofiles:delete`),title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),e(`kProfiles.select`)]})]}),P?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):te?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Pu,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.printerOffline`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.printerOfflineDesc`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>L(),children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`common.refresh`)]})]})}):ae.length>0?U?(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.leftExtruder`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.filter(e=>e.extruder_id===1).map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.rightExtruder`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.filter(e=>e.extruder_id===0).map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))})]})]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))}):p||h!==`all`||_!==`all`?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noMatchingProfiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.noMatchingProfilesDesc`)})]})}):(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(hc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noKProfiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.noKProfilesDesc`,{diameter:a})}),(0,K.jsxs)($,{onClick:()=>u(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`kProfiles.createFirstProfile`)]})]})}),s&&r&&(()=>{let{note:e,key:t}=he(s);return(0,K.jsx)(d6,{profile:s,printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,initialNote:e,initialNoteKey:t,onSaveNote:me,hasPermission:n,onClose:()=>{console.log(`[KProfiles] Edit modal onClose - refetching profiles...`),c(null),L()},onSave:()=>{c(null),L()}})})(),l&&r&&(0,K.jsx)(d6,{printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,onSaveNote:me,hasPermission:n,onClose:()=>{u(!1),L()},onSave:()=>{u(!1),L()}}),d&&r&&(0,K.jsx)(d6,{printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,onSaveNote:me,hasPermission:n,profile:{...d,slot_id:0,name:`${d.name} (Copy)`},onClose:()=>{f(null),L()},onSave:()=>{f(null),L()}}),E&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-sm`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(bu,{className:`w-5 h-5 text-red-500`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e(`kProfiles.bulkDelete.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`kProfiles.bulkDelete.cannotUndo`)})]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:e(`kProfiles.bulkDelete.message`,{count:w.size})}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>D(!1),disabled:O,className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsxs)($,{onClick:fe,disabled:O,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`common.delete`)]})]})]})})})]})}var p6=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`PVA`,`HIPS`,`PP`,`PET`,`NYLON`],aUe={PLA:`E8E8E8`,PETG:`4A90D9`,ABS:`E67E22`,ASA:`D35400`,TPU:`9B59B6`,PC:`BDC3C7`,PA:`2ECC71`,NYLON:`2ECC71`,PVA:`F1C40F`,HIPS:`95A5A6`,PP:`ECF0F1`,PET:`3498DB`};function oUe(e){let t=e.toUpperCase();for(let e of p6)if(RegExp(`\\b${e}\\b`).test(t))return e;return null}function sUe(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase();for(let e of p6){let r=n.indexOf(e);if(r>0){let e=t.slice(0,r).trim();if(e&&e.length>1)return e}}return null}function m6({preset:e,onDelete:t,onExpand:n,isExpanded:r}){let{t:i}=W(),{hasPermission:a}=dd(),o=e.filament_type||oUe(e.name),s=e.filament_vendor||sUe(e.name),c=null,l=!1;if(e.default_filament_colour)try{let t=JSON.parse(e.default_filament_colour),n=Array.isArray(t)?t[0]:t;typeof n==`string`&&/^#?[0-9a-fA-F]{6,8}$/.test(n.replace(`#`,``))&&(c=n.replace(`#`,``).slice(0,6),l=!0)}catch{let t=e.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(t.replace(`#`,``))&&(c=t.replace(`#`,``).slice(0,6),l=!0)}return!c&&o&&(c=aUe[o.toUpperCase()]||null),(0,K.jsx)(_d,{className:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors`,children:(0,K.jsxs)(yd,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[e.preset_type===`filament`&&(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0 ${!l&&!c?`opacity-25`:l?``:`opacity-50`}`,style:{backgroundColor:c?`#${c}`:`#666`}}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:o}),s&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s}),(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400`,children:i(`profiles.localProfiles.badge`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[a(`settings:update`)&&(0,K.jsx)(`button`,{onClick:()=>t(e.id),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,title:i(`profiles.localProfiles.delete`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>n(r?null:e.id),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:r?(0,K.jsx)(cs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(is,{className:`w-3.5 h-3.5`})})]})]}),r&&(0,K.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5`,children:[o&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.filamentType`)}),(0,K.jsx)(`span`,{className:`text-white`,children:o})]}),s&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.vendor`)}),(0,K.jsx)(`span`,{className:`text-white`,children:s})]}),e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.nozzleTemp`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[e.nozzle_temp_min,`–`,e.nozzle_temp_max,`°C`]})]}),e.filament_cost&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.cost`)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.filament_cost})]}),e.filament_density&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.density`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[e.filament_density,` g/cm³`]})]}),e.pressure_advance&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.pressureAdvance`)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.pressure_advance})]}),e.compatible_printers&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.compatiblePrinters`)}),(0,K.jsx)(`span`,{className:`text-white truncate ml-2`,children:(()=>{try{return JSON.parse(e.compatible_printers).join(`, `)}catch{return e.compatible_printers}})()})]}),e.inherits&&e.inherits!==e.name&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.inheritsFrom`)}),(0,K.jsx)(`span`,{className:`text-white truncate ml-2`,children:e.inherits})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.source`)}),(0,K.jsx)(`span`,{className:`text-white capitalize`,children:e.source})]})]})]})})}function cUe(){let{t:e}=W(),{hasPermission:t}=dd(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),{data:f,isLoading:p}=q({queryKey:[`localPresets`],queryFn:()=>Q.getLocalPresets()}),m=J({mutationFn:async e=>{let t=[];for(let n of Array.from(e)){let e=new FormData;e.append(`file`,n),t.push(await Q.importLocalPresets(e))}return t},onSuccess:t=>{n.invalidateQueries({queryKey:[`localPresets`]}),n.invalidateQueries({queryKey:[`slicerPresets`]});let i=0,a=0,o=0;for(let e of t)i+=e.imported,a+=e.skipped,o+=e.errors.length;i>0&&r(e(`profiles.localProfiles.toast.importSuccess`,{count:i})),a>0&&r(e(`profiles.localProfiles.toast.importSkipped`,{count:a}),`warning`),o>0&&r(e(`profiles.localProfiles.toast.importError`,{count:o}),`error`)},onError:e=>{r(e.message,`error`)}}),h=J({mutationFn:e=>Q.deleteLocalPreset(e),onSuccess:(t,i)=>{n.setQueryData([`localPresets`],e=>e&&{filament:e.filament.filter(e=>e.id!==i),printer:e.printer.filter(e=>e.id!==i),process:e.process.filter(e=>e.id!==i)}),n.invalidateQueries({queryKey:[`localPresets`]}),n.invalidateQueries({queryKey:[`slicerPresets`]}),d(null),r(e(`profiles.localProfiles.toast.deleted`))}}),g=(0,y.useCallback)(e=>{!e||e.length===0||m.mutate(e)},[m]),_=(0,y.useCallback)(e=>{e.preventDefault(),l(!1),g(e.dataTransfer.files)},[g]),v=(0,y.useCallback)(e=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.filament_type?.toLowerCase().includes(t)||e.filament_vendor?.toLowerCase().includes(t))},[i]),b=(0,y.useMemo)(()=>v(f?.filament||[]),[f?.filament,v]),x=(0,y.useMemo)(()=>v(f?.printer||[]),[f?.printer,v]),S=(0,y.useMemo)(()=>v(f?.process||[]),[f?.process,v]),C=b.length+x.length+S.length,w=(f?.filament?.length??0)+(f?.printer?.length??0)+(f?.process?.length??0)>0;return p?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[t(`settings:update`)&&(0,K.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:_,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`input`,{type:`file`,accept:`.json,.zip,.orca_filament,.bbscfg,.bbsflmt`,multiple:!0,className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,onChange:e=>g(e.target.files)}),m.isPending?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.importing`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-8 h-8 text-bambu-gray mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`profiles.localProfiles.import`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`profiles.localProfiles.importDesc`)})]})]}),w&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:e(`profiles.localProfiles.search`),className:`w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})]}),!w&&!p&&(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(wc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noPresets`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:e(`profiles.localProfiles.importDesc`)})]}),w&&C===0&&!p&&(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noSearchResults`)})]}),C>0&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:[b.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Hs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.filament`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,b.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),S.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.process`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,S.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),x.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4 text-orange-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.printer`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,x.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]})]}),u!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-red-400`}),(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:e(`profiles.localProfiles.deleteConfirmTitle`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`profiles.localProfiles.deleteConfirm`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>d(null),children:e(`profiles.localProfiles.cancel`)}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>h.mutate(u),disabled:h.isPending,children:[h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`profiles.localProfiles.delete`)]})]})]})})]})}function lUe(e){let t=e.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),n=e.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),r=e.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),i=e.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i);return{printer:t?t[1].trim():null,nozzle:n?(n[1]||n[2])+`mm`:null,layerHeight:r?r[1]+`mm`:null,filamentType:i?i[1].toUpperCase():null}}function uUe({settings:e,lastSyncTime:t,onRefresh:n,isRefreshing:r,printers:i,t:a}){let[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(`all`),[u,d]=(0,y.useState)(`all`),[f,p]=(0,y.useState)(`all`),[m,h]=(0,y.useState)(`all`),[g,_]=(0,y.useState)(`all`),[v,b]=(0,y.useState)(null),x=(0,y.useMemo)(()=>[...e.filament.map(e=>({...e,type:`filament`})),...e.printer.map(e=>({...e,type:`printer`})),...e.process.map(e=>({...e,type:`process`}))].map(e=>({...e,meta:lUe(e.name)})),[e]),S=(0,y.useMemo)(()=>{let e=new Set,t=new Set,n=new Set;return x.forEach(r=>{r.meta.nozzle&&e.add(r.meta.nozzle),r.meta.filamentType&&t.add(r.meta.filamentType),r.meta.layerHeight&&n.add(r.meta.layerHeight)}),{printers:i.map(e=>({id:e.id.toString(),name:e.name})),nozzles:Array.from(e).sort((e,t)=>parseFloat(e)-parseFloat(t)),filaments:Array.from(t).sort(),layerHeights:Array.from(n).sort((e,t)=>parseFloat(e)-parseFloat(t))}},[x,i]),C=(0,y.useMemo)(()=>u===`all`?null:i.find(e=>e.id.toString()===u)?.model||null,[u,i]),w=(0,y.useMemo)(()=>x.filter(e=>c===`all`||e.type===c).filter(e=>{if(u===`all`||!C)return!0;let t=e.meta.printer?.toLowerCase()||``,n=C.toLowerCase();return t.includes(n)||n.includes(t)}).filter(e=>f===`all`||e.meta.nozzle===f).filter(e=>m===`all`||e.meta.filamentType===m).filter(e=>g===`all`||e.meta.layerHeight===g).filter(e=>o===``||e.name.toLowerCase().includes(o.toLowerCase())).sort((e,t)=>e.name.localeCompare(t.name)),[x,c,u,C,f,m,g,o]),T=()=>{l(`all`),d(`all`),p(`all`),h(`all`),_(`all`),s(``)},E=c!==`all`||u!==`all`||f!==`all`||m!==`all`||g!==`all`||o!==``,D=e.filament.length+e.printer.length+e.process.length,O=e=>w.filter(t=>t.type===e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`profiles.cloudView.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{variant:`secondary`,onClick:n,disabled:r,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),a(`profiles.cloudView.refresh`)]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.type`),value:c,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`),count:D},{value:`filament`,label:a(`profiles.cloudView.filters.filament`),count:e.filament.length},{value:`printer`,label:a(`profiles.cloudView.filters.printer`),count:e.printer.length},{value:`process`,label:a(`profiles.cloudView.filters.process`),count:e.process.length}],onChange:e=>l(e)}),S.printers.length>0&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.printer`),value:u,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.printers.map(e=>({value:e.id,label:e.name}))],onChange:d}),S.nozzles.length>0&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.nozzle`),value:f,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.nozzles.map(e=>({value:e,label:e}))],onChange:p}),S.filaments.length>0&&(c===`all`||c===`filament`)&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.filament`),value:m,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.filaments.map(e=>({value:e,label:e}))],onChange:h}),S.layerHeights.length>0&&(c===`all`||c===`process`)&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.layer`),value:g,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.layerHeights.map(e=>({value:e,label:e}))],onChange:_}),E&&(0,K.jsx)(`button`,{onClick:T,className:`px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:a(`profiles.cloudView.clearFilters`)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),a(`profiles.cloudView.lastSynced`),` `,wf(t.toISOString(),`system`,a)]}),(0,K.jsx)(`span`,{children:a(`profiles.cloudView.showingCount`,{showing:w.length,total:D})})]}),w.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:a(`profiles.cloudView.noPresetsFound`)}),E&&(0,K.jsx)(`button`,{onClick:T,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:a(`profiles.cloudView.clearFilters`)})]}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,K.jsx)(h6,{icon:(0,K.jsx)(Hs,{className:`w-4 h-4 text-amber-400`}),title:a(`profiles.cloudView.columns.filament`),presets:O(`filament`),emptyText:a(`profiles.cloudView.noFilamentPresets`),onSelect:b}),(0,K.jsx)(h6,{icon:(0,K.jsx)(Hl,{className:`w-4 h-4 text-blue-400`}),title:a(`profiles.cloudView.columns.process`),presets:O(`process`),emptyText:a(`profiles.cloudView.noProcessPresets`),onSelect:b}),(0,K.jsx)(h6,{icon:(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),title:a(`profiles.cloudView.columns.printer`),presets:O(`printer`),emptyText:a(`profiles.cloudView.noPrinterPresets`),onSelect:b})]}),v&&(0,K.jsx)(fUe,{setting:v,onClose:()=>b(null),t:a})]})}function h6({icon:e,title:t,presets:n,emptyText:r,onSelect:i}){return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[e,(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:t}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,n.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:n.length===0?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:r}):n.map(e=>(0,K.jsx)(dUe,{preset:e,onClick:()=>i(e)},e.setting_id))})]})}function dUe({preset:e,onClick:t}){return(0,K.jsx)(`button`,{onClick:t,className:`w-full text-left px-3 py-2 rounded bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),e.meta.filamentType&&e.type===`filament`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.filamentType}),e.meta.layerHeight&&e.type===`process`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.layerHeight}),e.meta.printer&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.printer})]})})}function fUe({setting:e,onClose:t,t:n}){let{data:r,isLoading:i,error:a}=q({queryKey:[`orcaCloudProfileDetail`,e.setting_id],queryFn:()=>Q.orcaCloudGetProfile(e.setting_id),retry:!1});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-2xl max-w-4xl w-full max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e.type})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:i?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:a.message}):r?(0,K.jsx)(`pre`,{className:`text-xs font-mono text-bambu-gray bg-bambu-dark p-3 rounded overflow-x-auto whitespace-pre`,children:JSON.stringify(r.setting,null,2)}):(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:n(`profiles.cloudView.noPresetsFound`)})})]})})}function pUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),i=r(`orca_cloud:auth`),[a,o]=(0,y.useState)(`picker`),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(null),{data:b,isLoading:x}=q({queryKey:[`orcaCloudStatus`],queryFn:Q.orcaCloudStatus}),S=!!b?.connected,{data:C,isLoading:w,refetch:T,isRefetching:E,error:D,dataUpdatedAt:O}=q({queryKey:[`orcaCloudProfiles`],queryFn:Q.orcaCloudListProfiles,enabled:S,retry:!1,staleTime:1e3*60*5}),{data:k=[]}=q({queryKey:[`printers`],queryFn:Q.getPrinters,enabled:S}),[A,j]=(0,y.useState)();(0,y.useEffect)(()=>{O&&j(new Date(O))},[O]);let M=J({mutationFn:e=>Q.orcaCloudStartAuth(e),onSuccess:e=>{c(e.auth_url),u(``),f(null),o(`paste`),window.open(e.auth_url,`_blank`,`noopener,noreferrer`)},onError:t=>{n(t.message||e(`profiles.orcaCloud.errors.startFailed`),`error`)}}),N=J({mutationFn:e=>Q.orcaCloudFinishAuth(e),onSuccess:r=>{c(null),u(``),f(null),o(`picker`),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.connected`,{email:r.email||``}))},onError:t=>{f(t.message||e(`profiles.orcaCloud.errors.finishFailed`))}}),P=J({mutationFn:({email:e,password:t})=>Q.orcaCloudPasswordLogin(e,t),onSuccess:r=>{m(``),g(``),v(null),o(`picker`),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.connected`,{email:r.email||``}))},onError:t=>{v(t.message||e(`profiles.orcaCloud.errors.passwordFailed`))}}),F=J({mutationFn:Q.orcaCloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.removeQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.disconnected`))}});return x?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{children:[S&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`profiles.orcaCloud.connectedAs`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:b?.email})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>F.mutate(),disabled:F.isPending||!i,title:i?void 0:e(`profiles.orcaCloud.noLogoutPermission`),children:[(0,K.jsx)(Yc,{className:`w-4 h-4`}),e(`profiles.orcaCloud.logout`)]})]}),S?w?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):D?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:D.message}),(0,K.jsx)($,{onClick:()=>T(),children:e(`profiles.orcaCloud.retry`)})]}):C?(0,K.jsx)(uUe,{settings:C,lastSyncTime:A,onRefresh:()=>T(),isRefreshing:E,printers:k,t:e}):null:(0,K.jsx)(mUe,{mode:a,authUrl:s,pastedUrl:l,setPastedUrl:u,pasteError:d,passwordEmail:p,setPasswordEmail:m,passwordValue:h,setPasswordValue:g,passwordError:_,onPickProvider:e=>M.mutate(e),onPickPassword:()=>{o(`password`),v(null)},onSubmitPaste:t=>{t.preventDefault(),f(null);let n=l.trim();if(!n){f(e(`profiles.orcaCloud.errors.emptyPaste`));return}if(!n.includes(`code=`)){f(e(`profiles.orcaCloud.errors.noCode`));return}N.mutate(n)},onSubmitPassword:t=>{t.preventDefault(),v(null);let n=p.trim();if(!n||!h){v(e(`profiles.orcaCloud.errors.passwordEmpty`));return}P.mutate({email:n,password:h})},onBack:()=>{o(`picker`),c(null),u(``),f(null),m(``),g(``),v(null)},isStarting:M.isPending,isFinishing:N.isPending,isPasswordLoading:P.isPending,canManage:i,t:e})]})}function mUe(e){return e.mode===`paste`&&e.authUrl?(0,K.jsx)(gUe,{...e,authUrl:e.authUrl}):e.mode===`password`?(0,K.jsx)(_Ue,{...e}):(0,K.jsx)(hUe,{...e})}function hUe({onPickProvider:e,onPickPassword:t,isStarting:n,canManage:r,t:i}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-8 text-center`,children:[(0,K.jsx)(ws,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:i(`profiles.orcaCloud.connect.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6 max-w-xl mx-auto`,children:i(`profiles.orcaCloud.connect.description`)}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 max-w-sm mx-auto`,children:[(0,K.jsxs)($,{onClick:t,disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.email`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`google`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[n?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.google`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`github`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.github`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`apple`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.apple`)]})]})]})})}function gUe({authUrl:e,pastedUrl:t,setPastedUrl:n,pasteError:r,onSubmitPaste:i,onBack:a,isFinishing:o,t:s}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`text-bambu-gray hover:text-white text-sm flex items-center gap-1 mb-4`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),s(`profiles.orcaCloud.back`)]}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-4`,children:s(`profiles.orcaCloud.paste.title`)}),(0,K.jsxs)(`ol`,{className:`space-y-3 mb-6`,children:[(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-bambu-dark-tertiary text-white text-sm font-bold flex items-center justify-center`,children:`1`}),(0,K.jsx)(`p`,{className:`text-base text-white pt-0.5`,children:s(`profiles.orcaCloud.paste.step1`)})]}),(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-amber-500/20 text-amber-400 text-sm font-bold flex items-center justify-center`,children:`2`}),(0,K.jsx)(`div`,{className:`flex-1 p-3 bg-amber-500/10 border border-amber-500/40 rounded`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-base text-white font-medium`,children:s(`profiles.orcaCloud.paste.step2`)})]})})]}),(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-bambu-dark-tertiary text-white text-sm font-bold flex items-center justify-center`,children:`3`}),(0,K.jsx)(`p`,{className:`text-base text-white pt-0.5`,children:s(`profiles.orcaCloud.paste.step3`)})]})]}),(0,K.jsxs)(`div`,{className:`mb-4 p-3 bg-bambu-dark rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:s(`profiles.orcaCloud.paste.signInUrl`)}),(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green text-sm break-all hover:underline`,children:e})]}),(0,K.jsxs)(`form`,{onSubmit:i,children:[(0,K.jsx)(`label`,{htmlFor:`orca-callback-url`,className:`block text-sm text-bambu-gray mb-2`,children:s(`profiles.orcaCloud.paste.label`)}),(0,K.jsx)(`textarea`,{id:`orca-callback-url`,value:t,onChange:e=>n(e.target.value),placeholder:s(`profiles.orcaCloud.paste.placeholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono resize-none focus:outline-none focus:border-bambu-green`,rows:3,disabled:o}),r&&(0,K.jsxs)(`p`,{className:`mt-2 text-sm text-red-400 flex items-center gap-2`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),r]}),(0,K.jsx)(`div`,{className:`mt-4 flex items-center gap-3`,children:(0,K.jsxs)($,{type:`submit`,disabled:o||!t.trim(),children:[o?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),s(`profiles.orcaCloud.paste.submit`)]})})]})]})})}function _Ue({passwordEmail:e,setPasswordEmail:t,passwordValue:n,setPasswordValue:r,passwordError:i,onSubmitPassword:a,onBack:o,isPasswordLoading:s,t:c}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-6 max-w-md mx-auto`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:o,className:`text-bambu-gray hover:text-white text-sm flex items-center gap-1 mb-4`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),c(`profiles.orcaCloud.back`)]}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-4`,children:c(`profiles.orcaCloud.password.title`)}),(0,K.jsxs)(`form`,{onSubmit:a,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`orca-password-email`,className:`block text-sm text-bambu-gray mb-1`,children:c(`profiles.orcaCloud.password.email`)}),(0,K.jsx)(`input`,{id:`orca-password-email`,type:`email`,value:e,onChange:e=>t(e.target.value),placeholder:c(`profiles.orcaCloud.password.emailPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,disabled:s,autoComplete:`email`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`orca-password-value`,className:`block text-sm text-bambu-gray mb-1`,children:c(`profiles.orcaCloud.password.password`)}),(0,K.jsx)(`input`,{id:`orca-password-value`,type:`password`,value:n,onChange:e=>r(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,disabled:s,autoComplete:`current-password`})]}),i&&(0,K.jsxs)(`p`,{className:`text-sm text-red-400 flex items-center gap-2`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),i]}),(0,K.jsxs)($,{type:`submit`,disabled:s||!e.trim()||!n,children:[s?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),c(`profiles.orcaCloud.password.submit`)]})]})]})})}function g6(e,t){let n=`${e} ${t||``}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+`mm`:null,s=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=s?s[1]+`mm`:null,l=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i);return{printer:i,nozzle:o,layerHeight:c,filamentType:l?l[1].toUpperCase():null}}function _6(e){return/^(P[FPM]US|PF\d|PP\d)/.test(e)}function vUe({onSuccess:e,t}){let{showToast:n}=Td(),[r,i]=(0,y.useState)(`email`),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(`global`),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),b=J({mutationFn:()=>Q.cloudLogin(a,s,p),onSuccess:r=>{r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):r.needs_verification?(g(r.verification_type||`email`),v(r.tfa_key||null),r.verification_type===`totp`?n(t(`profiles.login.toast.enterTotp`)):n(t(`profiles.login.toast.codeSent`)),i(`code`)):n(r.message,`error`)},onError:e=>n(e.message,`error`)}),x=J({mutationFn:()=>Q.cloudVerify(a,l,_||void 0,p),onSuccess:r=>{r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):n(r.message,`error`)},onError:e=>n(e.message,`error`)}),S=J({mutationFn:()=>Q.cloudSetToken(d,p),onSuccess:()=>{n(t(`profiles.login.toast.tokenSet`)),e()},onError:e=>n(e.message,`error`)}),C=e=>{e.preventDefault(),r===`email`?b.mutate():r===`code`?x.mutate():r===`token`&&S.mutate()},w=b.isPending||x.isPending||S.isPending;return(0,K.jsx)(_d,{className:`max-w-md mx-auto`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,K.jsx)(`div`,{className:`inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3`,children:(0,K.jsx)(ws,{className:`w-6 h-6 text-bambu-green`})}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:t(`profiles.login.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:t(`profiles.login.subtitle`)})]}),(0,K.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[r===`email`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.email`)}),(0,K.jsx)(`input`,{type:`email`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,placeholder:`your@email.com`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.password`)}),(0,K.jsx)(`input`,{type:`password`,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,placeholder:`••••••••`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,K.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),r===`code`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(h===`totp`?`profiles.login.totpCode`:`profiles.login.verificationCode`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:h===`totp`?t(`profiles.login.enterTotpHint`):t(`profiles.login.checkEmail`,{email:a})}),(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none`,placeholder:`000000`,maxLength:6,required:!0})]}),r===`token`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.accessToken`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:t(`profiles.login.accessTokenHint`)}),(0,K.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none`,placeholder:`eyJ...`,rows:4,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,K.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[r===`code`&&(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>i(`email`),className:`flex-1`,children:t(`profiles.login.back`)}),(0,K.jsxs)($,{type:`submit`,disabled:w,className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Jc,{className:`w-4 h-4`}),t(r===`email`?`profiles.login.loginButton`:r===`code`?`profiles.login.verifyButton`:`profiles.login.setTokenButton`)]})]}),r===`email`&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(`token`),className:`text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),t(`profiles.login.useToken`)]})}),r===`token`&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(`email`),className:`text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors`,children:[(0,K.jsx)(Jc,{className:`w-4 h-4`}),t(`profiles.login.useEmail`)]})})]})]})})}function v6({label:e,value:t,options:n,onChange:r}){let[i,a]=(0,y.useState)(!1),o=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e,`:`]}),(0,K.jsx)(`span`,{children:o?.label||`All`}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,K.jsx)(`div`,{className:`absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto`,children:n.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{r(e.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${t===e.value?`text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`span`,{children:e.label}),e.count!==void 0&&(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.count})]},e.value))})]})]})}function yUe(){let[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{let e=()=>{t(window.scrollY>300)};return window.addEventListener(`scroll`,e),()=>window.removeEventListener(`scroll`,e)},[]),e?(0,K.jsx)(`button`,{onClick:()=>{window.scrollTo({top:0,behavior:`smooth`})},className:`fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40`,"aria-label":`Scroll to top`,children:(0,K.jsx)(Io,{className:`w-5 h-5`})}):null}function y6({setting:e,onClick:t,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:s}){let c=g6(e.name),l=_6(e.setting_id);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 group`,children:[(0,K.jsx)(`button`,{onClick:t,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?`bg-blue-500/20 border border-blue-500/50`:o?`bg-bambu-dark/50 opacity-40 cursor-not-allowed`:`bg-bambu-dark hover:bg-bambu-dark-tertiary`} ${r&&!o?`cursor-pointer`:``}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&a!==void 0&&(0,K.jsx)(`span`,{className:`flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium`,children:a+1}),!i&&l&&(0,K.jsx)(`span`,{className:`flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green`,title:s(`profiles.presets.myPreset`)}),(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),c.filamentType&&e.type===`filament`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.filamentType}),c.layerHeight&&e.type===`process`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.layerHeight}),c.printer&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.printer})]})}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1`,title:s(`profiles.presets.duplicate`),children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})}function b6(e,t=0){let n=` `.repeat(t);if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`string`){if(e.includes(`\\n`)||e.includes(` +`)),i(!0),setTimeout(()=>i(!1),2e3)},className:`flex items-center gap-2`,children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),n(r?`common.copied`:`common.copy`)]}),(0,K.jsx)($,{variant:`primary`,size:`sm`,onClick:t,className:`flex-1`,children:n(`settings.twoFa.savedCodes`)})]})]})}function HHe({onDone:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(`qr`),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)([]),[u,d]=(0,y.useState)(!1),{data:f,isLoading:p}=q({queryKey:[`totp-setup`],queryFn:()=>Q.setupTOTP(),staleTime:1/0}),m=J({mutationFn:e=>Q.enableTOTP(e),onSuccess:e=>{l(e.backup_codes),a(`backup`),n.invalidateQueries({queryKey:[`2fa-status`]})},onError:()=>r(t(`settings.twoFa.invalidCode`),`error`)});return p||!f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})}):i===`qr`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.setupInstructions`)}),(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(`img`,{src:`data:image/png;base64,${f.qr_code_b64}`,alt:`TOTP QR Code`,className:`w-48 h-48 rounded-lg`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:t(`settings.twoFa.manualEntry`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark-secondary rounded-lg px-3 py-2`,children:[(0,K.jsx)(`code`,{className:`text-white text-xs font-mono flex-1 break-all`,children:u?f.secret:`••••••••••••••••`}),(0,K.jsx)(`button`,{onClick:()=>d(!u),className:`text-bambu-gray hover:text-white`,children:u?(0,K.jsx)(Ys,{className:`w-4 h-4`}):(0,K.jsx)(Xs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(f.secret)},className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})]}),(0,K.jsx)($,{variant:`primary`,className:`w-full`,onClick:()=>a(`confirm`),children:t(`settings.twoFa.scannedContinue`)})]}):i===`confirm`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:t(`settings.twoFa.enterCodeToConfirm`)}),(0,K.jsx)(e6,{value:o,onChange:s,placeholder:`000000`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>a(`qr`),className:`flex-1`,children:t(`common.back`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:o.length!==6||m.isPending,onClick:()=>m.mutate(o),children:m.isPending?t(`common.saving`):t(`settings.twoFa.activate`)})]})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:t(`settings.twoFa.backupCodesTitle`)}),(0,K.jsx)(t6,{codes:c,onDone:e})]})}function UHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{user:r}=dd(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(``),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(``),[T,E]=(0,y.useState)(!1),{data:D,isLoading:O}=q({queryKey:[`2fa-status`],queryFn:()=>Q.get2FAStatus()}),{data:k}=q({queryKey:[`oidc-links`],queryFn:()=>Q.getOIDCLinks()}),A=J({mutationFn:()=>Q.enableEmailOTP(),onSuccess:e=>{_(e.setup_token),n(e.message,`success`)},onError:t=>{let r=t.message??``;r.toLowerCase().includes(`smtp`)?n(e(`settings.twoFa.smtpRequired`),`error`):n(r,`error`)}}),j=J({mutationFn:()=>Q.confirmEnableEmailOTP(g,v),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),_(null),b(``),n(e(`settings.twoFa.emailOtpEnabled`),`success`)},onError:e=>n(e.message,`error`)}),M=J({mutationFn:e=>Q.disableEmailOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),S(!1),w(``),n(e(`settings.twoFa.emailOtpDisabled`),`success`)},onError:e=>n(e.message,`error`)}),N=J({mutationFn:e=>Q.disableTOTP(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`2fa-status`]}),s(!1),d(``),n(e(`settings.twoFa.totpDisabled`),`success`)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),P=J({mutationFn:e=>Q.regenerateBackupCodes(e),onSuccess:e=>{t.invalidateQueries({queryKey:[`2fa-status`]}),l(!1),p(``),h(e.backup_codes)},onError:()=>n(e(`settings.twoFa.invalidCode`),`error`)}),F=J({mutationFn:e=>Q.deleteOIDCLink(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-links`]}),n(e(`settings.twoFa.oidcUnlinked`),`success`)},onError:e=>n(e.message,`error`)});if(O)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})});let I=!!r?.email;return(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-2fa-totp`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.totp_enabled?`bg-green-500/20`:`bg-gray-500/20`}`,children:(0,K.jsx)(eu,{className:`w-5 h-5 ${D?.totp_enabled?`text-green-400`:`text-gray-400`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.totpTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.totpDesc`)})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:D?.totp_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400 text-sm font-medium`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,K.jsx)(Kl,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,K.jsx)(yd,{children:i?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.setupAuthApp`)}),(0,K.jsx)(`button`,{onClick:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})},className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(HHe,{onDone:()=>{a(!1),t.removeQueries({queryKey:[`totp-setup`]})}})]}):o?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.disableConfirmHint`)}),(0,K.jsx)(e6,{value:u,onChange:d,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{s(!1),d(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,className:`flex-1`,disabled:u.length<6||N.isPending,onClick:()=>N.mutate(u),children:N.isPending?e(`common.saving`):e(`settings.twoFa.disableTotp`)})]})]}):c?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.regenBackupHint`)}),(0,K.jsx)(e6,{value:f,onChange:p,placeholder:`000000 or XXXXXXXX`,maxLength:8}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{l(!1),p(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:f.length<6||P.isPending,onClick:()=>P.mutate(f),children:P.isPending?e(`common.saving`):e(`settings.twoFa.regenBackup`)})]})]}):m?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:e(`settings.twoFa.newBackupCodes`)}),(0,K.jsx)(t6,{codes:m,onDone:()=>h(null)})]}):(0,K.jsx)(`div`,{className:`space-y-3`,children:D?.totp_enabled?(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray-light`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),e(`settings.twoFa.backupCodesRemaining`,{count:D.backup_codes_remaining})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>l(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`settings.twoFa.regenBackup`)]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>s(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.twoFa.disableTotp`)]})]}):(0,K.jsxs)($,{variant:`primary`,onClick:()=>a(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(eu,{className:`w-4 h-4`}),e(`settings.twoFa.setupTotp`)]})})})]}),(0,K.jsxs)(_d,{id:`card-2fa-emailotp`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${D?.email_otp_enabled?`bg-green-500/20`:`bg-gray-500/20`}`,children:(0,K.jsx)(Xc,{className:`w-5 h-5 ${D?.email_otp_enabled?`text-green-400`:`text-gray-400`}`})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.emailOtpTitle`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:I?e(`settings.twoFa.emailOtpDesc`,{email:r?.email}):e(`settings.twoFa.emailOtpNoEmail`)})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:D?.email_otp_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400 text-sm font-medium`,children:[(0,K.jsx)(Gl,{className:`w-4 h-4`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray text-sm`,children:[(0,K.jsx)(Kl,{className:`w-4 h-4`}),` `,e(`common.disabled`)]})})]})}),(0,K.jsx)(yd,{children:I?g?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailSetupEnterCode`)}),(0,K.jsx)(e6,{value:v,onChange:b,placeholder:`000000`}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{_(null),b(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:v.length!==6||j.isPending,onClick:()=>j.mutate(),children:j.isPending?e(`common.saving`):e(`settings.twoFa.verifyAndEnable`)})]})]}):x?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray-light text-sm`,children:e(`settings.twoFa.emailDisablePasswordHint`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:T?`text`:`password`,value:C,onChange:e=>w(e.target.value),placeholder:e(`settings.twoFa.passwordPlaceholder`),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>E(!T),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:T?(0,K.jsx)(Ys,{className:`w-5 h-5`}):(0,K.jsx)(Xs,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{S(!1),w(``)},className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,className:`flex-1`,disabled:!C||M.isPending,onClick:()=>M.mutate(C),children:M.isPending?e(`common.saving`):e(`settings.twoFa.disableEmailOtp`)})]})]}):(0,K.jsx)(`div`,{className:`flex gap-3`,children:D?.email_otp_enabled?(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>S(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`settings.twoFa.disableEmailOtp`)]}):(0,K.jsxs)($,{variant:`primary`,disabled:!I||A.isPending,onClick:()=>A.mutate(),className:`flex items-center gap-2`,children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),A.isPending?e(`common.saving`):e(`settings.twoFa.enableEmailOtp`)]})}):(0,K.jsx)(`p`,{className:`text-amber-400 text-sm`,children:e(`settings.twoFa.addEmailFirst`)})})]}),k&&k.length>0&&(0,K.jsxs)(_d,{id:`card-2fa-linked`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.twoFa.linkedAccounts`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.twoFa.linkedAccountsDesc`)})]}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`space-y-3`,children:k.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between py-2 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:e.provider_name}),e.provider_email&&(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:e.provider_email})]}),(0,K.jsx)($,{variant:`danger`,size:`sm`,onClick:()=>F.mutate(e.provider_id),disabled:F.isPending,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]},e.id))})})]})]})}var WHe={name:``,issuer_url:``,client_id:``,client_secret:``,scopes:`openid email profile`,is_enabled:!0,auto_create_users:!1,auto_link_existing_accounts:!1,email_claim:`email`,require_email_verified:!0,icon_url:void 0,default_group_id:null};function n6({initial:e,isEdit:t=!1,groups:n=[],onSave:r,onCancel:i,isPending:a}){let{t:o}=W(),[s,c]=(0,y.useState)(e),[l,u]=(0,y.useState)(!1),d=(e,t)=>c(n=>({...n,[e]:t})),f=`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors text-sm`,p=`block text-sm font-medium text-white mb-1`,m=()=>{let e={...s};t&&!l&&delete e.client_secret,r(e)},h=s.auto_link_existing_accounts===!0,g=s.require_email_verified??!0,_;return _=h?o(`settings.oidc.form.requireEmailVerifiedAutoLink`):g?o(`settings.oidc.form.requireEmailVerifiedDesc`):(0,K.jsx)(`span`,{className:`text-red-400`,children:o(`settings.oidc.form.requireEmailVerifiedWarning`)}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.name`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.name,onChange:e=>d(`name`,e.target.value),placeholder:`Google`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.issuerUrl`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.issuer_url,onChange:e=>d(`issuer_url`,e.target.value),placeholder:`https://accounts.google.com`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientId`),` `,(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{className:f,value:s.client_id,onChange:e=>d(`client_id`,e.target.value),placeholder:`your-client-id`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:p,children:[o(`settings.oidc.form.clientSecret`),!t&&(0,K.jsx)(`span`,{className:`text-red-400`,children:` *`}),t&&(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs ml-1`,children:[`(`,o(`settings.oidc.form.secretHint`),`)`]})]}),(0,K.jsx)(`input`,{className:f,type:`password`,value:l?s.client_secret:``,placeholder:t&&!l?`••••••••`:o(`settings.oidc.form.secretPlaceholder`),onChange:e=>{u(!0),d(`client_secret`,e.target.value)}})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.scopes`)}),(0,K.jsx)(`input`,{className:f,value:s.scopes,onChange:e=>d(`scopes`,e.target.value),placeholder:`openid email profile`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.iconUrl`)}),(0,K.jsx)(`input`,{className:f,value:s.icon_url??``,onChange:e=>d(`icon_url`,e.target.value===``?null:e.target.value),placeholder:`https://...`})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-6 pt-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(lU,{checked:s.is_enabled??!0,onChange:e=>d(`is_enabled`,e)}),(0,K.jsx)(`span`,{className:`text-white text-sm`,children:o(`settings.oidc.form.enabled`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(lU,{checked:s.auto_create_users??!1,onChange:e=>d(`auto_create_users`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoCreate`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoCreateDesc`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,K.jsx)(lU,{checked:s.auto_link_existing_accounts??!1,onChange:e=>d(`auto_link_existing_accounts`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.autoLink`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:o(`settings.oidc.form.autoLinkDesc`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer w-full`,children:[(0,K.jsx)(lU,{checked:g,onChange:e=>d(`require_email_verified`,e),disabled:h}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm`,children:o(`settings.oidc.form.requireEmailVerified`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs`,children:_})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.emailClaim`)}),(0,K.jsx)(`input`,{className:f,value:s.email_claim,onChange:e=>d(`email_claim`,e.target.value||`email`),placeholder:o(`settings.oidc.form.emailClaimPlaceholder`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.emailClaimDesc`)}),h&&s.email_claim!==`email`&&(0,K.jsx)(`p`,{className:`text-yellow-400 text-xs mt-1`,children:o(`settings.oidc.form.emailClaimCustomClaimAutoLinkWarning`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:p,children:o(`settings.oidc.form.defaultGroup`)}),(0,K.jsxs)(`select`,{className:f,value:s.default_group_id??``,onChange:e=>d(`default_group_id`,e.target.value?Number(e.target.value):null),children:[(0,K.jsx)(`option`,{value:``,children:o(`settings.oidc.form.defaultGroupViewersFallback`)}),n.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:o(`settings.oidc.form.defaultGroupDesc`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:i,className:`flex-1`,children:o(`common.cancel`)}),(0,K.jsx)($,{variant:`primary`,className:`flex-1`,disabled:!s.name||!s.issuer_url||!s.client_id||!t&&!s.client_secret||t&&l&&!s.client_secret||a,onClick:m,children:o(a?`common.saving`:`common.save`)})]})]})}function GHe({provider:e}){let[t,n]=(0,y.useState)(!1);return e.has_icon&&!t?(0,K.jsx)(`img`,{src:Q.oidcProviderIconUrl(e.id),alt:e.name,className:`w-8 h-8 rounded object-contain`,onError:()=>n(!0)}):(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,K.jsx)(bc,{className:`w-4 h-4 text-bambu-gray`})})}function KHe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(null),{data:l,isLoading:u}=q({queryKey:[`oidc-providers-all`],queryFn:()=>Q.getOIDCProvidersAll()}),{data:d=[]}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups()}),f=J({mutationFn:e=>Q.createOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),i(!1),n(e(`settings.oidc.created`),`success`)},onError:e=>n(e.message,`error`)}),p=J({mutationFn:({id:e,data:t})=>Q.updateOIDCProvider(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),o(null),n(e(`settings.oidc.updated`),`success`)},onError:e=>n(e.message,`error`)}),m=J({mutationFn:e=>Q.deleteOIDCProvider(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),c(null),n(e(`settings.oidc.deleted`),`success`)},onError:e=>n(e.message,`error`)}),h=J({mutationFn:e=>Q.refreshOIDCProviderIcon(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),t.invalidateQueries({queryKey:[`oidc-providers`]}),n(e(`settings.oidc.iconRefreshed`),`success`)},onError:t=>n(t.message||e(`settings.oidc.iconFetchFailed`),`error`)}),g=J({mutationFn:e=>Q.deleteOIDCProviderIcon(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`oidc-providers-all`]}),t.invalidateQueries({queryKey:[`oidc-providers`]}),n(e(`settings.oidc.iconRemoved`),`success`)},onError:e=>n(e.message,`error`)}),_=e=>p.mutate({id:e.id,data:{is_enabled:!e.is_enabled}});return u?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,K.jsx)(Ol,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(_d,{id:`card-oidc`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-semibold`,children:e(`settings.oidc.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:e(`settings.oidc.desc`)})]}),!r&&(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`flex items-center gap-2`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})}),r&&(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium mb-4`,children:e(`settings.oidc.newProvider`)}),(0,K.jsx)(n6,{initial:WHe,groups:d,onSave:e=>f.mutate(e),onCancel:()=>i(!1),isPending:f.isPending})]})})]}),l&&l.length===0&&!r&&(0,K.jsx)(_d,{id:`card-oidc-empty`,children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`text-center py-8 space-y-3`,children:[(0,K.jsx)(bc,{className:`w-12 h-12 text-bambu-gray mx-auto`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.oidc.empty`)}),(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>i(!0),className:`inline-flex items-center gap-2`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`settings.oidc.addProvider`)]})]})})}),l?.map(t=>(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(GHe,{provider:t}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h4`,{className:`text-white font-medium`,children:t.name}),t.is_enabled?(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-green-400 bg-green-400/10 px-2 py-0.5 rounded-full`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),` `,e(`common.enabled`)]}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-0.5 rounded-full`,children:[(0,K.jsx)(Ru,{className:`w-3 h-3`}),` `,e(`common.disabled`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-bambu-gray text-xs mt-0.5`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:t.issuer_url})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.icon_url&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>h.mutate(t.id),disabled:h.isPending,title:e(`settings.oidc.refreshIcon`),"data-testid":`refresh-icon-${t.id}`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h.isPending?`animate-spin`:``}`})}),t.has_icon&&(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>g.mutate(t.id),disabled:g.isPending,title:e(`settings.oidc.removeIcon`),"data-testid":`remove-icon-${t.id}`,children:(0,K.jsx)(jc,{className:`w-4 h-4`})}),(0,K.jsx)(lU,{checked:t.is_enabled,onChange:()=>_(t),disabled:p.isPending}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>o(a===t.id?null:t.id),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`danger`,size:`sm`,onClick:()=>c(t),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})}),a===t.id&&(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsx)(n6,{isEdit:!0,groups:d,initial:{name:t.name,issuer_url:t.issuer_url,client_id:t.client_id,client_secret:``,scopes:t.scopes,is_enabled:t.is_enabled,auto_create_users:t.auto_create_users,auto_link_existing_accounts:t.auto_link_existing_accounts,email_claim:t.email_claim,require_email_verified:t.require_email_verified,icon_url:t.icon_url??void 0,default_group_id:t.default_group_id??null},onSave:e=>p.mutate({id:t.id,data:e}),onCancel:()=>o(null),isPending:p.isPending})})}),a!==t.id&&(0,K.jsx)(yd,{children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2 text-sm`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.clientId`)}),(0,K.jsx)(`dd`,{className:`text-white font-mono truncate`,children:t.client_id})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.scopes`)}),(0,K.jsx)(`dd`,{className:`text-white`,children:t.scopes})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoCreate`)}),(0,K.jsx)(`dd`,{className:t.auto_create_users?`text-green-400`:`text-bambu-gray`,children:t.auto_create_users?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.autoLink`)}),(0,K.jsx)(`dd`,{className:t.auto_link_existing_accounts?`text-green-400`:`text-bambu-gray`,children:t.auto_link_existing_accounts?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.emailClaim`)}),(0,K.jsx)(`dd`,{className:`text-white font-mono`,children:t.email_claim})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.requireEmailVerified`)}),(0,K.jsx)(`dd`,{className:t.require_email_verified?`text-green-400`:`text-red-400`,children:t.require_email_verified?e(`common.yes`):e(`common.no`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`dt`,{className:`text-bambu-gray`,children:e(`settings.oidc.form.defaultGroup`)}),(0,K.jsx)(`dd`,{className:`text-white`,children:t.default_group_id?d.find(e=>e.id===t.default_group_id)?.name??e(`settings.oidc.form.defaultGroupViewersFallback`):e(`settings.oidc.form.defaultGroupViewersFallback`)})]})]})})]},t.id)),s&&(0,K.jsx)(Ad,{title:e(`settings.oidc.deleteTitle`),message:e(`settings.oidc.deleteMessage`,{name:s.name}),confirmText:e(`common.delete`),variant:`danger`,onConfirm:()=>m.mutate(s.id),onCancel:()=>c(null)})]})}var r6=new Map;function i6(e){r6.set(e.anchor,e)}function qHe(){return Array.from(r6.values())}i6({labelKey:`settings.encryption.title`,labelFallback:`MFA Encryption Status`,tab:`users`,subTab:`security`,keywords:`mfa encryption status security backup totp oidc fernet`,anchor:`card-mfa-encryption`});function JHe(){let{t:e}=W(),{data:t,isLoading:n,isError:r,refetch:i}=q({queryKey:[`encryptionStatus`],queryFn:()=>Q.getEncryptionStatus(),refetchInterval:e=>{if(!e.state.error)return 3e4;let t=e.state.fetchFailureCount??0;return t<=3?Math.min(5e3*Math.max(1,t),3e4):!1}});if(n)return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`text-bambu-gray`,size:20}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,"data-testid":`encryption-loading`,children:[(0,K.jsx)(X,{className:`animate-spin`,size:16}),(0,K.jsx)(`span`,{children:e(`common.loading`)})]})})]});if(r||!t)return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`text-bambu-gray`,size:20}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`div`,{className:`text-red-400`,"data-testid":`encryption-error`,children:e(`common.errorLoading`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(),className:`mt-2 text-sm text-blue-400 underline hover:text-blue-300`,"data-testid":`encryption-retry-button`,children:e(`common.retry`)})]})]});let a=t.legacy_plaintext_rows.oidc_providers+t.legacy_plaintext_rows.user_totp,o=t.encrypted_rows.oidc_providers+t.encrypted_rows.user_totp,s,c,l,u;t.decryption_broken?(s=`bg-red-500/20 border-red-500/50 text-red-400`,c=(0,K.jsx)(ys,{className:`text-red-400`,size:20}),l=e(`settings.encryption.decryptionBrokenTitle`),u=e(`settings.encryption.decryptionBrokenError`,{count:o})):t.key_source===`generated`?(s=`bg-amber-500/10 border-amber-500/30 text-amber-400`,c=(0,K.jsx)(Gl,{className:`text-amber-400`,size:20}),l=e(`settings.encryption.enabledGenerated`),u=e(`settings.encryption.backupHint`)):a>0?(s=`bg-amber-500/10 border-amber-500/30 text-amber-400`,c=(0,K.jsx)(Cu,{className:`text-amber-400`,size:20}),l=t.key_source===`env`?e(`settings.encryption.enabledFromEnv`):e(`settings.encryption.enabledFromFile`),u=e(`settings.encryption.legacyRowsWarning`,{count:a})):t.key_configured?(s=`bg-green-500/20 border-green-500/30 text-green-400`,c=(0,K.jsx)(Gl,{className:`text-green-400`,size:20}),l=t.key_source===`env`?e(`settings.encryption.enabledFromEnv`):e(`settings.encryption.enabledFromFile`),u=e(`settings.encryption.allEncrypted`)):(s=`bg-gray-500/20 border-gray-500/30 text-gray-400`,c=(0,K.jsx)(Kl,{className:`text-gray-400`,size:20}),l=e(`settings.encryption.notConfigured`),u=e(`settings.encryption.notConfiguredDesc`));let d=t.key_source===`generated`&&a>0;return(0,K.jsxs)(_d,{id:`card-mfa-encryption`,"data-testid":`encryption-status-card`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`settings.encryption.title`)})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`p-3 border rounded-lg ${s}`,"data-testid":`encryption-status`,children:[(0,K.jsx)(`p`,{className:`font-medium mb-1`,children:l}),(0,K.jsx)(`p`,{className:`text-sm`,children:u})]}),d&&(0,K.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-500/10 border-amber-500/30 text-amber-400`,"data-testid":`encryption-legacy-warning`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.legacyRowsWarning`,{count:a})})}),t.migration_error_count>0&&(0,K.jsx)(`div`,{className:`mt-2 p-3 border rounded-lg bg-amber-500/10 border-amber-500/30 text-amber-400`,"data-testid":`encryption-migration-warning`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:e(`settings.encryption.migrationErrorWarning`,{count:t.migration_error_count})})}),(0,K.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 text-sm`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.encryptedRowsLabel`)}),(0,K.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.encrypted_rows.oidc_providers,` · TOTP: `,t.encrypted_rows.user_totp]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`settings.encryption.legacyRowsLabel`)}),(0,K.jsxs)(`p`,{className:`font-medium`,children:[`OIDC: `,t.legacy_plaintext_rows.oidc_providers,` · TOTP: `,t.legacy_plaintext_rows.user_totp]})]})]})]})]})}var YHe={get:`bg-blue-500/20 text-blue-400 border-blue-500/30`,post:`bg-green-500/20 text-green-400 border-green-500/30`,put:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,patch:`bg-orange-500/20 text-orange-400 border-orange-500/30`,delete:`bg-red-500/20 text-red-400 border-red-500/30`};function XHe(e,t){let n=t.replace(`#/`,``).split(`/`),r=e;for(let e of n)r=r[e];return r}function a6(e,t,n=0){if(n>5)return`...`;if(t.$ref)return a6(e,XHe(e,t.$ref),n+1);if(t.allOf){let r={};for(let i of t.allOf){let t=a6(e,i,n+1);typeof t==`object`&&t&&Object.assign(r,t)}return r}if(t.example!==void 0)return t.example;if(t.default!==void 0)return t.default;switch(t.type){case`string`:return t.enum?t.enum[0]:`string`;case`integer`:case`number`:return 0;case`boolean`:return!1;case`array`:return t.items?[a6(e,t.items,n+1)]:[];case`object`:if(t.properties){let r={};for(let[i,a]of Object.entries(t.properties))r[i]=a6(e,a,n+1);return r}return{};default:return null}}function ZHe({path:e,method:t,spec:n,schema:r,apiKey:i}){let[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)({}),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!1);(0,y.useEffect)(()=>{if(a&&n.parameters){let e={};for(let t of n.parameters)t.schema?.default!==void 0&&(e[t.name]=String(t.schema.default));c(t=>({...e,...t}))}},[a,n.parameters]),(0,y.useEffect)(()=>{if(a&&n.requestBody?.content?.[`application/json`]?.schema&&!l){let e=n.requestBody.content[`application/json`].schema,t=a6(r,e);u(JSON.stringify(t,null,2))}},[a,n.requestBody,r,l]);let _=(()=>{let e=[];for(let t of n.parameters||[])if(t.in===`path`||t.required){let n=s[t.name];(n===void 0||n===``)&&e.push(t.name)}return e})(),v=async()=>{if(_.length>0){f({status:0,statusText:`Validation Error`,headers:{},body:`Missing required parameters: ${_.join(`, `)}`,duration:0});return}m(!0),f(null);try{let r=e,a=new URLSearchParams;for(let e of n.parameters||[]){let t=s[e.name];t!==void 0&&t!==``&&(e.in===`path`?r=r.replace(`{${e.name}}`,encodeURIComponent(t)):e.in===`query`&&a.append(e.name,t))}let o=a.toString(),c=`${r}${o?`?${o}`:``}`,u={"Content-Type":`application/json`};i&&(u[`X-API-Key`]=i);let d={method:t.toUpperCase(),headers:u};[`post`,`put`,`patch`].includes(t)&&l&&(d.body=l);let p=performance.now(),m=await fetch(c,d),h=Math.round(performance.now()-p),g={};m.headers.forEach((e,t)=>{g[t]=e});let _;_=m.headers.get(`content-type`)?.includes(`application/json`)?await m.json():await m.text(),f({status:m.status,statusText:m.statusText,headers:g,body:_,duration:h})}catch(e){f({status:0,statusText:`Network Error`,headers:{},body:e instanceof Error?e.message:`Unknown error`,duration:0})}finally{m(!1)}},b=async()=>{if(d){let e=typeof d.body==`string`?d.body:JSON.stringify(d.body,null,2);try{await navigator.clipboard.writeText(e),g(!0),setTimeout(()=>g(!1),2e3)}catch{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-999999px`,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t),g(!0),setTimeout(()=>g(!1),2e3)}}},x=(n.parameters||[]).filter(e=>e.in===`path`),S=(n.parameters||[]).filter(e=>e.in===`query`),C=[`post`,`put`,`patch`].includes(t)&&n.requestBody;return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>o(!a),className:`w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left`,children:[a?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${YHe[t]||`bg-gray-500/20 text-gray-400`}`,children:t}),(0,K.jsx)(`code`,{className:`text-sm text-white font-mono flex-1 truncate`,children:e}),n.summary&&(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray truncate max-w-[40%]`,children:n.summary})]}),a&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50`,children:[n.description&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n.description}),x.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Path Parameters`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,K.jsx)(`span`,{className:`text-red-400 ml-1`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),placeholder:e.description||e.schema?.type||`value`,className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`})]},e.name))})]}),S.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Query Parameters`}),(0,K.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray w-32 flex-shrink-0`,children:[e.name,e.required&&(0,K.jsx)(`span`,{className:`text-red-400 ml-1`,children:`*`})]}),e.schema?.enum?(0,K.jsxs)(`select`,{value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:`-- Select --`}),e.schema.enum.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}):(0,K.jsx)(`input`,{type:`text`,value:s[e.name]||``,onChange:t=>c(n=>({...n,[e.name]:t.target.value})),placeholder:e.description||e.schema?.type||`value`,className:`flex-1 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono focus:border-bambu-green focus:outline-none`})]},e.name))})]}),C&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:`Request Body`}),(0,K.jsx)(`textarea`,{value:l,onChange:e=>u(e.target.value),rows:8,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono focus:border-bambu-green focus:outline-none resize-y`,placeholder:`JSON request body...`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:v,disabled:p,children:[p?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bl,{className:`w-4 h-4`}),`Execute`]}),_.length>0&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400 flex items-center gap-1`,children:[(0,K.jsx)(ds,{className:`w-3 h-3`}),`Fill in: `,_.join(`, `)]})]}),d&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h4`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[`Response`,(0,K.jsxs)(`span`,{className:`px-2 py-0.5 text-xs rounded ${d.status>=200&&d.status<300?`bg-green-500/20 text-green-400`:d.status>=400?`bg-red-500/20 text-red-400`:`bg-yellow-500/20 text-yellow-400`}`,children:[d.status,` `,d.statusText]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[d.duration,`ms`]})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:b,children:h?(0,K.jsx)(ps,{className:`w-3 h-3 text-green-400`}):(0,K.jsx)(Ms,{className:`w-3 h-3`})})]}),(0,K.jsx)(`pre`,{className:`p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary`,children:typeof d.body==`string`?d.body:JSON.stringify(d.body,null,2)})]})]})]})}function QHe({apiKey:e=``}){let[t,n]=(0,y.useState)(null),[r,i]=(0,y.useState)(!0),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(new Set),[l,u]=(0,y.useState)(``);if((0,y.useEffect)(()=>{async function e(){try{let e=await fetch(`/openapi.json`);if(!e.ok)throw Error(`Failed to fetch OpenAPI schema`);n(await e.json())}catch(e){o(e instanceof Error?e.message:`Unknown error`)}finally{i(!1)}}e()},[]),r)return(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});if(a||!t)return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-red-400`,children:[(0,K.jsx)(ds,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{children:`Failed to load API schema`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:a})]})})});let d={};for(let[e,n]of Object.entries(t.paths))for(let[t,r]of Object.entries(n)){if(t===`parameters`)continue;let n=r.tags||[`Other`];for(let i of n)d[i]||(d[i]=[]),d[i].push({path:e,method:t,spec:r})}let f=Object.entries(d).map(([e,t])=>l?{tag:e,endpoints:t.filter(({path:e,method:t,spec:n})=>{let r=l.toLowerCase();return e.toLowerCase().includes(r)||t.toLowerCase().includes(r)||(n.summary?.toLowerCase()||``).includes(r)||(n.description?.toLowerCase()||``).includes(r)})}:{tag:e,endpoints:t}).filter(({endpoints:e})=>e.length>0).sort((e,t)=>e.tag.localeCompare(t.tag)),p=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`Search endpoints...`,className:`w-full max-w-md px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set(f.map(e=>e.tag)))},children:`Expand All`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{c(new Set)},children:`Collapse All`}),(0,K.jsxs)(`a`,{href:`/docs`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-sm text-bambu-green hover:underline`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`Swagger UI`]})]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[f.reduce((e,t)=>e+t.endpoints.length,0),` endpoints in `,f.length,` categories`]}),(0,K.jsx)(`div`,{className:`space-y-3`,children:f.map(({tag:n,endpoints:r})=>(0,K.jsxs)(_d,{children:[(0,K.jsx)(`button`,{onClick:()=>p(n),className:`w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/30 transition-colors text-left`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s.has(n)?(0,K.jsx)(is,{className:`w-5 h-5 text-bambu-gray`}):(0,K.jsx)(as,{className:`w-5 h-5 text-bambu-gray`}),(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white capitalize`,children:n.replace(/-/g,` `)}),(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray`,children:r.length})]})}),s.has(n)&&(0,K.jsx)(yd,{className:`pt-0 space-y-2`,children:r.map(({path:n,method:r,spec:i})=>(0,K.jsx)(ZHe,{path:n,method:r,spec:i,schema:t,apiKey:e},`${r}-${n}`))})]},n))})]})}var $He=[`general`,`plugs`,`notifications`,`queue`,`filament`,`network`,`apikeys`,`virtual-printer`,`spoolbuddy`,`failure-detection`,`users`,`backup`];i6({labelKey:`settings.general`,tab:`general`,keywords:`language date time format printer model printers cards`,anchor:`card-general`}),i6({labelKey:`settings.appearance`,tab:`general`,keywords:`theme dark light mode colors`,anchor:`card-appearance`}),i6({labelKey:`settings.archiveSettings`,tab:`general`,keywords:`archive auto save thumbnails captures`,anchor:`card-archive`}),i6({labelKey:`settings.camera`,tab:`general`,keywords:`camera external video stream`,anchor:`card-camera`}),i6({labelKey:`settings.costTracking`,tab:`general`,keywords:`currency filament cost energy kwh price`,anchor:`card-cost`}),i6({labelKey:`settings.fileManager`,tab:`general`,keywords:`file manager archive mode disk warning storage`,anchor:`card-filemanager`}),i6({labelKey:`settings.updates`,tab:`general`,keywords:`updates version firmware beta check`,anchor:`card-updates`}),i6({labelKey:`settings.dataManagement`,tab:`general`,keywords:`data reset clear logs notifications preferences`,anchor:`card-data`}),i6({labelKey:`settings.smartPlugs`,tab:`plugs`,keywords:`smart plug energy power automation tapo kasa tplink shelly`,anchor:`card-plugs`}),i6({labelKey:`settings.providers`,tab:`notifications`,keywords:`telegram discord email notification providers webhook`,anchor:`card-providers`}),i6({labelKey:`settings.messageTemplates`,tab:`notifications`,keywords:`message templates notification text edit`,anchor:`card-templates`}),i6({labelKey:`settings.defaultPrintOptions`,labelFallback:`Default Print Options`,tab:`queue`,keywords:`print bed leveling flow calibration vibration first layer timelapse`,anchor:`card-print-options`}),i6({labelKey:`settings.tempFanPresetsTitle`,labelFallback:`Temperature & Fan Presets`,tab:`queue`,keywords:`temperature fan presets nozzle bed chamber quick buttons popover`,anchor:`card-temp-fan-presets`}),i6({labelKey:`settings.staggeredStart`,labelFallback:`Staggered Start`,tab:`queue`,keywords:`staggered batch delay start queue group`,anchor:`card-staggered`}),i6({labelKey:`settings.plateClear`,labelFallback:`Plate-Clear Confirmation`,tab:`queue`,keywords:`plate clear confirm auto queue`,anchor:`card-plate`}),i6({labelKey:`settings.gcodeInjection`,labelFallback:`G-code Injection`,tab:`queue`,keywords:`gcode injection start end autoprint farmloop swapmod autoclear printflow`,anchor:`card-gcode`}),i6({labelKey:`settings.slicerCard`,labelFallback:`Slicer`,tab:`queue`,keywords:`slicer orcaslicer bambustudio orca bambu api sidecar url docker preferred`,anchor:`card-slicer`}),i6({labelKey:`settings.queueDrying`,tab:`queue`,keywords:`drying presets temperature time humidity ams`,anchor:`card-drying`}),i6({labelKey:`settings.filamentChecks`,tab:`filament`,keywords:`filament check warning runout remaining`,anchor:`card-filamentchecks`}),i6({labelKey:`settings.printModal`,tab:`filament`,keywords:`print modal custom mapping`,anchor:`card-printmodal`}),i6({labelKey:`settings.amsDisplayThresholds`,tab:`filament`,keywords:`ams humidity temperature threshold history retention`,anchor:`card-amsthresholds`}),i6({labelKey:`settings.externalUrl`,tab:`network`,keywords:`external url reverse proxy public notification link`,anchor:`card-externalurl`}),i6({labelKey:`settings.ftpRetry`,tab:`network`,keywords:`ftp retry upload retries backoff`,anchor:`card-ftpretry`}),i6({labelKey:`settings.homeAssistant`,tab:`network`,keywords:`home assistant ha hass mqtt integration`,anchor:`card-ha`}),i6({labelKey:`settings.mqttPublishing`,tab:`network`,keywords:`mqtt publish broker topic`,anchor:`card-mqtt`}),i6({labelKey:`settings.prometheusMetrics`,tab:`network`,keywords:`prometheus metrics grafana monitoring bearer token`,anchor:`card-prometheus`}),i6({labelKey:`settings.createNewApiKey`,tab:`apikeys`,keywords:`api key create permission scope`,anchor:`card-createapi`}),i6({labelKey:`settings.webhookEndpoints`,tab:`apikeys`,keywords:`webhook endpoint post http`,anchor:`card-webhooks`}),i6({labelKey:`settings.apiBrowser`,tab:`apikeys`,keywords:`api browser endpoint documentation test`,anchor:`card-apibrowser`}),i6({labelKey:`cameraTokens.title`,tab:`apikeys`,keywords:`camera token long-lived home assistant frigate kiosk stream`,anchor:`card-camera-tokens`}),i6({labelKey:`settings.tabs.virtualPrinter`,tab:`virtual-printer`,keywords:`virtual printer proxy archive slicer bambustudio orcaslicer ip bind`,anchor:`card-vp`}),i6({labelKey:`settings.tabs.spoolbuddy`,tab:`spoolbuddy`,keywords:`spoolbuddy device scale nfc rfid kiosk unregister`,anchor:`card-spoolbuddy`}),i6({labelKey:`settings.currentUser`,tab:`users`,subTab:`users`,keywords:`current user profile password change`,anchor:`card-currentuser`}),i6({labelKey:`settings.users`,tab:`users`,subTab:`users`,keywords:`users accounts list`,anchor:`card-users`}),i6({labelKey:`settings.groups`,tab:`users`,subTab:`users`,keywords:`groups roles permissions administrators operators viewers`,anchor:`card-groups`}),i6({labelKey:`settings.sessionPolicy.title`,labelFallback:`Session Policy`,tab:`users`,subTab:`users`,keywords:`session timeout expiry logout remember me jwt token lifetime`,anchor:`card-session-policy`}),i6({labelKey:`settings.email.smtpSettings`,labelFallback:`SMTP Configuration`,tab:`users`,subTab:`email`,keywords:`smtp email send server port password auth starttls ssl`,anchor:`card-smtp`}),i6({labelKey:`settings.ldap.title`,labelFallback:`LDAP Authentication`,tab:`users`,subTab:`ldap`,keywords:`ldap active directory ad authentication bind dn search base group mapping`,anchor:`card-ldap`}),i6({labelKey:`settings.tabs.backup`,tab:`backup`,keywords:`backup github restore download cloud sync profiles archives`,anchor:`card-backup`}),i6({labelKey:`externalLinks.sidebarLayout`,labelFallback:`Sidebar`,tab:`general`,keywords:`sidebar layout links pages hide show external custom navigation url add`,anchor:`card-sidebar-links`}),i6({labelKey:`settings.filamentTracking`,tab:`filament`,keywords:`spoolman filament tracking inventory sync remote integration`,anchor:`card-spoolman`}),i6({labelKey:`settings.catalog.spoolCatalog`,labelFallback:`Spool Catalog`,tab:`filament`,keywords:`spool catalog entries brand material reset import export`,anchor:`card-spool-catalog`}),i6({labelKey:`settings.colorCatalog.title`,labelFallback:`Color Catalog`,tab:`filament`,keywords:`color catalog hex swatch palette sync reset`,anchor:`card-color-catalog`}),i6({labelKey:`settings.tabs.failureDetection`,labelFallback:`Failure Detection`,tab:`failure-detection`,keywords:`failure detection ai ml obico spaghetti detect monitoring`,anchor:`card-fd-ml`}),i6({labelKey:`failureDetection.perPrinterTitle`,labelFallback:`Per-Printer Settings`,tab:`failure-detection`,keywords:`failure detection per printer enable per-printer sensitivity`,anchor:`card-fd-perprinter`}),i6({labelKey:`failureDetection.statusTitle`,labelFallback:`Detection Status`,tab:`failure-detection`,keywords:`failure detection status running connection`,anchor:`card-fd-status`}),i6({labelKey:`failureDetection.historyTitle`,labelFallback:`Detection History`,tab:`failure-detection`,keywords:`failure detection history log events`,anchor:`card-fd-history`}),i6({labelKey:`settings.email.advancedAuth`,labelFallback:`Advanced Email Authentication`,tab:`users`,subTab:`email`,keywords:`email authentication advanced password reset self-service forgot`,anchor:`card-email-advanced-auth`}),i6({labelKey:`settings.email.testConnection`,labelFallback:`Test SMTP Connection`,tab:`users`,subTab:`email`,keywords:`email smtp test connection send check`,anchor:`card-email-test`}),i6({labelKey:`settings.twoFa.totpTitle`,labelFallback:`Authenticator App (TOTP)`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa totp authenticator app google authy otp`,anchor:`card-2fa-totp`}),i6({labelKey:`settings.twoFa.emailOtpTitle`,labelFallback:`Email One-Time Codes`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa email otp one time code`,anchor:`card-2fa-emailotp`}),i6({labelKey:`settings.twoFa.linkedAccounts`,labelFallback:`Linked Accounts`,tab:`users`,subTab:`twofa`,keywords:`two factor 2fa linked accounts sso oidc provider google github`,anchor:`card-2fa-linked`}),i6({labelKey:`settings.oidc.title`,labelFallback:`Single Sign-On (OIDC)`,tab:`users`,subTab:`oidc`,keywords:`sso oidc openid single sign-on pocketid authentik keycloak google okta azure provider`,anchor:`card-oidc`}),i6({labelKey:`settings.ldap.serverConfig`,labelFallback:`LDAP Server Configuration`,tab:`users`,subTab:`ldap`,keywords:`ldap server url bind dn user search base group filter tls`,anchor:`card-ldap-server`}),i6({labelKey:`backup.githubBackup`,labelFallback:`GitHub Backup`,tab:`backup`,keywords:`github backup cloud remote sync profiles token`,anchor:`card-backup-github`}),i6({labelKey:`backup.history`,labelFallback:`Backup History`,tab:`backup`,keywords:`backup history log runs github commits`,anchor:`card-backup-history`}),i6({labelKey:`backup.localBackup`,labelFallback:`Local Backup`,tab:`backup`,keywords:`local backup download zip manual export`,anchor:`card-backup-local`}),i6({labelKey:`backup.scheduledBackup`,labelFallback:`Scheduled Backups`,tab:`backup`,keywords:`scheduled backup automatic hourly daily weekly retention local path`,anchor:`card-backup-scheduled`});var eUe={database:`bg-blue-600`,library_files:`bg-green-500`,library_thumbnails:`bg-teal-500`,library_other:`bg-emerald-700`,archive_timelapses:`bg-red-500`,archive_thumbnails:`bg-amber-500`,archive_files:`bg-sky-500`,virtual_printer_uploads:`bg-purple-500`,virtual_printer_upload_cache:`bg-fuchsia-500`,virtual_printer_certs:`bg-violet-500`,virtual_printer_other:`bg-purple-700`,downloads:`bg-cyan-500`,plate_calibration:`bg-lime-500`,logs:`bg-orange-500`,other_data:`bg-yellow-500`},o6=[`bg-blue-500`,`bg-green-500`,`bg-yellow-500`,`bg-red-500`,`bg-orange-500`,`bg-teal-500`,`bg-cyan-500`,`bg-purple-500`],s6=(e,t)=>eUe[e]||o6[t%o6.length];function tUe(){let e=no(),t=$n(),[n,r]=Mi(),{t:i,i18n:a}=W(),{showToast:o}=Td(),{authEnabled:s,user:c,isAdmin:l,refreshAuth:u,hasPermission:d}=dd(),{mode:f,resolvedMode:p,darkStyle:m,darkBackground:h,darkAccent:g,lightStyle:_,lightBackground:v,lightAccent:b,setMode:x,setDarkStyle:S,setDarkBackground:C,setDarkAccent:w,setLightStyle:T,setLightBackground:E,setLightAccent:D}=md(),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)({}),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(null),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(null),[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(Tp()),U=n.get(`tab`),se=U===`email`,[ce,le]=(0,y.useState)(se?`users`:U&&$He.includes(U)?U:`general`),[ue,de]=(0,y.useState)(se?`email`:`users`),fe=e=>{le(e),e===`users`&&de(`users`),e===`general`?n.delete(`tab`):n.set(`tab`,e),r(n,{replace:!0})},[pe,me]=(0,y.useState)(!1),[he,ge]=(0,y.useState)(``),[_e,ve]=(0,y.useState)({can_queue:!0,can_control_printer:!1,can_read_status:!0,can_manage_library:!0,can_manage_inventory:!0,can_access_cloud:!1,can_update_energy_cost:!1}),[ye,be]=(0,y.useState)(null),[xe,Se]=(0,y.useState)(!1),[Ce,we]=(0,y.useState)(null),[Te,Ee]=(0,y.useState)(``),[De,Oe]=(0,y.useState)(!1),[ke,Ae]=(0,y.useState)(!1),[je,Me]=(0,y.useState)(null),[Ne,Pe]=(0,y.useState)(!1),[Fe,Ie]=(0,y.useState)(!1),[Le,Re]=(0,y.useState)(!1),[ze,Be]=(0,y.useState)({currentPassword:``,newPassword:``,confirmPassword:``}),[Ve,He]=(0,y.useState)(!1),[Ue,We]=(0,y.useState)(!1),[Ge,Ke]=(0,y.useState)(!1),[qe,Je]=(0,y.useState)(`local`),[Ye,Xe]=(0,y.useState)(!1),[Ze,Qe]=(0,y.useState)(null),[$e,et]=(0,y.useState)(null),[tt,nt]=(0,y.useState)(null),[rt,it]=(0,y.useState)(!1),[at,ot]=(0,y.useState)({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),[st,ct]=(0,y.useState)(null),[lt,ut]=(0,y.useState)(null),[dt,ft]=(0,y.useState)(!1),[pt,mt]=(0,y.useState)({}),[ht,gt]=(0,y.useState)({}),_t=e=>{oe(e),Ep(e),o(i(`settings.toast.settingsSaved`),`success`)},{data:vt,isLoading:yt}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:bt,isLoading:xt,isFetching:St}=q({queryKey:[`storage-usage`],queryFn:()=>Q.getStorageUsage(),enabled:ce===`general`,staleTime:1/0,refetchInterval:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1}),Ct=async()=>{We(!0);try{let t=await Q.getStorageUsage({refresh:!0});e.setQueryData([`storage-usage`],t)}catch(e){o(e instanceof Error?e.message:`Failed to refresh storage usage`,`error`)}finally{We(!1)}},{data:wt,isLoading:Tt}=q({queryKey:[`smart-plugs`],queryFn:Q.getSmartPlugs}),{data:Et,isLoading:Dt}=q({queryKey:[`smart-plugs-energy`,wt?.map(e=>e.id)],queryFn:async()=>{if(!wt||wt.length===0)return null;let e=await Promise.all(wt.filter(e=>e.enabled).map(async e=>{try{return{plug:e,status:await Q.getSmartPlugStatus(e.id)}}catch{return{plug:e,status:null}}})),t=0,n=0,r=0,i=0,a=0;for(let{plug:o,status:s}of e){let e=o.plug_type===`mqtt`&&s?.energy?.power!=null;(s?.reachable||e)&&s?.energy&&(a++,s.energy?.power!=null&&(t+=s.energy.power),s.energy?.today!=null&&(n+=s.energy.today),s.energy?.yesterday!=null&&(r+=s.energy.yesterday),s.energy?.total!=null&&(i+=s.energy.total))}return{totalPower:t,totalToday:n,totalYesterday:r,totalLifetime:i,reachableCount:a,totalPlugs:wt.filter(e=>e.enabled).length}},enabled:ce===`plugs`&&!!wt&&wt.length>0,refetchInterval:ce===`plugs`?1e4:!1}),{data:kt,isLoading:At}=q({queryKey:[`notification-providers`],queryFn:Q.getNotificationProviders}),{data:jt,isLoading:Mt}=q({queryKey:[`api-keys`],queryFn:Q.getAPIKeys}),G=J({mutationFn:e=>Q.createAPIKey(e),onSuccess:t=>{be(t.key||null),me(!1),ge(``),e.invalidateQueries({queryKey:[`api-keys`]}),o(i(`settings.toast.apiKeyCreated`))},onError:e=>{o(`Failed to create API key: ${e.message}`,`error`)}}),Nt=J({mutationFn:e=>Q.deleteAPIKey(e),onSuccess:(t,n)=>{e.setQueryData([`api-keys`],e=>(e??[]).filter(e=>e.id!==n)),o(i(`settings.toast.apiKeyDeleted`))},onError:e=>{o(`Failed to delete API key: ${e.message}`,`error`)}}),{data:Pt}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:Ft,isLoading:It}=q({queryKey:[`notification-templates`],queryFn:Q.getNotificationTemplates}),{data:Lt}=q({queryKey:[`virtual-printer-settings`],queryFn:td.getSettings,refetchInterval:1e4}),Rt=Lt?.status?.running??!1,{data:zt}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:15e3}),Bt=zt?.length??0,Vt=zt?.some(e=>e.online)??!1,{data:Ht}=q({queryKey:[`obico-status`],queryFn:Q.getObicoStatus,refetchInterval:15e3}),Ut=!!(Ht?.is_running&&Ht?.enabled),{data:Wt}=q({queryKey:[`ffmpeg-status`],queryFn:Q.checkFfmpeg}),{data:Gt}=q({queryKey:[`version`],queryFn:Q.getVersion}),Kt=!s||d(`library:purge`),{data:qt}=q({queryKey:[`library-trash-settings`],queryFn:()=>Q.getLibraryTrashSettings(),enabled:Kt}),Jt=J({mutationFn:e=>Q.updateLibraryTrashSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`library-trash-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`libraryAutoPurge.saveFailed`),`error`)}),Yt=e=>{qt&&Jt.mutate({retention_days:qt.retention_days,auto_purge_enabled:qt.auto_purge_enabled,auto_purge_days:qt.auto_purge_days,auto_purge_include_never_printed:qt.auto_purge_include_never_printed,...e})},Xt=!s||d(`archives:purge`),{data:Zt}=q({queryKey:[`archive-purge-settings`],queryFn:()=>Q.getArchivePurgeSettings(),enabled:Xt}),Qt=J({mutationFn:e=>Q.updateArchivePurgeSettings(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`archive-purge-settings`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>o(e.message||i(`archiveAutoPurge.saveFailed`),`error`)}),$t=e=>{Zt&&Qt.mutate({enabled:Zt.enabled,days:Zt.days,purge_stats:Zt.purge_stats,...e})},{data:en,refetch:tn,isRefetching:nn}=q({queryKey:[`updateCheck`],queryFn:Q.checkForUpdates,enabled:vt?.check_updates!==!1,staleTime:300*1e3}),{data:rn,refetch:an}=q({queryKey:[`updateStatus`],queryFn:Q.getUpdateStatus,refetchInterval:e=>{let t=e.state.data;return t?.status===`downloading`||t?.status===`installing`?1e3:!1}}),{data:on}=q({queryKey:[`mqtt-status`],queryFn:Q.getMQTTStatus,refetchInterval:ce===`network`?5e3:!1}),{data:sn}=q({queryKey:[`github-backup-status`],queryFn:Q.getGitHubBackupStatus}),{data:cn}=q({queryKey:[`cloud-status`],queryFn:Q.getCloudStatus}),{data:ln={advanced_auth_enabled:!1,smtp_configured:!1}}=q({queryKey:[`advancedAuthStatus`],queryFn:()=>Q.getAdvancedAuthStatus()}),{data:un}=q({queryKey:[`ldapStatus`],queryFn:()=>Q.getLDAPStatus()}),{data:dn}=q({queryKey:[`twoFAStatus`],queryFn:()=>Q.get2FAStatus()}),{data:fn=[]}=q({queryKey:[`oidcProvidersAll`],queryFn:()=>Q.getOIDCProvidersAll(),enabled:l}),{data:pn=[],isLoading:mn}=q({queryKey:[`users`],queryFn:()=>Q.getUsers(),enabled:s&&d(`users:read`)}),{data:hn=[],isLoading:gn}=q({queryKey:[`groups`],queryFn:()=>Q.getGroups(),enabled:s&&d(`groups:read`)}),_n=J({mutationFn:e=>Q.createUser(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userCreated`))},onError:e=>{o(e.message,`error`)}}),vn=J({mutationFn:({id:e,data:t})=>Q.updateUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),e.invalidateQueries({queryKey:[`groups`]}),Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`settings.toast.userUpdated`))},onError:e=>{o(e.message,`error`)}}),yn=J({mutationFn:({id:e,deleteItems:t})=>Q.deleteUser(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`users`]}),o(i(`settings.toast.userDeleted`)),et(null),nt(null)},onError:e=>{o(e.message,`error`)}}),bn=J({mutationFn:e=>Q.resetUserPassword({user_id:e}),onSuccess:e=>{o(e.message,`success`)},onError:e=>{o(e.message,`error`)}}),xn=async e=>{et(e),it(!0);try{nt(await Q.getUserItemsCount(e))}catch{nt({archives:0,queue_items:0,library_files:0})}finally{it(!1)}},Sn=J({mutationFn:e=>Q.deleteGroup(e),onSuccess:()=>{e.invalidateQueries({queryKey:[`groups`]}),o(i(`settings.toast.groupDeleted`))},onError:e=>{o(e.message,`error`)}}),Cn=()=>{let e=ln?.advanced_auth_enabled||!1;if(!at.username){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(e&&!at.email){o(`Email is required when advanced authentication is enabled`,`error`);return}if(!e){if(!at.password){o(i(`settings.toast.fillRequiredFields`),`error`);return}if(at.password!==at.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=p3(at.password);if(e){o(i({tooShort:`settings.toast.passwordTooShort`,needsUppercase:`settings.toast.passwordNeedsUppercase`,needsLowercase:`settings.toast.passwordNeedsLowercase`,needsDigit:`settings.toast.passwordNeedsDigit`,needsSpecial:`settings.toast.passwordNeedsSpecial`}[e]),`error`);return}}_n.mutate({username:at.username,password:e?void 0:at.password,email:at.email||void 0,role:at.role,group_ids:at.group_ids.length>0?at.group_ids:void 0})},wn=e=>{if(at.password){if(at.password!==at.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}let e=p3(at.password);if(e){o(i({tooShort:`settings.toast.passwordTooShort`,needsUppercase:`settings.toast.passwordNeedsUppercase`,needsLowercase:`settings.toast.passwordNeedsLowercase`,needsDigit:`settings.toast.passwordNeedsDigit`,needsSpecial:`settings.toast.passwordNeedsSpecial`}[e]),`error`);return}}let t={username:at.username||void 0,password:at.password||void 0,email:at.email||void 0,role:at.role,group_ids:at.group_ids};t.password||delete t.password,vn.mutate({id:e,data:t})},Tn=e=>{Qe(e.id),ot({username:e.username,password:``,email:e.email||``,confirmPassword:``,role:e.role,group_ids:e.groups?.map(e=>e.id)||[]}),Xe(!0)},En=e=>{ot(t=>({...t,group_ids:t.group_ids.includes(e)?t.group_ids.filter(t=>t!==e):[...t.group_ids,e]}))},Dn=J({mutationFn:Q.applyUpdate,onSuccess:e=>{e.is_ha_addon||e.is_docker||e.is_windows_installer?o(e.message,`error`):an()}}),[On,kn]=(0,y.useState)(null),An=J({mutationFn:Q.testAllNotificationProviders,onSuccess:t=>{kn(t),e.invalidateQueries({queryKey:[`notification-providers`]}),t.failed===0?o(`All ${t.tested} providers tested successfully!`,`success`):o(`${t.success}/${t.tested} providers succeeded`,t.failed>0?`error`:`success`)},onError:e=>{o(`Failed to test providers: ${e.message}`,`error`)}}),jn=J({mutationFn:async e=>{if(!wt)return{success:0,failed:0};let t=wt.filter(e=>e.enabled),n=await Promise.all(t.map(async t=>{try{return await Q.controlSmartPlug(t.id,e),{success:!0}}catch{return{success:!1}}}));return{success:n.filter(e=>e.success).length,failed:n.filter(e=>!e.success).length}},onSuccess:(t,n)=>{e.invalidateQueries({queryKey:[`smart-plugs`]}),e.invalidateQueries({queryKey:[`smart-plugs-energy`]}),t.failed===0?o(`All ${t.success} plugs turned ${n}`,`success`):o(`${t.success} plugs turned ${n}, ${t.failed} failed`,`error`)},onError:e=>{o(`Failed: ${e.message}`,`error`)}}),Mn=(0,y.useRef)(null),Nn=(0,y.useRef)(null),Pn=(0,y.useRef)(!1),Fn=(0,y.useRef)(!0);(0,y.useEffect)(()=>{vt&&!O&&(k({...vt,external_url:vt.external_url||window.location.origin}),setTimeout(()=>{Fn.current=!1},100))},[vt,O]);let In=J({mutationFn:Q.updateSettings,onSuccess:t=>{e.setQueryData([`settings`],t),e.invalidateQueries({queryKey:[`archiveStats`]}),o(i(`settings.toast.settingsSaved`),`success`)},onError:e=>{o(`Failed to save: ${e.message}`,`error`)},onSettled:()=>{Pn.current=!1}}),Ln=J({mutationFn:({id:e,data:t})=>Q.updatePrinter(e,t),onSuccess:()=>{e.invalidateQueries({queryKey:[`printers`]}),o(i(`settings.toast.cameraSettingsSaved`),`success`)},onError:e=>{o(`Failed to update printer: ${e.message}`,`error`)}});(0,y.useEffect)(()=>{if(!(Fn.current||!O||!vt)&&!(s&&!d(`settings:update`))&&(vt.auto_archive!==O.auto_archive||vt.save_thumbnails!==O.save_thumbnails||vt.capture_finish_photo!==O.capture_finish_photo||vt.default_filament_cost!==O.default_filament_cost||vt.currency!==O.currency||vt.energy_cost_per_kwh!==O.energy_cost_per_kwh||vt.energy_tracking_mode!==O.energy_tracking_mode||vt.check_updates!==O.check_updates||(vt.check_printer_firmware??!0)!==(O.check_printer_firmware??!0)||(vt.include_beta_updates??!1)!==(O.include_beta_updates??!1)||vt.notification_language!==O.notification_language||(vt.bed_cooled_threshold??35)!==(O.bed_cooled_threshold??35)||vt.ams_humidity_good!==O.ams_humidity_good||vt.ams_humidity_fair!==O.ams_humidity_fair||vt.ams_temp_good!==O.ams_temp_good||vt.ams_temp_fair!==O.ams_temp_fair||vt.ams_history_retention_days!==O.ams_history_retention_days||vt.disable_filament_warnings!==O.disable_filament_warnings||vt.prefer_lowest_filament!==O.prefer_lowest_filament||(vt.queue_drying_enabled??!1)!==(O.queue_drying_enabled??!1)||(vt.queue_drying_block??!1)!==(O.queue_drying_block??!1)||(vt.ambient_drying_enabled??!1)!==(O.ambient_drying_enabled??!1)||(vt.drying_presets??``)!==(O.drying_presets??``)||(vt.ams_humidity_thresholds??``)!==(O.ams_humidity_thresholds??``)||vt.per_printer_mapping_expanded!==O.per_printer_mapping_expanded||vt.date_format!==O.date_format||vt.time_format!==O.time_format||vt.default_printer_id!==O.default_printer_id||vt.ftp_retry_enabled!==O.ftp_retry_enabled||vt.ftp_retry_count!==O.ftp_retry_count||vt.ftp_retry_delay!==O.ftp_retry_delay||vt.ftp_timeout!==O.ftp_timeout||vt.mqtt_enabled!==O.mqtt_enabled||vt.mqtt_broker!==O.mqtt_broker||vt.mqtt_port!==O.mqtt_port||vt.mqtt_username!==O.mqtt_username||vt.mqtt_password!==O.mqtt_password||vt.mqtt_topic_prefix!==O.mqtt_topic_prefix||vt.mqtt_use_tls!==O.mqtt_use_tls||vt.external_url!==O.external_url||vt.ha_enabled!==O.ha_enabled||vt.ha_url!==O.ha_url||vt.ha_token!==O.ha_token||(vt.library_archive_mode??`ask`)!==(O.library_archive_mode??`ask`)||Number(vt.library_disk_warning_gb??5)!==Number(O.library_disk_warning_gb??5)||(vt.camera_view_mode??`window`)!==(O.camera_view_mode??`window`)||(vt.preferred_slicer??`bambu_studio`)!==(O.preferred_slicer??`bambu_studio`)||(vt.open_in_slicer??null)!==(O.open_in_slicer??null)||(vt.use_slicer_api??!1)!==(O.use_slicer_api??!1)||(vt.orcaslicer_api_url??``)!==(O.orcaslicer_api_url??``)||(vt.bambu_studio_api_url??``)!==(O.bambu_studio_api_url??``)||vt.prometheus_enabled!==O.prometheus_enabled||vt.prometheus_token!==O.prometheus_token||(vt.user_notifications_enabled??!0)!==(O.user_notifications_enabled??!0)||(vt.default_bed_levelling??!0)!==(O.default_bed_levelling??!0)||(vt.default_flow_cali??!1)!==(O.default_flow_cali??!1)||(vt.default_vibration_cali??!0)!==(O.default_vibration_cali??!0)||(vt.default_layer_inspect??!1)!==(O.default_layer_inspect??!1)||(vt.default_timelapse??!1)!==(O.default_timelapse??!1)||(vt.default_nozzle_offset_cali??!0)!==(O.default_nozzle_offset_cali??!0)||(vt.stagger_group_size??2)!==(O.stagger_group_size??2)||(vt.stagger_interval_minutes??5)!==(O.stagger_interval_minutes??5)||(vt.require_plate_clear??!1)!==(O.require_plate_clear??!1)||(vt.nozzle_temp_presets??``)!==(O.nozzle_temp_presets??``)||(vt.bed_temp_presets??``)!==(O.bed_temp_presets??``)||(vt.chamber_temp_presets??``)!==(O.chamber_temp_presets??``)||(vt.fan_speed_presets??``)!==(O.fan_speed_presets??``)||(vt.session_max_hours??24)!==(O.session_max_hours??24))&&!Pn.current)return Mn.current&&clearTimeout(Mn.current),Mn.current=setTimeout(()=>{if(Pn.current)return;Pn.current=!0;let e={auto_archive:O.auto_archive,save_thumbnails:O.save_thumbnails,capture_finish_photo:O.capture_finish_photo,default_filament_cost:O.default_filament_cost,currency:O.currency,energy_cost_per_kwh:O.energy_cost_per_kwh,energy_tracking_mode:O.energy_tracking_mode,check_updates:O.check_updates,check_printer_firmware:O.check_printer_firmware,include_beta_updates:O.include_beta_updates,notification_language:O.notification_language,bed_cooled_threshold:O.bed_cooled_threshold,ams_humidity_good:O.ams_humidity_good,ams_humidity_fair:O.ams_humidity_fair,ams_temp_good:O.ams_temp_good,ams_temp_fair:O.ams_temp_fair,ams_history_retention_days:O.ams_history_retention_days,disable_filament_warnings:O.disable_filament_warnings,prefer_lowest_filament:O.prefer_lowest_filament,queue_drying_enabled:O.queue_drying_enabled,queue_drying_block:O.queue_drying_block,ambient_drying_enabled:O.ambient_drying_enabled,drying_presets:O.drying_presets,ams_humidity_thresholds:O.ams_humidity_thresholds,per_printer_mapping_expanded:O.per_printer_mapping_expanded,date_format:O.date_format,time_format:O.time_format,default_printer_id:O.default_printer_id,ftp_retry_enabled:O.ftp_retry_enabled,ftp_retry_count:O.ftp_retry_count,ftp_retry_delay:O.ftp_retry_delay,ftp_timeout:O.ftp_timeout,mqtt_enabled:O.mqtt_enabled,mqtt_broker:O.mqtt_broker,mqtt_port:O.mqtt_port,mqtt_username:O.mqtt_username,mqtt_password:O.mqtt_password,mqtt_topic_prefix:O.mqtt_topic_prefix,mqtt_use_tls:O.mqtt_use_tls,external_url:O.external_url,ha_enabled:O.ha_enabled,ha_url:O.ha_url,ha_token:O.ha_token,library_archive_mode:O.library_archive_mode,library_disk_warning_gb:O.library_disk_warning_gb,camera_view_mode:O.camera_view_mode,preferred_slicer:O.preferred_slicer,open_in_slicer:O.open_in_slicer,use_slicer_api:O.use_slicer_api,orcaslicer_api_url:O.orcaslicer_api_url,bambu_studio_api_url:O.bambu_studio_api_url,prometheus_enabled:O.prometheus_enabled,prometheus_token:O.prometheus_token,user_notifications_enabled:O.user_notifications_enabled,default_bed_levelling:O.default_bed_levelling,default_flow_cali:O.default_flow_cali,default_vibration_cali:O.default_vibration_cali,default_layer_inspect:O.default_layer_inspect,default_timelapse:O.default_timelapse,default_nozzle_offset_cali:O.default_nozzle_offset_cali,stagger_group_size:O.stagger_group_size,stagger_interval_minutes:O.stagger_interval_minutes,require_plate_clear:O.require_plate_clear,nozzle_temp_presets:O.nozzle_temp_presets,bed_temp_presets:O.bed_temp_presets,chamber_temp_presets:O.chamber_temp_presets,fan_speed_presets:O.fan_speed_presets,session_max_hours:O.session_max_hours};In.mutate(e)},500),()=>{Mn.current&&clearTimeout(Mn.current)}},[O,vt,In,s,d,o,i]);let Rn=(0,y.useCallback)((e,t)=>{if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}k(n=>n?{...n,[e]:t}:null)},[s,d,o,i]),zn=async(e,t,n)=>{if(!t){o(i(`settings.toast.enterCameraUrl`),`error`);return}gt(t=>({...t,[e]:!0})),mt(t=>({...t,[e]:null}));try{let r=await Q.testExternalCamera(e,t,n);mt(t=>({...t,[e]:r})),r.success?o(i(`settings.toast.cameraConnected`,{resolution:r.resolution||``}),`success`):o(r.error||i(`settings.toast.connectionFailed`),`error`)}catch(t){let n=t instanceof Error?t.message:i(`settings.toast.testFailed`);mt(t=>({...t,[e]:{success:!1,error:n}})),o(n,`error`)}finally{gt(t=>({...t,[e]:!1}))}},[Bn,Vn]=(0,y.useState)({}),Hn=(0,y.useRef)({}),Un=(0,y.useRef)(new Set),[Wn,Gn]=(0,y.useState)({}),Kn=(0,y.useRef)({}),qn=(0,y.useRef)(new Set);(0,y.useEffect)(()=>{if(Pt){let e={},t={};Pt.forEach(n=>{n.external_camera_url&&!Un.current.has(n.id)&&(e[n.id]=n.external_camera_url,Un.current.add(n.id)),n.external_camera_snapshot_url&&!qn.current.has(n.id)&&(t[n.id]=n.external_camera_snapshot_url,qn.current.add(n.id))}),Object.keys(e).length>0&&Vn(t=>({...t,...e})),Object.keys(t).length>0&&Gn(e=>({...e,...t}))}},[Pt]);let Jn=(e,t)=>{Vn(n=>({...n,[e]:t})),Hn.current[e]&&clearTimeout(Hn.current[e]),Hn.current[e]=setTimeout(()=>{Ln.mutate({id:e,data:{external_camera_url:t||null}})},800)},Yn=(e,t)=>{Gn(n=>({...n,[e]:t})),Kn.current[e]&&clearTimeout(Kn.current[e]),Kn.current[e]=setTimeout(()=>{Ln.mutate({id:e,data:{external_camera_snapshot_url:t||null}})},800)},Xn=(e,t)=>{let n={};t.type!==void 0&&(n.external_camera_type=t.type||null),t.enabled!==void 0&&(n.external_camera_enabled=t.enabled),t.rotation!==void 0&&(n.camera_rotation=t.rotation),Ln.mutate({id:e,data:n})};if(yt||!O)return(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});let Zn=qHe().map(e=>({...e,label:i(e.labelKey,e.labelFallback??e.labelKey)})),Qn=ne.trim().toLowerCase(),er=Qn?Zn.filter(e=>e.label.toLowerCase().includes(Qn)||e.keywords.toLowerCase().includes(Qn)).slice(0,8):[],tr=e=>{fe(e.tab),e.subTab&&de(e.subTab),re(``),setTimeout(()=>{let t=document.getElementById(e.anchor);t&&(t.scrollIntoView({behavior:`smooth`,block:`start`}),t.classList.add(`ring-2`,`ring-bambu-green`),setTimeout(()=>t.classList.remove(`ring-2`,`ring-bambu-green`),1500))},50)};return(0,K.jsx)(gd,{density:`dense`,children:(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-4 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Ul,{className:`w-7 h-7 text-bambu-green`}),i(`settings.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.configureBambuddy`)})]}),(0,K.jsxs)(`div`,{className:`relative sm:w-72`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:ne,onChange:e=>re(e.target.value),placeholder:i(`settings.searchPlaceholder`,`Search settings…`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),ne&&(0,K.jsx)(`button`,{onClick:()=>re(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`})}),er.length>0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-30 overflow-hidden`,children:er.map(e=>(0,K.jsxs)(`button`,{onClick:()=>tr(e),className:`w-full px-3 py-2 text-left hover:bg-bambu-dark-tertiary transition-colors border-b border-bambu-dark-tertiary last:border-b-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.label}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[i(`settings.tabs.${e.tab===`virtual-printer`?`virtualPrinter`:e.tab===`failure-detection`?`failureDetection`:e.tab}`),e.subTab?` › ${i(`settings.tabs.${e.subTab}`,e.subTab)}`:``]})]},e.anchor))}),Qn&&er.length===0&&(0,K.jsx)(`div`,{className:`absolute top-full left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-30 p-3`,children:(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noSearchResults`,`No matching settings.`)})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`nav`,{className:`flex flex-wrap gap-1 border-b border-bambu-dark-tertiary lg:flex-col lg:flex-nowrap lg:gap-0 lg:border-b-0 lg:border-r lg:w-48 lg:flex-shrink-0 lg:self-start lg:sticky lg:top-4`,children:[(0,K.jsxs)(`button`,{onClick:()=>fe(`general`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`general`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Ul,{className:`w-4 h-4`}),i(`settings.tabs.general`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`plugs`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`plugs`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(xl,{className:`w-4 h-4`}),i(`settings.tabs.smartPlugs`),wt&&wt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:wt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`notifications`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`notifications`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Bo,{className:`w-4 h-4`}),i(`settings.tabs.notifications`),kt&&kt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:kt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`queue`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`queue`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Uc,{className:`w-4 h-4`}),i(`settings.tabs.queue`,`Workflow`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`filament`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`filament`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fs,{className:`w-4 h-4`}),i(`settings.tabs.filament`)]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`network`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`network`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fu,{className:`w-4 h-4`}),i(`settings.tabs.network`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on?.enabled?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`apikeys`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`apikeys`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.tabs.apiKeys`),jt&&jt.length>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:jt.length})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`virtual-printer`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`virtual-printer`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),i(`settings.tabs.virtualPrinter`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Rt?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`spoolbuddy`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`spoolbuddy`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Pl,{className:`w-4 h-4`}),i(`settings.tabs.spoolbuddy`),Bt>0&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full`,children:Bt}),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Vt?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`failure-detection`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`failure-detection`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Fl,{className:`w-4 h-4`}),i(`settings.tabs.failureDetection`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${Ut?`bg-green-400`:`bg-gray-500`}`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`users`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),i(`settings.tabs.users`),s&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>fe(`backup`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ce===`backup`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Is,{className:`w-4 h-4`}),i(`settings.tabs.backup`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${cn?.is_authenticated&&sn?.configured&&sn?.enabled||vt?.local_backup_enabled?`bg-green-400`:`bg-gray-500`}`})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[ce===`general`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`a`,{href:`https://bambuddy.cool/sponsors.html?from=app-settings`,target:`_blank`,rel:`noopener noreferrer`,className:`group block mb-4 lg:mb-6 rounded-xl border border-bambu-green/30 bg-gradient-to-br from-bambu-green/15 via-bambu-green/5 to-transparent hover:border-bambu-green/50 hover:from-bambu-green/20 transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex flex-col md:flex-row items-start md:items-center gap-4 p-4 md:p-5`,children:[(0,K.jsx)(`div`,{className:`p-3 rounded-lg bg-bambu-green/20 text-bambu-green flex-shrink-0`,children:(0,K.jsx)(Oc,{className:`w-6 h-6`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-base font-semibold text-white`,children:i(`sponsors.sectionTitle`,`Independent & community-funded`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:i(`sponsors.tagline`,`Bambuddy is free and stays that way because people choose to support it. No VC, no cloud lock-in.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-bambu-green/20 text-bambu-green group-hover:bg-bambu-green/30 text-sm font-medium whitespace-nowrap self-start md:self-auto`,children:[i(`sponsors.viewSupporters`,`View supporters`),(0,K.jsx)(Js,{className:`w-4 h-4`})]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-xl`,children:[(0,K.jsxs)(_d,{id:`card-general`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.general`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[(0,K.jsx)(bc,{className:`w-4 h-4 inline mr-1`}),i(`settings.language`)]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:a.language,onChange:e=>{let t=e.target.value;if(s&&!d(`settings:update`)){o(i(`settings.toast.noPermissionUpdate`),`error`);return}a.changeLanguage(t),In.mutate({language:t})},className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:Ot.map(e=>(0,K.jsxs)(`option`,{value:e.code,children:[e.nativeName,` (`,e.name,`)`]},e.code))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.languageDescription`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultView`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`select`,{value:ae,onChange:e=>_t(e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:wp.map(e=>(0,K.jsx)(`option`,{value:e.to,children:i(e.labelKey)},e.id))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultViewDescription`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.dateFormat`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.date_format||`system`,onChange:e=>Rn(`date_format`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,K.jsx)(`option`,{value:`us`,children:i(`settings.dateFormatUs`)}),(0,K.jsx)(`option`,{value:`eu`,children:i(`settings.dateFormatEu`)}),(0,K.jsx)(`option`,{value:`iso`,children:i(`settings.dateFormatIso`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.timeFormat`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.time_format||`system`,onChange:e=>Rn(`time_format`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`system`,children:i(`settings.systemDefault`)}),(0,K.jsx)(`option`,{value:`12h`,children:i(`settings.timeFormat12`)}),(0,K.jsx)(`option`,{value:`24h`,children:i(`settings.timeFormat24`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultPrinter`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.default_printer_id??``,onChange:e=>Rn(`default_printer_id`,e.target.value?Number(e.target.value):null),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:i(`settings.noDefaultPrinter`)}),Pt?.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.defaultPrinterDescription`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-appearance`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ml,{className:`w-5 h-5`}),i(`settings.appearance`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-bambu-gray`,children:[i(`settings.theme`),`:`]}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:[{id:`dark`,label:i(`settings.themeDark`)},{id:`light`,label:i(`settings.themeLight`)},{id:`system`,label:i(`settings.themeSystem`)}].map(({id:e,label:t})=>(0,K.jsx)(`button`,{onClick:()=>{x(e),o(i(`settings.toast.settingsSaved`),`success`)},className:`px-3 py-1 text-xs rounded-lg border transition-colors ${f===e?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-gray-300 dark:border-bambu-dark-tertiary text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white cursor-pointer`}`,children:t},e))})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-4 rounded-lg border ${p===`dark`?`border-bambu-green bg-bambu-green/5`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.darkMode`),p===`dark`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,K.jsxs)(`select`,{value:h,onChange:e=>{C(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,K.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,K.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)}),(0,K.jsx)(`option`,{value:`oled`,children:i(`settings.bgOled`)}),(0,K.jsx)(`option`,{value:`slate`,children:i(`settings.bgSlate`)}),(0,K.jsx)(`option`,{value:`forest`,children:i(`settings.bgForest`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,K.jsxs)(`select`,{value:g,onChange:e=>{w(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,K.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,K.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,K.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,K.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,K.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,K.jsxs)(`select`,{value:m,onChange:e=>{S(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,K.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,K.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 p-4 rounded-lg border ${p===`light`?`border-bambu-green bg-bambu-green/5`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[i(`settings.lightMode`),p===`light`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.active`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.background`)}),(0,K.jsxs)(`select`,{value:v,onChange:e=>{E(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`neutral`,children:i(`settings.bgNeutral`)}),(0,K.jsx)(`option`,{value:`warm`,children:i(`settings.bgWarm`)}),(0,K.jsx)(`option`,{value:`cool`,children:i(`settings.bgCool`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.accent`)}),(0,K.jsxs)(`select`,{value:b,onChange:e=>{D(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`green`,children:i(`settings.accentGreen`)}),(0,K.jsx)(`option`,{value:`teal`,children:i(`settings.accentTeal`)}),(0,K.jsx)(`option`,{value:`blue`,children:i(`settings.accentBlue`)}),(0,K.jsx)(`option`,{value:`orange`,children:i(`settings.accentOrange`)}),(0,K.jsx)(`option`,{value:`purple`,children:i(`settings.accentPurple`)}),(0,K.jsx)(`option`,{value:`red`,children:i(`settings.accentRed`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.style`)}),(0,K.jsxs)(`select`,{value:_,onChange:e=>{T(e.target.value),o(i(`settings.toast.settingsSaved`),`success`)},className:`w-full px-2 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`classic`,children:i(`settings.styleClassic`)}),(0,K.jsx)(`option`,{value:`glow`,children:i(`settings.styleGlow`)}),(0,K.jsx)(`option`,{value:`vibrant`,children:i(`settings.styleVibrant`)})]})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.themeToggleHint`)})]})]}),(0,K.jsxs)(_d,{id:`card-archive`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.archiveSettings`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.autoArchivePrints`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoArchiveDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.auto_archive,onChange:e=>Rn(`auto_archive`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.saveThumbnails`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.saveThumbnailsDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.save_thumbnails,onChange:e=>Rn(`save_thumbnails`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.captureFinishPhoto`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.captureFinishPhotoDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.capture_finish_photo,onChange:e=>Rn(`capture_finish_photo`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.capture_finish_photo&&Wt&&!Wt.installed&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`text-yellow-500 font-medium`,children:i(`settings.ffmpegNotInstalled`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i(`settings.ffmpegRequired`)})]})]}),Xt&&Zt&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`archiveAutoPurge.enableLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`archiveAutoPurge.enableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:Zt.enabled,onChange:e=>$t({enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`archiveAutoPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!Zt.enabled,value:Zt.days,onChange:e=>$t({days:Math.max(7,Math.min(3650,parseInt(e.target.value||`0`,10)||0))}),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`archiveAutoPurge.days`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`archiveAutoPurge.ageDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,disabled:!Zt.enabled,checked:Zt.purge_stats,onChange:e=>$t({purge_stats:e.target.checked}),className:`mt-0.5 shrink-0 disabled:opacity-50`}),(0,K.jsxs)(`span`,{className:`text-sm`,children:[(0,K.jsx)(`span`,{className:`text-white block`,children:i(`archiveAutoPurge.purgeStatsLabel`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray block mt-0.5`,children:i(`archiveAutoPurge.purgeStatsDescription`)})]})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-md`,children:[(0,K.jsxs)(_d,{id:`card-camera`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Au,{className:`w-5 h-5 text-bambu-green`}),i(`settings.camera`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.cameraViewMode`)}),(0,K.jsxs)(`select`,{value:O.camera_view_mode??`window`,onChange:e=>Rn(`camera_view_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`window`,children:i(`settings.newWindow`)}),(0,K.jsx)(`option`,{value:`embedded`,children:i(`settings.embeddedOverlay`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:O.camera_view_mode===`embedded`?i(`settings.cameraOverlayDescription`):i(`settings.cameraWindowDescription`)})]}),(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4 mt-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.externalCameras`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:i(`settings.externalCamerasDescription`)}),Pt&&Pt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:Pt.map(e=>(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:e.external_camera_enabled,onChange:t=>Xn(e.id,{enabled:t.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-9 h-5 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-bambu-green`})]})]}),e.external_camera_enabled&&(0,K.jsxs)(`div`,{className:`space-y-2 mt-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:e.external_camera_type===`usb`?i(`settings.cameraPlaceholderUsb`):i(`settings.cameraPlaceholderUrl`),value:Bn[e.id]??e.external_camera_url??``,onChange:t=>Jn(e.id,t.target.value),className:`w-full px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`select`,{value:e.external_camera_type||`mjpeg`,onChange:t=>Xn(e.id,{type:t.target.value}),className:`flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`mjpeg`,children:i(`settings.cameraTypeMjpeg`)}),(0,K.jsx)(`option`,{value:`rtsp`,children:i(`settings.cameraTypeRtsp`)}),(0,K.jsx)(`option`,{value:`snapshot`,children:i(`settings.cameraTypeSnapshot`)}),(0,K.jsx)(`option`,{value:`usb`,children:i(`settings.cameraTypeUsb`)})]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>zn(e.id,Bn[e.id]??e.external_camera_url??``,e.external_camera_type||`mjpeg`),disabled:ht[e.id]||!(Bn[e.id]??e.external_camera_url),children:ht[e.id]?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),pt[e.id]&&(0,K.jsx)(`div`,{className:`text-xs flex items-center gap-1 ${pt[e.id]?.success?`text-green-500`:`text-red-500`}`,children:pt[e.id]?.success?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ps,{className:`w-3 h-3`}),i(`settings.connected`),pt[e.id]?.resolution&&` (${pt[e.id]?.resolution})`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ys,{className:`w-3 h-3`}),pt[e.id]?.error||i(`settings.toast.connectionFailed`)]})}),(e.external_camera_type===`mjpeg`||e.external_camera_type===`rtsp`||e.external_camera_type===`usb`)&&(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraSnapshotUrl`,`Snapshot URL (optional)`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:i(`settings.cameraSnapshotUrlPlaceholder`,`http://192.168.1.61:1984/api/frame.jpeg?src=printer`),value:Wn[e.id]??e.external_camera_snapshot_url??``,onChange:t=>Yn(e.id,t.target.value),className:`flex-1 px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>zn(e.id,Wn[e.id]??e.external_camera_snapshot_url??``,`snapshot`),disabled:ht[e.id]||!(Wn[e.id]??e.external_camera_snapshot_url),children:ht[e.id]?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`settings.test`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray opacity-75`,children:i(`settings.cameraSnapshotUrlHelp`,`Single-frame URL used for notification thumbnails, finish photos, timelapse and plate detection. Leave blank to capture from the live stream above. Useful for go2rtc (/api/frame.jpeg) and IP cameras with a dedicated snapshot endpoint.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:i(`settings.cameraRotation`)}),(0,K.jsxs)(`select`,{value:e.camera_rotation||0,onChange:t=>Xn(e.id,{rotation:parseInt(t.target.value)}),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:0,children:`0°`}),(0,K.jsx)(`option`,{value:90,children:`90°`}),(0,K.jsx)(`option`,{value:180,children:`180°`}),(0,K.jsx)(`option`,{value:270,children:`270°`})]})]})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray italic`,children:i(`settings.noPrintersConfigured`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-cost`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.costTracking`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.currency`)}),(0,K.jsx)(`select`,{value:O.currency,onChange:e=>Rn(`currency`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:ef.map(e=>(0,K.jsx)(`option`,{value:e.code,children:e.label},e.code))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.defaultFilamentCost`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:$d(O.currency)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:O.default_filament_cost,onChange:e=>Rn(`default_filament_cost`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,$d(O.currency).length*.6+1)}rem`},className:`w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.electricityCost`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:$d(O.currency)}),(0,K.jsx)(`input`,{type:`number`,step:`0.001`,min:`0`,value:O.energy_cost_per_kwh,onChange:e=>Rn(`energy_cost_per_kwh`,parseFloat(e.target.value)||0),style:{paddingLeft:`${Math.max(2,$d(O.currency).length*.6+1)}rem`},className:`w-full pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.energyDisplayMode`)}),(0,K.jsxs)(`select`,{value:O.energy_tracking_mode||`total`,onChange:e=>Rn(`energy_tracking_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`print`,children:i(`settings.printsOnly`)}),(0,K.jsx)(`option`,{value:`total`,children:i(`settings.totalConsumption`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:O.energy_tracking_mode===`print`?i(`settings.energyModePrintDescription`):i(`settings.energyModeTotalDescription`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-filemanager`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.fileManager`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.createArchiveEntry`)}),(0,K.jsxs)(`select`,{value:O.library_archive_mode??`ask`,onChange:e=>Rn(`library_archive_mode`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`always`,children:i(`settings.archiveMode.always`)}),(0,K.jsx)(`option`,{value:`never`,children:i(`settings.archiveMode.never`)}),(0,K.jsx)(`option`,{value:`ask`,children:i(`settings.archiveMode.ask`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.createArchiveEntryDescription`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.lowDiskSpaceWarning`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0.5`,max:`100`,step:`0.5`,value:O.library_disk_warning_gb??5,onChange:e=>Rn(`library_disk_warning_gb`,parseFloat(e.target.value)||5),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`GB`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.lowDiskSpaceDescription`)})]}),Kt&&qt&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3 mt-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`libraryAutoPurge.enableLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`libraryAutoPurge.enableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:qt.auto_purge_enabled,onChange:e=>Yt({auto_purge_enabled:e.target.checked}),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`libraryAutoPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:7,max:3650,disabled:!qt.auto_purge_enabled,value:qt.auto_purge_days,onChange:e=>Yt({auto_purge_days:Math.max(7,Math.min(3650,parseInt(e.target.value||`0`,10)||0))}),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`libraryAutoPurge.days`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`libraryAutoPurge.ageDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-white cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,disabled:!qt.auto_purge_enabled,checked:qt.auto_purge_include_never_printed,onChange:e=>Yt({auto_purge_include_never_printed:e.target.checked}),className:`rounded border-gray-300 disabled:opacity-50`}),i(`libraryAutoPurge.includeNeverPrinted`)]})]})]})]}),(0,K.jsxs)(_d,{id:`card-data`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.dataManagement`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.clearNotificationLogs`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.clearNotificationLogsDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Oe(!0),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`common.clear`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.resetUiPreferences`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.resetUiPreferencesDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Ae(!0),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),i(`settings.reset`)]})]}),(0,K.jsxs)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.storageUsage`,`Storage Usage`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageDescription`,`Breakdown of data usage by category`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:Ct,disabled:St||Ue,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${St||Ue?`animate-spin`:``}`}),i(`common.refresh`,`Refresh`)]})]}),(0,K.jsx)(`div`,{className:`mt-3`,children:xt?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`common.loading`,`Loading`)]}):bt?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-full h-3 bg-bambu-dark rounded-full overflow-hidden flex`,children:bt.categories.filter(e=>e.bytes>0).map((e,t)=>(0,K.jsx)(`div`,{className:`${s6(e.key,t)} h-full`,style:{width:`${e.percent_of_total}%`},title:`${e.label}: ${e.formatted}`},e.key))}),(0,K.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-3`,children:bt.categories.filter(e=>e.bytes>0).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full ${s6(e.key,t)}`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e.label}),(0,K.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]},e.key))}),(0,K.jsxs)(`div`,{className:`mt-2 text-xs text-bambu-gray`,children:[i(`settings.storageUsageTotal`,`Total`),`: `,(0,K.jsx)(`span`,{className:`text-white`,children:bt.total_formatted}),bt.scan_errors>0&&(0,K.jsxs)(`span`,{className:`ml-2 text-amber-400`,children:[i(`settings.storageUsageErrors`,`Scan errors`),`: `,bt.scan_errors]})]}),bt.other_breakdown?.length>0&&(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:i(`settings.storageUsageOtherBreakdown`,`Other breakdown`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:bt.other_breakdown.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:e.label}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full border ${e.kind===`system`?`border-slate-500 text-slate-300`:`border-bambu-green text-bambu-green`}`,children:e.kind===`system`?i(`settings.storageUsageSystem`,`System`):i(`settings.storageUsageData`,`Data`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-white`,children:e.formatted}),(0,K.jsxs)(`span`,{children:[`(`,e.percent_of_total.toFixed(1),`%)`]})]})]},`${e.bucket}-${e.kind}`))})]})]}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.storageUsageUnavailable`,`Storage usage data is unavailable`)})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.backupRestore`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.backupRestoreDescription`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>fe(`backup`),children:[(0,K.jsx)(Is,{className:`w-4 h-4`}),i(`settings.goToBackup`)]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-3 flex-1 lg:max-w-sm`,children:[(0,K.jsxs)(_d,{id:`card-updates`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.updates`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider`,children:i(`settings.printerFirmware`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.checkPrinterFirmware`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.checkFirmwareDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.check_printer_firmware??!0,onChange:e=>Rn(`check_printer_firmware`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsx)(`div`,{className:`border-t border-bambu-dark-tertiary pt-4`,children:(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wider mb-4`,children:i(`settings.bambuddySoftware`)})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.checkForUpdatesLabel`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoCheckDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.check_updates,onChange:e=>Rn(`check_updates`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${O.check_updates?``:`opacity-50`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.includeBetaUpdates`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.includeBetaUpdatesDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.include_beta_updates??!1,onChange:e=>Rn(`include_beta_updates`,e.target.checked),disabled:!O.check_updates,className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.currentVersion`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[`v`,Gt?.version||`...`]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>tn(),disabled:nn,children:[nn?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),i(`settings.checkNow`)]})]}),en?.update_available?(0,K.jsxs)(`div`,{className:`mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:`text-bambu-green font-medium`,children:[`Update available: v`,en.latest_version]}),en.release_name&&en.release_name!==en.latest_version&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:en.release_name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[en.release_notes&&(0,K.jsx)(`button`,{onClick:()=>Pe(!0),className:`text-bambu-gray hover:text-white transition-colors text-sm underline`,children:i(`settings.releaseNotes`)}),en.release_url&&(0,K.jsx)(`a`,{href:en.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-white transition-colors`,title:i(`settings.viewReleaseOnGitHub`),children:(0,K.jsx)(Js,{className:`w-4 h-4`})})]})]}),rn?.status===`downloading`||rn?.status===`installing`?(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:rn.message})]}),(0,K.jsx)(`div`,{className:`mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green h-2 rounded-full transition-all duration-300`,style:{width:`${rn.progress}%`}})})]}):rn?.status===`complete`?(0,K.jsx)(`div`,{className:`mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green`,children:rn.message}):rn?.status===`error`?(0,K.jsx)(`div`,{className:`mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400`,children:rn.error||rn.message}):en?.is_ha_addon?(0,K.jsx)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.updateViaHomeAssistant`)})}):en?.is_docker?(0,K.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.updateViaDocker`)}),(0,K.jsx)(`code`,{className:`block text-xs bg-bambu-dark p-2 rounded text-bambu-green font-mono`,children:`docker compose pull && docker compose up -d`})]}):en?.update_method===`windows_installer`?(0,K.jsxs)(`div`,{className:`mt-3 p-3 bg-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.updateViaWindowsInstaller`)}),(0,K.jsxs)(`a`,{href:en.installer_download_url||en.release_url||`https://github.com/maziggy/bambuddy/releases/tag/v${en.latest_version}`,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 bg-bambu-green hover:bg-bambu-green-light text-white focus:ring-bambu-green px-4 py-2 text-sm gap-2 min-h-[44px] md:min-h-0`,children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),i(`settings.downloadWindowsInstaller`,{version:en.latest_version})]})]}):(0,K.jsxs)($,{className:`mt-3`,onClick:()=>Dn.mutate(),disabled:Dn.isPending,children:[Dn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vs,{className:`w-4 h-4`}),i(`settings.installUpdate`)]})]}):en?.error?(0,K.jsx)(`div`,{className:`mt-2 p-2 bg-red-500/10 border border-red-500/30 rounded text-sm text-red-400`,children:i(`settings.failedToCheckUpdates`,{error:en.error})}):en&&!en.update_available?(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:i(`settings.latestVersionRunning`)}):null]})]})]}),(0,K.jsx)(CHe,{})]})]})]}),ce===`network`&&O&&(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-externalurl`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(bc,{className:`w-5 h-5 text-blue-400`}),i(`settings.externalUrl`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.externalUrlDescription`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bambuddyUrl`)}),(0,K.jsx)(`input`,{type:`text`,value:O.external_url??``,onChange:e=>Rn(`external_url`,e.target.value),placeholder:`http://192.168.1.100:8000`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.externalUrlHint`)})]})]})]}),(0,K.jsxs)(_d,{id:`card-ftpretry`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ol,{className:`w-5 h-5 text-blue-400`}),i(`settings.ftpRetry`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.ftpRetryDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableRetry`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.autoRetryDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ftp_retry_enabled??!0,onChange:e=>Rn(`ftp_retry_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.ftp_retry_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryAttempts`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_retry_count??3,onChange:e=>Rn(`ftp_retry_count`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[1,2,3,4,5,6,7,8,9,10].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.time`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.retryDelay`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_retry_delay??2,onChange:e=>Rn(`ftp_retry_delay`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[1,2,3,5,10,15,20,30].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.second`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.connectionTimeout`)}),(0,K.jsxs)(`div`,{className:`relative w-44`,children:[(0,K.jsx)(`select`,{value:O.ftp_timeout??30,onChange:e=>Rn(`ftp_timeout`,parseInt(e.target.value)),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[10,15,20,30,45,60,90,120,180,300].map(e=>(0,K.jsx)(`option`,{value:e,children:i(`settings.nSeconds`,{count:e})},e))}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.increaseForWeakWifi`)})]})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 lg:max-w-xl space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-ha`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Ac,{className:`w-5 h-5 text-bambu-green`}),i(`settings.homeAssistant`)]}),O.ha_enabled&<&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${lt.success?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-sm ${lt.success?`text-green-400`:`text-red-400`}`,children:lt.success?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.homeAssistantFullDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableHomeAssistant`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.homeAssistantDescription`)}),O.ha_env_managed&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 mt-1`,children:[(0,K.jsx)(qc,{className:`w-3 h-3 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-green`,children:i(`settings.autoEnabledViaEnv`)})]})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ha_enabled??!1,onChange:e=>Rn(`ha_enabled`,e.target.checked),disabled:O.ha_env_managed,className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green ${O.ha_env_managed?`opacity-60 cursor-not-allowed`:``}`})]})]}),O.ha_enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.homeAssistantUrl`),O.ha_url_from_env&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,value:O.ha_url??``,onChange:e=>Rn(`ha_url`,e.target.value),placeholder:`http://192.168.1.100:8123`,disabled:O.ha_url_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${O.ha_url_from_env?`opacity-60 cursor-not-allowed`:``}`}),O.ha_url_from_env&&(0,K.jsx)(qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),O.ha_url_from_env&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.urlFromEnvReadOnly`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.longLivedAccessToken`),O.ha_token_from_env&&(0,K.jsx)(`span`,{className:`ml-2 text-xs text-bambu-green`,children:i(`settings.environmentManagedLabel`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`password`,value:O.ha_token??``,onChange:e=>Rn(`ha_token`,e.target.value),placeholder:`eyJ0eXAiOiJKV1QiLC...`,disabled:O.ha_token_from_env,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${O.ha_token_from_env?`opacity-60 cursor-not-allowed`:``}`}),O.ha_token_from_env&&(0,K.jsx)(qc,{className:`absolute right-3 top-2.5 w-4 h-4 text-bambu-gray`})]}),O.ha_token_from_env?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.tokenFromEnvReadOnly`)}):(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.haTokenHint`)})]}),O.ha_url&&O.ha_token&&(0,K.jsx)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)($,{variant:`secondary`,size:`sm`,disabled:dt,onClick:async()=>{ft(!0),ut(null);try{ut(await Q.testHAConnection(O.ha_url,O.ha_token))}catch(e){ut({success:!1,message:null,error:e instanceof Error?e.message:i(`common.unknownError`)})}finally{ft(!1)}},children:[dt?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Fu,{className:`w-4 h-4`}),i(`settings.testConnection`)]})})]})]})]}),(0,K.jsxs)(_d,{id:`card-mqtt`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Fu,{className:`w-5 h-5 text-blue-400`}),i(`settings.mqttPublishing`)]}),on?.enabled&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full ${on.connected?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-sm ${on.connected?`text-green-400`:`text-red-400`}`,children:on.connected?i(`settings.connected`):i(`settings.disconnected`)})]})]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMqtt`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.mqttEnableDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.mqtt_enabled??!1,onChange:e=>Rn(`mqtt_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.mqtt_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.brokerHostname`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_broker??``,onChange:e=>Rn(`mqtt_broker`,e.target.value),placeholder:`mqtt.example.com or 192.168.1.100`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-end gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.port`)}),(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`65535`,value:O.mqtt_port??1883,onChange:e=>Rn(`mqtt_port`,Math.min(65535,Math.max(1,parseInt(e.target.value)||1883))),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 pb-2`,children:[(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.mqtt_use_tls??!1,onChange:e=>{let t=e.target.checked;Rn(`mqtt_use_tls`,t);let n=O.mqtt_port??1883;t&&n===1883?Rn(`mqtt_port`,8883):!t&&n===8883&&Rn(`mqtt_port`,1883)},className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]}),(0,K.jsx)(`span`,{className:`text-white text-sm`,children:i(`settings.useTls`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.usernameOptional`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_username??``,onChange:e=>Rn(`mqtt_username`,e.target.value),placeholder:i(`settings.leaveEmptyForAnonymous`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.passwordOptional`)}),(0,K.jsx)(`input`,{type:`password`,value:O.mqtt_password??``,onChange:e=>Rn(`mqtt_password`,e.target.value),placeholder:i(`settings.leaveEmptyForAnonymous`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.topicPrefix`)}),(0,K.jsx)(`input`,{type:`text`,value:O.mqtt_topic_prefix??`bambuddy`,onChange:e=>Rn(`mqtt_topic_prefix`,e.target.value),placeholder:`bambuddy`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.topicPrefixHint`,{prefix:O.mqtt_topic_prefix||`bambuddy`})})]}),on&&(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${on.connected?`bg-green-400`:`bg-red-400`}`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:on.connected?(0,K.jsxs)(K.Fragment,{children:[i(`settings.mqttConnectedTo`),` `,(0,K.jsxs)(`span`,{className:`text-white`,children:[on.broker,`:`,on.port]})]}):i(`settings.spoolmanDisconnected`)})]})})]})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 lg:max-w-md space-y-3`,children:(0,K.jsxs)(_d,{id:`card-prometheus`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Su,{className:`w-5 h-5 text-orange-400`}),i(`settings.prometheusMetrics`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.prometheusEndpointDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.enableMetricsEndpoint`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.prometheusDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.prometheus_enabled??!1,onChange:e=>Rn(`prometheus_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.prometheus_enabled&&(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.bearerTokenOptional`)}),(0,K.jsx)(`input`,{type:`password`,value:O.prometheus_token??``,onChange:e=>Rn(`prometheus_token`,e.target.value),placeholder:i(`settings.leaveEmptyForNoAuth`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.bearerTokenHint`)})]}),(0,K.jsxs)(`div`,{className:`pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white mb-2`,children:i(`settings.availableMetrics`)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray space-y-1`,children:[(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_printer_connected`}),` - `,i(`settings.metricsConnectionStatus`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_printer_state`}),` - `,i(`settings.metricsPrinterState`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_print_progress`}),` - `,i(`settings.metricsPrintProgress`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_bed_temp_celsius`}),` - `,i(`settings.metricsBedTemp`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_nozzle_temp_celsius`}),` - `,i(`settings.metricsNozzleTemp`)]}),(0,K.jsxs)(`p`,{children:[(0,K.jsx)(`code`,{className:`text-orange-400`,children:`bambuddy_prints_total`}),` - `,i(`settings.metricsPrintsTotal`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray/70 italic`,children:i(`settings.metricsMore`)})]})]})]})]})]})})]}),lt&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[lt.success?(0,K.jsx)(ps,{className:`w-8 h-8 text-green-400`}):(0,K.jsx)(ys,{className:`w-8 h-8 text-red-400`}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white`,children:lt.success?i(`settings.connectionSuccessful`):i(`settings.connectionFailed`)})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:lt.success?lt.message||i(`settings.haConnectionSuccess`):lt.error||i(`settings.haConnectionFailed`)}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)($,{variant:`primary`,onClick:()=>ut(null),children:i(`settings.ok`)})})]})}),ce===`plugs`&&(0,K.jsxs)(`div`,{id:`card-plugs`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(xl,{className:`w-5 h-5 text-bambu-green`}),i(`settings.smartPlugs`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.smartPlugsDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 shrink-0`,children:[wt&&wt.filter(e=>e.enabled).length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Me(`on`),disabled:jn.isPending,title:i(`settings.turnAllPlugsOn`),children:[jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(wl,{className:`w-4 h-4 text-bambu-green`}),i(`settings.allOn`)]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>Me(`off`),disabled:jn.isPending,title:i(`settings.turnAllPlugsOff`),children:[jn.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Cl,{className:`w-4 h-4 text-red-400`}),i(`settings.allOff`)]})]}),(0,K.jsxs)($,{className:`whitespace-nowrap`,onClick:()=>{F(null),N(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addSmartPlug`)]})]})]}),wt&&wt.length>0&&(0,K.jsxs)(_d,{className:`mb-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-yellow-400`}),i(`settings.energySummary`),Dt&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-gray ml-2`})]})}),(0,K.jsx)(yd,{children:Et?(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Bu,{className:`w-3 h-3`}),i(`settings.currentPower`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalPower.toFixed(1),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`W`})]}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.plugsOnline`,{reachable:Et.reachableCount,total:Et.totalPlugs})})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Zo,{className:`w-3 h-3`}),i(`settings.today`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalToday.toFixed(3),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalToday*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Su,{className:`w-3 h-3`}),i(`settings.yesterday`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalYesterday.toFixed(3),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalYesterday*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-xs mb-1`,children:[(0,K.jsx)(Rs,{className:`w-3 h-3`}),i(`settings.total`)]}),(0,K.jsxs)(`div`,{className:`text-xl font-bold text-white`,children:[Et.totalLifetime.toFixed(1),(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray ml-1`,children:`kWh`})]}),(O?.energy_cost_per_kwh??0)>0&&(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[`~`,(Et.totalLifetime*(O?.energy_cost_per_kwh??0)).toFixed(2),` `,$d(O?.currency||`USD`)]})]})]}):Dt?null:(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.enablePlugsForSummary`)})})]}),Tt?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):wt&&wt.length>0?(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:wt.map(e=>(0,K.jsx)(VVe,{plug:e,onEdit:e=>{F(e),N(!0)}},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-12`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(xl,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.noSmartPlugsTitle`)}),(0,K.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.noSmartPlugsDescription`)}),(0,K.jsxs)($,{onClick:()=>{F(null),N(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addFirstSmartPlug`)]})]})})})]}),ce===`notifications`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-providers`,children:[(0,K.jsx)(Bo,{className:`w-5 h-5 text-bambu-green`}),i(`settings.providers`)]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>H(!0),children:[(0,K.jsx)(kc,{className:`w-4 h-4`}),i(`settings.log`)]}),kt&&kt.length>0&&(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>{kn(null),An.mutate()},disabled:An.isPending,children:[An.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(zl,{className:`w-4 h-4`}),i(`settings.testAll`)]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>{z(null),L(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addNotificationProvider`)]})]})]}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.notificationLanguage`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.notificationLanguageDescription`)})]}),(0,K.jsx)(`select`,{value:O.notification_language||`en`,onChange:e=>Rn(`notification_language`,e.target.value),className:`px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green`,children:Ot.map(e=>(0,K.jsx)(`option`,{value:e.code,children:e.nativeName},e.code))})]})})}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.bedCooledThreshold`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.bedCooledThresholdDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:20,max:80,step:1,value:O.bed_cooled_threshold??35,onChange:e=>Rn(`bed_cooled_threshold`,Number(e.target.value)),className:`w-16 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm text-center focus:outline-none focus:ring-1 focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`°C`})]})]})})}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between ${ln?.advanced_auth_enabled?``:`opacity-50`}`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white text-sm font-medium`,children:i(`settings.userNotificationsEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:ln?.advanced_auth_enabled?i(`settings.userNotificationsEnabledDescription`):i(`settings.userNotificationsDisabledHint`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,className:`sr-only peer`,checked:O.user_notifications_enabled??!0,disabled:!ln?.advanced_auth_enabled,onChange:e=>Rn(`user_notifications_enabled`,e.target.checked)}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green peer-disabled:cursor-not-allowed`})]})]})})}),On&&(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-white`,children:i(`settings.testResults`)}),(0,K.jsx)(`button`,{onClick:()=>kn(null),className:`text-bambu-gray hover:text-white text-xs`,children:i(`common.dismiss`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm mb-2`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-green`,children:[(0,K.jsx)(ps,{className:`w-4 h-4`}),i(`settings.testPassedCount`,{count:On.success})]}),On.failed>0&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(ys,{className:`w-4 h-4`}),i(`settings.testFailedCount`,{count:On.failed})]})]}),On.results.filter(e=>!e.success).length>0&&(0,K.jsx)(`div`,{className:`space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary`,children:On.results.filter(e=>!e.success).map(e=>(0,K.jsxs)(`div`,{className:`text-xs text-red-400`,children:[(0,K.jsxs)(`span`,{className:`font-medium`,children:[e.provider_name,`:`]}),` `,e.message]},e.provider_id))})]})}),At?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):kt&&kt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:kt.map(e=>(0,K.jsx)(UVe,{provider:e,onEdit:e=>{z(e),L(!0)}},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(Bo,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm font-medium text-white mb-2`,children:i(`settings.noProvidersTitle`)}),(0,K.jsx)(`p`,{className:`text-xs mb-3`,children:i(`settings.noProvidersDescription`)}),(0,K.jsxs)($,{size:`sm`,onClick:()=>{z(null),L(!0)},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addProvider`)]})]})})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-2`,id:`card-templates`,children:[(0,K.jsx)(nc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.messageTemplates`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:i(`settings.messageTemplatesDescription`)}),(0,K.jsxs)(`div`,{className:`relative mb-3`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 text-bambu-gray absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),placeholder:i(`settings.filterTemplates`,`Filter templates…`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),ee&&(0,K.jsx)(`button`,{onClick:()=>te(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-bambu-gray hover:text-white`,"aria-label":`Clear filter`,children:(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`})})]}),It?(0,K.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):Ft&&Ft.length>0?(()=>{let e=ee.trim().toLowerCase(),t=[...Ft].sort((e,t)=>e.name.localeCompare(t.name)).filter(t=>!e||t.name.toLowerCase().includes(e)||(t.title_template||``).toLowerCase().includes(e));return t.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic text-center py-6`,children:i(`settings.noTemplatesMatch`,`No templates match your filter.`)}):(0,K.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,K.jsx)(_d,{className:`cursor-pointer hover:border-bambu-green/50 transition-colors`,onClick:()=>V(e),children:(0,K.jsx)(yd,{className:`py-2.5 px-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-sm truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs truncate mt-0.5`,children:e.title_template})]}),(0,K.jsx)(`button`,{className:`p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2`,onClick:t=>{t.stopPropagation(),V(e)},children:(0,K.jsx)(_l,{className:`w-4 h-4 text-bambu-gray`})})]})})},e.id))})})():(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-8`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(nc,{className:`w-12 h-12 mx-auto mb-3 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:i(`settings.noTemplatesAvailable`)})]})})})]})]}),ce===`apikeys`&&(0,K.jsxs)(`div`,{className:d(`api_keys:read`)?`grid grid-cols-1 xl:grid-cols-2 gap-4`:`grid grid-cols-1 gap-4`,children:[(0,K.jsxs)(`div`,{children:[d(`api_keys:read`)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-createapi`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiKeys`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiKeysDescription`)})]}),(0,K.jsxs)($,{size:`sm`,onClick:()=>me(!0),className:`flex-shrink-0`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createKey`)]})]}),ye&&(0,K.jsx)(_d,{className:`mb-6 border-bambu-green`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(ps,{className:`w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:i(`settings.apiKeyCreated`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyCopyWarning`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-bambu-dark rounded-lg p-2`,children:[(0,K.jsx)(`code`,{className:`flex-1 text-sm text-bambu-green font-mono break-all`,children:ye}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ye);else{let e=document.createElement(`textarea`);e.value=ye,e.style.position=`fixed`,e.style.left=`-999999px`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}o(i(`settings.toast.keyCopied`))}catch{o(i(`settings.toast.copyFailed`),`error`)}},children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 mt-3`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{Ee(ye),o(i(`settings.toast.keyAddedToBrowser`))},children:i(`settings.useInApiBrowser`)}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Se(!0),children:[(0,K.jsx)(El,{className:`w-4 h-4`}),i(`settings.apiKeyQrButton`)]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>{Se(!1),be(null)},children:i(`common.dismiss`)})]})]})]})})}),xe&&ye&&(0,K.jsx)(oHe,{apiKey:ye,baseUrl:O?.external_url||void 0,onClose:()=>Se(!1)}),pe&&(0,K.jsxs)(_d,{className:`mb-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:i(`settings.createNewApiKey`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keyName`)}),(0,K.jsx)(`input`,{type:`text`,value:he,onChange:e=>ge(e.target.value),placeholder:i(`settings.keyNamePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`common.permissions`)}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_read_status,onChange:e=>ve(t=>({...t,can_read_status:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.readStatus`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.readStatusDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_queue,onChange:e=>ve(t=>({...t,can_queue:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageQueue`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageQueueDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_control_printer,onChange:e=>ve(t=>({...t,can_control_printer:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.controlPrinter`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.controlPrinterDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_manage_library,onChange:e=>ve(t=>({...t,can_manage_library:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageLibrary`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageLibraryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_manage_inventory,onChange:e=>ve(t=>({...t,can_manage_inventory:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.manageInventory`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.manageInventoryDescription`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_access_cloud,onChange:e=>ve(t=>({...t,can_access_cloud:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.cloudAccess`,`Allow cloud access`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.cloudAccessDescription`,`Read Bambu Cloud presets and filaments on your behalf. Requires you to be signed into Bambu Cloud.`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-3 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:_e.can_update_energy_cost,onChange:e=>ve(t=>({...t,can_update_energy_cost:e.target.checked})),className:`w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`span`,{className:`text-white`,children:i(`settings.updateEnergyCost`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.updateEnergyCostDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pt-2`,children:[(0,K.jsxs)($,{onClick:()=>G.mutate({name:he||i(`settings.unnamedKey`),..._e}),disabled:G.isPending,children:[G.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createKey`)]}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>me(!1),children:i(`common.cancel`)})]})]})]}),Mt?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):jt&&jt.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:jt.map(e=>(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 ${e.enabled?`text-bambu-green`:`text-bambu-gray`}`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e.name}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[e.key_prefix,`••••••••`,e.last_used&&` · ${i(`settings.lastUsed`)}: ${yf(e.last_used)}`]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex gap-1 text-xs flex-wrap justify-end`,children:[e.can_read_status&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded`,children:i(`settings.read`)}),e.can_queue&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded`,children:i(`queue.title`)}),e.can_control_printer&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded`,children:i(`settings.control`)}),e.can_manage_library&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-cyan-500/20 text-cyan-400 rounded`,children:i(`settings.libraryBadge`)}),e.can_manage_inventory&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-pink-500/20 text-pink-400 rounded`,children:i(`settings.inventoryBadge`)}),e.can_access_cloud&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-purple-500/20 text-purple-400 rounded`,children:i(`settings.cloudBadge`,`Cloud`)}),e.can_update_energy_cost&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-amber-500/20 text-amber-400 rounded`,children:i(`settings.energyCostBadge`)}),e.user_id===null&&(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-yellow-500/20 text-yellow-400 rounded`,title:i(`settings.legacyKeyTooltip`,`Created before per-user ownership; recreate to use cloud access`),children:i(`settings.legacyKey`,`Legacy`)})]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>we(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4 text-red-400`})})]})]})})},e.id))}):(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-12`,children:(0,K.jsxs)(`div`,{className:`text-center text-bambu-gray`,children:[(0,K.jsx)(Ic,{className:`w-16 h-16 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.apiKeysEmptyTitle`)}),(0,K.jsx)(`p`,{className:`text-sm mb-4`,children:i(`settings.apiKeysEmptyDescription`)}),(0,K.jsxs)($,{onClick:()=>me(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createFirstKey`)]})]})})}),(0,K.jsxs)(_d,{className:`mt-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h3`,{className:`text-base font-semibold text-white`,id:`card-webhooks`,children:i(`settings.webhookEndpoints`)})}),(0,K.jsxs)(yd,{className:`space-y-3 text-sm`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:i(`settings.webhookApiKeyHint`)}),(0,K.jsxs)(`div`,{className:`space-y-2 font-mono text-xs`,children:[(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-blue-400`,children:`GET`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getAllStatus`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-blue-400`,children:`GET`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/status/:id`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.getSpecificStatus`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-green-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/queue`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.addToQueue`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-orange-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/pause`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.pausePrint`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-orange-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/resume`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.resumePrint`)]})]}),(0,K.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded`,children:[(0,K.jsx)(`span`,{className:`text-red-400`,children:`POST`}),` `,(0,K.jsx)(`span`,{className:`text-white`,children:`/api/v1/webhook/printer/:id/stop`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[` - `,i(`settings.webhook.stopPrint`)]})]})]})]})]})]}),(0,K.jsxs)(_d,{className:`mt-6`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-camera-tokens`,children:[(0,K.jsx)(Au,{className:`w-4 h-4 text-bambu-green`}),i(`cameraTokens.title`,`Camera API Tokens`)]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(BVe,{})})]})]}),d(`api_keys:read`)&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-apibrowser`,children:[(0,K.jsx)(bc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.apiBrowser`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.apiBrowserDescription`)})]}),(0,K.jsx)(_d,{className:`mb-4`,children:(0,K.jsxs)(yd,{className:`py-3`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-2`,children:i(`settings.apiKeyForTesting`)}),(0,K.jsx)(`input`,{type:`text`,value:Te,onChange:e=>Ee(e.target.value),placeholder:i(`settings.apiKeyPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:i(`settings.apiKeyHint`)})]})}),(0,K.jsx)(QHe,{apiKey:Te})]})]}),ce===`virtual-printer`&&(0,K.jsx)(`div`,{id:`card-vp`,children:(0,K.jsx)(kHe,{})}),ce===`spoolbuddy`&&(0,K.jsx)(`div`,{id:`card-spoolbuddy`,children:(0,K.jsx)(jHe,{})}),ce===`queue`&&O&&(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-print-options`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Uc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.defaultPrintOptions`,`Default Print Options`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.defaultPrintOptionsDescription`,`Set default values for print options when starting new prints. These can be overridden per print in the print dialog.`)}),[{key:`default_bed_levelling`,label:i(`settings.defaultBedLevelling`,`Bed Levelling`),desc:i(`settings.defaultBedLevellingDesc`,`Auto-level bed before print`),fallback:!0,dualNozzleOnly:!1},{key:`default_flow_cali`,label:i(`settings.defaultFlowCali`,`Flow Calibration`),desc:i(`settings.defaultFlowCaliDesc`,`Calibrate extrusion flow`),fallback:!1,dualNozzleOnly:!1},{key:`default_vibration_cali`,label:i(`settings.defaultVibrationCali`,`Vibration Calibration`),desc:i(`settings.defaultVibrationCaliDesc`,`Reduce ringing artifacts`),fallback:!0,dualNozzleOnly:!1},{key:`default_layer_inspect`,label:i(`settings.defaultLayerInspect`,`First Layer Inspection`),desc:i(`settings.defaultLayerInspectDesc`,`AI inspection of first layer`),fallback:!1,dualNozzleOnly:!1},{key:`default_timelapse`,label:i(`settings.defaultTimelapse`,`Timelapse`),desc:i(`settings.defaultTimelapseDesc`,`Record timelapse video`),fallback:!1,dualNozzleOnly:!1},{key:`default_nozzle_offset_cali`,label:i(`settings.defaultNozzleOffsetCali`,`Nozzle Offset Calibration`),desc:i(`settings.defaultNozzleOffsetCaliDesc`,`Calibrate nozzle offsets between extruders`),fallback:!0,dualNozzleOnly:!0}].filter(({dualNozzleOnly:e})=>!e||(Pt||[]).some(e=>e.nozzle_count===2)).map(({key:e,label:t,desc:n,fallback:r})=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:t}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:n})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O[e]??r,onChange:t=>Rn(e,t.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]},e))]})]}),(0,K.jsxs)(_d,{id:`card-temp-fan-presets`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(vu,{className:`w-4 h-4 text-bambu-green`}),i(`settings.tempFanPresetsTitle`,`Temperature & Fan Presets`)]})}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.tempFanPresetsDescription`,`Customize the quick-select values shown in printer-card temperature and fan-speed popovers. The Off button is always shown.`)}),Ip.map(e=>{let t=Lp(O?.[e.key]??``,e.defaults,e.lo,e.hi),n=e.unit===`C`?`°C`:`%`;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,K.jsxs)(`label`,{className:`text-sm text-white`,children:[i(`settings.${{nozzle_temp_presets:`tempFanPresetsNozzle`,bed_temp_presets:`tempFanPresetsBed`,chamber_temp_presets:`tempFanPresetsChamber`,fan_speed_presets:`tempFanPresetsFan`}[e.key]}`,{nozzle_temp_presets:`Nozzle temperature`,bed_temp_presets:`Bed temperature`,chamber_temp_presets:`Chamber temperature`,fan_speed_presets:`Fan speed`}[e.key]),` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,n,` · `,e.lo,`–`,e.hi,`)`]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>Rn(e.key,``),title:i(`settings.tempFanPresetsReset`,`Reset to defaults`),className:`text-bambu-gray hover:text-white transition-colors p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Al,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:[0,1,2].map(n=>(0,K.jsx)(`input`,{type:`number`,min:e.lo,max:e.hi,value:t[n],onChange:r=>{let i=[t[0],t[1],t[2]],a=parseInt(r.target.value,10);i[n]=Math.max(e.lo,Math.min(e.hi,Number.isFinite(a)?a:e.lo)),Rn(e.key,JSON.stringify(i))},className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`},n))})]},e.key)})]})]}),(0,K.jsxs)(_d,{id:`card-staggered`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-green`}),i(`settings.staggeredStart`,`Staggered Start`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.staggeredStartDescription`,`Default group size and interval when staggering multi-printer batch starts. Can be overridden per batch in the print modal.`)}),(0,K.jsxs)(`div`,{className:`flex gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerGroupSize`,`Group size`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:50,value:O.stagger_group_size??2,onChange:e=>Rn(`stagger_group_size`,Math.max(1,Math.min(50,parseInt(e.target.value)||1))),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerGroupSizeHelp`,`Printers to start simultaneously per group`)})]}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.staggerInterval`,`Interval (minutes)`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:60,value:O.stagger_interval_minutes??5,onChange:e=>Rn(`stagger_interval_minutes`,Math.max(1,Math.min(60,parseInt(e.target.value)||1))),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.staggerIntervalHelp`,`Delay between each group starting`)})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-plate`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-4 h-4 text-bambu-green`}),i(`settings.plateClear`,`Plate-Clear Confirmation`)]})}),(0,K.jsx)(yd,{className:`space-y-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 mr-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:i(`settings.requirePlateClear`,`Require plate-clear confirmation`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.requirePlateClearDescription`,`When enabled, the scheduler waits for per-printer plate-clear confirmation before starting queued prints on printers with finished jobs. Disabling this also hides the plate status badge and the "Mark plate as cleared" button on printer cards.`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.require_plate_clear??!1,onChange:e=>Rn(`require_plate_clear`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})})]}),(0,K.jsxs)(_d,{id:`card-gcode`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Es,{className:`w-4 h-4 text-bambu-green`}),i(`settings.gcodeInjection`,`G-code Injection`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.gcodeInjectionDescription`,`Configure custom G-code to inject at the start and/or end of prints for auto-print systems like Farmloop, SwapMod, AutoClear, and Printflow 3D. Snippets are configured per printer model and applied when "Inject G-code" is enabled on a queue item.`)}),(()=>{let e=(()=>{try{return O.gcode_snippets?JSON.parse(O.gcode_snippets):{}}catch{return{}}})(),t=[...new Set((Pt||[]).filter(e=>e.model).map(e=>e.model))].sort(),n=(t,n,r)=>{let i={...e};i[t]||(i[t]={start_gcode:``,end_gcode:``}),i[t][n]=r,!i[t].start_gcode&&!i[t].end_gcode&&delete i[t];let a=Object.keys(i).length>0?JSON.stringify(i):``;k(e=>e?{...e,gcode_snippets:a}:null),Nn.current=a},r=()=>{Nn.current!==null&&(In.mutate({gcode_snippets:Nn.current}),Nn.current=null)};return t.length===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic`,children:i(`settings.gcodeInjectionNoPrinters`,`No printers found. Add printers to configure G-code snippets.`)}):t.map(t=>{let a=e[t]||{start_gcode:``,end_gcode:``},o=!!(a.start_gcode||a.end_gcode);return(0,K.jsx)(lp,{defaultOpen:o,className:`border border-bambu-dark-tertiary rounded-lg px-3 py-2`,summary:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t}),o&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:i(`settings.gcodeConfigured`,`Configured`)})]}),children:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeStartLabel`,`Start G-code`)}),(0,K.jsx)(`textarea`,{value:a.start_gcode,onChange:e=>n(t,`start_gcode`,e.target.value),onBlur:r,placeholder:i(`settings.gcodeStartPlaceholder`,`G-code prepended before the print starts...`),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:outline-none focus:border-bambu-green resize-y`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1`,children:i(`settings.gcodeEndLabel`,`End G-code`)}),(0,K.jsx)(`textarea`,{value:a.end_gcode,onChange:e=>n(t,`end_gcode`,e.target.value),onBlur:r,placeholder:i(`settings.gcodeEndPlaceholder`,`G-code appended after the print ends...`),rows:3,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono focus:outline-none focus:border-bambu-green resize-y`})]})]})},t)})})()]})]})]}),(0,K.jsxs)(`div`,{className:`lg:w-1/2 space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-slicer`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ks,{className:`w-4 h-4 text-bambu-green`}),i(`settings.slicerCard`,`Slicer`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.preferredSlicer`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.preferred_slicer??`bambu_studio`,onChange:e=>Rn(`preferred_slicer`,e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,K.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.preferredSlicerDescription`)}),(O.preferred_slicer??`bambu_studio`)===`orcaslicer`&&(0,K.jsx)(`div`,{role:`alert`,className:`text-xs text-amber-200 bg-amber-900/20 border border-amber-700/40 rounded p-2 mt-2`,children:i(`settings.orcaslicerKnownIssuesWarning`,`OrcaSlicer 2.3.2 / 2.4.0-dev have known CLI bugs that block slicing many Bambu-authored 3MFs — see upstream issues #12426 (segfault on painted multi-extruder files) and #13386 (parameter-range strict-validation reject). Bambu Studio is recommended until the upstream fixes land.`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.openInSlicerLabel`,`Open in Slicer`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`select`,{value:O.open_in_slicer??``,onChange:e=>Rn(`open_in_slicer`,e.target.value===``?null:e.target.value),className:`w-full px-3 py-2 pr-10 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none appearance-none cursor-pointer`,children:[(0,K.jsx)(`option`,{value:``,children:i(`settings.openInSlicerInherit`,`Same as API slicer`)}),(0,K.jsx)(`option`,{value:`bambu_studio`,children:i(`settings.slicerBambuStudio`)}),(0,K.jsx)(`option`,{value:`orcaslicer`,children:i(`settings.slicerOrcaSlicer`)})]}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.openInSlicerDescription`,`Desktop slicer used by the 'Open in Slicer' button. Leave on 'Same as API slicer' to inherit, or pick a different slicer to use locally.`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.useSlicerApi`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.useSlicerApiDescription`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center cursor-pointer shrink-0`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.use_slicer_api??!1,onChange:e=>Rn(`use_slicer_api`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`relative w-11 h-6 bg-bambu-dark-tertiary rounded-full peer peer-checked:bg-bambu-green peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-bambu-green/50 transition-colors after:content-[''] after:absolute after:top-0.5 after:left-0.5 after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-transform peer-checked:after:translate-x-5`})]})]}),(O.use_slicer_api??!1)&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:(O.preferred_slicer??`bambu_studio`)===`orcaslicer`?i(`settings.orcaslicerApiUrl`,`OrcaSlicer sidecar URL`):i(`settings.bambuStudioApiUrl`,`Bambu Studio sidecar URL`)}),(0,K.jsx)(`input`,{type:`text`,value:((O.preferred_slicer??`bambu_studio`)===`orcaslicer`?O.orcaslicer_api_url:O.bambu_studio_api_url)??``,onChange:e=>Rn((O.preferred_slicer??`bambu_studio`)===`orcaslicer`?`orcaslicer_api_url`:`bambu_studio_api_url`,e.target.value),placeholder:(O.preferred_slicer??`bambu_studio`)===`orcaslicer`?`http://localhost:3003`:`http://localhost:3001`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none placeholder:text-bambu-gray/40`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:i(`settings.slicerApiUrlDescription`,`URL of the slicer-API sidecar container. Leave blank to use the SLICER_API_URL / BAMBU_STUDIO_API_URL env var defaults.`)})]})]})]}),(O.use_slicer_api??!1)&&(0,K.jsx)(PVe,{}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-base font-semibold text-white flex items-center gap-2`,id:`card-drying`,children:[(0,K.jsx)(ac,{className:`w-4 h-4 text-amber-400`}),i(`settings.queueDrying`)]})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.queueDryingDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingEnabledDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.queue_drying_enabled??!1,onChange:e=>Rn(`queue_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),O.queue_drying_enabled&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.queueDryingBlock`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.queueDryingBlockDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.queue_drying_block??!1,onChange:e=>Rn(`queue_drying_block`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-amber-500`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-white`,children:i(`settings.ambientDryingEnabled`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:i(`settings.ambientDryingEnabledDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.ambient_drying_enabled??!1,onChange:e=>Rn(`ambient_drying_enabled`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.dryingPresets`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.dryingPresetsDescription`)}),(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,K.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS 2 Pro`}),(0,K.jsx)(`th`,{className:`text-center py-1.5`,colSpan:2,children:`AMS-HT`})]})}),(0,K.jsx)(`tbody`,{children:(()=>{let e={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}},t={...e};try{if(O.drying_presets){let n=JSON.parse(O.drying_presets);typeof n==`object`&&n&&(t={...e,...n})}}catch{}let n=(e,n,r)=>{let i={...t,[e]:{...t[e],[n]:r}};Rn(`drying_presets`,JSON.stringify(i))};return Object.entries(t).map(([e,t])=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 text-white font-medium`,children:e}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:30,max:65,value:t.n3f,onChange:t=>n(e,`n3f`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:t.n3f_hours,onChange:t=>n(e,`n3f_hours`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:30,max:85,value:t.n3s,onChange:t=>n(e,`n3s`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})}),(0,K.jsx)(`td`,{className:`py-1 px-1`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:24,value:t.n3s_hours,onChange:t=>n(e,`n3s_hours`,Math.max(1,parseInt(t.target.value)||0)),className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`h`})]})})]},e))})()})]})})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:i(`settings.humidityThresholds`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.humidityThresholdsDescription`)}),(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left py-1.5`,children:i(`settings.dryingFilament`)}),(0,K.jsx)(`th`,{className:`text-right py-1.5 pr-2`,children:i(`settings.humidityThresholdCol`)})]})}),(0,K.jsx)(`tbody`,{children:(()=>{let e=O.ams_humidity_fair??60,t=[`PLA`,`PETG`,`TPU`,`ABS`,`ASA`,`PA`,`PC`,`PVA`],n={};try{if(O.ams_humidity_thresholds){let e=JSON.parse(O.ams_humidity_thresholds);typeof e==`object`&&e&&(n=e)}}catch{}let r=[{key:`default`,label:i(`settings.humidityThresholdDefault`),value:Number(n.default??e),isDefault:!0},...t.map(t=>({key:t,label:t,value:Number(n[t]??n.default??e),isDefault:!1}))],a=(e,t)=>{if(t.trim()===``){let t={...n};delete t[e],Rn(`ams_humidity_thresholds`,JSON.stringify(t));return}let r=parseInt(t,10);if(Number.isNaN(r))return;let i=Math.max(5,Math.min(95,r)),a={...n,[e]:i};Rn(`ams_humidity_thresholds`,JSON.stringify(a))};return r.map(e=>{let t=A[e.key],n=t===void 0?String(e.value):t;return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50`,children:[(0,K.jsx)(`td`,{className:`py-1.5 pr-2 font-medium ${e.isDefault?`text-bambu-gray italic`:`text-white`}`,children:e.label}),(0,K.jsx)(`td`,{className:`py-1 pr-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:5,max:95,value:n,onChange:t=>j(n=>({...n,[e.key]:t.target.value})),onBlur:t=>{a(e.key,t.target.value),j(t=>{let n={...t};return delete n[e.key],n})},onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 px-1.5 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-center text-xs focus:border-amber-500/50 focus:outline-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})})]},e.key)})})()})]})})]})]})]})]})]}),ce===`filament`&&O&&(0,K.jsx)(K.Fragment,{children:(0,K.jsxs)(`div`,{className:`flex flex-col lg:flex-row gap-4 lg:gap-6`,children:[(0,K.jsxs)(`div`,{className:`lg:w-1/3 space-y-3`,children:[(0,K.jsx)(uHe,{}),(0,K.jsxs)(_d,{id:`card-filamentchecks`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.filamentChecks`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.disableFilamentWarnings`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.disableFilamentWarningsDesc`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.disable_filament_warnings,onChange:e=>Rn(`disable_filament_warnings`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.preferLowestFilament`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.preferLowestFilamentDesc`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:i(`settings.preferLowestFilamentBackupNote`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.prefer_lowest_filament,onChange:e=>Rn(`prefer_lowest_filament`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})]})]}),(0,K.jsxs)(_d,{id:`card-printmodal`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.printModal`)})}),(0,K.jsx)(yd,{className:`space-y-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.expandCustomMapping`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.expandCustomMappingDescription`)})]}),(0,K.jsxs)(`label`,{className:`relative inline-flex items-center cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:O.per_printer_mapping_expanded??!1,onChange:e=>Rn(`per_printer_mapping_expanded`,e.target.checked),className:`sr-only peer`}),(0,K.jsx)(`div`,{className:`w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green`})]})]})})]}),(0,K.jsxs)(_d,{id:`card-amsthresholds`,children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.amsDisplayThresholds`)})}),(0,K.jsxs)(yd,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.amsThresholdsDescription`)}),(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(Us,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.humidity`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodGreen`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:O.ams_humidity_good??40,onChange:e=>Rn(`ams_humidity_good`,parseInt(e.target.value)||40),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`0`,max:`100`,value:O.ams_humidity_fair??60,onChange:e=>Rn(`ams_humidity_fair`,parseInt(e.target.value)||60),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`%`})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairBad`)}),(0,K.jsx)(`p`,{className:`text-xs text-amber-400/70`,children:i(`settings.fairAlsoDryingThreshold`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 pt-2 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(vu,{className:`w-4 h-4 text-orange-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.temperature`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.goodBlue`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:O.ams_temp_good??28,onChange:e=>Rn(`ams_temp_good`,parseFloat(e.target.value)||28),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:[i(`settings.fairOrange`),` ≤`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,step:`0.5`,min:`0`,max:`60`,value:O.ams_temp_fair??35,onChange:e=>Rn(`ams_temp_fair`,parseFloat(e.target.value)||35),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`°C`})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.aboveFairHot`)})]}),(0,K.jsxs)(`div`,{className:`space-y-3 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-white`,children:[(0,K.jsx)(Is,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`font-medium`,children:i(`settings.historyRetention`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:i(`settings.keepSensorHistory`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,min:`1`,max:`365`,value:O.ams_history_retention_days??30,onChange:e=>Rn(`ams_history_retention_days`,parseInt(e.target.value)||30),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`common.days`)})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:i(`settings.historyRetentionDescription`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`lg:w-2/3 space-y-3`,children:[(0,K.jsx)(dHe,{}),(0,K.jsx)(xHe,{})]})]})}),Ce!==null&&(0,K.jsx)(Ad,{title:i(`settings.deleteApiKeyTitle`),message:i(`settings.deleteApiKeyMessage`),confirmText:i(`settings.deleteKey`),variant:`danger`,onConfirm:()=>{Nt.mutate(Ce),we(null)},onCancel:()=>we(null)}),M&&(0,K.jsx)(HVe,{plug:P,onClose:()=>{N(!1),F(null)}}),I&&(0,K.jsx)(GVe,{provider:R,onClose:()=>{L(!1),z(null)}}),B&&(0,K.jsx)(KVe,{template:B,onClose:()=>V(null)}),ie&&(0,K.jsx)(JVe,{onClose:()=>H(!1)}),De&&(0,K.jsx)(Ad,{title:i(`settings.clearNotificationLogs`),message:i(`settings.clearLogsMessage`),confirmText:i(`settings.clearLogs`),variant:`warning`,onConfirm:async()=>{Oe(!1);try{o((await Q.clearNotificationLogs(30)).message,`success`)}catch{o(i(`settings.toast.clearLogsFailed`),`error`)}},onCancel:()=>Oe(!1)}),ke&&(0,K.jsx)(Ad,{title:i(`settings.resetUiPreferences`),message:i(`settings.resetUiPreferencesMessage`),confirmText:i(`settings.resetPreferences`),variant:`default`,onConfirm:()=>{Ae(!1),localStorage.clear(),o(i(`settings.toast.uiPreferencesReset`),`success`),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>Ae(!1)}),je&&(0,K.jsx)(Ad,{title:`Turn All Plugs ${je===`on`?`On`:`Off`}`,message:`This will turn ${je===`on`?`ON`:`OFF`} all ${wt?.filter(e=>e.enabled).length||0} enabled smart plugs. ${je===`off`?`Any running printers may be affected!`:``}`,confirmText:`Turn All ${je===`on`?`On`:`Off`}`,variant:je===`off`?`danger`:`warning`,onConfirm:()=>{let e=je;Me(null),jn.mutate(e)},onCancel:()=>Me(null)}),Ne&&en?.release_notes&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>Pe(!1),children:(0,K.jsxs)(_d,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(vd,{className:`flex flex-row items-center justify-between shrink-0`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white`,children:[`Release Notes - v`,en.latest_version]}),en.release_name&&en.release_name!==en.latest_version&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:en.release_name})]}),(0,K.jsx)(`button`,{onClick:()=>Pe(!1),className:`p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(yd,{className:`overflow-y-auto flex-1`,children:(0,K.jsx)(`pre`,{className:`text-sm text-bambu-gray whitespace-pre-wrap font-sans`,children:en.release_notes})}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2`,children:[en.release_url&&(0,K.jsx)(`a`,{href:en.release_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex-1`,children:(0,K.jsxs)($,{variant:`secondary`,className:`w-full`,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),`View on GitHub`]})}),(0,K.jsx)($,{onClick:()=>Pe(!1),className:`flex-1`,children:`Close`})]})]})}),ce===`users`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex gap-1 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>de(`users`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`users`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ku,{className:`w-4 h-4`}),i(`settings.tabs.users`)]}),(0,K.jsxs)(`button`,{onClick:()=>de(`email`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`email`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),i(`settings.tabs.emailAuth`)||`Email Authentication`,ln?.advanced_auth_enabled&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>de(`ldap`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px lg:border-b-0 lg:border-l-2 lg:-ml-px lg:mb-0 lg:justify-start flex items-center gap-2 ${ue===`ldap`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.ldap`)||`LDAP`,un?.ldap_enabled&&(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-green-400`})]}),(0,K.jsxs)(`button`,{onClick:()=>de(`twofa`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`twofa`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.twoFa`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${dn?.totp_enabled||dn?.email_otp_enabled?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,K.jsxs)(`button`,{onClick:()=>de(`oidc`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`oidc`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(bc,{className:`w-4 h-4`}),i(`settings.tabs.oidc`),(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full ${fn.some(e=>e.is_enabled)?`bg-green-400`:`bg-bambu-gray/40`}`})]}),l&&(0,K.jsxs)(`button`,{onClick:()=>de(`security`),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ue===`security`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent`}`,children:[(0,K.jsx)(ql,{className:`w-4 h-4`}),i(`settings.tabs.security`)]})]}),ue===`users`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${s?`bg-green-500/20`:`bg-gray-500/20`}`,children:s?(0,K.jsx)(qc,{className:`w-5 h-5 text-green-400`}):(0,K.jsx)(Kc,{className:`w-5 h-5 text-gray-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.authentication`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(s?`settings.authEnabledDescription`:`settings.authDisabledDescription`)})]})]}),s?c?.is_admin&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Ie(!0),children:[(0,K.jsx)(Kc,{className:`w-4 h-4`}),i(`common.disable`)]}):(0,K.jsxs)($,{onClick:()=>t(`/setup`),children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),i(`common.enable`)]})]})})}),ln?.advanced_auth_enabled&&(0,K.jsx)(_d,{className:`border-blue-500/30 bg-blue-500/5`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0`,children:(0,K.jsx)(Xc,{className:`w-5 h-5 text-blue-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:i(`settings.email.advancedAuthEnabled`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:i(`settings.email.advancedAuthEnabledDesc`)})]})]})})}),s&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-2 gap-6`,children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(_d,{id:`card-session-policy`,children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(qc,{className:`w-5 h-5 text-bambu-green`}),i(`settings.sessionPolicy.title`)]})}),(0,K.jsxs)(yd,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:i(`settings.sessionPolicy.description`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 mb-4`,children:[[{hours:24,labelKey:`settings.sessionPolicy.preset24h`},{hours:168,labelKey:`settings.sessionPolicy.preset7d`},{hours:720,labelKey:`settings.sessionPolicy.preset30d`}].map(e=>{let t=(O?.session_max_hours??24)===e.hours;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>Rn(`session_max_hours`,e.hours),disabled:s&&!d(`settings:update`),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors ${t?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark`} disabled:opacity-50 disabled:cursor-not-allowed`,children:i(e.labelKey)},e.hours)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{type:`number`,min:1,max:720,value:O?.session_max_hours??24,onChange:e=>{let t=parseInt(e.target.value,10);Number.isNaN(t)||Rn(`session_max_hours`,Math.max(1,Math.min(720,t)))},disabled:s&&!d(`settings:update`),"aria-label":i(`settings.sessionPolicy.customHoursLabel`),className:`w-20 px-2 py-2 bg-bambu-dark-tertiary text-white text-sm rounded-lg border border-bambu-dark-tertiary focus:border-bambu-green focus:outline-none disabled:opacity-50`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:i(`settings.sessionPolicy.hoursSuffix`)})]})]}),(O?.session_max_hours??24)>24&&(0,K.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-xs text-yellow-200`,children:i(`settings.sessionPolicy.warning`)})]})]})]}),c&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-currentuser`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),i(`settings.currentUser`)]}),c.auth_source!==`ldap`&&(0,K.jsxs)($,{size:`sm`,variant:`ghost`,onClick:()=>Re(!0),children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.changePassword`)]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium text-lg`,children:c.username}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:[c.is_admin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300`,children:i(`settings.admin`)}),c.groups?.map(e=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-500/20 text-purple-300`:e.name===`Operators`?`bg-blue-500/20 text-blue-300`:e.name===`Viewers`?`bg-green-500/20 text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]})})})]}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-users`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),i(`settings.users`)]}),d(`users:create`)&&(0,K.jsxs)($,{size:`sm`,onClick:()=>{Ke(!0),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addUser`)]})]})}),(0,K.jsx)(yd,{children:mn?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):pn.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noUsersFound`)}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:pn.map(e=>(0,K.jsxs)(`div`,{className:`py-3 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:e.username}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[e.auth_source===`ldap`&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-cyan-500/20 text-cyan-300`,children:`LDAP`}),e.is_admin&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300`,children:i(`settings.admin`)}),e.groups?.map(e=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded-full text-xs font-medium ${e.name===`Administrators`?`bg-purple-500/20 text-purple-300`:e.name===`Operators`?`bg-blue-500/20 text-blue-300`:e.name===`Viewers`?`bg-green-500/20 text-green-300`:`bg-gray-500/20 text-gray-300`}`,children:e.name},e.id))]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 ml-4`,children:[d(`users:update`)&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>Tn(e),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),d(`users:delete`)&&e.id!==c?.id&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>xn(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},e.id))})})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`h3`,{className:`text-lg font-semibold text-white flex items-center gap-2`,id:`card-groups`,children:[(0,K.jsx)(ql,{className:`w-5 h-5 text-bambu-green`}),i(`settings.groups`)]}),d(`groups:create`)&&(0,K.jsxs)($,{size:`sm`,onClick:()=>t(`/groups/new`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.addGroup`)]})]})}),(0,K.jsx)(yd,{children:gn?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 text-bambu-green animate-spin`})}):hn.length===0?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-8`,children:i(`settings.noGroupsFound`)}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:hn.map(e=>(0,K.jsxs)(`div`,{className:`py-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ql,{className:`w-4 h-4 ${e.name===`Administrators`?`text-purple-400`:e.name===`Operators`?`text-blue-400`:e.name===`Viewers`?`text-green-400`:`text-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:e.name}),e.is_system&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400`,children:i(`settings.system`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[d(`groups:update`)&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>t(`/groups/${e.id}/edit`),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),d(`groups:delete`)&&!e.is_system&&(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:()=>ct(e.id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1 ml-6`,children:e.description||i(`settings.noDescription`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:i(`settings.userCount`,{count:e.user_count})}),(0,K.jsx)(`span`,{children:i(`settings.permissionCount`,{count:e.permissions.length})})]})]},e.id))})})]})})]}),!s&&(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`py-6`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Kc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:i(`settings.authDisabledTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4 max-w-md mx-auto`,children:i(`settings.authDisabledMessage`)}),(0,K.jsxs)(`ul`,{className:`space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto`,children:[(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature1`)})]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature2`)})]}),(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsx)(`span`,{children:i(`settings.authDisabledFeature3`)})]})]}),(0,K.jsxs)($,{onClick:()=>t(`/setup`),children:[(0,K.jsx)(qc,{className:`w-4 h-4`}),i(`settings.enableAuthentication`)]})]})})})]}),ue===`email`&&(0,K.jsx)(`div`,{className:`max-w-5xl`,id:`card-smtp`,children:(0,K.jsx)(zHe,{})}),ue===`ldap`&&(0,K.jsx)(`div`,{className:`max-w-5xl`,id:`card-ldap`,children:(0,K.jsx)(VHe,{})}),ue===`twofa`&&(0,K.jsx)(`div`,{className:`max-w-2xl`,children:(0,K.jsx)(UHe,{})}),ue===`oidc`&&l&&(0,K.jsx)(`div`,{className:`max-w-3xl`,children:(0,K.jsx)(KHe,{})}),ue===`security`&&l&&(0,K.jsx)(`div`,{className:`max-w-3xl`,children:(0,K.jsx)(JHe,{})})]}),Ge&&!ln?.advanced_auth_enabled&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(ku,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.createUser`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[un?.ldap_enabled&&(0,K.jsxs)(`div`,{className:`mb-4 flex items-center gap-1 p-1 bg-bambu-dark-secondary rounded-lg`,role:`tablist`,"aria-label":i(`users.modal.tabsAriaLabel`),children:[(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":qe===`local`,onClick:()=>Je(`local`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${qe===`local`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.localTab`)}),(0,K.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":qe===`ldap`,onClick:()=>Je(`ldap`),className:`flex-1 px-3 py-2 text-sm rounded-md transition-colors ${qe===`ldap`?`bg-bambu-green/15 text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:i(`users.modal.ldapTab`)})]}),qe===`ldap`&&un?.ldap_enabled?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(L3,{onSuccess:e=>{Ke(!1),Je(`local`),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),(0,K.jsx)(`div`,{className:`mt-6 flex justify-end`,children:(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Ke(!1),Je(`local`),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.username`)}),(0,K.jsx)(`input`,{type:`text`,value:at.username,onChange:e=>ot({...at,username:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterUsername`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.password`)}),(0,K.jsx)(`input`,{type:`password`,value:at.password,onChange:e=>ot({...at,password:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterPassword`),autoComplete:`new-password`,minLength:8}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,K.jsx)(`input`,{type:`password`,value:at.confirmPassword,onChange:e=>ot({...at,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmPasswordPlaceholder`),autoComplete:`new-password`,minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.groups`)}),(0,K.jsxs)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[hn.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:at.group_ids.includes(e.id),onChange:()=>En(e.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,K.jsx)(`span`,{className:`text-xs text-yellow-400`,children:i(`settings.systemBadge`)})]},e.id)),hn.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`settings.noGroupsAvailable`)})]})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:Cn,disabled:_n.isPending||!at.username||!at.password||at.password!==at.confirmPassword||p3(at.password)!==null,children:_n.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`settings.creating`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),i(`settings.createUser`)]})})]})]})]})]})}),Ge&&ln?.advanced_auth_enabled&&(0,K.jsx)(lHe,{formData:at,setFormData:ot,groups:hn,onClose:()=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},onCreate:Cn,isCreating:_n.isPending,isCreateButtonDisabled:_n.isPending||!at.username||!at.email,ldapEnabled:un?.ldap_enabled,onLdapProvisioned:e=>{Ke(!1),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]}),o(i(`users.toast.ldapProvisioned`,{username:e.username}))}}),Ye&&Ze!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black flex items-center justify-center z-50 p-4`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(_l,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.editUser`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`settings.username`),` `,ln?.advanced_auth_enabled&&(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`})]}),(0,K.jsx)(`input`,{type:`text`,value:at.username,onChange:e=>ot({...at,username:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterUsername`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.email`)||`Email`,` `,ln?.advanced_auth_enabled?(0,K.jsx)(`span`,{className:`text-red-400`,children:`*`}):(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.optional`)||`optional`,`)`]})]}),(0,K.jsx)(`input`,{type:`email`,value:at.email,onChange:e=>ot({...at,email:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`users.form.emailPlaceholder`)||`user@example.com`,required:ln?.advanced_auth_enabled})]}),!ln?.advanced_auth_enabled&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:[i(`users.form.password`)||`Password`,` `,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal`,children:[`(`,i(`users.form.leaveBlankToKeep`)||`leave blank to keep current`,`)`]})]}),(0,K.jsx)(`input`,{type:`password`,value:at.password,onChange:e=>ot({...at,password:e.target.value,confirmPassword:``}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterNewPassword`),autoComplete:`new-password`,minLength:8}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-xs mt-1`,children:i(`settings.passwordRequirements`)})]}),at.password&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`settings.confirmPassword`)}),(0,K.jsx)(`input`,{type:`password`,value:at.confirmPassword,onChange:e=>ot({...at,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),ln?.advanced_auth_enabled&&(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary/50 border border-bambu-green/20 rounded-lg p-3 space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`users.form.passwordManagedByAdvancedAuth`)||`Password is managed by Advanced Authentication. Use "Reset Password" to send a new password to the user via email.`}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>Ze&&bn.mutate(Ze),disabled:bn.isPending||!at.email,className:`w-full`,children:bn.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`users.form.resettingPassword`)||`Resetting Password...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),i(`users.form.resetPassword`)||`Reset Password`]})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:i(`users.form.groups`)||`Groups`}),(0,K.jsx)(`div`,{className:`space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:hn.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:at.group_ids.includes(e.id),onChange:()=>En(e.id),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.name}),e.is_system&&(0,K.jsxs)(`span`,{className:`text-xs text-yellow-400`,children:[`(`,i(`users.system`)||`System`,`)`]})]},e.id))})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Xe(!1),Qe(null),ot({username:``,password:``,email:``,confirmPassword:``,role:`user`,group_ids:[]})},children:i(`users.modal.cancel`)||`Cancel`}),(0,K.jsx)($,{onClick:()=>wn(Ze),disabled:vn.isPending||!at.username||ln?.advanced_auth_enabled&&!at.email||!!(!ln?.advanced_auth_enabled&&at.password&&(at.password!==at.confirmPassword||p3(at.password)!==null)),children:vn.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`users.modal.saving`)||`Saving...`]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),i(`users.modal.saveChanges`)||`Save Changes`]})})]})]})]})}),$e!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4`,onClick:()=>{et(null),nt(null)},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold`,children:i(`settings.deleteUserTitle`)})]})}),(0,K.jsx)(yd,{className:`space-y-3`,children:rt?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent`})}):tt&&tt.archives+tt.queue_items+tt.library_files>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.userHasCreated`)}),(0,K.jsxs)(`ul`,{className:`list-disc list-inside text-bambu-gray space-y-1`,children:[tt.archives>0&&(0,K.jsxs)(`li`,{children:[tt.archives,` archive`,tt.archives===1?``:`s`]}),tt.queue_items>0&&(0,K.jsxs)(`li`,{children:[tt.queue_items,` queue item`,tt.queue_items===1?``:`s`]}),tt.library_files>0&&(0,K.jsxs)(`li`,{children:[tt.library_files,` library file`,tt.library_files===1?``:`s`]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.userItemsQuestion`)}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)($,{variant:`danger`,onClick:()=>yn.mutate({id:$e,deleteItems:!0}),disabled:yn.isPending,className:`justify-center`,children:i(`settings.deleteUserAndItems`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>yn.mutate({id:$e,deleteItems:!1}),disabled:yn.isPending,className:`justify-center`,children:i(`settings.deleteUserKeepItems`)}),(0,K.jsx)($,{variant:`ghost`,onClick:()=>{et(null),nt(null)},disabled:yn.isPending,className:`justify-center`,children:i(`common.cancel`)})]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white`,children:i(`settings.deleteUserConfirm`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:i(`settings.actionCannotBeUndone`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,K.jsx)($,{variant:`ghost`,onClick:()=>{et(null),nt(null)},disabled:yn.isPending,children:i(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,onClick:()=>yn.mutate({id:$e,deleteItems:!1}),disabled:yn.isPending,children:i(`settings.deleteUserTitle`)})]})]})})]})}),st!==null&&(0,K.jsx)(Ad,{title:i(`settings.deleteGroupTitle`),message:i(`settings.deleteGroupMessage`),confirmText:i(`settings.deleteGroup`),variant:`danger`,onConfirm:()=>{Sn.mutate(st),ct(null)},onCancel:()=>ct(null)}),ce===`failure-detection`&&(0,K.jsx)(`div`,{id:`card-failure-detection`,children:(0,K.jsx)(IHe,{})}),ce===`backup`&&(0,K.jsxs)(`div`,{id:`card-backup`,children:[(0,K.jsxs)(`div`,{className:`mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg flex items-start gap-2`,children:[(0,K.jsx)(ql,{className:`text-amber-400 flex-shrink-0 mt-0.5`,size:16}),(0,K.jsx)(`p`,{className:`text-sm text-amber-400`,children:i(`backup.includesEncryptionKey`)})]}),(0,K.jsx)(FHe,{})]}),Fe&&(0,K.jsx)(Ad,{title:i(`settings.disableAuthenticationTitle`),message:i(`settings.disableAuthenticationMessage`),confirmText:i(`settings.disableAuthentication`),variant:`danger`,onConfirm:async()=>{try{await Q.disableAuth(),o(i(`settings.toast.authDisabled`),`success`),await u(),Ie(!1),window.location.href=`/`}catch(e){o(e instanceof Error?e.message:i(`settings.toast.authDisableFailed`),`error`)}},onCancel:()=>Ie(!1)}),Le&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ic,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`settings.changePassword`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Current Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.currentPassword,onChange:e=>Be({...ze,currentPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterCurrentPassword`),autoComplete:`current-password`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`New Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.newPassword,onChange:e=>Be({...ze,newPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:i(`settings.enterNewPasswordMin6`),autoComplete:`new-password`,minLength:6})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:`Confirm New Password`}),(0,K.jsx)(`input`,{type:`password`,value:ze.confirmPassword,onChange:e=>Be({...ze,confirmPassword:e.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${ze.confirmPassword&&ze.newPassword!==ze.confirmPassword?`border-red-500`:`border-bambu-dark-tertiary`}`,placeholder:i(`settings.confirmNewPassword`),autoComplete:`new-password`,minLength:6}),ze.confirmPassword&&ze.newPassword!==ze.confirmPassword&&(0,K.jsx)(`p`,{className:`text-red-400 text-xs mt-1`,children:i(`settings.passwordsDoNotMatch`)})]})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})},children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:async()=>{if(ze.newPassword!==ze.confirmPassword){o(i(`settings.toast.passwordsDoNotMatch`),`error`);return}if(ze.newPassword.length<6){o(i(`settings.toast.passwordTooShort`),`error`);return}He(!0);try{await Q.changePassword(ze.currentPassword,ze.newPassword),o(i(`settings.toast.passwordChanged`),`success`),Re(!1),Be({currentPassword:``,newPassword:``,confirmPassword:``})}catch(e){o(e instanceof Error?e.message:`Failed to change password`,`error`)}finally{He(!1)}},disabled:Ve||!ze.currentPassword||!ze.newPassword||ze.newPassword!==ze.confirmPassword||ze.newPassword.length<6,children:Ve?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i(`settings.changing`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),i(`settings.changePassword`)]})})]})]})]})})]})]})]})})}var c6=e=>(Math.trunc(parseFloat(e)*1e3)/1e3).toFixed(3),nUe=e=>e.startsWith(`HH`)?`HF`:`S`,rUe=e=>{let t=e.match(/^([A-Z]{2}\d{2})/);return t?t[1]:`HH00`},l6=e=>{for(let t of[`High Flow_`,`High Flow `,`Standard_`,`Standard `,`HF_`,`HF `,`S_`,`S `])if(e.startsWith(t))return e.slice(t.length);let t=e.indexOf(`_`);return t>0?e.slice(t+1):e};function u6({profile:e,onEdit:t,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){let s=nUe(e.nozzle_id),c=e.nozzle_diameter;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r&&(0,K.jsx)(`button`,{onClick:a,className:`text-bambu-gray hover:text-white transition-colors p-1`,children:i?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green`}):(0,K.jsx)(ou,{className:`w-4 h-4`})}),(0,K.jsxs)(`button`,{onClick:()=>{r&&a?a():t()},className:`flex-1 text-left px-3 py-2 bg-bambu-dark rounded hover:bg-bambu-dark-tertiary transition-colors ${i?`ring-1 ring-bambu-green`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-green font-mono text-sm font-bold whitespace-nowrap`,children:c6(e.k_value)}),(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name||`Unnamed`}),o&&(0,K.jsx)(`span`,{title:`Has note`,children:(0,K.jsx)(lu,{className:`w-3 h-3 text-yellow-500`})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:[s,` `,c]})]}),o&&(0,K.jsxs)(`div`,{className:`text-xs mt-0.5 truncate text-yellow-500/70`,title:o,children:[`Note: `,o.length>50?o.substring(0,50)+`...`:o]})]}),!r&&n&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`text-bambu-gray hover:text-white transition-colors p-1`,title:`Copy profile`,children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})}function d6({profile:e,printerId:t,nozzleDiameter:n,existingProfiles:r=[],builtinFilaments:i=[],isDualNozzle:a=!1,initialNote:o=``,initialNoteKey:s=null,onClose:c,onSave:l,onSaveNote:u,hasPermission:d}){let{t:f}=W(),{showToast:p}=Td(),[m,h]=(0,y.useState)(e?.name||``),[g,_]=(0,y.useState)(e?.k_value?c6(e.k_value):`0.020`),[v,b]=(0,y.useState)(e?.filament_id||``),[x,S]=(0,y.useState)(e?.nozzle_id?rUe(e.nozzle_id):`HH00`),[C,w]=(0,y.useState)(e?.nozzle_diameter||n),[T,E]=(0,y.useState)(e?[e.extruder_id]:a?[0,1]:[0]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)({current:0,total:0}),[j,M]=(0,y.useState)(o),N=y.useMemo(()=>{let e=new Map;for(let t of i)e.set(t.filament_id,t.name);let t=new Map;for(let n of r)if(n.filament_id&&!t.has(n.filament_id)){let r=e.get(n.filament_id)||l6(n.name||``);t.set(n.filament_id,{id:n.filament_id,name:r||n.filament_id})}return Array.from(t.values()).sort((e,t)=>e.name.localeCompare(t.name))},[r,i]),P=J({mutationFn:e=>(console.log(`[KProfile] Calling API...`),Q.setKProfile(t,e)),onSuccess:t=>{if(console.log(`[KProfile] Save success:`,t),p(f(`kProfiles.toast.profileSaved`)),u&&j!==o){let t;t=j===``&&s?s:e&&e.slot_id>0?e.setting_id||`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`:`name_${m}_${v}`,u(t,j)}O(!0),setTimeout(()=>{O(!1),l()},2500)},onError:e=>{console.error(`[KProfile] Save error:`,e),p(e.message,`error`),O(!1)}}),F=J({mutationFn:e=>(console.log(`[KProfile] Deleting profile...`),Q.deleteKProfile(t,e)),onSuccess:e=>{console.log(`[KProfile] Delete success:`,e),p(f(`kProfiles.toast.profileDeleted`)),O(!0),setTimeout(()=>{O(!1),c()},4e3)},onError:e=>{console.error(`[KProfile] Delete error:`,e),p(e.message,`error`),O(!1)}}),[I,L]=(0,y.useState)(!1),R=()=>{e&&F.mutate({slot_id:e.slot_id,extruder_id:e.extruder_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,filament_id:e.filament_id,setting_id:e.setting_id})};return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:[(0,K.jsxs)(_d,{className:`w-full max-w-md relative`,children:[D&&(0,K.jsxs)(`div`,{className:`absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg`,children:[(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:k.total>1?f(`kProfiles.modal.savingExtruder`,{current:k.current,total:k.total}):f(`kProfiles.modal.syncing`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-1`,children:f(`kProfiles.modal.pleaseWait`)})]}),(0,K.jsxs)(yd,{className:`p-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:f(e?`kProfiles.modal.editTitle`:`kProfiles.modal.addTitle`)}),(0,K.jsx)(`button`,{onClick:c,className:`text-bambu-gray hover:text-white transition-colors`,disabled:D,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),a&&!e&&T.length===0){p(f(`kProfiles.toast.selectAtLeastOneExtruder`),`error`);return}let r=parseFloat(g).toFixed(6),i=`${x}-${C}`;if(e||T.length===1){let t={name:m,k_value:r,filament_id:v,nozzle_id:i,nozzle_diameter:C,extruder_id:e?e.extruder_id:T[0],setting_id:e?.setting_id,slot_id:e?.slot_id??0};console.log(`[KProfile] Saving profile:`,t),P.mutate(t);return}O(!0),A({current:1,total:T.length});let o=T.map(e=>({name:m,k_value:r,filament_id:v,nozzle_id:i,nozzle_diameter:C,extruder_id:e,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${o.length} profiles in batch:`,o);try{await Q.setKProfilesBatch(t,o),p(f(`kProfiles.toast.profilesSaved`,{count:T.length})),u&&j&&u(`name_${m}_${v}`,j)}catch(e){console.error(`[KProfile] Failed to save batch:`,e),p(f(`kProfiles.toast.failedToSaveBatch`),`error`),O(!1),A({current:0,total:0});return}A({current:T.length,total:T.length}),setTimeout(()=>{O(!1),A({current:0,total:0}),l()},3e3)},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.profileName`)}),(0,K.jsx)(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,placeholder:f(`kProfiles.modal.profileNamePlaceholder`),required:!e})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.kValue`)}),(0,K.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:g,onChange:e=>{let t=e.target.value;(t===``||/^\d*\.?\d*$/.test(t))&&_(t)},onBlur:e=>{let t=parseFloat(e.target.value);isNaN(t)||_((Math.trunc(t*1e3)/1e3).toFixed(3))},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none font-mono`,placeholder:f(`kProfiles.modal.kValuePlaceholder`),required:!0}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.kValueHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.filament`)}),(0,K.jsxs)(`select`,{value:v,onChange:t=>{let n=t.target.value;if(b(n),!e&&n&&!m){let e=N.find(e=>e.id===n);e&&h(`${x===`HH00`?`HF`:`S`} ${e.name}`)}},disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,required:!e,children:[(0,K.jsx)(`option`,{value:``,children:f(`kProfiles.modal.selectFilament`)}),e?.filament_id&&(0,K.jsx)(`option`,{value:e.filament_id,children:N.find(t=>t.id===e.filament_id)?.name||e.filament_id},e.filament_id),!e&&N.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),!e&&N.length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.noFilamentsHelp`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.flowType`)}),(0,K.jsxs)(`select`,{value:x,onChange:t=>{let n=t.target.value;if(S(n),!e&&v&&!m){let e=N.find(e=>e.id===v);e&&h(`${n===`HS00`?`HF`:`S`} ${e.name}`)}},disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,children:[(0,K.jsx)(`option`,{value:`HH00`,children:f(`kProfiles.modal.highFlow`)}),(0,K.jsx)(`option`,{value:`HS00`,children:f(`kProfiles.modal.standard`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.nozzleSize`)}),(0,K.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),disabled:!!e,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none ${e?`opacity-60 cursor-not-allowed`:``}`,children:[(0,K.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,K.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,K.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,K.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]})]}),a&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(e?`kProfiles.modal.extruder`:`kProfiles.modal.extruders`)}),e?(0,K.jsx)(`div`,{className:`px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white opacity-60`,children:e.extruder_id===1?f(`kProfiles.modal.left`):f(`kProfiles.modal.right`)}):(0,K.jsxs)(`div`,{className:`flex gap-4`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:T.includes(1),onChange:e=>{e.target.checked?E([...T,1]):E(T.filter(e=>e!==1))},className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:f(`kProfiles.modal.left`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:T.includes(0),onChange:e=>{e.target.checked?E([...T,0]):E(T.filter(e=>e!==0))},className:`w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green focus:ring-offset-0 accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:f(`kProfiles.modal.right`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(`kProfiles.modal.notes`)}),(0,K.jsx)(`textarea`,{value:j,onChange:e=>M(e.target.value),placeholder:f(`kProfiles.modal.notesPlaceholder`),rows:2,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none resize-none`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:f(`kProfiles.modal.notesHelp`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 pt-4`,children:[e&&(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>L(!0),disabled:F.isPending||D||!d(`kprofiles:delete`),title:d(`kprofiles:delete`)?void 0:f(`kProfiles.permission.noDelete`),className:`text-red-500 hover:bg-red-500/10`,children:F.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`})}),(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:c,disabled:D,className:`flex-1`,children:f(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:P.isPending||D||!d(e?`kprofiles:update`:`kprofiles:create`),title:d(e?`kprofiles:update`:`kprofiles:create`)?void 0:f(e?`kProfiles.permission.noUpdate`:`kProfiles.permission.noCreate`),className:`flex-1`,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(hc,{className:`w-4 h-4`}),f(`common.save`)]})]})]})]})]}),I&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-[60]`,children:(0,K.jsx)(_d,{className:`w-full max-w-sm`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(bu,{className:`w-5 h-5 text-red-500`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:f(`kProfiles.deleteConfirm.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:f(`kProfiles.deleteConfirm.cannotUndo`)})]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:f(`kProfiles.deleteConfirm.message`,{name:e?.name})}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>L(!1),className:`flex-1`,children:f(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>{L(!1),R()},disabled:F.isPending,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[F.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),f(`common.delete`)]})]})]})})})]})}var f6={NOZZLE_DIAMETER:`bambusy_kprofiles_nozzle`,SORT_OPTION:`bambusy_kprofiles_sort`};function iUe(){let{t:e}=W(),{showToast:t}=Td(),{hasPermission:n}=dd(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(()=>localStorage.getItem(f6.NOZZLE_DIAMETER)||`0.4`),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(`all`),[b,x]=(0,y.useState)(()=>localStorage.getItem(f6.SORT_OPTION)||`name`),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(new Set),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),A=(0,y.useCallback)(e=>`${e.slot_id}_${e.extruder_id}`,[]);(0,y.useEffect)(()=>{localStorage.setItem(f6.NOZZLE_DIAMETER,a)},[a]),(0,y.useEffect)(()=>{localStorage.setItem(f6.SORT_OPTION,b)},[b]);let{data:j,isLoading:M}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:N,isLoading:P,isFetching:F,error:I,refetch:L}=q({queryKey:[`kprofiles`,r,a],queryFn:async()=>{console.log(`[KProfiles] Fetching profiles for printer`,r,`nozzle`,a);let e=await Q.getKProfiles(r,a);return console.log(`[KProfiles] Received profiles:`,e?.profiles?.length||0,`profiles`),e},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:`always`}),{data:R}=q({queryKey:[`kprofiles`,r,`0.4`],queryFn:()=>Q.getKProfiles(r,`0.4`),enabled:!!r,staleTime:6e4}),{data:z}=q({queryKey:[`builtinFilaments`],queryFn:()=>Q.getBuiltinFilaments(),staleTime:3e5}),{data:B}=q({queryKey:[`filamentIdMap`],queryFn:()=>Q.getFilamentIdMap(),staleTime:3e5}),{data:V,refetch:ee}=q({queryKey:[`kprofile-notes`,r],queryFn:()=>Q.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),te=I?.message?.includes(`not connected`);(0,y.useEffect)(()=>{if(!r&&j&&j.length>0){let e=j.find(e=>e.is_active);e&&i(e.id)}},[r,j]),(0,y.useEffect)(()=>{if(r){let e=setTimeout(()=>{L()},150);return()=>clearTimeout(e)}},[r,a]);let ne=j?.filter(e=>e.is_active)||[],re=y.useMemo(()=>{let e=new Map;if(z)for(let t of z)e.set(t.filament_id,t.name);if(B)for(let[t,n]of Object.entries(B))e.has(t)||e.set(t,n);return e},[z,B]),ie=y.useMemo(()=>Array.from(re.entries()).map(([e,t])=>({filament_id:e,name:t})),[re]),H=y.useCallback(e=>re.get(e.filament_id)||l6(e.name),[re]),ae=y.useMemo(()=>N?.profiles?N.profiles.filter(e=>{let t=p.toLowerCase(),n=!t||e.name.toLowerCase().includes(t)||e.filament_id.toLowerCase().includes(t),r=h===`all`||h===`left`&&e.extruder_id===1||h===`right`&&e.extruder_id===0,i=_===`all`||_===`hf`&&e.nozzle_id.startsWith(`HH`)||_===`s`&&e.nozzle_id.startsWith(`HS`);return n&&r&&i}).sort((e,t)=>{switch(b){case`k_value`:return parseFloat(e.k_value)-parseFloat(t.k_value);case`filament`:return H(e).localeCompare(H(t));default:return e.name.localeCompare(t.name)}}):[],[N?.profiles,p,h,_,b,H]),oe=j?.find(e=>e.id===r),U=oe?.nozzle_count===2;(0,y.useEffect)(()=>{let e=e=>{e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLSelectElement||s||l||d||(e.key===`r`||e.key===`R`?(e.preventDefault(),L()):e.key===`n`||e.key===`N`?(e.preventDefault(),u(!0)):e.key===`Escape`&&S&&(e.preventDefault(),C(!1),T(new Set)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,l,d,S,L]);let se=(0,y.useCallback)(()=>{if(!N?.profiles||N.profiles.length===0){t(e(`kProfiles.toast.noProfilesToExport`),`error`);return}let n={version:1,exported_at:new Date().toISOString(),printer:oe?.name||`Unknown`,nozzle_diameter:a,profiles:N.profiles.map(e=>({name:e.name,k_value:e.k_value,filament_id:e.filament_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,extruder_id:e.extruder_id}))},r=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),i=URL.createObjectURL(r),o=document.createElement(`a`);o.href=i,o.download=`kprofiles_${oe?.name||`printer`}_${a}mm_${new Date().toISOString().split(`T`)[0]}.json`,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(i),t(e(`kProfiles.toast.exportedProfiles`,{count:N.profiles.length}))},[N?.profiles,oe,a,t,e]),ce=(0,y.useCallback)(()=>{let n=document.createElement(`input`);n.type=`file`,n.accept=`.json`,n.onchange=async n=>{let i=n.target.files?.[0];if(i)try{let n=await i.text(),o=JSON.parse(n);if(!o.profiles||!Array.isArray(o.profiles)){t(e(`kProfiles.toast.invalidFileFormat`),`error`);return}let s=0;for(let e of o.profiles)if(!(!e.name||!e.k_value||!e.filament_id))try{await Q.setKProfile(r,{name:e.name,k_value:parseFloat(e.k_value).toFixed(6),filament_id:e.filament_id,nozzle_id:e.nozzle_id||`HH00-${a}`,nozzle_diameter:e.nozzle_diameter||a,extruder_id:e.extruder_id??0,slot_id:0}),s++,await new Promise(e=>setTimeout(e,500))}catch(t){console.error(`Failed to import profile:`,e.name,t)}t(e(`kProfiles.toast.importedProfiles`,{count:s,total:o.profiles.length})),L()}catch(n){console.error(`Import error:`,n),t(e(`kProfiles.toast.failedToParseImport`),`error`)}},n.click()},[r,a,t,L,e]),le=(0,y.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ue=(0,y.useCallback)(()=>{T(new Set(ae.map(e=>A(e))))},[ae,A]),de=(0,y.useCallback)(()=>{w.size!==0&&D(!0)},[w.size]),fe=(0,y.useCallback)(async()=>{let n=ae.filter(e=>w.has(A(e)));k(!0);let i=0;for(let e of n)try{await Q.deleteKProfile(r,{slot_id:e.slot_id,extruder_id:e.extruder_id,nozzle_id:e.nozzle_id,nozzle_diameter:e.nozzle_diameter,filament_id:e.filament_id,setting_id:e.setting_id}),i++,await new Promise(e=>setTimeout(e,300))}catch(t){console.error(`Failed to delete profile:`,e.name,t)}t(e(`kProfiles.toast.profilesDeleted`,{count:i})),k(!1),D(!1),C(!1),T(new Set),L()},[r,w,ae,t,L,A,e]),pe=(0,y.useCallback)(e=>{let t=[];return e.setting_id&&t.push(e.setting_id),t.push(`slot_${e.slot_id}_${e.filament_id}_${e.extruder_id}`),t.push(`name_${e.name}_${e.filament_id}`),t},[]),me=(0,y.useCallback)(async(n,i)=>{if(r)try{await Q.setKProfileNote(r,n,i),ee()}catch(n){console.error(`Failed to save note:`,n),t(e(`kProfiles.toast.failedToSaveNote`),`error`)}},[r,ee,t,e]),he=(0,y.useCallback)(e=>{if(!V?.notes)return{note:``,key:null};let t=pe(e);for(let e of t)if(V.notes[e])return{note:V.notes[e],key:e};return{note:``,key:null}},[V,pe]),ge=(0,y.useCallback)(e=>he(e).note,[he]);return M?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):!j||j.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(ds,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noPrintersConfigured`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.addPrinterInSettings`)})]})}):ne.length===0?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Tl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noActivePrinters`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.enablePrinterConnection`)})]})}):(0,K.jsxs)(K.Fragment,{children:[F&&!P&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40`,children:[(0,K.jsx)(X,{className:`w-10 h-10 text-bambu-green animate-spin mb-3`}),(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`kProfiles.loadingProfiles`)})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-48`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.printer`)}),(0,K.jsx)(`select`,{value:r||``,onChange:e=>i(parseInt(e.target.value)),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:ne.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,K.jsxs)(`div`,{className:`w-32`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:e(`kProfiles.nozzle`)}),(0,K.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`0.2`,children:`0.2mm`}),(0,K.jsx)(`option`,{value:`0.4`,children:`0.4mm`}),(0,K.jsx)(`option`,{value:`0.6`,children:`0.6mm`}),(0,K.jsx)(`option`,{value:`0.8`,children:`0.8mm`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>L(),disabled:F||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noRead`),children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${F?`animate-spin`:``}`}),e(`kProfiles.refresh`)]}),(0,K.jsxs)($,{onClick:()=>u(!0),disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noCreate`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`kProfiles.addProfile`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-4 mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-48 relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:e(`kProfiles.searchPlaceholder`),className:`w-full pl-10 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`})]}),U&&(0,K.jsx)(`div`,{className:`w-36`,children:(0,K.jsxs)(`select`,{value:h,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`kProfiles.allExtruders`)}),(0,K.jsx)(`option`,{value:`left`,children:e(`kProfiles.leftOnly`)}),(0,K.jsx)(`option`,{value:`right`,children:e(`kProfiles.rightOnly`)})]})}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`kProfiles.allFlow`)}),(0,K.jsx)(`option`,{value:`hf`,children:e(`kProfiles.hfOnly`)}),(0,K.jsx)(`option`,{value:`s`,children:e(`kProfiles.sOnly`)})]})}),(0,K.jsx)(`div`,{className:`w-32`,children:(0,K.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`name`,children:e(`kProfiles.sortName`)}),(0,K.jsx)(`option`,{value:`k_value`,children:e(`kProfiles.sortKValue`)}),(0,K.jsx)(`option`,{value:`filament`,children:e(`kProfiles.sortFilament`)})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:se,disabled:!N?.profiles?.length||!n(`kprofiles:read`),title:n(`kprofiles:read`)?void 0:e(`kProfiles.permission.noExport`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),e(`kProfiles.export`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:ce,disabled:!n(`kprofiles:create`),title:n(`kprofiles:create`)?void 0:e(`kProfiles.permission.noImport`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),e(`kProfiles.import`)]}),(0,K.jsx)(`div`,{className:`flex-1`}),S?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,onClick:ue,children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),e(`kProfiles.selectAll`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:de,disabled:w.size===0||!n(`kprofiles:delete`),className:`text-red-500 hover:bg-red-500/10`,title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`kProfiles.delete`),` (`,w.size,`)`]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>{C(!1),T(new Set)},children:[(0,K.jsx)(Ru,{className:`w-4 h-4`}),e(`common.cancel`)]})]}):(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!0),disabled:!ae.length||!n(`kprofiles:delete`),title:n(`kprofiles:delete`)?void 0:e(`kProfiles.permission.noDelete`),children:[(0,K.jsx)(iu,{className:`w-4 h-4`}),e(`kProfiles.select`)]})]}),P?(0,K.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):te?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Pu,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.printerOffline`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.printerOfflineDesc`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>L(),children:[(0,K.jsx)(Ol,{className:`w-4 h-4`}),e(`common.refresh`)]})]})}):ae.length>0?U?(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.leftExtruder`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.filter(e=>e.extruder_id===1).map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray mb-2 px-1`,children:e(`kProfiles.rightExtruder`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.filter(e=>e.extruder_id===0).map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))})]})]}):(0,K.jsx)(`div`,{className:`space-y-1`,children:ae.map(e=>(0,K.jsx)(u6,{profile:e,onEdit:()=>c(e),onCopy:()=>f(e),selectionMode:S,isSelected:w.has(A(e)),onToggleSelect:()=>le(A(e)),note:ge(e)},A(e)))}):p||h!==`all`||_!==`all`?(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noMatchingProfiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`kProfiles.noMatchingProfilesDesc`)})]})}):(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-12 text-center`,children:[(0,K.jsx)(hc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-4`}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:e(`kProfiles.noKProfiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`kProfiles.noKProfilesDesc`,{diameter:a})}),(0,K.jsxs)($,{onClick:()=>u(!0),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),e(`kProfiles.createFirstProfile`)]})]})}),s&&r&&(()=>{let{note:e,key:t}=he(s);return(0,K.jsx)(d6,{profile:s,printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,initialNote:e,initialNoteKey:t,onSaveNote:me,hasPermission:n,onClose:()=>{console.log(`[KProfiles] Edit modal onClose - refetching profiles...`),c(null),L()},onSave:()=>{c(null),L()}})})(),l&&r&&(0,K.jsx)(d6,{printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,onSaveNote:me,hasPermission:n,onClose:()=>{u(!1),L()},onSave:()=>{u(!1),L()}}),d&&r&&(0,K.jsx)(d6,{printerId:r,nozzleDiameter:a,existingProfiles:R?.profiles||N?.profiles,builtinFilaments:ie,isDualNozzle:U,onSaveNote:me,hasPermission:n,profile:{...d,slot_id:0,name:`${d.name} (Copy)`},onClose:()=>{f(null),L()},onSave:()=>{f(null),L()}}),E&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-sm`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(bu,{className:`w-5 h-5 text-red-500`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:e(`kProfiles.bulkDelete.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`kProfiles.bulkDelete.cannotUndo`)})]})]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6`,children:e(`kProfiles.bulkDelete.message`,{count:w.size})}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>D(!1),disabled:O,className:`flex-1`,children:e(`common.cancel`)}),(0,K.jsxs)($,{onClick:fe,disabled:O,className:`flex-1 bg-red-500 hover:bg-red-600 text-white`,children:[O?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`common.delete`)]})]})]})})})]})}var p6=[`PLA`,`PETG`,`PCTG`,`ABS`,`ASA`,`TPU`,`PC`,`PA`,`PVA`,`HIPS`,`PP`,`PET`,`NYLON`],aUe={PLA:`E8E8E8`,PETG:`4A90D9`,ABS:`E67E22`,ASA:`D35400`,TPU:`9B59B6`,PC:`BDC3C7`,PA:`2ECC71`,NYLON:`2ECC71`,PVA:`F1C40F`,HIPS:`95A5A6`,PP:`ECF0F1`,PET:`3498DB`};function oUe(e){let t=e.toUpperCase();for(let e of p6)if(RegExp(`\\b${e}\\b`).test(t))return e;return null}function sUe(e){let t=e.replace(/@.+$/,``).trim(),n=t.toUpperCase();for(let e of p6){let r=n.indexOf(e);if(r>0){let e=t.slice(0,r).trim();if(e&&e.length>1)return e}}return null}function m6({preset:e,onDelete:t,onExpand:n,isExpanded:r}){let{t:i}=W(),{hasPermission:a}=dd(),o=e.filament_type||oUe(e.name),s=e.filament_vendor||sUe(e.name),c=null,l=!1;if(e.default_filament_colour)try{let t=JSON.parse(e.default_filament_colour),n=Array.isArray(t)?t[0]:t;typeof n==`string`&&/^#?[0-9a-fA-F]{6,8}$/.test(n.replace(`#`,``))&&(c=n.replace(`#`,``).slice(0,6),l=!0)}catch{let t=e.default_filament_colour;/^#?[0-9a-fA-F]{6,8}$/.test(t.replace(`#`,``))&&(c=t.replace(`#`,``).slice(0,6),l=!0)}return!c&&o&&(c=aUe[o.toUpperCase()]||null),(0,K.jsx)(_d,{className:`bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-dark-tertiary/80 transition-colors`,children:(0,K.jsxs)(yd,{className:`p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[e.preset_type===`filament`&&(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full border border-black/20 flex-shrink-0 ${!l&&!c?`opacity-25`:l?``:`opacity-50`}`,style:{backgroundColor:c?`#${c}`:`#666`}}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-bambu-green/20 text-bambu-green`,children:o}),s&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s}),(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400`,children:i(`profiles.localProfiles.badge`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:[a(`settings:update`)&&(0,K.jsx)(`button`,{onClick:()=>t(e.id),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,title:i(`profiles.localProfiles.delete`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>n(r?null:e.id),className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:r?(0,K.jsx)(cs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(is,{className:`w-3.5 h-3.5`})})]})]}),r&&(0,K.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary text-xs space-y-1.5`,children:[o&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.filamentType`)}),(0,K.jsx)(`span`,{className:`text-white`,children:o})]}),s&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.vendor`)}),(0,K.jsx)(`span`,{className:`text-white`,children:s})]}),e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.nozzleTemp`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[e.nozzle_temp_min,`–`,e.nozzle_temp_max,`°C`]})]}),e.filament_cost&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.cost`)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.filament_cost})]}),e.filament_density&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.density`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[e.filament_density,` g/cm³`]})]}),e.pressure_advance&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.pressureAdvance`)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.pressure_advance})]}),e.compatible_printers&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.compatiblePrinters`)}),(0,K.jsx)(`span`,{className:`text-white truncate ml-2`,children:(()=>{try{return JSON.parse(e.compatible_printers).join(`, `)}catch{return e.compatible_printers}})()})]}),e.inherits&&e.inherits!==e.name&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.inheritsFrom`)}),(0,K.jsx)(`span`,{className:`text-white truncate ml-2`,children:e.inherits})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:i(`profiles.localProfiles.source`)}),(0,K.jsx)(`span`,{className:`text-white capitalize`,children:e.source})]})]})]})})}function cUe(){let{t:e}=W(),{hasPermission:t}=dd(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null),{data:f,isLoading:p}=q({queryKey:[`localPresets`],queryFn:()=>Q.getLocalPresets()}),m=J({mutationFn:async e=>{let t=[];for(let n of Array.from(e)){let e=new FormData;e.append(`file`,n),t.push(await Q.importLocalPresets(e))}return t},onSuccess:t=>{n.invalidateQueries({queryKey:[`localPresets`]}),n.invalidateQueries({queryKey:[`slicerPresets`]});let i=0,a=0,o=0;for(let e of t)i+=e.imported,a+=e.skipped,o+=e.errors.length;i>0&&r(e(`profiles.localProfiles.toast.importSuccess`,{count:i})),a>0&&r(e(`profiles.localProfiles.toast.importSkipped`,{count:a}),`warning`),o>0&&r(e(`profiles.localProfiles.toast.importError`,{count:o}),`error`)},onError:e=>{r(e.message,`error`)}}),h=J({mutationFn:e=>Q.deleteLocalPreset(e),onSuccess:(t,i)=>{n.setQueryData([`localPresets`],e=>e&&{filament:e.filament.filter(e=>e.id!==i),printer:e.printer.filter(e=>e.id!==i),process:e.process.filter(e=>e.id!==i)}),n.invalidateQueries({queryKey:[`localPresets`]}),n.invalidateQueries({queryKey:[`slicerPresets`]}),d(null),r(e(`profiles.localProfiles.toast.deleted`))}}),g=(0,y.useCallback)(e=>{!e||e.length===0||m.mutate(e)},[m]),_=(0,y.useCallback)(e=>{e.preventDefault(),l(!1),g(e.dataTransfer.files)},[g]),v=(0,y.useCallback)(e=>{if(!i)return e;let t=i.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.filament_type?.toLowerCase().includes(t)||e.filament_vendor?.toLowerCase().includes(t))},[i]),b=(0,y.useMemo)(()=>v(f?.filament||[]),[f?.filament,v]),x=(0,y.useMemo)(()=>v(f?.printer||[]),[f?.printer,v]),S=(0,y.useMemo)(()=>v(f?.process||[]),[f?.process,v]),C=b.length+x.length+S.length,w=(f?.filament?.length??0)+(f?.printer?.length??0)+(f?.process?.length??0)>0;return p?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`space-y-6`,children:[t(`settings:update`)&&(0,K.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:_,className:`relative border-2 border-dashed rounded-lg p-6 text-center transition-colors ${c?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`input`,{type:`file`,accept:`.json,.zip,.orca_filament,.bbscfg,.bbsflmt`,multiple:!0,className:`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,onChange:e=>g(e.target.files)}),m.isPending?(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(X,{className:`w-5 h-5 text-bambu-green animate-spin`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.importing`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Du,{className:`w-8 h-8 text-bambu-gray mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:e(`profiles.localProfiles.import`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e(`profiles.localProfiles.importDesc`)})]})]}),w&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:e(`profiles.localProfiles.search`),className:`w-full pl-9 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})]}),!w&&!p&&(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(wc,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noPresets`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/60 mt-1`,children:e(`profiles.localProfiles.importDesc`)})]}),w&&C===0&&!p&&(0,K.jsxs)(`div`,{className:`text-center py-12`,children:[(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`profiles.localProfiles.noSearchResults`)})]}),C>0&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:[b.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Hs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.filament`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,b.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:b.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),S.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.process`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,S.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:S.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]}),x.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4 text-orange-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:e(`profiles.localProfiles.printer`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,x.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>(0,K.jsx)(m6,{preset:e,onDelete:e=>d(e),onExpand:s,isExpanded:o===e.id},e.id))})]})]}),u!==null&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-6 max-w-sm mx-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-red-400`}),(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:e(`profiles.localProfiles.deleteConfirmTitle`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`profiles.localProfiles.deleteConfirm`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>d(null),children:e(`profiles.localProfiles.cancel`)}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>h.mutate(u),disabled:h.isPending,children:[h.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),e(`profiles.localProfiles.delete`)]})]})]})})]})}function lUe(e){let t=e.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),n=e.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),r=e.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),i=e.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i);return{printer:t?t[1].trim():null,nozzle:n?(n[1]||n[2])+`mm`:null,layerHeight:r?r[1]+`mm`:null,filamentType:i?i[1].toUpperCase():null}}function uUe({settings:e,lastSyncTime:t,onRefresh:n,isRefreshing:r,printers:i,t:a}){let[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(`all`),[u,d]=(0,y.useState)(`all`),[f,p]=(0,y.useState)(`all`),[m,h]=(0,y.useState)(`all`),[g,_]=(0,y.useState)(`all`),[v,b]=(0,y.useState)(null),x=(0,y.useMemo)(()=>[...e.filament.map(e=>({...e,type:`filament`})),...e.printer.map(e=>({...e,type:`printer`})),...e.process.map(e=>({...e,type:`process`}))].map(e=>({...e,meta:lUe(e.name)})),[e]),S=(0,y.useMemo)(()=>{let e=new Set,t=new Set,n=new Set;return x.forEach(r=>{r.meta.nozzle&&e.add(r.meta.nozzle),r.meta.filamentType&&t.add(r.meta.filamentType),r.meta.layerHeight&&n.add(r.meta.layerHeight)}),{printers:i.map(e=>({id:e.id.toString(),name:e.name})),nozzles:Array.from(e).sort((e,t)=>parseFloat(e)-parseFloat(t)),filaments:Array.from(t).sort(),layerHeights:Array.from(n).sort((e,t)=>parseFloat(e)-parseFloat(t))}},[x,i]),C=(0,y.useMemo)(()=>u===`all`?null:i.find(e=>e.id.toString()===u)?.model||null,[u,i]),w=(0,y.useMemo)(()=>x.filter(e=>c===`all`||e.type===c).filter(e=>{if(u===`all`||!C)return!0;let t=e.meta.printer?.toLowerCase()||``,n=C.toLowerCase();return t.includes(n)||n.includes(t)}).filter(e=>f===`all`||e.meta.nozzle===f).filter(e=>m===`all`||e.meta.filamentType===m).filter(e=>g===`all`||e.meta.layerHeight===g).filter(e=>o===``||e.name.toLowerCase().includes(o.toLowerCase())).sort((e,t)=>e.name.localeCompare(t.name)),[x,c,u,C,f,m,g,o]),T=()=>{l(`all`),d(`all`),p(`all`),h(`all`),_(`all`),s(``)},E=c!==`all`||u!==`all`||f!==`all`||m!==`all`||g!==`all`||o!==``,D=e.filament.length+e.printer.length+e.process.length,O=e=>w.filter(t=>t.type===e);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:a(`profiles.cloudView.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsx)(`div`,{className:`flex gap-2`,children:(0,K.jsxs)($,{variant:`secondary`,onClick:n,disabled:r,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),a(`profiles.cloudView.refresh`)]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.type`),value:c,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`),count:D},{value:`filament`,label:a(`profiles.cloudView.filters.filament`),count:e.filament.length},{value:`printer`,label:a(`profiles.cloudView.filters.printer`),count:e.printer.length},{value:`process`,label:a(`profiles.cloudView.filters.process`),count:e.process.length}],onChange:e=>l(e)}),S.printers.length>0&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.printer`),value:u,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.printers.map(e=>({value:e.id,label:e.name}))],onChange:d}),S.nozzles.length>0&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.nozzle`),value:f,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.nozzles.map(e=>({value:e,label:e}))],onChange:p}),S.filaments.length>0&&(c===`all`||c===`filament`)&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.filament`),value:m,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.filaments.map(e=>({value:e,label:e}))],onChange:h}),S.layerHeights.length>0&&(c===`all`||c===`process`)&&(0,K.jsx)(v6,{label:a(`profiles.cloudView.filters.layer`),value:g,options:[{value:`all`,label:a(`profiles.cloudView.filters.all`)},...S.layerHeights.map(e=>({value:e,label:e}))],onChange:_}),E&&(0,K.jsx)(`button`,{onClick:T,className:`px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:a(`profiles.cloudView.clearFilters`)})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),a(`profiles.cloudView.lastSynced`),` `,wf(t.toISOString(),`system`,a)]}),(0,K.jsx)(`span`,{children:a(`profiles.cloudView.showingCount`,{showing:w.length,total:D})})]}),w.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:a(`profiles.cloudView.noPresetsFound`)}),E&&(0,K.jsx)(`button`,{onClick:T,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:a(`profiles.cloudView.clearFilters`)})]}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,K.jsx)(h6,{icon:(0,K.jsx)(Hs,{className:`w-4 h-4 text-amber-400`}),title:a(`profiles.cloudView.columns.filament`),presets:O(`filament`),emptyText:a(`profiles.cloudView.noFilamentPresets`),onSelect:b}),(0,K.jsx)(h6,{icon:(0,K.jsx)(Hl,{className:`w-4 h-4 text-blue-400`}),title:a(`profiles.cloudView.columns.process`),presets:O(`process`),emptyText:a(`profiles.cloudView.noProcessPresets`),onSelect:b}),(0,K.jsx)(h6,{icon:(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),title:a(`profiles.cloudView.columns.printer`),presets:O(`printer`),emptyText:a(`profiles.cloudView.noPrinterPresets`),onSelect:b})]}),v&&(0,K.jsx)(fUe,{setting:v,onClose:()=>b(null),t:a})]})}function h6({icon:e,title:t,presets:n,emptyText:r,onSelect:i}){return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[e,(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:t}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,n.length,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:n.length===0?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:r}):n.map(e=>(0,K.jsx)(dUe,{preset:e,onClick:()=>i(e)},e.setting_id))})]})}function dUe({preset:e,onClick:t}){return(0,K.jsx)(`button`,{onClick:t,className:`w-full text-left px-3 py-2 rounded bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),e.meta.filamentType&&e.type===`filament`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.filamentType}),e.meta.layerHeight&&e.type===`process`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.layerHeight}),e.meta.printer&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.meta.printer})]})})}function fUe({setting:e,onClose:t,t:n}){let{data:r,isLoading:i,error:a}=q({queryKey:[`orcaCloudProfileDetail`,e.setting_id],queryFn:()=>Q.orcaCloudGetProfile(e.setting_id),retry:!1});return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/60 z-50 flex items-center justify-center p-4`,onClick:t,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-2xl max-w-4xl w-full max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:e.type})]}),(0,K.jsx)(`button`,{onClick:t,className:`text-bambu-gray hover:text-white p-1`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:i?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a?(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:a.message}):r?(0,K.jsx)(`pre`,{className:`text-xs font-mono text-bambu-gray bg-bambu-dark p-3 rounded overflow-x-auto whitespace-pre`,children:JSON.stringify(r.setting,null,2)}):(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-16`,children:n(`profiles.cloudView.noPresetsFound`)})})]})})}function pUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),i=r(`orca_cloud:auth`),[a,o]=(0,y.useState)(`picker`),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(null),{data:b,isLoading:x}=q({queryKey:[`orcaCloudStatus`],queryFn:Q.orcaCloudStatus}),S=!!b?.connected,{data:C,isLoading:w,refetch:T,isRefetching:E,error:D,dataUpdatedAt:O}=q({queryKey:[`orcaCloudProfiles`],queryFn:Q.orcaCloudListProfiles,enabled:S,retry:!1,staleTime:1e3*60*5}),{data:k=[]}=q({queryKey:[`printers`],queryFn:Q.getPrinters,enabled:S}),[A,j]=(0,y.useState)();(0,y.useEffect)(()=>{O&&j(new Date(O))},[O]);let M=J({mutationFn:e=>Q.orcaCloudStartAuth(e),onSuccess:e=>{c(e.auth_url),u(``),f(null),o(`paste`),window.open(e.auth_url,`_blank`,`noopener,noreferrer`)},onError:t=>{n(t.message||e(`profiles.orcaCloud.errors.startFailed`),`error`)}}),N=J({mutationFn:e=>Q.orcaCloudFinishAuth(e),onSuccess:r=>{c(null),u(``),f(null),o(`picker`),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.connected`,{email:r.email||``}))},onError:t=>{f(t.message||e(`profiles.orcaCloud.errors.finishFailed`))}}),P=J({mutationFn:({email:e,password:t})=>Q.orcaCloudPasswordLogin(e,t),onSuccess:r=>{m(``),g(``),v(null),o(`picker`),t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.invalidateQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.connected`,{email:r.email||``}))},onError:t=>{v(t.message||e(`profiles.orcaCloud.errors.passwordFailed`))}}),F=J({mutationFn:Q.orcaCloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`orcaCloudStatus`]}),t.removeQueries({queryKey:[`orcaCloudProfiles`]}),n(e(`profiles.orcaCloud.toast.disconnected`))}});return x?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{children:[S&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`profiles.orcaCloud.connectedAs`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:b?.email})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>F.mutate(),disabled:F.isPending||!i,title:i?void 0:e(`profiles.orcaCloud.noLogoutPermission`),children:[(0,K.jsx)(Yc,{className:`w-4 h-4`}),e(`profiles.orcaCloud.logout`)]})]}),S?w?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):D?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:D.message}),(0,K.jsx)($,{onClick:()=>T(),children:e(`profiles.orcaCloud.retry`)})]}):C?(0,K.jsx)(uUe,{settings:C,lastSyncTime:A,onRefresh:()=>T(),isRefreshing:E,printers:k,t:e}):null:(0,K.jsx)(mUe,{mode:a,authUrl:s,pastedUrl:l,setPastedUrl:u,pasteError:d,passwordEmail:p,setPasswordEmail:m,passwordValue:h,setPasswordValue:g,passwordError:_,onPickProvider:e=>M.mutate(e),onPickPassword:()=>{o(`password`),v(null)},onSubmitPaste:t=>{t.preventDefault(),f(null);let n=l.trim();if(!n){f(e(`profiles.orcaCloud.errors.emptyPaste`));return}if(!n.includes(`code=`)){f(e(`profiles.orcaCloud.errors.noCode`));return}N.mutate(n)},onSubmitPassword:t=>{t.preventDefault(),v(null);let n=p.trim();if(!n||!h){v(e(`profiles.orcaCloud.errors.passwordEmpty`));return}P.mutate({email:n,password:h})},onBack:()=>{o(`picker`),c(null),u(``),f(null),m(``),g(``),v(null)},isStarting:M.isPending,isFinishing:N.isPending,isPasswordLoading:P.isPending,canManage:i,t:e})]})}function mUe(e){return e.mode===`paste`&&e.authUrl?(0,K.jsx)(gUe,{...e,authUrl:e.authUrl}):e.mode===`password`?(0,K.jsx)(_Ue,{...e}):(0,K.jsx)(hUe,{...e})}function hUe({onPickProvider:e,onPickPassword:t,isStarting:n,canManage:r,t:i}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-8 text-center`,children:[(0,K.jsx)(ws,{className:`w-12 h-12 text-bambu-green mx-auto mb-4`}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-2`,children:i(`profiles.orcaCloud.connect.title`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mb-6 max-w-xl mx-auto`,children:i(`profiles.orcaCloud.connect.description`)}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 max-w-sm mx-auto`,children:[(0,K.jsxs)($,{onClick:t,disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.email`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`google`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[n?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.google`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`github`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.github`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>e(`apple`),disabled:n||!r,title:r?void 0:i(`profiles.orcaCloud.noConnectPermission`),children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),i(`profiles.orcaCloud.providers.apple`)]})]})]})})}function gUe({authUrl:e,pastedUrl:t,setPastedUrl:n,pasteError:r,onSubmitPaste:i,onBack:a,isFinishing:o,t:s}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`text-bambu-gray hover:text-white text-sm flex items-center gap-1 mb-4`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),s(`profiles.orcaCloud.back`)]}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-4`,children:s(`profiles.orcaCloud.paste.title`)}),(0,K.jsxs)(`ol`,{className:`space-y-3 mb-6`,children:[(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-bambu-dark-tertiary text-white text-sm font-bold flex items-center justify-center`,children:`1`}),(0,K.jsx)(`p`,{className:`text-base text-white pt-0.5`,children:s(`profiles.orcaCloud.paste.step1`)})]}),(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-amber-500/20 text-amber-400 text-sm font-bold flex items-center justify-center`,children:`2`}),(0,K.jsx)(`div`,{className:`flex-1 p-3 bg-amber-500/10 border border-amber-500/40 rounded`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-400 flex-shrink-0 mt-0.5`}),(0,K.jsx)(`p`,{className:`text-base text-white font-medium`,children:s(`profiles.orcaCloud.paste.step2`)})]})})]}),(0,K.jsxs)(`li`,{className:`flex gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-shrink-0 w-7 h-7 rounded-full bg-bambu-dark-tertiary text-white text-sm font-bold flex items-center justify-center`,children:`3`}),(0,K.jsx)(`p`,{className:`text-base text-white pt-0.5`,children:s(`profiles.orcaCloud.paste.step3`)})]})]}),(0,K.jsxs)(`div`,{className:`mb-4 p-3 bg-bambu-dark rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:s(`profiles.orcaCloud.paste.signInUrl`)}),(0,K.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green text-sm break-all hover:underline`,children:e})]}),(0,K.jsxs)(`form`,{onSubmit:i,children:[(0,K.jsx)(`label`,{htmlFor:`orca-callback-url`,className:`block text-sm text-bambu-gray mb-2`,children:s(`profiles.orcaCloud.paste.label`)}),(0,K.jsx)(`textarea`,{id:`orca-callback-url`,value:t,onChange:e=>n(e.target.value),placeholder:s(`profiles.orcaCloud.paste.placeholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm font-mono resize-none focus:outline-none focus:border-bambu-green`,rows:3,disabled:o}),r&&(0,K.jsxs)(`p`,{className:`mt-2 text-sm text-red-400 flex items-center gap-2`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),r]}),(0,K.jsx)(`div`,{className:`mt-4 flex items-center gap-3`,children:(0,K.jsxs)($,{type:`submit`,disabled:o||!t.trim(),children:[o?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),s(`profiles.orcaCloud.paste.submit`)]})})]})]})})}function _Ue({passwordEmail:e,setPasswordEmail:t,passwordValue:n,setPasswordValue:r,passwordError:i,onSubmitPassword:a,onBack:o,isPasswordLoading:s,t:c}){return(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-6 max-w-md mx-auto`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:o,className:`text-bambu-gray hover:text-white text-sm flex items-center gap-1 mb-4`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),c(`profiles.orcaCloud.back`)]}),(0,K.jsx)(`h2`,{className:`text-xl font-bold text-white mb-4`,children:c(`profiles.orcaCloud.password.title`)}),(0,K.jsxs)(`form`,{onSubmit:a,className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`orca-password-email`,className:`block text-sm text-bambu-gray mb-1`,children:c(`profiles.orcaCloud.password.email`)}),(0,K.jsx)(`input`,{id:`orca-password-email`,type:`email`,value:e,onChange:e=>t(e.target.value),placeholder:c(`profiles.orcaCloud.password.emailPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,disabled:s,autoComplete:`email`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`orca-password-value`,className:`block text-sm text-bambu-gray mb-1`,children:c(`profiles.orcaCloud.password.password`)}),(0,K.jsx)(`input`,{id:`orca-password-value`,type:`password`,value:n,onChange:e=>r(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,disabled:s,autoComplete:`current-password`})]}),i&&(0,K.jsxs)(`p`,{className:`text-sm text-red-400 flex items-center gap-2`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),i]}),(0,K.jsxs)($,{type:`submit`,disabled:s||!e.trim()||!n,children:[s?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(rs,{className:`w-4 h-4`}),c(`profiles.orcaCloud.password.submit`)]})]})]})})}function g6(e,t){let n=`${e} ${t||``}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+`mm`:null,s=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=s?s[1]+`mm`:null,l=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i);return{printer:i,nozzle:o,layerHeight:c,filamentType:l?l[1].toUpperCase():null}}function _6(e){return/^(P[FPM]US|PF\d|PP\d)/.test(e)}function vUe({onSuccess:e,t}){let{showToast:n}=Td(),[r,i]=(0,y.useState)(`email`),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(`global`),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),b=J({mutationFn:()=>Q.cloudLogin(a,s,p),onSuccess:r=>{r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):r.needs_verification?(g(r.verification_type||`email`),v(r.tfa_key||null),r.verification_type===`totp`?n(t(`profiles.login.toast.enterTotp`)):n(t(`profiles.login.toast.codeSent`)),i(`code`)):n(r.message,`error`)},onError:e=>n(e.message,`error`)}),x=J({mutationFn:()=>Q.cloudVerify(a,l,_||void 0,p),onSuccess:r=>{r.success?(n(t(`profiles.login.toast.loggedIn`)),e()):n(r.message,`error`)},onError:e=>n(e.message,`error`)}),S=J({mutationFn:()=>Q.cloudSetToken(d,p),onSuccess:()=>{n(t(`profiles.login.toast.tokenSet`)),e()},onError:e=>n(e.message,`error`)}),C=e=>{e.preventDefault(),r===`email`?b.mutate():r===`code`?x.mutate():r===`token`&&S.mutate()},w=b.isPending||x.isPending||S.isPending;return(0,K.jsx)(_d,{className:`max-w-md mx-auto`,children:(0,K.jsxs)(yd,{children:[(0,K.jsxs)(`div`,{className:`text-center mb-6`,children:[(0,K.jsx)(`div`,{className:`inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3`,children:(0,K.jsx)(ws,{className:`w-6 h-6 text-bambu-green`})}),(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:t(`profiles.login.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:t(`profiles.login.subtitle`)})]}),(0,K.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[r===`email`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.email`)}),(0,K.jsx)(`input`,{type:`email`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,placeholder:`your@email.com`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.password`)}),(0,K.jsx)(`input`,{type:`password`,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,placeholder:`••••••••`,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,K.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),r===`code`&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(h===`totp`?`profiles.login.totpCode`:`profiles.login.verificationCode`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:h===`totp`?t(`profiles.login.enterTotpHint`):t(`profiles.login.checkEmail`,{email:a})}),(0,K.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full px-3 py-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-center text-2xl tracking-widest font-mono focus:border-bambu-green focus:outline-none`,placeholder:`000000`,maxLength:6,required:!0})]}),r===`token`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.accessToken`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:t(`profiles.login.accessTokenHint`)}),(0,K.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-xs font-mono placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none resize-none`,placeholder:`eyJ...`,rows:4,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:t(`profiles.login.region`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`global`,children:t(`profiles.login.regionGlobal`)}),(0,K.jsx)(`option`,{value:`china`,children:t(`profiles.login.regionChina`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[r===`code`&&(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>i(`email`),className:`flex-1`,children:t(`profiles.login.back`)}),(0,K.jsxs)($,{type:`submit`,disabled:w,className:`flex-1`,children:[w?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Jc,{className:`w-4 h-4`}),t(r===`email`?`profiles.login.loginButton`:r===`code`?`profiles.login.verifyButton`:`profiles.login.setTokenButton`)]})]}),r===`email`&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(`token`),className:`text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),t(`profiles.login.useToken`)]})}),r===`token`&&(0,K.jsx)(`div`,{className:`pt-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>i(`email`),className:`text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors`,children:[(0,K.jsx)(Jc,{className:`w-4 h-4`}),t(`profiles.login.useEmail`)]})})]})]})})}function v6({label:e,value:t,options:n,onChange:r}){let[i,a]=(0,y.useState)(!1),o=n.find(e=>e.value===t);return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e,`:`]}),(0,K.jsx)(`span`,{children:o?.label||`All`}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,K.jsx)(`div`,{className:`absolute top-full left-0 mt-1 min-w-[160px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl z-20 py-1 max-h-60 overflow-y-auto`,children:n.map(e=>(0,K.jsxs)(`button`,{onClick:()=>{r(e.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${t===e.value?`text-bambu-green`:`text-white`}`,children:[(0,K.jsx)(`span`,{children:e.label}),e.count!==void 0&&(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:e.count})]},e.value))})]})]})}function yUe(){let[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{let e=()=>{t(window.scrollY>300)};return window.addEventListener(`scroll`,e),()=>window.removeEventListener(`scroll`,e)},[]),e?(0,K.jsx)(`button`,{onClick:()=>{window.scrollTo({top:0,behavior:`smooth`})},className:`fixed bottom-6 right-6 p-3 bg-bambu-green hover:bg-bambu-green-light text-white rounded-full shadow-lg shadow-bambu-green/25 transition-all z-40`,"aria-label":`Scroll to top`,children:(0,K.jsx)(Io,{className:`w-5 h-5`})}):null}function y6({setting:e,onClick:t,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:s}){let c=g6(e.name),l=_6(e.setting_id);return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 group`,children:[(0,K.jsx)(`button`,{onClick:t,disabled:o,className:`flex-1 text-left px-3 py-2 rounded transition-colors ${i?`bg-blue-500/20 border border-blue-500/50`:o?`bg-bambu-dark/50 opacity-40 cursor-not-allowed`:`bg-bambu-dark hover:bg-bambu-dark-tertiary`} ${r&&!o?`cursor-pointer`:``}`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&a!==void 0&&(0,K.jsx)(`span`,{className:`flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium`,children:a+1}),!i&&l&&(0,K.jsx)(`span`,{className:`flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green`,title:s(`profiles.presets.myPreset`)}),(0,K.jsx)(`span`,{className:`text-white text-sm truncate flex-1`,title:e.name,children:e.name}),c.filamentType&&e.type===`filament`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.filamentType}),c.layerHeight&&e.type===`process`&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.layerHeight}),c.printer&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:c.printer})]})}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:`opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1`,title:s(`profiles.presets.duplicate`),children:(0,K.jsx)(Ms,{className:`w-4 h-4`})})]})}function b6(e,t=0){let n=` `.repeat(t);if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`string`){if(e.includes(`\\n`)||e.includes(` `)){let t=e.replace(/\\n/g,` `).replace(/\\"/g,`"`).replace(/\\t/g,` `).split(` `);if(t.length>1)return`""" @@ -8718,7 +8718,7 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content: `+n+`]`;if(typeof e==`object`){let r=Object.entries(e);return r.length===0?`{}`:`{ `+r.map(([e,r])=>n+` `+JSON.stringify(e)+`: `+b6(r,t+1)).join(`, `)+` -`+n+`}`}return String(e)}function bUe({setting:e,onClose:t,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:a,t:o}){let{showToast:s}=Td(),c=no(),[l,u]=(0,y.useState)(!1),{data:d,isLoading:f}=q({queryKey:[`cloudSettingDetail`,e.setting_id],queryFn:()=>Q.getCloudSettingDetail(e.setting_id)}),p=J({mutationFn:()=>Q.deleteCloudSetting(e.setting_id),onSuccess:()=>{s(o(`profiles.presets.toast.deleted`)),c.invalidateQueries({queryKey:[`cloudSettings`]}),n()},onError:e=>s(e.message,`error`)}),m=_6(e.setting_id),h=g6(e.name,d?.setting?.inherits);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white truncate`,children:e.name}),m&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full`,children:o(`profiles.presets.editable`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`capitalize`,children:o(`profiles.presets.types.${e.type}`)}),h.printer&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:`•`}),(0,K.jsx)(`span`,{children:h.printer})]})]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):d?(0,K.jsx)(`pre`,{className:`text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full`,children:b6(d)}):(0,K.jsx)(`div`,{className:`text-center py-16 text-bambu-gray`,children:o(`profiles.presets.failedToLoadDetails`)})}),l?(0,K.jsxs)(`div`,{className:`flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{className:`font-medium`,children:o(`profiles.presets.deleteConfirm`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:o(`profiles.presets.deleteWarning`,{name:e.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>u(!1),disabled:p.isPending,className:`flex-1`,children:o(`common.cancel`)}),(0,K.jsxs)($,{variant:`danger`,onClick:()=>p.mutate(),disabled:p.isPending,className:`flex-1`,children:[p.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),o(`common.delete`)]})]})]}):(0,K.jsx)(`div`,{className:`flex-shrink-0 p-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`flex-1`,children:o(`common.close`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:r,disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noDuplicatePermission`),children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),o(`profiles.presets.duplicate`)]}),m&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,onClick:i,disabled:f||!d||!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noEditPermission`),children:[(0,K.jsx)(vl,{className:`w-4 h-4`}),o(`common.edit`)]}),(0,K.jsx)($,{variant:`danger`,onClick:()=>u(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noDeletePermission`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})})]})})})}function x6(){try{let e=localStorage.getItem(`bambusy_preset_templates`);return e?JSON.parse(e):[]}catch{return[]}}function S6(e){localStorage.setItem(`bambusy_preset_templates`,JSON.stringify(e))}function xUe({onClose:e,onApply:t,t:n}){let{showToast:r}=Td(),[i,a]=(0,y.useState)(x6),[o,s]=(0,y.useState)(`all`),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(`{}`),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),x=o===`all`?i:i.filter(e=>e.type===o),S=e=>{a(e),S6(e)},C=e=>{S(i.filter(t=>t.id!==e)),b(null),r(n(`profiles.templates.toast.deleted`))},w=e=>{l(e.id),d(e.name),p(e.description),h(JSON.stringify(e.settings,null,2)),_(null)},T=()=>{if(!(!c||!u.trim()))try{let e=JSON.parse(m);S(i.map(t=>t.id===c?{...t,name:u.trim(),description:f.trim(),settings:e}:t)),l(null),r(n(`profiles.templates.toast.updated`))}catch(e){_(e.message)}},E=()=>{l(null),d(``),p(``),h(`{}`),_(null)},D=e=>{S(i.map(t=>t.id===e?{...t,showInModal:!t.showInModal}:t))},O={filament:{label:n(`profiles.presets.types.filament`),icon:Hs,color:`text-amber-400`},print:{label:n(`profiles.presets.types.process`),icon:Hl,color:`text-blue-400`},printer:{label:n(`profiles.presets.types.printer`),icon:Tl,color:`text-purple-400`}},k=v?i.find(e=>e.id===v):null;return(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(v?b(null):c?E():e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[v,c,e]),(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:[k&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-60`,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 bg-red-500/20 rounded-lg`,children:(0,K.jsx)(Cu,{className:`w-6 h-6 text-red-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:n(`profiles.templates.deleteTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`profiles.templates.deleteWarning`)})]})]}),(0,K.jsx)(`p`,{className:`text-white mb-6`,children:n(`profiles.templates.deleteConfirm`,{name:k.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>b(null),className:`flex-1`,children:n(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>C(v),className:`flex-1 bg-red-500 hover:bg-red-600`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),n(`common.delete`)]})]})]})})}),(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ru,{className:`w-5 h-5 text-amber-400`}),n(`profiles.templates.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`profiles.templates.typeFilter`)}),[`all`,`filament`,`print`,`printer`].map(e=>(0,K.jsx)(`button`,{onClick:()=>s(e),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:e===`all`?n(`common.all`):O[e].label},e))]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:x.length===0?(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(ru,{className:`w-12 h-12 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{children:n(`profiles.templates.noTemplates`)}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:n(`profiles.templates.createFirst`)})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>{let r=O[e.type],i=r.icon;return c===e.id?(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-green`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:n(`profiles.templates.namePlaceholder`),className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:n(`profiles.templates.descriptionPlaceholder`),className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray mb-1 block`,children:n(`profiles.templates.settingsJson`)}),(0,K.jsx)(`textarea`,{value:m,onChange:e=>{h(e.target.value),_(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${g?`border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`}),g&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:g})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{size:`sm`,onClick:T,disabled:!u.trim(),children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),`Save`]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:E,children:`Cancel`})]})]},e.id):(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsx)(i,{className:`w-5 h-5 ${r.color} flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.description})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded`,children:n(`profiles.templates.fieldsCount`,{count:Object.keys(e.settings).length})}),(0,K.jsx)(`button`,{onClick:()=>D(e.id),className:`p-1 transition-colors ${e.showInModal?`text-bambu-green hover:text-bambu-green/70`:`text-bambu-gray hover:text-white`}`,title:e.showInModal?n(`profiles.templates.shownInModals`):n(`profiles.templates.hiddenInModals`),children:e.showInModal?(0,K.jsx)(Xs,{className:`w-4 h-4`}):(0,K.jsx)(Ys,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>t(e),className:`px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors`,children:n(`profiles.templates.apply`)}),(0,K.jsx)(`button`,{onClick:()=>w(e),className:`p-1 text-bambu-gray hover:text-white`,title:n(`common.edit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>b(e.id),className:`p-1 text-bambu-gray hover:text-red-400`,title:n(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]},e.id)})})})]})})]})}function C6({onClose:e,leftPreset:t,rightPreset:n,leftLabel:r,rightLabel:i,t:a}){let[o,s]=(0,y.useState)(`changes`),[c,l]=(0,y.useState)(``),u=(0,y.useMemo)(()=>{let e=new Set([...Object.keys(t),...Object.keys(n)]),r=[];for(let i of e){if(i===`inherits`||i===`version`)continue;let e=t[i],a=n[i],o=i in t,s=i in n,c;c=!o&&s?`added`:o&&!s?`removed`:JSON.stringify(e)===JSON.stringify(a)?`same`:`changed`,r.push({key:i,left:e,right:a,status:c})}return r.sort((e,t)=>{let n={changed:0,added:1,removed:2,same:3};return n[e.status]===n[t.status]?e.key.localeCompare(t.key):n[e.status]-n[t.status]})},[t,n]),d=(0,y.useMemo)(()=>{let e=[...u];if(o===`changes`&&(e=e.filter(e=>e.status!==`same`)),c){let t=c.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||String(e.left).toLowerCase().includes(t)||String(e.right).toLowerCase().includes(t))}return e},[u,o,c]),f=(0,y.useMemo)(()=>({added:u.filter(e=>e.status===`added`).length,removed:u.filter(e=>e.status===`removed`).length,changed:u.filter(e=>e.status===`changed`).length,same:u.filter(e=>e.status===`same`).length}),[u]),p=e=>{if(e===void 0)return`—`;if(e===null)return`null`;if(Array.isArray(e))return e.length===0?`[]`:e.length===1?String(e[0]):e.join(`, `);if(typeof e==`object`)return JSON.stringify(e);let t=String(e);if(t.includes(`\\n`)||t.length>100){let e=t.split(`\\n`).length;if(e>1)return`[${e} lines of G-code/script]`;if(t.length>100)return t.substring(0,100)+`…`}return t};return(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(vc,{className:`w-5 h-5 text-blue-400`}),a(`profiles.diff.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`profiles.diff.left`)}),(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:r})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`profiles.diff.right`)}),(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:i})]})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400`,children:[(0,K.jsx)(Sl,{className:`w-3.5 h-3.5`}),f.added,` `,a(`profiles.diff.added`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(al,{className:`w-3.5 h-3.5`}),f.removed,` `,a(`profiles.diff.removed`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-400`,children:[(0,K.jsx)(No,{className:`w-3.5 h-3.5`}),f.changed,` `,a(`profiles.diff.changed`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Ks,{className:`w-3.5 h-3.5`}),f.same,` `,a(`profiles.diff.same`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`profiles.diff.searchFields`),className:`pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48`})]}),f.same>0&&(0,K.jsxs)(`div`,{className:`flex rounded overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>s(`changes`),className:`px-3 py-1.5 text-sm transition-colors ${o===`changes`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:a(`profiles.diff.changes`)}),(0,K.jsx)(`button`,{onClick:()=>s(`all`),className:`px-3 py-1.5 text-sm transition-colors ${o===`all`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:a(`common.all`)})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:d.length===0?(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(Ks,{className:`w-12 h-12 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{children:a(o===`changes`?`profiles.diff.noDifferences`:`profiles.diff.noFieldsMatch`)})]}):(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{className:`sticky top-0 bg-bambu-dark-secondary`,children:(0,K.jsxs)(`tr`,{className:`text-sm text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:a(`profiles.diff.field`)}),(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:r}),(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:i})]})}),(0,K.jsx)(`tbody`,{children:d.map(e=>{let t={added:`bg-green-500/10`,removed:`bg-red-500/10`,changed:`bg-amber-500/10`,same:``}[e.status],n={added:(0,K.jsx)(Sl,{className:`w-3.5 h-3.5 text-green-400`}),removed:(0,K.jsx)(al,{className:`w-3.5 h-3.5 text-red-400`}),changed:(0,K.jsx)(No,{className:`w-3.5 h-3.5 text-amber-400`}),same:(0,K.jsx)(Ks,{className:`w-3.5 h-3.5 text-bambu-gray-dark`})}[e.status];return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary ${t}`,children:[(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,(0,K.jsx)(`span`,{className:`text-sm text-white font-mono`,children:e.key})]})}),(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-mono break-all ${e.status===`removed`?`text-red-300`:e.status===`changed`?`text-white`:`text-bambu-gray`}`,children:p(e.left)})}),(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-mono break-all ${e.status===`added`?`text-green-300`:e.status===`changed`?`text-white`:`text-bambu-gray`}`,children:p(e.right)})})]},e.key)})})]})})]})})})}function SUe({onClose:e,initialData:t,allPresets:n,t:r}){let{showToast:i}=Td(),a=no(),o=!!t?.setting_id,[s,c]=(0,y.useState)(`common`),[l,u]=(0,y.useState)(t?.type||`filament`),[d,f]=(0,y.useState)(t?.name?o?t.name:`${t.name} (Copy)`:``),[p,m]=(0,y.useState)(t?.base_id||``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(t?.setting||{inherits:``}),[b,x]=(0,y.useState)(JSON.stringify(t?.setting||{inherits:``},null,2)),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(x6),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(!0),[ee,te]=(0,y.useState)(null),[ne,re]=(0,y.useState)(!1),ie=(0,y.useMemo)(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),H=(0,y.useMemo)(()=>ie.filter(e=>_6(e.setting_id)),[ie]),{data:ae}=q({queryKey:[`cloudFields`,l],queryFn:()=>Q.getCloudFields(l===`print`?`process`:l),staleTime:1e3*60*60}),{data:oe}=q({queryKey:[`allPresetDetails`,l,H.map(e=>e.setting_id).join(`,`)],queryFn:async()=>{let e={};for(let t=0;t{try{let t=await Q.getCloudSettingDetail(e.setting_id);return{id:e.setting_id,detail:t}}catch{return null}}))).forEach(t=>{t&&(e[t.id]=t.detail)})}return e},enabled:H.length>0,staleTime:1e3*60*10}),{data:U,isLoading:se}=q({queryKey:[`cloudSettingDetail`,p],queryFn:()=>Q.getCloudSettingDetail(p),enabled:!!p});(0,y.useEffect)(()=>{s!==`json`&&x(JSON.stringify(_,null,2))},[_,s]);let ce=(0,y.useMemo)(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(e=>!_6(e.setting_id)).sort((e,t)=>e.name.localeCompare(t.name)),[n,l]);(0,y.useEffect)(()=>{if(!p)return;let e=ce.find(e=>e.setting_id===p);e&&(g(e.name),o||(v({inherits:e.name}),x(JSON.stringify({inherits:e.name},null,2))))},[p,ce,o]);let le=(0,y.useMemo)(()=>{let e=ae?.fields||[],t=new Set(e.map(e=>e.key)),n=new Set,i=new Set([`inherits`,`updated_time`,`compatible_printers`,`compatible_prints`]);oe&&Object.values(oe).forEach(e=>{e?.setting&&Object.keys(e.setting).forEach(e=>{!t.has(e)&&!i.has(e)&&n.add(e)})}),Object.keys(_).forEach(e=>{!t.has(e)&&!i.has(e)&&n.add(e)});let a=Array.from(n).sort().map(e=>({key:e,label:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),type:`text`,category:`discovered`,description:r(`profiles.presets.discoveredFromPresets`)}));return[...e,...a]},[ae,oe,_,r]),ue=le.filter(e=>e.label.toLowerCase().includes(w.toLowerCase())||e.key.toLowerCase().includes(w.toLowerCase())),de=()=>{if(O.trim()){let e=O.trim().toLowerCase().replace(/\s+/g,`_`);fe(e,``),k(``),j(!1),i(r(`profiles.presets.toast.fieldAdded`,{key:e}))}},fe=(e,t)=>{v(n=>{let r={...n};return t===``||t===void 0?delete r[e]:r[e]=t,r})},pe=e=>{v(t=>({...t,...e.settings})),te(e.name),i(r(`profiles.templates.toast.applied`))},me=()=>{if(!I.trim())return;let e={..._};if(delete e.inherits,Object.keys(e).length===0){i(r(`profiles.presets.noOverridesToSave`),`error`);return}let t={id:Date.now().toString(),name:I.trim(),description:R.trim()||r(`profiles.presets.customTemplate`),type:l,settings:e,showInModal:B},n=[...M,t];N(n),S6(n),F(!1),L(``),z(``),V(!0),i(r(`profiles.templates.toast.created`))},he=(0,y.useMemo)(()=>M.filter(e=>e.type===l&&e.showInModal),[l,M]),ge=e=>{x(e);try{v(JSON.parse(e)),C(null)}catch(e){C(e.message)}},_e=e=>{e.preventDefault(),D(!1);let t=e.dataTransfer.files[0];if(t&&t.name.endsWith(`.json`)){let e=new FileReader;e.onload=e=>{try{let t=e.target?.result,n=JSON.parse(t),a=n.setting||n;v(e=>({...e,...a})),x(JSON.stringify({..._,...a},null,2)),i(r(`profiles.presets.fileImported`))}catch{i(r(`profiles.presets.invalidJsonFile`),`error`)}},e.readAsText(t)}},ve=J({mutationFn:()=>{let e={..._},t=l===`filament`?`filament_settings_id`:l===`print`?`print_settings_id`:`printer_settings_id`;e[t]=`"${d}"`;let n={type:l,name:d,base_id:p,setting:e};return Q.createCloudSetting(n)},onSuccess:async()=>{i(r(`profiles.presets.toast.created`)),await a.refetchQueries({queryKey:[`cloudSettings`]}),e()},onError:e=>i(e.message,`error`)}),ye=J({mutationFn:()=>{if(!t?.setting_id)throw Error(r(`profiles.presets.noSettingId`));return Q.updateCloudSetting(t.setting_id,{name:d,setting:_})},onSuccess:async()=>{i(r(`profiles.presets.toast.updated`)),a.removeQueries({queryKey:[`cloudSettingDetail`]}),await a.refetchQueries({queryKey:[`cloudSettings`]}),e()},onError:e=>i(e.message,`error`)}),be=o?ye:ve,xe=U?.setting?.inherits,Se=xe?ce.find(e=>e.name===xe):void 0,{data:Ce}=q({queryKey:[`cloudSettingDetail`,Se?.setting_id],queryFn:()=>Q.getCloudSettingDetail(Se.setting_id),enabled:!!Se?.setting_id}),we=(0,y.useMemo)(()=>{let e=Ce?.setting||{},t=U?.setting||{},n=p&&oe?.[p]?.setting?oe[p].setting:{};return{...e,...t,...n}},[p,U,Ce,oe]),Te=e=>{if(e==null)return``;if(Array.isArray(e)){let t=[...new Set(e.map(e=>String(e)))];return t.length===1?t[0]:e.join(`, `)}return String(e)},Ee=e=>{let t=_[e.key],n=we[e.key],i=Te(n),a=se?r(`common.loading`):i||``,o=`w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`;if(e.type===`boolean`){let r=t===`1`||t===void 0&&n===`1`;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>fe(e.key,t===`1`?`0`:`1`),className:`w-8 h-5 rounded-full transition-colors ${r?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${r?`translate-x-3.5`:`translate-x-0.5`}`})})}return e.type===`select`?(0,K.jsxs)(`select`,{value:t||``,onChange:t=>fe(e.key,t.target.value),className:o,children:[(0,K.jsx)(`option`,{value:``,children:a}),e.options?.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:t===void 0?``:String(t),onChange:t=>fe(e.key,t.target.value),step:e.step,min:e.min,max:e.max,placeholder:a,className:o}),e.unit&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.unit})]})},De=(0,y.useMemo)(()=>U?.setting?U.setting:{},[U]);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onDragOver:e=>{e.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:_e,children:[ne&&p&&(0,K.jsx)(C6,{onClose:()=>re(!1),leftPreset:De,rightPreset:_,leftLabel:r(`profiles.presets.baseLabel`,{name:h||p}),rightLabel:r(`profiles.presets.currentLabel`,{name:d||r(`profiles.presets.newPreset`)}),t:r}),(0,K.jsx)(_d,{className:`w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:r(o?`profiles.presets.editPreset`:t?`profiles.presets.duplicatePreset`:`profiles.presets.createNewPreset`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`profiles.presets.customizeSettings`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p&&(0,K.jsxs)(`button`,{onClick:()=>re(!0),className:`flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:r(`profiles.presets.compareWithBase`),children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),r(`profiles.presets.compare`)]}),(0,K.jsx)(`button`,{onClick:e,className:`p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),E&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Du,{className:`w-12 h-12 text-bambu-green mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-bambu-green font-medium`,children:r(`profiles.presets.dropJsonToImport`)})]})}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 max-[640px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`common.type`)}),(0,K.jsxs)(`select`,{value:l,onChange:e=>{u(e.target.value),m(``)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`filament`,children:r(`profiles.presets.types.filament`)}),(0,K.jsx)(`option`,{value:`print`,children:r(`profiles.presets.types.process`)}),(0,K.jsx)(`option`,{value:`printer`,children:r(`profiles.presets.types.printer`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`profiles.presets.basePreset`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`profiles.presets.selectBasePreset`)}),ce.map(e=>(0,K.jsx)(`option`,{value:e.setting_id,children:e.name},e.setting_id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`profiles.presets.presetName`)}),(0,K.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:r(`profiles.presets.myCustomPreset`)})]})]}),h&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:(0,K.jsxs)(`p`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),r(`profiles.presets.inheritsFrom`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:h}),se&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin ml-1`})]})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center`,children:[(0,K.jsxs)(`button`,{onClick:()=>c(`common`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`common`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)($l,{className:`w-4 h-4`}),r(`profiles.presets.tabs.common`)]}),(0,K.jsxs)(`button`,{onClick:()=>c(`fields`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`fields`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(Gc,{className:`w-4 h-4`}),r(`profiles.presets.tabs.allFields`)]}),(0,K.jsxs)(`button`,{onClick:()=>c(`json`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`json`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(Es,{className:`w-4 h-4`}),`JSON`,S&&(0,K.jsx)(ds,{className:`w-3 h-3 text-red-400`})]}),(0,K.jsx)(`div`,{className:`flex-1 max-[640px]:hidden`}),(0,K.jsxs)(`button`,{onClick:()=>{let e=new Blob([JSON.stringify({name:d,type:l,base_id:p,setting:_},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${d||`preset`}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t),i(r(`profiles.presets.toast.exported`))},className:`flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors`,title:r(`profiles.presets.exportToJson`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),r(`common.download`)]}),(0,K.jsxs)(`button`,{onClick:()=>document.getElementById(`file-import`)?.click(),className:`flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors`,title:r(`profiles.presets.importFromJson`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),r(`common.upload`)]}),(0,K.jsx)(`input`,{id:`file-import`,type:`file`,accept:`.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{try{let t=JSON.parse(e.target?.result),n=t.setting||t;v(e=>({...e,...n})),i(r(`profiles.presets.fileImported`))}catch{i(r(`profiles.presets.invalidJson`),`error`)}},e.readAsText(t)}}})]}),(0,K.jsxs)(`div`,{className:`flex-1 p-4`,children:[s===`common`&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[(0,K.jsx)(ru,{className:`w-4 h-4 text-amber-400`}),r(`profiles.templates.title`)]}),Object.keys(_).filter(e=>e!==`inherits`).length>0&&(0,K.jsxs)(`button`,{onClick:()=>F(!P),className:`text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors`,children:[(0,K.jsx)(Nl,{className:`w-3 h-3`}),r(`profiles.presets.saveAsTemplate`)]})]}),P&&(0,K.jsxs)(`div`,{className:`mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 mb-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:r(`profiles.templates.namePlaceholder`),className:`px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:r(`profiles.templates.descriptionPlaceholder`),className:`px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{size:`sm`,onClick:me,disabled:!I.trim(),children:[(0,K.jsx)(Nl,{className:`w-3 h-3`}),r(`common.save`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>F(!1),children:r(`common.cancel`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(!B),className:`flex items-center gap-1.5 text-xs transition-colors ${B?`text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[B?(0,K.jsx)(Xs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(Ys,{className:`w-3.5 h-3.5`}),r(B?`profiles.templates.shownInModals`:`profiles.templates.hiddenInModals`)]})]})]}),ee&&(0,K.jsxs)(`div`,{className:`mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2`,children:[(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-green`,children:[r(`profiles.presets.templateApplied`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:ee})]}),(0,K.jsx)(`button`,{onClick:()=>te(null),className:`ml-auto text-bambu-green/70 hover:text-bambu-green`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[he.map(e=>(0,K.jsxs)(`button`,{onClick:()=>pe(e),className:`p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e.description})]},e.id)),he.length===0&&(0,K.jsx)(`p`,{className:`col-span-3 text-center text-bambu-gray text-sm py-4`,children:r(`profiles.presets.noTemplatesSelected`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark mt-2 text-center`,children:r(`profiles.presets.manageTemplatesHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:r(`profiles.presets.commonSettings`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3`,children:le.slice(0,10).map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray flex-shrink-0`,children:e.label}),(0,K.jsx)(`div`,{className:`w-48 max-[640px]:w-full`,children:Ee(e)})]},e.key))})]}),Object.keys(_).length>1&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:r(`profiles.presets.currentOverrides`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(_).filter(([e])=>e!==`inherits`).map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded`,children:[e,`: `,String(t).slice(0,20),(0,K.jsx)(`button`,{onClick:()=>fe(e,void 0),className:`hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))})]})]}),s===`fields`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,style:{height:`400px`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3 flex-shrink-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:r(`profiles.presets.availableFields`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:oe?r(`profiles.templates.fieldsCount`,{count:le.length}):r(`common.loading`)})]}),(0,K.jsxs)(`div`,{className:`relative mb-3 flex-shrink-0`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:r(`profiles.presets.searchFieldsPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-1 pr-2 min-h-0`,children:[ue.filter(e=>!(e.key in _)).map(e=>{let t=we[e.key],n=Te(t);return(0,K.jsxs)(`div`,{onClick:()=>{v(t=>({...t,[e.key]:n||``}))},className:`flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark truncate`,children:e.key})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[n&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate`,title:n,children:[n.slice(0,20),n.length>20?`...`:``]}),(0,K.jsx)(`div`,{className:`w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors`,children:(0,K.jsx)(Sl,{className:`w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors`})})]})]},e.key)}),ue.filter(e=>!(e.key in _)).length===0&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-4 text-sm`,children:r(w?`profiles.presets.noMatchingFields`:`profiles.presets.allFieldsAdded`)})]}),(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0`,children:A?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>e.key===`Enter`&&de(),placeholder:`custom_field_name`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)($,{size:`sm`,onClick:de,disabled:!O.trim(),children:(0,K.jsx)(Sl,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>{j(!1),k(``)},children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):(0,K.jsxs)(`button`,{onClick:()=>j(!0),className:`w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`profiles.presets.addCustomField`)]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3 flex-shrink-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:r(`profiles.presets.yourOverrides`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:r(`profiles.templates.fieldsCount`,{count:Object.keys(_).filter(e=>e!==`inherits`).length})})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-2 min-h-0`,children:[Object.entries(_).filter(([e])=>e!==`inherits`).map(([e,t])=>{let n=le.find(t=>t.key===e);return(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:n?.label||e}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark`,children:e})]}),(0,K.jsx)(`button`,{onClick:()=>fe(e,void 0),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),n?Ee(n):(0,K.jsx)(`input`,{type:`text`,value:String(t),onChange:t=>fe(e,t.target.value),className:`w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]},e)}),Object.keys(_).filter(e=>e!==`inherits`).length===0&&(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)($l,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`profiles.presets.noOverridesYet`)}),(0,K.jsx)(`p`,{className:`text-xs mt-1`,children:r(`profiles.presets.clickFieldsToAdd`)})]})]}),Object.keys(_).filter(e=>e!==`inherits`).length>0&&(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsxs)(`button`,{onClick:()=>{F(!0),c(`common`)},className:`w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),r(`profiles.presets.saveAsTemplate`)]})})]})]}),s===`json`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[S&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),S]}),(0,K.jsx)(`textarea`,{value:b,onChange:e=>ge(e.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${S?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,spellCheck:!1}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`profiles.presets.jsonTip`)})]})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!o&&!p||!!S,className:`flex-1`,children:[be.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):o?(0,K.jsx)(Nl,{className:`w-4 h-4`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(o?`common.save`:t?`common.duplicate`:`common.create`)]})]})]})})]})}function CUe({settings:e,lastSyncTime:t,onRefresh:n,isRefreshing:r,printers:i,hasPermission:a,t:o}){let[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`all`),[d,f]=(0,y.useState)(`all`),[p,m]=(0,y.useState)(`all`),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(`all`),[b,x]=(0,y.useState)(`all`),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)([null,null]),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(null),ee=no(),te=(0,y.useMemo)(()=>[...e.filament.map(e=>({...e,type:`filament`})),...e.printer.map(e=>({...e,type:`printer`})),...e.process.map(e=>({...e,type:`process`}))].map(e=>({...e,meta:g6(e.name)})),[e]),ne=(0,y.useMemo)(()=>{let e=new Set,t=new Set,n=new Set;return te.forEach(r=>{r.meta.nozzle&&e.add(r.meta.nozzle),r.meta.filamentType&&t.add(r.meta.filamentType),r.meta.layerHeight&&n.add(r.meta.layerHeight)}),{printers:i.map(e=>({id:e.id.toString(),name:e.name})),nozzles:Array.from(e).sort((e,t)=>parseFloat(e)-parseFloat(t)),filaments:Array.from(t).sort(),layerHeights:Array.from(n).sort((e,t)=>parseFloat(e)-parseFloat(t))}},[te,i]),re=(0,y.useMemo)(()=>p===`all`?null:i.find(e=>e.id.toString()===p)?.model||null,[p,i]),ie=(0,y.useMemo)(()=>te.filter(e=>l===`all`||e.type===l).filter(e=>{if(d===`all`)return!0;let t=_6(e.setting_id);return d===`custom`?t:!t}).filter(e=>{if(p===`all`||!re)return!0;let t=e.meta.printer?.toLowerCase()||``,n=re.toLowerCase();return t.includes(n)||n.includes(t)}).filter(e=>h===`all`||e.meta.nozzle===h).filter(e=>_===`all`||e.meta.filamentType===_).filter(e=>b===`all`||e.meta.layerHeight===b).filter(e=>s===``||e.name.toLowerCase().includes(s.toLowerCase())).sort((e,t)=>e.name.localeCompare(t.name)),[te,l,d,p,re,h,_,b,s]),H=e=>{if(P){let t=I[0]?.setting_id===e.setting_id,n=I[1]?.setting_id===e.setting_id;if(t)L([I[1],null]);else if(n)L([I[0],null]);else if(!I[0])L([e,null]);else if(I[1]){if(I[0].type!==e.type)return;L([I[0],e])}else{if(I[0].type!==e.type)return;L([I[0],e])}}else C(e)},ae=e=>{if(I[0]?.setting_id===e.setting_id)return 0;if(I[1]?.setting_id===e.setting_id)return 1},oe=async e=>{try{let t=await Q.getCloudSettingDetail(e.setting_id);k({type:e.type===`process`?`print`:e.type,name:e.name,base_id:t.base_id||`GFSA00`,setting:t.setting||{}}),C(null)}catch(e){console.error(`Failed to fetch preset details for duplication:`,e)}},U=async e=>{try{ee.removeQueries({queryKey:[`cloudSettingDetail`,e.setting_id]});let t=await Q.getCloudSettingDetail(e.setting_id);j({type:e.type===`process`?`print`:e.type,name:e.name,base_id:t.base_id||`GFSA00`,setting:t.setting||{},setting_id:e.setting_id}),C(null)}catch(e){console.error(`Failed to fetch preset details for editing:`,e)}},se=()=>{u(`all`),f(`all`),m(`all`),g(`all`),v(`all`),x(`all`),c(``)},ce=l!==`all`||d!==`all`||p!==`all`||h!==`all`||_!==`all`||b!==`all`||s!==``,le=e.filament.length+e.printer.length+e.process.length;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:o(`profiles.cloudView.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[(0,K.jsxs)($,{variant:P?`primary`:`secondary`,onClick:()=>{P?(F(!1),L([null,null])):F(!0)},children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),o(P?`common.cancel`:`profiles.presets.compare`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>D(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noTemplatesPermission`),children:[(0,K.jsx)(ru,{className:`w-4 h-4`}),o(`profiles.cloudView.templates`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:n,disabled:r||!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noRefreshPermission`),children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),o(`profiles.cloudView.refresh`)]}),(0,K.jsxs)($,{onClick:()=>T(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),o(`profiles.cloudView.newPreset`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.type`),value:l,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`),count:le},{value:`filament`,label:o(`profiles.cloudView.filters.filament`),count:e.filament.length},{value:`printer`,label:o(`profiles.cloudView.filters.printer`),count:e.printer.length},{value:`process`,label:o(`profiles.cloudView.filters.process`),count:e.process.length}],onChange:e=>u(e)}),(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.owner`),value:d,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},{value:`custom`,label:o(`profiles.cloudView.filters.myPresets`)},{value:`builtin`,label:o(`profiles.cloudView.filters.builtIn`)}],onChange:e=>f(e)}),ne.printers.length>0&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.printer`),value:p,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.printers.map(e=>({value:e.id,label:e.name}))],onChange:m}),ne.nozzles.length>0&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.nozzle`),value:h,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.nozzles.map(e=>({value:e,label:e}))],onChange:g}),ne.filaments.length>0&&(l===`all`||l===`filament`)&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.filament`),value:_,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.filaments.map(e=>({value:e,label:e}))],onChange:v}),ne.layerHeights.length>0&&(l===`all`||l===`process`)&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.layer`),value:b,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.layerHeights.map(e=>({value:e,label:e}))],onChange:x}),ce&&(0,K.jsx)(`button`,{onClick:se,className:`px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:o(`profiles.cloudView.clearFilters`)})]})]}),P&&(0,K.jsx)(`div`,{className:`mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(vc,{className:`w-5 h-5 text-blue-400`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:o(`profiles.cloudView.compareMode`)}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:I[0]?o(`profiles.cloudView.selectAnotherPreset`,{type:I[0].type}):o(`profiles.cloudView.clickTwoPresets`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${I[0]?`bg-blue-500/30 text-blue-700 dark:text-blue-300`:`bg-bambu-dark text-bambu-gray`}`,children:I[0]?I[0].name:o(`profiles.cloudView.selectFirst`)}),(0,K.jsx)(No,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${I[1]?`bg-blue-500/30 text-blue-700 dark:text-blue-300`:`bg-bambu-dark text-bambu-gray`}`,children:I[1]?I[1].name:o(`profiles.cloudView.selectSecond`)})]}),I[0]&&I[1]&&(0,K.jsxs)($,{size:`sm`,onClick:async()=>{try{let[e,t]=await Promise.all([Q.getCloudSettingDetail(I[0].setting_id),Q.getCloudSettingDetail(I[1].setting_id)]);V([e.setting||{},t.setting||{}]),z(!0)}catch{}},children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),o(`profiles.cloudView.compareNow`)]})]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),o(`profiles.cloudView.lastSynced`),` `,wf(t.toISOString(),`system`,o)]}),(0,K.jsx)(`span`,{children:o(`profiles.cloudView.showingCount`,{showing:ie.length,total:le})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-green`}),(0,K.jsxs)(`span`,{children:[`= `,o(`profiles.presets.myPreset`)]})]})]}),ie.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`profiles.cloudView.noPresetsFound`)}),ce&&(0,K.jsx)(`button`,{onClick:se,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:o(`profiles.cloudView.clearFilters`)})]}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Hs,{className:`w-4 h-4 text-amber-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.filament`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`filament`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`filament`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`filament`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noFilamentPresets`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.process`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`process`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`process`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`process`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noProcessPresets`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.printer`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`printer`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`printer`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`printer`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noPrinterPresets`)})]})]})]}),S&&(0,K.jsx)(bUe,{setting:S,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>oe(S),onEdit:()=>U(S),hasPermission:a,t:o}),(w||O||A||M)&&(0,K.jsx)(SUe,{onClose:()=>{T(!1),k(null),j(null),N(null)},initialData:A||O||(M?{type:M.type,name:``,base_id:``,setting:M.setting}:void 0),allPresets:e,t:o}),E&&(0,K.jsx)(xUe,{onClose:()=>D(!1),onApply:e=>{N({type:e.type,setting:e.settings}),D(!1)},t:o}),R&&B&&I[0]&&I[1]&&(0,K.jsx)(C6,{onClose:()=>{z(!1),V(null)},leftPreset:B[0],rightPreset:B[1],leftLabel:I[0].name,rightLabel:I[1].name,t:o})]})}function wUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),[i,a]=(0,y.useState)(`cloud`),[o,s]=(0,y.useState)(),{data:c,isLoading:l}=q({queryKey:[`cloudStatus`],queryFn:Q.getCloudStatus}),{data:u=[]}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:d,isLoading:f,refetch:p,dataUpdatedAt:m}=q({queryKey:[`cloudSettings`],queryFn:()=>Q.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});(0,y.useEffect)(()=>{m&&s(new Date(m))},[m]);let h=J({mutationFn:Q.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`cloudStatus`]}),t.removeQueries({queryKey:[`cloudSettings`]}),n(e(`profiles.toast.loggedOut`))}});return l?(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex items-center justify-center min-h-[400px]`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(ws,{className:`w-7 h-7 text-bambu-green`}),e(`profiles.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`profiles.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary mb-6`,children:[(0,K.jsxs)(`button`,{onClick:()=>a(`cloud`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`cloud`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(ws,{className:`w-4 h-4`}),e(`profiles.tabs.bambuCloud`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`orca_cloud`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`orca_cloud`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(ws,{className:`w-4 h-4`}),e(`profiles.tabs.orcaCloud`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`local`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`local`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(wc,{className:`w-4 h-4`}),e(`profiles.tabs.local`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`kprofiles`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`kprofiles`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(hc,{className:`w-4 h-4`}),e(`profiles.tabs.kprofiles`)]})]}),i===`cloud`&&(0,K.jsxs)(K.Fragment,{children:[c?.is_authenticated&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`profiles.connectedAs`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:c.email}),c.region&&(0,K.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-xs rounded bg-bambu-dark-tertiary text-bambu-gray`,children:c.region===`china`?e(`profiles.login.regionChina`):e(`profiles.login.regionGlobal`)})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>h.mutate(),disabled:h.isPending||!r(`cloud:auth`),title:r(`cloud:auth`)?void 0:e(`profiles.noLogoutPermission`),children:[(0,K.jsx)(Yc,{className:`w-4 h-4`}),e(`profiles.logout`)]})]}),c?.is_authenticated?f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):d?(0,K.jsx)(CUe,{settings:d,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:u,hasPermission:r,t:e}):(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`profiles.failedToLoad`)}),(0,K.jsx)($,{onClick:()=>p(),children:e(`profiles.retry`)})]}):(0,K.jsx)(vUe,{onSuccess:()=>{t.invalidateQueries({queryKey:[`cloudStatus`]})},t:e})]}),i===`orca_cloud`&&(0,K.jsx)(pUe,{}),i===`local`&&(0,K.jsx)(cUe,{}),i===`kprofiles`&&(0,K.jsx)(iUe,{}),(0,K.jsx)(yUe,{})]})}function TUe(e,t){let n=(t||``).toUpperCase().replace(/[- ]/g,``),r=n.includes(`X1`),i=n.includes(`P1`),a=n.includes(`A1MINI`),o=n.includes(`A1`)&&!a,s=n.includes(`H2D`),c=n.includes(`H2C`),l=n.includes(`H2S`),u=s||c||l,d=n.includes(`P2S`),f=n.includes(`X2D`),p=d||f;switch(e){case`Lubricate Steel Rods`:return p?`https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis`:null;case`Clean Steel Rods`:return p?`https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis`:null;case`Lubricate Linear Rails`:return a?`https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis`:o?`https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis`:u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;case`Clean Nozzle/Hotend`:return r||i?`https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog`:a||o?`https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog`:u?`https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning`:p?`https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend`:`https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog`;case`Check Belt Tension`:return r?`https://wiki.bambulab.com/en/x1/maintenance/belt-tension`:i?`https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance`:a?`https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension`:o?`https://wiki.bambulab.com/en/a1/maintenance/belt_tension`:s?`https://wiki.bambulab.com/en/h2/maintenance/belt-tension`:c?`https://wiki.bambulab.com/en/h2c/maintenance/belt-tension`:l?`https://wiki.bambulab.com/en/h2s/maintenance/belt-tension`:p?`https://wiki.bambulab.com/en/p2s/maintenance/belt-tension`:`https://wiki.bambulab.com/en/x1/maintenance/belt-tension`;case`Clean Carbon Rods`:return r||i?`https://wiki.bambulab.com/en/general/carbon-rods-clearance`:null;case`Clean Linear Rails`:return a?`https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis`:o?`https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis`:u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;case`Clean Build Plate`:return`https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide`;case`Check PTFE Tube`:return r||i?`https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube`:a||o?`https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube`:s?`https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer`:l?`https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer`:c?`https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer`:`https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube`;case`Replace HEPA Filter`:case`HEPA Filter`:case`Replace Carbon Filter`:case`Carbon Filter`:return u?`https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte`:`https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter`;case`Lubricate Left Nozzle Rail`:case`Left Nozzle Rail`:return u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;default:return null}}var w6={Droplet:Hs,Flame:ac,Ruler:Ml,Sparkles:ru,Square:ou,Cable:qo,Wrench:Lu,Calendar:Zo,Timer:yu,Cog:ks,Fan:Zs,Zap:Bu,Wind:Iu,Thermometer:vu,Layers:Rc,Box:Wo,Target:pu,RefreshCw:Ol,Settings:Ul,Filter:mc,CircleDot:hs};function T6(e){return e&&w6[e]||Lu}function E6(e,t,n){if(t===`days`){if(e<1)return n?n(`common.today`):`Today`;if(e===1)return n?n(`maintenance.day`):`1 day`;if(e<7){let t=Math.round(e);return n?n(`maintenance.days`,{count:t}):`${t} days`}if(e<180){let t=Math.round(e/7);return t===1?n?n(`maintenance.week`):`1 week`:n?n(`maintenance.weeks`,{count:t}):`${t} weeks`}let t=Math.round(e/30);return t===1?n?n(`maintenance.month`):`1 month`:n?n(`maintenance.months`,{count:t}):`${t} months`}else{if(e<1)return`${Math.round(e*60)}m`;if(e<24)return`${e<10?e.toFixed(1):Math.round(e)}h`;let t=e/24;if(t<7)return`${t<2?t.toFixed(1):Math.round(t)}d`;let n=t/7;return n<12?`${n<2?n.toFixed(1):Math.round(n)}w`:`${Math.round(n/4)}mo`}}function D6(e,t,n){return t===`days`?e===1?n?n(`maintenance.day`):`1 day`:e===7?n?n(`maintenance.week`):`1 week`:e===14?n?n(`maintenance.weeks`,{count:2}):`2 weeks`:e===30?n?n(`maintenance.month`):`1 month`:e===60?n?n(`maintenance.months`,{count:2}):`2 months`:e===90?n?n(`maintenance.months`,{count:3}):`3 months`:e===180?n?n(`maintenance.months`,{count:6}):`6 months`:e===365?n?n(`maintenance.year`):`1 year`:n?n(`maintenance.days`,{count:e}):`${e} days`:`${e}h`}function EUe({item:e,onPerform:t,onToggle:n,hasPermission:r,t:i}){let a=T6(e.maintenance_type_icon),o=e.interval_type||`hours`,s=(()=>{if(o===`days`){let t=e.days_since_maintenance??0;return Math.max(0,Math.min(100,t/e.interval_hours*100))}return Math.max(0,Math.min(100,(e.interval_hours-e.hours_until_due)/e.interval_hours*100))})(),c=()=>e.enabled?e.is_due?`text-red-400`:e.is_warning?`text-amber-400`:`text-bambu-green`:`text-bambu-gray`;return(0,K.jsx)(`div`,{className:`rounded-xl border p-4 transition-all ${e.enabled?e.is_due?`bg-red-500/5 border-red-500/20`:e.is_warning?`bg-amber-500/5 border-amber-500/20`:`bg-bambu-dark-secondary border-bambu-dark-tertiary`:`bg-bambu-dark-secondary/50`}`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3 max-[550px]:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative p-2.5 rounded-lg shrink-0 ${e.is_due?`bg-red-500/20`:e.is_warning?`bg-amber-500/20`:e.enabled?`bg-bambu-dark`:`bg-bambu-dark/50`}`,children:[(0,K.jsx)(a,{className:`w-5 h-5 ${c()}`}),e.enabled&&(e.is_due||e.is_warning)&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${e.is_due?`bg-red-500`:`bg-amber-500`} animate-pulse`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium truncate ${e.enabled?`text-white`:`text-bambu-gray`}`,children:e.maintenance_type_name}),o===`days`&&(0,K.jsx)(`span`,{title:i(`maintenance.timeBasedInterval`),children:(0,K.jsx)(Zo,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`})}),(()=>{let t=e.maintenance_type_wiki_url||TUe(e.maintenance_type_name,e.printer_model);return t?(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-bambu-green transition-colors shrink-0`,title:i(`maintenance.viewDocumentation`),onClick:e=>e.stopPropagation(),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):null})()]}),(0,K.jsx)(`div`,{className:`mt-2 mb-1.5`,children:(0,K.jsx)(`div`,{className:`w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${e.enabled?e.is_due?`bg-red-500`:e.is_warning?`bg-amber-500`:`bg-bambu-green`:`bg-bambu-gray/30`}`,style:{width:`${s}%`}})})}),(0,K.jsxs)(`div`,{className:`text-xs flex items-center gap-1 ${c()}`,children:[e.is_due&&(0,K.jsx)(Cu,{className:`w-3 h-3`}),e.is_warning&&!e.is_due&&(0,K.jsx)(Ss,{className:`w-3 h-3`}),!e.is_due&&!e.is_warning&&e.enabled&&(0,K.jsx)(rs,{className:`w-3 h-3`}),(()=>{if(!e.enabled)return i(`common.disabled`);if(o===`days`){let t=e.days_until_due??0;return e.is_due?i(`maintenance.overdueBy`,{duration:E6(Math.abs(t),`days`,i)}):e.is_warning?i(`maintenance.dueIn`,{duration:E6(t,`days`,i)}):i(`maintenance.timeLeft`,{duration:E6(t,`days`,i)})}else return e.is_due?i(`maintenance.overdueBy`,{duration:E6(Math.abs(e.hours_until_due),`hours`,i)}):e.is_warning?i(`maintenance.dueIn`,{duration:E6(e.hours_until_due,`hours`,i)}):i(`maintenance.timeLeft`,{duration:E6(e.hours_until_due,`hours`,i)})})()]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1`,children:[(0,K.jsx)(`span`,{title:r(`maintenance:update`)?void 0:i(`maintenance.noPermissionUpdate`),children:(0,K.jsx)(cU,{checked:e.enabled,onChange:t=>n(e.id,t),disabled:!r(`maintenance:update`)})}),(0,K.jsxs)($,{size:`sm`,variant:e.is_due?`primary`:`secondary`,onClick:()=>t(e.id),disabled:!e.enabled||!r(`maintenance:update`),title:r(`maintenance:update`)?void 0:i(`maintenance.noPermissionPerform`),className:`!px-3`,children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5`}),i(`common.reset`)]})]})]})})}function DUe({overview:e,onPerform:t,onToggle:n,onSetHours:r,hasPermission:i,t:a}){let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(e.total_print_hours.toFixed(1)),f=[...e.maintenance_items].sort((e,t)=>e.is_due&&!t.is_due?-1:!e.is_due&&t.is_due?1:e.is_warning&&!t.is_warning?-1:!e.is_warning&&t.is_warning?1:e.maintenance_type_id-t.maintenance_type_id),p=f.find(e=>e.enabled&&(e.is_due||e.is_warning)),m=()=>{let t=parseFloat(u);!isNaN(t)&&t>=0&&(r(e.printer_id,t),l(!1))};return(0,K.jsxs)(_d,{className:`overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:e.printer_name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.due_count>0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),a(`maintenance.overdueCount`,{count:e.due_count})]}),e.warning_count>0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),a(`maintenance.dueSoonCount`,{count:e.warning_count})]}),e.due_count===0&&e.warning_count===0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),a(`maintenance.allGood`)]})]})]}),(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors`,children:[o?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`}),a(o?`common.collapse`:`common.expand`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-6 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 bg-bambu-dark/50 rounded-lg`,children:(0,K.jsx)(yu,{className:`w-4 h-4 text-bambu-gray`})}),c?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&l(!1)},className:`w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm`,min:`0`,step:`1`,autoFocus:!0}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:a(`common.hours`)}),(0,K.jsx)($,{size:`sm`,onClick:m,children:a(`common.save`)}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>l(!1),children:a(`common.cancel`)})]}):(0,K.jsxs)(`button`,{onClick:()=>{i(`maintenance:update`)&&(d(Math.round(e.total_print_hours).toString()),l(!0))},className:`group ${i(`maintenance:update`)?``:`cursor-not-allowed opacity-60`}`,title:i(`maintenance:update`)?void 0:a(`maintenance.noPermissionEditHours`),children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-white ${i(`maintenance:update`)?`group-hover:text-bambu-green`:``} transition-colors flex items-center gap-1`,children:[Math.round(e.total_print_hours),` `,a(`common.hours`),(0,K.jsx)(gl,{className:`w-3 h-3 text-bambu-gray ${i(`maintenance:update`)?`group-hover:text-bambu-green`:``}`})]}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:a(`maintenance.totalPrintTime`)})]})]}),(0,K.jsx)(`div`,{className:`w-px h-10 bg-bambu-dark-tertiary`}),p&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${p.is_due?`bg-red-500/20`:`bg-amber-500/20`}`,children:(0,K.jsx)(T6(p.maintenance_type_icon),{className:`w-4 h-4 ${p.is_due?`text-red-400`:`text-amber-400`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium ${p.is_due?`text-red-400`:`text-amber-400`}`,children:p.maintenance_type_name}),(0,K.jsx)(`div`,{className:`text-xs ${p.is_due?`text-red-400/70`:`text-amber-400/70`}`,children:p.is_due?a(`common.overdue`):a(`maintenance.dueSoon`)})]})]})]})]}),o&&(0,K.jsx)(yd,{className:`pt-0 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4`,children:f.map(e=>(0,K.jsx)(EUe,{item:e,onPerform:t,onToggle:n,hasPermission:i,t:a},e.id))})})]})}function OUe({overview:e,types:t,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onRestoreDefaults:o,isRestoringDefaults:s,onAssignType:c,onRemoveItem:l,hasPermission:u,t:d}){let[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(`hours`),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`100`),[T,E]=(0,y.useState)(`hours`),[D,O]=(0,y.useState)(`Wrench`),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(null),[F,I]=(0,y.useState)(null),L=(0,y.useMemo)(()=>e?e.map(e=>({id:e.printer_id,name:e.printer_name})):[],[e]),R=t=>e?e.filter(e=>e.maintenance_items.some(e=>e.maintenance_type_id===t)).map(e=>({printerId:e.printer_id,printerName:e.printer_name,itemId:e.maintenance_items.find(e=>e.maintenance_type_id===t)?.id})):[],z=t=>{if(!e)return[];let n=new Set(R(t).map(e=>e.printerId));return L.filter(e=>!n.has(e.id))},[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(`hours`),[ae,oe]=(0,y.useState)(`Wrench`),[U,se]=(0,y.useState)(``),ce=e=>{V(e),te(e.name),re(e.default_interval_hours.toString()),H(e.interval_type||`hours`),oe(e.icon||`Wrench`),se(e.wiki_url||``)},le=()=>{B&&ee.trim()&&parseFloat(ne)>0&&(i(B.id,{name:ee.trim(),default_interval_hours:parseFloat(ne),interval_type:ie,icon:ae,wiki_url:U.trim()||null}),V(null))},ue=(e,t,r)=>{let i=parseFloat(m);!isNaN(i)&&i>0&&n(e,{custom_interval_hours:Math.abs(i-t)<.01?null:i,custom_interval_type:g===r?null:g}),p(null)},de=e=>{e.preventDefault(),x.trim()&&parseFloat(C)>0&&j.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(C),interval_type:T,icon:D,wiki_url:k.trim()||null},Array.from(j)),S(``),w(`100`),E(`hours`),A(``),M(new Set),b(!1))},fe=e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},pe=e?.map(e=>({printerId:e.printer_id,printerName:e.printer_name,items:e.maintenance_items.sort((e,t)=>e.maintenance_type_id-t.maintenance_type_id)})).sort((e,t)=>e.printerName.localeCompare(t.printerName))||[],me=t.filter(e=>e.is_system),he=t.filter(e=>!e.is_system);return(0,K.jsxs)(`div`,{className:`space-y-8`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:d(`maintenance.maintenanceTypes`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:d(`maintenance.maintenanceTypesDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:o,disabled:!u(`maintenance:delete`)||s,title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),children:d(`maintenance.restoreDefaults`)}),(0,K.jsxs)($,{onClick:()=>b(!v),disabled:!u(`maintenance:create`),title:u(`maintenance:create`)?void 0:d(`maintenance.noPermissionEditTypes`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),d(`maintenance.addCustomType`)]})]})]}),v&&(0,K.jsx)(_d,{className:`mb-6`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`form`,{onSubmit:de,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`lg:col-span-2`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`common.name`)}),(0,K.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`maintenance.exampleName`),autoFocus:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.intervalType`)}),(0,K.jsxs)(`select`,{value:T,onChange:e=>{E(e.target.value),e.target.value===`days`?w(`30`):w(`100`)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.intervalValue`,{type:T===`days`?d(`maintenance.calendarDays`).toLowerCase():d(`common.hours`)})}),(0,K.jsx)(`input`,{type:`number`,value:C,onChange:e=>w(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,min:`1`})]})]}),(0,K.jsx)(`div`,{className:`mt-4 flex items-end justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.icon`)}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:Object.keys(w6).map(e=>{let t=w6[e];return(0,K.jsx)(`button`,{type:`button`,onClick:()=>O(e),className:`p-2 rounded-lg transition-colors ${D===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(t,{className:`w-4 h-4`})},e)})})]})}),(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.documentationLink`)}),(0,K.jsx)(`input`,{type:`url`,value:k,onChange:e=>A(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:`https://wiki.bambulab.com/...`})]}),(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.assignToPrinters`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>fe(e.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${j.has(e.id)?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,children:e.name},e.id))}),j.size===0&&(0,K.jsx)(`p`,{className:`text-xs text-orange-400 mt-1`,children:d(`maintenance.selectAtLeastOnePrinter`)})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>{b(!1),M(new Set)},children:d(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!x.trim()||j.size===0,children:d(`maintenance.addType`)})]})]})})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[me.map(e=>{let t=T6(e.icon),n=e.interval_type||`hours`;return(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg`,children:(0,K.jsx)(t,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-white truncate`,children:e.name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-0.5 flex items-center gap-1`,children:[n===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.default_interval_hours,n,d)]})]}),(0,K.jsx)(`button`,{onClick:()=>{u(`maintenance:delete`)&&I(e)},disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u(`maintenance:delete`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})},e.id)}),he.map(e=>{let t=T6(e.icon),n=e.interval_type||`hours`;if(B?.id===e.id)return(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green`,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`common.name`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`select`,{value:ie,onChange:e=>H(e.target.value),className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]}),(0,K.jsx)(`input`,{type:`number`,value:ne,onChange:e=>re(e.target.value),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,min:`1`})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(w6).map(e=>{let t=w6[e];return(0,K.jsx)(`button`,{type:`button`,onClick:()=>oe(e),className:`p-1.5 rounded transition-colors ${ae===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:(0,K.jsx)(t,{className:`w-3.5 h-3.5`})},e)})}),(0,K.jsx)(`input`,{type:`url`,value:U,onChange:e=>se(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`maintenance.documentationLink`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{size:`sm`,onClick:le,disabled:!ee.trim(),children:d(`common.save`)}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>V(null),children:d(`common.cancel`)})]})]})},e.id);let r=R(e.id),i=z(e.id),o=N===e.id;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2.5 bg-bambu-green/20 rounded-lg`,children:(0,K.jsx)(t,{className:`w-5 h-5 text-bambu-green`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded`,children:d(`maintenance.custom`)})]}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-0.5 flex items-center gap-1`,children:[n===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.default_interval_hours,n,d)]})]}),(0,K.jsxs)(`button`,{onClick:()=>P(o?null:e.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${r.length>0?`border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20`:`border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20`}`,title:d(`maintenance.printersAssignedClick`,{count:r.length}),children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:r.length}),(0,K.jsx)(is,{className:`w-3 h-3 transition-transform ${o?`rotate-180`:``}`})]}),(0,K.jsx)(`button`,{onClick:()=>ce(e),disabled:!u(`maintenance:update`),title:u(`maintenance:update`)?void 0:d(`maintenance.noPermissionEditTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${u(`maintenance:update`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(gl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{confirm(d(`maintenance.deleteTypeConfirm`,{name:e.name}))&&a(e.id)},disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u(`maintenance:delete`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}),o&&(0,K.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:d(`maintenance.assignedToPrinters`)}),r.length===0?(0,K.jsx)(`p`,{className:`text-xs text-orange-400`,children:d(`maintenance.noPrintersAssigned`)}):(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white`,children:[e.printerName,(0,K.jsx)(`button`,{onClick:()=>e.itemId&&l(e.itemId),disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?d(`maintenance.removeFromPrinter`):d(`maintenance.noPermissionRemovePrinter`),className:`ml-1 ${u(`maintenance:delete`)?`hover:text-red-400`:`opacity-50 cursor-not-allowed`}`,children:`×`})]},e.printerId))}),i.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:d(`maintenance.addPrinterShort`)}),i.map(t=>(0,K.jsxs)(`button`,{onClick:()=>c(t.id,e.id),disabled:!u(`maintenance:create`),title:u(`maintenance:create`)?void 0:d(`maintenance.noPermissionAssignPrinter`),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${u(`maintenance:create`)?`hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green`:`opacity-50 cursor-not-allowed text-bambu-gray`}`,children:[`+ `,t.name]},t.id))]})]})]},e.id)})]})]}),pe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:d(`maintenance.intervalOverrides`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:d(`maintenance.intervalOverridesDescription`)})]}),(0,K.jsx)(`div`,{className:`space-y-4`,children:pe.map(e=>(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e.printerName}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2`,children:e.items.map(e=>{let n=T6(e.maintenance_type_icon),r=t.find(t=>t.id===e.maintenance_type_id),i=r?.default_interval_hours||e.interval_hours,a=r?.interval_type||`hours`,o=e.interval_type||`hours`,s=f===e.id;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(n,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-1 truncate`,children:e.maintenance_type_name}),s?(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[g===`days`?(0,K.jsx)(Zo,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`}):(0,K.jsx)(yu,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`}),(0,K.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]}),(0,K.jsx)(`input`,{type:`number`,value:m,onChange:e=>h(e.target.value),onKeyDown:t=>{t.key===`Enter`&&ue(e.id,i,a),t.key===`Escape`&&p(null)},className:`w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs`,min:`1`}),(0,K.jsx)($,{size:`sm`,onClick:()=>ue(e.id,i,a),children:`OK`})]}):(0,K.jsxs)(`button`,{onClick:()=>{u(`maintenance:update`)&&(p(e.id),h(e.interval_hours.toString()),_(o))},disabled:!u(`maintenance:update`),title:u(`maintenance:update`)?void 0:d(`maintenance.noPermissionEditIntervals`),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${u(`maintenance:update`)?`hover:bg-bambu-dark-secondary hover:border-bambu-green`:`opacity-50 cursor-not-allowed`}`,children:[o===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.interval_hours,o,d),(0,K.jsx)(gl,{className:`w-3 h-3 text-bambu-gray`})]})]},e.id)})})]})},e.printerId))})]}),pe.length===0&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(Ss,{className:`w-12 h-12 mx-auto mb-4 text-bambu-gray/30`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:d(`common.noPrinters`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray/70 mt-1`,children:d(`maintenance.intervalOverridesDescription`)})]})}),F&&(0,K.jsx)(Ad,{title:d(`maintenance.deleteSystemTypeTitle`),message:d(`maintenance.deleteSystemTypeMessage`,{name:F.name}),confirmText:d(`common.delete`),cancelText:d(`common.cancel`),variant:`danger`,cancelVariant:`primary`,cardClassName:`bg-red-950/70 border border-red-800/70`,onConfirm:()=>{a(F.id),I(null)},onCancel:()=>I(null)})]})}function kUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),[i,a]=(0,y.useState)(`status`),{data:o,isLoading:s}=q({queryKey:[`maintenanceOverview`],queryFn:Q.getMaintenanceOverview}),{data:c}=q({queryKey:[`maintenanceTypes`],queryFn:Q.getMaintenanceTypes}),l=J({mutationFn:({id:e,notes:t})=>Q.performMaintenance(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),t.invalidateQueries({queryKey:[`maintenanceSummary`]}),n(e(`maintenance.maintenanceComplete`))},onError:e=>{n(e.message,`error`)}}),u=J({mutationFn:({id:e,data:t})=>Q.updateMaintenanceItem(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]})},onError:e=>{n(e.message,`error`)}}),d=J({mutationFn:({id:e,data:t})=>Q.updateMaintenanceType(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeUpdated`))},onError:e=>{n(e.message,`error`)}}),f=J({mutationFn:Q.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeDeleted`))},onError:e=>{n(e.message,`error`)}}),p=J({mutationFn:Q.restoreDefaultMaintenanceTypes,onSuccess:r=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.defaultsRestored`,{count:r.restored}))},onError:e=>{n(e.message,`error`)}}),m=J({mutationFn:({printerId:e,hours:t})=>Q.setPrinterHours(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),t.invalidateQueries({queryKey:[`maintenanceSummary`]}),n(e(`maintenance.printHoursUpdated`))},onError:e=>{n(e.message,`error`)}}),h=J({mutationFn:({printerId:e,typeId:t})=>Q.assignMaintenanceType(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.printerAssigned`))},onError:e=>{n(e.message,`error`)}}),g=J({mutationFn:Q.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.printerRemoved`))},onError:e=>{n(e.message,`error`)}}),_=e=>{l.mutate({id:e})},v=(e,t)=>{u.mutate({id:e,data:{enabled:t}})},b=(e,t)=>{m.mutate({printerId:e,hours:t})};if(s)return(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});let x=o?.reduce((e,t)=>e+t.due_count,0)||0,S=o?.reduce((e,t)=>e+t.warning_count,0)||0;return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Lu,{className:`w-7 h-7 text-bambu-green`}),e(`maintenance.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i===`status`?(0,K.jsxs)(K.Fragment,{children:[x>0&&(0,K.jsx)(`span`,{className:`text-red-400`,children:e(`maintenance.dueCount`,{count:x})}),x>0&&S>0&&` · `,S>0&&(0,K.jsx)(`span`,{className:`text-amber-400`,children:e(`maintenance.warningCount`,{count:S})}),x===0&&S===0&&(0,K.jsx)(`span`,{className:`text-bambu-green`,children:e(`maintenance.allOk`)})]}):e(`maintenance.configureSettings`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 mb-6 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`status`),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i===`status`?`text-bambu-green border-bambu-green`:`text-bambu-gray border-transparent hover:text-white`}`,children:e(`maintenance.statusTab`)}),(0,K.jsx)(`button`,{onClick:()=>a(`settings`),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i===`settings`?`text-bambu-green border-bambu-green`:`text-bambu-gray border-transparent hover:text-white`}`,children:e(`maintenance.settingsTab`)})]}),i===`status`?(0,K.jsx)(`div`,{className:`space-y-6`,children:o&&o.length>0?[...o].sort((e,t)=>{let n=e.due_count*10+e.warning_count,r=t.due_count*10+t.warning_count;return n===r?e.printer_name.localeCompare(t.printer_name):r-n}).map(t=>(0,K.jsx)(DUe,{overview:t,onPerform:_,onToggle:v,onSetHours:b,hasPermission:r,t:e},t.printer_id)):(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-16`,children:[(0,K.jsx)(Lu,{className:`w-16 h-16 mx-auto mb-4 text-bambu-gray/30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:e(`common.noPrinters`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`maintenance.configureSettings`)})]})})}):(0,K.jsx)(OUe,{overview:o,types:c||[],onUpdateInterval:(e,t)=>u.mutate({id:e,data:t}),onAddType:async(r,i)=>{let a=await Q.createMaintenanceType(r);for(let e of i)await Q.assignMaintenanceType(e,a.id);t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeUpdated`))},onUpdateType:(e,t)=>d.mutate({id:e,data:t}),onDeleteType:e=>f.mutate(e),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(e,t)=>h.mutate({printerId:e,typeId:t}),onRemoveItem:e=>g.mutate(e),hasPermission:r,t:e})]})}var O6=[`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#6b7280`];function k6({project:e,onClose:t,onSave:n,isLoading:r,currencySymbol:i,t:a}){let[o,s]=(0,y.useState)(e?.name||``),[c,l]=(0,y.useState)(e?.description||``),[u,d]=(0,y.useState)(e?.color||O6[0]),[f,p]=(0,y.useState)(e?.target_count?.toString()||``),[m,h]=(0,y.useState)(e?.target_parts_count?.toString()||``),[g,_]=(0,y.useState)(e?.status||`active`),[v,b]=(0,y.useState)(e?.tags||``),[x,S]=(0,y.useState)(e?.due_date?.split(`T`)[0]||``),[C,w]=(0,y.useState)(e?.priority||`normal`),[T,E]=(0,y.useState)(e?.budget?.toString()||``),[D,O]=(0,y.useState)(e?.url||``),[k,A]=(0,y.useState)(null),j=no(),[M,N]=(0,y.useState)(e?.cover_image_filename||null),P=(0,y.useRef)(null),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)(0);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary flex flex-col max-h-[calc(100vh-2rem)]`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(e?`projects.editProject`:`projects.newProject`)})}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let r=D.trim();if(r&&!/^https?:\/\//i.test(r)){A(a(`projects.urlInvalid`));return}A(null),n({name:o.trim(),description:c.trim()||void 0,color:u,target_count:f?parseInt(f,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:x||void 0,priority:C,budget:T.trim()?parseFloat(T):null,url:e?r||null:r||void 0,...e&&{status:g}})},className:`flex flex-col flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.name`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.namePlaceholder`),required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.description`)}),(0,K.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none`,placeholder:a(`projects.descriptionPlaceholder`),rows:2})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.urlLabel`)}),(0,K.jsx)(`input`,{type:`url`,value:D,onChange:e=>{O(e.target.value),k&&A(null)},className:`w-full bg-bambu-dark border rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none ${k?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,placeholder:a(`projects.urlPlaceholder`),maxLength:2048}),k&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:k})]}),e&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.coverImageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-20 h-20 rounded bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden flex items-center justify-center flex-shrink-0`,children:M?(0,K.jsx)(`img`,{src:`${Q.getProjectCoverImageUrl(e.id)}?v=${L}`,alt:a(`projects.coverImageAlt`),className:`w-full h-full object-cover`}):(0,K.jsx)(Mc,{className:`w-6 h-6 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`input`,{ref:P,type:`file`,accept:`image/jpeg,image/png,image/gif,image/webp`,onChange:async t=>{let n=t.target.files?.[0];if(!(!n||!e)){I(!0);try{N((await Q.uploadProjectCoverImage(e.id,n)).filename),R(e=>e+1),j.invalidateQueries({queryKey:[`projects`]})}catch{}finally{I(!1),P.current&&(P.current.value=``)}}},className:`hidden`}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>P.current?.click(),disabled:F,children:[F?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Du,{className:`w-4 h-4 mr-1`}),a(M?`projects.coverImageReplace`:`projects.coverImageUpload`)]}),M&&(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:async()=>{if(e){I(!0);try{await Q.deleteProjectCoverImage(e.id),N(null),R(e=>e+1),j.invalidateQueries({queryKey:[`projects`]})}finally{I(!1)}}},disabled:F,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mr-1`}),a(`projects.coverImageRemove`)]})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.color`)}),(0,K.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:O6.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`w-8 h-8 rounded-full transition-transform ${u===e?`ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110`:``}`,style:{backgroundColor:e}},e))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.targetPlates`)}),(0,K.jsx)(`input`,{type:`number`,value:f,onChange:e=>p(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.targetPlatesPlaceholder`),min:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:a(`projects.targetPlatesHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.targetParts`)}),(0,K.jsx)(`input`,{type:`number`,value:m,onChange:e=>h(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.targetPartsPlaceholder`),min:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:a(`projects.targetPartsHelp`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.tagsLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:v,onChange:e=>b(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.tagsPlaceholder`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.dueDate`)}),(0,K.jsx)(`input`,{type:`date`,value:x,onChange:e=>S(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.priority`)}),(0,K.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`low`,children:a(`projects.priorityLow`)}),(0,K.jsx)(`option`,{value:`normal`,children:a(`projects.priorityNormal`)}),(0,K.jsx)(`option`,{value:`high`,children:a(`projects.priorityHigh`)}),(0,K.jsx)(`option`,{value:`urgent`,children:a(`projects.priorityUrgent`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projectDetail.cost.budget`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray pointer-events-none`,children:i}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:T,onChange:e=>E(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded pl-8 pr-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:`0.00`})]})]}),e&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.status`)}),(0,K.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`active`,children:a(`projects.statusActive`)}),(0,K.jsx)(`option`,{value:`completed`,children:a(`projects.statusCompleted`)}),(0,K.jsx)(`option`,{value:`archived`,children:a(`projects.statusArchived`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:a(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!o.trim()||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):a(e?`common.save`:`projects.create`)})]})]})]})})}function AUe({projectId:e,altText:t}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null);return(0,K.jsxs)(`div`,{ref:n,className:`relative flex-shrink-0`,onMouseEnter:()=>{if(!n.current)return;let e=n.current.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight,a=e.right+8;a+384>t-8&&(a=e.left-384-8);let s=e.top;s+384>r-8&&(s=r-384-8),s<8&&(s=8),o({left:a,top:s}),i(!0)},onMouseLeave:()=>i(!1),onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg overflow-hidden bg-bambu-dark border border-bambu-dark-tertiary`,children:(0,K.jsx)(`img`,{src:Q.getProjectCoverImageUrl(e),alt:t,className:`w-full h-full object-cover`,loading:`lazy`})}),r&&a&&(0,Op.createPortal)((0,K.jsx)(`div`,{className:`fixed z-[100] w-96 h-96 rounded-lg overflow-hidden border border-bambu-dark-tertiary shadow-2xl bg-bambu-dark pointer-events-none`,style:{left:a.left,top:a.top},"aria-hidden":`true`,children:(0,K.jsx)(`img`,{src:Q.getProjectCoverImageUrl(e),alt:``,className:`w-full h-full object-contain`,loading:`lazy`})}),document.body)]})}function jUe({project:e,onClick:t,onEdit:n,onDelete:r,hasPermission:i,t:a}){let o=e.target_count?Math.round(e.archive_count/e.target_count*100):0,s=e.target_parts_count?Math.round(e.completed_count/e.target_parts_count*100):0,c=e.status===`completed`,l=e.status===`archived`,[u,d]=(0,y.useState)(!1),f=c?{icon:ms,color:`text-bambu-green`,bg:`bg-bambu-green/10`}:l?{icon:Oo,color:`text-bambu-gray`,bg:`bg-bambu-gray/10`}:e.queue_count>0?{icon:Ss,color:`text-blue-400`,bg:`bg-blue-400/10`}:{icon:sc,color:`text-bambu-gray`,bg:`bg-bambu-gray/10`};return(0,K.jsxs)(`div`,{className:`group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden`,onClick:t,children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full`,style:{backgroundColor:e.color||`#6b7280`,boxShadow:`0 0 12px ${e.color||`#6b7280`}40`}}),(0,K.jsxs)(`div`,{className:`p-5 pl-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[e.cover_image_filename?(0,K.jsx)(AUe,{projectId:e.id,altText:a(`projects.coverImageAlt`)}):(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:(0,K.jsx)(f.icon,{className:`w-5 h-5 ${f.color}`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white truncate`,children:e.name}),e.url&&(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),title:e.url,"aria-label":a(`projects.openExternalUrl`),className:`inline-flex items-center justify-center w-6 h-6 rounded bg-bambu-dark border border-bambu-dark-tertiary text-bambu-green hover:bg-bambu-green/10 hover:border-bambu-green transition-colors flex-shrink-0`,children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}),e.target_parts_count?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${s>=100?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray`}`,children:[e.completed_count,`/`,e.target_parts_count,` `,a(`projects.parts`)]}):e.target_count?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray`}`,children:[e.archive_count,`/`,e.target_count,` `,a(`projects.plates`)]}):e.completed_count>0?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray`,children:[e.completed_count,` `,a(`projects.parts`)]}):null,c&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap`,children:a(`projects.done`)}),l&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap`,children:a(`projects.statusArchived`)})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray/70 mt-1 line-clamp-1`,children:e.description}),e.archives&&e.archives.length>0&&(()=>{let t=e.archives.map(e=>e.filament_type).filter(Boolean).flatMap(e=>e.split(`,`).map(e=>e.trim())).filter(Boolean),n=[...new Set(t)],r=e.archives.map(e=>e.filament_color).filter(Boolean).flatMap(e=>e.split(`,`).map(e=>e.trim())).filter(e=>e.startsWith(`#`)||/^[0-9A-Fa-f]{6}$/.test(e)),i=[...new Set(r)];return n.length===0&&i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[n.slice(0,3).map(e=>(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded`,children:e},e)),i.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i.slice(0,5).map(e=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e.startsWith(`#`)?e:`#${e}`},title:e},e)),i.length>5&&(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray ml-0.5`,children:[`+`,i.length-5]})]})]})})()]})]}),(0,K.jsxs)(`div`,{className:`relative`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100`,onClick:()=>d(!u),children:(0,K.jsx)(Ws,{className:`w-4 h-4`})}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>d(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i(`projects:update`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{i(`projects:update`)&&(n(),d(!1))},disabled:!i(`projects:update`),title:i(`projects:update`)?void 0:a(`projects.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4`}),a(`common.edit`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i(`projects:delete`)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{i(`projects:delete`)&&(r(),d(!1))},disabled:!i(`projects:delete`),title:i(`projects:delete`)?void 0:a(`projects.noDeletePermission`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),a(`common.delete`)]})]})]})]})]}),(0,K.jsx)(`div`,{className:`mb-4`,children:e.target_count||e.target_parts_count?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[e.target_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:a(`projects.plates`)}),(0,K.jsxs)(`span`,{className:o>=100?`text-bambu-green font-medium`:`text-white`,children:[e.archive_count,` / `,e.target_count]})]}),(0,K.jsx)(`div`,{className:`h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out rounded-full relative`,style:{width:`${Math.min(o,100)}%`,background:o>=100?`linear-gradient(90deg, #22c55e, #4ade80)`:`linear-gradient(90deg, ${e.color||`#6b7280`}, ${e.color||`#6b7280`}cc)`,boxShadow:`0 0 8px ${o>=100?`#22c55e`:e.color||`#6b7280`}60`}})})]}),e.target_parts_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:a(`projects.parts`)}),(0,K.jsxs)(`span`,{className:s>=100?`text-bambu-green font-medium`:`text-white`,children:[e.completed_count,` / `,e.target_parts_count]})]}),(0,K.jsx)(`div`,{className:`h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out rounded-full relative`,style:{width:`${Math.min(s,100)}%`,background:s>=100?`linear-gradient(90deg, #22c55e, #4ade80)`:`linear-gradient(90deg, ${e.color||`#6b7280`}, ${e.color||`#6b7280`}cc)`,boxShadow:`0 0 8px ${s>=100?`#22c55e`:e.color||`#6b7280`}60`}})})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`text-xs text-red-400`,children:[e.failed_count,` `,a(`projects.failed`)]})]}):e.completed_count>0||e.failed_count>0?(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-xs`,children:[e.completed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.completed_count,` `,a(`projects.completed`)]})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.failed_count,` `,a(`projects.failed`)]})]}),e.queue_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-blue-400`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.queue_count,` `,a(`projects.inQueue`)]})]})]}):(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/60 italic`,children:a(`projects.noPrintsYet`)})}),e.archives&&e.archives.length>0&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:e.archives.slice(0,4).map(e=>(0,K.jsxs)(`div`,{className:`relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary`,title:e.print_name||`Unknown`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:e.print_name||``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray/50`,children:(0,K.jsx)(pl,{className:`w-6 h-6`})}),e.status===`failed`&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-red-500/40 flex items-center justify-center`,children:(0,K.jsx)(Cu,{className:`w-4 h-4 text-white`})})]},e.id))}),e.archive_count>4&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5 text-center`,children:a(`common.more`,{count:e.archive_count-4})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-bambu-gray`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:a(`projects.printJobs`),children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5 text-blue-400`}),(0,K.jsxs)(`span`,{children:[e.archive_count,` `,a(`projects.plates`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:a(`projects.partsPrinted`),children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5 text-bambu-green`}),(0,K.jsxs)(`span`,{children:[e.completed_count,` `,a(`projects.parts`)]})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-red-400`,title:a(`projects.failedParts`),children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:e.failed_count})]}),e.queue_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-yellow-400`,title:a(`projects.inQueue`),children:[(0,K.jsx)(Wc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:e.queue_count})]})]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors`})]})]})]})}function MUe(){let{t:e}=W(),t=$n(),n=no(),{showToast:r}=Td(),{hasPermission:i}=dd(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(),[l,u]=(0,y.useState)(`active`),[d,f]=(0,y.useState)(null),{data:p}=q({queryKey:[`settings`],queryFn:Q.getSettings}),m=$d(p?.currency||`USD`),{data:h,isLoading:g}=q({queryKey:[`projects`,l===`all`?void 0:l],queryFn:()=>Q.getProjects(l===`all`?void 0:l)}),_=J({mutationFn:e=>Q.createProject(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),o(!1),r(e(`projects.toast.created`),`success`)},onError:e=>{r(e.message,`error`)}}),v=J({mutationFn:({id:e,data:t})=>Q.updateProject(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),o(!1),c(void 0),r(e(`projects.toast.updated`),`success`)},onError:e=>{r(e.message,`error`)}}),b=J({mutationFn:e=>Q.deleteProject(e),onSuccess:()=>{f(null),r(e(`projects.toast.deleted`),`success`),setTimeout(()=>window.location.reload(),100)},onError:e=>{f(null),r(e.message,`error`)}}),x=J({mutationFn:e=>Q.importProject(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),r(e(`projects.toast.imported`),`success`)},onError:e=>{r(e.message,`error`)}}),S=(0,y.useRef)(null),C=async()=>{try{let t=await Q.getProjects(),n=await Promise.all(t.map(async e=>await Q.exportProjectJson(e.id))),i=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`bambuddy_projects_${new Date().toISOString().split(`T`)[0]}.json`,o.click(),URL.revokeObjectURL(a),r(e(`projects.toast.exported`),`success`)}catch(e){r(e.message,`error`)}},w=()=>{S.current?.click()},T=async t=>{let i=t.target.files?.[0];if(i){try{if(i.name.toLowerCase().endsWith(`.zip`))await Q.importProjectFile(i),n.invalidateQueries({queryKey:[`projects`]}),r(e(`projects.toast.imported`),`success`);else{let t=await i.text(),n=JSON.parse(t),a=Array.isArray(n)?n:[n];for(let e of a)await x.mutateAsync(e);a.length>1&&r(e(`projects.toast.multipleImported`,{count:a.length}),`success`)}}catch(t){r(`${e(`projects.toast.importFailed`)}: ${t.message}`,`error`)}t.target.value=``}},E=e=>{s?v.mutate({id:s.id,data:e}):_.mutate(e)},D=e=>{c(e),o(!0)},O=e=>{t(`/projects/${e.id}`)},k=e=>{f(e)},A=()=>{d!==null&&b.mutate(d)},j=h?.reduce((e,t)=>(e[t.status]=(e[t.status]||0)+1,e.all=(e.all||0)+1,e),{})||{};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,K.jsx)(`input`,{ref:S,type:`file`,accept:`.json,.zip`,onChange:T,className:`hidden`}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(sc,{className:`w-7 h-7 text-bambu-green`}),e(`projects.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`projects.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:w,disabled:!i(`projects:create`),title:i(`projects:create`)?e(`projects.importProject`):e(`projects.noImportPermission`),children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),e(`projects.import`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:C,disabled:!i(`projects:read`),title:i(`projects:read`)?e(`projects.exportAll`):e(`projects.noExportPermission`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),e(`projects.export`)]}),(0,K.jsxs)($,{onClick:()=>o(!0),className:`sm:w-auto w-full`,disabled:!i(`projects:create`),title:i(`projects:create`)?void 0:e(`projects.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`projects.newProject`)]})]})]}),(0,K.jsx)(`div`,{className:`flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit`,children:[{key:`active`,label:e(`projects.statusActive`),icon:Ss},{key:`completed`,label:e(`projects.statusCompleted`),icon:ms},{key:`archived`,label:e(`projects.statusArchived`),icon:Oo},{key:`all`,label:e(`common.all`),icon:sc}].map(({key:e,label:t,icon:n})=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===e?`bg-bambu-card text-white shadow-sm`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(n,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:t}),j[e]>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${l===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary`}`,children:j[e]})]},e))}),g?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`projects.loading`)})]})}):h?.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(sc,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:l===`all`?e(`projects.noProjects`):e(`projects.noProjectsFiltered`,{status:l})}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:l===`all`?e(`projects.createFirst`):e(`projects.noProjectsFilteredHelp`,{status:l})}),l===`all`&&(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!i(`projects:create`),title:i(`projects:create`)?void 0:e(`projects.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`projects.createFirstButton`)]})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8`,children:h?.map(t=>(0,K.jsx)(jUe,{project:t,onClick:()=>O(t),onEdit:()=>D(t),onDelete:()=>k(t.id),hasPermission:i,t:e},t.id))}),d!==null&&(0,K.jsx)(Ad,{title:e(`projects.deleteProject`),message:e(`projects.deleteConfirm`),confirmText:e(`projects.deleteProject`),variant:`danger`,onConfirm:A,onCancel:()=>f(null)}),a&&(0,K.jsx)(k6,{project:s,onClose:()=>{o(!1),c(void 0)},onSave:E,isLoading:_.isPending||v.isPending,currencySymbol:m,t:e})]})}function NUe(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)}function PUe(e){return e>=1e3?`${(e/1e3).toFixed(2)}kg`:`${Math.round(e)}g`}function FUe({status:e,t}){let n={active:`bg-bambu-green/20 text-bambu-green`,completed:`bg-blue-500/20 text-blue-400`,archived:`bg-bambu-gray/20 text-bambu-gray`},r=n[e]||n.active,i={active:t(`projectDetail.status.active`),completed:t(`projectDetail.status.completed`),archived:t(`projectDetail.status.archived`)};return(0,K.jsx)(`span`,{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[e]||e.charAt(0).toUpperCase()+e.slice(1)})}function A6({icon:e,label:t,value:n,subValue:r,hint:i,color:a=`text-bambu-gray`}){return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,title:i,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:(0,K.jsx)(e,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t}),(0,K.jsx)(`p`,{className:`text-xl font-semibold text-white`,children:n}),r&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:r})]})]})})})}function IUe({archives:e,t}){return e.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-12 h-12 mx-auto mb-2 opacity-50`}),(0,K.jsx)(`p`,{children:t(`projectDetail.noPrints`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3`,children:e.map(e=>(0,K.jsxs)(wi,{to:`/archives?search=${encodeURIComponent(e.print_name||``)}`,className:`group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:e.print_name||`Print`,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:(0,K.jsx)(pl,{className:`w-8 h-8`})}),e.status===`failed`&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-red-500/30 flex items-center justify-center`,children:(0,K.jsx)(ys,{className:`w-8 h-8 text-white`})}),e.status===`completed`&&(0,K.jsx)(`div`,{className:`absolute top-1 right-1`,children:(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green`})}),(0,K.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(`p`,{className:`text-xs text-white truncate`,children:e.print_name||`Unknown`})})]},e.id))})}function LUe({priority:e,t}){let n={low:{color:`bg-gray-500/20 text-gray-400`,label:t(`projectDetail.priority.low`)},normal:{color:`bg-blue-500/20 text-blue-400`,label:t(`projectDetail.priority.normal`)},high:{color:`bg-orange-500/20 text-orange-400`,label:t(`projectDetail.priority.high`)},urgent:{color:`bg-red-500/20 text-red-400`,label:t(`projectDetail.priority.urgent`)}},{color:r,label:i}=n[e]||n.normal;return(0,K.jsxs)(`span`,{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[e===`urgent`&&(0,K.jsx)(Cu,{className:`w-3 h-3`}),i]})}function j6(e,t){if(!e)return null;let n=vf(e);if(!n)return null;let r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:`text-red-400`,label:t(`projectDetail.dueDate.overdue`)}:i===0?{color:`text-orange-400`,label:t(`projectDetail.dueDate.today`)}:i<=3?{color:`text-yellow-400`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}:{color:`text-bambu-gray`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}}function RUe(){let{id:e}=ir(),t=$n(),{t:n}=W(),r=no(),{showToast:i}=Td(),{hasPermission:a}=dd(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),g=parseInt(e||`0`,10),{data:_,isLoading:v,error:b}=q({queryKey:[`project`,g],queryFn:()=>Q.getProject(g),enabled:g>0}),{data:x,isLoading:S}=q({queryKey:[`project-archives`,g],queryFn:()=>Q.getProjectArchives(g),enabled:g>0}),{data:C,isLoading:w}=q({queryKey:[`project-bom`,g],queryFn:()=>Q.getProjectBOM(g),enabled:g>0}),{data:T,isLoading:E}=q({queryKey:[`project-timeline`,g],queryFn:()=>Q.getProjectTimeline(g,20),enabled:g>0}),{data:D}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:O}=q({queryKey:[`project-folders`,g],queryFn:()=>Q.getLibraryFoldersByProject(g),enabled:g>0}),{data:k,isLoading:A}=q({queryKey:[`project-files`,g],queryFn:()=>Q.getLibraryFiles(null,!1,g),enabled:g>0}),j=(0,y.useMemo)(()=>{let e=new Map;for(let t of k??[])if(t.folder_id!=null){let n=e.get(t.folder_id)??[];n.push(t),e.set(t.folder_id,n)}return e},[k]),M=$d(D?.currency||`USD`),N=D?.time_format||`system`,P=J({mutationFn:e=>Q.updateProject(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project`,g]}),r.invalidateQueries({queryKey:[`projects`]}),s(!1),l(!1),i(n(`projectDetail.toast.projectUpdated`),`success`)},onError:e=>{i(e.message,`error`)}}),F=()=>{d(_?.notes||``),l(!0)},I=()=>{P.mutate({notes:u})},L=()=>{l(!1),d(``)},[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(1),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(``),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(!1),[ce,le]=(0,y.useState)(null),[ue,de]=(0,y.useState)(``),[fe,pe]=(0,y.useState)(1),[me,he]=(0,y.useState)(``),[ge,_e]=(0,y.useState)(``),[ve,ye]=(0,y.useState)(``),[be,xe]=(0,y.useState)({isOpen:!1,title:``,message:``,onConfirm:()=>{}}),Se=J({mutationFn:e=>Q.createBOMItem(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),z(``),V(1),te(``),re(``),H(``),oe(!1),i(n(`projectDetail.toast.partAdded`),`success`)},onError:e=>i(e.message,`error`)}),Ce=J({mutationFn:({itemId:e,data:t})=>Q.updateBOMItem(g,e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),le(null)},onError:e=>i(e.message,`error`)}),we=J({mutationFn:e=>Q.deleteBOMItem(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),i(n(`projectDetail.toast.partRemoved`),`success`)},onError:e=>i(e.message,`error`)}),Te=e=>{e.preventDefault(),R.trim()&&Se.mutate({name:R.trim(),quantity_needed:B,unit_price:ee?parseFloat(ee):void 0,sourcing_url:ne.trim()||void 0,remarks:ie.trim()||void 0})},Ee=e=>{let t=e.is_complete?0:e.quantity_needed;Ce.mutate({itemId:e.id,data:{quantity_acquired:t}})},De=(e,t)=>{xe({isOpen:!0,title:n(`projectDetail.bom.deletePart`),message:n(`projectDetail.bom.deleteConfirm`,{name:t}),onConfirm:()=>{xe(e=>({...e,isOpen:!1})),we.mutate(e)}})},Oe=e=>{le(e),de(e.name),pe(e.quantity_needed),he(e.unit_price?.toString()||``),_e(e.sourcing_url||``),ye(e.remarks||``)},ke=e=>{e.preventDefault(),!(!ce||!ue.trim())&&Ce.mutate({itemId:ce.id,data:{name:ue.trim(),quantity_needed:fe,unit_price:me?parseFloat(me):void 0,sourcing_url:ge.trim()||void 0,remarks:ve.trim()||void 0}})},Ae=()=>{le(null)},je=async()=>{try{let{blob:e,filename:t}=await Q.exportProjectZip(Number(g)),r=URL.createObjectURL(e),a=document.createElement(`a`);a.href=r,a.download=t||`${_?.name||`project`}_${new Date().toISOString().split(`T`)[0]}.zip`,a.click(),URL.revokeObjectURL(r),i(n(`projectDetail.toast.projectExported`),`success`)}catch(e){i(e.message,`error`)}},Me=J({mutationFn:()=>Q.createTemplateFromProject(g),onSuccess:()=>{r.invalidateQueries({queryKey:[`projects`]}),i(n(`projectDetail.toast.templateCreated`),`success`)},onError:e=>i(e.message,`error`)}),Ne=e=>bf(e,N,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});if(v)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});if(b||!_)return(0,K.jsxs)(`div`,{className:`text-center py-24`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:b?`${n(`common.error`)}: ${b.message}`:n(`projectDetail.notFound`)}),(0,K.jsx)($,{variant:`secondary`,className:`mt-4`,onClick:()=>t(`/projects`),children:n(`projectDetail.backToProjects`)})]});let Pe=_.stats,Fe=Pe?.progress_percent??0,Ie=Pe?.parts_progress_percent??0;return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(wi,{to:`/projects`,className:`hover:text-white transition-colors`,children:n(`nav.projects`)}),(0,K.jsx)(as,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-white`,children:_.name})]}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`button`,{onClick:()=>t(`/projects`),className:`p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsx)(jo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full shrink-0`,style:{backgroundColor:_.color||`#6b7280`}}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:_.name}),_.description&&(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:_.description})]})]}),(0,K.jsx)(FUe,{status:_.status,t:n})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:je,disabled:!a(`projects:read`),title:a(`projects:read`)?n(`projectDetail.exportProject`):n(`projectDetail.noExportPermission`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),n(`projectDetail.export`)]}),(0,K.jsxs)($,{onClick:()=>s(!0),disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-2`}),n(`common.edit`)]})]})]}),(_.target_count||_.target_parts_count)&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4 space-y-4`,children:[_.target_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.progress.platesProgress`)}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[Pe?.total_archives||0,` / `,_.target_count,` `,n(`projectDetail.progress.printJobs`)]})]}),(0,K.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(Fe,100)}%`,backgroundColor:Fe>=100?`#22c55e`:_.color||`#6b7280`}})}),(0,K.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.percentComplete`,{percent:Fe.toFixed(0)})}),Pe?.remaining_prints!=null&&Pe.remaining_prints>0&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.remaining`,{count:Pe.remaining_prints})})]})]}),_.target_parts_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.progress.partsProgress`)}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[Pe?.completed_prints||0,` / `,_.target_parts_count,` `,n(`projectDetail.progress.parts`)]})]}),(0,K.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(Ie,100)}%`,backgroundColor:Ie>=100?`#22c55e`:_.color||`#6b7280`}})}),(0,K.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.percentComplete`,{percent:Ie.toFixed(0)})}),Pe?.remaining_parts!=null&&Pe.remaining_parts>0&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.remaining`,{count:Pe.remaining_parts})})]})]})]})}),Pe&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark text-bambu-green`,children:(0,K.jsx)(pl,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.stats.printJobs`)}),(0,K.jsxs)(`p`,{className:`text-xl font-semibold text-white`,children:[Pe.total_archives,` `,(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:n(`projectDetail.stats.total`)})]}),Pe.failed_prints>0&&(0,K.jsx)(`p`,{className:`text-sm text-status-error`,children:n(`projectDetail.stats.failed`,{count:Pe.failed_prints})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.stats.partsPrinted`,{count:Pe.completed_prints})})]})]})})}),(0,K.jsx)(A6,{icon:Ss,label:n(`projectDetail.stats.printTime`),value:Ef(Pe.total_print_time_hours),color:`text-yellow-400`}),(0,K.jsx)(A6,{icon:Tl,label:n(`projectDetail.stats.filamentUsed`),value:PUe(Pe.total_filament_grams),color:`text-purple-400`})]}),Pe&&(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost;return Pe.estimated_cost>0||e>0||_.budget!==null})()&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white mb-3`,children:n(`projectDetail.cost.title`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.filamentCost`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[M,Pe.estimated_cost.toFixed(2)]})]}),Pe.total_energy_kwh>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.energy`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[Pe.total_energy_kwh.toFixed(3),` kWh`,Pe.total_energy_cost>0&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray ml-1`,children:[`(`,M,Pe.total_energy_cost.toFixed(2),`)`]})]})]}),(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost;return e<=0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.totalCost`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-bambu-green`,children:[M,e.toFixed(2)]}),Pe.bom_cost>0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.cost.includesBom`)})]})})(),_.budget!==null&&(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost,t=_.budget-e;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.budget`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[n(`projectDetail.cost.total`),`: `,(0,K.jsxs)(`span`,{className:`text-white font-semibold`,children:[M,_.budget.toFixed(2)]})]}),(0,K.jsxs)(`p`,{className:`text-sm ${t>=0?`text-bambu-green`:`text-red-400`}`,children:[n(`projectDetail.cost.remaining`),`: `,(0,K.jsxs)(`span`,{className:`font-semibold`,children:[M,t.toFixed(2)]})]})]})})()]})]})}),_.children&&_.children.length>0&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-3`,children:[(0,K.jsx)(dc,{className:`w-5 h-5`}),n(`projectDetail.subProjects.title`,{count:_.children.length})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:_.children.map(e=>(0,K.jsxs)(wi,{to:`/projects/${e.id}`,className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full`,style:{backgroundColor:e.color||`#6b7280`}}),(0,K.jsx)(`span`,{className:`text-white`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded ${e.status===`completed`?`bg-status-ok/20 text-status-ok`:e.status===`archived`?`bg-bambu-gray/20 text-bambu-gray`:`bg-blue-500/20 text-blue-400`}`,children:e.status})]}),e.progress_percent!==null&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e.progress_percent.toFixed(0),`%`]})]},e.id))})]})}),_.parent_id&&_.parent_name&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.partOf`)}),(0,K.jsx)(wi,{to:`/projects/${_.parent_id}`,className:`text-bambu-green hover:underline`,children:_.parent_name})]}),(_.tags||_.due_date||_.priority!==`normal`)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[_.priority&&_.priority!==`normal`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.priorityLabel`)}),(0,K.jsx)(LUe,{priority:_.priority,t:n})]}),_.due_date&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:yf(_.due_date,{year:`numeric`,month:`short`,day:`numeric`})}),j6(_.due_date,n)&&(0,K.jsxs)(`span`,{className:`text-xs ${j6(_.due_date,n).color}`,children:[`(`,j6(_.due_date,n).label,`)`]})]}),_.tags&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:_.tags.split(`,`).map((e,t)=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded`,children:e.trim()},t))})]})]}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-5 h-5`}),n(`projectDetail.notes.title`)]}),c?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:L,disabled:P.isPending,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mr-1`}),n(`common.cancel`)]}),(0,K.jsxs)($,{size:`sm`,onClick:I,disabled:P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}):(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),n(`common.save`)]})]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:F,disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.notes.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-1`}),n(`common.edit`)]})]}),c?(0,K.jsx)(X0,{content:u,onChange:d,placeholder:n(`projectDetail.notes.placeholder`)}):_.notes?(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:VG.sanitize(_.notes)}}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.notes.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(cc,{className:`w-5 h-5`}),n(`projectDetail.files.title`)]})}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:[(0,K.jsx)(wi,{to:`/files`,className:`text-bambu-green hover:underline`,children:n(`projectDetail.files.linkFolders`)}),` `,n(`projectDetail.files.forQuickAccess`)]}),O&&O.length>0?(0,K.jsx)(`div`,{className:`space-y-4`,children:O.map(e=>{let t=j.get(e.id)??[],r=A;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(wi,{to:`/files?folder=${e.id}`,className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(cc,{className:`w-5 h-5 text-bambu-green shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`projectDetail.files.fileCount`,{count:e.file_count})})]})]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray shrink-0`})]}),r?(0,K.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-bambu-gray text-sm`,children:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`})}):t.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray/60 text-xs italic px-3`,children:n(`projectDetail.files.noFiles`)}):(0,K.jsx)(`div`,{className:`space-y-1 pl-3`,children:t.map(e=>{let t=NUe(e.filename);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 shrink-0 rounded bg-bambu-dark overflow-hidden flex items-center justify-center`,children:e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getLibraryFileThumbnailUrl(e.id),alt:e.print_name||e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(Qs,{className:`w-5 h-5 text-bambu-gray/40`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,title:e.print_name||e.filename,children:e.print_name||e.filename}),(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded font-medium ${e.file_type===`3mf`?`bg-bambu-green/20 text-bambu-green`:e.file_type===`gcode`||e.file_type===`gcode.3mf`?`bg-blue-500/20 text-blue-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:e.file_type.toUpperCase()})]}),t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:()=>p(e),title:n(`projectDetail.files.print`),className:`p-1.5 rounded hover:bg-bambu-green/20 text-bambu-green transition-colors`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>h(e),title:n(`projectDetail.files.addToQueue`),className:`p-1.5 rounded hover:bg-blue-500/20 text-blue-400 transition-colors`,children:(0,K.jsx)(Xo,{className:`w-4 h-4`})})]})]},e.id)})})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.files.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Jl,{className:`w-5 h-5`}),n(`projectDetail.bom.title`),Pe&&Pe.bom_total_items>0&&(0,K.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n(`projectDetail.bom.acquired`,{completed:Pe.bom_completed_items,total:Pe.bom_total_items}),`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C&&C.some(e=>e.is_complete)&&(0,K.jsx)(`button`,{onClick:()=>se(!U),className:`text-xs px-2 py-1 rounded transition-colors ${U?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:n(U?`projectDetail.bom.showAll`:`projectDetail.bom.hideDone`)}),!ae&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>oe(!0),disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.bom.noAddPermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),n(`projectDetail.bom.addPart`)]})]})]}),ae&&(0,K.jsxs)(`form`,{onSubmit:Te,className:`bg-bambu-dark rounded-lg p-4 mb-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.partNamePlaceholder`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:B,onChange:e=>V(parseInt(e.target.value)||1),className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:`1`,placeholder:n(`projectDetail.bom.qty`)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,value:ee,onChange:e=>te(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.price`,{currency:M})})]})]}),(0,K.jsx)(`input`,{type:`url`,value:ne,onChange:e=>re(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,K.jsx)(`input`,{type:`text`,value:ie,onChange:e=>H(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.remarksPlaceholder`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>oe(!1),children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:!R.trim()||Se.isPending,children:Se.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`projectDetail.bom.addPart`)})]})]}),w?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):C&&C.length>0?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[C.filter(e=>!U||!e.is_complete).map(e=>(0,K.jsx)(`div`,{className:`p-3 rounded-lg transition-colors ${e.is_complete?`bg-status-ok/10`:`bg-bambu-dark`}`,children:ce?.id===e.id?(0,K.jsxs)(`form`,{onSubmit:ke,className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:ue,onChange:e=>de(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.partName`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:fe,onChange:e=>pe(parseInt(e.target.value)||1),className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:`1`,placeholder:n(`projectDetail.bom.qty`)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,value:me,onChange:e=>he(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.price`,{currency:M})})]})]}),(0,K.jsx)(`input`,{type:`url`,value:ge,onChange:e=>_e(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,K.jsx)(`input`,{type:`text`,value:ve,onChange:e=>ye(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.remarksPlaceholder`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:Ae,children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:!ue.trim()||Ce.isPending,children:Ce.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`common.save`)})]})]}):(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&Ee(e),disabled:Ce.isPending||!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.bom.noUpdatePermission`),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors shrink-0 ${e.is_complete?`bg-status-ok border-status-ok text-white`:a(`projects:update`)?`border-bambu-gray hover:border-bambu-green`:`border-bambu-gray/50 cursor-not-allowed`}`,children:e.is_complete&&(0,K.jsx)(ps,{className:`w-3 h-3`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm font-medium ${e.is_complete?`text-bambu-gray line-through`:`text-white`}`,children:[e.name,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal ml-2`,children:[`x`,e.quantity_needed]})]}),e.unit_price!==null&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-green whitespace-nowrap`,children:[M,(e.unit_price*e.quantity_needed).toFixed(2)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&Oe(e),disabled:!a(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${a(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`projects:update`)?n(`common.edit`):n(`projectDetail.bom.noEditPermission`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&De(e.id,e.name),disabled:!a(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${a(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`projects:update`)?n(`common.delete`):n(`projectDetail.bom.noDeletePermission`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]}),e.sourcing_url&&(0,K.jsxs)(`a`,{href:e.sourcing_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(Js,{className:`w-3 h-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:(()=>{try{return new URL(e.sourcing_url).hostname.replace(`www.`,``)}catch{return e.sourcing_url}})()})]}),e.remarks&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray/80 italic`,children:e.remarks})]})]})},e.id)),Pe&&Pe.bom_cost>0&&(0,K.jsxs)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.bom.totalCost`)}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[M,Pe.bom_cost.toFixed(2)]})]})]}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.bom.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(kc,{className:`w-5 h-5`}),n(`projectDetail.timeline.title`)]})}),E?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):T&&T.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:T.slice(0,10).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${e.event_type===`print_completed`?`bg-status-ok/20 text-status-ok`:e.event_type===`print_failed`?`bg-status-error/20 text-status-error`:e.event_type===`print_started`?`bg-yellow-500/20 text-yellow-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[e.event_type===`print_completed`&&(0,K.jsx)(ps,{className:`w-4 h-4`}),e.event_type===`print_failed`&&(0,K.jsx)(ys,{className:`w-4 h-4`}),e.event_type===`print_started`&&(0,K.jsx)(Tl,{className:`w-4 h-4`}),e.event_type===`queued`&&(0,K.jsx)(Wc,{className:`w-4 h-4`}),e.event_type===`project_created`&&(0,K.jsx)(Sl,{className:`w-4 h-4`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.title}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.description}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:Ne(e.timestamp)})]})]},t))}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.timeline.empty`)})]})}),!_.is_template&&(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Me.mutate(),disabled:Me.isPending||!a(`projects:create`),title:a(`projects:create`)?void 0:n(`projectDetail.template.noCreatePermission`),children:[Me.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Ms,{className:`w-4 h-4 mr-2`}),n(`projectDetail.template.saveAsTemplate`)]})}),Pe&&(Pe.queued_prints>0||Pe.in_progress_prints>0)&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Wc,{className:`w-5 h-5`}),n(`projectDetail.queue.title`)]}),(0,K.jsx)(wi,{to:`/queue?project=${g}`,className:`text-sm text-bambu-green hover:underline`,children:n(`projectDetail.queue.viewAll`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[Pe.in_progress_prints>0&&(0,K.jsx)(`span`,{className:`text-yellow-400`,children:n(`projectDetail.queue.printing`,{count:Pe.in_progress_prints})}),Pe.queued_prints>0&&(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.queue.queued`,{count:Pe.queued_prints})})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5`}),n(`projectDetail.prints.title`,{count:x?.length||0})]})}),S?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,K.jsx)(IUe,{archives:x||[],t:n})]}),o&&(0,K.jsx)(k6,{t:n,currencySymbol:M,project:{..._,archive_count:Pe?.total_archives||0,total_items:Pe?.total_items||0,completed_count:Pe?.completed_prints||0,failed_count:Pe?.failed_prints||0,queue_count:Pe?.queued_prints||0,progress_percent:Pe?.progress_percent||null,archives:[]},onClose:()=>s(!1),onSave:e=>P.mutate(e),isLoading:P.isPending}),be.isOpen&&(0,K.jsx)(Ad,{title:be.title,message:be.message,confirmText:n(`common.delete`),variant:`danger`,onConfirm:be.onConfirm,onCancel:()=>xe(e=>({...e,isOpen:!1}))}),f&&(0,K.jsx)(oW,{mode:`reprint`,libraryFileId:f.id,archiveName:f.print_name||f.filename,projectId:g,onClose:()=>p(null),onSuccess:()=>{p(null),r.invalidateQueries({queryKey:[`archives`]})}}),m&&(0,K.jsx)(oW,{mode:`add-to-queue`,libraryFileId:m.id,archiveName:m.print_name||m.filename,projectId:g,onClose:()=>h(null),onSuccess:()=>{h(null),r.invalidateQueries({queryKey:[`queue`]})}})]})}function zUe({archiveId:e,libraryFileId:t,title:n,fileType:r,onClose:i,onSliceWithBambuddy:a}){let{t:o}=W(),{data:s}=q({queryKey:[`settings`],queryFn:Q.getSettings}),c=s?.open_in_slicer||s?.preferred_slicer||`bambu_studio`,l=t!=null,[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(!0),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(0),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),N=(0,y.useRef)(null),P=(0,y.useRef)(null),F=.35;(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,y.useEffect)(()=>{if(h(!0),l){let e=(r||``).toLowerCase(),t=e===`3mf`||e===`gcode.3mf`,n=t||e===`stl`,i=t||e===`gcode`;p({has_model:n,has_gcode:i,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(n?`3d`:i?`gcode`:null),h(!1);return}if(!e){p(null),d(null),h(!1);return}Q.getArchiveCapabilities(e).then(e=>{p(e),e.has_model?d(`3d`):e.has_gcode&&d(`gcode`),h(!1)}).catch(()=>{p({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(`3d`),h(!1)})},[e,r,l]),(0,y.useEffect)(()=>{if(b(!0),S(null),w(0),l){let e=(r||``).toLowerCase();if(!t||!(e===`3mf`||e===`gcode.3mf`)){_(null),b(!1);return}Q.getLibraryFilePlates(t).then(e=>_(e)).catch(()=>_(null)).finally(()=>b(!1));return}if(!e){_(null),b(!1);return}Q.getArchivePlates(e).then(e=>_(e)).catch(()=>_(null)).finally(()=>b(!1))},[e,r,l,t]);let I=(0,y.useMemo)(()=>g?.plates??[],[g]),L=(g?.is_multi_plate??!1)&&I.length>1,R=T&&L,z=x==null?null:I.find(e=>e.index===x)??null,B=e=>e.object_count??e.objects?.length??0,V=I.reduce((e,t)=>e+B(t),0),ee=z?B(z):V,te=z?o(`modelViewer.plateNumber`,{number:z.index}):o(`modelViewer.allPlates`),ne=I.length>0,re=(0,y.useRef)(null),ie=(0,y.useRef)(null),[H,ae]=(0,y.useState)(10),[oe,U]=(0,y.useState)(3),se=I.length>H,ce=Math.max(1,Math.ceil(I.length/H)),le=se?I.slice(C*H,(C+1)*H):I;(0,y.useEffect)(()=>{if(!R){ae(10),U(3);return}let e=re.current,t=ie.current;if(!e||!t)return;let n=0,r=()=>{let n=t.clientWidth,r=Math.floor(n/210),i=Math.max(3,Math.min(5,r||3));U(e=>e===i?e:i);let a=window.getComputedStyle(e),o=Number.parseFloat(a.rowGap||`0`),s=e.querySelector(`button`)?.getBoundingClientRect().height??44,c=t.clientHeight,l=Math.max(1,Math.floor((c+o)/(s+o)))*i,u=Math.max(1,l-1);ae(e=>e===u?e:u)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};i();let a=new ResizeObserver(i);return a.observe(t),a.observe(e),()=>{n&&cancelAnimationFrame(n),a.disconnect()}},[R,I.length]),(0,y.useEffect)(()=>{if(!se){w(0);return}w(e=>Math.min(e,ce-1))},[I.length,se,ce]),(0,y.useEffect)(()=>{if(!se||x==null)return;let e=I.findIndex(e=>e.index===x);if(e<0)return;let t=Math.floor(e/H);w(e=>e===t?e:t)},[I,H,x,se]),(0,y.useEffect)(()=>{if(!R){O(null),M(!1);return}if(j)return;let e=N.current,t=P.current;if(!e||!t)return;let n=e.clientHeight;if(!n)return;let r=Math.max(240,n*F),i=Math.max(160,n-10-r),a=Math.min(t.scrollHeight,i);O(Math.max(160,a))},[R,j,I.length,C,10,160,240,F]),(0,y.useEffect)(()=>{if(!k)return;let e=e=>{let t=N.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.height;if(!r)return;let i=Math.max(240,r*F),a=Math.max(160,r-10-i);O(Math.min(a,Math.max(160,e.clientY-n.top)))},t=()=>{A(!1),M(!0)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`,()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[k,10,160,240,F]);let ue=l?(r||``).toLowerCase()===`3mf`:!0,de=(()=>{let e=(r||``).toLowerCase();return e===`3mf`||e===`stl`||e===`step`||e===`stp`})(),fe=!!(l&&s?.use_slicer_api&&a&&de);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 ${T?`p-0`:`p-8`}`,onClick:i,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary w-full flex flex-col ${T?`h-full max-w-none rounded-none`:`h-[80vh] max-w-4xl rounded-xl`}`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1 mr-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:n}),ne&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap`,children:[te,`: `,o(`modelViewer.objectCount`,{count:ee})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[fe?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:a,children:[(0,K.jsx)(ks,{className:`w-4 h-4`}),o(`slice.action`)]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:async()=>{if(!ue)return;let r=n||`model`;try{if(l){let{token:e}=await Q.createLibrarySlicerToken(t),n=Q.getLibrarySlicerDownloadUrl(t,e,r);VW(`${window.location.origin}${n}`,c)}else{let{token:t}=await Q.createArchiveSlicerToken(e),n=Q.getArchiveSlicerDownloadUrl(e,t,r);VW(`${window.location.origin}${n}`,c)}}catch{VW(l?`${window.location.origin}${Q.getLibraryFileDownloadUrl(t)}`:`${window.location.origin}${Q.getArchiveForSlicer(e,r)}`,c)}},disabled:!ue,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),o(`modelViewer.openInSlicer`)]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>E(e=>!e),title:T?`Exit fullscreen`:`Enter fullscreen`,children:T?(0,K.jsx)(rl,{className:`w-4 h-4`}):(0,K.jsx)($c,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),f&&(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>f.has_model&&d(`3d`),disabled:!f.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u===`3d`?`text-bambu-green border-b-2 border-bambu-green`:f.has_model?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),o(`modelViewer.tabs.model`),!f.has_model&&(0,K.jsxs)(`span`,{className:`text-xs`,children:[`(`,o(`modelViewer.notAvailable`),`)`]})]}),(0,K.jsxs)(`button`,{onClick:()=>f.has_gcode&&d(`gcode`),disabled:!f.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u===`gcode`?`text-bambu-green border-b-2 border-bambu-green`:f.has_gcode?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Ts,{className:`w-4 h-4`}),o(`modelViewer.tabs.gcode`),!f.has_gcode&&(0,K.jsxs)(`span`,{className:`text-xs`,children:[`(`,o(`modelViewer.notSliced`),`)`]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden p-4`,children:m?(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})}):u===`3d`&&f?(0,K.jsxs)(`div`,{ref:N,className:`w-full h-full flex flex-col ${R?`gap-0 min-h-0`:`gap-3`}`,children:[L&&(0,K.jsxs)(`div`,{ref:P,style:R&&D!=null?{height:D}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${R?`flex flex-col shrink-0`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4`}),o(`modelViewer.plates`),v&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})]}),(0,K.jsxs)(`div`,{className:R?`flex flex-col min-h-0 flex-1`:void 0,children:[(0,K.jsx)(`div`,{ref:ie,className:R?`min-h-0 overflow-hidden pr-1 flex-1`:void 0,children:(0,K.jsxs)(`div`,{ref:re,className:R?`grid gap-2`:`grid grid-cols-2 md:grid-cols-3 gap-2`,style:R?{gridTemplateColumns:`repeat(${oe}, minmax(0, 1fr))`}:void 0,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>S(null),className:`flex items-center rounded-lg border text-left transition-colors ${R?`gap-1.5 p-1.5 w-full`:`gap-2 p-2`} ${x==null?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`div`,{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${R?`w-8 h-8`:`w-10 h-10`}`,children:(0,K.jsx)(Rc,{className:`${R?`w-4 h-4`:`w-5 h-5`} text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`${R?`text-xs`:`text-sm`} text-white font-medium truncate`,children:o(`modelViewer.allPlates`)}),(0,K.jsx)(`p`,{className:`${R?`text-[10px]`:`text-xs`} text-bambu-gray truncate`,children:o(`modelViewer.plateCount`,{count:I.length})})]}),x==null&&(0,K.jsx)(rs,{className:`${R?`w-3.5 h-3.5`:`w-4 h-4`} text-bambu-green flex-shrink-0`})]}),le.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>S(e.index),className:`flex items-center rounded-lg border text-left transition-colors ${R?`gap-1.5 p-1.5 w-full`:`gap-2 p-2`} ${x===e.index?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[e.has_thumbnail&&e.thumbnail_url?(0,K.jsx)(`img`,{src:e.thumbnail_url,alt:`Plate ${e.index}`,className:`${R?`w-8 h-8`:`w-10 h-10`} rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${R?`w-8 h-8`:`w-10 h-10`}`,children:(0,K.jsx)(Rc,{className:`${R?`w-4 h-4`:`w-5 h-5`} text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`${R?`text-xs`:`text-sm`} text-white font-medium truncate`,children:e.name||o(`modelViewer.plateNumber`,{number:e.index})}),(0,K.jsx)(`p`,{className:`${R?`text-[10px]`:`text-xs`} text-bambu-gray truncate`,children:o(`modelViewer.objectCount`,{count:e.object_count??e.objects?.length??0})})]}),x===e.index&&(0,K.jsx)(rs,{className:`${R?`w-3.5 h-3.5`:`w-4 h-4`} text-bambu-green flex-shrink-0`})]},e.index))]})}),(z||se)&&(0,K.jsxs)(`div`,{className:`mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto`,children:[z&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 whitespace-nowrap`,children:[(0,K.jsx)(`span`,{children:o(`modelViewer.plateNumber`,{number:z.index})}),z.print_time_seconds!=null&&(0,K.jsx)(`span`,{children:o(`modelViewer.eta`,{minutes:Math.round(z.print_time_seconds/60)})}),z.filament_used_grams!=null&&(0,K.jsxs)(`span`,{children:[z.filament_used_grams.toFixed(1),` g`]}),z.filaments.length>0&&(0,K.jsx)(`span`,{children:o(`modelViewer.filamentCount`,{count:z.filaments.length})})]}),se&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 whitespace-nowrap ${z?`ml-auto`:``}`,children:[(0,K.jsx)(`span`,{children:o(`modelViewer.pagination.pageOf`,{current:C+1,total:ce})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e=>Math.max(e-1,0)),disabled:C===0,className:`px-2 py-1 rounded border text-xs ${C===0?`border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:o(`modelViewer.pagination.prev`)}),(()=>{let e=Math.max(0,C-2),t=Math.min(ce,e+5);t-e<5&&(e=Math.max(0,t-5));let n=Array.from({length:t-e},(t,n)=>e+n);return(0,K.jsxs)(K.Fragment,{children:[e>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(0),className:`px-2 py-1 rounded border text-xs ${C===0?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:`1`}),e>1&&(0,K.jsx)(`span`,{className:`px-1`,children:`…`}),n.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e),className:`px-2 py-1 rounded border text-xs ${C===e?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:e+1},e)),tw(ce-1),className:`px-2 py-1 rounded border text-xs ${C===ce-1?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:ce})]})})(),(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e=>Math.min(e+1,ce-1)),disabled:C>=ce-1,className:`px-2 py-1 rounded border text-xs ${C>=ce-1?`border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:o(`modelViewer.pagination.next`)})]})]})]})]})]}),R&&(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,onMouseDown:e=>{e.preventDefault(),A(!0),M(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${k?`bg-bambu-dark-tertiary`:`bg-bambu-dark-secondary/60 hover:bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`div`,{className:`w-12 h-1 rounded-full bg-bambu-gray/50`})}),(0,K.jsx)(`div`,{className:`flex-1 ${R?`min-h-0`:``}`,children:(0,K.jsx)(ly,{url:l?Q.getLibraryFileDownloadUrl(t):f.has_source?Q.getSource3mfDownloadUrl(e):Q.getArchiveDownload(e),fileType:r,buildVolume:f.build_volume,filamentColors:f.filament_colors,selectedPlateId:x,className:`w-full h-full`})})]}):u===`gcode`&&f?(0,K.jsx)(iT,{gcodeUrl:l?Q.getLibraryFileGcodeUrl(t):Q.getArchiveGcode(e),filamentColors:f.filament_colors,className:`w-full h-full`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:o(`modelViewer.noPreview`)})})]})})}var M6=[`library-tags`];function BUe({open:e,fileIds:t,onClose:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(`add`),[c,l]=(0,y.useState)(new Set),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``);(0,y.useEffect)(()=>{e||(s(`add`),l(new Set),d(``),p(``))},[e]);let{data:m=[],isLoading:h}=q({queryKey:M6,queryFn:Q.getLibraryTags,enabled:e}),g=(0,y.useMemo)(()=>{let e=u.trim().toLowerCase();return e?m.filter(t=>t.name.toLowerCase().includes(e)):m},[m,u]),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=J({mutationFn:e=>Q.createLibraryTag(e),onSuccess:e=>{l(t=>new Set(t).add(e.id)),p(``),i.invalidateQueries({queryKey:M6})},onError:e=>{a(e.message||r(`fileManager.tags.saveFailed`),`error`)}}),b=J({mutationFn:()=>Q.bulkAssignLibraryTags(t,Array.from(c),o),onSuccess:e=>{a(o===`add`?r(`fileManager.tags.applyAddSuccess`,{count:e.associations_added,files:e.files_updated}):r(`fileManager.tags.applyRemoveSuccess`,{count:e.associations_removed,files:e.files_updated}),`success`),i.invalidateQueries({queryKey:[`library-files`]}),i.invalidateQueries({queryKey:M6}),n()},onError:e=>{a(e.message||r(`fileManager.tags.applyFailed`),`error`)}});if((0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&!b.isPending&&!v.isPending&&n()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,b.isPending,v.isPending]),!e)return null;let x=!f.trim()||v.isPending||m.some(e=>e.name.toLowerCase()===f.trim().toLowerCase()),S=`bulk-tags-picker-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>!b.isPending&&n()}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":S,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h3`,{id:S,className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-green`}),r(`fileManager.tags.bulkTitle`,{count:t.length})]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:n,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`px-5 py-3 border-b border-bambu-dark-tertiary flex gap-4 text-sm`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`bulk-action`,checked:o===`add`,onChange:()=>s(`add`),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:r(`fileManager.tags.actionAdd`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`bulk-action`,checked:o===`remove`,onChange:()=>s(`remove`),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:r(`fileManager.tags.actionRemove`)})]})]}),(0,K.jsx)(`div`,{className:`px-5 py-3 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:r(`fileManager.tags.searchPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 min-h-[8rem] max-h-[24rem]`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-12 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),r(`common.loading`)]}):g.length===0?(0,K.jsx)(`div`,{className:`py-12 text-center text-bambu-gray text-sm`,children:m.length===0?r(`fileManager.tags.empty`):r(`fileManager.tags.noMatches`)}):(0,K.jsx)(`ul`,{className:`divide-y divide-bambu-dark-tertiary/40`,children:g.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-5 py-2 hover:bg-bambu-dark-tertiary/30 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c.has(e.id),onChange:()=>_(e.id),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate flex-1`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.file_count})]})},e.id))})}),o===`add`&&(0,K.jsxs)(`div`,{className:`px-5 py-3 border-t border-bambu-dark-tertiary flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:r(`fileManager.tags.createPlaceholder`),maxLength:64,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,onKeyDown:e=>{e.key===`Enter`&&!x&&(e.preventDefault(),v.mutate(f.trim()))}}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>v.mutate(f.trim()),disabled:x,children:[v.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`fileManager.tags.createButton`)]})]}),(0,K.jsxs)(`div`,{className:`px-5 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:n,disabled:b.isPending,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`button`,onClick:()=>b.mutate(),disabled:c.size===0||b.isPending||t.length===0,children:[b.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(o===`add`?`fileManager.tags.applyAdd`:`fileManager.tags.applyRemove`)]})]})]})]})}function VUe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var HUe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,UUe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,WUe={};function N6(e,t){return((t||WUe).jsx?UUe:HUe).test(e)}var GUe=/[ \t\n\f\r]/g;function KUe(e){return typeof e==`object`?e.type===`text`?P6(e.value):!1:P6(e)}function P6(e){return e.replace(GUe,``)===``}var F6=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};F6.prototype.normal={},F6.prototype.property={},F6.prototype.space=void 0;function I6(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new F6(n,r,t)}function L6(e){return e.toLowerCase()}var R6=class{constructor(e,t){this.attribute=t,this.property=e}};R6.prototype.attribute=``,R6.prototype.booleanish=!1,R6.prototype.boolean=!1,R6.prototype.commaOrSpaceSeparated=!1,R6.prototype.commaSeparated=!1,R6.prototype.defined=!1,R6.prototype.mustUseProperty=!1,R6.prototype.number=!1,R6.prototype.overloadedBoolean=!1,R6.prototype.property=``,R6.prototype.spaceSeparated=!1,R6.prototype.space=void 0;var z6=s({boolean:()=>B6,booleanish:()=>V6,commaOrSpaceSeparated:()=>K6,commaSeparated:()=>G6,number:()=>U6,overloadedBoolean:()=>H6,spaceSeparated:()=>W6}),qUe=0,B6=q6(),V6=q6(),H6=q6(),U6=q6(),W6=q6(),G6=q6(),K6=q6();function q6(){return 2**++qUe}var J6=Object.keys(z6),Y6=class extends R6{constructor(e,t,n,r){let i=-1;if(super(e,t),X6(this,`space`,r),typeof n==`number`)for(;++i4&&n.slice(0,4)===`data`&&QUe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(i8,tWe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!i8.test(e)){let n=e.replace(ZUe,eWe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Y6}return new i(r,t)}function eWe(e){return`-`+e.toLowerCase()}function tWe(e){return e.charAt(1).toUpperCase()}var nWe=I6([Q6,JUe,t8,n8,r8],`html`),a8=I6([Q6,YUe,t8,n8,r8],`svg`);function rWe(e){return e.join(` `).trim()}var iWe=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=` +`+n+`}`}return String(e)}function bUe({setting:e,onClose:t,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:a,t:o}){let{showToast:s}=Td(),c=no(),[l,u]=(0,y.useState)(!1),{data:d,isLoading:f}=q({queryKey:[`cloudSettingDetail`,e.setting_id],queryFn:()=>Q.getCloudSettingDetail(e.setting_id)}),p=J({mutationFn:()=>Q.deleteCloudSetting(e.setting_id),onSuccess:()=>{s(o(`profiles.presets.toast.deleted`)),c.invalidateQueries({queryKey:[`cloudSettings`]}),n()},onError:e=>s(e.message,`error`)}),m=_6(e.setting_id),h=g6(e.name,d?.setting?.inherits);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white truncate`,children:e.name}),m&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full`,children:o(`profiles.presets.editable`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`capitalize`,children:o(`profiles.presets.types.${e.type}`)}),h.printer&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{children:`•`}),(0,K.jsx)(`span`,{children:h.printer})]})]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):d?(0,K.jsx)(`pre`,{className:`text-xs text-bambu-gray font-mono whitespace-pre-wrap break-all bg-bambu-dark p-4 rounded-lg border border-bambu-dark-tertiary overflow-x-auto max-w-full`,children:b6(d)}):(0,K.jsx)(`div`,{className:`text-center py-16 text-bambu-gray`,children:o(`profiles.presets.failedToLoadDetails`)})}),l?(0,K.jsxs)(`div`,{className:`flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5`}),(0,K.jsx)(`span`,{className:`font-medium`,children:o(`profiles.presets.deleteConfirm`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:o(`profiles.presets.deleteWarning`,{name:e.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>u(!1),disabled:p.isPending,className:`flex-1`,children:o(`common.cancel`)}),(0,K.jsxs)($,{variant:`danger`,onClick:()=>p.mutate(),disabled:p.isPending,className:`flex-1`,children:[p.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(bu,{className:`w-4 h-4`}),o(`common.delete`)]})]})]}):(0,K.jsx)(`div`,{className:`flex-shrink-0 p-4 border-t border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,className:`flex-1`,children:o(`common.close`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:r,disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noDuplicatePermission`),children:[(0,K.jsx)(Ms,{className:`w-4 h-4`}),o(`profiles.presets.duplicate`)]}),m&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`secondary`,onClick:i,disabled:f||!d||!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noEditPermission`),children:[(0,K.jsx)(vl,{className:`w-4 h-4`}),o(`common.edit`)]}),(0,K.jsx)($,{variant:`danger`,onClick:()=>u(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.presets.noDeletePermission`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]})})]})})})}function x6(){try{let e=localStorage.getItem(`bambusy_preset_templates`);return e?JSON.parse(e):[]}catch{return[]}}function S6(e){localStorage.setItem(`bambusy_preset_templates`,JSON.stringify(e))}function xUe({onClose:e,onApply:t,t:n}){let{showToast:r}=Td(),[i,a]=(0,y.useState)(x6),[o,s]=(0,y.useState)(`all`),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(`{}`),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(null),x=o===`all`?i:i.filter(e=>e.type===o),S=e=>{a(e),S6(e)},C=e=>{S(i.filter(t=>t.id!==e)),b(null),r(n(`profiles.templates.toast.deleted`))},w=e=>{l(e.id),d(e.name),p(e.description),h(JSON.stringify(e.settings,null,2)),_(null)},T=()=>{if(!(!c||!u.trim()))try{let e=JSON.parse(m);S(i.map(t=>t.id===c?{...t,name:u.trim(),description:f.trim(),settings:e}:t)),l(null),r(n(`profiles.templates.toast.updated`))}catch(e){_(e.message)}},E=()=>{l(null),d(``),p(``),h(`{}`),_(null)},D=e=>{S(i.map(t=>t.id===e?{...t,showInModal:!t.showInModal}:t))},O={filament:{label:n(`profiles.presets.types.filament`),icon:Hs,color:`text-amber-400`},print:{label:n(`profiles.presets.types.process`),icon:Hl,color:`text-blue-400`},printer:{label:n(`profiles.presets.types.printer`),icon:Tl,color:`text-purple-400`}},k=v?i.find(e=>e.id===v):null;return(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(v?b(null):c?E():e())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[v,c,e]),(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:[k&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-60`,children:(0,K.jsx)(_d,{className:`w-full max-w-md`,children:(0,K.jsxs)(yd,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`div`,{className:`p-2 bg-red-500/20 rounded-lg`,children:(0,K.jsx)(Cu,{className:`w-6 h-6 text-red-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:n(`profiles.templates.deleteTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`profiles.templates.deleteWarning`)})]})]}),(0,K.jsx)(`p`,{className:`text-white mb-6`,children:n(`profiles.templates.deleteConfirm`,{name:k.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>b(null),className:`flex-1`,children:n(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>C(v),className:`flex-1 bg-red-500 hover:bg-red-600`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),n(`common.delete`)]})]})]})})}),(0,K.jsx)(_d,{className:`w-full max-w-2xl max-h-[80vh] flex flex-col`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(ru,{className:`w-5 h-5 text-amber-400`}),n(`profiles.templates.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`profiles.templates.typeFilter`)}),[`all`,`filament`,`print`,`printer`].map(e=>(0,K.jsx)(`button`,{onClick:()=>s(e),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:e===`all`?n(`common.all`):O[e].label},e))]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-4`,children:x.length===0?(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(ru,{className:`w-12 h-12 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{children:n(`profiles.templates.noTemplates`)}),(0,K.jsx)(`p`,{className:`text-sm mt-1`,children:n(`profiles.templates.createFirst`)})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:x.map(e=>{let r=O[e.type],i=r.icon;return c===e.id?(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg border border-bambu-green`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 mb-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:n(`profiles.templates.namePlaceholder`),className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:n(`profiles.templates.descriptionPlaceholder`),className:`px-3 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray mb-1 block`,children:n(`profiles.templates.settingsJson`)}),(0,K.jsx)(`textarea`,{value:m,onChange:e=>{h(e.target.value),_(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${g?`border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`}),g&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:g})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{size:`sm`,onClick:T,disabled:!u.trim(),children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),`Save`]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:E,children:`Cancel`})]})]},e.id):(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsx)(i,{className:`w-5 h-5 ${r.color} flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.description})]}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded`,children:n(`profiles.templates.fieldsCount`,{count:Object.keys(e.settings).length})}),(0,K.jsx)(`button`,{onClick:()=>D(e.id),className:`p-1 transition-colors ${e.showInModal?`text-bambu-green hover:text-bambu-green/70`:`text-bambu-gray hover:text-white`}`,title:e.showInModal?n(`profiles.templates.shownInModals`):n(`profiles.templates.hiddenInModals`),children:e.showInModal?(0,K.jsx)(Xs,{className:`w-4 h-4`}):(0,K.jsx)(Ys,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>t(e),className:`px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors`,children:n(`profiles.templates.apply`)}),(0,K.jsx)(`button`,{onClick:()=>w(e),className:`p-1 text-bambu-gray hover:text-white`,title:n(`common.edit`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>b(e.id),className:`p-1 text-bambu-gray hover:text-red-400`,title:n(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]},e.id)})})})]})})]})}function C6({onClose:e,leftPreset:t,rightPreset:n,leftLabel:r,rightLabel:i,t:a}){let[o,s]=(0,y.useState)(`changes`),[c,l]=(0,y.useState)(``),u=(0,y.useMemo)(()=>{let e=new Set([...Object.keys(t),...Object.keys(n)]),r=[];for(let i of e){if(i===`inherits`||i===`version`)continue;let e=t[i],a=n[i],o=i in t,s=i in n,c;c=!o&&s?`added`:o&&!s?`removed`:JSON.stringify(e)===JSON.stringify(a)?`same`:`changed`,r.push({key:i,left:e,right:a,status:c})}return r.sort((e,t)=>{let n={changed:0,added:1,removed:2,same:3};return n[e.status]===n[t.status]?e.key.localeCompare(t.key):n[e.status]-n[t.status]})},[t,n]),d=(0,y.useMemo)(()=>{let e=[...u];if(o===`changes`&&(e=e.filter(e=>e.status!==`same`)),c){let t=c.toLowerCase();e=e.filter(e=>e.key.toLowerCase().includes(t)||String(e.left).toLowerCase().includes(t)||String(e.right).toLowerCase().includes(t))}return e},[u,o,c]),f=(0,y.useMemo)(()=>({added:u.filter(e=>e.status===`added`).length,removed:u.filter(e=>e.status===`removed`).length,changed:u.filter(e=>e.status===`changed`).length,same:u.filter(e=>e.status===`same`).length}),[u]),p=e=>{if(e===void 0)return`—`;if(e===null)return`null`;if(Array.isArray(e))return e.length===0?`[]`:e.length===1?String(e[0]):e.join(`, `);if(typeof e==`object`)return JSON.stringify(e);let t=String(e);if(t.includes(`\\n`)||t.length>100){let e=t.split(`\\n`).length;if(e>1)return`[${e} lines of G-code/script]`;if(t.length>100)return t.substring(0,100)+`…`}return t};return(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsx)(_d,{className:`w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col min-h-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(vc,{className:`w-5 h-5 text-blue-400`}),a(`profiles.diff.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`profiles.diff.left`)}),(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:r})]}),(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`profiles.diff.right`)}),(0,K.jsx)(`p`,{className:`text-white font-medium truncate`,children:i})]})]}),(0,K.jsxs)(`div`,{className:`flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-green-400`,children:[(0,K.jsx)(Sl,{className:`w-3.5 h-3.5`}),f.added,` `,a(`profiles.diff.added`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(al,{className:`w-3.5 h-3.5`}),f.removed,` `,a(`profiles.diff.removed`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-amber-400`,children:[(0,K.jsx)(No,{className:`w-3.5 h-3.5`}),f.changed,` `,a(`profiles.diff.changed`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-bambu-gray`,children:[(0,K.jsx)(Ks,{className:`w-3.5 h-3.5`}),f.same,` `,a(`profiles.diff.same`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:a(`profiles.diff.searchFields`),className:`pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none w-48`})]}),f.same>0&&(0,K.jsxs)(`div`,{className:`flex rounded overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>s(`changes`),className:`px-3 py-1.5 text-sm transition-colors ${o===`changes`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:a(`profiles.diff.changes`)}),(0,K.jsx)(`button`,{onClick:()=>s(`all`),className:`px-3 py-1.5 text-sm transition-colors ${o===`all`?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:a(`common.all`)})]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:d.length===0?(0,K.jsxs)(`div`,{className:`text-center py-12 text-bambu-gray`,children:[(0,K.jsx)(Ks,{className:`w-12 h-12 mx-auto mb-4 opacity-30`}),(0,K.jsx)(`p`,{children:a(o===`changes`?`profiles.diff.noDifferences`:`profiles.diff.noFieldsMatch`)})]}):(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{className:`sticky top-0 bg-bambu-dark-secondary`,children:(0,K.jsxs)(`tr`,{className:`text-sm text-bambu-gray border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:a(`profiles.diff.field`)}),(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:r}),(0,K.jsx)(`th`,{className:`text-left p-3 w-1/3`,children:i})]})}),(0,K.jsx)(`tbody`,{children:d.map(e=>{let t={added:`bg-green-500/10`,removed:`bg-red-500/10`,changed:`bg-amber-500/10`,same:``}[e.status],n={added:(0,K.jsx)(Sl,{className:`w-3.5 h-3.5 text-green-400`}),removed:(0,K.jsx)(al,{className:`w-3.5 h-3.5 text-red-400`}),changed:(0,K.jsx)(No,{className:`w-3.5 h-3.5 text-amber-400`}),same:(0,K.jsx)(Ks,{className:`w-3.5 h-3.5 text-bambu-gray-dark`})}[e.status];return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary ${t}`,children:[(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,(0,K.jsx)(`span`,{className:`text-sm text-white font-mono`,children:e.key})]})}),(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-mono break-all ${e.status===`removed`?`text-red-300`:e.status===`changed`?`text-white`:`text-bambu-gray`}`,children:p(e.left)})}),(0,K.jsx)(`td`,{className:`p-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-mono break-all ${e.status===`added`?`text-green-300`:e.status===`changed`?`text-white`:`text-bambu-gray`}`,children:p(e.right)})})]},e.key)})})]})})]})})})}function SUe({onClose:e,initialData:t,allPresets:n,t:r}){let{showToast:i}=Td(),a=no(),o=!!t?.setting_id,[s,c]=(0,y.useState)(`common`),[l,u]=(0,y.useState)(t?.type||`filament`),[d,f]=(0,y.useState)(t?.name?o?t.name:`${t.name} (Copy)`:``),[p,m]=(0,y.useState)(t?.base_id||``),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(t?.setting||{inherits:``}),[b,x]=(0,y.useState)(JSON.stringify(t?.setting||{inherits:``},null,2)),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(x6),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(!0),[ee,te]=(0,y.useState)(null),[ne,re]=(0,y.useState)(!1),ie=(0,y.useMemo)(()=>({filament:n.filament,print:n.process,printer:n.printer})[l]||[],[n,l]),H=(0,y.useMemo)(()=>ie.filter(e=>_6(e.setting_id)),[ie]),{data:ae}=q({queryKey:[`cloudFields`,l],queryFn:()=>Q.getCloudFields(l===`print`?`process`:l),staleTime:1e3*60*60}),{data:oe}=q({queryKey:[`allPresetDetails`,l,H.map(e=>e.setting_id).join(`,`)],queryFn:async()=>{let e={};for(let t=0;t{try{let t=await Q.getCloudSettingDetail(e.setting_id);return{id:e.setting_id,detail:t}}catch{return null}}))).forEach(t=>{t&&(e[t.id]=t.detail)})}return e},enabled:H.length>0,staleTime:1e3*60*10}),{data:U,isLoading:se}=q({queryKey:[`cloudSettingDetail`,p],queryFn:()=>Q.getCloudSettingDetail(p),enabled:!!p});(0,y.useEffect)(()=>{s!==`json`&&x(JSON.stringify(_,null,2))},[_,s]);let ce=(0,y.useMemo)(()=>({filament:n.filament,print:n.process,printer:n.printer}[l]||[]).filter(e=>!_6(e.setting_id)).sort((e,t)=>e.name.localeCompare(t.name)),[n,l]);(0,y.useEffect)(()=>{if(!p)return;let e=ce.find(e=>e.setting_id===p);e&&(g(e.name),o||(v({inherits:e.name}),x(JSON.stringify({inherits:e.name},null,2))))},[p,ce,o]);let le=(0,y.useMemo)(()=>{let e=ae?.fields||[],t=new Set(e.map(e=>e.key)),n=new Set,i=new Set([`inherits`,`updated_time`,`compatible_printers`,`compatible_prints`]);oe&&Object.values(oe).forEach(e=>{e?.setting&&Object.keys(e.setting).forEach(e=>{!t.has(e)&&!i.has(e)&&n.add(e)})}),Object.keys(_).forEach(e=>{!t.has(e)&&!i.has(e)&&n.add(e)});let a=Array.from(n).sort().map(e=>({key:e,label:e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),type:`text`,category:`discovered`,description:r(`profiles.presets.discoveredFromPresets`)}));return[...e,...a]},[ae,oe,_,r]),ue=le.filter(e=>e.label.toLowerCase().includes(w.toLowerCase())||e.key.toLowerCase().includes(w.toLowerCase())),de=()=>{if(O.trim()){let e=O.trim().toLowerCase().replace(/\s+/g,`_`);fe(e,``),k(``),j(!1),i(r(`profiles.presets.toast.fieldAdded`,{key:e}))}},fe=(e,t)=>{v(n=>{let r={...n};return t===``||t===void 0?delete r[e]:r[e]=t,r})},pe=e=>{v(t=>({...t,...e.settings})),te(e.name),i(r(`profiles.templates.toast.applied`))},me=()=>{if(!I.trim())return;let e={..._};if(delete e.inherits,Object.keys(e).length===0){i(r(`profiles.presets.noOverridesToSave`),`error`);return}let t={id:Date.now().toString(),name:I.trim(),description:R.trim()||r(`profiles.presets.customTemplate`),type:l,settings:e,showInModal:B},n=[...M,t];N(n),S6(n),F(!1),L(``),z(``),V(!0),i(r(`profiles.templates.toast.created`))},he=(0,y.useMemo)(()=>M.filter(e=>e.type===l&&e.showInModal),[l,M]),ge=e=>{x(e);try{v(JSON.parse(e)),C(null)}catch(e){C(e.message)}},_e=e=>{e.preventDefault(),D(!1);let t=e.dataTransfer.files[0];if(t&&t.name.endsWith(`.json`)){let e=new FileReader;e.onload=e=>{try{let t=e.target?.result,n=JSON.parse(t),a=n.setting||n;v(e=>({...e,...a})),x(JSON.stringify({..._,...a},null,2)),i(r(`profiles.presets.fileImported`))}catch{i(r(`profiles.presets.invalidJsonFile`),`error`)}},e.readAsText(t)}},ve=J({mutationFn:()=>{let e={..._},t=l===`filament`?`filament_settings_id`:l===`print`?`print_settings_id`:`printer_settings_id`;e[t]=`"${d}"`;let n={type:l,name:d,base_id:p,setting:e};return Q.createCloudSetting(n)},onSuccess:async()=>{i(r(`profiles.presets.toast.created`)),await a.refetchQueries({queryKey:[`cloudSettings`]}),e()},onError:e=>i(e.message,`error`)}),ye=J({mutationFn:()=>{if(!t?.setting_id)throw Error(r(`profiles.presets.noSettingId`));return Q.updateCloudSetting(t.setting_id,{name:d,setting:_})},onSuccess:async()=>{i(r(`profiles.presets.toast.updated`)),a.removeQueries({queryKey:[`cloudSettingDetail`]}),await a.refetchQueries({queryKey:[`cloudSettings`]}),e()},onError:e=>i(e.message,`error`)}),be=o?ye:ve,xe=U?.setting?.inherits,Se=xe?ce.find(e=>e.name===xe):void 0,{data:Ce}=q({queryKey:[`cloudSettingDetail`,Se?.setting_id],queryFn:()=>Q.getCloudSettingDetail(Se.setting_id),enabled:!!Se?.setting_id}),we=(0,y.useMemo)(()=>{let e=Ce?.setting||{},t=U?.setting||{},n=p&&oe?.[p]?.setting?oe[p].setting:{};return{...e,...t,...n}},[p,U,Ce,oe]),Te=e=>{if(e==null)return``;if(Array.isArray(e)){let t=[...new Set(e.map(e=>String(e)))];return t.length===1?t[0]:e.join(`, `)}return String(e)},Ee=e=>{let t=_[e.key],n=we[e.key],i=Te(n),a=se?r(`common.loading`):i||``,o=`w-full px-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`;if(e.type===`boolean`){let r=t===`1`||t===void 0&&n===`1`;return(0,K.jsx)(`button`,{type:`button`,onClick:()=>fe(e.key,t===`1`?`0`:`1`),className:`w-8 h-5 rounded-full transition-colors ${r?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${r?`translate-x-3.5`:`translate-x-0.5`}`})})}return e.type===`select`?(0,K.jsxs)(`select`,{value:t||``,onChange:t=>fe(e.key,t.target.value),className:o,children:[(0,K.jsx)(`option`,{value:``,children:a}),e.options?.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:t===void 0?``:String(t),onChange:t=>fe(e.key,t.target.value),step:e.step,min:e.min,max:e.max,placeholder:a,className:o}),e.unit&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray whitespace-nowrap`,children:e.unit})]})},De=(0,y.useMemo)(()=>U?.setting?U.setting:{},[U]);return(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onDragOver:e=>{e.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:_e,children:[ne&&p&&(0,K.jsx)(C6,{onClose:()=>re(!1),leftPreset:De,rightPreset:_,leftLabel:r(`profiles.presets.baseLabel`,{name:h||p}),rightLabel:r(`profiles.presets.currentLabel`,{name:d||r(`profiles.presets.newPreset`)}),t:r}),(0,K.jsx)(_d,{className:`w-full max-w-6xl max-h-[90vh] flex flex-col overflow-y-auto`,children:(0,K.jsxs)(yd,{className:`p-0 flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:r(o?`profiles.presets.editPreset`:t?`profiles.presets.duplicatePreset`:`profiles.presets.createNewPreset`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`profiles.presets.customizeSettings`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p&&(0,K.jsxs)(`button`,{onClick:()=>re(!0),className:`flex items-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,title:r(`profiles.presets.compareWithBase`),children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),r(`profiles.presets.compare`)]}),(0,K.jsx)(`button`,{onClick:e,className:`p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),E&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-bambu-green/10 border-2 border-dashed border-bambu-green rounded-lg flex items-center justify-center z-10`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Du,{className:`w-12 h-12 text-bambu-green mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-bambu-green font-medium`,children:r(`profiles.presets.dropJsonToImport`)})]})}),(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-4 max-[640px]:grid-cols-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`common.type`)}),(0,K.jsxs)(`select`,{value:l,onChange:e=>{u(e.target.value),m(``)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`filament`,children:r(`profiles.presets.types.filament`)}),(0,K.jsx)(`option`,{value:`print`,children:r(`profiles.presets.types.process`)}),(0,K.jsx)(`option`,{value:`printer`,children:r(`profiles.presets.types.printer`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`profiles.presets.basePreset`)}),(0,K.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:``,children:r(`profiles.presets.selectBasePreset`)}),ce.map(e=>(0,K.jsx)(`option`,{value:e.setting_id,children:e.name},e.setting_id))]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`profiles.presets.presetName`)}),(0,K.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,placeholder:r(`profiles.presets.myCustomPreset`)})]})]}),h&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:(0,K.jsxs)(`p`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(rs,{className:`w-3 h-3 text-bambu-green`}),r(`profiles.presets.inheritsFrom`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:h}),se&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin ml-1`})]})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary max-[640px]:flex-wrap max-[640px]:items-center`,children:[(0,K.jsxs)(`button`,{onClick:()=>c(`common`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`common`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)($l,{className:`w-4 h-4`}),r(`profiles.presets.tabs.common`)]}),(0,K.jsxs)(`button`,{onClick:()=>c(`fields`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`fields`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(Gc,{className:`w-4 h-4`}),r(`profiles.presets.tabs.allFields`)]}),(0,K.jsxs)(`button`,{onClick:()=>c(`json`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${s===`json`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(Es,{className:`w-4 h-4`}),`JSON`,S&&(0,K.jsx)(ds,{className:`w-3 h-3 text-red-400`})]}),(0,K.jsx)(`div`,{className:`flex-1 max-[640px]:hidden`}),(0,K.jsxs)(`button`,{onClick:()=>{let e=new Blob([JSON.stringify({name:d,type:l,base_id:p,setting:_},null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${d||`preset`}.json`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t),i(r(`profiles.presets.toast.exported`))},className:`flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors`,title:r(`profiles.presets.exportToJson`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),r(`common.download`)]}),(0,K.jsxs)(`button`,{onClick:()=>document.getElementById(`file-import`)?.click(),className:`flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors`,title:r(`profiles.presets.importFromJson`),children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),r(`common.upload`)]}),(0,K.jsx)(`input`,{id:`file-import`,type:`file`,accept:`.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];if(t){let e=new FileReader;e.onload=e=>{try{let t=JSON.parse(e.target?.result),n=t.setting||t;v(e=>({...e,...n})),i(r(`profiles.presets.fileImported`))}catch{i(r(`profiles.presets.invalidJson`),`error`)}},e.readAsText(t)}}})]}),(0,K.jsxs)(`div`,{className:`flex-1 p-4`,children:[s===`common`&&(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h3`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[(0,K.jsx)(ru,{className:`w-4 h-4 text-amber-400`}),r(`profiles.templates.title`)]}),Object.keys(_).filter(e=>e!==`inherits`).length>0&&(0,K.jsxs)(`button`,{onClick:()=>F(!P),className:`text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors`,children:[(0,K.jsx)(Nl,{className:`w-3 h-3`}),r(`profiles.presets.saveAsTemplate`)]})]}),P&&(0,K.jsxs)(`div`,{className:`mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 mb-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),placeholder:r(`profiles.templates.namePlaceholder`),className:`px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:r(`profiles.templates.descriptionPlaceholder`),className:`px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{size:`sm`,onClick:me,disabled:!I.trim(),children:[(0,K.jsx)(Nl,{className:`w-3 h-3`}),r(`common.save`)]}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>F(!1),children:r(`common.cancel`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(!B),className:`flex items-center gap-1.5 text-xs transition-colors ${B?`text-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[B?(0,K.jsx)(Xs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(Ys,{className:`w-3.5 h-3.5`}),r(B?`profiles.templates.shownInModals`:`profiles.templates.hiddenInModals`)]})]})]}),ee&&(0,K.jsxs)(`div`,{className:`mb-3 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg flex items-center gap-2`,children:[(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-green`,children:[r(`profiles.presets.templateApplied`),` `,(0,K.jsx)(`span`,{className:`font-medium`,children:ee})]}),(0,K.jsx)(`button`,{onClick:()=>te(null),className:`ml-auto text-bambu-green/70 hover:text-bambu-green`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[he.map(e=>(0,K.jsxs)(`button`,{onClick:()=>pe(e),className:`p-3 text-left bg-bambu-dark border border-bambu-dark-tertiary rounded-lg hover:border-bambu-gray-dark transition-colors`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:e.description})]},e.id)),he.length===0&&(0,K.jsx)(`p`,{className:`col-span-3 text-center text-bambu-gray text-sm py-4`,children:r(`profiles.presets.noTemplatesSelected`)})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark mt-2 text-center`,children:r(`profiles.presets.manageTemplatesHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:r(`profiles.presets.commonSettings`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-3`,children:le.slice(0,10).map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 max-[640px]:flex-col max-[640px]:items-start`,children:[(0,K.jsx)(`label`,{className:`text-sm text-bambu-gray flex-shrink-0`,children:e.label}),(0,K.jsx)(`div`,{className:`w-48 max-[640px]:w-full`,children:Ee(e)})]},e.key))})]}),Object.keys(_).length>1&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:r(`profiles.presets.currentOverrides`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Object.entries(_).filter(([e])=>e!==`inherits`).map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-green/10 text-bambu-green text-xs rounded`,children:[e,`: `,String(t).slice(0,20),(0,K.jsx)(`button`,{onClick:()=>fe(e,void 0),className:`hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})})]},e))})]})]}),s===`fields`&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-6`,style:{height:`400px`},children:[(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3 flex-shrink-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:r(`profiles.presets.availableFields`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:oe?r(`profiles.templates.fieldsCount`,{count:le.length}):r(`common.loading`)})]}),(0,K.jsxs)(`div`,{className:`relative mb-3 flex-shrink-0`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:r(`profiles.presets.searchFieldsPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-1 pr-2 min-h-0`,children:[ue.filter(e=>!(e.key in _)).map(e=>{let t=we[e.key],n=Te(t);return(0,K.jsxs)(`div`,{onClick:()=>{v(t=>({...t,[e.key]:n||``}))},className:`flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.label}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark truncate`,children:e.key})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[n&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate`,title:n,children:[n.slice(0,20),n.length>20?`...`:``]}),(0,K.jsx)(`div`,{className:`w-6 h-6 flex items-center justify-center rounded bg-bambu-dark-tertiary group-hover:bg-bambu-green/20 transition-colors`,children:(0,K.jsx)(Sl,{className:`w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors`})})]})]},e.key)}),ue.filter(e=>!(e.key in _)).length===0&&(0,K.jsx)(`p`,{className:`text-center text-bambu-gray py-4 text-sm`,children:r(w?`profiles.presets.noMatchingFields`:`profiles.presets.allFieldsAdded`)})]}),(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0`,children:A?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>e.key===`Enter`&&de(),placeholder:`custom_field_name`,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white font-mono text-sm placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`,autoFocus:!0}),(0,K.jsx)($,{size:`sm`,onClick:de,disabled:!O.trim(),children:(0,K.jsx)(Sl,{className:`w-4 h-4`})}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>{j(!1),k(``)},children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}):(0,K.jsxs)(`button`,{onClick:()=>j(!0),className:`w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors`,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`profiles.presets.addCustomField`)]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3 flex-shrink-0`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white`,children:r(`profiles.presets.yourOverrides`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:r(`profiles.templates.fieldsCount`,{count:Object.keys(_).filter(e=>e!==`inherits`).length})})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto space-y-2 pr-2 min-h-0`,children:[Object.entries(_).filter(([e])=>e!==`inherits`).map(([e,t])=>{let n=le.find(t=>t.key===e);return(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:n?.label||e}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark`,children:e})]}),(0,K.jsx)(`button`,{onClick:()=>fe(e,void 0),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),n?Ee(n):(0,K.jsx)(`input`,{type:`text`,value:String(t),onChange:t=>fe(e,t.target.value),className:`w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none`})]},e)}),Object.keys(_).filter(e=>e!==`inherits`).length===0&&(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)($l,{className:`w-8 h-8 mx-auto mb-2 opacity-50`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`profiles.presets.noOverridesYet`)}),(0,K.jsx)(`p`,{className:`text-xs mt-1`,children:r(`profiles.presets.clickFieldsToAdd`)})]})]}),Object.keys(_).filter(e=>e!==`inherits`).length>0&&(0,K.jsx)(`div`,{className:`pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsxs)(`button`,{onClick:()=>{F(!0),c(`common`)},className:`w-full flex items-center justify-center gap-2 p-2 text-sm text-bambu-gray hover:text-white border border-dashed border-bambu-dark-tertiary hover:border-bambu-gray-dark rounded-lg transition-colors`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),r(`profiles.presets.saveAsTemplate`)]})})]})]}),s===`json`&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[S&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-red-400 text-sm`,children:[(0,K.jsx)(ds,{className:`w-4 h-4`}),S]}),(0,K.jsx)(`textarea`,{value:b,onChange:e=>ge(e.target.value),className:`w-full h-80 px-3 py-2 bg-bambu-dark border rounded-lg text-white text-xs font-mono focus:outline-none resize-none ${S?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,spellCheck:!1}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`profiles.presets.jsonTip`)})]})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,K.jsxs)($,{onClick:()=>be.mutate(),disabled:be.isPending||!d.trim()||!o&&!p||!!S,className:`flex-1`,children:[be.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):o?(0,K.jsx)(Nl,{className:`w-4 h-4`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(o?`common.save`:t?`common.duplicate`:`common.create`)]})]})]})})]})}function CUe({settings:e,lastSyncTime:t,onRefresh:n,isRefreshing:r,printers:i,hasPermission:a,t:o}){let[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`all`),[d,f]=(0,y.useState)(`all`),[p,m]=(0,y.useState)(`all`),[h,g]=(0,y.useState)(`all`),[_,v]=(0,y.useState)(`all`),[b,x]=(0,y.useState)(`all`),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(null),[A,j]=(0,y.useState)(null),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)([null,null]),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(null),ee=no(),te=(0,y.useMemo)(()=>[...e.filament.map(e=>({...e,type:`filament`})),...e.printer.map(e=>({...e,type:`printer`})),...e.process.map(e=>({...e,type:`process`}))].map(e=>({...e,meta:g6(e.name)})),[e]),ne=(0,y.useMemo)(()=>{let e=new Set,t=new Set,n=new Set;return te.forEach(r=>{r.meta.nozzle&&e.add(r.meta.nozzle),r.meta.filamentType&&t.add(r.meta.filamentType),r.meta.layerHeight&&n.add(r.meta.layerHeight)}),{printers:i.map(e=>({id:e.id.toString(),name:e.name})),nozzles:Array.from(e).sort((e,t)=>parseFloat(e)-parseFloat(t)),filaments:Array.from(t).sort(),layerHeights:Array.from(n).sort((e,t)=>parseFloat(e)-parseFloat(t))}},[te,i]),re=(0,y.useMemo)(()=>p===`all`?null:i.find(e=>e.id.toString()===p)?.model||null,[p,i]),ie=(0,y.useMemo)(()=>te.filter(e=>l===`all`||e.type===l).filter(e=>{if(d===`all`)return!0;let t=_6(e.setting_id);return d===`custom`?t:!t}).filter(e=>{if(p===`all`||!re)return!0;let t=e.meta.printer?.toLowerCase()||``,n=re.toLowerCase();return t.includes(n)||n.includes(t)}).filter(e=>h===`all`||e.meta.nozzle===h).filter(e=>_===`all`||e.meta.filamentType===_).filter(e=>b===`all`||e.meta.layerHeight===b).filter(e=>s===``||e.name.toLowerCase().includes(s.toLowerCase())).sort((e,t)=>e.name.localeCompare(t.name)),[te,l,d,p,re,h,_,b,s]),H=e=>{if(P){let t=I[0]?.setting_id===e.setting_id,n=I[1]?.setting_id===e.setting_id;if(t)L([I[1],null]);else if(n)L([I[0],null]);else if(!I[0])L([e,null]);else if(I[1]){if(I[0].type!==e.type)return;L([I[0],e])}else{if(I[0].type!==e.type)return;L([I[0],e])}}else C(e)},ae=e=>{if(I[0]?.setting_id===e.setting_id)return 0;if(I[1]?.setting_id===e.setting_id)return 1},oe=async e=>{try{let t=await Q.getCloudSettingDetail(e.setting_id);k({type:e.type===`process`?`print`:e.type,name:e.name,base_id:t.base_id||`GFSA00`,setting:t.setting||{}}),C(null)}catch(e){console.error(`Failed to fetch preset details for duplication:`,e)}},U=async e=>{try{ee.removeQueries({queryKey:[`cloudSettingDetail`,e.setting_id]});let t=await Q.getCloudSettingDetail(e.setting_id);j({type:e.type===`process`?`print`:e.type,name:e.name,base_id:t.base_id||`GFSA00`,setting:t.setting||{},setting_id:e.setting_id}),C(null)}catch(e){console.error(`Failed to fetch preset details for editing:`,e)}},se=()=>{u(`all`),f(`all`),m(`all`),g(`all`),v(`all`),x(`all`),c(``)},ce=l!==`all`||d!==`all`||p!==`all`||h!==`all`||_!==`all`||b!==`all`||s!==``,le=e.filament.length+e.printer.length+e.process.length;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`space-y-4 mb-6`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:o(`profiles.cloudView.searchPlaceholder`),className:`w-full pl-10 pr-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray-dark focus:border-bambu-green focus:outline-none`})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 max-[550px]:flex-wrap max-[550px]:items-center`,children:[(0,K.jsxs)($,{variant:P?`primary`:`secondary`,onClick:()=>{P?(F(!1),L([null,null])):F(!0)},children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),o(P?`common.cancel`:`profiles.presets.compare`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>D(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noTemplatesPermission`),children:[(0,K.jsx)(ru,{className:`w-4 h-4`}),o(`profiles.cloudView.templates`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:n,disabled:r||!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noRefreshPermission`),children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${r?`animate-spin`:``}`}),o(`profiles.cloudView.refresh`)]}),(0,K.jsxs)($,{onClick:()=>T(!0),disabled:!a(`cloud:auth`),title:a(`cloud:auth`)?void 0:o(`profiles.cloudView.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),o(`profiles.cloudView.newPreset`)]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.type`),value:l,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`),count:le},{value:`filament`,label:o(`profiles.cloudView.filters.filament`),count:e.filament.length},{value:`printer`,label:o(`profiles.cloudView.filters.printer`),count:e.printer.length},{value:`process`,label:o(`profiles.cloudView.filters.process`),count:e.process.length}],onChange:e=>u(e)}),(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.owner`),value:d,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},{value:`custom`,label:o(`profiles.cloudView.filters.myPresets`)},{value:`builtin`,label:o(`profiles.cloudView.filters.builtIn`)}],onChange:e=>f(e)}),ne.printers.length>0&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.printer`),value:p,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.printers.map(e=>({value:e.id,label:e.name}))],onChange:m}),ne.nozzles.length>0&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.nozzle`),value:h,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.nozzles.map(e=>({value:e,label:e}))],onChange:g}),ne.filaments.length>0&&(l===`all`||l===`filament`)&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.filament`),value:_,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.filaments.map(e=>({value:e,label:e}))],onChange:v}),ne.layerHeights.length>0&&(l===`all`||l===`process`)&&(0,K.jsx)(v6,{label:o(`profiles.cloudView.filters.layer`),value:b,options:[{value:`all`,label:o(`profiles.cloudView.filters.all`)},...ne.layerHeights.map(e=>({value:e,label:e}))],onChange:x}),ce&&(0,K.jsx)(`button`,{onClick:se,className:`px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors`,children:o(`profiles.cloudView.clearFilters`)})]})]}),P&&(0,K.jsx)(`div`,{className:`mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(vc,{className:`w-5 h-5 text-blue-400`}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:o(`profiles.cloudView.compareMode`)}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:I[0]?o(`profiles.cloudView.selectAnotherPreset`,{type:I[0].type}):o(`profiles.cloudView.clickTwoPresets`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${I[0]?`bg-blue-500/30 text-blue-700 dark:text-blue-300`:`bg-bambu-dark text-bambu-gray`}`,children:I[0]?I[0].name:o(`profiles.cloudView.selectFirst`)}),(0,K.jsx)(No,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${I[1]?`bg-blue-500/30 text-blue-700 dark:text-blue-300`:`bg-bambu-dark text-bambu-gray`}`,children:I[1]?I[1].name:o(`profiles.cloudView.selectSecond`)})]}),I[0]&&I[1]&&(0,K.jsxs)($,{size:`sm`,onClick:async()=>{try{let[e,t]=await Promise.all([Q.getCloudSettingDetail(I[0].setting_id),Q.getCloudSettingDetail(I[1].setting_id)]);V([e.setting||{},t.setting||{}]),z(!0)}catch{}},children:[(0,K.jsx)(vc,{className:`w-4 h-4`}),o(`profiles.cloudView.compareNow`)]})]})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),o(`profiles.cloudView.lastSynced`),` `,wf(t.toISOString(),`system`,o)]}),(0,K.jsx)(`span`,{children:o(`profiles.cloudView.showingCount`,{showing:ie.length,total:le})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-green`}),(0,K.jsxs)(`span`,{children:[`= `,o(`profiles.presets.myPreset`)]})]})]}),ie.length===0?(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 text-bambu-gray-dark mx-auto mb-4`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`profiles.cloudView.noPresetsFound`)}),ce&&(0,K.jsx)(`button`,{onClick:se,className:`mt-2 text-sm text-bambu-green hover:text-bambu-green-light`,children:o(`profiles.cloudView.clearFilters`)})]}):(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Hs,{className:`w-4 h-4 text-amber-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.filament`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`filament`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`filament`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`filament`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noFilamentPresets`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Hl,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.process`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`process`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`process`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`process`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noProcessPresets`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 px-1`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`h3`,{className:`text-sm font-medium text-bambu-gray`,children:o(`profiles.cloudView.columns.printer`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray-dark`,children:[`(`,ie.filter(e=>e.type===`printer`).length,`)`]})]}),(0,K.jsxs)(`div`,{className:`space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1`,children:[ie.filter(e=>e.type===`printer`).map(e=>(0,K.jsx)(y6,{setting:e,onClick:()=>H(e),onDuplicate:()=>oe(e),compareMode:P,isCompareSelected:ae(e)!==void 0,compareIndex:ae(e),compareDisabled:P&&!!I[0]&&I[0].type!==e.type,t:o},e.setting_id)),ie.filter(e=>e.type===`printer`).length===0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray-dark px-3 py-2`,children:o(`profiles.cloudView.noPrinterPresets`)})]})]})]}),S&&(0,K.jsx)(bUe,{setting:S,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>oe(S),onEdit:()=>U(S),hasPermission:a,t:o}),(w||O||A||M)&&(0,K.jsx)(SUe,{onClose:()=>{T(!1),k(null),j(null),N(null)},initialData:A||O||(M?{type:M.type,name:``,base_id:``,setting:M.setting}:void 0),allPresets:e,t:o}),E&&(0,K.jsx)(xUe,{onClose:()=>D(!1),onApply:e=>{N({type:e.type,setting:e.settings}),D(!1)},t:o}),R&&B&&I[0]&&I[1]&&(0,K.jsx)(C6,{onClose:()=>{z(!1),V(null)},leftPreset:B[0],rightPreset:B[1],leftLabel:I[0].name,rightLabel:I[1].name,t:o})]})}function wUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),[i,a]=(0,y.useState)(`cloud`),[o,s]=(0,y.useState)(),{data:c,isLoading:l}=q({queryKey:[`cloudStatus`],queryFn:Q.getCloudStatus}),{data:u=[]}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:d,isLoading:f,refetch:p,dataUpdatedAt:m}=q({queryKey:[`cloudSettings`],queryFn:()=>Q.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});(0,y.useEffect)(()=>{m&&s(new Date(m))},[m]);let h=J({mutationFn:Q.cloudLogout,onSuccess:()=>{t.invalidateQueries({queryKey:[`cloudStatus`]}),t.removeQueries({queryKey:[`cloudSettings`]}),n(e(`profiles.toast.loggedOut`))}});return l?(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex items-center justify-center min-h-[400px]`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(ws,{className:`w-7 h-7 text-bambu-green`}),e(`profiles.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`profiles.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary mb-6`,children:[(0,K.jsxs)(`button`,{onClick:()=>a(`cloud`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`cloud`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(ws,{className:`w-4 h-4`}),e(`profiles.tabs.bambuCloud`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`orca_cloud`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`orca_cloud`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(ws,{className:`w-4 h-4`}),e(`profiles.tabs.orcaCloud`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`local`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`local`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(wc,{className:`w-4 h-4`}),e(`profiles.tabs.local`)]}),(0,K.jsxs)(`button`,{onClick:()=>a(`kprofiles`),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i===`kprofiles`?`text-bambu-green border-bambu-green`:`text-bambu-gray hover:text-white border-transparent`}`,children:[(0,K.jsx)(hc,{className:`w-4 h-4`}),e(`profiles.tabs.kprofiles`)]})]}),i===`cloud`&&(0,K.jsxs)(K.Fragment,{children:[c?.is_authenticated&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green animate-pulse`}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e(`profiles.connectedAs`),` `,(0,K.jsx)(`span`,{className:`text-white`,children:c.email}),c.region&&(0,K.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-xs rounded bg-bambu-dark-tertiary text-bambu-gray`,children:c.region===`china`?e(`profiles.login.regionChina`):e(`profiles.login.regionGlobal`)})]})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>h.mutate(),disabled:h.isPending||!r(`cloud:auth`),title:r(`cloud:auth`)?void 0:e(`profiles.noLogoutPermission`),children:[(0,K.jsx)(Yc,{className:`w-4 h-4`}),e(`profiles.logout`)]})]}),c?.is_authenticated?f?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):d?(0,K.jsx)(CUe,{settings:d,lastSyncTime:o,onRefresh:()=>p(),isRefreshing:f,printers:u,hasPermission:r,t:e}):(0,K.jsxs)(`div`,{className:`text-center py-16`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`profiles.failedToLoad`)}),(0,K.jsx)($,{onClick:()=>p(),children:e(`profiles.retry`)})]}):(0,K.jsx)(vUe,{onSuccess:()=>{t.invalidateQueries({queryKey:[`cloudStatus`]})},t:e})]}),i===`orca_cloud`&&(0,K.jsx)(pUe,{}),i===`local`&&(0,K.jsx)(cUe,{}),i===`kprofiles`&&(0,K.jsx)(iUe,{}),(0,K.jsx)(yUe,{})]})}function TUe(e,t){let n=(t||``).toUpperCase().replace(/[- ]/g,``),r=n.includes(`X1`),i=n.includes(`P1`),a=n.includes(`A1MINI`),o=n.includes(`A1`)&&!a,s=n.includes(`H2D`),c=n.includes(`H2C`),l=n.includes(`H2S`),u=s||c||l,d=n.includes(`P2S`),f=n.includes(`X2D`),p=d||f;switch(e){case`Lubricate Steel Rods`:return p?`https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis`:null;case`Clean Steel Rods`:return p?`https://wiki.bambulab.com/en/p2s/maintenance/lubricate-x-y-z-axis`:null;case`Lubricate Linear Rails`:return a?`https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis`:o?`https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis`:u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;case`Clean Nozzle/Hotend`:return r||i?`https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog`:a||o?`https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog`:u?`https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning`:p?`https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend`:`https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog`;case`Check Belt Tension`:return r?`https://wiki.bambulab.com/en/x1/maintenance/belt-tension`:i?`https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance`:a?`https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension`:o?`https://wiki.bambulab.com/en/a1/maintenance/belt_tension`:s?`https://wiki.bambulab.com/en/h2/maintenance/belt-tension`:c?`https://wiki.bambulab.com/en/h2c/maintenance/belt-tension`:l?`https://wiki.bambulab.com/en/h2s/maintenance/belt-tension`:p?`https://wiki.bambulab.com/en/p2s/maintenance/belt-tension`:`https://wiki.bambulab.com/en/x1/maintenance/belt-tension`;case`Clean Carbon Rods`:return r||i?`https://wiki.bambulab.com/en/general/carbon-rods-clearance`:null;case`Clean Linear Rails`:return a?`https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis`:o?`https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis`:u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;case`Clean Build Plate`:return`https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide`;case`Check PTFE Tube`:return r||i?`https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube`:a||o?`https://wiki.bambulab.com/en/a1-mini/maintenance/ptfe-tube`:s?`https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer`:l?`https://wiki.bambulab.com/en/h2s/maintenance/replace-ptfe-tube-on-h2s-printer`:c?`https://wiki.bambulab.com/en/h2/maintenance/replace-ptfe-tube-on-h2d-printer`:`https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube`;case`Replace HEPA Filter`:case`HEPA Filter`:case`Replace Carbon Filter`:case`Carbon Filter`:return u?`https://wiki.bambulab.com/en/h2/maintenance/replace-smoke-purifier-air-filte`:`https://wiki.bambulab.com/en/x1/maintenance/replace-carbon-filter`;case`Lubricate Left Nozzle Rail`:case`Left Nozzle Rail`:return u?`https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication`:null;default:return null}}var w6={Droplet:Hs,Flame:ac,Ruler:Ml,Sparkles:ru,Square:ou,Cable:qo,Wrench:Lu,Calendar:Zo,Timer:yu,Cog:ks,Fan:Zs,Zap:Bu,Wind:Iu,Thermometer:vu,Layers:Rc,Box:Wo,Target:pu,RefreshCw:Ol,Settings:Ul,Filter:mc,CircleDot:hs};function T6(e){return e&&w6[e]||Lu}function E6(e,t,n){if(t===`days`){if(e<1)return n?n(`common.today`):`Today`;if(e===1)return n?n(`maintenance.day`):`1 day`;if(e<7){let t=Math.round(e);return n?n(`maintenance.days`,{count:t}):`${t} days`}if(e<180){let t=Math.round(e/7);return t===1?n?n(`maintenance.week`):`1 week`:n?n(`maintenance.weeks`,{count:t}):`${t} weeks`}let t=Math.round(e/30);return t===1?n?n(`maintenance.month`):`1 month`:n?n(`maintenance.months`,{count:t}):`${t} months`}else{if(e<1)return`${Math.round(e*60)}m`;if(e<24)return`${e<10?e.toFixed(1):Math.round(e)}h`;let t=e/24;if(t<7)return`${t<2?t.toFixed(1):Math.round(t)}d`;let n=t/7;return n<12?`${n<2?n.toFixed(1):Math.round(n)}w`:`${Math.round(n/4)}mo`}}function D6(e,t,n){return t===`days`?e===1?n?n(`maintenance.day`):`1 day`:e===7?n?n(`maintenance.week`):`1 week`:e===14?n?n(`maintenance.weeks`,{count:2}):`2 weeks`:e===30?n?n(`maintenance.month`):`1 month`:e===60?n?n(`maintenance.months`,{count:2}):`2 months`:e===90?n?n(`maintenance.months`,{count:3}):`3 months`:e===180?n?n(`maintenance.months`,{count:6}):`6 months`:e===365?n?n(`maintenance.year`):`1 year`:n?n(`maintenance.days`,{count:e}):`${e} days`:`${e}h`}function EUe({item:e,onPerform:t,onToggle:n,hasPermission:r,t:i}){let a=T6(e.maintenance_type_icon),o=e.interval_type||`hours`,s=(()=>{if(o===`days`){let t=e.days_since_maintenance??0;return Math.max(0,Math.min(100,t/e.interval_hours*100))}return Math.max(0,Math.min(100,(e.interval_hours-e.hours_until_due)/e.interval_hours*100))})(),c=()=>e.enabled?e.is_due?`text-red-400`:e.is_warning?`text-amber-400`:`text-bambu-green`:`text-bambu-gray`;return(0,K.jsx)(`div`,{className:`rounded-xl border p-4 transition-all ${e.enabled?e.is_due?`bg-red-500/5 border-red-500/20`:e.is_warning?`bg-amber-500/5 border-amber-500/20`:`bg-bambu-dark-secondary border-bambu-dark-tertiary`:`bg-bambu-dark-secondary/50`}`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3 max-[550px]:flex-wrap`,children:[(0,K.jsxs)(`div`,{className:`relative p-2.5 rounded-lg shrink-0 ${e.is_due?`bg-red-500/20`:e.is_warning?`bg-amber-500/20`:e.enabled?`bg-bambu-dark`:`bg-bambu-dark/50`}`,children:[(0,K.jsx)(a,{className:`w-5 h-5 ${c()}`}),e.enabled&&(e.is_due||e.is_warning)&&(0,K.jsx)(`span`,{className:`absolute -top-1 -right-1 w-2.5 h-2.5 rounded-full ${e.is_due?`bg-red-500`:`bg-amber-500`} animate-pulse`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`font-medium truncate ${e.enabled?`text-white`:`text-bambu-gray`}`,children:e.maintenance_type_name}),o===`days`&&(0,K.jsx)(`span`,{title:i(`maintenance.timeBasedInterval`),children:(0,K.jsx)(Zo,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`})}),(()=>{let t=e.maintenance_type_wiki_url||TUe(e.maintenance_type_name,e.printer_model);return t?(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-gray hover:text-bambu-green transition-colors shrink-0`,title:i(`maintenance.viewDocumentation`),onClick:e=>e.stopPropagation(),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}):null})()]}),(0,K.jsx)(`div`,{className:`mt-2 mb-1.5`,children:(0,K.jsx)(`div`,{className:`w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ${e.enabled?e.is_due?`bg-red-500`:e.is_warning?`bg-amber-500`:`bg-bambu-green`:`bg-bambu-gray/30`}`,style:{width:`${s}%`}})})}),(0,K.jsxs)(`div`,{className:`text-xs flex items-center gap-1 ${c()}`,children:[e.is_due&&(0,K.jsx)(Cu,{className:`w-3 h-3`}),e.is_warning&&!e.is_due&&(0,K.jsx)(Ss,{className:`w-3 h-3`}),!e.is_due&&!e.is_warning&&e.enabled&&(0,K.jsx)(rs,{className:`w-3 h-3`}),(()=>{if(!e.enabled)return i(`common.disabled`);if(o===`days`){let t=e.days_until_due??0;return e.is_due?i(`maintenance.overdueBy`,{duration:E6(Math.abs(t),`days`,i)}):e.is_warning?i(`maintenance.dueIn`,{duration:E6(t,`days`,i)}):i(`maintenance.timeLeft`,{duration:E6(t,`days`,i)})}else return e.is_due?i(`maintenance.overdueBy`,{duration:E6(Math.abs(e.hours_until_due),`hours`,i)}):e.is_warning?i(`maintenance.dueIn`,{duration:E6(e.hours_until_due,`hours`,i)}):i(`maintenance.timeLeft`,{duration:E6(e.hours_until_due,`hours`,i)})})()]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 max-[550px]:w-full max-[550px]:justify-end max-[550px]:mt-1`,children:[(0,K.jsx)(`span`,{title:r(`maintenance:update`)?void 0:i(`maintenance.noPermissionUpdate`),children:(0,K.jsx)(lU,{checked:e.enabled,onChange:t=>n(e.id,t),disabled:!r(`maintenance:update`)})}),(0,K.jsxs)($,{size:`sm`,variant:e.is_due?`primary`:`secondary`,onClick:()=>t(e.id),disabled:!e.enabled||!r(`maintenance:update`),title:r(`maintenance:update`)?void 0:i(`maintenance.noPermissionPerform`),className:`!px-3`,children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5`}),i(`common.reset`)]})]})]})})}function DUe({overview:e,onPerform:t,onToggle:n,onSetHours:r,hasPermission:i,t:a}){let[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(e.total_print_hours.toFixed(1)),f=[...e.maintenance_items].sort((e,t)=>e.is_due&&!t.is_due?-1:!e.is_due&&t.is_due?1:e.is_warning&&!t.is_warning?-1:!e.is_warning&&t.is_warning?1:e.maintenance_type_id-t.maintenance_type_id),p=f.find(e=>e.enabled&&(e.is_due||e.is_warning)),m=()=>{let t=parseFloat(u);!isNaN(t)&&t>=0&&(r(e.printer_id,t),l(!1))};return(0,K.jsxs)(_d,{className:`overflow-hidden`,children:[(0,K.jsxs)(`div`,{className:`p-5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`h2`,{className:`text-xl font-semibold text-white`,children:e.printer_name}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.due_count>0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),a(`maintenance.overdueCount`,{count:e.due_count})]}),e.warning_count>0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-amber-500/20 text-amber-400 text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),a(`maintenance.dueSoonCount`,{count:e.warning_count})]}),e.due_count===0&&e.warning_count===0&&(0,K.jsxs)(`span`,{className:`px-2.5 py-1 bg-bambu-green/20 text-bambu-green text-xs font-medium rounded-full flex items-center gap-1.5`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),a(`maintenance.allGood`)]})]})]}),(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm text-bambu-gray hover:text-white hover:bg-bambu-dark rounded-lg transition-colors`,children:[o?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`}),a(o?`common.collapse`:`common.expand`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-6 mt-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 bg-bambu-dark/50 rounded-lg`,children:(0,K.jsx)(yu,{className:`w-4 h-4 text-bambu-gray`})}),c?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m(),e.key===`Escape`&&l(!1)},className:`w-24 px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm`,min:`0`,step:`1`,autoFocus:!0}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:a(`common.hours`)}),(0,K.jsx)($,{size:`sm`,onClick:m,children:a(`common.save`)}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>l(!1),children:a(`common.cancel`)})]}):(0,K.jsxs)(`button`,{onClick:()=>{i(`maintenance:update`)&&(d(Math.round(e.total_print_hours).toString()),l(!0))},className:`group ${i(`maintenance:update`)?``:`cursor-not-allowed opacity-60`}`,title:i(`maintenance:update`)?void 0:a(`maintenance.noPermissionEditHours`),children:[(0,K.jsxs)(`div`,{className:`text-sm font-medium text-white ${i(`maintenance:update`)?`group-hover:text-bambu-green`:``} transition-colors flex items-center gap-1`,children:[Math.round(e.total_print_hours),` `,a(`common.hours`),(0,K.jsx)(gl,{className:`w-3 h-3 text-bambu-gray ${i(`maintenance:update`)?`group-hover:text-bambu-green`:``}`})]}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:a(`maintenance.totalPrintTime`)})]})]}),(0,K.jsx)(`div`,{className:`w-px h-10 bg-bambu-dark-tertiary`}),p&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${p.is_due?`bg-red-500/20`:`bg-amber-500/20`}`,children:(0,K.jsx)(T6(p.maintenance_type_icon),{className:`w-4 h-4 ${p.is_due?`text-red-400`:`text-amber-400`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`text-sm font-medium ${p.is_due?`text-red-400`:`text-amber-400`}`,children:p.maintenance_type_name}),(0,K.jsx)(`div`,{className:`text-xs ${p.is_due?`text-red-400/70`:`text-amber-400/70`}`,children:p.is_due?a(`common.overdue`):a(`maintenance.dueSoon`)})]})]})]})]}),o&&(0,K.jsx)(yd,{className:`pt-0 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4`,children:f.map(e=>(0,K.jsx)(EUe,{item:e,onPerform:t,onToggle:n,hasPermission:i,t:a},e.id))})})]})}function OUe({overview:e,types:t,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onRestoreDefaults:o,isRestoringDefaults:s,onAssignType:c,onRemoveItem:l,hasPermission:u,t:d}){let[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(``),[g,_]=(0,y.useState)(`hours`),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(``),[C,w]=(0,y.useState)(`100`),[T,E]=(0,y.useState)(`hours`),[D,O]=(0,y.useState)(`Wrench`),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(new Set),[N,P]=(0,y.useState)(null),[F,I]=(0,y.useState)(null),L=(0,y.useMemo)(()=>e?e.map(e=>({id:e.printer_id,name:e.printer_name})):[],[e]),R=t=>e?e.filter(e=>e.maintenance_items.some(e=>e.maintenance_type_id===t)).map(e=>({printerId:e.printer_id,printerName:e.printer_name,itemId:e.maintenance_items.find(e=>e.maintenance_type_id===t)?.id})):[],z=t=>{if(!e)return[];let n=new Set(R(t).map(e=>e.printerId));return L.filter(e=>!n.has(e.id))},[B,V]=(0,y.useState)(null),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(`hours`),[ae,oe]=(0,y.useState)(`Wrench`),[U,se]=(0,y.useState)(``),ce=e=>{V(e),te(e.name),re(e.default_interval_hours.toString()),H(e.interval_type||`hours`),oe(e.icon||`Wrench`),se(e.wiki_url||``)},le=()=>{B&&ee.trim()&&parseFloat(ne)>0&&(i(B.id,{name:ee.trim(),default_interval_hours:parseFloat(ne),interval_type:ie,icon:ae,wiki_url:U.trim()||null}),V(null))},ue=(e,t,r)=>{let i=parseFloat(m);!isNaN(i)&&i>0&&n(e,{custom_interval_hours:Math.abs(i-t)<.01?null:i,custom_interval_type:g===r?null:g}),p(null)},de=e=>{e.preventDefault(),x.trim()&&parseFloat(C)>0&&j.size>0&&(r({name:x.trim(),default_interval_hours:parseFloat(C),interval_type:T,icon:D,wiki_url:k.trim()||null},Array.from(j)),S(``),w(`100`),E(`hours`),A(``),M(new Set),b(!1))},fe=e=>{M(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},pe=e?.map(e=>({printerId:e.printer_id,printerName:e.printer_name,items:e.maintenance_items.sort((e,t)=>e.maintenance_type_id-t.maintenance_type_id)})).sort((e,t)=>e.printerName.localeCompare(t.printerName))||[],me=t.filter(e=>e.is_system),he=t.filter(e=>!e.is_system);return(0,K.jsxs)(`div`,{className:`space-y-8`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:d(`maintenance.maintenanceTypes`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:d(`maintenance.maintenanceTypesDescription`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:o,disabled:!u(`maintenance:delete`)||s,title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),children:d(`maintenance.restoreDefaults`)}),(0,K.jsxs)($,{onClick:()=>b(!v),disabled:!u(`maintenance:create`),title:u(`maintenance:create`)?void 0:d(`maintenance.noPermissionEditTypes`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),d(`maintenance.addCustomType`)]})]})]}),v&&(0,K.jsx)(_d,{className:`mb-6`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`form`,{onSubmit:de,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{className:`lg:col-span-2`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`common.name`)}),(0,K.jsx)(`input`,{type:`text`,value:x,onChange:e=>S(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`maintenance.exampleName`),autoFocus:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.intervalType`)}),(0,K.jsxs)(`select`,{value:T,onChange:e=>{E(e.target.value),e.target.value===`days`?w(`30`):w(`100`)},className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.intervalValue`,{type:T===`days`?d(`maintenance.calendarDays`).toLowerCase():d(`common.hours`)})}),(0,K.jsx)(`input`,{type:`number`,value:C,onChange:e=>w(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,min:`1`})]})]}),(0,K.jsx)(`div`,{className:`mt-4 flex items-end justify-between`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.icon`)}),(0,K.jsx)(`div`,{className:`flex gap-1`,children:Object.keys(w6).map(e=>{let t=w6[e];return(0,K.jsx)(`button`,{type:`button`,onClick:()=>O(e),className:`p-2 rounded-lg transition-colors ${D===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(t,{className:`w-4 h-4`})},e)})})]})}),(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.documentationLink`)}),(0,K.jsx)(`input`,{type:`url`,value:k,onChange:e=>A(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:`https://wiki.bambulab.com/...`})]}),(0,K.jsxs)(`div`,{className:`mt-4`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-bambu-gray mb-1.5`,children:d(`maintenance.assignToPrinters`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:L.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>fe(e.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${j.has(e.id)?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary`}`,children:e.name},e.id))}),j.size===0&&(0,K.jsx)(`p`,{className:`text-xs text-orange-400 mt-1`,children:d(`maintenance.selectAtLeastOnePrinter`)})]}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:()=>{b(!1),M(new Set)},children:d(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!x.trim()||j.size===0,children:d(`maintenance.addType`)})]})]})})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3`,children:[me.map(e=>{let t=T6(e.icon),n=e.interval_type||`hours`;return(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg`,children:(0,K.jsx)(t,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-white truncate`,children:e.name}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-0.5 flex items-center gap-1`,children:[n===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.default_interval_hours,n,d)]})]}),(0,K.jsx)(`button`,{onClick:()=>{u(`maintenance:delete`)&&I(e)},disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u(`maintenance:delete`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})},e.id)}),he.map(e=>{let t=T6(e.icon),n=e.interval_type||`hours`;if(B?.id===e.id)return(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green`,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:ee,onChange:e=>te(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`common.name`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`select`,{value:ie,onChange:e=>H(e.target.value),className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]}),(0,K.jsx)(`input`,{type:`number`,value:ne,onChange:e=>re(e.target.value),className:`w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,min:`1`})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(w6).map(e=>{let t=w6[e];return(0,K.jsx)(`button`,{type:`button`,onClick:()=>oe(e),className:`p-1.5 rounded transition-colors ${ae===e?`bg-bambu-green text-white`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:(0,K.jsx)(t,{className:`w-3.5 h-3.5`})},e)})}),(0,K.jsx)(`input`,{type:`url`,value:U,onChange:e=>se(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`,placeholder:d(`maintenance.documentationLink`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{size:`sm`,onClick:le,disabled:!ee.trim(),children:d(`common.save`)}),(0,K.jsx)($,{size:`sm`,variant:`secondary`,onClick:()=>V(null),children:d(`common.cancel`)})]})]})},e.id);let r=R(e.id),i=z(e.id),o=N===e.id;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2.5 bg-bambu-green/20 rounded-lg`,children:(0,K.jsx)(t,{className:`w-5 h-5 text-bambu-green`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded`,children:d(`maintenance.custom`)})]}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-0.5 flex items-center gap-1`,children:[n===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.default_interval_hours,n,d)]})]}),(0,K.jsxs)(`button`,{onClick:()=>P(o?null:e.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${r.length>0?`border-bambu-green/50 bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20`:`border-orange-400/50 bg-orange-400/10 text-orange-400 hover:bg-orange-400/20`}`,title:d(`maintenance.printersAssignedClick`,{count:r.length}),children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:r.length}),(0,K.jsx)(is,{className:`w-3 h-3 transition-transform ${o?`rotate-180`:``}`})]}),(0,K.jsx)(`button`,{onClick:()=>ce(e),disabled:!u(`maintenance:update`),title:u(`maintenance:update`)?void 0:d(`maintenance.noPermissionEditTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${u(`maintenance:update`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(gl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{confirm(d(`maintenance.deleteTypeConfirm`,{name:e.name}))&&a(e.id)},disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?void 0:d(`maintenance.noPermissionDeleteTypes`),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${u(`maintenance:delete`)?``:`opacity-50 cursor-not-allowed`}`,children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]}),o&&(0,K.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:d(`maintenance.assignedToPrinters`)}),r.length===0?(0,K.jsx)(`p`,{className:`text-xs text-orange-400`,children:d(`maintenance.noPrintersAssigned`)}):(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white`,children:[e.printerName,(0,K.jsx)(`button`,{onClick:()=>e.itemId&&l(e.itemId),disabled:!u(`maintenance:delete`),title:u(`maintenance:delete`)?d(`maintenance.removeFromPrinter`):d(`maintenance.noPermissionRemovePrinter`),className:`ml-1 ${u(`maintenance:delete`)?`hover:text-red-400`:`opacity-50 cursor-not-allowed`}`,children:`×`})]},e.printerId))}),i.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:d(`maintenance.addPrinterShort`)}),i.map(t=>(0,K.jsxs)(`button`,{onClick:()=>c(t.id,e.id),disabled:!u(`maintenance:create`),title:u(`maintenance:create`)?void 0:d(`maintenance.noPermissionAssignPrinter`),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${u(`maintenance:create`)?`hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green`:`opacity-50 cursor-not-allowed text-bambu-gray`}`,children:[`+ `,t.name]},t.id))]})]})]},e.id)})]})]}),pe.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:d(`maintenance.intervalOverrides`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:d(`maintenance.intervalOverridesDescription`)})]}),(0,K.jsx)(`div`,{className:`space-y-4`,children:pe.map(e=>(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`py-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white mb-3`,children:e.printerName}),(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2`,children:e.items.map(e=>{let n=T6(e.maintenance_type_icon),r=t.find(t=>t.id===e.maintenance_type_id),i=r?.default_interval_hours||e.interval_hours,a=r?.interval_type||`hours`,o=e.interval_type||`hours`,s=f===e.id;return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(n,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray flex-1 truncate`,children:e.maintenance_type_name}),s?(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[g===`days`?(0,K.jsx)(Zo,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`}):(0,K.jsx)(yu,{className:`w-3.5 h-3.5 text-bambu-gray shrink-0`}),(0,K.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs`,children:[(0,K.jsx)(`option`,{value:`hours`,children:d(`maintenance.printHours`)}),(0,K.jsx)(`option`,{value:`days`,children:d(`maintenance.calendarDays`)})]}),(0,K.jsx)(`input`,{type:`number`,value:m,onChange:e=>h(e.target.value),onKeyDown:t=>{t.key===`Enter`&&ue(e.id,i,a),t.key===`Escape`&&p(null)},className:`w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs`,min:`1`}),(0,K.jsx)($,{size:`sm`,onClick:()=>ue(e.id,i,a),children:`OK`})]}):(0,K.jsxs)(`button`,{onClick:()=>{u(`maintenance:update`)&&(p(e.id),h(e.interval_hours.toString()),_(o))},disabled:!u(`maintenance:update`),title:u(`maintenance:update`)?void 0:d(`maintenance.noPermissionEditIntervals`),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${u(`maintenance:update`)?`hover:bg-bambu-dark-secondary hover:border-bambu-green`:`opacity-50 cursor-not-allowed`}`,children:[o===`days`?(0,K.jsx)(Zo,{className:`w-3 h-3`}):(0,K.jsx)(yu,{className:`w-3 h-3`}),D6(e.interval_hours,o,d),(0,K.jsx)(gl,{className:`w-3 h-3 text-bambu-gray`})]})]},e.id)})})]})},e.printerId))})]}),pe.length===0&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-12`,children:[(0,K.jsx)(Ss,{className:`w-12 h-12 mx-auto mb-4 text-bambu-gray/30`}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:d(`common.noPrinters`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray/70 mt-1`,children:d(`maintenance.intervalOverridesDescription`)})]})}),F&&(0,K.jsx)(Ad,{title:d(`maintenance.deleteSystemTypeTitle`),message:d(`maintenance.deleteSystemTypeMessage`,{name:F.name}),confirmText:d(`common.delete`),cancelText:d(`common.cancel`),variant:`danger`,cancelVariant:`primary`,cardClassName:`bg-red-950/70 border border-red-800/70`,onConfirm:()=>{a(F.id),I(null)},onCancel:()=>I(null)})]})}function kUe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r}=dd(),[i,a]=(0,y.useState)(`status`),{data:o,isLoading:s}=q({queryKey:[`maintenanceOverview`],queryFn:Q.getMaintenanceOverview}),{data:c}=q({queryKey:[`maintenanceTypes`],queryFn:Q.getMaintenanceTypes}),l=J({mutationFn:({id:e,notes:t})=>Q.performMaintenance(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),t.invalidateQueries({queryKey:[`maintenanceSummary`]}),n(e(`maintenance.maintenanceComplete`))},onError:e=>{n(e.message,`error`)}}),u=J({mutationFn:({id:e,data:t})=>Q.updateMaintenanceItem(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]})},onError:e=>{n(e.message,`error`)}}),d=J({mutationFn:({id:e,data:t})=>Q.updateMaintenanceType(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeUpdated`))},onError:e=>{n(e.message,`error`)}}),f=J({mutationFn:Q.deleteMaintenanceType,onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeDeleted`))},onError:e=>{n(e.message,`error`)}}),p=J({mutationFn:Q.restoreDefaultMaintenanceTypes,onSuccess:r=>{t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.defaultsRestored`,{count:r.restored}))},onError:e=>{n(e.message,`error`)}}),m=J({mutationFn:({printerId:e,hours:t})=>Q.setPrinterHours(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),t.invalidateQueries({queryKey:[`maintenanceSummary`]}),n(e(`maintenance.printHoursUpdated`))},onError:e=>{n(e.message,`error`)}}),h=J({mutationFn:({printerId:e,typeId:t})=>Q.assignMaintenanceType(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.printerAssigned`))},onError:e=>{n(e.message,`error`)}}),g=J({mutationFn:Q.removeMaintenanceItem,onSuccess:()=>{t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.printerRemoved`))},onError:e=>{n(e.message,`error`)}}),_=e=>{l.mutate({id:e})},v=(e,t)=>{u.mutate({id:e,data:{enabled:t}})},b=(e,t)=>{m.mutate({printerId:e,hours:t})};if(s)return(0,K.jsx)(`div`,{className:`p-4 md:p-8 flex justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});let x=o?.reduce((e,t)=>e+t.due_count,0)||0,S=o?.reduce((e,t)=>e+t.warning_count,0)||0;return(0,K.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(Lu,{className:`w-7 h-7 text-bambu-green`}),e(`maintenance.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:i===`status`?(0,K.jsxs)(K.Fragment,{children:[x>0&&(0,K.jsx)(`span`,{className:`text-red-400`,children:e(`maintenance.dueCount`,{count:x})}),x>0&&S>0&&` · `,S>0&&(0,K.jsx)(`span`,{className:`text-amber-400`,children:e(`maintenance.warningCount`,{count:S})}),x===0&&S===0&&(0,K.jsx)(`span`,{className:`text-bambu-green`,children:e(`maintenance.allOk`)})]}):e(`maintenance.configureSettings`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-1 mb-6 border-b border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`status`),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i===`status`?`text-bambu-green border-bambu-green`:`text-bambu-gray border-transparent hover:text-white`}`,children:e(`maintenance.statusTab`)}),(0,K.jsx)(`button`,{onClick:()=>a(`settings`),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i===`settings`?`text-bambu-green border-bambu-green`:`text-bambu-gray border-transparent hover:text-white`}`,children:e(`maintenance.settingsTab`)})]}),i===`status`?(0,K.jsx)(`div`,{className:`space-y-6`,children:o&&o.length>0?[...o].sort((e,t)=>{let n=e.due_count*10+e.warning_count,r=t.due_count*10+t.warning_count;return n===r?e.printer_name.localeCompare(t.printer_name):r-n}).map(t=>(0,K.jsx)(DUe,{overview:t,onPerform:_,onToggle:v,onSetHours:b,hasPermission:r,t:e},t.printer_id)):(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`text-center py-16`,children:[(0,K.jsx)(Lu,{className:`w-16 h-16 mx-auto mb-4 text-bambu-gray/30`}),(0,K.jsx)(`p`,{className:`text-lg font-medium text-white mb-2`,children:e(`common.noPrinters`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`maintenance.configureSettings`)})]})})}):(0,K.jsx)(OUe,{overview:o,types:c||[],onUpdateInterval:(e,t)=>u.mutate({id:e,data:t}),onAddType:async(r,i)=>{let a=await Q.createMaintenanceType(r);for(let e of i)await Q.assignMaintenanceType(e,a.id);t.invalidateQueries({queryKey:[`maintenanceTypes`]}),t.invalidateQueries({queryKey:[`maintenanceOverview`]}),n(e(`maintenance.typeUpdated`))},onUpdateType:(e,t)=>d.mutate({id:e,data:t}),onDeleteType:e=>f.mutate(e),onRestoreDefaults:()=>p.mutate(),isRestoringDefaults:p.isPending,onAssignType:(e,t)=>h.mutate({printerId:e,typeId:t}),onRemoveItem:e=>g.mutate(e),hasPermission:r,t:e})]})}var O6=[`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#06b6d4`,`#3b82f6`,`#8b5cf6`,`#ec4899`,`#6b7280`];function k6({project:e,onClose:t,onSave:n,isLoading:r,currencySymbol:i,t:a}){let[o,s]=(0,y.useState)(e?.name||``),[c,l]=(0,y.useState)(e?.description||``),[u,d]=(0,y.useState)(e?.color||O6[0]),[f,p]=(0,y.useState)(e?.target_count?.toString()||``),[m,h]=(0,y.useState)(e?.target_parts_count?.toString()||``),[g,_]=(0,y.useState)(e?.status||`active`),[v,b]=(0,y.useState)(e?.tags||``),[x,S]=(0,y.useState)(e?.due_date?.split(`T`)[0]||``),[C,w]=(0,y.useState)(e?.priority||`normal`),[T,E]=(0,y.useState)(e?.budget?.toString()||``),[D,O]=(0,y.useState)(e?.url||``),[k,A]=(0,y.useState)(null),j=no(),[M,N]=(0,y.useState)(e?.cover_image_filename||null),P=(0,y.useRef)(null),[F,I]=(0,y.useState)(!1),[L,R]=(0,y.useState)(0);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary flex flex-col max-h-[calc(100vh-2rem)]`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(e?`projects.editProject`:`projects.newProject`)})}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault();let r=D.trim();if(r&&!/^https?:\/\//i.test(r)){A(a(`projects.urlInvalid`));return}A(null),n({name:o.trim(),description:c.trim()||void 0,color:u,target_count:f?parseInt(f,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:v.trim()||void 0,due_date:x||void 0,priority:C,budget:T.trim()?parseFloat(T):null,url:e?r||null:r||void 0,...e&&{status:g}})},className:`flex flex-col flex-1 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.name`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.namePlaceholder`),required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.description`)}),(0,K.jsx)(`textarea`,{value:c,onChange:e=>l(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green resize-none`,placeholder:a(`projects.descriptionPlaceholder`),rows:2})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.urlLabel`)}),(0,K.jsx)(`input`,{type:`url`,value:D,onChange:e=>{O(e.target.value),k&&A(null)},className:`w-full bg-bambu-dark border rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none ${k?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,placeholder:a(`projects.urlPlaceholder`),maxLength:2048}),k&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:k})]}),e&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.coverImageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-20 h-20 rounded bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden flex items-center justify-center flex-shrink-0`,children:M?(0,K.jsx)(`img`,{src:`${Q.getProjectCoverImageUrl(e.id)}?v=${L}`,alt:a(`projects.coverImageAlt`),className:`w-full h-full object-cover`}):(0,K.jsx)(Mc,{className:`w-6 h-6 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(`input`,{ref:P,type:`file`,accept:`image/jpeg,image/png,image/gif,image/webp`,onChange:async t=>{let n=t.target.files?.[0];if(!(!n||!e)){I(!0);try{N((await Q.uploadProjectCoverImage(e.id,n)).filename),R(e=>e+1),j.invalidateQueries({queryKey:[`projects`]})}catch{}finally{I(!1),P.current&&(P.current.value=``)}}},className:`hidden`}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>P.current?.click(),disabled:F,children:[F?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Du,{className:`w-4 h-4 mr-1`}),a(M?`projects.coverImageReplace`:`projects.coverImageUpload`)]}),M&&(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:async()=>{if(e){I(!0);try{await Q.deleteProjectCoverImage(e.id),N(null),R(e=>e+1),j.invalidateQueries({queryKey:[`projects`]})}finally{I(!1)}}},disabled:F,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mr-1`}),a(`projects.coverImageRemove`)]})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.color`)}),(0,K.jsx)(`div`,{className:`flex gap-2 flex-wrap`,children:O6.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>d(e),className:`w-8 h-8 rounded-full transition-transform ${u===e?`ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110`:``}`,style:{backgroundColor:e}},e))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.targetPlates`)}),(0,K.jsx)(`input`,{type:`number`,value:f,onChange:e=>p(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.targetPlatesPlaceholder`),min:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:a(`projects.targetPlatesHelp`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.targetParts`)}),(0,K.jsx)(`input`,{type:`number`,value:m,onChange:e=>h(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.targetPartsPlaceholder`),min:`1`}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:a(`projects.targetPartsHelp`)})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.tagsLabel`)}),(0,K.jsx)(`input`,{type:`text`,value:v,onChange:e=>b(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:a(`projects.tagsPlaceholder`)})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.dueDate`)}),(0,K.jsx)(`input`,{type:`date`,value:x,onChange:e=>S(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projects.priority`)}),(0,K.jsxs)(`select`,{value:C,onChange:e=>w(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`low`,children:a(`projects.priorityLow`)}),(0,K.jsx)(`option`,{value:`normal`,children:a(`projects.priorityNormal`)}),(0,K.jsx)(`option`,{value:`high`,children:a(`projects.priorityHigh`)}),(0,K.jsx)(`option`,{value:`urgent`,children:a(`projects.priorityUrgent`)})]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`projectDetail.cost.budget`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray pointer-events-none`,children:i}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,value:T,onChange:e=>E(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded pl-8 pr-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:`0.00`})]})]}),e&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.status`)}),(0,K.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`active`,children:a(`projects.statusActive`)}),(0,K.jsx)(`option`,{value:`completed`,children:a(`projects.statusCompleted`)}),(0,K.jsx)(`option`,{value:`archived`,children:a(`projects.statusArchived`)})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:a(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!o.trim()||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):a(e?`common.save`:`projects.create`)})]})]})]})})}function AUe({projectId:e,altText:t}){let n=(0,y.useRef)(null),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(null);return(0,K.jsxs)(`div`,{ref:n,className:`relative flex-shrink-0`,onMouseEnter:()=>{if(!n.current)return;let e=n.current.getBoundingClientRect(),t=window.innerWidth,r=window.innerHeight,a=e.right+8;a+384>t-8&&(a=e.left-384-8);let s=e.top;s+384>r-8&&(s=r-384-8),s<8&&(s=8),o({left:a,top:s}),i(!0)},onMouseLeave:()=>i(!1),onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-lg overflow-hidden bg-bambu-dark border border-bambu-dark-tertiary`,children:(0,K.jsx)(`img`,{src:Q.getProjectCoverImageUrl(e),alt:t,className:`w-full h-full object-cover`,loading:`lazy`})}),r&&a&&(0,Op.createPortal)((0,K.jsx)(`div`,{className:`fixed z-[100] w-96 h-96 rounded-lg overflow-hidden border border-bambu-dark-tertiary shadow-2xl bg-bambu-dark pointer-events-none`,style:{left:a.left,top:a.top},"aria-hidden":`true`,children:(0,K.jsx)(`img`,{src:Q.getProjectCoverImageUrl(e),alt:``,className:`w-full h-full object-contain`,loading:`lazy`})}),document.body)]})}function jUe({project:e,onClick:t,onEdit:n,onDelete:r,hasPermission:i,t:a}){let o=e.target_count?Math.round(e.archive_count/e.target_count*100):0,s=e.target_parts_count?Math.round(e.completed_count/e.target_parts_count*100):0,c=e.status===`completed`,l=e.status===`archived`,[u,d]=(0,y.useState)(!1),f=c?{icon:ms,color:`text-bambu-green`,bg:`bg-bambu-green/10`}:l?{icon:Oo,color:`text-bambu-gray`,bg:`bg-bambu-gray/10`}:e.queue_count>0?{icon:Ss,color:`text-blue-400`,bg:`bg-blue-400/10`}:{icon:sc,color:`text-bambu-gray`,bg:`bg-bambu-gray/10`};return(0,K.jsxs)(`div`,{className:`group relative bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary hover:border-bambu-green/50 hover:shadow-lg hover:shadow-bambu-green/5 transition-all duration-300 cursor-pointer overflow-hidden`,onClick:t,children:[(0,K.jsx)(`div`,{className:`absolute top-0 left-0 w-1.5 h-full`,style:{backgroundColor:e.color||`#6b7280`,boxShadow:`0 0 12px ${e.color||`#6b7280`}40`}}),(0,K.jsxs)(`div`,{className:`p-5 pl-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[e.cover_image_filename?(0,K.jsx)(AUe,{projectId:e.id,altText:a(`projects.coverImageAlt`)}):(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${f.bg} flex-shrink-0`,children:(0,K.jsx)(f.icon,{className:`w-5 h-5 ${f.color}`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,K.jsx)(`h3`,{className:`font-semibold text-white truncate`,children:e.name}),e.url&&(0,K.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),title:e.url,"aria-label":a(`projects.openExternalUrl`),className:`inline-flex items-center justify-center w-6 h-6 rounded bg-bambu-dark border border-bambu-dark-tertiary text-bambu-green hover:bg-bambu-green/10 hover:border-bambu-green transition-colors flex-shrink-0`,children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}),e.target_parts_count?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${s>=100?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray`}`,children:[e.completed_count,`/`,e.target_parts_count,` `,a(`projects.parts`)]}):e.target_count?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray`}`,children:[e.archive_count,`/`,e.target_count,` `,a(`projects.plates`)]}):e.completed_count>0?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium bg-bambu-dark text-bambu-gray`,children:[e.completed_count,` `,a(`projects.parts`)]}):null,c&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap`,children:a(`projects.done`)}),l&&(0,K.jsx)(`span`,{className:`text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap`,children:a(`projects.statusArchived`)})]}),e.description&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray/70 mt-1 line-clamp-1`,children:e.description}),e.archives&&e.archives.length>0&&(()=>{let t=e.archives.map(e=>e.filament_type).filter(Boolean).flatMap(e=>e.split(`,`).map(e=>e.trim())).filter(Boolean),n=[...new Set(t)],r=e.archives.map(e=>e.filament_color).filter(Boolean).flatMap(e=>e.split(`,`).map(e=>e.trim())).filter(e=>e.startsWith(`#`)||/^[0-9A-Fa-f]{6}$/.test(e)),i=[...new Set(r)];return n.length===0&&i.length===0?null:(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[n.slice(0,3).map(e=>(0,K.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded`,children:e},e)),i.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[i.slice(0,5).map(e=>(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full border border-black/20`,style:{backgroundColor:e.startsWith(`#`)?e:`#${e}`},title:e},e)),i.length>5&&(0,K.jsxs)(`span`,{className:`text-[10px] text-bambu-gray ml-0.5`,children:[`+`,i.length-5]})]})]})})()]})]}),(0,K.jsxs)(`div`,{className:`relative`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{className:`p-1.5 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors opacity-0 group-hover:opacity-100`,onClick:()=>d(!u),children:(0,K.jsx)(Ws,{className:`w-4 h-4`})}),u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>d(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i(`projects:update`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{i(`projects:update`)&&(n(),d(!1))},disabled:!i(`projects:update`),title:i(`projects:update`)?void 0:a(`projects.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4`}),a(`common.edit`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i(`projects:delete`)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{i(`projects:delete`)&&(r(),d(!1))},disabled:!i(`projects:delete`),title:i(`projects:delete`)?void 0:a(`projects.noDeletePermission`),children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),a(`common.delete`)]})]})]})]})]}),(0,K.jsx)(`div`,{className:`mb-4`,children:e.target_count||e.target_parts_count?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[e.target_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:a(`projects.plates`)}),(0,K.jsxs)(`span`,{className:o>=100?`text-bambu-green font-medium`:`text-white`,children:[e.archive_count,` / `,e.target_count]})]}),(0,K.jsx)(`div`,{className:`h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out rounded-full relative`,style:{width:`${Math.min(o,100)}%`,background:o>=100?`linear-gradient(90deg, #22c55e, #4ade80)`:`linear-gradient(90deg, ${e.color||`#6b7280`}, ${e.color||`#6b7280`}cc)`,boxShadow:`0 0 8px ${o>=100?`#22c55e`:e.color||`#6b7280`}60`}})})]}),e.target_parts_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:a(`projects.parts`)}),(0,K.jsxs)(`span`,{className:s>=100?`text-bambu-green font-medium`:`text-white`,children:[e.completed_count,` / `,e.target_parts_count]})]}),(0,K.jsx)(`div`,{className:`h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500 ease-out rounded-full relative`,style:{width:`${Math.min(s,100)}%`,background:s>=100?`linear-gradient(90deg, #22c55e, #4ade80)`:`linear-gradient(90deg, ${e.color||`#6b7280`}, ${e.color||`#6b7280`}cc)`,boxShadow:`0 0 8px ${s>=100?`#22c55e`:e.color||`#6b7280`}60`}})})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`text-xs text-red-400`,children:[e.failed_count,` `,a(`projects.failed`)]})]}):e.completed_count>0||e.failed_count>0?(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-xs`,children:[e.completed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-bambu-gray`,children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.completed_count,` `,a(`projects.completed`)]})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-red-400`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.failed_count,` `,a(`projects.failed`)]})]}),e.queue_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-blue-400`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),(0,K.jsxs)(`span`,{children:[e.queue_count,` `,a(`projects.inQueue`)]})]})]}):(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/60 italic`,children:a(`projects.noPrintsYet`)})}),e.archives&&e.archives.length>0&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:e.archives.slice(0,4).map(e=>(0,K.jsxs)(`div`,{className:`relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary`,title:e.print_name||`Unknown`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:e.print_name||``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray/50`,children:(0,K.jsx)(pl,{className:`w-6 h-6`})}),e.status===`failed`&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-red-500/40 flex items-center justify-center`,children:(0,K.jsx)(Cu,{className:`w-4 h-4 text-white`})})]},e.id))}),e.archive_count>4&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1.5 text-center`,children:a(`common.more`,{count:e.archive_count-4})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-xs text-bambu-gray`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:a(`projects.printJobs`),children:[(0,K.jsx)(Rc,{className:`w-3.5 h-3.5 text-blue-400`}),(0,K.jsxs)(`span`,{children:[e.archive_count,` `,a(`projects.plates`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:a(`projects.partsPrinted`),children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5 text-bambu-green`}),(0,K.jsxs)(`span`,{children:[e.completed_count,` `,a(`projects.parts`)]})]}),e.failed_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-red-400`,title:a(`projects.failedParts`),children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:e.failed_count})]}),e.queue_count>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-yellow-400`,title:a(`projects.inQueue`),children:[(0,K.jsx)(Wc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{children:e.queue_count})]})]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors`})]})]})]})}function MUe(){let{t:e}=W(),t=$n(),n=no(),{showToast:r}=Td(),{hasPermission:i}=dd(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(),[l,u]=(0,y.useState)(`active`),[d,f]=(0,y.useState)(null),{data:p}=q({queryKey:[`settings`],queryFn:Q.getSettings}),m=$d(p?.currency||`USD`),{data:h,isLoading:g}=q({queryKey:[`projects`,l===`all`?void 0:l],queryFn:()=>Q.getProjects(l===`all`?void 0:l)}),_=J({mutationFn:e=>Q.createProject(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),o(!1),r(e(`projects.toast.created`),`success`)},onError:e=>{r(e.message,`error`)}}),v=J({mutationFn:({id:e,data:t})=>Q.updateProject(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),o(!1),c(void 0),r(e(`projects.toast.updated`),`success`)},onError:e=>{r(e.message,`error`)}}),b=J({mutationFn:e=>Q.deleteProject(e),onSuccess:()=>{f(null),r(e(`projects.toast.deleted`),`success`),setTimeout(()=>window.location.reload(),100)},onError:e=>{f(null),r(e.message,`error`)}}),x=J({mutationFn:e=>Q.importProject(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`projects`]}),r(e(`projects.toast.imported`),`success`)},onError:e=>{r(e.message,`error`)}}),S=(0,y.useRef)(null),C=async()=>{try{let t=await Q.getProjects(),n=await Promise.all(t.map(async e=>await Q.exportProjectJson(e.id))),i=new Blob([JSON.stringify(n,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a,o.download=`bambuddy_projects_${new Date().toISOString().split(`T`)[0]}.json`,o.click(),URL.revokeObjectURL(a),r(e(`projects.toast.exported`),`success`)}catch(e){r(e.message,`error`)}},w=()=>{S.current?.click()},T=async t=>{let i=t.target.files?.[0];if(i){try{if(i.name.toLowerCase().endsWith(`.zip`))await Q.importProjectFile(i),n.invalidateQueries({queryKey:[`projects`]}),r(e(`projects.toast.imported`),`success`);else{let t=await i.text(),n=JSON.parse(t),a=Array.isArray(n)?n:[n];for(let e of a)await x.mutateAsync(e);a.length>1&&r(e(`projects.toast.multipleImported`,{count:a.length}),`success`)}}catch(t){r(`${e(`projects.toast.importFailed`)}: ${t.message}`,`error`)}t.target.value=``}},E=e=>{s?v.mutate({id:s.id,data:e}):_.mutate(e)},D=e=>{c(e),o(!0)},O=e=>{t(`/projects/${e.id}`)},k=e=>{f(e)},A=()=>{d!==null&&b.mutate(d)},j=h?.reduce((e,t)=>(e[t.status]=(e[t.status]||0)+1,e.all=(e.all||0)+1,e),{})||{};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,K.jsx)(`input`,{ref:S,type:`file`,accept:`.json,.zip`,onChange:T,className:`hidden`}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(sc,{className:`w-7 h-7 text-bambu-green`}),e(`projects.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`projects.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:w,disabled:!i(`projects:create`),title:i(`projects:create`)?e(`projects.importProject`):e(`projects.noImportPermission`),children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),e(`projects.import`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:C,disabled:!i(`projects:read`),title:i(`projects:read`)?e(`projects.exportAll`):e(`projects.noExportPermission`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),e(`projects.export`)]}),(0,K.jsxs)($,{onClick:()=>o(!0),className:`sm:w-auto w-full`,disabled:!i(`projects:create`),title:i(`projects:create`)?void 0:e(`projects.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`projects.newProject`)]})]})]}),(0,K.jsx)(`div`,{className:`flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit`,children:[{key:`active`,label:e(`projects.statusActive`),icon:Ss},{key:`completed`,label:e(`projects.statusCompleted`),icon:ms},{key:`archived`,label:e(`projects.statusArchived`),icon:Oo},{key:`all`,label:e(`common.all`),icon:sc}].map(({key:e,label:t,icon:n})=>(0,K.jsxs)(`button`,{onClick:()=>u(e),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${l===e?`bg-bambu-card text-white shadow-sm`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(n,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{children:t}),j[e]>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full ${l===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary`}`,children:j[e]})]},e))}),g?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`projects.loading`)})]})}):h?.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 px-4`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(sc,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:l===`all`?e(`projects.noProjects`):e(`projects.noProjectsFiltered`,{status:l})}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:l===`all`?e(`projects.createFirst`):e(`projects.noProjectsFilteredHelp`,{status:l})}),l===`all`&&(0,K.jsxs)($,{onClick:()=>o(!0),disabled:!i(`projects:create`),title:i(`projects:create`)?void 0:e(`projects.noCreatePermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`projects.createFirstButton`)]})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8`,children:h?.map(t=>(0,K.jsx)(jUe,{project:t,onClick:()=>O(t),onEdit:()=>D(t),onDelete:()=>k(t.id),hasPermission:i,t:e},t.id))}),d!==null&&(0,K.jsx)(Ad,{title:e(`projects.deleteProject`),message:e(`projects.deleteConfirm`),confirmText:e(`projects.deleteProject`),variant:`danger`,onConfirm:A,onCancel:()=>f(null)}),a&&(0,K.jsx)(k6,{project:s,onClose:()=>{o(!1),c(void 0)},onSave:E,isLoading:_.isPending||v.isPending,currencySymbol:m,t:e})]})}function NUe(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)}function PUe(e){return e>=1e3?`${(e/1e3).toFixed(2)}kg`:`${Math.round(e)}g`}function FUe({status:e,t}){let n={active:`bg-bambu-green/20 text-bambu-green`,completed:`bg-blue-500/20 text-blue-400`,archived:`bg-bambu-gray/20 text-bambu-gray`},r=n[e]||n.active,i={active:t(`projectDetail.status.active`),completed:t(`projectDetail.status.completed`),archived:t(`projectDetail.status.archived`)};return(0,K.jsx)(`span`,{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[e]||e.charAt(0).toUpperCase()+e.slice(1)})}function A6({icon:e,label:t,value:n,subValue:r,hint:i,color:a=`text-bambu-gray`}){return(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,title:i,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:(0,K.jsx)(e,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t}),(0,K.jsx)(`p`,{className:`text-xl font-semibold text-white`,children:n}),r&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:r})]})]})})})}function IUe({archives:e,t}){return e.length===0?(0,K.jsxs)(`div`,{className:`text-center py-8 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-12 h-12 mx-auto mb-2 opacity-50`}),(0,K.jsx)(`p`,{children:t(`projectDetail.noPrints`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 gap-3`,children:e.map(e=>(0,K.jsxs)(wi,{to:`/archives?search=${encodeURIComponent(e.print_name||``)}`,className:`group relative aspect-square rounded-lg bg-bambu-dark border border-bambu-dark-tertiary overflow-hidden hover:border-bambu-green transition-colors`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getArchiveThumbnail(e.id),alt:e.print_name||`Print`,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:(0,K.jsx)(pl,{className:`w-8 h-8`})}),e.status===`failed`&&(0,K.jsx)(`div`,{className:`absolute inset-0 bg-red-500/30 flex items-center justify-center`,children:(0,K.jsx)(ys,{className:`w-8 h-8 text-white`})}),e.status===`completed`&&(0,K.jsx)(`div`,{className:`absolute top-1 right-1`,children:(0,K.jsx)(ps,{className:`w-4 h-4 text-bambu-green`})}),(0,K.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/80 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,K.jsx)(`p`,{className:`text-xs text-white truncate`,children:e.print_name||`Unknown`})})]},e.id))})}function LUe({priority:e,t}){let n={low:{color:`bg-gray-500/20 text-gray-400`,label:t(`projectDetail.priority.low`)},normal:{color:`bg-blue-500/20 text-blue-400`,label:t(`projectDetail.priority.normal`)},high:{color:`bg-orange-500/20 text-orange-400`,label:t(`projectDetail.priority.high`)},urgent:{color:`bg-red-500/20 text-red-400`,label:t(`projectDetail.priority.urgent`)}},{color:r,label:i}=n[e]||n.normal;return(0,K.jsxs)(`span`,{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[e===`urgent`&&(0,K.jsx)(Cu,{className:`w-3 h-3`}),i]})}function j6(e,t){if(!e)return null;let n=vf(e);if(!n)return null;let r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:`text-red-400`,label:t(`projectDetail.dueDate.overdue`)}:i===0?{color:`text-orange-400`,label:t(`projectDetail.dueDate.today`)}:i<=3?{color:`text-yellow-400`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}:{color:`text-bambu-gray`,label:t(`projectDetail.dueDate.daysLeft`,{count:i})}}function RUe(){let{id:e}=ir(),t=$n(),{t:n}=W(),r=no(),{showToast:i}=Td(),{hasPermission:a}=dd(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(null),g=parseInt(e||`0`,10),{data:_,isLoading:v,error:b}=q({queryKey:[`project`,g],queryFn:()=>Q.getProject(g),enabled:g>0}),{data:x,isLoading:S}=q({queryKey:[`project-archives`,g],queryFn:()=>Q.getProjectArchives(g),enabled:g>0}),{data:C,isLoading:w}=q({queryKey:[`project-bom`,g],queryFn:()=>Q.getProjectBOM(g),enabled:g>0}),{data:T,isLoading:E}=q({queryKey:[`project-timeline`,g],queryFn:()=>Q.getProjectTimeline(g,20),enabled:g>0}),{data:D}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:O}=q({queryKey:[`project-folders`,g],queryFn:()=>Q.getLibraryFoldersByProject(g),enabled:g>0}),{data:k,isLoading:A}=q({queryKey:[`project-files`,g],queryFn:()=>Q.getLibraryFiles(null,!1,g),enabled:g>0}),j=(0,y.useMemo)(()=>{let e=new Map;for(let t of k??[])if(t.folder_id!=null){let n=e.get(t.folder_id)??[];n.push(t),e.set(t.folder_id,n)}return e},[k]),M=$d(D?.currency||`USD`),N=D?.time_format||`system`,P=J({mutationFn:e=>Q.updateProject(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project`,g]}),r.invalidateQueries({queryKey:[`projects`]}),s(!1),l(!1),i(n(`projectDetail.toast.projectUpdated`),`success`)},onError:e=>{i(e.message,`error`)}}),F=()=>{d(_?.notes||``),l(!0)},I=()=>{P.mutate({notes:u})},L=()=>{l(!1),d(``)},[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(1),[ee,te]=(0,y.useState)(``),[ne,re]=(0,y.useState)(``),[ie,H]=(0,y.useState)(``),[ae,oe]=(0,y.useState)(!1),[U,se]=(0,y.useState)(!1),[ce,le]=(0,y.useState)(null),[ue,de]=(0,y.useState)(``),[fe,pe]=(0,y.useState)(1),[me,he]=(0,y.useState)(``),[ge,_e]=(0,y.useState)(``),[ve,ye]=(0,y.useState)(``),[be,xe]=(0,y.useState)({isOpen:!1,title:``,message:``,onConfirm:()=>{}}),Se=J({mutationFn:e=>Q.createBOMItem(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),z(``),V(1),te(``),re(``),H(``),oe(!1),i(n(`projectDetail.toast.partAdded`),`success`)},onError:e=>i(e.message,`error`)}),Ce=J({mutationFn:({itemId:e,data:t})=>Q.updateBOMItem(g,e,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),le(null)},onError:e=>i(e.message,`error`)}),we=J({mutationFn:e=>Q.deleteBOMItem(g,e),onSuccess:()=>{r.invalidateQueries({queryKey:[`project-bom`,g]}),r.invalidateQueries({queryKey:[`project`,g]}),i(n(`projectDetail.toast.partRemoved`),`success`)},onError:e=>i(e.message,`error`)}),Te=e=>{e.preventDefault(),R.trim()&&Se.mutate({name:R.trim(),quantity_needed:B,unit_price:ee?parseFloat(ee):void 0,sourcing_url:ne.trim()||void 0,remarks:ie.trim()||void 0})},Ee=e=>{let t=e.is_complete?0:e.quantity_needed;Ce.mutate({itemId:e.id,data:{quantity_acquired:t}})},De=(e,t)=>{xe({isOpen:!0,title:n(`projectDetail.bom.deletePart`),message:n(`projectDetail.bom.deleteConfirm`,{name:t}),onConfirm:()=>{xe(e=>({...e,isOpen:!1})),we.mutate(e)}})},Oe=e=>{le(e),de(e.name),pe(e.quantity_needed),he(e.unit_price?.toString()||``),_e(e.sourcing_url||``),ye(e.remarks||``)},ke=e=>{e.preventDefault(),!(!ce||!ue.trim())&&Ce.mutate({itemId:ce.id,data:{name:ue.trim(),quantity_needed:fe,unit_price:me?parseFloat(me):void 0,sourcing_url:ge.trim()||void 0,remarks:ve.trim()||void 0}})},Ae=()=>{le(null)},je=async()=>{try{let{blob:e,filename:t}=await Q.exportProjectZip(Number(g)),r=URL.createObjectURL(e),a=document.createElement(`a`);a.href=r,a.download=t||`${_?.name||`project`}_${new Date().toISOString().split(`T`)[0]}.zip`,a.click(),URL.revokeObjectURL(r),i(n(`projectDetail.toast.projectExported`),`success`)}catch(e){i(e.message,`error`)}},Me=J({mutationFn:()=>Q.createTemplateFromProject(g),onSuccess:()=>{r.invalidateQueries({queryKey:[`projects`]}),i(n(`projectDetail.toast.templateCreated`),`success`)},onError:e=>i(e.message,`error`)}),Ne=e=>bf(e,N,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`});if(v)return(0,K.jsx)(`div`,{className:`flex items-center justify-center py-24`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})});if(b||!_)return(0,K.jsxs)(`div`,{className:`text-center py-24`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:b?`${n(`common.error`)}: ${b.message}`:n(`projectDetail.notFound`)}),(0,K.jsx)($,{variant:`secondary`,className:`mt-4`,onClick:()=>t(`/projects`),children:n(`projectDetail.backToProjects`)})]});let Pe=_.stats,Fe=Pe?.progress_percent??0,Ie=Pe?.parts_progress_percent??0;return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-8`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray`,children:[(0,K.jsx)(wi,{to:`/projects`,className:`hover:text-white transition-colors`,children:n(`nav.projects`)}),(0,K.jsx)(as,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-white`,children:_.name})]}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,K.jsx)(`button`,{onClick:()=>t(`/projects`),className:`p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors`,children:(0,K.jsx)(jo,{className:`w-5 h-5 text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-4 h-4 rounded-full shrink-0`,style:{backgroundColor:_.color||`#6b7280`}}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:_.name}),_.description&&(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:_.description})]})]}),(0,K.jsx)(FUe,{status:_.status,t:n})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:je,disabled:!a(`projects:read`),title:a(`projects:read`)?n(`projectDetail.exportProject`):n(`projectDetail.noExportPermission`),children:[(0,K.jsx)(Vs,{className:`w-4 h-4 mr-2`}),n(`projectDetail.export`)]}),(0,K.jsxs)($,{onClick:()=>s(!0),disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-2`}),n(`common.edit`)]})]})]}),(_.target_count||_.target_parts_count)&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4 space-y-4`,children:[_.target_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.progress.platesProgress`)}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[Pe?.total_archives||0,` / `,_.target_count,` `,n(`projectDetail.progress.printJobs`)]})]}),(0,K.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(Fe,100)}%`,backgroundColor:Fe>=100?`#22c55e`:_.color||`#6b7280`}})}),(0,K.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.percentComplete`,{percent:Fe.toFixed(0)})}),Pe?.remaining_prints!=null&&Pe.remaining_prints>0&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.remaining`,{count:Pe.remaining_prints})})]})]}),_.target_parts_count&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.progress.partsProgress`)}),(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white`,children:[Pe?.completed_prints||0,` / `,_.target_parts_count,` `,n(`projectDetail.progress.parts`)]})]}),(0,K.jsx)(`div`,{className:`h-3 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full transition-all duration-500`,style:{width:`${Math.min(Ie,100)}%`,backgroundColor:Ie>=100?`#22c55e`:_.color||`#6b7280`}})}),(0,K.jsxs)(`div`,{className:`flex justify-between mt-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.percentComplete`,{percent:Ie.toFixed(0)})}),Pe?.remaining_parts!=null&&Pe.remaining_parts>0&&(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.progress.remaining`,{count:Pe.remaining_parts})})]})]})]})}),Pe&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{className:`p-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark text-bambu-green`,children:(0,K.jsx)(pl,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.stats.printJobs`)}),(0,K.jsxs)(`p`,{className:`text-xl font-semibold text-white`,children:[Pe.total_archives,` `,(0,K.jsx)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:n(`projectDetail.stats.total`)})]}),Pe.failed_prints>0&&(0,K.jsx)(`p`,{className:`text-sm text-status-error`,children:n(`projectDetail.stats.failed`,{count:Pe.failed_prints})}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:n(`projectDetail.stats.partsPrinted`,{count:Pe.completed_prints})})]})]})})}),(0,K.jsx)(A6,{icon:Ss,label:n(`projectDetail.stats.printTime`),value:Ef(Pe.total_print_time_hours),color:`text-yellow-400`}),(0,K.jsx)(A6,{icon:Tl,label:n(`projectDetail.stats.filamentUsed`),value:PUe(Pe.total_filament_grams),color:`text-purple-400`})]}),Pe&&(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost;return Pe.estimated_cost>0||e>0||_.budget!==null})()&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white mb-3`,children:n(`projectDetail.cost.title`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.filamentCost`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[M,Pe.estimated_cost.toFixed(2)]})]}),Pe.total_energy_kwh>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.energy`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-white`,children:[Pe.total_energy_kwh.toFixed(3),` kWh`,Pe.total_energy_cost>0&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray ml-1`,children:[`(`,M,Pe.total_energy_cost.toFixed(2),`)`]})]})]}),(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost;return e<=0?null:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.totalCost`)}),(0,K.jsxs)(`p`,{className:`text-lg font-semibold text-bambu-green`,children:[M,e.toFixed(2)]}),Pe.bom_cost>0&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:n(`projectDetail.cost.includesBom`)})]})})(),_.budget!==null&&(()=>{let e=Pe.estimated_cost+Pe.total_energy_cost+Pe.bom_cost,t=_.budget-e;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.cost.budget`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[n(`projectDetail.cost.total`),`: `,(0,K.jsxs)(`span`,{className:`text-white font-semibold`,children:[M,_.budget.toFixed(2)]})]}),(0,K.jsxs)(`p`,{className:`text-sm ${t>=0?`text-bambu-green`:`text-red-400`}`,children:[n(`projectDetail.cost.remaining`),`: `,(0,K.jsxs)(`span`,{className:`font-semibold`,children:[M,t.toFixed(2)]})]})]})})()]})]})}),_.children&&_.children.length>0&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2 mb-3`,children:[(0,K.jsx)(dc,{className:`w-5 h-5`}),n(`projectDetail.subProjects.title`,{count:_.children.length})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:_.children.map(e=>(0,K.jsxs)(wi,{to:`/projects/${e.id}`,className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full`,style:{backgroundColor:e.color||`#6b7280`}}),(0,K.jsx)(`span`,{className:`text-white`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded ${e.status===`completed`?`bg-status-ok/20 text-status-ok`:e.status===`archived`?`bg-bambu-gray/20 text-bambu-gray`:`bg-blue-500/20 text-blue-400`}`,children:e.status})]}),e.progress_percent!==null&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e.progress_percent.toFixed(0),`%`]})]},e.id))})]})}),_.parent_id&&_.parent_name&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.partOf`)}),(0,K.jsx)(wi,{to:`/projects/${_.parent_id}`,className:`text-bambu-green hover:underline`,children:_.parent_name})]}),(_.tags||_.due_date||_.priority!==`normal`)&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[_.priority&&_.priority!==`normal`&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray uppercase`,children:n(`projectDetail.priorityLabel`)}),(0,K.jsx)(LUe,{priority:_.priority,t:n})]}),_.due_date&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Zo,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:yf(_.due_date,{year:`numeric`,month:`short`,day:`numeric`})}),j6(_.due_date,n)&&(0,K.jsxs)(`span`,{className:`text-xs ${j6(_.due_date,n).color}`,children:[`(`,j6(_.due_date,n).label,`)`]})]}),_.tags&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:_.tags.split(`,`).map((e,t)=>(0,K.jsx)(`span`,{className:`px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded`,children:e.trim()},t))})]})]}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-5 h-5`}),n(`projectDetail.notes.title`)]}),c?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:L,disabled:P.isPending,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 mr-1`}),n(`common.cancel`)]}),(0,K.jsxs)($,{size:`sm`,onClick:I,disabled:P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}):(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),n(`common.save`)]})]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:F,disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.notes.noEditPermission`),children:[(0,K.jsx)(gl,{className:`w-4 h-4 mr-1`}),n(`common.edit`)]})]}),c?(0,K.jsx)(X0,{content:u,onChange:d,placeholder:n(`projectDetail.notes.placeholder`)}):_.notes?(0,K.jsx)(`div`,{className:`prose prose-invert prose-sm max-w-none`,dangerouslySetInnerHTML:{__html:HG.sanitize(_.notes)}}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.notes.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(cc,{className:`w-5 h-5`}),n(`projectDetail.files.title`)]})}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mb-3`,children:[(0,K.jsx)(wi,{to:`/files`,className:`text-bambu-green hover:underline`,children:n(`projectDetail.files.linkFolders`)}),` `,n(`projectDetail.files.forQuickAccess`)]}),O&&O.length>0?(0,K.jsx)(`div`,{className:`space-y-4`,children:O.map(e=>{let t=j.get(e.id)??[],r=A;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(wi,{to:`/files?folder=${e.id}`,className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(cc,{className:`w-5 h-5 text-bambu-green shrink-0`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,children:e.name}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`projectDetail.files.fileCount`,{count:e.file_count})})]})]}),(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray shrink-0`})]}),r?(0,K.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-bambu-gray text-sm`,children:(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`})}):t.length===0?(0,K.jsx)(`p`,{className:`text-bambu-gray/60 text-xs italic px-3`,children:n(`projectDetail.files.noFiles`)}):(0,K.jsx)(`div`,{className:`space-y-1 pl-3`,children:t.map(e=>{let t=NUe(e.filename);return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 shrink-0 rounded bg-bambu-dark overflow-hidden flex items-center justify-center`,children:e.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getLibraryFileThumbnailUrl(e.id),alt:e.print_name||e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(Qs,{className:`w-5 h-5 text-bambu-gray/40`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white truncate`,title:e.print_name||e.filename,children:e.print_name||e.filename}),(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded font-medium ${e.file_type===`3mf`?`bg-bambu-green/20 text-bambu-green`:e.file_type===`gcode`||e.file_type===`gcode.3mf`?`bg-blue-500/20 text-blue-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:e.file_type.toUpperCase()})]}),t&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`button`,{onClick:()=>p(e),title:n(`projectDetail.files.print`),className:`p-1.5 rounded hover:bg-bambu-green/20 text-bambu-green transition-colors`,children:(0,K.jsx)(bl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>h(e),title:n(`projectDetail.files.addToQueue`),className:`p-1.5 rounded hover:bg-blue-500/20 text-blue-400 transition-colors`,children:(0,K.jsx)(Xo,{className:`w-4 h-4`})})]})]},e.id)})})]},e.id)})}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.files.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Jl,{className:`w-5 h-5`}),n(`projectDetail.bom.title`),Pe&&Pe.bom_total_items>0&&(0,K.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n(`projectDetail.bom.acquired`,{completed:Pe.bom_completed_items,total:Pe.bom_total_items}),`)`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[C&&C.some(e=>e.is_complete)&&(0,K.jsx)(`button`,{onClick:()=>se(!U),className:`text-xs px-2 py-1 rounded transition-colors ${U?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:text-white`}`,children:n(U?`projectDetail.bom.showAll`:`projectDetail.bom.hideDone`)}),!ae&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>oe(!0),disabled:!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.bom.noAddPermission`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-1`}),n(`projectDetail.bom.addPart`)]})]})]}),ae&&(0,K.jsxs)(`form`,{onSubmit:Te,className:`bg-bambu-dark rounded-lg p-4 mb-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>z(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.partNamePlaceholder`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:B,onChange:e=>V(parseInt(e.target.value)||1),className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:`1`,placeholder:n(`projectDetail.bom.qty`)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,value:ee,onChange:e=>te(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.price`,{currency:M})})]})]}),(0,K.jsx)(`input`,{type:`url`,value:ne,onChange:e=>re(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,K.jsx)(`input`,{type:`text`,value:ie,onChange:e=>H(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.remarksPlaceholder`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>oe(!1),children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:!R.trim()||Se.isPending,children:Se.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`projectDetail.bom.addPart`)})]})]}),w?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):C&&C.length>0?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[C.filter(e=>!U||!e.is_complete).map(e=>(0,K.jsx)(`div`,{className:`p-3 rounded-lg transition-colors ${e.is_complete?`bg-status-ok/10`:`bg-bambu-dark`}`,children:ce?.id===e.id?(0,K.jsxs)(`form`,{onSubmit:ke,className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,K.jsx)(`input`,{type:`text`,value:ue,onChange:e=>de(e.target.value),className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.partName`),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`number`,value:fe,onChange:e=>pe(parseInt(e.target.value)||1),className:`w-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white focus:outline-none focus:border-bambu-green`,min:`1`,placeholder:n(`projectDetail.bom.qty`)}),(0,K.jsx)(`input`,{type:`number`,step:`0.01`,value:me,onChange:e=>he(e.target.value),className:`flex-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.price`,{currency:M})})]})]}),(0,K.jsx)(`input`,{type:`url`,value:ge,onChange:e=>_e(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.sourcingUrlPlaceholder`)}),(0,K.jsx)(`input`,{type:`text`,value:ve,onChange:e=>ye(e.target.value),className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:n(`projectDetail.bom.remarksPlaceholder`)}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,size:`sm`,onClick:Ae,children:n(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:!ue.trim()||Ce.isPending,children:Ce.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):n(`common.save`)})]})]}):(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&Ee(e),disabled:Ce.isPending||!a(`projects:update`),title:a(`projects:update`)?void 0:n(`projectDetail.bom.noUpdatePermission`),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors shrink-0 ${e.is_complete?`bg-status-ok border-status-ok text-white`:a(`projects:update`)?`border-bambu-gray hover:border-bambu-green`:`border-bambu-gray/50 cursor-not-allowed`}`,children:e.is_complete&&(0,K.jsx)(ps,{className:`w-3 h-3`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-sm font-medium ${e.is_complete?`text-bambu-gray line-through`:`text-white`}`,children:[e.name,(0,K.jsxs)(`span`,{className:`text-bambu-gray font-normal ml-2`,children:[`x`,e.quantity_needed]})]}),e.unit_price!==null&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-green whitespace-nowrap`,children:[M,(e.unit_price*e.quantity_needed).toFixed(2)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&Oe(e),disabled:!a(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${a(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`projects:update`)?n(`common.edit`):n(`projectDetail.bom.noEditPermission`),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`projects:update`)&&De(e.id,e.name),disabled:!a(`projects:update`),className:`p-1 rounded transition-colors shrink-0 ${a(`projects:update`)?`hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`projects:update`)?n(`common.delete`):n(`projectDetail.bom.noDeletePermission`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]}),e.sourcing_url&&(0,K.jsxs)(`a`,{href:e.sourcing_url,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 mt-1 text-xs text-blue-400 hover:text-blue-300 transition-colors`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(Js,{className:`w-3 h-3 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:(()=>{try{return new URL(e.sourcing_url).hostname.replace(`www.`,``)}catch{return e.sourcing_url}})()})]}),e.remarks&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray/80 italic`,children:e.remarks})]})]})},e.id)),Pe&&Pe.bom_cost>0&&(0,K.jsxs)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.bom.totalCost`)}),(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[M,Pe.bom_cost.toFixed(2)]})]})]}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.bom.empty`)})]})}),(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-3`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(kc,{className:`w-5 h-5`}),n(`projectDetail.timeline.title`)]})}),E?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):T&&T.length>0?(0,K.jsx)(`div`,{className:`space-y-3`,children:T.slice(0,10).map((e,t)=>(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${e.event_type===`print_completed`?`bg-status-ok/20 text-status-ok`:e.event_type===`print_failed`?`bg-status-error/20 text-status-error`:e.event_type===`print_started`?`bg-yellow-500/20 text-yellow-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[e.event_type===`print_completed`&&(0,K.jsx)(ps,{className:`w-4 h-4`}),e.event_type===`print_failed`&&(0,K.jsx)(ys,{className:`w-4 h-4`}),e.event_type===`print_started`&&(0,K.jsx)(Tl,{className:`w-4 h-4`}),e.event_type===`queued`&&(0,K.jsx)(Wc,{className:`w-4 h-4`}),e.event_type===`project_created`&&(0,K.jsx)(Sl,{className:`w-4 h-4`})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white`,children:e.title}),e.description&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:e.description}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:Ne(e.timestamp)})]})]},t))}):(0,K.jsx)(`p`,{className:`text-bambu-gray/70 text-sm italic`,children:n(`projectDetail.timeline.empty`)})]})}),!_.is_template&&(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>Me.mutate(),disabled:Me.isPending||!a(`projects:create`),title:a(`projects:create`)?void 0:n(`projectDetail.template.noCreatePermission`),children:[Me.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-2`}):(0,K.jsx)(Ms,{className:`w-4 h-4 mr-2`}),n(`projectDetail.template.saveAsTemplate`)]})}),Pe&&(Pe.queued_prints>0||Pe.in_progress_prints>0)&&(0,K.jsx)(_d,{children:(0,K.jsxs)(yd,{className:`p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Wc,{className:`w-5 h-5`}),n(`projectDetail.queue.title`)]}),(0,K.jsx)(wi,{to:`/queue?project=${g}`,className:`text-sm text-bambu-green hover:underline`,children:n(`projectDetail.queue.viewAll`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm`,children:[Pe.in_progress_prints>0&&(0,K.jsx)(`span`,{className:`text-yellow-400`,children:n(`projectDetail.queue.printing`,{count:Pe.in_progress_prints})}),Pe.queued_prints>0&&(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`projectDetail.queue.queued`,{count:Pe.queued_prints})})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(pl,{className:`w-5 h-5`}),n(`projectDetail.prints.title`,{count:x?.length||0})]})}),S?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,K.jsx)(X,{className:`w-6 h-6 animate-spin text-bambu-green`})}):(0,K.jsx)(IUe,{archives:x||[],t:n})]}),o&&(0,K.jsx)(k6,{t:n,currencySymbol:M,project:{..._,archive_count:Pe?.total_archives||0,total_items:Pe?.total_items||0,completed_count:Pe?.completed_prints||0,failed_count:Pe?.failed_prints||0,queue_count:Pe?.queued_prints||0,progress_percent:Pe?.progress_percent||null,archives:[]},onClose:()=>s(!1),onSave:e=>P.mutate(e),isLoading:P.isPending}),be.isOpen&&(0,K.jsx)(Ad,{title:be.title,message:be.message,confirmText:n(`common.delete`),variant:`danger`,onConfirm:be.onConfirm,onCancel:()=>xe(e=>({...e,isOpen:!1}))}),f&&(0,K.jsx)(sW,{mode:`reprint`,libraryFileId:f.id,archiveName:f.print_name||f.filename,projectId:g,onClose:()=>p(null),onSuccess:()=>{p(null),r.invalidateQueries({queryKey:[`archives`]})}}),m&&(0,K.jsx)(sW,{mode:`add-to-queue`,libraryFileId:m.id,archiveName:m.print_name||m.filename,projectId:g,onClose:()=>h(null),onSuccess:()=>{h(null),r.invalidateQueries({queryKey:[`queue`]})}})]})}function zUe({archiveId:e,libraryFileId:t,title:n,fileType:r,onClose:i,onSliceWithBambuddy:a}){let{t:o}=W(),{data:s}=q({queryKey:[`settings`],queryFn:Q.getSettings}),c=s?.open_in_slicer||s?.preferred_slicer||`bambu_studio`,l=t!=null,[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(null),[m,h]=(0,y.useState)(!0),[g,_]=(0,y.useState)(null),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(null),[C,w]=(0,y.useState)(0),[T,E]=(0,y.useState)(!1),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),N=(0,y.useRef)(null),P=(0,y.useRef)(null),F=.35;(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,y.useEffect)(()=>{if(h(!0),l){let e=(r||``).toLowerCase(),t=e===`3mf`||e===`gcode.3mf`,n=t||e===`stl`,i=t||e===`gcode`;p({has_model:n,has_gcode:i,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(n?`3d`:i?`gcode`:null),h(!1);return}if(!e){p(null),d(null),h(!1);return}Q.getArchiveCapabilities(e).then(e=>{p(e),e.has_model?d(`3d`):e.has_gcode&&d(`gcode`),h(!1)}).catch(()=>{p({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),d(`3d`),h(!1)})},[e,r,l]),(0,y.useEffect)(()=>{if(b(!0),S(null),w(0),l){let e=(r||``).toLowerCase();if(!t||!(e===`3mf`||e===`gcode.3mf`)){_(null),b(!1);return}Q.getLibraryFilePlates(t).then(e=>_(e)).catch(()=>_(null)).finally(()=>b(!1));return}if(!e){_(null),b(!1);return}Q.getArchivePlates(e).then(e=>_(e)).catch(()=>_(null)).finally(()=>b(!1))},[e,r,l,t]);let I=(0,y.useMemo)(()=>g?.plates??[],[g]),L=(g?.is_multi_plate??!1)&&I.length>1,R=T&&L,z=x==null?null:I.find(e=>e.index===x)??null,B=e=>e.object_count??e.objects?.length??0,V=I.reduce((e,t)=>e+B(t),0),ee=z?B(z):V,te=z?o(`modelViewer.plateNumber`,{number:z.index}):o(`modelViewer.allPlates`),ne=I.length>0,re=(0,y.useRef)(null),ie=(0,y.useRef)(null),[H,ae]=(0,y.useState)(10),[oe,U]=(0,y.useState)(3),se=I.length>H,ce=Math.max(1,Math.ceil(I.length/H)),le=se?I.slice(C*H,(C+1)*H):I;(0,y.useEffect)(()=>{if(!R){ae(10),U(3);return}let e=re.current,t=ie.current;if(!e||!t)return;let n=0,r=()=>{let n=t.clientWidth,r=Math.floor(n/210),i=Math.max(3,Math.min(5,r||3));U(e=>e===i?e:i);let a=window.getComputedStyle(e),o=Number.parseFloat(a.rowGap||`0`),s=e.querySelector(`button`)?.getBoundingClientRect().height??44,c=t.clientHeight,l=Math.max(1,Math.floor((c+o)/(s+o)))*i,u=Math.max(1,l-1);ae(e=>e===u?e:u)},i=()=>{n&&cancelAnimationFrame(n),n=requestAnimationFrame(r)};i();let a=new ResizeObserver(i);return a.observe(t),a.observe(e),()=>{n&&cancelAnimationFrame(n),a.disconnect()}},[R,I.length]),(0,y.useEffect)(()=>{if(!se){w(0);return}w(e=>Math.min(e,ce-1))},[I.length,se,ce]),(0,y.useEffect)(()=>{if(!se||x==null)return;let e=I.findIndex(e=>e.index===x);if(e<0)return;let t=Math.floor(e/H);w(e=>e===t?e:t)},[I,H,x,se]),(0,y.useEffect)(()=>{if(!R){O(null),M(!1);return}if(j)return;let e=N.current,t=P.current;if(!e||!t)return;let n=e.clientHeight;if(!n)return;let r=Math.max(240,n*F),i=Math.max(160,n-10-r),a=Math.min(t.scrollHeight,i);O(Math.max(160,a))},[R,j,I.length,C,10,160,240,F]),(0,y.useEffect)(()=>{if(!k)return;let e=e=>{let t=N.current;if(!t)return;let n=t.getBoundingClientRect(),r=n.height;if(!r)return;let i=Math.max(240,r*F),a=Math.max(160,r-10-i);O(Math.min(a,Math.max(160,e.clientY-n.top)))},t=()=>{A(!1),M(!0)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`row-resize`,document.body.style.userSelect=`none`,()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[k,10,160,240,F]);let ue=l?(r||``).toLowerCase()===`3mf`:!0,de=(()=>{let e=(r||``).toLowerCase();return e===`3mf`||e===`stl`||e===`step`||e===`stp`})(),fe=!!(l&&s?.use_slicer_api&&a&&de);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 ${T?`p-0`:`p-8`}`,onClick:i,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary w-full flex flex-col ${T?`h-full max-w-none rounded-none`:`h-[80vh] max-w-4xl rounded-xl`}`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1 mr-4`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate`,children:n}),ne&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary/70 px-2 py-1 rounded whitespace-nowrap`,children:[te,`: `,o(`modelViewer.objectCount`,{count:ee})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[fe?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:a,children:[(0,K.jsx)(ks,{className:`w-4 h-4`}),o(`slice.action`)]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:async()=>{if(!ue)return;let r=n||`model`;try{if(l){let{token:e}=await Q.createLibrarySlicerToken(t),n=Q.getLibrarySlicerDownloadUrl(t,e,r);HW(`${window.location.origin}${n}`,c)}else{let{token:t}=await Q.createArchiveSlicerToken(e),n=Q.getArchiveSlicerDownloadUrl(e,t,r);HW(`${window.location.origin}${n}`,c)}}catch{HW(l?`${window.location.origin}${Q.getLibraryFileDownloadUrl(t)}`:`${window.location.origin}${Q.getArchiveForSlicer(e,r)}`,c)}},disabled:!ue,children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),o(`modelViewer.openInSlicer`)]}),(0,K.jsx)($,{variant:`secondary`,size:`sm`,onClick:()=>E(e=>!e),title:T?`Exit fullscreen`:`Enter fullscreen`,children:T?(0,K.jsx)(rl,{className:`w-4 h-4`}):(0,K.jsx)($c,{className:`w-4 h-4`})}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:i,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),f&&(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`button`,{onClick:()=>f.has_model&&d(`3d`),disabled:!f.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u===`3d`?`text-bambu-green border-b-2 border-bambu-green`:f.has_model?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Wo,{className:`w-4 h-4`}),o(`modelViewer.tabs.model`),!f.has_model&&(0,K.jsxs)(`span`,{className:`text-xs`,children:[`(`,o(`modelViewer.notAvailable`),`)`]})]}),(0,K.jsxs)(`button`,{onClick:()=>f.has_gcode&&d(`gcode`),disabled:!f.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${u===`gcode`?`text-bambu-green border-b-2 border-bambu-green`:f.has_gcode?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,K.jsx)(Ts,{className:`w-4 h-4`}),o(`modelViewer.tabs.gcode`),!f.has_gcode&&(0,K.jsxs)(`span`,{className:`text-xs`,children:[`(`,o(`modelViewer.notSliced`),`)`]})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-hidden p-4`,children:m?(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})}):u===`3d`&&f?(0,K.jsxs)(`div`,{ref:N,className:`w-full h-full flex flex-col ${R?`gap-0 min-h-0`:`gap-3`}`,children:[L&&(0,K.jsxs)(`div`,{ref:P,style:R&&D!=null?{height:D}:void 0,className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3 ${R?`flex flex-col shrink-0`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4`}),o(`modelViewer.plates`),v&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`})]}),(0,K.jsxs)(`div`,{className:R?`flex flex-col min-h-0 flex-1`:void 0,children:[(0,K.jsx)(`div`,{ref:ie,className:R?`min-h-0 overflow-hidden pr-1 flex-1`:void 0,children:(0,K.jsxs)(`div`,{ref:re,className:R?`grid gap-2`:`grid grid-cols-2 md:grid-cols-3 gap-2`,style:R?{gridTemplateColumns:`repeat(${oe}, minmax(0, 1fr))`}:void 0,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>S(null),className:`flex items-center rounded-lg border text-left transition-colors ${R?`gap-1.5 p-1.5 w-full`:`gap-2 p-2`} ${x==null?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[(0,K.jsx)(`div`,{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${R?`w-8 h-8`:`w-10 h-10`}`,children:(0,K.jsx)(Rc,{className:`${R?`w-4 h-4`:`w-5 h-5`} text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`${R?`text-xs`:`text-sm`} text-white font-medium truncate`,children:o(`modelViewer.allPlates`)}),(0,K.jsx)(`p`,{className:`${R?`text-[10px]`:`text-xs`} text-bambu-gray truncate`,children:o(`modelViewer.plateCount`,{count:I.length})})]}),x==null&&(0,K.jsx)(rs,{className:`${R?`w-3.5 h-3.5`:`w-4 h-4`} text-bambu-green flex-shrink-0`})]}),le.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>S(e.index),className:`flex items-center rounded-lg border text-left transition-colors ${R?`gap-1.5 p-1.5 w-full`:`gap-2 p-2`} ${x===e.index?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[e.has_thumbnail&&e.thumbnail_url?(0,K.jsx)(`img`,{src:e.thumbnail_url,alt:`Plate ${e.index}`,className:`${R?`w-8 h-8`:`w-10 h-10`} rounded object-cover bg-bambu-dark-tertiary`}):(0,K.jsx)(`div`,{className:`rounded bg-bambu-dark-tertiary flex items-center justify-center ${R?`w-8 h-8`:`w-10 h-10`}`,children:(0,K.jsx)(Rc,{className:`${R?`w-4 h-4`:`w-5 h-5`} text-bambu-gray`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`${R?`text-xs`:`text-sm`} text-white font-medium truncate`,children:e.name||o(`modelViewer.plateNumber`,{number:e.index})}),(0,K.jsx)(`p`,{className:`${R?`text-[10px]`:`text-xs`} text-bambu-gray truncate`,children:o(`modelViewer.objectCount`,{count:e.object_count??e.objects?.length??0})})]}),x===e.index&&(0,K.jsx)(rs,{className:`${R?`w-3.5 h-3.5`:`w-4 h-4`} text-bambu-green flex-shrink-0`})]},e.index))]})}),(z||se)&&(0,K.jsxs)(`div`,{className:`mt-auto pt-3 flex items-center gap-4 text-xs text-bambu-gray overflow-x-auto`,children:[z&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 whitespace-nowrap`,children:[(0,K.jsx)(`span`,{children:o(`modelViewer.plateNumber`,{number:z.index})}),z.print_time_seconds!=null&&(0,K.jsx)(`span`,{children:o(`modelViewer.eta`,{minutes:Math.round(z.print_time_seconds/60)})}),z.filament_used_grams!=null&&(0,K.jsxs)(`span`,{children:[z.filament_used_grams.toFixed(1),` g`]}),z.filaments.length>0&&(0,K.jsx)(`span`,{children:o(`modelViewer.filamentCount`,{count:z.filaments.length})})]}),se&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 whitespace-nowrap ${z?`ml-auto`:``}`,children:[(0,K.jsx)(`span`,{children:o(`modelViewer.pagination.pageOf`,{current:C+1,total:ce})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e=>Math.max(e-1,0)),disabled:C===0,className:`px-2 py-1 rounded border text-xs ${C===0?`border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:o(`modelViewer.pagination.prev`)}),(()=>{let e=Math.max(0,C-2),t=Math.min(ce,e+5);t-e<5&&(e=Math.max(0,t-5));let n=Array.from({length:t-e},(t,n)=>e+n);return(0,K.jsxs)(K.Fragment,{children:[e>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(0),className:`px-2 py-1 rounded border text-xs ${C===0?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:`1`}),e>1&&(0,K.jsx)(`span`,{className:`px-1`,children:`…`}),n.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e),className:`px-2 py-1 rounded border text-xs ${C===e?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:e+1},e)),tw(ce-1),className:`px-2 py-1 rounded border text-xs ${C===ce-1?`border-bambu-green text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:ce})]})})(),(0,K.jsx)(`button`,{type:`button`,onClick:()=>w(e=>Math.min(e+1,ce-1)),disabled:C>=ce-1,className:`px-2 py-1 rounded border text-xs ${C>=ce-1?`border-bambu-dark-tertiary text-bambu-gray/40 cursor-not-allowed`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white hover:border-bambu-gray`}`,children:o(`modelViewer.pagination.next`)})]})]})]})]})]}),R&&(0,K.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,onMouseDown:e=>{e.preventDefault(),A(!0),M(!0)},className:`h-2 cursor-row-resize flex items-center justify-center ${k?`bg-bambu-dark-tertiary`:`bg-bambu-dark-secondary/60 hover:bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`div`,{className:`w-12 h-1 rounded-full bg-bambu-gray/50`})}),(0,K.jsx)(`div`,{className:`flex-1 ${R?`min-h-0`:``}`,children:(0,K.jsx)(ly,{url:l?Q.getLibraryFileDownloadUrl(t):f.has_source?Q.getSource3mfDownloadUrl(e):Q.getArchiveDownload(e),fileType:r,buildVolume:f.build_volume,filamentColors:f.filament_colors,selectedPlateId:x,className:`w-full h-full`})})]}):u===`gcode`&&f?(0,K.jsx)(aT,{gcodeUrl:l?Q.getLibraryFileGcodeUrl(t):Q.getArchiveGcode(e),filamentColors:f.filament_colors,className:`w-full h-full`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:o(`modelViewer.noPreview`)})})]})})}var M6=[`library-tags`];function BUe({open:e,fileIds:t,onClose:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(`add`),[c,l]=(0,y.useState)(new Set),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(``);(0,y.useEffect)(()=>{e||(s(`add`),l(new Set),d(``),p(``))},[e]);let{data:m=[],isLoading:h}=q({queryKey:M6,queryFn:Q.getLibraryTags,enabled:e}),g=(0,y.useMemo)(()=>{let e=u.trim().toLowerCase();return e?m.filter(t=>t.name.toLowerCase().includes(e)):m},[m,u]),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=J({mutationFn:e=>Q.createLibraryTag(e),onSuccess:e=>{l(t=>new Set(t).add(e.id)),p(``),i.invalidateQueries({queryKey:M6})},onError:e=>{a(e.message||r(`fileManager.tags.saveFailed`),`error`)}}),b=J({mutationFn:()=>Q.bulkAssignLibraryTags(t,Array.from(c),o),onSuccess:e=>{a(o===`add`?r(`fileManager.tags.applyAddSuccess`,{count:e.associations_added,files:e.files_updated}):r(`fileManager.tags.applyRemoveSuccess`,{count:e.associations_removed,files:e.files_updated}),`success`),i.invalidateQueries({queryKey:[`library-files`]}),i.invalidateQueries({queryKey:M6}),n()},onError:e=>{a(e.message||r(`fileManager.tags.applyFailed`),`error`)}});if((0,y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&!b.isPending&&!v.isPending&&n()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,n,b.isPending,v.isPending]),!e)return null;let x=!f.trim()||v.isPending||m.some(e=>e.name.toLowerCase()===f.trim().toLowerCase()),S=`bulk-tags-picker-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>!b.isPending&&n()}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":S,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-5 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h3`,{id:S,className:`text-base font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-4 h-4 text-bambu-green`}),r(`fileManager.tags.bulkTitle`,{count:t.length})]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:n,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`px-5 py-3 border-b border-bambu-dark-tertiary flex gap-4 text-sm`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`bulk-action`,checked:o===`add`,onChange:()=>s(`add`),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:r(`fileManager.tags.actionAdd`)})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`radio`,name:`bulk-action`,checked:o===`remove`,onChange:()=>s(`remove`),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-white`,children:r(`fileManager.tags.actionRemove`)})]})]}),(0,K.jsx)(`div`,{className:`px-5 py-3 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`input`,{type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:r(`fileManager.tags.searchPlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`div`,{className:`overflow-y-auto flex-1 min-h-[8rem] max-h-[24rem]`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-12 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-5 h-5 animate-spin mr-2`}),r(`common.loading`)]}):g.length===0?(0,K.jsx)(`div`,{className:`py-12 text-center text-bambu-gray text-sm`,children:m.length===0?r(`fileManager.tags.empty`):r(`fileManager.tags.noMatches`)}):(0,K.jsx)(`ul`,{className:`divide-y divide-bambu-dark-tertiary/40`,children:g.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-5 py-2 hover:bg-bambu-dark-tertiary/30 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c.has(e.id),onChange:()=>_(e.id),className:`accent-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white truncate flex-1`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.file_count})]})},e.id))})}),o===`add`&&(0,K.jsxs)(`div`,{className:`px-5 py-3 border-t border-bambu-dark-tertiary flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:r(`fileManager.tags.createPlaceholder`),maxLength:64,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,onKeyDown:e=>{e.key===`Enter`&&!x&&(e.preventDefault(),v.mutate(f.trim()))}}),(0,K.jsxs)($,{type:`button`,variant:`secondary`,onClick:()=>v.mutate(f.trim()),disabled:x,children:[v.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`fileManager.tags.createButton`)]})]}),(0,K.jsxs)(`div`,{className:`px-5 py-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:n,disabled:b.isPending,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`button`,onClick:()=>b.mutate(),disabled:c.size===0||b.isPending||t.length===0,children:[b.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(o===`add`?`fileManager.tags.applyAdd`:`fileManager.tags.applyRemove`)]})]})]})]})}function VUe(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var HUe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,UUe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,WUe={};function N6(e,t){return((t||WUe).jsx?UUe:HUe).test(e)}var GUe=/[ \t\n\f\r]/g;function KUe(e){return typeof e==`object`?e.type===`text`?P6(e.value):!1:P6(e)}function P6(e){return e.replace(GUe,``)===``}var F6=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};F6.prototype.normal={},F6.prototype.property={},F6.prototype.space=void 0;function I6(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new F6(n,r,t)}function L6(e){return e.toLowerCase()}var R6=class{constructor(e,t){this.attribute=t,this.property=e}};R6.prototype.attribute=``,R6.prototype.booleanish=!1,R6.prototype.boolean=!1,R6.prototype.commaOrSpaceSeparated=!1,R6.prototype.commaSeparated=!1,R6.prototype.defined=!1,R6.prototype.mustUseProperty=!1,R6.prototype.number=!1,R6.prototype.overloadedBoolean=!1,R6.prototype.property=``,R6.prototype.spaceSeparated=!1,R6.prototype.space=void 0;var z6=s({boolean:()=>B6,booleanish:()=>V6,commaOrSpaceSeparated:()=>K6,commaSeparated:()=>G6,number:()=>U6,overloadedBoolean:()=>H6,spaceSeparated:()=>W6}),qUe=0,B6=q6(),V6=q6(),H6=q6(),U6=q6(),W6=q6(),G6=q6(),K6=q6();function q6(){return 2**++qUe}var J6=Object.keys(z6),Y6=class extends R6{constructor(e,t,n,r){let i=-1;if(super(e,t),X6(this,`space`,r),typeof n==`number`)for(;++i4&&n.slice(0,4)===`data`&&QUe.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(i8,tWe);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!i8.test(e)){let n=e.replace(ZUe,eWe);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Y6}return new i(r,t)}function eWe(e){return`-`+e.toLowerCase()}function tWe(e){return e.charAt(1).toUpperCase()}var nWe=I6([Q6,JUe,t8,n8,r8],`html`),a8=I6([Q6,YUe,t8,n8,r8],`svg`);function rWe(e){return e.join(` `).trim()}var iWe=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=` `,d=`/`,f=`*`,p=``,m=`comment`,h=`declaration`;function g(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,g=1;function v(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(u);g=~n?e.length-n:g+e.length}function y(){var e={line:l,column:g};return function(t){return t.position=new b(e),C(),t}}function b(e){this.start=e,this.end={line:l,column:g},this.source=t.source}b.prototype.content=e;function x(n){var r=Error(t.source+`:`+l+`:`+g+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=g,r.source=e,!t.silent)throw r}function S(t){var n=t.exec(e);if(n){var r=n[0];return v(r),e=e.slice(r.length),n}}function C(){S(i)}function w(e){var t;for(e||=[];t=T();)t!==!1&&e.push(t);return e}function T(){var t=y();if(!(d!=e.charAt(0)||f!=e.charAt(1))){for(var n=2;p!=e.charAt(n)&&(f!=e.charAt(n)||d!=e.charAt(n+1));)++n;if(n+=2,p===e.charAt(n-1))return x(`End of comment missing`);var r=e.slice(2,n-2);return g+=2,v(r),e=e.slice(n),g+=2,t({type:m,comment:r})}}function E(){var e=y(),t=S(a);if(t){if(T(),!S(o))return x(`property missing ':'`);var r=S(s),i=e({type:h,property:_(t[0].replace(n,p)),value:r?_(r[0].replace(n,p)):p});return S(c),i}}function D(){var e=[];w(e);for(var t;t=E();)t!==!1&&(e.push(t),w(e));return e}return C(),D()}function _(e){return e?e.replace(l,p):p}t.exports=g})),aWe=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(iWe());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),oWe=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),sWe=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(aWe()),r=oWe();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),o8=c8(`end`),s8=c8(`start`);function c8(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function cWe(e){let t=s8(e),n=o8(e);if(t&&n)return{start:t,end:n}}function l8(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?d8(e.position):`start`in e||`end`in e?d8(e):`line`in e||`column`in e?u8(e):``}function u8(e){return f8(e&&e.line)+`:`+f8(e&&e.column)}function d8(e){return u8(e&&e.start)+`-`+u8(e&&e.end)}function f8(e){return e&&typeof e==`number`?e:1}var p8=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=l8(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};p8.prototype.file=``,p8.prototype.name=``,p8.prototype.reason=``,p8.prototype.message=``,p8.prototype.stack=``,p8.prototype.column=void 0,p8.prototype.line=void 0,p8.prototype.ancestors=void 0,p8.prototype.cause=void 0,p8.prototype.fatal=void 0,p8.prototype.place=void 0,p8.prototype.ruleId=void 0,p8.prototype.source=void 0;var lWe=l(sWe(),1),m8={}.hasOwnProperty,uWe=new Map,dWe=/[A-Z]/g,fWe=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),pWe=new Set([`td`,`th`]);function mWe(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=SWe(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=xWe(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?a8:nWe,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=h8(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function h8(e,t,n){if(t.type===`element`)return hWe(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return gWe(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return vWe(e,t,n);if(t.type===`mdxjsEsm`)return _We(e,t);if(t.type===`root`)return yWe(e,t,n);if(t.type===`text`)return bWe(e,t)}function hWe(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=a8,e.schema=i),e.ancestors.push(t);let a=y8(e,t.tagName,!1),o=CWe(e,t),s=v8(e,t);return fWe.has(t.tagName)&&(s=s.filter(function(e){return typeof e==`string`?!KUe(e):!0})),g8(e,o,a,t),_8(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function gWe(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}b8(e,t.position)}function _We(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);b8(e,t.position)}function vWe(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=a8,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:y8(e,t.name,!0),o=wWe(e,t),s=v8(e,t);return g8(e,o,a,t),_8(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function yWe(e,t,n){let r={};return _8(r,v8(e,t)),e.create(t,e.Fragment,r,n)}function bWe(e,t){return t.value}function g8(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function _8(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function xWe(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function SWe(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=s8(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function CWe(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&m8.call(t.properties,i)){let a=TWe(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&pWe.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function wWe(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`)if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else b8(e,t.position);else{let i=r.name,a;if(r.value&&typeof r.value==`object`)if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else b8(e,t.position);else a=r.value===null?!0:r.value;n[i]=a}return n}function v8(e,t){let n=[],r=-1,i=e.passKeys?new Map:uWe;for(;++ri?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a0?(D8(e,e.length,0,t),e):t}var k8={}.hasOwnProperty;function A8(e){let t={},n=-1;for(;++n13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function M8(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var N8=H8(/[A-Za-z]/),P8=H8(/[\dA-Za-z]/),PWe=H8(/[#-'*+\--9=?A-Z^-~]/);function F8(e){return e!==null&&(e<32||e===127)}var I8=H8(/\d/),FWe=H8(/[\dA-Fa-f]/),IWe=H8(/[!-/:-@[-`{-~]/);function L8(e){return e!==null&&e<-2}function R8(e){return e!==null&&(e<0||e===32)}function z8(e){return e===-2||e===-1||e===32}var B8=H8(/\p{P}|\p{S}/u),V8=H8(/\s/);function H8(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function U8(e){let t=[],n=-1,r=0,i=0;for(;++n55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function W8(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return z8(r)?(e.enter(n),s(r)):t(r)}function s(r){return z8(r)&&a++o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;er;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function VWe(e,t,n){return W8(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function K8(e){if(e===null||R8(e)||V8(e))return 1;if(B8(e))return 2}function q8(e,t,n){let r=[],i=-1;for(;++i1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};Y8(d,-c),Y8(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=O8(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=O8(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=O8(l,q8(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=O8(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=O8(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,D8(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n0&&z8(t)?W8(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||L8(t)?e.check(e5,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||L8(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),z8(t)?W8(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),z8(t)?W8(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||L8(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function $We(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var n5={name:`codeIndented`,tokenize:tGe},eGe={partial:!0,tokenize:nGe};function tGe(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),W8(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):L8(t)?e.attempt(eGe,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||L8(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function nGe(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):L8(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):W8(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):L8(e)?i(e):n(e)}}var rGe={name:`codeText`,previous:aGe,resolve:iGe,tokenize:oGe};function iGe(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return ethis.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&r5(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),r5(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),r5(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function a5(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||F8(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||L8(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||R8(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):L8(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||L8(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!z8(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function s5(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):L8(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),W8(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||L8(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function c5(e,t){let n;return r;function r(i){return L8(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):z8(i)?W8(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var mGe={name:`definition`,tokenize:gGe},hGe={partial:!0,tokenize:_Ge};function gGe(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return o5.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=M8(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return R8(t)?c5(e,l)(t):l(t)}function l(t){return a5(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(hGe,d,d)(t)}function d(t){return z8(t)?W8(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||L8(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function _Ge(e,t,n){return r;function r(t){return R8(t)?c5(e,i)(t):n(t)}function i(t){return s5(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return z8(t)?W8(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||L8(e)?t(e):n(e)}}var vGe={name:`hardBreakEscape`,tokenize:yGe};function yGe(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return L8(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var bGe={name:`headingAtx`,resolve:xGe,tokenize:SGe};function xGe(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},D8(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function SGe(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||R8(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||L8(n)?(e.exit(`atxHeading`),t(n)):z8(n)?W8(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||R8(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var CGe=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),l5=[`pre`,`script`,`style`,`textarea`],wGe={concrete:!0,name:`htmlFlow`,resolveTo:DGe,tokenize:OGe},TGe={partial:!0,tokenize:AGe},EGe={partial:!0,tokenize:kGe};function DGe(e){let t=e.length;for(;t--&&!(e[t][0]===`enter`&&e[t][1].type===`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function OGe(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):N8(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):N8(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return N8(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||R8(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&l5.includes(l)?(i=1,r.interrupt?t(s):O(s)):CGe.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||P8(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return z8(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||N8(t)?(e.consume(t),b):z8(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||P8(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):z8(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):z8(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||L8(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||R8(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||z8(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||L8(t)?O(t):z8(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):L8(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(TGe,R,k)(t)):t===null||L8(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(EGe,A,R)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||L8(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return l5.includes(n)?(e.consume(t),L):O(t)}return N8(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||L8(t)?(e.exit(`htmlFlowData`),R(t)):(e.consume(t),L)}function R(n){return e.exit(`htmlFlow`),t(n)}}function kGe(e,t,n){let r=this;return i;function i(t){return L8(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function AGe(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(X8,t,n)}}var jGe={name:`htmlText`,tokenize:MGe};function MGe(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):N8(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):N8(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):L8(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):L8(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):L8(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):L8(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return N8(t)?(e.consume(t),S):n(t)}function S(t){return t===45||P8(t)?(e.consume(t),S):C(t)}function C(t){return L8(t)?(o=C,N(t)):z8(t)?(e.consume(t),C):M(t)}function w(t){return t===45||P8(t)?(e.consume(t),w):t===47||t===62||R8(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||N8(t)?(e.consume(t),E):L8(t)?(o=T,N(t)):z8(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||P8(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):L8(t)?(o=D,N(t)):z8(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):L8(t)?(o=O,N(t)):z8(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):L8(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||R8(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||R8(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return z8(t)?W8(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var u5={name:`labelEnd`,resolveAll:IGe,resolveTo:LGe,tokenize:RGe},NGe={tokenize:zGe},PGe={tokenize:BGe},FGe={tokenize:VGe};function IGe(e){let t=-1,n=[];for(;++t=3&&(a===null||L8(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),z8(t)?W8(e,s,`whitespace`)(t):s(t))}}var p5={continuation:{tokenize:ZGe},exit:$Ge,name:`list`,tokenize:XGe},JGe={partial:!0,tokenize:eKe},YGe={partial:!0,tokenize:QGe};function XGe(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:I8(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(f5,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return I8(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(X8,r.interrupt?n:u,e.attempt(JGe,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return z8(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function ZGe(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(X8,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,W8(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!z8(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(YGe,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,W8(e,e.attempt(p5,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function QGe(e,t,n){let r=this;return W8(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function $Ge(e){e.exit(this.containerState.type)}function eKe(e,t,n){let r=this;return W8(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!z8(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var m5={name:`setextUnderline`,resolveTo:tKe,tokenize:nKe};function tKe(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function nKe(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),z8(t)?W8(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||L8(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var rKe={tokenize:iKe};function iKe(e){let t=this,n=e.attempt(X8,r,e.attempt(this.parser.constructs.flowInitial,i,W8(e,e.attempt(this.parser.constructs.flow,i,e.attempt(lGe,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var aKe={resolveAll:g5()},oKe=h5(`string`),sKe=h5(`text`);function h5(e){return{resolveAll:g5(e===`text`?cKe:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i_Ke,contentInitial:()=>dKe,disable:()=>vKe,document:()=>uKe,flow:()=>pKe,flowInitial:()=>fKe,insideSpan:()=>gKe,string:()=>mKe,text:()=>hKe}),uKe={42:p5,43:p5,45:p5,48:p5,49:p5,50:p5,51:p5,52:p5,53:p5,54:p5,55:p5,56:p5,57:p5,62:Z8},dKe={91:mGe},fKe={[-2]:n5,[-1]:n5,32:n5},pKe={35:bGe,42:f5,45:[m5,f5],60:wGe,61:m5,95:f5,96:t5,126:t5},mKe={38:$8,92:Q8},hKe={[-5]:d5,[-4]:d5,[-3]:d5,33:HGe,38:$8,42:J8,60:[WWe,jGe],91:WGe,92:[vGe,Q8],93:u5,95:J8,96:rGe},gKe={null:[J8,aKe]},_Ke={null:[42,95]},vKe={null:[]};function yKe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=O8(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=q8(a,l.events,l),l.events):[]}function f(e,t){return xKe(p(e),t)}function p(e){return bKe(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function xKe(e,t){let n=-1,r=[],i;for(;++n0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||x5).call(a,void 0,e[0])}for(r.position={start:y5(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:y5(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function ZJe(){return`!`}T7.peek=QJe;function T7(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function QJe(){return`!`}E7.peek=$Je;function E7(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a\u007F]/.test(e.url))}O7.peek=eYe;function O7(e,t,n,r){let i=y7(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(D7(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function eYe(e,t,n){return D7(e,n)?`<`:`[`}k7.peek=tYe;function k7(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function tYe(){return`[`}function A7(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function nYe(e){let t=A7(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function rYe(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function j7(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function iYe(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?rYe(n):A7(n),s=e.ordered?o===`.`?`)`:`.`:nYe(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),j7(n)===o&&t){let t=-1;for(;++t-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function sYe(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var cYe=F5([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function lYe(e,t,n,r){return(e.children.some(function(e){return cYe(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function uYe(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}M7.peek=dYe;function M7(e,t,n,r){let i=uYe(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=x7(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=b7(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=x7(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+b7(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function dYe(e,t,n){return n.options.strong||`*`}function fYe(e,t,n,r){return n.safe(e.value,r)}function pYe(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function mYe(e,t,n){let r=(j7(n)+(n.options.ruleSpaces?` `:``)).repeat(pYe(n));return n.options.ruleSpaces?r.slice(0,-1):r}var N7={blockquote:LJe,break:v7,code:UJe,definition:GJe,emphasis:S7,hardBreak:v7,heading:YJe,html:C7,image:w7,imageReference:T7,inlineCode:E7,link:O7,linkReference:k7,list:iYe,listItem:oYe,paragraph:sYe,root:lYe,strong:M7,text:fYe,thematicBreak:mYe};function hYe(){return{enter:{table:gYe,tableData:F7,tableHeader:F7,tableRow:vYe},exit:{codeText:yYe,table:_Ye,tableData:P7,tableHeader:P7,tableRow:P7}}}function gYe(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function _Ye(e){this.exit(e),this.data.inTable=void 0}function vYe(e){this.enter({type:`tableRow`,children:[]},e)}function P7(e){this.exit(e)}function F7(e){this.enter({type:`tableCell`,children:[]},e)}function yYe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,bYe));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function bYe(e,t){return t===`|`?t:e}function xYe(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:` `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(` -`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return FJe(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zYe={tokenize:qYe,partial:!0};function BYe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:WYe,continuation:{tokenize:GYe},exit:KYe}},text:{91:{name:`gfmFootnoteCall`,tokenize:UYe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:VYe,resolveTo:HYe}}}}function VYe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=M8(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function HYe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function UYe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||R8(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(M8(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return R8(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function WYe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||R8(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=M8(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return R8(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),W8(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function GYe(e,t,n){return e.check(X8,t,e.attempt(zYe,t,n))}function KYe(e){e.exit(`gfmFootnoteDefinition`)}function qYe(e,t,n){let r=this;return W8(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function JYe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=K8(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var YYe=class{constructor(){this.map=[]}add(e,t,n){XYe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function XYe(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):L8(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):z8(t)?W8(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||R8(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,z8(t)?W8(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return z8(t)?W8(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||L8(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return z8(t)?W8(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||L8(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||L8(n)?(e.exit(`tableRow`),t(n)):z8(n)?W8(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||R8(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eXe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new YYe;for(;++nn[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Q7(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Z7(e,t,n,r,i){let a=[],o=Q7(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Q7(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tXe={name:`tasklistCheck`,tokenize:rXe};function nXe(){return{text:{91:tXe}}}function rXe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return R8(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return L8(r)?t(r):z8(r)?e.check({tokenize:iXe},t,n)(r):n(r)}}function iXe(e,t,n){return W8(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function aXe(e){return A8([AYe(),BYe(),JYe(e),QYe(),nXe()])}var oXe={};function sXe(e){let t=this,n=e||oXe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(aXe(n)),a.push(EYe()),o.push(DYe(n))}function cXe({folderId:e}){let{t}=W(),[n,r]=(0,y.useState)(!1),{data:i,isLoading:a,error:o}=q({queryKey:[`folder-readme`,e],queryFn:()=>Q.getLibraryFolderReadme(e),retry:!1,staleTime:3e4});return a||o||!i?null:(0,K.jsxs)(`div`,{className:`mb-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-bambu-dark/40 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,title:i.filename,children:i.filename}),i.truncated&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 flex-shrink-0`,children:t(`fileManager.readme.truncated`)})]}),n?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,K.jsx)(cs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`})]}),!n&&(0,K.jsx)(`div`,{className:`px-4 py-3 border-t border-bambu-dark-tertiary max-h-96 overflow-y-auto text-sm text-bambu-gray-light leading-relaxed space-y-2`,children:(0,K.jsx)(Jqe,{remarkPlugins:[sXe],components:{h1:({children:e})=>(0,K.jsx)(`h1`,{className:`text-lg font-semibold text-white mt-2 mb-1`,children:e}),h2:({children:e})=>(0,K.jsx)(`h2`,{className:`text-base font-semibold text-white mt-2 mb-1`,children:e}),h3:({children:e})=>(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white mt-2 mb-1`,children:e}),p:({children:e})=>(0,K.jsx)(`p`,{className:`my-1`,children:e}),ul:({children:e})=>(0,K.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5 ml-2`,children:e}),ol:({children:e})=>(0,K.jsx)(`ol`,{className:`list-decimal list-inside space-y-0.5 ml-2`,children:e}),li:({children:e})=>(0,K.jsx)(`li`,{children:e}),code:({children:e,...t})=>t.className?(0,K.jsx)(`code`,{className:`block p-2 bg-bambu-dark rounded text-xs font-mono text-bambu-gray-light overflow-x-auto`,children:e}):(0,K.jsx)(`code`,{className:`px-1 py-0.5 bg-bambu-dark rounded text-xs font-mono text-bambu-green`,children:e}),pre:({children:e})=>(0,K.jsx)(`pre`,{className:`my-2`,children:e}),blockquote:({children:e})=>(0,K.jsx)(`blockquote`,{className:`border-l-2 border-bambu-dark-tertiary pl-3 text-bambu-gray italic`,children:e}),a:({children:e,href:t})=>(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline`,children:e}),table:({children:e})=>(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsx)(`table`,{className:`min-w-full text-xs border-collapse`,children:e})}),th:({children:e})=>(0,K.jsx)(`th`,{className:`border border-bambu-dark-tertiary px-2 py-1 text-left font-semibold text-white`,children:e}),td:({children:e})=>(0,K.jsx)(`td`,{className:`border border-bambu-dark-tertiary px-2 py-1`,children:e}),hr:()=>(0,K.jsx)(`hr`,{className:`border-bambu-dark-tertiary my-2`})},children:i.content})})]})}function lXe({open:e,onClose:t,onPickTag:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),{data:m=[],isLoading:h}=q({queryKey:M6,queryFn:Q.getLibraryTags,enabled:e}),g=()=>{i.invalidateQueries({queryKey:M6}),i.invalidateQueries({queryKey:[`library-files`]})},_=J({mutationFn:async()=>{let e=u.trim();if(!e)throw Error(r(`fileManager.tags.nameRequired`));return c?Q.updateLibraryTag(c.id,e):Q.createLibraryTag(e)},onSuccess:()=>{a(r(c?`fileManager.tags.updated`:`fileManager.tags.created`),`success`),s(!1),l(null),d(``),g()},onError:e=>{a(e.message||r(`fileManager.tags.saveFailed`),`error`)}}),v=J({mutationFn:e=>Q.deleteLibraryTag(e),onSuccess:()=>{a(r(`fileManager.tags.deleted`),`success`),p(null),g()},onError:e=>{a(e.message||r(`fileManager.tags.deleteFailed`),`error`)}}),b=()=>{l(null),d(``),s(!0)},x=e=>{l(e),d(e.name),s(!0)},S=(0,y.useCallback)(()=>{_.isPending||(s(!1),l(null),d(``))},[_.isPending]);(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(_.isPending||v.isPending||(o?S():f||t()))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,o,f,_.isPending,v.isPending,S,t]);let C=e=>{e.preventDefault(),_.mutate()};if(!e)return null;let w=`library-tags-modal-title`,T=`library-tag-editor-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>{_.isPending||v.isPending||t()}}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-4xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":w,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`h2`,{id:w,className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),r(`fileManager.tags.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-0.5`,children:r(`fileManager.tags.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:b,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`fileManager.tags.add`)]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:t,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin mr-2`}),r(`common.loading`)]}):m.length===0?(0,K.jsx)(`div`,{className:`py-16 text-center text-bambu-gray`,children:r(`fileManager.tags.empty`)}):(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:r(`fileManager.tags.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right`,children:r(`fileManager.tags.fileCount`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right w-32`,children:r(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:m.map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 hover:bg-bambu-dark-tertiary/30 ${n?`cursor-pointer`:``}`,onClick:()=>{n&&(n(e.id),t())},children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white font-medium`,children:e.name}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right text-bambu-gray`,children:e.file_count}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded`,onClick:()=>x(e),title:r(`common.edit`),"aria-label":r(`fileManager.tags.editAria`,{name:e.name}),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded`,onClick:()=>p(e),title:r(`common.delete`),"aria-label":r(`fileManager.tags.deleteAria`,{name:e.name}),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},e.id))})]})})]}),o&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:S}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 shadow-2xl`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":T,children:[(0,K.jsx)(`h3`,{id:T,className:`text-lg font-semibold text-white mb-4`,children:r(c?`fileManager.tags.edit`:`fileManager.tags.add`)}),(0,K.jsxs)(`form`,{onSubmit:C,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`library-tag-name`,children:r(`fileManager.tags.name`)}),(0,K.jsx)(`input`,{id:`library-tag-name`,type:`text`,maxLength:64,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green mb-4`,placeholder:r(`fileManager.tags.createPlaceholder`),value:u,onChange:e=>d(e.target.value),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:S,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:_.isPending||!u.trim(),children:[_.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.save`)]})]})]})]})]}),f&&(0,K.jsx)(Ad,{title:r(`fileManager.tags.confirmDelete`,{name:f.name}),message:f.file_count>0?r(`fileManager.tags.confirmDeleteInUseMessage`,{count:f.file_count}):r(`fileManager.tags.confirmDeleteMessage`),confirmText:r(`common.delete`),variant:`danger`,isLoading:v.isPending,onConfirm:()=>v.mutate(f.id),onCancel:()=>p(null)})]})}var uXe=90;function dXe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(uXe),[o,s]=(0,y.useState)(!0),[c,l]=(0,y.useState)(i);(0,y.useEffect)(()=>{let e=window.setTimeout(()=>l(i),300);return()=>window.clearTimeout(e)},[i]);let u=q({queryKey:[`library-purge-preview`,c,o],queryFn:()=>Q.previewLibraryPurge(c,o),enabled:c>=1}),d=J({mutationFn:()=>Q.executeLibraryPurge(i,o),onSuccess:i=>{r(t(`libraryPurge.toast.success`,{count:i.moved_to_trash}),`success`),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]}),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),e()},onError:e=>r(e.message||t(`libraryPurge.toast.failed`),`error`)});(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!d.isPending&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,d.isPending]);let f=u.data,p=f?.count??0,m=f?.total_bytes??0,h=p>0&&!d.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-lg w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),t(`libraryPurge.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`,"aria-label":t(`common.close`),disabled:d.isPending,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:t(`libraryPurge.description`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`purge-days`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:t(`libraryPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{id:`purge-days`,type:`number`,min:1,max:3650,value:i,onChange:e=>a(Math.max(1,Math.min(3650,parseInt(e.target.value||`0`,10)||0))),className:`w-24 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:t(`libraryPurge.days`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`rounded border-gray-300`}),t(`libraryPurge.includeNeverPrinted`)]}),(0,K.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/30 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-2`,children:t(`libraryPurge.effectsTitle`)}),(0,K.jsxs)(`ul`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1 list-disc pl-4`,children:[(0,K.jsx)(`li`,{children:t(`libraryPurge.effect1`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect2`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect3`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect4`)})]})]}),(0,K.jsx)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 p-3`,children:u.isLoading||u.isFetching?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,t(`libraryPurge.previewLoading`)]}):u.isError?(0,K.jsx)(`div`,{className:`text-sm text-red-600 dark:text-red-400`,children:u.error?.message??t(`libraryPurge.previewFailed`)}):(0,K.jsxs)(`div`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:t(`libraryPurge.previewSummary`,{count:p,size:Cd(m)})}),f?.sample_filenames&&f.sample_filenames.length>0&&(0,K.jsxs)(`ul`,{className:`mt-2 text-xs text-gray-600 dark:text-gray-400 space-y-0.5 list-disc pl-4`,children:[f.sample_filenames.map(e=>(0,K.jsx)(`li`,{className:`truncate`,children:e},e)),p>f.sample_filenames.length&&(0,K.jsx)(`li`,{className:`list-none italic text-gray-500`,children:t(`libraryPurge.andMore`,{count:p-f.sample_filenames.length})})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-start text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-3 py-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:t(`libraryPurge.warning`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:d.isPending,children:t(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,disabled:!h,onClick:()=>d.mutate(),children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}),t(`libraryPurge.purging`)]}):t(`libraryPurge.confirmCta`,{count:p})})]})]})})}function fXe({parentId:e,onClose:t,onSave:n,isLoading:r,t:i}){let[a,o]=(0,y.useState)(``);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`fileManager.newFolder`)})}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),n({name:a.trim(),parent_id:e})},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:i(`fileManager.folderName`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`fileManager.folderNamePlaceholder`),autoFocus:!0,required:!0})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:i(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!a.trim()||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`common.create`)})]})]})]})})}function pXe({onClose:e,onSave:t,isLoading:n,t:r}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(!1);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(uc,{className:`w-5 h-5 text-bambu-green`}),r(`fileManager.linkExternalFolder`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`fileManager.linkExternalFolderDescription`)})]}),(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t({name:i.trim(),external_path:o.trim(),readonly:c,show_hidden:u})},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:r(`fileManager.folderName`)}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:r(`fileManager.externalFolderNamePlaceholder`),autoFocus:!0,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:r(`fileManager.externalPath`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green font-mono text-sm`,placeholder:`/mnt/nas/3d-prints`,required:!0}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`fileManager.externalPathHelp`)})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:r(`fileManager.readOnly`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,r(`fileManager.readOnlyHelp`),`)`]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:r(`fileManager.showHiddenFiles`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:e,children:r(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!i.trim()||!o.trim()||n,children:n?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):r(`fileManager.linkFolder`)})]})]})]})})}var mXe=`<>:"/\\|?*`;function hXe(e){for(let t of e)if(mXe.includes(t)||t.charCodeAt(0)<32)return t;return null}function gXe({type:e,currentName:t,onClose:n,onSave:r,isLoading:i,t:a}){let o=e===`file`?t.match(/(\.gcode\.3mf|\.3mf|\.gcode)$/i)?.[1]??``:``,s=e===`file`&&o?t.slice(0,-o.length):t,[c,l]=(0,y.useState)(s),u=e===`file`?hXe(c):null,d=u?a(`fileManager.invalidFilenameChar`,{char:u}):null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(e===`file`?`fileManager.renameFile`:`fileManager.renameFolder`)})}),(0,K.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),d)return;let i=e===`file`?c.trim()+o:c.trim();c.trim()&&i!==t&&r(i)},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.name`)}),(0,K.jsxs)(`div`,{className:`flex items-center bg-bambu-dark border rounded focus-within:border-bambu-green ${d?`border-red-500`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`flex-1 bg-transparent px-3 py-2 text-white placeholder-bambu-gray focus:outline-none min-w-0`,autoFocus:!0,required:!0}),o&&(0,K.jsx)(`span`,{className:`pr-3 text-bambu-gray text-sm select-none whitespace-nowrap`,children:o})]}),d&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:d})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:n,children:a(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!c.trim()||c.trim()===s||!!d||i,children:i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):a(`common.rename`)})]})]})]})})}function _Xe({folders:e,selectedFiles:t,currentFolderId:n,onClose:r,onMove:i,isLoading:a,t:o}){let[s,c]=(0,y.useState)(null),l=(e,t=0)=>{let n=[];for(let r of e)n.push({id:r.id,name:r.name,depth:t}),r.children.length>0&&n.push(...l(r.children,t+1));return n},u=[{id:null,name:o(`fileManager.rootNoFolder`),depth:0},...l(e)];return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:o(`fileManager.moveFiles`,{count:t.length})})}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-1`,children:u.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),disabled:e.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:e.id===n?`opacity-50 cursor-not-allowed text-bambu-gray`:`hover:bg-bambu-dark text-white`}`,style:{paddingLeft:`${12+e.depth*16}px`},children:[(0,K.jsx)(cc,{className:`w-4 h-4`}),e.name,e.id===n&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray ml-auto`,children:[`(`,o(`fileManager.current`),`)`]})]},e.id??`root`))}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:r,children:o(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>i(s),disabled:a,children:a?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):o(`common.move`)})]})]})]})})}function vXe({folder:e,onClose:t,onLink:n,isLoading:r,t:i}){let[a,o]=(0,y.useState)(`project`),[s,c]=(0,y.useState)(e.project_id||e.archive_id||null);(0,y.useState)(()=>{e.archive_id&&o(`archive`)});let{data:l}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),{data:u}=q({queryKey:[`archives-for-link`],queryFn:()=>Q.getArchives(void 0,void 0,100)}),d=()=>{n(a===`project`?{project_id:s,archive_id:0}:{project_id:0,archive_id:s})},f=()=>{n({project_id:0,archive_id:0})},p=e.project_id||e.archive_id;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),i(`fileManager.linkFolder`)]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`fileManager.linkFolderDescription`,{name:e.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>{o(`project`),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a===`project`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Go,{className:`w-4 h-4`}),i(`fileManager.project`)]}),(0,K.jsxs)(`button`,{onClick:()=>{o(`archive`),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a===`archive`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),i(`fileManager.archive`)]})]}),(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2`,children:a===`project`?l&&l.length>0?l.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark-tertiary text-white`}`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:e.color||`#00ae42`}}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-4`,children:i(`fileManager.noProjectsFound`)}):u&&u.length>0?u.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark-tertiary text-white`}`,children:[(0,K.jsx)(Qs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.print_name||e.filename})]},e.id)):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-4`,children:i(`fileManager.noArchivesFound`)})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-between`,children:[p&&(0,K.jsxs)($,{variant:`danger`,onClick:f,disabled:r,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 mr-2`}),i(`fileManager.unlink`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2 ${p?``:`ml-auto`}`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:d,disabled:!s||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`fileManager.link`)})]})]})]})})}function $7({folder:e,selectedFolderId:t,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:s=!1,defaultExpanded:c=!0,hasPermission:l,t:u}){let[d,f]=(0,y.useState)(c),[p,m]=(0,y.useState)(!1),h=e.children.length>0,g=e.project_id||e.archive_id,_=e.is_external;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${t===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(e.id),children:[h?(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),f(!d)},className:`p-0.5 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(as,{className:`w-3.5 h-3.5 transition-transform ${d?`rotate-90`:``}`})}):(0,K.jsx)(`div`,{className:`w-4.5`}),_?(0,K.jsx)(uc,{className:`w-4 h-4 text-purple-400 flex-shrink-0`}):(0,K.jsx)(cc,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm flex-1 min-w-0 ${s?`break-all`:`truncate`}`,title:e.name,children:e.name}),g&&(0,K.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e)},className:`flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors`,title:`${e.project_name?`Project: ${e.project_name}`:`Archive: ${e.archive_name}`} (click to change)`,children:[(0,K.jsx)(Vc,{className:`w-3 h-3`}),e.project_name?(0,K.jsx)(Go,{className:`w-3 h-3`}):(0,K.jsx)(Oo,{className:`w-3 h-3`})]}),_&&e.external_readonly&&(0,K.jsx)(`span`,{title:u(`fileManager.readOnly`),children:(0,K.jsx)(qc,{className:`w-3 h-3 text-amber-400 flex-shrink-0`})}),e.file_count>0&&(0,K.jsx)(`span`,{className:`flex-shrink-0 text-xs text-bambu-gray`,children:e.file_count}),!g&&!_&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e)},className:`flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary`,title:u(`fileManager.linkToProjectOrArchive`),children:(0,K.jsx)(Vc,{className:`w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green`})}),(0,K.jsx)(`div`,{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${s?``:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>m(!p),className:`p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ws,{className:`w-3.5 h-3.5 text-bambu-gray`})}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>m(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:update_all`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:update_all`)&&(a(e),m(!1))},disabled:!l(`library:update_all`),title:l(`library:update_all`)?void 0:u(`fileManager.noPermissionRenameFolder`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5`}),u(`common.rename`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:update_all`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:update_all`)&&(i(e),m(!1))},disabled:!l(`library:update_all`),title:l(`library:update_all`)?void 0:u(`fileManager.noPermissionLinkFolder`),children:[(0,K.jsx)(Vc,{className:`w-3.5 h-3.5`}),u(g?`fileManager.changeLink`:`fileManager.linkTo`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:delete_all`)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:delete_all`)&&(r(e.id),m(!1))},disabled:!l(`library:delete_all`),title:l(`library:delete_all`)?void 0:u(`fileManager.noPermissionDeleteFolder`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),u(`common.delete`)]})]})]})]})})]}),h&&d&&(0,K.jsx)(`div`,{children:e.children.map(e=>(0,K.jsx)($7,{folder:e,selectedFolderId:t,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:s,defaultExpanded:c,hasPermission:l,t:u},e.id))})]})}function e9(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)}function t9(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)?!1:t.endsWith(`.stl`)||t.endsWith(`.3mf`)||t.endsWith(`.step`)||t.endsWith(`.stp`)}function yXe({file:e,isSelected:t,isMobile:n,onSelect:r,onDelete:i,onDownload:a,onAddToQueue:o,onPrint:s,onSlice:c,useSlicerApi:l,onPreview3d:u,onRename:d,onGenerateThumbnail:f,onTagClick:p,thumbnailVersion:m,hasPermission:h,canModify:g,authEnabled:_,t:v}){let[b,x]=(0,y.useState)(!1);return(0,K.jsxs)(`div`,{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${t?`border-bambu-green ring-1 ring-bambu-green`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,onClick:()=>r(e.id),children:[(0,K.jsxs)(`div`,{className:`aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(e.id)}${m?(Q.getLibraryFileThumbnailUrl(e.id).includes(`?`)?`&`:`?`)+`v=${m}`:``}`,alt:e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(Qs,{className:`w-12 h-12 text-bambu-gray/30`}),(0,K.jsx)(`div`,{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${e.file_type===`3mf`?`bg-bambu-green/90 text-white`:e.file_type===`gcode`||e.file_type===`gcode.3mf`?`bg-blue-500/90 text-white`:e.file_type===`stl`?`bg-purple-500/90 text-white`:`bg-bambu-gray/90 text-white`}`,children:e.file_type.toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white truncate`,title:e.print_name||e.filename,children:e.print_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:Cd(e.file_size)}),e.print_time_seconds&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(e.print_time_seconds)]})]}),e.sliced_for_model&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),e.sliced_for_model]}),e.print_count>0&&(0,K.jsx)(`div`,{className:`mt-1 text-xs text-bambu-green`,children:v(`fileManager.printedCount`,{count:e.print_count})}),_&&e.created_by_username&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]}),(e.tags?.length??0)>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,onClick:e=>e.stopPropagation(),children:e.tags.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>p?.(e.id),className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[10px] bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20 transition-colors max-w-full`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-2.5 h-2.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`absolute bottom-2 right-2 transition-opacity ${n?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{onClick:()=>x(!b),className:`p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ws,{className:`w-4 h-4 text-bambu-gray`})}),b&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>x(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]`,children:[s&&e9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`printers:control`)?`text-bambu-green hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`printers:control`)&&(s(e),x(!1))},disabled:!h(`printers:control`),title:h(`printers:control`)?void 0:v(`fileManager.noPermissionPrint`),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5`}),v(`common.print`)]}),o&&e9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`queue:create`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`queue:create`)&&(o(e.id),x(!1))},disabled:!h(`queue:create`),title:h(`queue:create`)?void 0:v(`fileManager.noPermissionAddToQueue`),children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),v(`fileManager.schedulePrint`)]}),c&&l&&t9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:upload`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:upload`)&&(c(e),x(!1))},disabled:!h(`library:upload`),title:h(`library:upload`)?void 0:v(`fileManager.noPermissionSlice`),children:[(0,K.jsx)(ks,{className:`w-3.5 h-3.5`}),v(`slice.action`)]}),u&&(e.file_type===`3mf`||e.file_type===`gcode`||e.file_type===`stl`||e.file_type===`gcode.3mf`)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:read`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:read`)&&(u(e),x(!1))},disabled:!h(`library:read`),title:h(`library:read`)?void 0:`You do not have permission to preview files`,children:[(0,K.jsx)(Wo,{className:`w-3.5 h-3.5`}),`3D Preview`]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:read`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:read`)&&(a(e.id),x(!1))},disabled:!h(`library:read`),title:h(`library:read`)?void 0:v(`fileManager.noPermissionDownload`),children:[(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`}),v(`common.download`)]}),d&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`update`,e.created_by_id)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`update`,e.created_by_id)&&(d(e),x(!1))},disabled:!g(`library`,`update`,e.created_by_id),title:g(`library`,`update`,e.created_by_id)?void 0:v(`fileManager.noPermissionRenameFile`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5`}),v(`common.rename`)]}),f&&e.file_type===`stl`&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`update`,e.created_by_id)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`update`,e.created_by_id)&&(f(e),x(!1))},disabled:!g(`library`,`update`,e.created_by_id),title:g(`library`,`update`,e.created_by_id)?void 0:v(`fileManager.noPermissionGenerateThumbnail`),children:[(0,K.jsx)(Mc,{className:`w-3.5 h-3.5`}),v(`fileManager.generateThumbnail`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`delete`,e.created_by_id)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`delete`,e.created_by_id)&&(i(e.id),x(!1))},disabled:!g(`library`,`delete`,e.created_by_id),title:g(`library`,`delete`,e.created_by_id)?void 0:v(`fileManager.noPermissionDeleteFile`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),v(`common.delete`)]})]})]})]}),(0,K.jsx)(`div`,{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${t?`bg-bambu-green border-bambu-green`:`border-white/30 bg-black/30 ${n?`opacity-100`:`opacity-0 group-hover:opacity-100`}`}`,children:t&&(0,K.jsx)(`div`,{className:`w-2 h-2 bg-white rounded-sm`})})]})}function bXe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i,canModify:a,authEnabled:o}=dd(),[s]=Mi(),c=$n(),l=s.get(`folder`),[u,d]=(0,y.useState)(l?parseInt(l,10):null),[f,p]=(0,y.useState)(`internal`),[m,h]=(0,y.useState)([]),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)([]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)([]),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(null),[z,B]=(0,y.useState)(null),[V,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(null),[re,ie]=(0,y.useState)(null),[H,ae]=(0,y.useState)(null),[oe,U]=(0,y.useState)({}),[se,ce]=(0,y.useState)(null),[le,ue]=(0,y.useState)(()=>localStorage.getItem(`library-view-mode`)||`grid`),[de,fe]=(0,y.useState)(()=>localStorage.getItem(`library-wrap-folders`)===`true`),[pe,me]=(0,y.useState)(()=>localStorage.getItem(`library-collapse-folders`)===`true`),[he,ge]=(0,y.useState)(()=>localStorage.getItem(`library-folder-sort-field`)===`activity`?`activity`:`name`),[_e,ve]=(0,y.useState)(()=>localStorage.getItem(`library-folder-sort-direction`)===`desc`?`desc`:`asc`),[ye,be]=(0,y.useState)(()=>{let e=localStorage.getItem(`library-sidebar-width`);return e?parseInt(e,10):256}),[xe,Se]=(0,y.useState)(!1),Ce=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!xe)return;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let e=e=>{if(!Ce.current)return;let t=Ce.current.parentElement?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left;be(Math.min(500,Math.max(200,n)))},t=()=>{Se(!1),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`library-sidebar-width`,String(ye))};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.userSelect=``,document.body.style.cursor=``}},[xe,ye]);let[we,Te]=(0,y.useState)(``),[Ee,De]=(0,y.useState)(`all`),[Oe,ke]=(0,y.useState)(``),[Ae,je]=(0,y.useState)(()=>localStorage.getItem(`library-sort-field`)||`name`),[Me,Ne]=(0,y.useState)(()=>localStorage.getItem(`library-sort-direction`)||`asc`),Pe=UW();(0,y.useEffect)(()=>{let e=s.get(`folder`);e&&d(parseInt(e,10))},[s]);let{data:Fe}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),{data:Ie,isLoading:Le}=q({queryKey:[`library-folders`],queryFn:()=>Q.getLibraryFolders()}),Re=(0,y.useMemo)(()=>{if(!Ie)return Ie;let e=t=>[...t].sort((e,t)=>{let n=0;if(he===`name`)n=e.name.localeCompare(t.name);else{let r=e.latest_activity_at?new Date(e.latest_activity_at).getTime():null,i=t.latest_activity_at?new Date(t.latest_activity_at).getTime():null;if(r===null&&i===null)n=e.name.localeCompare(t.name);else if(r===null)return 1;else if(i===null)return-1;else n=r-i}return _e===`asc`?n:-n}).map(t=>({...t,children:e(t.children)}));return e(Ie)},[Ie,he,_e]),{data:ze}=q({queryKey:[`library-trash-count`],queryFn:async()=>{try{return(await Q.listLibraryTrash(1,0)).total}catch{return 0}},staleTime:3e4}),Be=u!==null&&we.trim().length>0,Ve=(0,y.useMemo)(()=>[...N].sort((e,t)=>e-t),[N]),{data:He=[]}=q({queryKey:[`library-tags`],queryFn:Q.getLibraryTags}),Ue=(0,y.useMemo)(()=>{let e=new Map;for(let t of He)e.set(t.id,t.name);return e},[He]);(0,y.useEffect)(()=>{He.length!==0&&P(e=>{let t=e.filter(e=>Ue.has(e));return t.length===e.length?e:t})},[He.length,Ue]);let We=(0,y.useCallback)(e=>{P(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{data:Ge,isLoading:Ke}=q({queryKey:[`library-files`,u,f,Be,Ve],queryFn:()=>Q.getLibraryFiles(u,!1,void 0,u===null?f:void 0,Be,Ve)}),{data:qe}=q({queryKey:[`library-stats`],queryFn:()=>Q.getLibraryStats()}),{data:Je}=q({queryKey:[`users`],queryFn:()=>Q.getUsers()}),Ye=(0,y.useMemo)(()=>{if(!Ge)return[];let e=new Set(Ge.map(e=>e.file_type));return Array.from(e).sort()},[Ge]),Xe=(0,y.useMemo)(()=>{if(!Ge)return[];let e=[...Ge];if(we.trim()){let t=we.toLowerCase();e=e.filter(e=>e.filename.toLowerCase().includes(t)||e.print_name&&e.print_name.toLowerCase().includes(t))}if(Ee!==`all`&&(e=e.filter(e=>e.file_type===Ee)),Oe.trim()){let t=Oe.toLowerCase();e=e.filter(e=>e.created_by_username&&e.created_by_username.toLowerCase().includes(t))}return e.sort((e,t)=>{let n=0;switch(Ae){case`name`:n=(e.print_name||e.filename).localeCompare(t.print_name||t.filename);break;case`date`:n=(vf(e.created_at)?.getTime()??0)-(vf(t.created_at)?.getTime()??0);break;case`size`:n=e.file_size-t.file_size;break;case`type`:n=e.file_type.localeCompare(t.file_type);break;case`prints`:n=e.print_count-t.print_count;break}return Me===`asc`?n:-n}),e},[Ge,we,Ee,Oe,Ae,Me]),Ze=(0,y.useMemo)(()=>{if(!qe||!Fe)return!1;let e=(Fe.library_disk_warning_gb||5)*1024*1024*1024;return qe.disk_free_bytesQ.createLibraryFolder(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),_(!1),n(e(`fileManager.toast.folderCreated`),`success`)},onError:e=>n(e.message,`error`)}),$e=J({mutationFn:async e=>{let t=await Q.createExternalFolder(e);return await Q.scanExternalFolder(t.id),t},onSuccess:r=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-stats`]}),b(!1),d(r.id),n(e(`fileManager.toast.externalFolderLinked`),`success`)},onError:e=>n(e.message,`error`)}),et=J({mutationFn:e=>Q.scanExternalFolder(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),n(e(`fileManager.toast.folderScanned`,{added:r.added,removed:r.removed}),`success`)},onError:e=>n(e.message,`error`)}),tt=J({mutationFn:e=>Q.deleteLibraryFolder(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-stats`]}),u===L?.id&&d(null),R(null),n(e(`fileManager.toast.folderDeleted`),`success`)},onError:e=>{R(null),n(e.message,`error`)}}),nt=J({mutationFn:e=>Q.deleteLibraryFile(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),t.invalidateQueries({queryKey:[`library-trash-count`]}),h(e=>e.filter(e=>e!==L?.id)),R(null),n(e(`fileManager.toast.fileDeleted`),`success`)},onError:e=>{R(null),n(e.message,`error`)}}),rt=J({mutationFn:e=>Q.bulkDeleteLibrary(e,[]),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),t.invalidateQueries({queryKey:[`library-trash-count`]}),n(e(`fileManager.toast.filesDeleted`,{count:i.length}),`success`),h([]),R(null)},onError:e=>{R(null),n(e.message,`error`)}}),it=J({mutationFn:({fileIds:e,folderId:t})=>Q.moveLibraryFiles(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),h([]),S(!1),n(e(`fileManager.toast.filesMoved`),`success`)},onError:e=>n(e.message,`error`)}),at=J({mutationFn:({id:e,data:t})=>Q.updateLibraryFolder(e,t),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`project-folders`]}),t.invalidateQueries({queryKey:[`archive-folders`]}),I(null),n(i.data.project_id===0&&i.data.archive_id===0?e(`fileManager.toast.folderUnlinked`):e(`fileManager.toast.folderLinked`),`success`)},onError:e=>n(e.message,`error`)}),ot=J({mutationFn:({id:e,filename:t})=>Q.updateLibraryFile(e,{filename:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),ae(null),n(e(`fileManager.toast.fileRenamed`),`success`)},onError:e=>{ae(null),n(e.message,`error`)}}),st=J({mutationFn:({id:e,name:t})=>Q.updateLibraryFolder(e,{name:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),ae(null),n(e(`fileManager.toast.folderRenamed`),`success`)},onError:e=>{ae(null),n(e.message,`error`)}}),ct=J({mutationFn:()=>Q.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:r=>{if(t.invalidateQueries({queryKey:[`library-files`]}),r.succeeded>0){let e=Date.now(),t={};r.results.forEach(n=>{n.success&&(t[n.file_id]=e)}),U(e=>({...e,...t}))}r.succeeded>0&&r.failed===0?n(e(`fileManager.toast.thumbnailsGenerated`,{count:r.succeeded}),`success`):r.succeeded>0&&r.failed>0?n(e(`fileManager.toast.thumbnailsGeneratedPartial`,{succeeded:r.succeeded,failed:r.failed}),`success`):r.processed===0?n(e(`fileManager.toast.noStlMissingThumbnails`),`info`):n(e(`fileManager.toast.failedToGenerateThumbnails`,{error:r.results[0]?.error||`Unknown error`}),`error`)},onError:e=>n(e.message,`error`)}),lt=J({mutationFn:e=>Q.batchGenerateStlThumbnails({file_ids:[e]}),onSuccess:r=>{if(t.invalidateQueries({queryKey:[`library-files`]}),r.succeeded>0){let t=r.results[0]?.file_id;t&&U(e=>({...e,[t]:Date.now()})),n(e(`fileManager.toast.thumbnailGenerated`),`success`)}else n(e(`fileManager.toast.failedToGenerateThumbnail`,{error:r.results[0]?.error||`Unknown error`}),`error`)},onError:e=>n(e.message,`error`)}),ut=(0,y.useCallback)(e=>{let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.includes(`.gcode.`)},[]),dt=(0,y.useMemo)(()=>Ge?Ge.filter(e=>m.includes(e.id)&&ut(e.filename)):[],[Ge,m,ut]),ft=(0,y.useCallback)(e=>{h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),pt=(0,y.useCallback)(()=>{Xe.length>0&&h(Xe.map(e=>e.id))},[Xe]),mt=(0,y.useCallback)(()=>{h([])},[]),ht=()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]})},{isDraggingOver:gt,dragHandlers:_t}=WW({disabled:!r(`library:upload`)||C,onFiles:e=>{E(e),w(!0)}}),vt=e=>{Q.downloadLibraryFile(e).catch(e=>{console.error(`Library file download failed:`,e)})},yt=()=>{L&&(L.type===`file`?nt.mutate(L.id):L.type===`folder`?tt.mutate(L.id):L.type===`bulk`&&rt.mutate(m))},bt=tt.isPending||nt.isPending||rt.isPending,xt=e=>{ue(e),localStorage.setItem(`library-view-mode`,e)},St=Le||Ke,Ct=(0,y.useMemo)(()=>{if(!u||!Ie)return null;let e=t=>{for(let n of t){if(n.id===u)return n;let t=e(n.children);if(t)return t}return null};return e(Ie)},[u,Ie]);return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col relative`,..._t,children:[gt&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`border-4 border-dashed border-bambu-green rounded-xl p-12 text-center`,children:[(0,K.jsx)(Du,{className:`w-16 h-16 mx-auto mb-4 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-2xl font-semibold text-white mb-2`,children:e(`fileManager.dropFilesHere`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`fileManager.releaseToUpload`)})]})}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(cc,{className:`w-7 h-7 text-bambu-green`}),e(`fileManager.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`fileManager.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center bg-bambu-dark rounded-lg p-1`,children:[(0,K.jsx)(`button`,{onClick:()=>xt(`grid`),className:`p-1.5 rounded transition-colors ${le===`grid`?`bg-bambu-dark-secondary text-white`:`text-bambu-gray hover:text-white`}`,title:e(`fileManager.gridView`),children:(0,K.jsx)(zc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>xt(`list`),className:`p-1.5 rounded transition-colors ${le===`list`?`bg-bambu-dark-secondary text-white`:`text-bambu-gray hover:text-white`}`,title:e(`fileManager.listView`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})})]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>ct.mutate(),disabled:ct.isPending||!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?e(`fileManager.generateThumbnailsForMissing`):e(`fileManager.noPermissionGenerateThumbnail`),children:[ct.isPending?(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}):(0,K.jsx)(Mc,{className:`w-4 h-4 mr-2`}),e(`fileManager.generateThumbnails`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>b(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?e(`fileManager.linkExternalFolder`):e(`fileManager.noPermissionCreateFolder`),children:[(0,K.jsx)(uc,{className:`w-4 h-4 mr-2`}),e(`fileManager.linkExternal`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>_(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionCreateFolder`),children:[(0,K.jsx)(lc,{className:`w-4 h-4 mr-2`}),e(`fileManager.newFolder`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>A(!0),title:e(`fileManager.tags.manageTitle`),children:[(0,K.jsx)(fu,{className:`w-4 h-4 mr-2`}),e(`fileManager.tags.manage`)]}),r(`library:purge`)&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>O(!0),title:e(`libraryPurge.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`libraryPurge.headerButton`)]}),i(`library:delete_own`,`library:delete_all`)&&(0,K.jsxs)(wi,{to:`/files/trash`,className:`inline-flex items-center px-3 py-1.5 text-sm rounded bg-bambu-dark-secondary text-bambu-gray hover:text-white hover:bg-bambu-dark transition-colors`,title:e(`libraryTrash.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`libraryTrash.headerButton`),typeof ze==`number`&&ze>0&&(0,K.jsx)(`span`,{className:`ml-1.5 px-1.5 py-0.5 text-xs rounded-full bg-bambu-green/20 text-bambu-green`,children:ze})]}),(0,K.jsxs)($,{onClick:()=>w(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionUpload`),children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),e(`common.upload`)]})]})]}),Ze&&qe&&Fe&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-500 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-amber-500 font-medium`,children:e(`fileManager.lowDiskSpaceWarning`)}),(0,K.jsx)(`p`,{className:`text-xs text-amber-500/80`,children:e(`fileManager.lowDiskSpaceDetails`,{free:Cd(qe.disk_free_bytes),total:Cd(qe.disk_total_bytes),threshold:Fe.library_disk_warning_gb})})]})]}),qe&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(rc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.files`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:qe.total_files})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(cc,{className:`w-4 h-4 text-blue-400`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.folders`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:qe.total_folders})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(wc,{className:`w-4 h-4 text-amber-400`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.size`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:Cd(qe.total_size_bytes)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm sm:ml-auto`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.free`),`:`]}),(0,K.jsx)(`span`,{className:`font-medium ${Ze?`text-amber-500`:`text-white`}`,children:Cd(qe.disk_free_bytes)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0`,children:[(0,K.jsx)(`div`,{className:`lg:hidden`,children:(0,K.jsxs)(`select`,{value:u===null?`__top:${f}`:String(u),onChange:e=>{let t=e.target.value;t.startsWith(`__top:`)?(d(null),p(t.slice(6))):d(parseInt(t,10))},className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsxs)(`option`,{value:`__top:internal`,children:[`📁 `,e(`fileManager.allFiles`)]}),Ie?.some(e=>e.is_external)&&(0,K.jsxs)(`option`,{value:`__top:external`,children:[`🔗 `,e(`fileManager.allExternal`)]}),Re&&(()=>{let e=(t,n=0)=>{let r=[];for(let i of t)r.push({id:i.id,name:i.name,fileCount:i.file_count,depth:n}),i.children.length>0&&r.push(...e(i.children,n+1));return r};return e(Re).map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`│ `.repeat(e.depth),`📂 `,e.name,` `,e.fileCount>0?`(${e.fileCount})`:``]},e.id))})()]})}),(0,K.jsxs)(`div`,{ref:Ce,className:`hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative`,style:{width:`${ye}px`},children:[(0,K.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${xe?`bg-bambu-green`:`hover:bg-bambu-green/50`}`,onMouseDown:e=>{e.preventDefault(),Se(!0)},onDoubleClick:()=>{be(256),localStorage.setItem(`library-sidebar-width`,`256`)},title:e(`fileManager.dragToResizeTooltip`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${xe?`opacity-100`:``}`,children:[(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`}),(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`}),(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`})]})}),(0,K.jsxs)(`div`,{className:`p-3 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-white`,children:e(`fileManager.folders`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`select`,{value:he,onChange:e=>{let t=e.target.value===`activity`?`activity`:`name`;ge(t),localStorage.setItem(`library-folder-sort-field`,t)},className:`text-xs px-1 py-0.5 rounded bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray focus:outline-none focus:border-bambu-green`,title:e(`fileManager.folderSort`),"aria-label":e(`fileManager.folderSort`),children:[(0,K.jsx)(`option`,{value:`name`,children:e(`fileManager.folderSortByName`)}),(0,K.jsx)(`option`,{value:`activity`,children:e(`fileManager.folderSortByActivity`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=_e===`asc`?`desc`:`asc`;ve(e),localStorage.setItem(`library-folder-sort-direction`,e)},className:`text-bambu-gray hover:text-white hover:bg-bambu-dark p-1 rounded transition-colors`,title:e(_e===`asc`?`fileManager.ascending`:`fileManager.descending`),"aria-label":e(_e===`asc`?`fileManager.ascending`:`fileManager.descending`),children:_e===`asc`?(0,K.jsx)(Fo,{className:`w-3.5 h-3.5`}):(0,K.jsx)(ko,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>{let e=!pe;me(e),localStorage.setItem(`library-collapse-folders`,String(e))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${pe?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:text-white hover:bg-bambu-dark`}`,title:e(pe?`fileManager.expandFoldersByDefault`:`fileManager.collapseFoldersByDefault`),children:e(`fileManager.collapse`)}),(0,K.jsx)(`button`,{onClick:()=>{let e=!de;fe(e),localStorage.setItem(`library-wrap-folders`,String(e))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${de?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:text-white hover:bg-bambu-dark`}`,title:e(de?`fileManager.disableTextWrapping`:`fileManager.enableTextWrapping`),children:e(`fileManager.wrap`)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null&&f===`internal`?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,onClick:()=>{d(null),p(`internal`)},children:[(0,K.jsx)(Qs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:e(`fileManager.allFiles`)})]}),Ie?.some(e=>e.is_external)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null&&f===`external`?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,onClick:()=>{d(null),p(`external`)},children:[(0,K.jsx)(uc,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`text-sm`,children:e(`fileManager.allExternal`)})]}),Re?.map(t=>(0,K.jsx)($7,{folder:t,selectedFolderId:u,onSelect:d,onDelete:e=>R({type:`folder`,id:e}),onLink:I,onRename:e=>ae({type:`folder`,id:e.id,name:e.name}),wrapNames:de,defaultExpanded:!pe,hasPermission:r,t:e},`${t.id}-${pe?`c`:`e`}`))]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:[u!==null&&(0,K.jsx)(cXe,{folderId:u}),He.length>0&&(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium shrink-0`,children:e(`fileManager.tags.filterLabel`)}),He.map(e=>{let t=N.includes(e.id);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>We(e.id),className:t?`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bambu-green/20 text-bambu-green border border-bambu-green/40 hover:bg-bambu-green/30 transition-colors`:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bambu-dark text-bambu-gray border border-bambu-dark-tertiary hover:text-white hover:border-bambu-green/40 transition-colors`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:e.name}),t&&(0,K.jsx)(Ru,{className:`w-3 h-3`})]},e.id)}),N.length>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>P([]),className:`ml-auto text-xs text-bambu-gray hover:text-white shrink-0`,children:e(`fileManager.tags.clearAll`)})]}),Ct?.is_external&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg`,children:[(0,K.jsx)(uc,{className:`w-5 h-5 text-purple-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-purple-300`,children:e(`fileManager.externalFolder`)}),Ct.external_readonly&&(0,K.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 flex items-center gap-1`,children:[(0,K.jsx)(qc,{className:`w-3 h-3`}),e(`fileManager.readOnly`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate font-mono`,title:Ct.external_path||``,children:Ct.external_path})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>u&&et.mutate(u),disabled:et.isPending,title:e(`fileManager.scanFolder`),children:[et.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`fileManager.scanFolder`)})]})]}),Ge&&Ge.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static`,children:[(0,K.jsxs)(`div`,{className:`relative w-full sm:w-auto sm:flex-1 sm:max-w-xs`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:e(`fileManager.searchFiles`),value:we,onChange:e=>Te(e.target.value),className:`w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`}),Be&&(0,K.jsx)(`span`,{className:`absolute -bottom-4 left-0 text-[10px] text-bambu-gray whitespace-nowrap`,title:e(`fileManager.searchSubfoldersHint`),children:e(`fileManager.searchSubfoldersHint`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray hidden sm:block`}),(0,K.jsxs)(`select`,{value:Ee,onChange:e=>De(e.target.value),className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`fileManager.allTypes`)}),Ye.map(e=>(0,K.jsx)(`option`,{value:e,children:e.toUpperCase()},e))]})]}),o&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:e(`fileManager.filterByUser`,{defaultValue:`Filter by user`}),value:Oe,onChange:e=>ke(e.target.value),list:`usernames-list`,className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${Oe?`pr-7`:``}`,style:Oe?{WebkitAppearance:`none`,MozAppearance:`textfield`}:void 0}),Oe&&(0,K.jsx)(`button`,{onClick:()=>ke(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})}),(0,K.jsx)(`datalist`,{id:`usernames-list`,children:Je?.map(e=>(0,K.jsx)(`option`,{value:e.username},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{value:Ae,onChange:e=>{let t=e.target.value;je(t),localStorage.setItem(`library-sort-field`,t)},className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`name`,children:e(`common.name`)}),(0,K.jsx)(`option`,{value:`date`,children:e(`common.date`)}),(0,K.jsx)(`option`,{value:`size`,children:e(`fileManager.size`)}),(0,K.jsx)(`option`,{value:`type`,children:e(`common.type`)}),(0,K.jsx)(`option`,{value:`prints`,children:e(`fileManager.prints`)})]}),(0,K.jsx)(`button`,{onClick:()=>Ne(e=>{let t=e===`asc`?`desc`:`asc`;return localStorage.setItem(`library-sort-direction`,t),t}),className:`p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors`,title:e(Me===`asc`?`fileManager.ascending`:`fileManager.descending`),children:Me===`asc`?(0,K.jsx)(Fo,{className:`w-4 h-4 text-white`}):(0,K.jsx)(ko,{className:`w-4 h-4 text-white`})})]}),(we||Ee!==`all`||Oe)&&(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray hidden sm:inline`,children:e(`fileManager.resultsCount`,{showing:Xe.length,total:Ge.length})})]}),Xe.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static`,children:[m.length===Xe.length&&m.length>0?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:mt,children:[(0,K.jsx)(ou,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.deselectAll`)})]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:pt,children:[(0,K.jsx)(iu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.selectAll`)})]}),m.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray ml-2`,children:e(`fileManager.selected`,{count:m.length})}),(0,K.jsx)(`div`,{className:`hidden sm:block flex-1`}),(0,K.jsxs)(`div`,{className:`w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0`,children:[dt.length===1&&(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>ee(dt[0]),disabled:!r(`printers:control`),title:r(`printers:control`)?void 0:e(`fileManager.noPermissionPrint`),children:[(0,K.jsx)(bl,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.print`)})]}),dt.length===1&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ne(dt[0]),disabled:!r(`queue:create`),title:r(`queue:create`)?void 0:e(`fileManager.noPermissionAddToQueue`),children:[(0,K.jsx)(Ss,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.schedulePrint`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>S(!0),disabled:!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?void 0:e(`fileManager.noPermissionMoveFiles`),children:[(0,K.jsx)(cl,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.move`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>M(!0),disabled:!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?e(`fileManager.tags.bulkTooltip`):e(`fileManager.tags.noPermission`),children:[(0,K.jsx)(fu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.tags.tagAction`)})]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>{m.length===1?R({type:`file`,id:m[0]}):R({type:`bulk`,id:0,count:m.length})},disabled:!i(`library:delete_own`,`library:delete_all`),title:i(`library:delete_own`,`library:delete_all`)?void 0:e(`fileManager.noPermissionDeleteFiles`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.delete`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:mt,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.clear`)})]})]})]})]}),St?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`fileManager.loadingFiles`)})]})}):Ge?.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(Qs,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:e(u===null?f===`external`?`fileManager.externalIsEmpty`:`fileManager.noFilesYet`:`fileManager.folderIsEmpty`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:e(u===null?f===`external`?`fileManager.externalEmptyDescription`:`fileManager.noFilesDescription`:`fileManager.folderEmptyDescription`)}),(0,K.jsxs)($,{onClick:()=>w(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionUpload`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`fileManager.uploadFiles`)]})]}):Xe.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:e(`fileManager.noMatchingFiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:e(`fileManager.noMatchingFilesDescription`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Te(``),De(`all`)},children:e(`fileManager.clearFilters`)})]}):le===`grid`?(0,K.jsx)(`div`,{className:`flex-1 lg:overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4`,children:Xe.map(t=>(0,K.jsx)(yXe,{file:t,isSelected:m.includes(t.id),isMobile:Pe,t:e,onSelect:ft,onDelete:e=>R({type:`file`,id:e}),onDownload:vt,onAddToQueue:e=>{let t=Ge?.find(t=>t.id===e);t&&ne(t)},onPrint:B,onSlice:ie,useSlicerApi:Fe?.use_slicer_api??!1,onPreview3d:e=>{e9(e.filename)?c(`/gcode-viewer?library_file=${e.id}`):ce(e)},onRename:e=>ae({type:`file`,id:e.id,name:e.filename}),onGenerateThumbnail:e=>lt.mutate(e.id),onTagClick:We,thumbnailVersion:oe[t.id],hasPermission:r,canModify:a,authEnabled:o},t.id))})}):(0,K.jsx)(`div`,{className:`flex-1 lg:overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`hidden sm:grid ${o?`grid-cols-[auto_1fr_120px_100px_100px_100px_minmax(0,200px)_220px]`:`grid-cols-[auto_1fr_100px_100px_100px_minmax(0,200px)_220px]`} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[(0,K.jsx)(`div`,{className:`w-6`}),(0,K.jsx)(`div`,{children:e(`common.name`)}),o&&(0,K.jsx)(`div`,{children:e(`fileManager.uploadedBy`,{defaultValue:`Uploaded By`})}),(0,K.jsx)(`div`,{children:e(`common.type`)}),(0,K.jsx)(`div`,{children:e(`fileManager.size`)}),(0,K.jsx)(`div`,{children:e(`fileManager.prints`)}),(0,K.jsx)(`div`,{children:e(`fileManager.tags.title`)}),(0,K.jsx)(`div`,{})]}),Xe.map(t=>(0,K.jsxs)(`div`,{className:`grid ${o?`grid-cols-[auto_1fr_120px_100px_100px_100px_minmax(0,200px)_220px]`:`grid-cols-[auto_1fr_100px_100px_100px_minmax(0,200px)_220px]`} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${m.includes(t.id)?`bg-bambu-green/10`:``}`,onClick:()=>ft(t.id),children:[(0,K.jsx)(`div`,{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${m.includes(t.id)?`bg-bambu-green border-bambu-green`:`border-bambu-gray/50`}`,children:m.includes(t.id)&&(0,K.jsx)(`div`,{className:`w-2 h-2 bg-white rounded-sm`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`relative group/thumb`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden`,children:t.thumbnail_path?(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(t.id)}${oe[t.id]?(Q.getLibraryFileThumbnailUrl(t.id).includes(`?`)?`&`:`?`)+`v=${oe[t.id]}`:``}`,alt:``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(Qs,{className:`w-5 h-5 text-bambu-gray/50`})})}),t.thumbnail_path&&(0,K.jsx)(`div`,{className:`absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block`,children:(0,K.jsx)(`div`,{className:`w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden`,children:(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(t.id)}${oe[t.id]?(Q.getLibraryFileThumbnailUrl(t.id).includes(`?`)?`&`:`?`)+`v=${oe[t.id]}`:``}`,alt:t.filename,className:`w-full h-full object-contain`})})})]}),(0,K.jsx)(`div`,{className:`min-w-0`,children:(0,K.jsx)(`div`,{className:`text-sm text-white truncate`,children:t.print_name||t.filename})})]}),o&&(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray flex items-center gap-1`,children:t.created_by_username?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:t.created_by_username})]}):`-`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type===`3mf`?`bg-bambu-green/20 text-bambu-green`:t.file_type===`gcode`||t.file_type===`gcode.3mf`?`bg-blue-500/20 text-blue-400`:t.file_type===`stl`?`bg-purple-500/20 text-purple-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:t.file_type.toUpperCase()})}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:Cd(t.file_size)}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:t.print_count>0?`${t.print_count}x`:`-`}),(0,K.jsx)(`div`,{className:`min-w-0`,onClick:e=>e.stopPropagation(),children:!t.tags||t.tags.length===0?(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/50`,children:`-`}):(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>We(e.id),className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[10px] bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20 transition-colors max-w-full`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-2.5 h-2.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e9(t.filename)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>r(`printers:control`)&&B(t),className:`p-1.5 rounded transition-colors ${r(`printers:control`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`printers:control`)?e(`common.print`):e(`fileManager.noPermissionPrint`),disabled:!r(`printers:control`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{r(`queue:create`)&&ne(t)},className:`p-1.5 rounded transition-colors ${r(`queue:create`)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`queue:create`)?e(`fileManager.schedulePrint`):e(`fileManager.noPermissionAddToQueue`),disabled:!r(`queue:create`),children:(0,K.jsx)(Ss,{className:`w-4 h-4`})})]}),(Fe?.use_slicer_api??!1)&&t9(t.filename)&&(0,K.jsx)(`button`,{onClick:()=>r(`library:upload`)&&ie(t),className:`p-1.5 rounded transition-colors ${r(`library:upload`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:upload`)?e(`slice.action`):e(`fileManager.noPermissionSlice`),disabled:!r(`library:upload`),children:(0,K.jsx)(ks,{className:`w-4 h-4`})}),(t.file_type===`3mf`||t.file_type===`gcode`||t.file_type===`gcode.3mf`||t.file_type===`stl`)&&(0,K.jsx)(`button`,{onClick:()=>{r(`library:read`)&&(e9(t.filename)?c(`/gcode-viewer?library_file=${t.id}`):ce(t))},className:`p-1.5 rounded transition-colors ${r(`library:read`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:read`)?`3D Preview`:`You do not have permission to preview files`,disabled:!r(`library:read`),children:(0,K.jsx)(Wo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>r(`library:read`)&&vt(t.id),className:`p-1.5 rounded transition-colors ${r(`library:read`)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:read`)?e(`common.download`):e(`fileManager.noPermissionDownload`),disabled:!r(`library:read`),children:(0,K.jsx)(Vs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`library`,`update`,t.created_by_id)&&ae({type:`file`,id:t.id,name:t.filename}),className:`p-1.5 rounded transition-colors ${a(`library`,`update`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`update`,t.created_by_id)?e(`common.rename`):e(`fileManager.noPermissionRenameFile`),disabled:!a(`library`,`update`,t.created_by_id),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),t.file_type===`stl`&&(0,K.jsx)(`button`,{onClick:()=>a(`library`,`update`,t.created_by_id)&<.mutate(t.id),className:`p-1.5 rounded transition-colors ${a(`library`,`update`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`update`,t.created_by_id)?e(`fileManager.generateThumbnail`):e(`fileManager.noPermissionGenerateThumbnail`),disabled:lt.isPending||!a(`library`,`update`,t.created_by_id),children:(0,K.jsx)(Mc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`library`,`delete`,t.created_by_id)&&R({type:`file`,id:t.id}),className:`p-1.5 rounded transition-colors ${a(`library`,`delete`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-red-400`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`delete`,t.created_by_id)?e(`common.delete`):e(`fileManager.noPermissionDeleteFile`),disabled:!a(`library`,`delete`,t.created_by_id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},t.id))]})})]})]}),g&&(0,K.jsx)(fXe,{parentId:u,onClose:()=>_(!1),onSave:e=>Qe.mutate(e),isLoading:Qe.isPending,t:e}),v&&(0,K.jsx)(pXe,{onClose:()=>b(!1),onSave:e=>$e.mutate(e),isLoading:$e.isPending,t:e}),x&&Ie&&(0,K.jsx)(_Xe,{folders:Ie,selectedFiles:m,currentFolderId:u,onClose:()=>S(!1),onMove:e=>it.mutate({fileIds:m,folderId:e}),isLoading:it.isPending,t:e}),C&&(0,K.jsx)(KU,{folderId:u,onClose:()=>{w(!1),E([])},onUploadComplete:ht,initialFiles:T.length>0?T:void 0}),D&&(0,K.jsx)(dXe,{onClose:()=>O(!1)}),(0,K.jsx)(lXe,{open:k,onClose:()=>A(!1),onPickTag:e=>{N.includes(e)||P(t=>[...t,e])}}),(0,K.jsx)(BUe,{open:j,fileIds:m,onClose:()=>M(!1)}),F&&(0,K.jsx)(vXe,{folder:F,onClose:()=>I(null),onLink:e=>at.mutate({id:F.id,data:e}),isLoading:at.isPending,t:e}),L&&(0,K.jsx)(Ad,{title:L.type===`folder`?e(`fileManager.deleteFolder`):L.type===`bulk`?e(`fileManager.deleteFilesCount`,{count:L.count}):e(`fileManager.deleteFile`),message:L.type===`folder`?e(`fileManager.deleteFolderConfirm`):L.type===`bulk`?e(`fileManager.deleteFilesConfirm`,{count:L.count}):e(`fileManager.deleteFileConfirm`),confirmText:e(`common.delete`),variant:`danger`,isLoading:bt,loadingText:e(`fileManager.deleting`),onConfirm:yt,onCancel:()=>R(null)}),z&&(0,K.jsx)(oW,{mode:`reprint`,libraryFileId:z.id,archiveName:z.print_name||z.filename,onClose:()=>B(null),onSuccess:()=>{B(null),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`archives`]})}}),V&&(0,K.jsx)(oW,{mode:`reprint`,libraryFileId:V.id,archiveName:V.print_name||V.filename,onClose:()=>ee(null),onSuccess:()=>{ee(null),h([]),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`archives`]})}}),te&&(0,K.jsx)(oW,{mode:`add-to-queue`,libraryFileId:te.id,archiveName:te.print_name||te.filename,onClose:()=>ne(null),onSuccess:()=>{ne(null),h([]),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`queue`]}),t.invalidateQueries({queryKey:[`archives`]})}}),re&&(0,K.jsx)(RW,{source:{kind:`libraryFile`,id:re.id,filename:re.filename},onClose:()=>ie(null)}),se&&(0,K.jsx)(zUe,{libraryFileId:se.id,title:se.print_name||se.filename,fileType:se.file_type,onClose:()=>ce(null),onSliceWithBambuddy:t9(se.filename)&&r(`library:upload`)?()=>{let e=se;ce(null),ie(e)}:void 0}),H&&(0,K.jsx)(gXe,{type:H.type,currentName:H.name,onClose:()=>ae(null),onSave:e=>{H.type===`file`?ot.mutate({id:H.id,filename:e}):st.mutate({id:H.id,name:e})},isLoading:ot.isPending||st.isPending,t:e})]})}function xXe(e){let t=vf(e);if(!t)return``;let n=Math.ceil((t.getTime()-Date.now())/(1e3*60*60*24));return n<=0?`any moment`:n===1?`1 day`:`${n} days`}function n9(e){let t=vf(e);return t?t.toLocaleString():e}function SXe(){let{t:e}=W(),t=$n(),n=no(),{showToast:r}=Td(),{hasPermission:i,authEnabled:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(new Set),u=!a||i(`library:purge`),d=q({queryKey:[`library-trash`],queryFn:()=>Q.listLibraryTrash(200,0)}),f=q({queryKey:[`library-trash-settings`],queryFn:()=>Q.getLibraryTrashSettings(),enabled:u}),[p,m]=(0,y.useState)(null);(0,y.useEffect)(()=>{f.data&&p===null&&m(f.data.retention_days)},[f.data,p]);let h=J({mutationFn:e=>{let t=f.data;return Q.updateLibraryTrashSettings({retention_days:e,auto_purge_enabled:t?.auto_purge_enabled??!1,auto_purge_days:t?.auto_purge_days??90,auto_purge_include_never_printed:t?.auto_purge_include_never_printed??!0})},onSuccess:t=>{r(e(`libraryTrash.toast.retentionSaved`,{days:t.retention_days}),`success`),n.invalidateQueries({queryKey:[`library-trash-settings`]}),n.invalidateQueries({queryKey:[`library-trash`]})},onError:t=>r(t.message||e(`libraryTrash.toast.retentionFailed`),`error`)}),g=J({mutationFn:e=>Q.restoreLibraryTrash(e),onSuccess:()=>{r(e(`libraryTrash.toast.restored`),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]})},onError:t=>r(t.message||e(`libraryTrash.toast.restoreFailed`),`error`)}),_=J({mutationFn:e=>Q.hardDeleteLibraryTrash(e),onSuccess:()=>{r(e(`libraryTrash.toast.purged`),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.purgeFailed`),`error`)}),v=J({mutationFn:()=>Q.emptyLibraryTrash(),onSuccess:t=>{r(e(`libraryTrash.toast.emptied`,{count:t.deleted}),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.emptyFailed`),`error`)}),b=J({mutationFn:e=>Promise.all(e.map(e=>Q.restoreLibraryTrash(e))),onSuccess:(t,i)=>{r(e(`libraryTrash.toast.bulkRestored`,{count:i.length}),`success`),l(new Set),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]})},onError:t=>r(t.message||e(`libraryTrash.toast.restoreFailed`),`error`)}),x=J({mutationFn:e=>Promise.all(e.map(e=>Q.hardDeleteLibraryTrash(e))),onSuccess:(t,i)=>{r(e(`libraryTrash.toast.bulkPurged`,{count:i.length}),`success`),l(new Set),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.purgeFailed`),`error`)}),S=(0,y.useMemo)(()=>d.data?.items??[],[d.data?.items]),C=d.data?.retention_days??30,w=(0,y.useMemo)(()=>S.reduce((e,t)=>e+t.file_size,0),[S]),T=S.length>0&&S.every(e=>c.has(e.id)),E=c.size>0&&!T,D=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(`div`,{className:`p-6 max-w-screen-2xl mx-auto`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-3 mb-4`,children:(0,K.jsxs)(wi,{to:`/files`,className:`inline-flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),` `,e(`libraryTrash.backToFiles`)]})}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-6 gap-4 flex-wrap`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100`,children:e(`libraryTrash.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-1`,children:e(u?`libraryTrash.subtitleAdmin`:`libraryTrash.subtitleUser`,{days:C})})]}),S.length>0&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s({type:`empty`}),className:`text-red-600 dark:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.emptyTrash`)]})]}),u&&f.data&&(0,K.jsxs)(`div`,{className:`mb-4 border border-gray-200 dark:border-gray-700 rounded-lg p-3 flex items-center gap-3 bg-gray-50 dark:bg-gray-800/40`,children:[(0,K.jsx)(`label`,{htmlFor:`retention-days`,className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(`libraryTrash.retentionLabel`)}),(0,K.jsx)(`input`,{id:`retention-days`,type:`number`,min:1,max:365,value:p??f.data.retention_days,onChange:e=>m(Math.max(1,Math.min(365,parseInt(e.target.value||`0`,10)||0))),className:`w-20 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e(`libraryTrash.days`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>p!=null&&h.mutate(p),disabled:h.isPending||p==null||p===f.data.retention_days,className:`ml-auto`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),e(`common.save`)]})]}),d.isLoading?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,e(`libraryTrash.loading`)]}):S.length===0?(0,K.jsx)(`div`,{className:`border border-dashed border-gray-300 dark:border-gray-700 rounded-lg p-12 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:e(`libraryTrash.empty`)})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`libraryTrash.summary`,{count:S.length,size:Cd(w)})}),c.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:e(`libraryTrash.selectionCount`,{count:c.size})}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>b.mutate(Array.from(c)),disabled:b.isPending,children:[(0,K.jsx)(Al,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.bulkRestore`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s({type:`bulkDelete`,count:c.size}),disabled:x.isPending,className:`text-red-600 dark:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.bulkPurge`)]})]})]}),(0,K.jsx)(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-800 text-left text-gray-600 dark:text-gray-300`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-3 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:T,ref:e=>{e&&(e.indeterminate=E)},onChange:()=>{l(e=>e.size===S.length?new Set:new Set(S.map(e=>e.id)))},"aria-label":e(`libraryTrash.selectAll`),className:`rounded border-gray-300 cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.filename`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.folder`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium text-right`,children:e(`libraryTrash.col.size`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium whitespace-nowrap`,children:e(`libraryTrash.col.deleted`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium whitespace-nowrap`,children:e(`libraryTrash.col.autoPurge`)}),u&&(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.owner`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium text-right`,children:e(`libraryTrash.col.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:S.map(t=>(0,K.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-gray-800/50`,children:[(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:c.has(t.id),onChange:()=>D(t.id),"aria-label":e(`libraryTrash.selectOne`,{filename:t.filename}),className:`rounded border-gray-300 cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-900 dark:text-gray-100 truncate max-w-md`,title:t.filename,children:t.filename}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400`,children:t.folder_name??`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right text-gray-600 dark:text-gray-400 tabular-nums whitespace-nowrap`,children:Cd(t.file_size)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400 whitespace-nowrap`,children:n9(t.deleted_at)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400 whitespace-nowrap`,children:(0,K.jsx)(`span`,{title:n9(t.auto_purge_at),children:e(`libraryTrash.autoPurgeIn`,{when:xXe(t.auto_purge_at)})})}),u&&(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400`,children:t.created_by_username??`—`}),(0,K.jsxs)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>g.mutate(t.id),disabled:g.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-xs text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300`,children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5`}),e(`libraryTrash.restore`)]}),(0,K.jsxs)(`button`,{onClick:()=>s({type:`delete`,id:t.id,filename:t.filename}),disabled:_.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-xs text-red-600 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300 ml-2`,children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),e(`libraryTrash.purgeNow`)]})]})]},t.id))})]})})]}),o&&(0,K.jsx)(Ad,{onCancel:()=>s(null),onConfirm:()=>{o&&(o.type===`delete`?_.mutate(o.id):o.type===`bulkDelete`?x.mutate(Array.from(c)):v.mutate(),s(null))},title:o.type===`delete`?e(`libraryTrash.confirm.purgeTitle`):o.type===`bulkDelete`?e(`libraryTrash.confirm.bulkPurgeTitle`):e(`libraryTrash.confirm.emptyTitle`),message:o.type===`delete`?e(`libraryTrash.confirm.purgeBody`,{filename:o.filename}):o.type===`bulkDelete`?e(`libraryTrash.confirm.bulkPurgeBody`,{count:o.count}):e(`libraryTrash.confirm.emptyBody`,{count:S.length}),confirmText:e(`libraryTrash.confirm.cta`),variant:`danger`}),d.isError&&(0,K.jsxs)(`div`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:[d.error?.message??e(`libraryTrash.loadError`),(0,K.jsx)($,{variant:`secondary`,onClick:()=>t(`/files`),className:`ml-3`,children:e(`libraryTrash.backToFiles`)})]})]})}function CXe(e,t){let n=`token=${encodeURIComponent(t)}`,r=0;return e.querySelectorAll(`img[src*="/api/v1/"], video[src*="/api/v1/"]`).forEach(e=>{let t=e.getAttribute(`src`)||``;if(t.includes(n))return;let i=t.replace(/([?&])token=[^&]*(&|$)/,(e,t,n)=>n===`&`?t:``);e.src=`${i}${i.includes(`?`)?`&`:`?`}${n}`,r+=1}),r}function r9(){let{authEnabled:e,user:t,loading:n}=dd(),r=no(),i=(0,y.useRef)(!1),{data:a}=q({queryKey:[`camera-stream-token`,t?.id??null],queryFn:()=>Q.getCameraStreamToken(),enabled:!n&&(!e||t!==null),staleTime:3e3*1e3,refetchInterval:3e3*1e3});(0,y.useEffect)(()=>{let e=a?.token??null;return Ju(e),e&&CXe(document,e),()=>Ju(null)},[a?.token]),(0,y.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;if(!(t instanceof HTMLImageElement||t instanceof HTMLVideoElement))return;let n=t.src||``,a=Yu();!a||!n.includes(`token=${encodeURIComponent(a)}`)||i.current||(i.current=!0,r.invalidateQueries({queryKey:[`camera-stream-token`]}),setTimeout(()=>{i.current=!1},5e3))};return document.addEventListener(`error`,t,!0),()=>document.removeEventListener(`error`,t,!0)},[e,r])}var i9=5,wXe=2e3,TXe=3e4,EXe=5e3;function DXe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,authEnabled:i,user:a}=dd(),{printerId:o}=ir(),s=parseInt(o||`0`,10),[c]=Mi(),l=parseInt(c.get(`fps`)||`15`,10),u=Math.min(Math.max(isNaN(l)?15:l,1),30);r9();let{data:d}=q({queryKey:[`camera-stream-token`,a?.id??null],queryFn:()=>Q.getCameraStreamToken(),enabled:i?!!a:!0,staleTime:3e3*1e3}),f=d?.token??Yu(),[p,m]=(0,y.useState)(`stream`),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!0),[w,T]=(0,y.useState)(Date.now()),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(0),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(0),[I,L]=(0,y.useState)(1),[R,z]=(0,y.useState)({x:0,y:0}),[B,V]=(0,y.useState)(!1),[ee,te]=(0,y.useState)({x:0,y:0}),[ne,re]=(0,y.useState)(null),[ie,H]=(0,y.useState)(null),ae=(0,y.useRef)(null),oe=(0,y.useRef)(null),U=(0,y.useRef)(null),se=(0,y.useRef)(null),ce=(0,y.useRef)(null),{data:le}=q({queryKey:[`printer`,s],queryFn:()=>Q.getPrinter(s),enabled:s>0}),{data:ue}=q({queryKey:[`printerStatus`,s],queryFn:()=>Q.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=J({mutationFn:e=>Q.setChamberLight(s,e),onMutate:async e=>{await t.cancelQueries({queryKey:[`printerStatus`,s]});let n=t.getQueryData([`printerStatus`,s]);return t.setQueryData([`printerStatus`,s],t=>({...t,chamber_light:e})),{previousStatus:n}},onSuccess:(e,t)=>{n(`Chamber light ${t?`on`:`off`}`)},onError:(r,i,a)=>{a?.previousStatus&&t.setQueryData([`printerStatus`,s],a.previousStatus),n(r.message||e(`printers.toast.failedToControlChamberLight`),`error`)}}),fe=(ue?.state===`RUNNING`||ue?.state===`PAUSE`)&&(ue?.printable_objects_count??0)>=2;(0,y.useEffect)(()=>(le&&(document.title=`${le.name} - Camera`),()=>{document.title=`Bambuddy`}),[le]);let pe=(0,y.useRef)(!1);(0,y.useEffect)(()=>{let e=`/api/v1/printers/${s}/camera/stop`;pe.current=!1;let t=()=>{if(s>0&&!pe.current){pe.current=!0;let t={},n=Ku();n&&(t.Authorization=`Bearer ${n}`),fetch(e,{method:`POST`,keepalive:!0,headers:t}).catch(()=>{})}},n=()=>{t()};window.addEventListener(`beforeunload`,n);let r=ae.current;return()=>{window.removeEventListener(`beforeunload`,n),r&&(r.src=``),t()}},[s]),(0,y.useEffect)(()=>{if(S&&!E){let e=setTimeout(()=>{C(!1)},p===`stream`?3e3:2e4);return()=>clearTimeout(e)}},[p,S,w,E]),(0,y.useEffect)(()=>{let e=()=>{k(!!document.fullscreenElement),L(1),z({x:0,y:0}),p===`stream`&&!E&&(ae.current&&(ae.current.src=``),setTimeout(()=>{C(!0),T(Date.now())},200))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[p,E]),(0,y.useEffect)(()=>{let e,t=()=>{clearTimeout(e),e=setTimeout(()=>{localStorage.setItem(`cameraWindowState`,JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener(`resize`,t),()=>{clearTimeout(e),window.removeEventListener(`resize`,t)}},[]),(0,y.useEffect)(()=>()=>{U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ce.current&&clearInterval(ce.current)},[]);let me=(0,y.useCallback)(()=>{if(A>=i9){N(!1),x(!0);return}let e=Math.min(wXe*2**A,TXe);N(!0),F(Math.ceil(e/1e3)),se.current=setInterval(()=>{F(e=>e<=1?(se.current&&clearInterval(se.current),0):e-1)},1e3),U.current=setTimeout(()=>{j(e=>e+1),N(!1),C(!0),x(!1),ae.current&&(ae.current.src=``),T(Date.now())},e)},[A]);(0,y.useEffect)(()=>{if(p!==`stream`||S||M||E){ce.current&&=(clearInterval(ce.current),null);return}return ce.current=setInterval(async()=>{try{let e=await Q.getCameraStatus(s);(e.stalled||!e.active&&!b)&&(console.log(`Stream issue detected: stalled=${e.stalled}, active=${e.active}, reconnecting...`),ce.current&&=(clearInterval(ce.current),null),C(!1),me())}catch{}},EXe),()=>{ce.current&&=(clearInterval(ce.current),null)}},[p,S,b,M,E,s,me]);let he=()=>{C(!1),p===`stream`&&A{if(C(!1),x(!1),j(0),N(!1),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&!localStorage.getItem(`cameraWindowState`)){let e=ae.current,t=e.naturalWidth,n=e.naturalHeight;if(t>0&&n>0){let e=window.outerWidth-window.innerWidth,r=window.outerHeight-window.innerHeight,i=t+16+e,a=n+45+16+r;try{window.resizeTo(i,a)}catch{}}}},_e=()=>{if(s>0){let e={},t=Ku();t&&(e.Authorization=`Bearer ${t}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:`POST`,headers:e}).catch(()=>{})}},ve=e=>{p===e||E||(D(!0),C(!0),x(!1),j(0),N(!1),L(1),z({x:0,y:0}),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&(ae.current.src=``),p===`stream`&&_e(),setTimeout(()=>{m(e),T(Date.now()),D(!1)},100))},ye=()=>{E||(D(!0),C(!0),x(!1),j(0),N(!1),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&(ae.current.src=``),p===`stream`&&_e(),setTimeout(()=>{T(Date.now()),D(!1)},100))},be=()=>{oe.current&&(document.fullscreenElement?document.exitFullscreen():oe.current.requestFullscreen())},xe=()=>{L(e=>Math.min(e+.5,4))},Se=()=>{L(e=>{let t=Math.max(e-.5,1);return t===1&&z({x:0,y:0}),t})},Ce=e=>{e.preventDefault(),e.deltaY<0?xe():Se()},we=e=>{I>1&&(e.preventDefault(),V(!0),te({x:e.clientX-R.x,y:e.clientY-R.y}))},Te=(0,y.useCallback)(()=>{if(!oe.current)return{x:300,y:200};let e=oe.current.getBoundingClientRect(),t=e.width*(I-1)/2,n=e.height*(I-1)/2;return{x:Math.max(50,t),y:Math.max(50,n)}},[I]),Ee=e=>{if(B&&I>1){let t=e.clientX-ee.x,n=e.clientY-ee.y,r=Te();z({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},De=()=>{V(!1)},Oe=e=>{if(e.length<2)return 0;let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)},ke=e=>e.length<2?{x:e[0].clientX,y:e[0].clientY}:{x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2},Ae=e=>{e.touches.length===2?(e.preventDefault(),re(Oe(e.touches)),H(ke(e.touches))):e.touches.length===1&&I>1&&(e.preventDefault(),V(!0),te({x:e.touches[0].clientX-R.x,y:e.touches[0].clientY-R.y}))},je=e=>{if(e.touches.length===2&&ne!==null){e.preventDefault();let t=Oe(e.touches),n=t/ne;L(e=>{let t=Math.max(1,Math.min(4,e*n));return t===1&&z({x:0,y:0}),t}),re(t);let r=ke(e.touches);if(ie){let e=Te();z(t=>({x:Math.max(-e.x,Math.min(e.x,t.x+(r.x-ie.x))),y:Math.max(-e.y,Math.min(e.y,t.y+(r.y-ie.y)))}))}H(r)}else if(e.touches.length===1&&B&&I>1){e.preventDefault();let t=e.touches[0].clientX-ee.x,n=e.touches[0].clientY-ee.y,r=Te();z({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},Me=e=>{e.touches.length<2&&(re(null),H(null)),e.touches.length===0&&V(!1)},Ne=()=>{L(1),z({x:0,y:0})},Pe=E||i&&!f?``:(e=>f?`${e}&token=${encodeURIComponent(f)}`:Xu(e))(p===`stream`?`/api/v1/printers/${s}/camera/stream?fps=${u}&t=${w}`:`/api/v1/printers/${s}/camera/snapshot?t=${w}`),Fe=S||E||M;return s?(0,K.jsxs)(`div`,{ref:oe,className:`min-h-screen bg-black flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h1`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[(0,K.jsx)(Qo,{className:`w-4 h-4`}),le?.name||`Printer ${s}`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark rounded p-0.5`,children:[(0,K.jsx)(`button`,{onClick:()=>ve(`stream`),disabled:Fe,className:`px-3 py-1 text-xs rounded transition-colors ${p===`stream`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white disabled:opacity-50`}`,children:e(`camera.live`)}),(0,K.jsx)(`button`,{onClick:()=>ve(`snapshot`),disabled:Fe,className:`px-3 py-1 text-xs rounded transition-colors ${p===`snapshot`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white disabled:opacity-50`}`,children:e(`camera.snapshot`)})]}),(0,K.jsx)(`button`,{onClick:()=>de.mutate(!ue?.chamber_light),disabled:!ue?.connected||de.isPending||!r(`printers:control`),className:`p-1.5 rounded disabled:opacity-50 ${ue?.chamber_light?`bg-yellow-500/20 hover:bg-yellow-500/30`:`hover:bg-bambu-dark-tertiary`}`,title:r(`printers:control`)?e(`camera.chamberLight`):e(`printers.permission.noControl`),children:(0,K.jsx)(oT,{on:ue?.chamber_light??!1,className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>g(!0),disabled:!fe||!r(`printers:control`),className:`p-1.5 rounded disabled:opacity-50 ${fe&&r(`printers:control`)?`hover:bg-bambu-dark-tertiary`:``}`,title:r(`printers:control`)?e(fe?`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):e(`printers.permission.noControl`),children:(0,K.jsx)(sT,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:ye,disabled:Fe,className:`p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50`,title:e(p===`stream`?`camera.restartStream`:`camera.refreshSnapshot`),children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-gray ${Fe?`animate-spin`:``}`})}),(0,K.jsx)(`button`,{onClick:()=>v(!0),className:`p-1.5 hover:bg-bambu-dark-tertiary rounded`,title:e(`camera.diagnose.button`),children:(0,K.jsx)(cu,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:be,className:`p-1.5 hover:bg-bambu-dark-tertiary rounded`,title:e(O?`camera.exitFullscreen`:`camera.fullscreen`),children:O?(0,K.jsx)(il,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(el,{className:`w-4 h-4 text-bambu-gray`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-2 overflow-hidden`,onWheel:Ce,onMouseMove:Ee,onMouseUp:De,onMouseLeave:De,onTouchStart:Ae,onTouchMove:je,onTouchEnd:Me,style:{touchAction:`none`},children:(0,K.jsxs)(`div`,{className:`relative w-full h-full flex items-center justify-center`,children:[(S||E)&&!M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Ol,{className:`w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(p===`stream`?`camera.connectingToCamera`:`camera.capturingSnapshot`)})]})}),M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/80 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-4`,children:[(0,K.jsx)(Pu,{className:`w-10 h-10 text-orange-400 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:e(`camera.connectionLost`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:e(`camera.reconnecting`,{countdown:P,attempt:Math.min(A+1,i9),max:i9})}),(0,K.jsx)(`button`,{onClick:ye,className:`px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors`,children:e(`camera.reconnectNow`)})]})}),b&&!M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-4`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12 text-orange-400 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:e(`camera.cameraUnavailable`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4 max-w-md`,children:e(`camera.cameraUnavailableDesc`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[(0,K.jsx)(`button`,{onClick:ye,className:`px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors`,children:e(`camera.retry`)}),(0,K.jsx)(`button`,{onClick:()=>v(!0),className:`px-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white rounded transition-colors`,children:e(`camera.diagnose.button`)})]})]})}),(0,K.jsx)(`img`,{ref:ae,src:Pe,alt:e(`camera.cameraStream`),className:`max-w-full max-h-full object-contain select-none`,style:{transform:`scale(${I}) translate(${R.x/I}px, ${R.y/I}px) rotate(${le?.camera_rotation||0}deg)`,...le?.camera_rotation===90||le?.camera_rotation===270?{maxWidth:`100vh`,maxHeight:`100vw`}:{},cursor:I>1?B?`grabbing`:`grab`:`default`},onError:Pe?he:void 0,onLoad:Pe?ge:void 0,onMouseDown:we,draggable:!1},w),(0,K.jsxs)(`div`,{className:`absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`button`,{onClick:Se,disabled:I<=1,className:`p-1.5 hover:bg-white/10 rounded disabled:opacity-30`,title:e(`camera.zoomOut`),children:(0,K.jsx)(Vu,{className:`w-4 h-4 text-white`})}),(0,K.jsxs)(`button`,{onClick:Ne,className:`px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]`,title:e(`camera.resetZoom`),children:[Math.round(I*100),`%`]}),(0,K.jsx)(`button`,{onClick:xe,disabled:I>=4,className:`p-1.5 hover:bg-white/10 rounded disabled:opacity-30`,title:e(`camera.zoomIn`),children:(0,K.jsx)(zu,{className:`w-4 h-4 text-white`})})]})]})}),(0,K.jsx)(cT,{printerId:s,isOpen:h,onClose:()=>g(!1)}),_&&(0,K.jsx)(lT,{printerId:s,printerName:le?.name||null,onClose:()=>v(!1)})]}):(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-white`,children:e(`camera.invalidPrinterId`)})})}function OXe(e,t,n){if(!e)return``;if(!t)return e;let r=t.match(/plate_(\d+)\.gcode/);return r&&parseInt(r[1],10)>1?`${e} — ${n(`printers.plateNumber`,`Plate {{number}}`,{number:r[1]})}`:e}function kXe(e){let t=e.get(`show`)?.split(`,`)||[`progress`,`layers`,`eta`,`filename`,`status`],n=parseInt(e.get(`fps`)||`15`,10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=e.get(`camera`),a=i!==`false`&&i!==`0`;return{size:e.get(`size`)||`medium`,fps:r,showCamera:a,showProgress:t.includes(`progress`),showLayers:t.includes(`layers`),showEta:t.includes(`eta`),showFilename:t.includes(`filename`),showStatus:t.includes(`status`),showPrinter:t.includes(`printer`)}}function AXe(e,t){if(e.stg_cur_name)return e.stg_cur_name;switch(e.state){case`RUNNING`:return t(`streamOverlay.status.printing`);case`PAUSE`:return t(`streamOverlay.status.paused`);case`FINISH`:return t(`streamOverlay.status.finished`);case`FAILED`:return t(`streamOverlay.status.failed`);case`IDLE`:return t(`streamOverlay.status.idle`);default:return e.state||t(`streamOverlay.status.unknown`)}}function jXe(e){switch(e){case`small`:return{container:`p-3`,text:`text-sm`,textLarge:`text-lg`,progressHeight:`h-2`,icon:`w-3 h-3`,gap:`gap-2`,logoHeight:`h-12`};case`large`:return{container:`p-6`,text:`text-xl`,textLarge:`text-3xl`,progressHeight:`h-4`,icon:`w-6 h-6`,gap:`gap-4`,logoHeight:`h-24`};default:return{container:`p-4`,text:`text-base`,textLarge:`text-xl`,progressHeight:`h-3`,icon:`w-4 h-4`,gap:`gap-3`,logoHeight:`h-16`}}}function MXe(){let{printerId:e}=ir(),[t]=Mi(),{t:n}=W(),r=no(),i=parseInt(e||`0`,10),[a,o]=(0,y.useState)(Date.now()),s=(0,y.useMemo)(()=>kXe(t),[t]),c=jXe(s.size),{data:l}=q({queryKey:[`printer`,i],queryFn:()=>Q.getPrinter(i),enabled:i>0}),{data:u}=q({queryKey:[`printerStatus`,i],queryFn:()=>Q.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings}),f=d?.time_format||`system`;(0,y.useEffect)(()=>{if(!i)return;let e=null,t=!1;return(async()=>{let n;try{n=(await Q.getWebSocketToken()).token}catch{}if(t)return;let a=window.location.protocol===`https:`?`wss:`:`ws:`,o=n?`?token=${encodeURIComponent(n)}`:``,s=`${a}//${window.location.host}/api/v1/ws${o}`;e=new WebSocket(s),e.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`printer_status`&&t.printer_id===i&&r.setQueryData([`printerStatus`,i],t.status)}catch{}},e.onerror=()=>{}})(),()=>{t=!0,e&&e.close()}},[i,r]),(0,y.useEffect)(()=>(document.title=l?`${l.name} - ${n(`streamOverlay.title`)}`:n(`streamOverlay.title`),()=>{document.title=`Bambuddy`}),[l,n]);let p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-white`,children:n(`streamOverlay.invalidPrinterId`)})});if(!u)return(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-gray-400`,children:n(`common.loading`)})});let m=u.state===`RUNNING`||u.state===`PAUSE`,h=u.progress||0,g=Xu(`/api/v1/printers/${i}/camera/stream?fps=${s.fps}&t=${a}`);return(0,K.jsxs)(`div`,{className:`min-h-screen bg-black relative overflow-hidden`,children:[s.showCamera&&(0,K.jsx)(`img`,{src:g,alt:n(`streamOverlay.cameraStream`),className:`absolute inset-0 w-full h-full object-contain`,style:l?.camera_rotation?{transform:`rotate(${l.camera_rotation}deg)`}:void 0,onError:p},a),(0,K.jsx)(`a`,{href:`https://github.com/maziggy/bambuddy`,target:`_blank`,rel:`noopener noreferrer`,className:`absolute top-4 right-4 z-10`,children:(0,K.jsx)(`img`,{src:`/img/bambuddy_logo_dark_transparent.png`,alt:`Bambuddy`,className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),(0,K.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent`,children:(0,K.jsxs)(`div`,{className:`${c.container}`,children:[s.showPrinter&&l&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} mb-2`,children:[(0,K.jsx)(Tl,{className:`${c.icon} text-white/70`}),(0,K.jsx)(`span`,{className:`${c.text} text-white font-medium`,children:l.name})]}),s.showFilename&&u.current_print&&(0,K.jsx)(`div`,{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:OXe(u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,``),u.gcode_file,n)}),s.showStatus&&(0,K.jsx)(`div`,{className:`${c.text} text-white/70 mb-2`,children:AXe(u,n)}),s.showProgress&&m&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1 ${c.text}`,children:[(0,K.jsx)(`span`,{className:`text-white/70`,children:n(`streamOverlay.progress`)}),(0,K.jsxs)(`span`,{className:`text-white font-bold`,children:[Math.round(h),`%`]})]}),(0,K.jsx)(`div`,{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${h}%`}})})]}),m&&(s.showLayers||s.showEta)&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} flex-wrap`,children:[s.showLayers&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(Rc,{className:c.icon}),(0,K.jsxs)(`span`,{className:c.text,children:[(0,K.jsx)(`span`,{className:`text-white`,children:u.layer_num}),(0,K.jsx)(`span`,{className:`mx-1`,children:`/`}),(0,K.jsx)(`span`,{children:u.total_layers})]})]}),s.showEta&&u.remaining_time!=null&&u.remaining_time>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(yu,{className:c.icon}),(0,K.jsx)(`span`,{className:`${c.text} text-white`,children:Cf(u.remaining_time*60)})]}),(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(Ss,{className:c.icon}),(0,K.jsxs)(`span`,{className:`${c.text} text-white`,children:[n(`streamOverlay.eta`),` `,Sf(u.remaining_time,f,n)]})]})]})]}),!m&&(0,K.jsx)(`div`,{className:`${c.text} text-white/70 py-2`,children:u.connected?n(`streamOverlay.printerIdle`):n(`streamOverlay.printerOffline`)})]})})]})}function NXe(){let{t:e}=W(),{id:t}=ir(),{mode:n}=md(),{data:r,isLoading:i,error:a}=q({queryKey:[`external-link`,t],queryFn:()=>Q.getExternalLink(Number(t)),enabled:!!t});return i?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a||!r?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-bambu-gray`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12`}),(0,K.jsx)(`p`,{children:e(`common.linkNotFound`)})]}):(0,K.jsx)(`iframe`,{src:r.url,className:`h-full w-full border-0`,style:{colorScheme:n},title:r.name,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`})}function a9(){let{id:e}=ir(),t=$n(),n=no(),{t:r}=W(),{showToast:i}=Td(),a=!!e,[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),{data:g,isLoading:_}=q({queryKey:[`group`,e],queryFn:()=>Q.getGroup(Number(e)),enabled:a}),{data:v,isLoading:b}=q({queryKey:[`permissions`],queryFn:()=>Q.getPermissions()});a&&g&&!m&&(s(g.name),l(g.description||``),d(g.permissions),h(!0));let x=J({mutationFn:e=>Q.createGroup(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`groups`]}),n.invalidateQueries({queryKey:[`group`]}),i(r(`groups.toast.created`)),t(`/settings?tab=users`)},onError:e=>{i(e.message,`error`)}}),S=J({mutationFn:t=>Q.updateGroup(Number(e),t),onSuccess:a=>{n.invalidateQueries({queryKey:[`groups`]}),a&&n.setQueryData([`group`,e],a),i(r(`groups.toast.updated`)),t(`/settings?tab=users`)},onError:e=>{i(e.message,`error`)}}),C=x.isPending||S.isPending,w=()=>{if(!o.trim()){i(r(`groups.toast.enterGroupName`),`error`);return}a?S.mutate({name:o===g?.name?void 0:o,description:c,permissions:u}):x.mutate({name:o,description:c||void 0,permissions:u})},T=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},E=(e,t)=>{let n=e.permissions.map(e=>e.value);d(e=>{let r=e.filter(e=>!n.includes(e));return t?[...r,...n]:r})},D=e=>e.permissions.every(e=>u.includes(e.value)),O=e=>{let t=e.permissions.filter(e=>u.includes(e.value)).length;return t>0&&t{v&&d(v.all_permissions)},A=()=>{d([])},j=f.toLowerCase(),M=(0,y.useMemo)(()=>v?j?v.categories.map(e=>({...e,permissions:e.permissions.filter(e=>e.label.toLowerCase().includes(j))})).filter(e=>e.permissions.length>0):v.categories:[],[v,j]),N=v?.all_permissions.length??0;return _||b?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`space-y-6 max-w-5xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>t(`/settings?tab=users`),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(jo,{className:`w-5 h-5`})}),(0,K.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:r(a?`groups.editor.title`:`groups.editor.createTitle`)})]}),a&&g?.is_system&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 shrink-0`}),r(`groups.form.systemGroupWarning`)]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:r(`groups.form.groupName`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:a&&g?.is_system,className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50`,placeholder:r(`groups.form.groupNamePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:r(`groups.form.description`)}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`groups.form.descriptionPlaceholder`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[r(`groups.editor.permissionsSelected`,{count:u.length}),` / `,N]}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:k,children:r(`groups.editor.selectAll`)}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:A,children:r(`groups.editor.clearAll`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:r(`groups.editor.search`),className:`pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64`})]})]}),M.length===0?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:r(`groups.editor.noResults`)}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:M.map(e=>{let t=v.categories.find(t=>t.name===e.name),n=t.permissions.filter(e=>u.includes(e.value)).length,r=t.permissions.length,i=D(t),a=O(t);return(0,K.jsxs)(_d,{children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>E(t,!i),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${i?`bg-bambu-green border-bambu-green`:a?`bg-bambu-green/50 border-bambu-green`:`border-bambu-gray hover:border-white`}`,children:[i&&(0,K.jsx)(rs,{className:`w-3 h-3 text-white`}),a&&!i&&(0,K.jsx)(al,{className:`w-3 h-3 text-white`})]}),(0,K.jsx)(ql,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray tabular-nums`,children:[n,`/`,r]})]}),(0,K.jsx)(`div`,{className:`p-3 space-y-1`,children:e.permissions.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.value),onChange:()=>T(e.value),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.label})]},e.value))})]},e.name)})}),(0,K.jsx)(`div`,{className:`h-16`}),(0,K.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>t(`/settings?tab=users`),children:r(`common.cancel`)}),(0,K.jsx)($,{onClick:w,disabled:C||!o.trim(),children:C?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.saving`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),r(`common.save`)]})})]})]})}var PXe=1.65,o9=[`#1DB954`,`#3B82F6`,`#F59E0B`,`#EF4444`,`#8B5CF6`];function s9(e,t,n){return`${e}||${t??``}||${n??``}`}function c9(e,t){let n=new Date(e);return n.setDate(n.getDate()+Math.round(t)),n}function l9(e){return e.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function u9(e){return e.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function FXe(e){if(e.length<2)return null;let t=[...e].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()),n=Date.now(),r=Math.LN2/30,i=[];for(let e=1;ee+t.weight,0);if(a===0)return null;let o=i.reduce((e,t)=>e+t.rate*t.weight,0)/a,s=i.reduce((e,t)=>e+t.weight*(t.rate-o)**2,0)/a;return{rate:o,stdDev:Math.sqrt(s)}}function IXe(e){let t=e.reduce((e,t)=>e+Math.max(0,t.weight_used-(t.weight_used_baseline??0)),0);if(t===0)return null;let n=Date.now(),r=(n-e.reduce((e,t)=>{let n=new Date(t.created_at).getTime();return nQ.getAllUsageHistory(5e3),staleTime:6e4,enabled:o}),{data:w=[]}=q({queryKey:[`shopping-list`],queryFn:Q.getShoppingList,staleTime:3e4,enabled:o}),T=x?.forecast_global_lead_time_days??0,E=(0,y.useMemo)(()=>{let e=new Map;for(let t of S)e.set(s9(t.material,t.subtype,t.brand),t);return e},[S]),D=(0,y.useMemo)(()=>{let e=new Map;for(let t of C){let n=e.get(t.spool_id)??[];n.push(t),e.set(t.spool_id,n)}return e},[C]),O=(0,y.useMemo)(()=>{let t=new Map;for(let n of e){if(n.archived_at)continue;let e=s9(n.material,n.subtype,n.brand),r=t.get(e)??{key:e,material:n.material,subtype:n.subtype,brand:n.brand,spools:[]};r.spools.push(n),t.set(e,r)}return[...t.values()]},[e]),k=(0,y.useMemo)(()=>{let e=new Date;return e.setHours(0,0,0,0),O.map(t=>{let n=E.get(t.key)??null,r=n?.lead_time_days??0,i=Math.max(T,r),a=n?.safety_margin_value??14,o=n?.safety_margin_unit??`days`,s=t.spools.reduce((e,t)=>e+Math.max(0,t.label_weight-t.weight_used),0),c=t.spools.reduce((e,t)=>e+t.label_weight,0),l=t.spools.reduce((e,t)=>e+Math.max(0,t.weight_used-(t.weight_used_baseline??0)),0),u=[];for(let e of t.spools)u.push(...D.get(e.id)??[]);let d=null,f=null,p=`none`,m=FXe(u);if(m!==null)d=m.rate,f=m.stdDev,p=`history`;else{let e=IXe(t.spools);e!==null&&(d=e,p=`delta`)}let h=PXe*(f??(d===null?0:d*.2))*Math.sqrt(i)+(o===`g`?a:d===null?a*5:d*a),g=d===null?0:d*i+h,_=d&&d>0?Math.floor(s/d):null,v=_===null?null:c9(e,_),y=d&&d>0?Math.floor((s-g)/d):null,b=y===null?null:c9(e,Math.max(0,y)),x=_!==null&&i>0&&_<=i,S=!x&&y!==null&&y<=0;return{group:t,settings:n,totalRemainingG:s,totalLabelG:c,totalSpools:t.spools.length,totalUsedG:l,dailyRateG:d,dailyRateStdDev:f,rateTier:p,effectiveLeadTimeDays:i,safetyStockG:h,reorderPointG:g,daysRemaining:_,daysUntilROP:y,projectedEmptyDate:v,reorderTriggerDate:b,reorderAlert:S,stockBreakAlert:x}})},[O,E,D,T]),A=(0,y.useMemo)(()=>{let e=[...k];return e.sort((e,t)=>{let n=0,r=0;switch(u){case`material`:n=[e.group.material,e.group.subtype??``,e.group.brand??``].join(` `).toLowerCase(),r=[t.group.material,t.group.subtype??``,t.group.brand??``].join(` `).toLowerCase();break;case`used`:n=e.totalUsedG,r=t.totalUsedG;break;case`days_left`:n=e.daysRemaining??999999,r=t.daysRemaining??999999;break;case`stock`:n=e.totalRemainingG,r=t.totalRemainingG;break}let i=nr);return f===`asc`?i:-i}),e},[k,u,f]),j=(0,y.useMemo)(()=>k.filter(e=>!e.settings?.alerts_snoozed&&(e.stockBreakAlert||e.reorderAlert)),[k]),M=(0,y.useMemo)(()=>[...k].filter(e=>e.dailyRateG!==null).sort((e,t)=>t.totalUsedG-e.totalUsedG).slice(0,5),[k]);if(!o)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-bambu-gray gap-3`,children:[(0,K.jsx)(qc,{className:`w-8 h-8 opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`forecast.noReadAccess`)})]});function N(e){u===e?p(e=>e===`asc`?`desc`:`asc`):(d(e),p(e===`days_left`?`asc`:`desc`))}let P=w.length>0?w.length:null;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[j.length>0&&(0,K.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors ${j.some(e=>e.stockBreakAlert)?`bg-red-500/15 border-red-500/30 text-red-300 hover:bg-red-500/25`:`bg-yellow-500/15 border-yellow-500/30 text-yellow-300 hover:bg-yellow-500/25`}`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4`}),r(`forecast.alertCount`,{count:j.length}),c?(0,K.jsx)(cs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(is,{className:`w-3.5 h-3.5`})]}),s&&(0,K.jsx)(HXe,{value:T,onSave:e=>{Q.updateSettings({forecast_global_lead_time_days:e}).then(()=>{t.invalidateQueries({queryKey:[`settings`]}),n(r(`forecast.globalLeadTimeSaved`),`success`)})}}),(0,K.jsxs)(`button`,{onClick:()=>_(e=>!e),className:`relative flex items-center gap-2 px-3 py-1.5 rounded-lg border border-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary text-sm transition-colors ml-auto`,children:[(0,K.jsx)(Jl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r(`forecast.shoppingList`)}),P&&(0,K.jsx)(`span`,{className:`absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-bambu-green text-white text-[10px] font-bold flex items-center justify-center`,children:P})]})]}),c&&j.length>0&&(0,K.jsx)(`div`,{className:`space-y-2`,children:j.map(e=>(0,K.jsx)(zXe,{forecast:e,onCart:()=>h(e)},e.group.key))}),g&&(0,K.jsx)(KXe,{items:w,forecasts:k,globalLeadTime:T,canWrite:s,onClose:()=>_(!1),onRemove:e=>{Q.removeFromShoppingList(e).then(()=>t.invalidateQueries({queryKey:[`shopping-list`]})).catch(()=>n(r(`forecast.failedSaveSettings`),`error`))},onClear:()=>{Q.clearShoppingList().then(()=>t.invalidateQueries({queryKey:[`shopping-list`]})).catch(()=>n(r(`forecast.failedSaveSettings`),`error`))}}),M.length>0&&(0,K.jsx)(VXe,{forecasts:M,days:v,onDaysChange:b}),k.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(xu,{className:`w-10 h-10 mb-3 opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`forecast.noSpools`)})]}):(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`w-8 px-4 py-3`}),(0,K.jsx)(d9,{col:`material`,active:u,dir:f,onSort:N,children:r(`forecast.sku`)}),(0,K.jsx)(d9,{col:`stock`,active:u,dir:f,onSort:N,children:r(`forecast.stock`)}),(0,K.jsx)(d9,{col:`used`,active:u,dir:f,onSort:N,children:r(`forecast.dailyRate`)}),(0,K.jsx)(d9,{col:`days_left`,active:u,dir:f,onSort:N,children:r(`forecast.daysLeft`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:r(`forecast.emptyBy`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:r(`forecast.reorderBy`)}),(0,K.jsx)(`th`,{className:`w-24 px-4 py-3`})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:A.map(e=>(0,K.jsx)(UXe,{forecast:e,globalLeadTime:T,canWrite:s,onSaved:()=>t.invalidateQueries({queryKey:[`sku-settings`]}),onCart:()=>h(e),showToast:n},e.group.key))})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-3 text-xs text-bambu-gray border-t border-bambu-dark-tertiary bg-bambu-dark-tertiary/20`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-bambu-green inline-block`}),r(`forecast.trendLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-blue-400 inline-block`}),r(`forecast.estimatedLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-bambu-gray/40 inline-block`}),r(`forecast.noDataLegend`)]})]})]}),m&&(0,K.jsx)(JXe,{forecast:m,onClose:()=>h(null),onAdd:e=>{Q.addToShoppingList(e).then(()=>{t.invalidateQueries({queryKey:[`shopping-list`]}),n(r(`forecast.addedToCart`),`success`),h(null),_(!0)}).catch(()=>n(r(`forecast.failedAddItem`),`error`))}})]})}function d9({col:e,active:t,dir:n,onSort:r,children:i}){return(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide cursor-pointer select-none hover:text-white transition-colors`,onClick:()=>r(e),children:(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[i,t===e?n===`asc`?(0,K.jsx)(Io,{className:`w-3 h-3 ml-1 text-bambu-green`}):(0,K.jsx)(Ao,{className:`w-3 h-3 ml-1 text-bambu-green`}):(0,K.jsx)(Po,{className:`w-3 h-3 ml-1 opacity-40`})]})})}function zXe({forecast:e,onCart:t}){let{t:n}=W(),r=[e.group.brand,e.group.material,e.group.subtype].filter(Boolean).join(` `),i=e.stockBreakAlert;return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg border text-sm ${i?`bg-red-500/10 border-red-500/30 text-red-300`:`bg-yellow-500/10 border-yellow-500/30 text-yellow-300`}`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:r}),i?(0,K.jsxs)(`span`,{className:`ml-2 text-xs opacity-80`,children:[n(`forecast.stockBreakRisk`),` — `,n(`forecast.stockBreakDetail`,{days:e.daysRemaining,lt:e.effectiveLeadTimeDays})]}):(0,K.jsxs)(`span`,{className:`ml-2 text-xs opacity-80`,children:[n(`forecast.reorderNow`),` — `,n(`forecast.reorderTriggerPassed`,{date:e.reorderTriggerDate?l9(e.reorderTriggerDate):`—`})]})]}),(0,K.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 px-2.5 py-1 rounded border border-current text-xs opacity-70 hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(Jl,{className:`w-3 h-3`}),` `,n(`forecast.order`)]})]})}var BXe=[{label:`1W`,value:7},{label:`1M`,value:30},{label:`6M`,value:180}];function VXe({forecasts:e,days:t,onDaysChange:n}){let{t:r}=W(),i=Array.from({length:t+1},(e,t)=>t),a=e.map((e,n)=>({key:e.group.key,label:[e.group.brand,e.group.material,e.group.subtype].filter(Boolean).join(` `),color:o9[n%o9.length],rop:e.reorderPointG,points:LXe(e,t)})),o=i.map(e=>{let t={day:e,label:u9(c9(new Date,e))};for(let n of a){let r=n.points.find(t=>t.day===e);t[n.key]=r?.stock??0}return t}),s=(()=>{for(let e=t;e>=0;e--)if(a.some(t=>o[e]?.[t.key]>0))return e;return t})(),c=o.slice(0,s+1),l=a.filter(e=>e.rop>0);return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:r(`forecast.chartTitle`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1 hidden sm:inline`,children:r(`forecast.dashedLinesROP`)}),(0,K.jsx)(`div`,{className:`ml-auto flex items-center bg-bambu-dark-tertiary rounded-lg p-0.5`,children:BXe.map(e=>(0,K.jsx)(`button`,{onClick:()=>n(e.value),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${t===e.value?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:e.label},e.value))})]}),(0,K.jsx)(pA,{width:`100%`,height:220,children:(0,K.jsxs)(oU,{data:c,margin:{top:4,right:8,bottom:0,left:0},children:[(0,K.jsx)(`defs`,{children:a.map(e=>(0,K.jsxs)(`linearGradient`,{id:`grad-${e.key}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,K.jsx)(`stop`,{offset:`5%`,stopColor:e.color,stopOpacity:.25}),(0,K.jsx)(`stop`,{offset:`95%`,stopColor:e.color,stopOpacity:.02})]},e.key))}),(0,K.jsx)(EV,{strokeDasharray:`3 3`,stroke:`#374151`,strokeOpacity:.5}),(0,K.jsx)(gH,{dataKey:`label`,tick:{fill:`#6B7280`,fontSize:10},interval:Math.max(0,Math.ceil(s/8)-1),axisLine:!1,tickLine:!1}),(0,K.jsx)(xH,{tick:{fill:`#6B7280`,fontSize:10},axisLine:!1,tickLine:!1,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}kg`:`${e}g`,width:48}),(0,K.jsx)(cz,{contentStyle:{background:`#1a1a2e`,border:`1px solid #374151`,borderRadius:8,fontSize:12},labelStyle:{color:`#9CA3AF`},itemStyle:{color:`#E5E7EB`},formatter:(e,t)=>typeof e==`number`?`${e}g — ${a.find(e=>e.key===String(t))?.label??t}`:``}),(0,K.jsx)(dj,{formatter:e=>(0,K.jsx)(`span`,{style:{color:`#9CA3AF`,fontSize:11},children:a.find(t=>t.key===e)?.label??e})}),a.map(e=>(0,K.jsx)(JV,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:2,fill:`url(#grad-${e.key})`,dot:!1,activeDot:{r:3}},e.key)),l.map(e=>(0,K.jsx)(uV,{y:e.rop,stroke:e.color,strokeDasharray:`4 3`,strokeOpacity:.6},`rop-${e.key}`))]})})]})}function HXe({value:e,onSave:t}){let{t:n}=W(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(String(e));function s(){let e=parseInt(a,10);isNaN(e)||e<0||(t(e),i(!1))}return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-tertiary/40 rounded-lg border border-bambu-dark-tertiary text-xs text-bambu-gray`,children:[(0,K.jsx)(Pc,{className:`w-3.5 h-3.5 flex-shrink-0`,"aria-label":n(`forecast.globalLeadTimeHint`)}),(0,K.jsxs)(`span`,{className:`hidden sm:inline`,children:[n(`forecast.globalLeadTime`),`:`]}),r?(0,K.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault(),s()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:365,value:a,onChange:e=>o(e.target.value),className:`w-14 px-1.5 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`d`}),(0,K.jsx)(`button`,{type:`submit`,className:`px-2 py-0.5 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80`,children:n(`forecast.save`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`text-xs text-bambu-gray hover:text-white`,children:`✕`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`font-semibold text-white`,children:[e,`d`]}),(0,K.jsx)(`button`,{onClick:()=>{o(String(e)),i(!0)},className:`p-0.5 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function UXe({forecast:e,globalLeadTime:t,canWrite:n,onSaved:r,onCart:i,showToast:a}){let{t:o}=W(),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(String(e.settings?.lead_time_days??0)),[h,g]=(0,y.useState)(String(e.settings?.safety_margin_value??14)),[_,v]=(0,y.useState)(e.settings?.safety_margin_unit??`days`);(0,y.useEffect)(()=>{l||m(String(e.settings?.lead_time_days??0))},[e.settings?.lead_time_days,l]),(0,y.useEffect)(()=>{d||(g(String(e.settings?.safety_margin_value??14)),v(e.settings?.safety_margin_unit??`days`))},[e.settings?.safety_margin_value,e.settings?.safety_margin_unit,d]);let b=J({mutationFn:Q.upsertSkuSettings,onSuccess:()=>{r(),a(o(`forecast.settingsSaved`),`success`)},onError:()=>a(o(`forecast.failedSaveSettings`),`error`)}),x=e.settings?.alerts_snoozed??!1,S=[e.group.brand,e.group.material,e.group.subtype].filter(Boolean).join(` `),C=e.group.spools[0]?.rgba?Jd(e.group.spools[0].rgba):{backgroundColor:`#4B5563`},w=e.totalLabelG>0?Math.round(e.totalRemainingG/e.totalLabelG*100):0,T=x||e.daysRemaining===null?`text-bambu-gray`:e.stockBreakAlert?`text-red-400`:e.reorderAlert||e.daysRemaining<30?`text-yellow-400`:`text-green-400`;function E(t,n,r,i=x){b.mutate({material:e.group.material,subtype:e.group.subtype,brand:e.group.brand,lead_time_days:t,safety_margin_value:n,safety_margin_unit:r,alerts_snoozed:i})}function D(t){t.stopPropagation(),E(e.settings?.lead_time_days??0,e.settings?.safety_margin_value??14,e.settings?.safety_margin_unit??`days`,!x)}let O=e.rateTier===`history`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-bambu-green/15 text-bambu-green`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-green`}),o(`forecast.trend`)]}):e.rateTier===`delta`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-400/15 text-blue-400`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-blue-400`}),o(`forecast.estimated`)]}):(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray/60`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-gray/40`}),o(`forecast.noData`)]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`cursor-pointer hover:bg-bambu-dark-tertiary/40 transition-colors ${x?``:e.stockBreakAlert?`bg-red-500/5`:e.reorderAlert?`bg-yellow-500/5`:``} ${x?`opacity-50`:``}`,onClick:()=>c(e=>!e),children:[(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`block w-3 h-3 rounded-full border border-black/20`,style:C})}),(0,K.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-white`,children:S}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray`,children:o(`forecast.spoolCount`,{count:e.totalSpools})})]}),(0,K.jsxs)(`td`,{className:`px-4 py-3 min-w-[120px]`,children:[(0,K.jsx)(`div`,{className:`h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden mb-1 w-24`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${w>50?`bg-bambu-green`:w>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(w,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(e.totalRemainingG),`g`]})]}),(0,K.jsxs)(`td`,{className:`px-4 py-3`,children:[(0,K.jsx)(`div`,{className:`text-sm text-white`,children:e.dailyRateG===null?`—`:`${e.dailyRateG.toFixed(1)}g/d`}),(0,K.jsx)(`div`,{className:`mt-0.5`,children:O})]}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-semibold ${T}`,children:e.daysRemaining===null?(0,K.jsx)(`span`,{className:`text-bambu-gray font-normal`,children:`—`}):`${e.daysRemaining}d`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.projectedEmptyDate?l9(e.projectedEmptyDate):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-medium ${!x&&e.reorderAlert?`text-yellow-400`:`text-bambu-gray`}`,children:e.reorderTriggerDate?l9(e.reorderTriggerDate):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&(0,K.jsx)(`button`,{onClick:i,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:o(`forecast.addToCart`),children:(0,K.jsx)(Jl,{className:`w-4 h-4`})}),!x&&(e.stockBreakAlert?(0,K.jsx)(Cu,{className:`w-4 h-4 text-red-400`,"aria-label":o(`forecast.stockBreakRisk`)}):e.reorderAlert?(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400`,"aria-label":o(`forecast.reorderNow`)}):e.daysRemaining===null?null:(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green/50`})),n&&(0,K.jsx)(`button`,{onClick:D,className:`p-1 rounded transition-colors ${x?`text-bambu-gray/70 hover:text-white`:`text-bambu-dark-tertiary hover:text-bambu-gray`}`,title:o(x?`forecast.alertsEnabled`:`forecast.alertsSnoozed`),children:(0,K.jsx)(zo,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c(e=>!e)},className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,children:s?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`})})]})})]}),s&&(0,K.jsx)(`tr`,{className:`bg-bambu-dark-tertiary/10`,children:(0,K.jsx)(`td`,{colSpan:8,className:`px-6 py-4`,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,K.jsx)(f9,{label:o(`forecast.effectiveLeadTime`),value:`${e.effectiveLeadTimeDays}d`,hint:o(`forecast.effectiveLeadTimeHint`,{global:t,sku:e.settings?.lead_time_days??0})}),(0,K.jsx)(f9,{label:o(`forecast.safetyMarginLabel`),value:`${Math.round(e.safetyStockG)}g`,hint:o(`forecast.safetyMarginHint`)}),(0,K.jsx)(f9,{label:o(`forecast.reorderPoint`),value:`${Math.round(e.reorderPointG)}g`,hint:o(`forecast.reorderPointHint`)})]}),n&&(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,K.jsx)(WXe,{label:o(`forecast.skuLeadTimeOverride`),hint:o(`forecast.skuLeadTimeHint`),unit:o(`forecast.leadTime`),editing:l,value:e.settings?.lead_time_days??0,inputValue:p,onInputChange:m,onEdit:()=>{m(String(e.settings?.lead_time_days??0)),u(!0)},onSave:()=>{let t=parseInt(p,10);!isNaN(t)&&t>=0&&(E(t,e.settings?.safety_margin_value??14,_),u(!1))},onCancel:()=>u(!1),isPending:b.isPending,saveLabel:o(`forecast.save`),cancelLabel:o(`forecast.cancel`)}),(0,K.jsx)(GXe,{value:e.settings?.safety_margin_value??14,unit:_,editing:d,inputValue:h,dailyRateG:e.dailyRateG,onInputChange:g,onUnitChange:e=>v(e),onEdit:()=>{g(String(e.settings?.safety_margin_value??14)),v(e.settings?.safety_margin_unit??`days`),f(!0)},onSave:()=>{let t=parseInt(h,10);!isNaN(t)&&t>=0&&(E(e.settings?.lead_time_days??0,t,_),f(!1))},onCancel:()=>f(!1),isPending:b.isPending,saveLabel:o(`forecast.save`),cancelLabel:o(`forecast.cancel`),safetyMarginLabel:o(`forecast.safetyMarginLabel`)})]}),e.group.spools.length>1&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:o(`forecast.individualSpools`)}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:`#`}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.remaining`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.used`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`forecast.labelWeight`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:e.group.spools.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used),n=e.label_weight>0?t/e.label_weight*100:0;return(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-tertiary/30 transition-colors`,children:[(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray/70`,children:[`#`,e.id]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-24 h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden flex-shrink-0`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${n>50?`bg-bambu-green`:n>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(n,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[Math.round(t),`g`]})]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[Math.round(Math.max(0,e.weight_used-(e.weight_used_baseline??0))),`g`]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e.label_weight,`g`]})})]},e.id)})})]})})]})]})})})]})}function f9({label:e,value:t,hint:n}){return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3`,title:n,children:[(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mb-1`,children:e}),(0,K.jsx)(`div`,{className:`text-lg font-semibold text-white`,children:t})]})}function WXe({label:e,hint:t,unit:n,editing:r,value:i,inputValue:a,onInputChange:o,onEdit:s,onSave:c,onCancel:l,isPending:u,saveLabel:d=`Save`,cancelLabel:f=`Cancel`}){return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-white`,children:e}),(0,K.jsx)(`span`,{title:t,children:(0,K.jsx)(Pc,{className:`w-3 h-3 text-bambu-gray/50`})})]}),r?(0,K.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:365,value:a,onChange:e=>o(e.target.value),className:`w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0,disabled:u}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n}),(0,K.jsx)(`button`,{type:`submit`,disabled:u,className:`px-2 py-1 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:d}),(0,K.jsx)(`button`,{type:`button`,onClick:l,disabled:u,className:`px-2 py-1 text-xs text-bambu-gray hover:text-white`,children:f})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold text-white`,children:i}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n}),(0,K.jsx)(`button`,{onClick:s,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function GXe({value:e,unit:t,editing:n,inputValue:r,dailyRateG:i,onInputChange:a,onUnitChange:o,onEdit:s,onSave:c,onCancel:l,isPending:u,saveLabel:d=`Save`,cancelLabel:f=`Cancel`,safetyMarginLabel:p=`Safety Margin`}){let{t:m}=W(),h=t===`g`?e:i===null?null:Math.round(i*e),g=t===`days`?m(`forecast.safetyMarginHintDays`,{approx:h===null?``:m(`forecast.safetyMarginHintDaysApprox`,{g:h})}):m(`forecast.safetyMarginHintG`,{approx:i===null?``:m(`forecast.safetyMarginHintGApprox`,{days:Math.round(e/i)})});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-white`,children:p}),(0,K.jsx)(`span`,{title:g,children:(0,K.jsx)(Pc,{className:`w-3 h-3 text-bambu-gray/50`})})]}),n?(0,K.jsxs)(`form`,{className:`flex items-center gap-2 flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:t===`g`?1e4:365,value:r,onChange:e=>a(e.target.value),className:`w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0,disabled:u}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded overflow-hidden text-xs`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`days`),className:`px-2 py-1 transition-colors ${t===`days`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`days`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`g`),className:`px-2 py-1 transition-colors ${t===`g`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`g`})]}),(0,K.jsx)(`button`,{type:`submit`,disabled:u,className:`px-2 py-1 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:d}),(0,K.jsx)(`button`,{type:`button`,onClick:l,disabled:u,className:`px-2 py-1 text-xs text-bambu-gray hover:text-white`,children:f})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold text-white`,children:e}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:t}),h!==null&&t===`days`&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray/60`,children:[`≈ `,h,`g`]}),t===`g`&&i!==null&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray/60`,children:[`≈ `,Math.round(e/i),`d`]}),(0,K.jsx)(`button`,{onClick:s,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function KXe({items:e,forecasts:t,globalLeadTime:n,canWrite:r,onClose:i,onRemove:a,onClear:o}){let{t:s}=W(),c=no(),[l,u]=(0,y.useState)(`list`),d=J({mutationFn:async({id:e,status:t,item:n,avgSpoolG:r})=>{if(await Q.updateShoppingListStatus(e,t),t===`received`&&n){let t=r??1e3,i={material:n.material,subtype:n.subtype,brand:n.brand,label_weight:t,core_weight:0,core_weight_catalog_id:null,color_name:null,rgba:null,extra_colors:null,effect_type:null,nozzle_temp_min:null,nozzle_temp_max:null,note:n.note??null,tag_uid:null,tray_uuid:null,data_origin:`manual`,tag_type:null,cost_per_kg:null,last_scale_weight:null,last_weighed_at:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,added_full:null,last_used:null,encode_time:null,category:`Stock`,low_stock_threshold_pct:null};await Q.bulkCreateSpools(i,n.quantity_spools),await Q.removeFromShoppingList(e)}},onSuccess:()=>{c.invalidateQueries({queryKey:[`shopping-list`]}),c.invalidateQueries({queryKey:[`spools`]})}}),f=(0,y.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.group.key,n);return e},[t]),p=(0,y.useMemo)(()=>e.map(e=>({item:e,forecast:f.get(s9(e.material,e.subtype,e.brand))??null})),[e,f]),m=(0,y.useMemo)(()=>p.filter(({forecast:e})=>!e||e.dailyRateG===null?!1:e.stockBreakAlert||e.daysRemaining!==null&&e.daysRemaining<=e.effectiveLeadTimeDays),[p]);function h(){let t=[s(`forecast.qty`),s(`forecast.material`),`Brand`,`Subtype`,`${s(`forecast.weight`)} (g)`,`${s(`forecast.leadTime`)} (d)`,s(`forecast.expectedRestock`),s(`forecast.status`),s(`forecast.note`)],r=e.map(e=>{let t=f.get(s9(e.material,e.subtype,e.brand))??null,r=t&&t.totalSpools>0?t.totalLabelG/t.totalSpools:1e3,i=Math.round(e.quantity_spools*r),a=t?.effectiveLeadTimeDays??n??0,o=a>0?l9(c9(new Date,a)):``;return[e.quantity_spools,e.material,e.brand??``,e.subtype??``,i,a||``,o,e.status,e.note??``].map(e=>`"${String(e).replace(/"/g,`""`)}"`).join(`,`)}),i=[t.join(`,`),...r].join(` -`),a=new Blob([i],{type:`text/csv`}),o=URL.createObjectURL(a),c=document.createElement(`a`);c.href=o,c.download=`shopping-list-${new Date().toISOString().slice(0,10)}.csv`,c.click(),setTimeout(()=>URL.revokeObjectURL(o),100)}return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Jl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:s(`forecast.shoppingList`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s(`forecast.shoppingListItems`,{count:e.length})}),e.length>0&&(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-tertiary rounded-md p-0.5 ml-1`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(`list`),className:`flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium rounded transition-colors ${l===`list`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(pl,{className:`w-3 h-3`}),s(`forecast.listView`)]}),(0,K.jsxs)(`button`,{onClick:()=>u(`logistics`),className:`flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium rounded transition-colors ${l===`logistics`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(ts,{className:`w-3 h-3`}),s(`forecast.logisticsView`),m.length>0&&(0,K.jsx)(`span`,{className:`w-3.5 h-3.5 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center`,children:m.length})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:h,className:`flex items-center gap-1.5 text-xs text-bambu-gray hover:text-white transition-colors px-2 py-1 rounded border border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`,children:[(0,K.jsx)(Vs,{className:`w-3 h-3`}),s(`forecast.downloadCsv`)]}),r&&(0,K.jsx)(`button`,{onClick:o,className:`text-xs text-red-400 hover:text-red-300 transition-colors px-2 py-1 rounded border border-red-500/20 hover:bg-red-500/10`,children:s(`forecast.clearAll`)})]}),(0,K.jsx)(`button`,{onClick:i,className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center py-8 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-8 h-8 mb-2 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:s(`forecast.shoppingListEmpty`)})]}):l===`list`?(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/20`,children:[(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.qty`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.material`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.weight`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.leadTime`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.expectedRestock`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.status`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.note`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-right text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:e.map(e=>{let t=[e.brand,e.material,e.subtype].filter(Boolean).join(` `),i=m.some(t=>t.item.id===e.id),o=f.get(s9(e.material,e.subtype,e.brand))??null,c=o&&o.totalSpools>0?o.totalLabelG/o.totalSpools:1e3,l=Math.round(e.quantity_spools*c),u=o?.effectiveLeadTimeDays??n??0,p=u>0?c9(new Date,u):null,h=e.status===`purchased`||e.status===`received`,g=e.status===`received`,_=d.isPending;return(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-tertiary/30 transition-colors ${i&&!h?`bg-red-500/5`:``}`,children:[(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsxs)(`span`,{className:`text-sm font-semibold text-bambu-green`,children:[e.quantity_spools,`×`]})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:t}),i&&!h&&(0,K.jsx)(Cu,{className:`w-3.5 h-3.5 text-red-400 flex-shrink-0`,"aria-label":s(`forecast.stockBreakBefore`)})]})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-white`,children:l>=1e3?`${(l/1e3).toFixed(1)}kg`:`${l}g`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:u>0?`${u}d`:`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:p?l9(p):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${g?`bg-bambu-green/20 text-bambu-green`:h?`bg-blue-400/20 text-blue-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:s(g?`forecast.received`:h?`forecast.purchased`:`forecast.pending`)})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.note||`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-end gap-1`,children:r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>d.mutate({id:e.id,status:h?`pending`:`purchased`}),disabled:_||g,title:s(h?`forecast.resetToPending`:`forecast.markPurchased`),className:`p-1 rounded transition-colors disabled:opacity-30 ${h?`text-blue-400 hover:text-bambu-gray`:`text-bambu-gray hover:text-blue-400`}`,children:h?(0,K.jsx)(Al,{className:`w-3.5 h-3.5`}):(0,K.jsx)(Ps,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>d.mutate({id:e.id,status:`received`,item:e,avgSpoolG:c}),disabled:_||!h||g,title:s(`forecast.markReceived`),className:`p-1 rounded transition-colors text-bambu-gray hover:text-bambu-green disabled:opacity-30`,children:(0,K.jsx)(dl,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>a(e.id),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,title:s(`forecast.remove`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})})]})})})]},e.id)})})]})}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:p.filter(({item:e})=>e.status!==`received`).map(({item:e,forecast:t})=>(0,K.jsx)(qXe,{item:e,forecast:t,globalLeadTime:n,canWrite:r,onRemove:()=>a(e.id)},e.id))})]})}function qXe({item:e,forecast:t,globalLeadTime:n,canWrite:r,onRemove:i}){let{t:a}=W(),o=[e.brand,e.material,e.subtype].filter(Boolean).join(` `),s=(0,y.useMemo)(()=>{if(!t||t.dailyRateG===null||t.dailyRateG<=0)return null;let n=t.dailyRateG,r=t.effectiveLeadTimeDays,i=t.totalSpools>0?t.totalLabelG/t.totalSpools:1e3,a=e.quantity_spools*i,o=Math.max(0,t.totalRemainingG-n*r),s=o+a,c=Math.ceil(s/n),l=Math.min(r+c+5,365),u=[];for(let e=0;e<=l;e++){let i=u9(c9(new Date,e));if(e===r)u.push({day:e,label:i,stock:Math.round(o),rop:Math.round(t.reorderPointG),safetyStock:Math.round(t.safetyStockG)}),u.push({day:e,label:i,stock:Math.round(s),rop:Math.round(t.reorderPointG),safetyStock:Math.round(t.safetyStockG),arrival:!0});else{let a=e{if(!t||t.dailyRateG===null||t.dailyRateG<=0)return null;let e=Math.floor(t.totalRemainingG/t.dailyRateG);return ee>=1e3?`${(e/1e3).toFixed(1)}kg`:`${e}g`,width:44}),(0,K.jsx)(cz,{contentStyle:{background:`#1a1a2e`,border:`1px solid #374151`,borderRadius:8,fontSize:11},labelStyle:{color:`#9CA3AF`},formatter:(e,t)=>typeof e==`number`?t===`stock`?`${e}g — ${a(`forecast.stock`)}`:t===`rop`?`${e}g — ${a(`forecast.reorderPoint`)}`:t===`safetyStock`?`${e}g — ${a(`forecast.safetyMarginLabel`)}`:`${e}`:``}),(0,K.jsx)(JV,{type:`linear`,dataKey:`stock`,stroke:`#1DB954`,strokeWidth:2,fill:`url(#cart-post-${e.id})`,dot:!1,activeDot:{r:3}}),t.reorderPointG>0&&(0,K.jsx)(uV,{y:t.reorderPointG,stroke:`#F59E0B`,strokeDasharray:`5 3`,strokeOpacity:.8,label:{value:`ROP`,position:`insideTopRight`,fill:`#F59E0B`,fontSize:9}}),t.safetyStockG>0&&(0,K.jsx)(uV,{y:t.safetyStockG,stroke:`#6B7280`,strokeDasharray:`3 3`,strokeOpacity:.6,label:{value:`SS`,position:`insideTopRight`,fill:`#6B7280`,fontSize:9}}),(0,K.jsx)(uV,{x:u9(c9(new Date,s.lt)),stroke:`#3B82F6`,strokeWidth:1.5,strokeDasharray:`4 3`,strokeOpacity:.9,label:{value:`+${s.arrivalG>=1e3?`${(s.arrivalG/1e3).toFixed(1)}kg`:`${Math.round(s.arrivalG)}g`} arrives (d${s.lt})`,position:`insideTopLeft`,fill:`#3B82F6`,fontSize:9}}),c!==null&&(0,K.jsx)(uV,{x:u9(c9(new Date,c)),stroke:`#EF4444`,strokeWidth:1.5,strokeOpacity:.9,label:{value:`OUT`,position:`insideTopLeft`,fill:`#EF4444`,fontSize:9}})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mt-2 text-[10px] text-bambu-gray`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-yellow-400 border-dashed`}),` `,a(`forecast.ropLabel`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t border-bambu-gray border-dashed`}),` `,a(`forecast.safetyStockLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-blue-400 border-dashed`}),` `,a(`forecast.stockArrivalLegend`)]}),l&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-red-400`}),` `,a(`forecast.stockoutLegend`)]})]})]}):null]})}function JXe({forecast:e,onClose:t,onAdd:n}){let{t:r}=W(),i=[e.group.brand,e.group.material,e.group.subtype].filter(Boolean).join(` `),[a,o]=(0,y.useState)(`qty`),[s,c]=(0,y.useState)(`1`),[l,u]=(0,y.useState)(`30`),[d,f]=(0,y.useState)(``),p=(0,y.useMemo)(()=>{if(!e.dailyRateG||e.dailyRateG<=0)return null;let t=e.dailyRateG*Number(l),n=e.group.spools.length>0?e.group.spools.reduce((e,t)=>e+t.label_weight,0)/e.group.spools.length:1e3;return Math.ceil(t/n)},[e,l]),m=a===`qty`?parseInt(s,10)||1:p??1;function h(t){t.preventDefault(),n({material:e.group.material,subtype:e.group.subtype,brand:e.group.brand,quantity_spools:m,note:d||null})}return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-2xl border border-bambu-dark-tertiary w-full max-w-sm shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-5 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Jl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-white`,children:r(`forecast.addToCartTitle`)})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:h,className:`p-5 space-y-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:i}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-tertiary rounded-lg p-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`qty`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors ${a===`qty`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:r(`forecast.byQuantity`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`duration`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors ${a===`duration`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:r(`forecast.byDuration`)})]}),a===`qty`?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.numberOfSpools`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:99,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,autoFocus:!0})]}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.lastHowManyDays`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:365,value:l,onChange:e=>u(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,autoFocus:!0})]}),e.dailyRateG===null?(0,K.jsx)(`div`,{className:`text-xs text-yellow-400 px-1`,children:r(`forecast.noUsageQty`)}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-bambu-dark-tertiary/50 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`≈`}),(0,K.jsx)(`span`,{className:`text-sm font-semibold text-bambu-green`,children:r(`forecast.spoolCount`,{count:p??0})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`at `,e.dailyRateG.toFixed(1),`g/day`]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.noteOptional`)}),(0,K.jsx)(`input`,{type:`text`,maxLength:200,value:d,onChange:e=>f(e.target.value),placeholder:r(`forecast.notePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/40 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[(0,K.jsx)(`button`,{type:`submit`,className:`flex-1 py-2 bg-bambu-green text-white text-sm font-medium rounded-lg hover:bg-bambu-green/80 transition-colors`,children:r(`forecast.addNSpools`,{count:m})}),(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 text-sm text-bambu-gray hover:text-white border border-bambu-dark-tertiary rounded-lg transition-colors`,children:r(`forecast.cancel`)})]})]})]})})}var p9={material:``,subtype:``,brand:``,color_name:``,rgba:`808080FF`,extra_colors:``,effect_type:``,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:``,note:``,cost_per_kg:null,category:``,low_stock_threshold_pct:null,location_id:null,spoolman_filament_id:null},YXe=new Set([`material`,`subtype`,`brand`,`rgba`,`color_name`,`label_weight`]);function m9(e,t=!1,n=!1){let r={};return t||n?(!e.material&&!e.spoolman_filament_id&&(r.material=`Material is required`),{isValid:Object.keys(r).length===0,errors:r}):(e.slicer_filament||(r.slicer_filament=`Slicer preset is required`),e.material||(r.material=`Material is required`),e.brand||(r.brand=`Brand is required`),e.subtype||(r.subtype=`Subtype is required`),{isValid:Object.keys(r).length===0,errors:r})}function h9({formData:e,updateField:t,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:a,selectedPresetOption:o,filamentOptions:s,availableBrands:c,availableMaterials:l,quickAdd:u,quantity:d,onQuantityChange:f,errors:p}){let{t:m}=W(),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(String(e.label_weight)),[M,N]=(0,y.useState)(!1),P=(0,y.useRef)(null),F=(0,y.useRef)(null),I=(0,y.useRef)(null),L=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&g(!1),L.current&&!L.current.contains(e.target)&&C(!1),F.current&&!F.current.contains(e.target)&&v(!1),I.current&&!I.current.contains(e.target)&&x(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let R=(0,y.useMemo)(()=>{if(!i)return s;let e=i.toLowerCase();return s.filter(t=>t.displayName.toLowerCase().includes(e)||t.code.toLowerCase().includes(e))},[s,i]),z=(0,y.useMemo)(()=>{if(!w)return c;let e=w.toLowerCase();return c.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[c,w]),B=(0,y.useMemo)(()=>{if(!E)return wU;let e=E.toLowerCase();return wU.filter(t=>t.toLowerCase().includes(e))},[E]),V=(0,y.useMemo)(()=>{if(!O)return l;let e=O.toLowerCase();return l.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[O,l]);(0,y.useEffect)(()=>{M||j(String(e.label_weight))},[e.label_weight,M]);let ee=e=>{t(`slicer_filament`,e.code),a(e.displayName),g(!1);let n=OU(e.name);n.material&&t(`material`,n.material),n.brand&&t(`brand`,n.brand),n.variant&&t(`subtype`,n.variant)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[!u&&(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}),` `,m(`inventory.loadingPresets`)]}):n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ws,{className:`w-3 h-3 text-bambu-green`}),` `,m(`inventory.cloudConnected`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cs,{className:`w-3 h-3`}),` `,m(`inventory.cloudNotConnected`)]})}),!u&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.slicerPreset`),` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:P,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.searchPresets`),value:i,onChange:e=>{a(e.target.value),g(!0)},onFocus:()=>{g(!0),a(``)}}),h&&(0,K.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:R.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noPresetsFound`)}):R.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===e.code?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>ee(e),children:e.displayName},`${e.code}::${e.name}`))})]}),o&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray`,children:[m(`inventory.selectedPreset`),`: `,(0,K.jsx)(`span`,{className:`font-mono text-bambu-green`,children:o.code})]}),p?.slicer_filament&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.slicer_filament})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.material`),` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:L,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.selectMaterial`),value:S?O:e.material,onChange:e=>{k(e.target.value),C(!0)},onFocus:()=>{C(!0),k(``)}}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),S&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[V.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):V.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.material===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`material`,n),C(!1),k(``)},children:n},n)),O&&!V.includes(O)&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`material`,O),C(!1),k(``)},children:m(`inventory.useCustomMaterial`,{material:O})})]})]}),p?.material&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.material})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.brand`),!u&&` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:F,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.searchBrand`),value:_?w:e.brand,onChange:e=>{T(e.target.value),v(!0)},onFocus:()=>{v(!0),T(``)}}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),_&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[z.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):z.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.brand===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`brand`,n),v(!1),T(``)},children:n},n)),w&&!z.includes(w)&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`brand`,w),v(!1),T(``)},children:m(`inventory.useCustomBrand`,{brand:w})})]})]}),p?.brand&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.brand})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.subtype`),!u&&` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:I,children:[(0,K.jsx)(`input`,{type:`text`,value:b?E:e.subtype,onChange:e=>{D(e.target.value),x(!0)},onFocus:()=>{x(!0),D(``)},placeholder:`Basic, Matte, Silk...`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),b&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[B.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):B.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.subtype===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`subtype`,n),x(!1),D(``)},children:n},n)),E&&!wU.some(e=>e.toLowerCase()===E.toLowerCase().trim())&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`subtype`,E),x(!1),D(``)},children:m(`inventory.useCustomBrand`,{brand:E})})]})]}),p?.subtype&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.subtype})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:m(`inventory.labelWeight`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:A,min:0,onFocus:()=>N(!0),onChange:e=>j(e.target.value),onBlur:()=>{N(!1);let n=A.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0){j(String(e.label_weight));return}let i=Math.round(r);t(`label_weight`,i),j(String(i))}}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]})]}),u&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:m(`inventory.quantity`)}),(0,K.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:d,min:1,max:100,onChange:e=>{f(Math.max(1,Math.min(100,parseInt(e.target.value)||1)))}})]})]})}function XXe(e){let t=e.split(/[\s,]+/).map(e=>e.trim().replace(/^#/,``)).filter(Boolean),n=[],r=[];for(let e of t)(e.length===6||e.length===8)&&/^[0-9a-fA-F]+$/.test(e)?n.push(e.toLowerCase()):r.push(e);return{value:n.join(`,`),invalid:r}}function g9({formData:e,updateField:t,recentColors:n,onColorUsed:r,catalogColors:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(``),u=(e.rgba.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),d=u.substring(0,6),f=u.substring(6,8)===`00`,[p,m]=(0,y.useState)(f?u:d);(0,y.useEffect)(()=>{m(f?u:d)},[d,u,f]);let h=e=>u===(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),g=e=>Jd(e),_=(e,n,i,a)=>{let o=e.replace(`#`,``).toUpperCase();if(t(`rgba`,o.length===8?o:o+`FF`),t(`color_name`,n),i!==void 0){let e=i??``;w(e),E([]),D.current=e,t(`extra_colors`,e)}a!==void 0&&t(`effect_type`,a??``),r({name:n,hex:e})},v=(0,y.useMemo)(()=>{if(i.length===0)return[];let t=e.brand?.trim(),n=e.material?.toLowerCase().trim(),r=e.subtype?.toLowerCase().trim();if(!t&&!n)return[];let a=t?t.toLowerCase().split(/[\s\-_]+/).filter(e=>e.length>=2):[],o=e=>{if(a.length===0)return!0;let t=e.toLowerCase();return a.some(e=>t.includes(e))};if(t&&!n){let e=i.filter(e=>o(e.manufacturer));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}let s=n&&r?`${n} ${r}`:``;if(s){let e=i.filter(e=>o(e.manufacturer)&&e.material?.toLowerCase()===s);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}));let t=s.replace(/\+$/,``);if(t!==s){let e=i.filter(e=>o(e.manufacturer)&&e.material?.toLowerCase()===t);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0}))}}if(n){let e=i.filter(e=>o(e.manufacturer)&&(!e.material||e.material.toLowerCase().startsWith(n)));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}return[]},[i,e.brand,e.material,e.subtype]),b=(0,y.useMemo)(()=>{if(!c)return v;if(v.length===0)return[];let e=c.toLowerCase();return v.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[c,v]),x=v.length>0,S=(0,y.useMemo)(()=>c?EU.filter(e=>e.name.toLowerCase().includes(c.toLowerCase())):o?EU:TU,[c,o]),[C,w]=(0,y.useState)(e.extra_colors),[T,E]=(0,y.useState)([]),D=(0,y.useRef)(e.extra_colors);(0,y.useEffect)(()=>{e.extra_colors!==D.current&&(w(e.extra_colors),E([]),D.current=e.extra_colors)},[e.extra_colors]);let O=(0,y.useMemo)(()=>U3({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`bar`}),[e.rgba,e.extra_colors,e.effect_type,e.subtype]),k=e=>{if(w(e),!e.trim()){E([]),D.current=``,t(`extra_colors`,``);return}let{value:n,invalid:r}=XXe(e);E(r),D.current=n,t(`extra_colors`,n)};return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`h-10 rounded-lg border border-bambu-dark-tertiary`,style:O,"data-testid":`color-preview-banner`}),n.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray shrink-0`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:a(`inventory.recentColors`)})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.name},e.hex))})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.searchColors`),value:c,onChange:e=>l(e.target.value)})]}),x?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:c?a(`inventory.searchResults`):`${e.brand}${e.material?` ${e.material}`:``}`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[b.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name,e.extra_colors,e.effect_type),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name,children:(0,K.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name})},`${e.hex}-${e.name}-${e.manufacturer??``}`)),b.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:a(`inventory.noColorsFound`)})]})]}):(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:a(c?`inventory.searchResults`:o?`inventory.allColors`:`inventory.commonColors`)}),!c&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex items-center gap-1 hover:text-white transition-colors`,children:o?(0,K.jsxs)(K.Fragment,{children:[a(`inventory.showLess`),` `,(0,K.jsx)(cs,{className:`w-3 h-3`})]}):(0,K.jsxs)(K.Fragment,{children:[a(`inventory.showAll`),` `,(0,K.jsx)(is,{className:`w-3 h-3`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[S.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.name,children:(0,K.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.name})},e.hex)),S.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:a(`inventory.noColorsFound`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.colorName`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.colorNamePlaceholder`),value:e.color_name,onChange:e=>t(`color_name`,e.target.value)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.hexColor`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`,children:`#`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green`,placeholder:`RRGGBB`,value:p.toUpperCase(),onChange:e=>{let n=e.target.value.replace(`#`,``).replace(/[^0-9A-Fa-f]/g,``).toUpperCase(),r=n.length>8?n.substring(0,8):n;m(r),r.length===6?t(`rgba`,r+`FF`):r.length===8&&t(`rgba`,r)},onBlur:()=>{if(p.length===7){let e=p+`0`;m(e),t(`rgba`,e)}else if(p.length>0&&p.length<6){let e=p.padEnd(6,`0`);m(e),t(`rgba`,e+`FF`)}}})]}),(0,K.jsx)(`input`,{type:`color`,className:`w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent`,value:`#${d}`,onChange:e=>{t(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:a(`inventory.pickColor`)})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.extraColorsLabel`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.extraColorsPlaceholder`),value:C,onChange:e=>k(e.target.value),"data-testid":`extra-colors-input`}),T.length>0&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:a(`inventory.extraColorsInvalid`,{tokens:T.join(`, `)})}),!T.length&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:a(`inventory.extraColorsHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1 flex items-center gap-1.5`,children:[(0,K.jsx)(ru,{className:`w-3.5 h-3.5`}),a(`inventory.colorEffectLabel`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-stretch`,children:[(0,K.jsx)(`select`,{className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.effect_type,onChange:e=>t(`effect_type`,e.target.value),"data-testid":`effect-type-select`,children:B3.map(e=>(0,K.jsx)(`option`,{value:e.value,children:a(e.labelKey)},e.value||`none`))}),(0,K.jsx)(W3,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`preview`,className:`w-10 h-10`,shape:`square`})]})]})]})]})}function ZXe({catalog:e,value:t,onChange:n,catalogId:r,onCatalogIdChange:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(``),u=(0,y.useRef)(null),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,y.useEffect)(()=>{if(e.length===0)return;let n=e.filter(e=>e.weight===t);if(r){let n=e.find(e=>e.id===r);if(n&&n.weight===t)return}n.length===1?i(n[0].id):n.length===0&&r!==null&&i(null)},[t,e,r,i]);let f=(0,y.useMemo)(()=>{if(!c)return e;let t=c.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.weight.toString().includes(t))},[e,c]),p=(0,y.useMemo)(()=>e.filter(e=>e.weight===t),[e,t]),m=(0,y.useMemo)(()=>{if(o)return c;if(r){let t=e.find(e=>e.id===r);if(t)return t.name}return p.length>0?p[0].name:``},[o,c,r,e,p]);return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Pl,{className:`w-3.5 h-3.5 text-bambu-gray`}),a(`inventory.coreWeight`)]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,ref:u,children:[(0,K.jsx)(`input`,{ref:d,type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.searchSpoolWeight`),value:m,onFocus:()=>{s(!0),l(``)},onChange:e=>{l(e.target.value),s(!0)}}),o&&(0,K.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:f.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:a(`inventory.noResults`)}):f.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?e.id===r:e.weight===t)?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{i(e.id),n(e.weight),s(!1),l(``)},children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),(0,K.jsxs)(`span`,{className:`font-mono text-xs text-bambu-gray ml-2 shrink-0`,children:[e.weight,`g`]})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`input`,{type:`number`,className:`w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green`,value:t,min:0,max:2e3,onChange:e=>{let t=parseInt(e.target.value);!isNaN(t)&&t>=0&&n(t)}}),(0,K.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function _9({formData:e,updateField:t,spoolCatalog:n,currencySymbol:r,availableCategories:i,availableLocations:a=[],onCreateLocation:o,globalLowStockThreshold:s,spoolmanMode:c=!1}){let{t:l}=W(),{showToast:u}=Td(),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(``),[S,C]=(0,y.useState)(!1),w=Math.max(0,e.label_weight-e.weight_used),T=e.core_weight+w;return(0,y.useEffect)(()=>{p||f(String(T))},[p,T]),(0,y.useEffect)(()=>{_||g(String(w))},[_,w]),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[c?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray px-1`,children:l(`inventory.spoolWeightManagedBySpoolman`)}):(0,K.jsx)(ZXe,{catalog:n,value:e.core_weight,onChange:e=>t(`core_weight`,e),catalogId:e.core_weight_catalog_id,onCatalogIdChange:e=>t(`core_weight_catalog_id`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.currentWeight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:`number`,value:h,min:0,max:e.label_weight,onFocus:()=>v(!0),onChange:e=>{g(e.target.value)},onBlur:()=>{v(!1);let n=h.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0||r>e.label_weight){g(String(w));return}let i=Math.round(r);t(`weight_used`,Math.max(0,e.label_weight-i)),g(String(i))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.label_weight,`g`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.measuredWeight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:`number`,value:d,min:0,onFocus:()=>m(!0),onChange:e=>{f(e.target.value)},onBlur:()=>{m(!1);let n=d.trim(),r=Number(n),i=e.core_weight,a=e.core_weight+e.label_weight;if(!n||!Number.isFinite(r)||ra){u(l(`inventory.measuredWeightError`,{min:i,max:a}),`error`),f(String(T));return}let o=Math.round(r),s=Math.max(0,Math.min(e.label_weight,o-e.core_weight));t(`weight_used`,Math.max(0,e.label_weight-s)),f(String(o))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.core_weight+e.label_weight,`g`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.costPerKg`,`Cost per kg`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:r}),(0,K.jsx)(`input`,{type:`number`,value:e.cost_per_kg??``,min:0,step:.01,placeholder:`0.00`,onChange:e=>{t(`cost_per_kg`,e.target.value===``?null:parseFloat(e.target.value))},style:{paddingLeft:`${Math.max(2,r.length*.6+1)}rem`},className:`w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-category`,children:l(`inventory.category`)}),(0,K.jsx)(`input`,{id:`spool-category`,type:`text`,list:`spool-category-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>t(`category`,e.target.value)}),i.length>0&&(0,K.jsx)(`datalist`,{id:`spool-category-options`,children:i.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-low-stock-threshold`,children:l(`inventory.lowStockThresholdOverride`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{id:`spool-low-stock-threshold`,type:`number`,className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:String(s),value:e.low_stock_threshold_pct??``,min:1,max:99,step:1,onChange:e=>{let n=e.target.value;if(n===``){t(`low_stock_threshold_pct`,null);return}let r=Number(n);Number.isFinite(r)&&t(`low_stock_threshold_pct`,Math.min(99,Math.max(1,Math.round(r))))}}),(0,K.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-bambu-gray pointer-events-none`,children:`%`})]})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:l(`inventory.lowStockThresholdOverrideHelp`,{global:s})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.note`)}),(0,K.jsx)(`textarea`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]`,placeholder:l(`inventory.notePlaceholder`),value:e.note,onChange:e=>t(`note`,e.target.value)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-storage-location`,children:l(`inventory.storageLocation`)}),(0,K.jsxs)(`select`,{id:`spool-storage-location`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.location_id??``,onChange:e=>{let n=e.target.value;if(!n){t(`location_id`,null);return}t(`location_id`,Number(n))},children:[(0,K.jsx)(`option`,{value:``,children:l(`inventory.storageLocationNone`)}),a.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),o&&(0,K.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,maxLength:255,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`locations.createPlaceholder`),value:b,onChange:e=>x(e.target.value)}),(0,K.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark disabled:opacity-50`,disabled:!b.trim()||S,onClick:async()=>{let e=b.trim();if(!(!e||!o)){C(!0);try{let n=await o(e);n&&(t(`location_id`,n.id),x(``))}finally{C(!1)}}},children:l(`locations.addShort`)})]})]})]})}function QXe({filaments:e,isLoading:t,selectedId:n,onSelect:r}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),l=(0,y.useRef)(null),u=(0,y.useRef)(null),d=(0,y.useMemo)(()=>e.find(e=>e.id===n)??null,[e,n]);(0,y.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&(o(!1),c(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let f=(0,y.useMemo)(()=>{let t=s.toLowerCase().trim();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.material?.toLowerCase().includes(t)??!1)||(e.vendor?.name.toLowerCase().includes(t)??!1)||(e.color_name?.toLowerCase().includes(t)??!1)):e},[e,s]);(0,y.useEffect)(()=>{a&&u.current?.focus()},[a]);let p=()=>{o(!0),c(``)},m=e=>{r(e),o(!1),c(``)},h=e=>e?`#${e.replace(`#`,``)}`:`#808080`;return(0,K.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:i(`inventory.pickFromSpoolmanCatalog`)}),(0,K.jsxs)(`button`,{type:`button`,onClick:p,className:`w-full flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-left focus:outline-none focus:border-bambu-green hover:border-bambu-gray transition-colors`,children:[t?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin shrink-0`}):d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full shrink-0 border border-white/20`,style:{backgroundColor:h(d.color_hex)},"aria-label":i(`inventory.spoolmanFilamentColorSwatch`)}),(0,K.jsxs)(`span`,{className:`text-white text-sm truncate flex-1`,children:[d.vendor?.name?`${d.vendor.name} — `:``,d.name]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-bambu-gray text-sm flex-1`,children:i(`inventory.spoolmanFilamentCatalog`)})]}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0 ml-auto`})]}),a&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl`,children:[(0,K.jsx)(`div`,{className:`p-2 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`input`,{ref:u,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:i(`inventory.pickFromSpoolmanCatalog`),className:`w-full px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`ul`,{className:`max-h-56 overflow-y-auto py-1`,children:t?(0,K.jsxs)(`li`,{className:`flex items-center justify-center gap-2 py-4 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:i(`common.loading`,`Loading…`)})]}):f.length===0?(0,K.jsx)(`li`,{className:`py-4 text-center text-bambu-gray text-sm`,children:i(`inventory.noSpoolmanFilaments`)}):f.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bambu-dark-tertiary transition-colors ${e.id===n?`bg-bambu-dark-tertiary`:``}`,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full shrink-0 border border-white/20`,style:{backgroundColor:h(e.color_hex)},"aria-label":i(`inventory.spoolmanFilamentColorSwatch`)}),(0,K.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`span`,{className:`block text-white text-sm truncate`,children:[e.vendor?.name?`${e.vendor.name} — `:``,e.name]}),(0,K.jsxs)(`span`,{className:`block text-bambu-gray text-xs truncate`,children:[[e.material,e.color_name].filter(Boolean).join(` · `),e.weight?` · ${e.weight}g`:``]})]})]})},e.id))})]})]})}function v9({formData:e,printersWithCalibrations:t,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:a}){let{t:o}=W(),s=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},c=(e,t,n)=>{let i=`${e}:${t}:${n??`null`}`,a=`${e}:${n??`null`}`;r(e=>{let t=new Set(e);if(t.has(i))t.delete(i);else{for(let e of Array.from(t)){let n=e.split(`:`);`${n[0]}:${n[2]}`===a&&t.delete(e)}t.add(i)}return t})},l=()=>{let n=new Set;for(let{printer:r,calibrations:i}of t){if(!r.connected)continue;let t=i.filter(t=>IU(t,e)),a=new Map;for(let e of t){let t=`${e.extruder_id??`null`}`;a.has(t)||a.set(t,[]),a.get(t).push(e)}for(let[e,t]of a)if(t.length>0){let i=[...t].sort((e,t)=>t.k_value-e.k_value)[0];n.add(`${r.id}:${i.cali_idx}:${e}`)}}r(n)};if(!e.material)return(0,K.jsx)(`div`,{className:`p-6 bg-bambu-dark rounded-lg text-center`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`inventory.selectMaterialFirst`)})});if(t.length===0)return(0,K.jsx)(`div`,{className:`p-6 bg-bambu-dark rounded-lg text-center`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`inventory.noPrintersConfigured`)})});let u=t.reduce((t,{printer:n,calibrations:r})=>n.connected?t+r.filter(t=>IU(t,e)).length:t,0),d=(e,t)=>{let r=`${e.id}:${t.cali_idx}:${t.extruder_id??`null`}`,i=n.has(r);return(0,K.jsxs)(`label`,{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${i?`bg-bambu-green/10 border-bambu-green/30`:`bg-bambu-dark border-transparent hover:bg-bambu-dark/80`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i,onChange:()=>c(String(e.id),t.cali_idx,t.extruder_id),className:`w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`span`,{className:`text-sm font-medium ${i?`text-bambu-green`:`text-white`}`,children:t.name||t.filament_id})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,K.jsxs)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray`,children:[`K=`,t.k_value.toFixed(3)]})})]},`${t.cali_idx}-${t.extruder_id}`)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[o(`inventory.matchingFilter`),`: `,e.brand||o(`inventory.anyBrand`),` / `,e.material,` / `,e.subtype||o(`inventory.anyVariant`)]}),u>0&&(0,K.jsxs)(`button`,{type:`button`,onClick:l,className:`flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors`,children:[(0,K.jsx)(ru,{className:`w-3.5 h-3.5`}),o(`inventory.autoSelect`),` (`,u,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-3`,children:t.map(({printer:t,calibrations:n})=>{let r=i.has(String(t.id)),a=n.filter(t=>IU(t,e)),c=a.length,l=a.some(e=>e.extruder_id!==void 0&&e.extruder_id!==null&&e.extruder_id>0),u=a.filter(e=>e.extruder_id===1),f=a.filter(e=>e.extruder_id===0||e.extruder_id===void 0||e.extruder_id===null);return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(String(t.id)),className:`w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`font-medium text-white`,children:t.name}),c>0?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green`,children:[c,` `,o(c===1?`inventory.match`:`inventory.matches`)]}):(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray`,children:o(`inventory.noMatches`)})]}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-1 rounded-full ${t.connected?`bg-green-500/20 text-green-500`:`bg-bambu-gray/20 text-bambu-gray`}`,children:t.connected?o(`inventory.connected`):o(`inventory.offline`)})]}),r&&(0,K.jsx)(`div`,{className:`px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary`,children:t.connected?c===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:o(`inventory.noKProfilesMatch`)}):l?(0,K.jsxs)(K.Fragment,{children:[u.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.leftNozzle`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>d(t,e))})]}),f.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.rightNozzle`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:f.map(e=>d(t,e))})]})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>d(t,e))}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:o(`inventory.printerOffline`)})})]},t.id)})}),n.size>0&&(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:n.size}),` `,o(`inventory.profilesSelected`)]})})]})}function $Xe(e){let t=vf(e);return t?t.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`2-digit`,year:`2-digit`})+` `+t.toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):``}var eZe={completed:`text-bambu-green`,failed:`text-red-400`,aborted:`text-yellow-400`};function tZe({spoolId:e}){let{t}=W(),n=no(),{showToast:r}=Td(),{data:i,isLoading:a}=q({queryKey:[`spool-usage`,e],queryFn:()=>Q.getSpoolUsageHistory(e)}),o=J({mutationFn:()=>Q.clearSpoolUsageHistory(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`spool-usage`,e]}),r(t(`inventory.historyCleared`),`success`)}});return a?(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 animate-spin text-bambu-green`})}):!i||i.length===0?(0,K.jsxs)(`div`,{className:`text-center py-4 text-bambu-gray text-sm`,children:[(0,K.jsx)(Ss,{className:`w-5 h-5 mx-auto mb-2 opacity-50`}),t(`inventory.noUsageHistory`)]}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t(`inventory.usageHistory`)}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>o.mutate(),disabled:o.isPending,className:`text-xs text-bambu-gray hover:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-3 h-3 mr-1`}),t(`inventory.clearHistory`)]})]}),(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:i.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:$Xe(e.created_at)}),e.print_name&&(0,K.jsx)(`span`,{className:`text-white ml-2 truncate`,title:e.print_name,children:e.print_name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0 ml-2`,children:[(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[e.weight_used.toFixed(1),`g`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_used,`%)`]}),(0,K.jsx)(`span`,{className:eZe[e.status]||`text-bambu-gray`,children:e.status})]})]},e.id))})]})}var y9=[`inventory-locations`];function b9(e){return e.invalidateQueries({queryKey:y9})}function x9(e,t){return Promise.all([e.invalidateQueries({queryKey:[...t]}),b9(e)])}var S9={tag_uid:null,tray_uuid:null,tag_type:null,data_origin:null};function nZe({isOpen:e,onClose:t,spool:n,mode:r,printersWithCalibrations:i=[],currencySymbol:a,onSpoolsCreated:o,spoolmanMode:s=!1,spoolsQueryKey:c=[`inventory-spools`]}){let{t:l}=W(),u=no(),{showToast:d}=Td(),f=()=>x9(u,c),p=r===`edit`,m=r===`copy`,[h,g]=(0,y.useState)(p9),[_,v]=(0,y.useState)({}),[b,x]=(0,y.useState)(`filament`),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)([]),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)([]),[B,V]=(0,y.useState)([]),[ee,te]=(0,y.useState)([]),[ne,re]=(0,y.useState)([]),[ie,H]=(0,y.useState)([]),[ae,oe]=(0,y.useState)([]),[U,se]=(0,y.useState)([]),[ce,le]=(0,y.useState)(new Set),[ue,de]=(0,y.useState)(new Set),fe=i.length>0?i:U,pe=ce.size,{data:me=[],isLoading:he,error:ge}=q({queryKey:[`spoolman-inventory-filaments`],queryFn:()=>Q.getSpoolmanInventoryFilaments(),enabled:s&&e,staleTime:6e4,retry:!1});(0,y.useEffect)(()=>{oe(MU())},[]),(0,y.useEffect)(()=>{let t=!1;return e&&((async()=>{N(!0);try{let[e,n]=await Promise.allSettled([(async()=>(await Q.getCloudStatus()).is_authenticated?{connected:!0,presets:await Q.getFilamentPresets()}:{connected:!1,presets:[]})(),(async()=>(await Q.orcaCloudStatus()).connected?{connected:!0,presets:(await Q.orcaCloudListProfiles()).filament}:{connected:!1,presets:[]})()]);if(t)return;let r=e.status===`fulfilled`&&e.value.connected,i=n.status===`fulfilled`&&n.value.connected,a=e.status===`fulfilled`?e.value.presets:[],o=n.status===`fulfilled`?n.value.presets:[];j(r||i),F([...a,...o])}catch(e){if(t)return;console.error(`Failed to fetch cloud presets:`,e),j(!1)}finally{t||N(!1)}})(),s||Q.getSpoolCatalog().then(z).catch(console.error),Q.getColorCatalog().then(H).catch(console.error),Q.getLocalPresets().then(e=>te(e.filament)).catch(console.error),Q.getBuiltinFilaments().then(re).catch(console.error),Q.getLocations().then(e=>V(e.map(e=>({id:e.id,name:e.name})))).catch(console.error),i.length===0&&(async()=>{try{let e=await Q.getPrinters(),t=await Promise.all(e.map(e=>Q.getPrinterStatus(e.id).catch(()=>null))),n=[];for(let r=0;r({cali_idx:e.slot_id,filament_id:e.filament_id,setting_id:e.setting_id||``,name:e.name,k_value:parseFloat(e.k_value)||0,n_coef:parseFloat(e.n_coef)||0,extruder_id:e.extruder_id,nozzle_diameter:e.nozzle_diameter}))}catch{}n.push({printer:{...i,connected:a},calibrations:o})}se(n)}catch(e){console.error(`Failed to fetch printer calibrations:`,e)}})()),()=>{t=!0}},[e,i.length]);let _e=(0,y.useMemo)(()=>AU(P,new Set,ee,ne),[P,ee,ne]),ve=(0,y.useMemo)(()=>{let e=kU(P,ee),t=ie.map(e=>e.manufacturer?.trim()).filter(e=>!!e),n=new Set([...e,...t]);return Array.from(n).sort((e,t)=>e.localeCompare(t))},[P,ee,ie]),ye=(0,y.useMemo)(()=>{let e=ie.map(e=>e.material?.trim()).filter(e=>!!e),t=new Set([...SU,...e]);return Array.from(t).sort((e,t)=>e.localeCompare(t))},[ie]),be=(0,y.useMemo)(()=>{let e=[];for(let t of ie){let n=t.manufacturer?.trim(),r=t.material?.trim();n&&r&&e.push({brand:n,material:r})}for(let t of P){let n=OU(t.name);n.brand&&n.material&&e.push({brand:n.brand,material:n.material})}for(let t of ee){let n=OU(t.name),r=t.filament_vendor?.trim()||n.brand,i=n.material;r&&i&&e.push({brand:r,material:i})}return e},[P,ie,ee]),xe=(0,y.useMemo)(()=>{let e=new Map;for(let t of be){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(n)||e.set(n,new Set),e.get(n).add(r)}return e},[be]),Se=(0,y.useMemo)(()=>{let e=new Map;for(let t of be){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(r)||e.set(r,new Set),e.get(r).add(n)}return e},[be]),Ce=(0,y.useMemo)(()=>{if(!h.material)return ve;let e=h.material.toLowerCase(),t=Se.get(e);return!t||t.size===0?ve:ve.filter(e=>t.has(e.toLowerCase()))},[ve,h.material,Se]),we=(0,y.useMemo)(()=>{if(!h.brand)return ye;let e=h.brand.toLowerCase(),t=xe.get(e);return!t||t.size===0?ye:ye.filter(e=>t.has(e.toLowerCase()))},[ye,h.brand,xe]),Te=(0,y.useMemo)(()=>jU(h.slicer_filament,_e),[h.slicer_filament,_e]);(0,y.useEffect)(()=>{if(e){if(n){let e=n.rgba&&/^[0-9A-Fa-f]{8}$/.test(n.rgba)?n.rgba:`808080FF`;if(g({material:n.material||``,subtype:n.subtype||``,brand:n.brand||``,color_name:n.color_name_is_synthesized?``:n.color_name||``,rgba:e,extra_colors:n.extra_colors||``,effect_type:n.effect_type||``,label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:m?0:n.weight_used||0,slicer_filament:n.slicer_filament||``,note:n.note||``,cost_per_kg:n.cost_per_kg??null,category:n.category||``,low_stock_threshold_pct:n.low_stock_threshold_pct??null,location_id:n.location_id??null,spoolman_filament_id:null}),L(n.slicer_filament_name||n.slicer_filament||``),n.k_profiles&&n.k_profiles.length>0){let e=new Set;for(let t of n.k_profiles)t.cali_idx!==null&&t.cali_idx!==void 0&&e.add(`${t.printer_id}:${t.cali_idx}:${t.extruder??`null`}`);le(e)}else le(new Set)}else g(p9),L(``),le(new Set),D(!1),k(1);v({}),x(`filament`),C(!1),T(!1)}},[e,n,r,m]),(0,y.useEffect)(()=>{if(!e||!n||w||h.location_id!=null)return;let t=n.storage_location?.trim();if(!t||B.length===0)return;let r=B.find(e=>e.name.toLowerCase()===t.toLowerCase());r&&g(e=>e.location_id===r.id?e:{...e,location_id:r.id})},[e,n,B,h.location_id,w]),(0,y.useEffect)(()=>{e&&fe.length>0&&de(new Set(fe.map(e=>String(e.printer.id))))},[e,fe]);let Ee=(e,t)=>{let n=YXe.has(e);s&&n&&h.spoolman_filament_id!==null&&d(l(`inventory.spoolmanFilamentUnlinked`),`info`),g(r=>({...r,[e]:t,...s&&n&&r.spoolman_filament_id!==null?{spoolman_filament_id:null}:{}})),e===`weight_used`&&C(!0),e===`location_id`&&T(!0),_[e]&&v(t=>({...t,[e]:void 0}))},De=e=>{let t=e.material||``,n=e.name||``,r=t&&n.startsWith(t)?n.slice(t.length).trim():n,i=(e.color_hex??``).replace(`#`,``).toUpperCase(),a=/^[0-9A-F]{6}$/.test(i)?i:`808080`;g(n=>({...n,spoolman_filament_id:e.id,material:t,subtype:r,brand:e.vendor?.name||``,rgba:`${a}FF`,color_name:e.color_name||``,label_weight:e.weight??n.label_weight})),d(l(`inventory.spoolmanFilamentSelected`),`success`)},Oe=e=>{oe(t=>NU(e,t))},ke=J({mutationFn:e=>s?Q.createSpoolmanInventorySpool(e):Q.createSpool(e),onSuccess:async e=>{e?.id&&!await Ve(e.id)||(await f(),o&&o([e]),d(l(`inventory.spoolCreated`),`success`),t())},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),Ae=J({mutationFn:({data:e,qty:t})=>s?Q.bulkCreateSpoolmanInventorySpools(e,t):Q.bulkCreateSpools(e,t),onSuccess:async e=>{let n=s&&`created`in e?e:null,r=n?n.created:e;if(ce.size>0)for(let e of r)await Ve(e.id);await f(),o&&o(r),n&&n.failed_count>0?d(l(`inventory.spoolsPartiallyCreated`,{created:r.length,total:n.requested_count}),`warning`):d(l(`inventory.spoolsCreated`,{count:r.length}),`success`),t()},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),je=J({mutationFn:e=>s?Q.updateSpoolmanInventorySpool(n.id,e):Q.updateSpool(n.id,e),onSuccess:async()=>{n?.id&&!await Ve(n.id)||(await f(),d(l(`inventory.spoolUpdated`),`success`),t())},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),Me=J({mutationFn:()=>s?Q.updateSpoolmanInventorySpool(n.id,S9):Q.updateSpool(n.id,S9),onSuccess:async()=>{await f(),d(l(`inventory.rfidCleared`,`RFID tag cleared`),`success`),t()},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.tagClearFailed`),`error`)}}),{data:Ne}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:e&&p&&!s}),{data:Pe}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e&&p&&s}),Fe=(()=>{if(n)return s?Pe?.find(e=>e.spoolman_spool_id===n.id):Ne?.find(e=>e.spool_id===n.id)})(),{data:Ie}=q({queryKey:[`inventory-spools`],queryFn:()=>Q.getSpools(!0),enabled:e}),{data:Le}=q({queryKey:[`settings`],queryFn:Q.getSettings,enabled:e}),Re=(()=>{let e=new Set;for(let t of Ie??[]){let n=t.category?.trim();n&&e.add(n)}return Array.from(e).sort((e,t)=>e.localeCompare(t))})(),ze=Le?.low_stock_threshold??20,Be=J({mutationFn:async()=>{if(!Fe)throw Error(`No assignment`);if(s){if(!n)throw Error(`No spool`);await Q.unassignSpoolmanSlot(n.id);return}await Q.unassignSpool(Fe.printer_id,Fe.ams_id,Fe.tray_id)},onSuccess:async()=>{s?(await u.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),await u.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})):await u.invalidateQueries({queryKey:[`spool-assignments`]}),d(l(`inventory.unassignSuccess`,`Spool unassigned`),`success`),t()},onError:e=>{d(e.message,`error`)}}),Ve=async e=>{let t=s?Q.saveSpoolmanKProfiles:Q.saveSpoolKProfiles;if(ce.size===0)try{return await t(e,[]),!0}catch(e){return console.error(`Failed to save K-profiles:`,e),d(l(`inventory.kProfileSaveFailed`),`warning`),!1}let n=[],r=0;for(let e of ce){let[t,i,a]=e.split(`:`),o=parseInt(t),s=parseInt(i),c=a===`null`?0:parseInt(a),l=fe.find(e=>e.printer.id===o);if(l){let e=l.calibrations.find(e=>e.cali_idx===s);e?n.push({printer_id:o,extruder:c,nozzle_diameter:e.nozzle_diameter||`0.4`,k_value:e.k_value,name:e.name||null,cali_idx:e.cali_idx,setting_id:e.setting_id||null}):r++}else r++}if(r>0)return console.error(`saveKProfiles: ${r} profile key(s) could not be resolved`,Array.from(ce)),d(l(`inventory.kProfileSaveFailed`),`warning`),!1;if(n.length>0)try{return await t(e,n),!0}catch(e){return console.error(`Failed to save K-profiles:`,e),d(l(`inventory.kProfileSaveFailed`),`warning`),!1}return!0};if((0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let He=()=>{let e=m9(h,E,s);if(!e.isValid){v(e.errors),(e.errors.slicer_filament||e.errors.material||e.errors.brand||e.errors.subtype)&&x(`filament`);return}let t=Te?.displayName||I||null,n={material:h.material||null,subtype:h.subtype||null,brand:h.brand||null,color_name:h.color_name||null,rgba:h.rgba||null,extra_colors:h.extra_colors||null,effect_type:h.effect_type||null,label_weight:h.label_weight,...s?{}:{core_weight:h.core_weight,core_weight_catalog_id:h.core_weight_catalog_id},slicer_filament:h.slicer_filament||null,slicer_filament_name:t,nozzle_temp_min:null,nozzle_temp_max:null,note:h.note||null,cost_per_kg:h.cost_per_kg,category:h.category.trim()||null,low_stock_threshold_pct:h.low_stock_threshold_pct,...s?{spoolman_filament_id:h.spoolman_filament_id}:{}};(!p||S)&&(n.weight_used=h.weight_used),(!p||w)&&(n.location_id=h.location_id),p?je.mutate(n):O>1?Ae.mutate({data:n,qty:O}):ke.mutate(n)},Ue=ke.isPending||Ae.isPending||je.isPending||Me.isPending||Be.isPending;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-baseline gap-2`,children:[l(p?`inventory.editSpool`:m?`inventory.copySpool`:`inventory.addSpool`),p&&n&&(0,K.jsxs)(`span`,{className:`text-sm font-mono text-bambu-gray`,children:[`#`,n.id]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),r===`create`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-amber-400`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:l(`inventory.quickAdd`)})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{D(!E),E||x(`filament`)},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${E?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${E?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`button`,{onClick:()=>x(`filament`),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${b===`filament`?`text-bambu-green border-b-2 border-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(ml,{className:`w-4 h-4`}),l(`inventory.filamentInfoTab`)]}),!E&&(0,K.jsxs)(`button`,{onClick:()=>x(`pa-profile`),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${b===`pa-profile`?`text-bambu-green border-b-2 border-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ro,{className:`w-4 h-4`}),l(`inventory.paProfileTab`),pe>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green`,children:pe})]})]}),(0,K.jsx)(`div`,{className:`p-4 overflow-y-auto flex-1`,style:{scrollbarGutter:`stable`},children:b===`filament`?(0,K.jsxs)(`div`,{className:`space-y-6`,children:[s&&!p&&(0,K.jsx)(`div`,{children:ge?(0,K.jsx)(`p`,{className:`text-sm text-red-400 px-1`,children:l(`inventory.spoolmanCatalogLoadFailed`)}):(0,K.jsx)(QXe,{filaments:me,isLoading:he,selectedId:h.spoolman_filament_id,onSelect:De})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.filamentInfo`)}),(0,K.jsx)(h9,{formData:h,updateField:Ee,cloudAuthenticated:A,loadingCloudPresets:M,presetInputValue:I,setPresetInputValue:L,selectedPresetOption:Te,filamentOptions:_e,availableBrands:Ce,availableMaterials:we,quickAdd:E,quantity:O,onQuantityChange:k,errors:_})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.color`)}),(0,K.jsx)(g9,{formData:h,updateField:Ee,recentColors:ae,onColorUsed:Oe,catalogColors:ie})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.additional`)}),(0,K.jsx)(_9,{formData:h,updateField:Ee,spoolCatalog:R,currencySymbol:a,availableCategories:Re,availableLocations:B,onCreateLocation:async e=>{try{let t=await Q.createLocation({name:e});return V(e=>[...e,{id:t.id,name:t.name}].sort((e,t)=>e.name.localeCompare(t.name))),await b9(u),{id:t.id,name:t.name}}catch(e){return console.error(e),d((e instanceof Error?e.message:l(`locations.saveFailed`))||l(`locations.saveFailed`),`error`),null}},globalLowStockThreshold:ze,spoolmanMode:s})]}),p&&n&&!s&&(0,K.jsx)(`div`,{children:(0,K.jsx)(tZe,{spoolId:n.id})})]}):(0,K.jsx)(v9,{formData:h,updateField:Ee,printersWithCalibrations:fe,selectedProfiles:ce,setSelectedProfiles:le,expandedPrinters:ue,setExpandedPrinters:de})}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:[p&&(0,K.jsxs)(`div`,{className:`flex gap-2 mr-auto`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Me.mutate(),disabled:Ue||!n?.tag_uid,children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),l(`inventory.clearRfid`,`Clear RFID Tag`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Be.mutate(),disabled:Ue||!Fe,children:[(0,K.jsx)(Eu,{className:`w-4 h-4`}),l(`inventory.unassignSpool`,`Unassign`)]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 ml-auto`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:l(`common.cancel`)}),(0,K.jsx)($,{onClick:He,disabled:Ue,children:Ue?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),l(`common.saving`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),l(p?`common.save`:m?`inventory.copySpool`:`inventory.addSpool`)]})})]})]})]})]})}function rZe({isOpen:e,onClose:t,columns:n,defaultColumns:r,onSave:i}){let{t:a}=W(),[o,s]=(0,y.useState)(n),[c,l]=(0,y.useState)(null),u=(0,y.useRef)(null);if((0,y.useEffect)(()=>{e&&s(n.map(e=>({...e})))},[e,n]),(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let d=e=>{s(t=>t.map((t,n)=>n===e?{...t,visible:!t.visible}:t))},f=(e,t)=>{t<0||t>=o.length||s(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},p=(e,t)=>{u.current=t,l(t),e.dataTransfer.effectAllowed=`move`},m=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=u.current;n!==null&&n!==t&&(f(n,t),u.current=t,l(t))},h=e=>{e.preventDefault()},g=()=>{u.current=null,l(null)},_=()=>{s(r.map(e=>({...e})))},v=()=>{i(o),t()},b=o.filter(e=>e.visible).length;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsx)(_d,{className:`w-full max-w-md max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6 flex flex-col min-h-0`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:a(`inventory.configureColumns`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:[a(`inventory.configureColumnsDesc`),(0,K.jsxs)(`span`,{className:`ml-2 text-bambu-gray/60`,children:[`(`,b,` `,a(`inventory.of`),` `,o.length,` `,a(`inventory.visible`),`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-1 overflow-y-auto flex-1 min-h-0 pr-1`,children:o.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-tertiary/50`} ${e.visible?``:`opacity-50`}`,draggable:!0,onDragStart:e=>p(e,t),onDragOver:e=>m(e,t),onDrop:h,onDragEnd:g,children:[(0,K.jsx)(`div`,{className:`cursor-grab text-bambu-gray/50 hover:text-bambu-gray`,children:(0,K.jsx)(xc,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`flex-1 font-medium text-sm text-white`,children:e.label}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(`button`,{onClick:()=>f(t,t-1),disabled:t===0,className:`p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed`,title:a(`inventory.moveUp`),children:(0,K.jsx)(cs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>f(t,t+1),disabled:t===o.length-1,className:`p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed`,title:a(`inventory.moveDown`),children:(0,K.jsx)(is,{className:`w-4 h-4`})})]}),(0,K.jsx)(`button`,{onClick:()=>d(t),className:`p-1.5 rounded transition-colors ${e.visible?`text-bambu-green hover:bg-bambu-green/10`:`text-bambu-gray/50 hover:bg-bambu-dark-secondary`}`,title:e.visible?a(`inventory.hideColumn`):a(`inventory.showColumn`),children:e.visible?(0,K.jsx)(Xs,{className:`w-4 h-4`}):(0,K.jsx)(Ys,{className:`w-4 h-4`})})]},e.id))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:_,className:`mr-auto`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),a(`inventory.reset`)]}),(0,K.jsx)($,{variant:`secondary`,onClick:t,children:a(`inventory.cancel`)}),(0,K.jsx)($,{onClick:v,children:a(`inventory.applyChanges`)})]})]})})})}var iZe=[{value:`ams_holder_74x33`,i18nKey:`amsHolderSmall`,fallbackLabel:`AMS holder — small (74 × 33 mm)`,fallbackHint:`Single label per page; matches the printable label from MakerWorld model 752566 (AMS Filament Label Holder).`},{value:`ams_holder_75x55`,i18nKey:`amsHolderLarge`,fallbackLabel:`AMS holder — large (75 × 55 mm)`,fallbackHint:`Single label per page; fits the cardstock-insert variant of the AMS Filament Label Holder. Roomy enough for swatch, brand, material, ID, and QR code.`},{value:`box_40x30`,i18nKey:`box40x30`,fallbackLabel:`Box label (40 × 30 mm)`,fallbackHint:`Single label per page; common DK/Brother roll size, good for filament-bag and storage-bin labels.`},{value:`box_62x29`,i18nKey:`box`,fallbackLabel:`Box label (62 × 29 mm)`,fallbackHint:`Single label per page; sized for Brother PT/QL and Dymo small labels.`},{value:`avery_l7160`,i18nKey:`averyL7160`,fallbackLabel:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,fallbackHint:`EU sheet stock; 21 labels per A4 page.`},{value:`avery_5160`,i18nKey:`avery5160`,fallbackLabel:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,fallbackHint:`US sheet stock; 30 labels per Letter page.`}];function aZe(e){let t=window.URL.createObjectURL(e);if(!window.open(t,`_blank`)){let e=document.createElement(`a`);e.href=t,e.download=`bambuddy-labels.pdf`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}setTimeout(()=>window.URL.revokeObjectURL(t),6e4)}function oZe(e){return Jd(e)}function sZe(e){return`${e.color_name??`${e.material}${e.subtype?` ${e.subtype}`:``}`}${e.brand?` · ${e.brand}`:``}`}function cZe(e){return[e.color_name,e.material,e.subtype,e.brand,`#${e.id}`].filter(Boolean).join(` `).toLowerCase()}function C9(e){if(!e)return[1,0];let t=e.replace(/^#/,``).slice(0,6);if(t.length!==6)return[1,0];let n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);if([n,r,i].some(Number.isNaN))return[1,0];let a=n/255,o=r/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=(c+l)/2,d=c-l;if((d===0?0:d/(1-Math.abs(2*u-1)))<.1)return[1,u];let f=0;return f=c===a?(o-s)/d%6:c===o?(s-a)/d+2:(a-o)/d+4,f*=60,f<0&&(f+=360),[0,f]}function lZe({isOpen:e,onClose:t,availableSpools:n,initialSelectedIds:r,spoolmanMode:i}){let{t:a}=W(),{showToast:o}=Td(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(new Set),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(`id`);(0,y.useEffect)(()=>{if(e){let e=new Set(n.map(e=>e.id));u(new Set(r.filter(t=>e.has(t)))),f(``),m(``),g(`id`),c(null)}},[e]);let _=(0,y.useMemo)(()=>{let e=[...n];return h===`color`?(e.sort((e,t)=>{let n=C9(e.rgba),r=C9(t.rgba);return n[0]===r[0]?n[1]===r[1]?e.id-t.id:n[1]-r[1]:n[0]-r[0]}),e):(e.sort((e,t)=>e.id-t.id),e)},[n,h]),v=(0,y.useMemo)(()=>{let e=new Set;for(let t of _)t.material&&e.add(t.material.toUpperCase());return[...e].sort()},[_]),b=(0,y.useMemo)(()=>{let e=d.trim().toLowerCase();return _.filter(t=>!(p&&(t.material||``).toUpperCase()!==p||e&&!cZe(t).includes(e)))},[_,d,p]),x=b.length>0&&b.every(e=>l.has(e.id));if(!e)return null;let S=l.size,C=S===0;function w(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function T(){u(e=>{let t=new Set(e);for(let e of b)t.add(e.id);return t})}function E(){u(e=>{let t=new Set(e);for(let e of b)t.delete(e.id);return t})}function D(){u(new Set)}async function O(e){if(C||s)return;let n=_.filter(e=>l.has(e.id)).map(e=>e.id);c(e);try{aZe(i?await Q.printSpoolmanSpoolLabels({spool_ids:n,template:e}):await Q.printSpoolLabels({spool_ids:n,template:e})),t()}catch(e){o(a(`inventory.labels.error`,`Could not generate labels: {{msg}}`,{msg:e instanceof Error?e.message:String(e)}),`error`)}finally{c(null)}}return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start sm:items-center justify-center p-4 overflow-y-auto`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-3xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] overflow-hidden flex flex-col my-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(`inventory.labels.title`,`Print spool labels`)}),S>0&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,a(`inventory.labels.selectedCount`,`{{count}} selected`,{count:S}),`)`]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,"aria-label":a(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-2 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:a(`inventory.labels.searchPlaceholder`,`Search name, brand, or #ID`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),v.length>1&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:a(`inventory.labels.filterByMaterial`,`Material:`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>m(``),className:`px-2 py-0.5 text-xs rounded-full border transition ${p===``?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.allMaterials`,`All`)}),v.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`px-2 py-0.5 text-xs rounded-full border transition ${p===e?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:e},e))]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:a(`inventory.labels.sortBy.label`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(`id`),className:`px-2 py-0.5 text-xs rounded-full border transition ${h===`id`?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.sortBy.id`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(`color`),className:`px-2 py-0.5 text-xs rounded-full border transition ${h===`color`?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.sortBy.color`)})]})]}),(0,K.jsxs)(`div`,{className:`px-4 pt-3 pb-2 flex items-center justify-between gap-3 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`inventory.labels.pickSpools`,`Pick which spools to print labels for:`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:x?E:T,disabled:b.length===0,className:`text-bambu-green hover:underline disabled:opacity-50 disabled:no-underline disabled:cursor-not-allowed`,children:x?a(`inventory.labels.deselectVisible`,`Deselect visible`):a(`inventory.labels.selectVisible`,`Select all visible ({{count}})`,{count:b.length})}),(0,K.jsx)(`button`,{type:`button`,onClick:D,disabled:S===0,className:`text-bambu-gray hover:text-white hover:underline disabled:opacity-50 disabled:no-underline disabled:cursor-not-allowed`,children:a(`inventory.labels.clearAll`,`Clear all`)})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-2 pb-2 min-h-0`,children:b.length===0?(0,K.jsx)(`div`,{className:`text-center text-sm text-bambu-gray py-6`,children:_.length===0?a(`inventory.labels.noSpoolsToShow`,`No spools to show. Adjust your filter and try again.`):a(`inventory.labels.noMatches`,`No spools match the current search or filter.`)}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:b.map(e=>{let t=l.has(e.id);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary/50 cursor-pointer`,children:[t?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green shrink-0`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>w(e.id),className:`sr-only`}),(0,K.jsx)(`span`,{className:`w-4 h-4 rounded border border-black/20 shrink-0`,style:oZe(e.rgba)}),(0,K.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-sm text-white`,children:sZe(e)}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray shrink-0`,children:[`#`,e.id]})]})},e.id)})})}),(0,K.jsx)(`div`,{className:`px-3 pt-2 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-2 border-t border-bambu-dark-tertiary`,children:iZe.map(e=>{let t=s===e.value,n=a(`inventory.labels.templates.${e.i18nKey}.label`,e.fallbackLabel),r=a(`inventory.labels.templates.${e.i18nKey}.hint`,e.fallbackHint);return(0,K.jsxs)(`button`,{disabled:C||s!==null,onClick:()=>O(e.value),title:`${n} — ${r}`,className:`w-full text-left p-2.5 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-green hover:bg-bambu-green/10 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-bambu-dark-tertiary disabled:hover:bg-bambu-dark transition flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-medium text-white text-sm truncate`,children:n}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-0.5 truncate`,children:r})]}),t&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-green shrink-0`})]},e.value)})}),(0,K.jsx)(`div`,{className:`flex justify-end gap-2 px-5 py-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,disabled:s!==null,children:a(`common.cancel`,`Cancel`)})})]})]})}function uZe({onClose:e,onImported:t}){let{t:n}=W(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),h=(0,y.useRef)(null),g=async e=>{i(e),c(null),m(null),u(!0);try{c(await Q.importSpoolsCsvPreview(e))}catch(e){m(e instanceof Error?e.message:n(`inventory.csv.previewError`,`Could not read the CSV file`))}finally{u(!1)}},_=e=>{let t=e.target.files?.[0];t&&g(t)},v=e=>{e.preventDefault(),o(!1);let t=e.dataTransfer.files?.[0];t&&g(t)},b=async()=>{if(r){f(!0),m(null);try{t((await Q.importSpoolsCsv(r)).created)}catch(e){m(e instanceof Error?e.message:n(`inventory.csv.importError`,`Import failed`)),f(!1)}}},x=e=>e===`valid`?(0,K.jsx)(ps,{className:`w-4 h-4 text-green-500 flex-shrink-0`}):e===`error`?(0,K.jsx)(ys,{className:`w-4 h-4 text-red-500 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),S=s?.valid_count??0;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-3xl border border-bambu-dark-tertiary flex flex-col max-h-[90vh]`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`inventory.csv.modalTitle`,`Import spools from CSV`)}),(0,K.jsx)(`button`,{onClick:e,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:e=>{e.preventDefault(),o(!1)},onDrop:v,onClick:()=>h.current?.click(),className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${a?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Du,{className:`w-9 h-9 mx-auto mb-2 ${a?`text-bambu-green`:`text-bambu-gray`}`}),r?(0,K.jsxs)(`p`,{className:`text-white font-medium flex items-center justify-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),` `,r.name]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.csv.selectFile`,`Choose a CSV file or drag it here`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:n(`inventory.csv.dragHint`,`Header: material (required), brand, subtype, color_name, rgba, …`)})]})]}),(0,K.jsx)(`input`,{ref:h,type:`file`,accept:`.csv,text/csv`,className:`hidden`,onChange:_}),l&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-bambu-gray py-4`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`inventory.csv.parsing`,`Reading file…`)]}),p&&(0,K.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg flex items-start gap-3`,children:[(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-sm text-red-300 break-words`,children:p})]}),s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-green-500/10 text-green-400`,children:n(`inventory.csv.validCount`,`{{count}} valid`,{count:s.valid_count})}),(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-red-500/10 text-red-400`,children:n(`inventory.csv.errorCount`,`{{count}} error`,{count:s.error_count})}),(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-bambu-dark text-bambu-gray`,children:n(`inventory.csv.skippedCount`,`{{count}} skipped`,{count:s.skipped_count})})]}),s.warnings.length>0&&(0,K.jsx)(`div`,{className:`p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg space-y-1`,children:s.warnings.map((e,t)=>(0,K.jsx)(`p`,{className:`text-xs text-yellow-300`,children:e},t))}),s.rows.length>0&&(0,K.jsx)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:(0,K.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{className:`text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colRow`,`Row`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colStatus`,`Status`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.material`,`Material`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.brand`,`Brand`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colColor`,`Color`)})]})}),(0,K.jsx)(`tbody`,{children:s.rows.map(e=>(0,K.jsxs)(`tr`,{className:`border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`td`,{className:`px-3 py-2 text-bambu-gray`,children:e.row_number}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[x(e.status),e.status===`error`&&e.reason&&(0,K.jsx)(`span`,{className:`text-xs text-red-400 break-words`,children:e.reason})]})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:e.material||`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:e.brand||`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`inline-block w-4 h-4 rounded-full border border-bambu-dark-tertiary flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.color_name||`—`}),e.resolved_color&&!e.cross_material_color&&(0,K.jsx)(`span`,{title:n(`inventory.csv.colorResolved`,`Color filled from catalog`),children:(0,K.jsx)(Mu,{className:`w-3.5 h-3.5 text-bambu-green flex-shrink-0`})}),e.cross_material_color&&(0,K.jsx)(`span`,{title:n(`inventory.csv.colorCrossMaterial`,`Color taken from a different material — no exact match in catalog`),children:(0,K.jsx)(Cu,{className:`w-3.5 h-3.5 text-yellow-500 flex-shrink-0`})}),e.duplicate_of_existing&&(0,K.jsx)(`span`,{title:n(`inventory.csv.duplicateExisting`,`A spool with this material, brand and color already exists — it will still be imported as a new spool`),children:(0,K.jsx)(Ms,{className:`w-3.5 h-3.5 text-amber-400 flex-shrink-0`})})]})})]},e.row_number))})]})})})]})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:d,children:n(`common.cancel`)}),(0,K.jsx)($,{onClick:b,disabled:!s||S===0||d,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),n(`inventory.csv.importing`,`Importing…`)]}):S>0?n(`inventory.csv.importValidRows`,`Import {{count}} valid rows`,{count:S}):n(`inventory.csv.noValidRows`,`No valid rows`)})]})]})})}function dZe({open:e,onClose:t,onPickLocation:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),{data:m=[],isLoading:h}=q({queryKey:y9,queryFn:Q.getLocations,enabled:e}),g=()=>{b9(i),i.invalidateQueries({queryKey:[`inventory-spools`]}),i.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},_=J({mutationFn:async()=>{let e=u.trim();if(!e)throw Error(r(`locations.nameRequired`));return c?Q.updateLocation(c.id,{name:e}):Q.createLocation({name:e})},onSuccess:()=>{a(r(c?`locations.updated`:`locations.created`),`success`),s(!1),l(null),d(``),g()},onError:e=>{a(e.message||r(`locations.saveFailed`),`error`)}}),v=J({mutationFn:e=>Q.deleteLocation(e),onSuccess:()=>{a(r(`locations.deleted`),`success`),p(null),g()},onError:e=>{a(e.message||r(`locations.deleteFailed`),`error`)}}),b=()=>{l(null),d(``),s(!0)},x=e=>{l(e),d(e.name),s(!0)},S=(0,y.useCallback)(()=>{_.isPending||(s(!1),l(null),d(``))},[_.isPending]);(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(_.isPending||v.isPending||(o?S():f||t()))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,o,f,_.isPending,v.isPending,S,t]);let C=e=>{e.preventDefault(),_.mutate()};if(!e)return null;let w=`locations-modal-title`,T=`location-editor-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>{_.isPending||v.isPending||t()}}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-2xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":w,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{id:w,className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Zc,{className:`w-5 h-5 text-bambu-green`}),r(`locations.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-0.5`,children:r(`locations.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:b,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`locations.add`)]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:t,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin mr-2`}),r(`common.loading`)]}):m.length===0?(0,K.jsx)(`div`,{className:`py-16 text-center text-bambu-gray`,children:r(`locations.empty`)}):(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:r(`locations.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right`,children:r(`locations.spools`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right w-32`,children:r(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:m.map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 hover:bg-bambu-dark-tertiary/30 cursor-pointer`,onClick:()=>{n&&(n(e.id),t())},children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white font-medium`,children:e.name}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right text-bambu-gray`,children:e.spool_count}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded`,onClick:()=>x(e),title:r(`common.edit`),"aria-label":r(`locations.editAria`,{name:e.name,defaultValue:`Edit ${e.name}`}),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded disabled:opacity-40`,disabled:e.spool_count>0,onClick:()=>p(e),title:e.spool_count>0?r(`locations.deleteBlocked`):r(`common.delete`),"aria-label":r(`locations.deleteAria`,{name:e.name,defaultValue:`Delete ${e.name}`}),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},e.id))})]})})]}),o&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:S}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 shadow-2xl`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":T,children:[(0,K.jsx)(`h3`,{id:T,className:`text-lg font-semibold text-white mb-4`,children:r(c?`locations.edit`:`locations.add`)}),(0,K.jsxs)(`form`,{onSubmit:C,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`location-name`,children:r(`locations.name`)}),(0,K.jsx)(`input`,{id:`location-name`,type:`text`,maxLength:255,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green mb-4`,placeholder:r(`locations.createPlaceholder`),value:u,onChange:e=>d(e.target.value),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:S,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:_.isPending||!u.trim(),children:[_.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.save`)]})]})]})]})]}),f&&(0,K.jsx)(Ad,{title:r(`locations.confirmDelete`,{name:f.name}),message:r(`locations.confirmDeleteMessage`),confirmText:r(`common.delete`),variant:`danger`,isLoading:v.isPending,onConfirm:()=>v.mutate(f.id),onCancel:()=>p(null)})]})}var w9=[{id:`material`,type:`searchable`,labelKey:`inventory.material`},{id:`subtype`,type:`searchable`,labelKey:`inventory.subtype`},{id:`brand`,type:`searchable`,labelKey:`inventory.brand`},{id:`color_name`,type:`text`,labelKey:`inventory.colorName`},{id:`rgba`,type:`color`,labelKey:`inventory.color`,pattern:`^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$`},{id:`location_id`,type:`searchableClosed`,labelKey:`inventory.storageLocation`},{id:`slicer_filament_name`,type:`searchable`,labelKey:`inventory.slicerFilamentName`},{id:`slicer_filament`,type:`searchable`,labelKey:`inventory.slicerFilament`},{id:`cost_per_kg`,type:`number`,labelKey:`inventory.costPerKg`,min:0,step:.01},{id:`note`,type:`textarea`,labelKey:`inventory.note`},{id:`label_weight`,type:`number`,labelKey:`inventory.labelWeight`,min:1,step:1},{id:`core_weight`,type:`number`,labelKey:`inventory.coreWeight`,min:0,step:1},{id:`category`,type:`searchable`,labelKey:`inventory.category`},{id:`low_stock_threshold_pct`,type:`number`,labelKey:`inventory.lowStockThresholdOverride`,min:1,max:99,step:1}];function fZe({value:e,onChange:t,options:n,allowCustom:r,placeholderKey:i,disabled:a}){let{t:o}=W(),s=(0,y.useRef)(null),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``);(0,y.useEffect)(()=>{if(!c)return;let e=e=>{s.current&&!s.current.contains(e.target)&&(l(!1),d(``))},t=e=>{e.key===`Escape`&&(l(!1),d(``))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[c]);let f=c?u:n.find(t=>t.value===e)?.label??e,p=(0,y.useMemo)(()=>{if(!c)return n;let e=u.trim().toLowerCase();return e?n.filter(t=>t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e)):n},[c,u,n]),m=c&&u.trim()&&!n.some(e=>e.value.toLowerCase()===u.trim().toLowerCase());return(0,K.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,K.jsx)(`input`,{type:`text`,disabled:a,value:f,onChange:e=>{d(e.target.value),l(!0),r&&t(e.target.value)},onFocus:()=>{l(!0),d(``)},placeholder:i?o(i):void 0,className:`w-full px-3 py-2 pr-9 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),c&&(0,K.jsxs)(`div`,{className:`absolute z-50 left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:[p.length===0&&!r&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:o(`inventory.noResults`)}),p.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e===n.value?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(n.value),l(!1),d(``)},children:n.label},n.value)),r&&m&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(u.trim()),l(!1),d(``)},children:o(`inventory.bulk.useCustom`,{value:u.trim()})})]})]})}function T9(...e){let t=new Set;for(let n of e)for(let e of n){let n=e?.trim();n&&t.add(n)}return Array.from(t).sort((e,t)=>e.localeCompare(t))}function pZe({isOpen:e,selectedCount:t,isPending:n,availableLocations:r,availableMaterials:i,availableSubtypes:a,availableBrands:o,availableCategories:s,availableSlicerFilaments:c,availableSlicerFilamentNames:l,onClose:u,onApply:d}){let{t:f}=W(),{data:p=[]}=q({queryKey:[`bulk-edit-cloud-presets`],enabled:e,staleTime:300*1e3,queryFn:async()=>{let e=[];try{if((await Q.getCloudStatus()).is_authenticated){let t=await Q.getFilamentPresets();e.push(...t)}}catch{}try{if((await Q.orcaCloudStatus()).connected){let t=await Q.orcaCloudListProfiles();e.push(...t.filament)}}catch{}return e}}),{data:m}=q({queryKey:[`bulk-edit-local-presets`],enabled:e,staleTime:300*1e3,queryFn:Q.getLocalPresets}),{data:h=[]}=q({queryKey:[`builtin-filaments`],enabled:e,staleTime:300*1e3,queryFn:Q.getBuiltinFilaments}),g=(0,y.useMemo)(()=>AU(p,new Set,m?.filament??[],h),[p,m,h]),[_,v]=(0,y.useState)({}),b=(0,y.useMemo)(()=>T9(SU,i).map(e=>({value:e,label:e})),[i]),x=(0,y.useMemo)(()=>T9(wU,a).map(e=>({value:e,label:e})),[a]),S=(0,y.useMemo)(()=>T9(CU,o).map(e=>({value:e,label:e})),[o]),C=(0,y.useMemo)(()=>T9(s).map(e=>({value:e,label:e})),[s]),w=(0,y.useMemo)(()=>{let e=g.map(e=>({value:e.code,label:e.displayName})),t=c.filter(t=>!e.some(e=>e.value===t)).map(e=>({value:e,label:e}));return[...e,...t].sort((e,t)=>e.label.localeCompare(t.label))},[g,c]),T=(0,y.useMemo)(()=>{let e=g.map(e=>({value:e.displayName,label:e.displayName})),t=l.filter(t=>!e.some(e=>e.value===t)).map(e=>({value:e,label:e}));return[...e,...t].sort((e,t)=>e.label.localeCompare(t.label))},[g,l]),E=(0,y.useMemo)(()=>r.map(e=>({value:String(e.id),label:e.name})),[r]);if(!e)return null;let D=(e,t)=>{v(n=>({...n,[e]:t}))},O=e=>{v(t=>{let n={...t};return delete n[e],n})},k=(()=>{let e={};for(let t of w9){let n=_[t.id];if(n===void 0)continue;let r=typeof n==`string`?n.trim():n;if(!(r===``||r===null))if(t.type===`number`){let n=Number(r);Number.isFinite(n)&&(e[t.id]=n)}else if(t.id===`location_id`){let n=Number(r);Number.isFinite(n)&&n>0&&(e[t.id]=n)}else if(t.id===`rgba`){let n=String(r).replace(/^#/,``),i=n.length===6?`${n}FF`:n;/^[0-9A-Fa-f]{8}$/.test(i)&&(e[t.id]=i.toUpperCase())}else e[t.id]=String(r)}return e})(),A=Object.keys(k).length>0,j=w9.some(e=>{let t=_[e.id];return t===void 0||t.trim()===``?!1:k[e.id]===void 0}),M=e=>e===`material`?b:e===`subtype`?x:e===`brand`?S:e===`category`?C:e===`slicer_filament`?w:e===`slicer_filament_name`?T:e===`location_id`?E:[],N=e=>{let t=_[e.id]??``;if(e.type===`searchable`||e.type===`searchableClosed`)return(0,K.jsx)(fZe,{value:t,onChange:t=>{t===``?O(e.id):D(e.id,t)},options:M(e.id),allowCustom:e.type===`searchable`,disabled:n});if(e.type===`textarea`)return(0,K.jsx)(`textarea`,{disabled:n,value:t,onChange:t=>D(e.id,t.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none resize-none min-h-[60px]`});if(e.type===`color`){let r=t.trim().replace(/^#/,``),i=r.length===6?`${r}FF`:r,a=t.trim()!==``&&!/^[0-9A-Fa-f]{8}$/.test(i);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`color`,disabled:n,value:`#${(t||`808080`).replace(/^#/,``).slice(0,6)}`,onChange:t=>D(e.id,t.target.value.replace(/^#/,``).toUpperCase()),className:`h-9 w-12 rounded cursor-pointer`}),(0,K.jsx)(`input`,{type:`text`,disabled:n,value:t,onChange:t=>D(e.id,t.target.value.replace(/^#/,``).toUpperCase()),placeholder:`RRGGBB or RRGGBBAA`,className:`flex-1 px-3 py-2 bg-bambu-dark border rounded-lg text-white placeholder-bambu-gray/50 focus:outline-none ${a?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,pattern:e.pattern})]}),a&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:f(`inventory.bulk.invalidHex`)})]})}return(0,K.jsx)(`input`,{type:e.type===`number`?`number`:`text`,disabled:n,value:t,onChange:t=>D(e.id,t.target.value),min:e.min,max:e.max,step:e.step,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`})};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50`,onClick:n?void 0:u,children:(0,K.jsxs)(`div`,{className:`w-full max-w-3xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-5 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:f(`inventory.bulk.editTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:f(`inventory.bulk.editSubtitle`,{count:t})})]}),(0,K.jsx)(`button`,{onClick:u,disabled:n,className:`p-1 text-bambu-gray hover:text-white transition-colors`,"aria-label":f(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`p`,{className:`px-5 pt-4 text-xs text-bambu-gray`,children:f(`inventory.bulk.editHint`)}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5 space-y-3`,children:w9.map(e=>{let t=_[e.id]!==void 0;return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md p-2 transition-colors ${t?`bg-bambu-green/5 border border-bambu-green/30`:`border border-transparent`}`,children:[(0,K.jsx)(`div`,{className:`pt-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,checked:t,onChange:t=>{t.target.checked?D(e.id,``):O(e.id)},"aria-label":f(`inventory.bulk.toggleField`)})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(e.labelKey)}),N(e)]})]},e.id)})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-5 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:f(`inventory.bulk.changeCount`,{count:Object.keys(k).length})}),(0,K.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:u,disabled:n,children:f(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>d(k),disabled:!A||n||j,children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),f(`inventory.bulk.applyPending`)]}):f(`inventory.bulk.applyButton`,{count:t})})]})]})]})})}function mZe(e){let t=e[0],n=0,r=0,i=0;for(let t of e)n+=t.label_weight,r+=t.weight_used,i+=t.core_weight;return{...t,label_weight:n,weight_used:r,core_weight:i}}function E9(e){let t=new Set;for(let n of e)if(typeof n==`string`){let e=n.trim();e&&t.add(e)}return Array.from(t).sort((e,t)=>e.localeCompare(t))}function hZe(e){return`${e.material}|${e.subtype||``}|${e.brand||``}|${e.color_name||``}|${e.rgba||``}|${e.extra_colors||``}|${e.effect_type||``}|${e.label_weight}`}var gZe=`bambuddy-inventory-columns`,D9=[{id:`id`,label:`#`,visible:!0},{id:`added_time`,label:`Added`,visible:!0},{id:`encode_time`,label:`Encoded`,visible:!1},{id:`last_used_time`,label:`Last Used`,visible:!1},{id:`rgba`,label:`Color`,visible:!0},{id:`material`,label:`Material`,visible:!0},{id:`subtype`,label:`Subtype`,visible:!0},{id:`color_name`,label:`Color Name`,visible:!1},{id:`brand`,label:`Brand`,visible:!0},{id:`slicer_filament`,label:`Slicer Filament`,visible:!1},{id:`location`,label:`Location`,visible:!0},{id:`storage_location`,label:`Storage Location`,visible:!1},{id:`label_weight`,label:`Label`,visible:!0},{id:`net`,label:`Net`,visible:!0},{id:`gross`,label:`Gross`,visible:!1},{id:`added_full`,label:`Full`,visible:!1},{id:`used`,label:`Used`,visible:!1},{id:`printed_total`,label:`Printed Total`,visible:!1},{id:`printed_since_weight`,label:`Printed Since Weight`,visible:!1},{id:`note`,label:`Note`,visible:!1},{id:`pa_k`,label:`PA(K)`,visible:!0},{id:`tag_id`,label:`Tag ID`,visible:!1},{id:`data_origin`,label:`Data Origin`,visible:!1},{id:`tag_type`,label:`Linked Tag Type`,visible:!1},{id:`stock`,label:`Stock`,visible:!1},{id:`remaining`,label:`Remaining`,visible:!0},{id:`spool_name`,label:`Spool`,visible:!1},{id:`cost_per_kg`,label:`Cost/kg`,visible:!1},{id:`weight_check`,label:`Weight Check`,visible:!1}];function _Ze(){try{let e=localStorage.getItem(gZe);if(e){let t=JSON.parse(e),n=new Set(D9.map(e=>e.id)),r=new Set(t.map(e=>e.id)),i=t.filter(e=>n.has(e.id)),a=D9.filter(e=>!r.has(e.id));return[...i,...a]}}catch{}return D9.map(e=>({...e}))}function vZe(e){try{localStorage.setItem(gZe,JSON.stringify(e))}catch{}}function O9(e,t=!1){return t&&e>=1e3?`${(e/1e3).toFixed(1)}kg`:`${Math.round(e)}g`}var yZe={PLA:`bg-green-500/20 text-green-400`,ABS:`bg-red-500/20 text-red-400`,PETG:`bg-blue-500/20 text-blue-400`,TPU:`bg-purple-500/20 text-purple-400`,ASA:`bg-orange-500/20 text-orange-400`,PA:`bg-yellow-500/20 text-yellow-400`,PC:`bg-cyan-500/20 text-cyan-400`,PET:`bg-sky-500/20 text-sky-400`};function k9(e,t=`system`){if(!e)return`-`;let n=vf(e);return n?uf(n,t):`-`}var bZe={id:()=>`#`,added_time:()=>`Added`,encode_time:()=>`Encoded`,last_used_time:()=>`Last Used`,rgba:e=>e(`inventory.color`),material:e=>e(`inventory.material`),subtype:e=>e(`inventory.subtype`),color_name:e=>e(`inventory.colorName`),brand:e=>e(`inventory.brand`),slicer_filament:e=>e(`inventory.slicerFilament`),location:()=>`Location`,storage_location:e=>e(`inventory.storageLocation`),label_weight:e=>e(`inventory.labelWeight`),net:e=>e(`inventory.net`),gross:()=>`Gross`,added_full:()=>`Full`,used:e=>e(`inventory.weightUsed`),printed_total:()=>`Printed Total`,printed_since_weight:()=>`Printed Since Weight`,note:e=>e(`inventory.note`),pa_k:()=>`PA(K)`,tag_id:()=>`Tag ID`,data_origin:()=>`Data Origin`,tag_type:()=>`Linked Tag Type`,stock:e=>e(`inventory.stock`),remaining:e=>e(`inventory.remaining`),spool_name:e=>e(`inventory.spoolName`),cost_per_kg:e=>e(`inventory.costPerKg`),weight_check:e=>e(`inventory.weightCheck`)},A9={id:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm font-medium text-white`,children:e.id}),added_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:k9(e.created_at,t)}),encode_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:k9(e.encode_time,t)}),last_used_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.last_used?k9(e.last_used,t):`Never`}),rgba:({spool:e})=>(0,K.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,K.jsx)(W3,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,effectSize:`table`,subtype:e.subtype})}),material:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.material}),subtype:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.subtype||`-`}),color_name:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:Kd(e.color_name,e.rgba)||`-`}),brand:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.brand||`-`}),slicer_filament:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,title:e.slicer_filament||void 0,children:e.slicer_filament_name||e.slicer_filament||`-`}),location:({spool:e,assignmentMap:t})=>{let n=t[e.id];if(!n)return(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`});let r=n.printer_name||`Printer ${n.printer_id}`,i=n.ams_id===254||n.ams_id===255,a=!i&&n.ams_id>=128;return(0,K.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400`,children:[r,` `,If(n.ams_id,n.tray_id,a,i),n.ams_label?` (${n.ams_label})`:``]})},storage_location:({spool:e})=>e.storage_location?(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-500/20 text-blue-400`,children:e.storage_location}):(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}),label_weight:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:O9(e.label_weight)}),net:({remaining:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:O9(e)}),gross:({spool:e,remaining:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:O9(t+e.core_weight)}),added_full:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.added_full==null?`-`:e.added_full?`Yes`:`No`}),used:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.weight_used>0?O9(e.weight_used):`-`}),printed_total:()=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`}),printed_since_weight:()=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`}),note:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray max-w-[150px] truncate block`,title:e.note||void 0,children:e.note||`-`}),pa_k:({spool:e})=>(e.k_profiles?.length??0)===0?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}):(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green`,children:`K`}),tag_id:({spool:e})=>{let t=e.tag_uid||e.tray_uuid;return t?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray font-mono`,title:t,children:t.length>12?`${t.slice(0,6)}...${t.slice(-4)}`:t}):(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`})},data_origin:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.data_origin||`-`}),tag_type:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.tag_type||`-`}),stock:({spool:e,t})=>e.slicer_filament?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}):(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400`,children:t(`inventory.stock`)}),remaining:({remaining:e,pct:t})=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${t>50?`bg-bambu-green`:t>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(t,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray min-w-[40px] text-right`,children:[Math.round(e),`g`]})]}),spool_name:({spool:e,catalogMap:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:(e.core_weight_catalog_id==null?void 0:t[e.core_weight_catalog_id])?.name||`-`}),cost_per_kg:({spool:e,currencySymbol:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.cost_per_kg==null?`-`:`${t}${e.cost_per_kg.toFixed(2)}`}),weight_check:({spool:e,onSyncWeight:t})=>{let n=e.last_scale_weight;if(n==null)return(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,title:`No scale measurement`,children:`-`});let r=e.core_weight||0,i=Math.max(0,e.label_weight-e.weight_used)+r,a,o;n0?`+${Math.round(a)}`:`${Math.round(a)}`,c=o?`Scale: ${Math.round(n)}g\nCalculated: ${Math.round(i)}g\nDifference: ${s}g (within tolerance)`:`Scale: ${Math.round(n)}g\nCalculated: ${Math.round(i)}g\nDifference: ${s}g (mismatch!)`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium ${o?`text-green-400`:`text-yellow-400`}`,title:c,children:[(0,K.jsxs)(`span`,{children:[Math.round(n),`g`]}),o?(0,K.jsx)(rs,{className:`w-3 h-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),t&&(0,K.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),n.preventDefault(),t(e)},className:`p-1 hover:bg-bambu-green/20 rounded transition-colors text-bambu-green`,title:`Sync: trust scale weight and reset tracking`,children:(0,K.jsx)(Ol,{className:`w-3.5 h-3.5`})})]})]})}},j9={id:e=>e.id,added_time:e=>e.created_at||``,encode_time:e=>e.encode_time||``,last_used_time:e=>e.last_used||``,material:e=>(e.material||``).toLowerCase(),subtype:e=>(e.subtype||``).toLowerCase(),color_name:e=>(e.color_name||``).toLowerCase(),brand:e=>(e.brand||``).toLowerCase(),slicer_filament:e=>(e.slicer_filament_name||e.slicer_filament||``).toLowerCase(),location:(e,t)=>{let n=t[e.id];if(!n)return``;let r=n.ams_id===254||n.ams_id===255,i=!r&&n.ams_id>=128,a=n.ams_label?` (${n.ams_label})`:``;return`${n.printer_name||``} ${If(n.ams_id,n.tray_id,i,r)}${a}`},storage_location:e=>(e.storage_location||``).toLowerCase(),label_weight:e=>e.label_weight,net:e=>Math.max(0,e.label_weight-e.weight_used),gross:e=>Math.max(0,e.label_weight-e.weight_used)+e.core_weight,used:e=>e.weight_used,remaining:e=>e.label_weight>0?Math.max(0,e.label_weight-e.weight_used)/e.label_weight:0,note:e=>(e.note||``).toLowerCase(),data_origin:e=>(e.data_origin||``).toLowerCase(),tag_type:e=>(e.tag_type||``).toLowerCase(),stock:e=>+!!e.slicer_filament,spool_name:e=>e.core_weight_catalog_id??0,cost_per_kg:e=>e.cost_per_kg??0,weight_check:e=>{if(e.last_scale_weight==null)return-1;let t=Math.max(0,e.label_weight-e.weight_used)+e.core_weight;return Math.abs(e.last_scale_weight-t)}},M9=`bambuddy-inventory-sort`;function xZe(){try{let e=localStorage.getItem(M9);if(e)return JSON.parse(e)}catch{}return null}function SZe(e){try{e?localStorage.setItem(M9,JSON.stringify(e)):localStorage.removeItem(M9)}catch{}}function CZe(){let{data:e}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),t=e!==void 0;return(0,K.jsx)(wZe,{spoolmanMode:e?.spoolman_enabled===`true`&&!!e?.spoolman_url,spoolmanModeReady:t})}function wZe({spoolmanMode:e=!1,spoolmanModeReady:t=!0}){let{t:n}=W(),r=no(),{showToast:i}=Td(),{hasPermission:a,loading:o}=dd(),s=!o&&a(`inventory:forecast_read`),[c,l]=Mi(),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(`active`),[E,D]=(0,y.useState)(`all`),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(``),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(`all`),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`table`),[ee,te]=(0,y.useState)(xZe),[ne,re]=(0,y.useState)(_Ze),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(()=>{try{return localStorage.getItem(`bambuddy-inventory-group`)===`true`}catch{return!1}}),[U,se]=(0,y.useState)(new Set),[ce,le]=(0,y.useState)(new Set),[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)(null),me=(0,y.useCallback)(e=>{le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,y.useCallback)(()=>le(new Set),[]);(0,y.useEffect)(()=>{le(new Set)},[w,E,O,A,M,P,I,R]);let[ge,_e]=(0,y.useState)(0),[ve,ye]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`bambuddy-inventory-pageSize`);if(e){let t=Number(e);if([15,30,50,100,-1].includes(t))return t}}catch{}return 15}),{data:be}=q({queryKey:[`settings`],queryFn:Q.getSettings}),xe=be?.date_format||`system`,Se=e?[`spoolman-inventory-spools`]:[`inventory-spools`],Ce=()=>x9(r,Se),{data:we,isLoading:Te}=q({queryKey:Se,queryFn:()=>e?Q.getSpoolmanInventorySpools(!0):Q.getSpools(!0),refetchInterval:3e4}),Ee=(0,y.useCallback)(async()=>{x(!0);try{await Q.exportSpoolsCsv()}catch(e){i(e instanceof Error?e.message:n(`inventory.csv.exportError`,`Export failed`),`error`)}finally{x(!1)}},[i,n]),De=e?n(`inventory.csv.spoolmanHint`,`In Spoolman mode, use Spoolman's built-in CSV import/export.`):void 0,{data:Oe=[]}=q({queryKey:y9,queryFn:Q.getLocations}),ke=c.get(`location_id`),Ae=ke===`__none__`?`__none__`:ke&&/^\d+$/.test(ke)&&Number(ke)>0?ke:``,je=c.get(`spool`),Me=je&&/^\d+$/.test(je)&&Number(je)>0?Number(je):null,Ne=we?.find(e=>e.id===Me)??null,Pe=(0,y.useCallback)(()=>{f.current=!0,l(e=>(e.delete(`spool`),e),{replace:!0})},[l]),{data:Fe,isError:Ie,error:Le}=q({queryKey:e?[`spoolman-inventory-spool`,Me]:[`inventory-spool`,Me],queryFn:()=>e?Q.getSpoolmanInventorySpool(Me):Q.getSpool(Me),enabled:t&&Me!==null&&Ne===null,staleTime:1/0,retry:(e,t)=>e<2&&!(t instanceof Uu&&t.status===404)});(0,y.useEffect)(()=>{if(!f.current){if(t&&Me&&Ne){Pe(),d({spool:Ne,mode:`edit`});return}if(Fe){Pe(),d({spool:Fe,mode:`edit`});return}Ie&&(Pe(),i(n(Le instanceof Uu&&Le.status===404?`inventory.deepLinkSpoolNotFound`:`inventory.deepLinkFetchFailed`),`error`))}},[t,Me,Ne,Fe,Ie,Le,Pe,i,n]);let{data:Re}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),refetchInterval:3e4}),{data:ze=[],isError:Be}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e,refetchInterval:3e4,staleTime:1e4,retry:1}),Ve=(0,y.useRef)(!1);(0,y.useEffect)(()=>{Be&&!Ve.current?(Ve.current=!0,i(n(`inventory.spoolmanUnreachable`),`error`)):Be||(Ve.current=!1)},[Be,i,n]);let{data:He}=q({queryKey:[`spool-catalog`],queryFn:()=>Q.getSpoolCatalog()}),Ue=J({mutationFn:t=>e?Q.deleteSpoolmanInventorySpool(t):Q.deleteSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolDeleted`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.deleteSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.deleteFailed`),`error`)}}),We=J({mutationFn:t=>e?Q.archiveSpoolmanInventorySpool(t):Q.archiveSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolArchived`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.archiveSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.archiveFailed`),`error`)}}),Ge=J({mutationFn:t=>e?Q.restoreSpoolmanInventorySpool(t):Q.restoreSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolRestored`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.restoreSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.restoreFailed`),`error`)}}),Ke=J({mutationFn:t=>e?Q.resetSpoolmanInventorySpoolConsumedCounter(t):Q.resetSpoolConsumedCounter(t),onSuccess:()=>{r.invalidateQueries({queryKey:Se}),i(n(`inventory.consumedCounterReset`),`success`)},onError:()=>{i(n(`inventory.resetConsumedCounterFailed`),`error`)}}),qe=J({mutationFn:t=>e?Q.bulkResetSpoolmanInventorySpoolConsumedCounter(t):Q.bulkResetSpoolConsumedCounter(t),onSuccess:e=>{r.invalidateQueries({queryKey:Se}),i(n(`inventory.allConsumedCountersReset`,{count:e.reset}),`success`),pe(null),he()},onError:()=>{i(n(`inventory.resetConsumedCounterFailed`),`error`)}}),Je=e=>(e.not_found?.length??0)+(e.errors?.length??0),Ye=J({mutationFn:async({ids:t,update:n})=>e?Q.bulkUpdateSpoolmanInventorySpools(t,n):Q.bulkUpdateSpools(t,n),onSuccess:e=>{Ce();let t=Je(e);if(e.updated===0){i(n(`inventory.bulk.updateAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.updatePartial`,{ok:e.updated,failed:t}),`warning`):i(n(`inventory.bulk.updateSuccess`,{count:e.updated}),`success`),de(!1),he()},onError:e=>{i(e.message||n(`inventory.bulk.updateFailed`),`error`)}}),Xe=J({mutationFn:async t=>e?Q.bulkDeleteSpoolmanInventorySpools(t):Q.bulkDeleteSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.deleted===0){i(n(`inventory.bulk.deleteAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.deletePartial`,{ok:e.deleted,failed:t}),`warning`):i(n(`inventory.bulk.deleteSuccess`,{count:e.deleted}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.deleteFailed`),`error`)}}),Ze=J({mutationFn:async t=>e?Q.bulkArchiveSpoolmanInventorySpools(t):Q.bulkArchiveSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.archived===0&&t>0){i(n(`inventory.bulk.archiveAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.archivePartial`,{ok:e.archived,failed:t}),`warning`):i(n(`inventory.bulk.archiveSuccess`,{count:e.archived}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.archiveFailed`),`error`)}}),Qe=J({mutationFn:async t=>e?Q.bulkRestoreSpoolmanInventorySpools(t):Q.bulkRestoreSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.restored===0&&t>0){i(n(`inventory.bulk.restoreAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.restorePartial`,{ok:e.restored,failed:t}),`warning`):i(n(`inventory.bulk.restoreSuccess`,{count:e.restored}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.restoreFailed`),`error`)}}),$e=(0,y.useMemo)(()=>(we??[]).map(e=>e.id),[we]),et=async t=>{if(t.last_scale_weight!=null)try{e?await Q.syncSpoolmanSpoolWeight(t.id,t.last_scale_weight):await od.updateSpoolWeight(t.id,t.last_scale_weight),r.invalidateQueries({queryKey:Se}),i(`Synced "${[t.brand,t.material,t.color_name].filter(Boolean).join(` `)}" to scale weight`,`success`)}catch(e){let t=e instanceof Uu&&e.status===404,r=e instanceof Uu&&e.status===503;i(n(t?`inventory.syncWeightSpoolNotFound`:r?`inventory.syncWeightSpoolmanUnreachable`:`inventory.syncWeightFailed`),`error`)}},tt=be?.low_stock_threshold??20,[nt,rt]=(0,y.useState)(!1),[it,at]=(0,y.useState)(tt.toString());(0,y.useEffect)(()=>{nt||at(tt.toString())},[tt,nt]);let ot=J({mutationFn:e=>Q.updateSettings({low_stock_threshold:e}),onSuccess:()=>{r.invalidateQueries({queryKey:[`settings`]}),i(n(`common.saved`),`success`),rt(!1)},onError:()=>{i(n(`inventory.lowStockThresholdError`),`error`)}}),st=(0,y.useMemo)(()=>{if(!we)return null;let e=0,t=0,n=0,r=0,i={};for(let a of we){if(t+=Math.max(0,a.weight_used-(a.weight_used_baseline??0)),a.archived_at)continue;r++;let o=Math.max(0,a.label_weight-a.weight_used);e+=o,(a.label_weight>0?o/a.label_weight*100:0)<(a.low_stock_threshold_pct??tt)&&n++;let s=a.material||`Unknown`;i[s]||(i[s]={count:0,weight:0}),i[s].count++,i[s].weight+=o}return{totalWeight:e,totalConsumed:t,lowStock:n,byMaterial:i,totalSpools:r}},[we,tt]),ct=(Re?.length??0)+(e?ze.length:0),lt=$d(be?.currency||`USD`),ut=(0,y.useMemo)(()=>{let e={};for(let t of Re||[])e[t.spool_id]={printer_id:t.printer_id,printer_name:t.printer_name,ams_id:t.ams_id,tray_id:t.tray_id,ams_label:t.ams_label??null};for(let t of ze)typeof t?.spoolman_spool_id!=`number`||t.spoolman_spool_id<=0||typeof t.printer_id!=`number`||typeof t.ams_id!=`number`||typeof t.tray_id!=`number`||e[t.spoolman_spool_id]||(e[t.spoolman_spool_id]={printer_id:t.printer_id,printer_name:t.printer_name??null,ams_id:t.ams_id,tray_id:t.tray_id,ams_label:t.ams_label??null});return e},[Re,ze]),dt=(0,y.useMemo)(()=>{let e={};for(let t of He||[])e[t.id]=t;return e},[He]),ft=(0,y.useMemo)(()=>st?Object.entries(st.byMaterial).sort((e,t)=>t[1].weight-e[1].weight).slice(0,4):[],[st]),pt=(0,y.useMemo)(()=>{let e=we||[];if(e=w===`active`?e.filter(e=>!e.archived_at):e.filter(e=>!!e.archived_at),E===`used`?e=e.filter(e=>e.weight_used>0):E===`new`?e=e.filter(e=>e.weight_used===0):E===`lowstock`&&(e=e.filter(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(e.label_weight>0?t/e.label_weight*100:0)<(e.low_stock_threshold_pct??tt)})),O&&(e=e.filter(e=>e.material===O)),A&&(e=e.filter(e=>e.brand===A)),M&&(e=M===`__none__`?e.filter(e=>!e.category):e.filter(e=>e.category===M)),P){let t=Number(P);e=e.filter(e=>e.core_weight_catalog_id===t)}if(Ae)if(Ae===`__none__`)e=e.filter(e=>!e.location_id&&!e.storage_location?.trim());else{let t=Number(Ae),n=Oe.find(e=>e.id===t)?.name?.trim().toLowerCase();e=e.filter(e=>e.location_id==null?n?(e.storage_location||``).trim().toLowerCase()===n:!1:e.location_id===t)}return I===`stock`?e=e.filter(e=>!e.slicer_filament):I===`configured`&&(e=e.filter(e=>!!e.slicer_filament)),R&&(e=mU(e,R)),e},[we,w,E,O,A,M,P,I,Ae,R,tt,Oe]),mt=()=>_e(0),ht=(0,y.useCallback)(e=>{l(t=>(t.delete(`location_id`),e&&t.set(`location_id`,e),t),{replace:!0}),mt()},[l]),gt=[...new Set(we?.map(e=>e.material)||[])].sort(),_t=[...new Set(we?.map(e=>e.brand).filter(Boolean)||[])].sort(),vt=[...new Set(we?.map(e=>e.category?.trim()).filter(Boolean)||[])].sort(),yt=(we??[]).some(e=>!e.category),bt=[...new Set(we?.map(e=>e.core_weight_catalog_id).filter(e=>e!=null)||[])].sort((e,t)=>{let n=(dt[e]?.name||``).toLowerCase(),r=(dt[t]?.name||``).toLowerCase();return n.localeCompare(r)}),xt=(we??[]).some(e=>!e.location_id&&!e.storage_location?.trim()),St=w!==`active`||E!==`all`||!!O||!!A||!!M||!!P||!!Ae||I!==`all`||!!R,Ct=e=>{re(e),vZe(e)},wt=(0,y.useMemo)(()=>ne.filter(e=>e.visible).map(e=>e.id),[ne]),Tt=e=>{j9[e]&&(te(t=>{let n;return n=t?.column===e?t.direction===`asc`?{column:e,direction:`desc`}:null:{column:e,direction:`asc`},SZe(n),n}),mt())},Et=(0,y.useMemo)(()=>{if(!ee)return pt;let e=j9[ee.column];return e?[...pt].sort((t,n)=>{let r=e(t,ut),i=e(n,ut);return ri?ee.direction===`asc`?1:-1:0}):pt},[pt,ee,ut]),Dt=(0,y.useMemo)(()=>{if(!ae)return Et.map(e=>({type:`single`,spool:e}));let e=new Map;for(let t of Et)if(!(t.weight_used>0||ut[t.id])){let n=hZe(t),r=e.get(n);r?r.push(t):e.set(n,[t])}let t=[],n=new Set;for(let r of Et){if(r.weight_used>0||ut[r.id]){t.push({type:`single`,spool:r});continue}let i=hZe(r);if(n.has(i))continue;n.add(i);let a=e.get(i);a.length===1?t.push({type:`single`,spool:a[0]}):t.push({type:`group`,key:i,spools:a,representative:a[0]})}return t},[Et,ae,ut]),Ot=ve===-1,kt=Dt.length,At=Ot?kt||1:ve,jt=Math.max(1,Math.ceil(kt/At)),Mt=Ot?0:Math.min(ge,jt-1),G=Ot?Dt:Dt.slice(Mt*At,(Mt+1)*At),Nt=()=>{let e=!ae;oe(e),se(new Set),mt();try{localStorage.setItem(`bambuddy-inventory-group`,String(e))}catch{}},Pt=e=>{se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ft=e=>{ye(e),_e(0);try{localStorage.setItem(`bambuddy-inventory-pageSize`,String(e))}catch{}};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(pl,{className:`w-7 h-7 text-bambu-green`}),n(`inventory.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:n(`inventory.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,disabled:e,onClick:()=>v(!0),title:De,children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`inventory.csv.importButton`,`Import CSV`)]}),(0,K.jsxs)($,{variant:`secondary`,disabled:e||b,onClick:Ee,title:De,children:[b?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vs,{className:`w-4 h-4`}),n(`inventory.csv.exportButton`,`Export CSV`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!0),children:[(0,K.jsx)(Zc,{className:`w-4 h-4`}),n(`locations.manage`)]}),(0,K.jsxs)($,{variant:`secondary`,disabled:pt.length===0,onClick:()=>g(pt.map(e=>e.id)),title:pt.length===0?n(`inventory.labels.noSpoolsTitle`,`No spools to label`):n(`inventory.labels.bulkTitle`,`Pick spools to print labels for from the {{count}} currently shown`,{count:pt.length}),children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),n(`inventory.labels.printLabels`,`Print labels…`)]}),(0,K.jsxs)($,{onClick:()=>d({spool:null,mode:`create`}),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),n(`inventory.addSpool`)]})]})]}),st&&!Te&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.totalInventory`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:O9(st.totalWeight,!0)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[st.totalSpools,` `,st.totalSpools===1?n(`inventory.spool`):n(`inventory.spools`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.totalConsumed`)})]}),st.totalConsumed>0&&$e.length>0&&(0,K.jsx)(`button`,{onClick:()=>m({type:`reset-all-consumed-counters`}),className:`p-1 text-bambu-gray hover:text-red-400 rounded transition-colors`,title:n(`inventory.resetAllConsumedCountersTooltip`),"aria-label":n(`inventory.resetAllConsumedCounters`),children:(0,K.jsx)(qs,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:O9(st.totalConsumed,!0)}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:n(`inventory.sinceTracking`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-green-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.byMaterial`)})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:ft.map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${yZe[e]||`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[e,` `,(0,K.jsx)(`span`,{className:`opacity-70`,children:O9(t.weight,!0)})]},e))})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.inPrinter`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:ct}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:n(`inventory.loadedInAms`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.lowStock`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold ${st.lowStock>0?`text-yellow-400`:`text-white`}`,children:st.lowStock}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1 flex items-center gap-2`,children:nt?(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=parseFloat(it);!isNaN(t)&&t>=.1&&t<=99.9?ot.mutate(t):i(n(`inventory.lowStockThresholdError`),`error`)},className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`<`}),(0,K.jsx)(`input`,{type:`text`,inputMode:`decimal`,pattern:`^\\d{0,2}(\\.\\d?)?$`,maxLength:4,value:it,onChange:e=>{let t=e.target.value.replace(/[^\d.]/g,``);/^\d{0,2}(\.\d?)?$/.test(t)&&at(t)},className:`px-1.5 py-1 rounded border border-bambu-dark-tertiary text-xs text-white bg-bambu-dark-secondary focus:outline-none focus:border-bambu-green w-14 text-center`,onWheel:e=>e.currentTarget.blur(),disabled:ot.isPending}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`%`}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:ot.isPending,children:n(`common.save`)}),(0,K.jsx)($,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>rt(!1),disabled:ot.isPending,children:n(`common.cancel`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`< `,tt,`%`]}),(0,K.jsx)(`button`,{className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:n(`common.edit`),onClick:()=>{at(tt.toString()),rt(!0)},children:(0,K.jsx)(_l,{className:`w-4 h-4`})})]})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 max-w-md ${B===`forecast`?`invisible pointer-events-none`:``}`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>{z(e.target.value),mt()},placeholder:n(`inventory.search`),className:`w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),R&&(0,K.jsx)(`button`,{onClick:()=>{z(``),mt()},className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B===`table`&&(0,K.jsxs)(`button`,{onClick:()=>H(!0),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,title:n(`inventory.configureColumns`),children:[(0,K.jsx)(As,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.columns`)})]}),B!==`forecast`&&(0,K.jsxs)(`button`,{onClick:Nt,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${ae?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,title:n(`inventory.groupSimilar`),children:[(0,K.jsx)(Sc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.groupSimilar`)})]}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>V(`table`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${B===`table`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.table`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(`cards`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${B===`cards`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(zc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.cards`)})]}),(0,K.jsxs)(`button`,{onClick:()=>s&&V(`forecast`),disabled:!s,title:s?void 0:n(`forecast.noReadAccess`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${B===`forecast`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[s?(0,K.jsx)(Su,{className:`w-4 h-4`}):(0,K.jsx)(qc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`forecast.title`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${B===`forecast`?`hidden`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>{T(`active`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${w===`active`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5`}),n(`inventory.active`)]}),(0,K.jsxs)(`button`,{onClick:()=>{T(`archived`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${w===`archived`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5`}),n(`inventory.archived`)]})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>{D(`all`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${E===`all`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.all`)}),(0,K.jsxs)(`button`,{onClick:()=>{D(`used`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${E===`used`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),n(`inventory.used`)]}),(0,K.jsx)(`button`,{onClick:()=>{D(`new`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${E===`new`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.new`)}),(0,K.jsxs)(`button`,{onClick:()=>{D(`lowstock`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${E===`lowstock`?`bg-yellow-500/20 text-yellow-400`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),n(`inventory.lowStock`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>{L(`all`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`all`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.all`)}),(0,K.jsx)(`button`,{onClick:()=>{L(`stock`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`stock`?`bg-amber-500/20 text-amber-400`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.stock`)}),(0,K.jsx)(`button`,{onClick:()=>{L(`configured`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`configured`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.configured`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${O?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.material`)}),gt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${A?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.brand`)}),_t.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(vt.length>0||M)&&(0,K.jsxs)(`select`,{value:M,onChange:e=>{N(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${M?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.category`)}),vt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),yt&&(0,K.jsx)(`option`,{value:`__none__`,children:n(`inventory.categoryNone`)})]}),bt.length>0&&(0,K.jsxs)(`select`,{value:P,onChange:e=>{F(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${P?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.spoolName`)}),bt.map(e=>(0,K.jsx)(`option`,{value:e,children:dt[e]?.name||`#${e}`},e))]}),(Oe.length>0||Ae)&&(0,K.jsxs)(`select`,{value:Ae,onChange:e=>{ht(e.target.value)},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${Ae?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.storageLocation`)}),Oe.map(e=>(0,K.jsx)(`option`,{value:String(e.id),children:e.name},e.id)),xt&&(0,K.jsx)(`option`,{value:`__none__`,children:n(`inventory.storageLocationNone`)})]}),St&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`button`,{onClick:()=>{T(`active`),D(`all`),k(``),j(``),N(``),F(``),L(`all`),z(``),l(e=>(e.delete(`location_id`),e),{replace:!0}),mt()},className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors`,children:[(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`}),n(`inventory.clearFilters`)]})]}),B!==`forecast`&&(0,K.jsxs)(`span`,{className:`ml-auto text-xs text-bambu-gray`,children:[Et.length,` `,Et.length===1?n(`inventory.spool`):n(`inventory.spools`),ae&&kt0&&B!==`forecast`&&(0,K.jsxs)(`div`,{className:`sticky top-2 z-10 mb-4 flex items-center gap-2 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-green font-medium`,children:n(`inventory.bulk.selectionCount`,{count:ce.size})}),(0,K.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>de(!0),children:[(0,K.jsx)(_l,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.edit`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>g([...ce]),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.printLabels`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`reset-consumed-counter`),children:[(0,K.jsx)(qs,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.resetUsage`)]}),w===`archived`?(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`restore`),children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.restore`)]}):(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`archive`),children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.archive`)]}),(0,K.jsxs)($,{size:`sm`,variant:`danger`,onClick:()=>pe(`delete`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.delete`)]}),(0,K.jsx)(`button`,{className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,onClick:he,title:n(`inventory.bulk.clearSelection`),"aria-label":n(`inventory.bulk.clearSelection`),children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),Te?(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):B===`forecast`?(0,K.jsx)(RXe,{spools:we||[]}):B===`cards`?G.length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:G.map(e=>{if(e.type===`group`){let{key:t,spools:r,representative:i}=e,a=r.reduce((e,t)=>e+Math.max(0,t.label_weight-t.weight_used),0),o=U3({rgba:i.rgba,extraColors:i.extra_colors,effectType:i.effect_type,subtype:i.subtype,effectSize:`groupheader`}),s=U.has(t);return(0,K.jsxs)(`div`,{className:`col-span-full`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer`,onClick:()=>Pt(t),children:[(0,K.jsx)(`div`,{className:`h-10 flex items-center px-4 gap-3`,style:o,children:(0,K.jsx)(`span`,{className:`bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium`,children:Kd(i.color_name,i.rgba)||`-`})}),(0,K.jsxs)(`div`,{className:`px-4 py-3 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${s?``:`-rotate-90`}`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-white`,children:[i.material,i.subtype?` ${i.subtype}`:``]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i.brand||`-`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,title:n(`inventory.remaining`),children:O9(a)}),(0,K.jsx)(`span`,{className:`text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full`,children:n(`inventory.groupedSpools`,{count:r.length})})]})]})]}),s&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4`,children:r.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(0,K.jsx)(EZe,{spool:e,remaining:t,pct:e.label_weight>0?t/e.label_weight*100:0,onClick:()=>d({spool:e,mode:`edit`}),onPrintLabel:()=>g([e.id]),onCopy:()=>d({spool:e,mode:`copy`}),t:n},e.id)})})]},`group-${t}`)}let t=e.spool,r=Math.max(0,t.label_weight-t.weight_used);return(0,K.jsx)(EZe,{spool:t,remaining:r,pct:t.label_weight>0?r/t.label_weight*100:0,onClick:()=>d({spool:t,mode:`edit`}),onPrintLabel:()=>g([t.id]),onCopy:()=>d({spool:t,mode:`copy`}),t:n},t.id)})}),(0,K.jsx)(TZe,{pageIndex:Mt,pageSize:ve,totalRows:kt,totalPages:jt,onPageChange:_e,onPageSizeChange:Ft,t:n})]}):(0,K.jsx)(kZe,{hasFilters:St,onAddSpool:()=>d({spool:null,mode:`create`}),t:n}):G.length>0?(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`w-10 px-3 py-3`,children:(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":n(`inventory.bulk.selectAllVisible`),checked:G.length>0&&G.every(e=>(e.type===`group`?e.spools.map(e=>e.id):[e.spool.id]).every(e=>ce.has(e))),onChange:e=>{if(e.target.checked){let e=new Set(ce);for(let t of G){let n=t.type===`group`?t.spools.map(e=>e.id):[t.spool.id];for(let t of n)e.add(t)}le(e)}else{let e=new Set(ce);for(let t of G){let n=t.type===`group`?t.spools.map(e=>e.id):[t.spool.id];for(let t of n)e.delete(t)}le(e)}}})}),wt.map(e=>{let t=!!j9[e],r=ee?.column===e;return(0,K.jsx)(`th`,{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${e===`remaining`?`min-w-[150px]`:``} ${t?`cursor-pointer hover:text-bambu-green transition-colors`:``} ${r?`text-bambu-green`:`text-bambu-gray`}`,onClick:t?()=>Tt(e):void 0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[bZe[e]?.(n)??e,t&&(r?ee.direction===`asc`?(0,K.jsx)(Io,{className:`w-3 h-3`}):(0,K.jsx)(Ao,{className:`w-3 h-3`}):(0,K.jsx)(Po,{className:`w-3 h-3 opacity-30`}))]})},e)}),(0,K.jsx)(`th`,{className:`text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:n(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:G.map(e=>{if(e.type===`group`){let{key:t,spools:r}=e,i=U.has(t),a=mZe(r),o=Math.max(0,a.label_weight-a.weight_used);return(0,K.jsx)(OZe,{spools:r,headerSpool:a,remaining:o,pct:a.label_weight>0?o/a.label_weight*100:0,isExpanded:i,onToggle:()=>Pt(t),selectedIds:ce,onToggleSelected:me,onToggleGroupSelected:(e,t)=>{le(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},onEdit:e=>d({spool:e,mode:`edit`}),onCopy:e=>d({spool:e,mode:`copy`}),onArchive:e=>m({type:`archive`,spoolId:e}),onDelete:e=>m({type:`delete`,spoolId:e}),onPrintLabel:e=>g([e]),onResetConsumedCounter:e=>m({type:`reset-consumed-counter`,spoolId:e}),visibleColumns:wt,assignmentMap:ut,catalogMap:dt,currencySymbol:lt,dateFormat:xe,t:n,onSyncWeight:et},`group-${t}`)}let t=e.spool,r=Math.max(0,t.label_weight-t.weight_used);return(0,K.jsx)(DZe,{spool:t,remaining:r,pct:t.label_weight>0?r/t.label_weight*100:0,isSelected:ce.has(t.id),onToggleSelected:()=>me(t.id),onEdit:()=>d({spool:t,mode:`edit`}),onCopy:()=>d({spool:t,mode:`copy`}),onRestore:()=>Ge.mutate(t.id),onArchive:()=>m({type:`archive`,spoolId:t.id}),onDelete:()=>m({type:`delete`,spoolId:t.id}),onPrintLabel:()=>g([t.id]),onResetConsumedCounter:()=>m({type:`reset-consumed-counter`,spoolId:t.id}),visibleColumns:wt,assignmentMap:ut,catalogMap:dt,currencySymbol:lt,dateFormat:xe,t:n,onSyncWeight:et},t.id)})})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:Ot?`${kt} ${n(kt===1?`inventory.spool`:`inventory.spools`)}`:(0,K.jsxs)(K.Fragment,{children:[n(`inventory.showing`),` `,Mt*At+1,` `,n(`inventory.to`),` `,Math.min((Mt+1)*At,kt),` `,n(`inventory.of`),` `,kt,` `,n(`inventory.spools`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`inventory.show`)}),(0,K.jsxs)(`select`,{value:ve,onChange:e=>Ft(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[15,30,50,100].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:n(`inventory.all`)})]}),!Ot&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>_e(0),disabled:Mt===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,title:`First page`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>_e(e=>Math.max(0,e-1)),disabled:Mt===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[n(`inventory.page`),` `,Mt+1,` `,n(`inventory.of`),` `,jt]}),(0,K.jsx)(`button`,{onClick:()=>_e(e=>Math.min(jt-1,e+1)),disabled:Mt>=jt-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>_e(jt-1),disabled:Mt>=jt-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,title:`Last page`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})]}):(0,K.jsx)(kZe,{hasFilters:St,onAddSpool:()=>d({spool:null,mode:`create`}),t:n}),u!==null&&(0,K.jsx)(nZe,{isOpen:!0,onClose:()=>d(null),spool:u.spool,mode:u.mode,currencySymbol:lt,spoolmanMode:e,spoolsQueryKey:Se}),p&&(0,K.jsx)(Ad,{title:p.type===`delete`?n(`common.delete`):p.type===`archive`?n(`inventory.archive`):p.type===`reset-consumed-counter`?n(`inventory.resetConsumedCounter`):n(`inventory.resetAllConsumedCounters`),message:p.type===`delete`?n(`inventory.deleteConfirm`):p.type===`archive`?n(`inventory.archiveConfirm`):p.type===`reset-consumed-counter`?n(`inventory.resetConsumedCounterConfirm`):n(`inventory.resetAllConsumedCountersConfirm`,{count:$e.length}),confirmText:p.type===`delete`?n(`common.delete`):p.type===`archive`?n(`inventory.archive`):n(`inventory.resetConsumedCounter`),variant:p.type===`archive`?`warning`:`danger`,onConfirm:()=>{p.type===`delete`?Ue.mutate(p.spoolId):p.type===`archive`?We.mutate(p.spoolId):p.type===`reset-consumed-counter`?Ke.mutate(p.spoolId):qe.mutate($e),m(null)},onCancel:()=>m(null)}),(0,K.jsx)(rZe,{isOpen:ie,onClose:()=>H(!1),columns:ne,defaultColumns:D9,onSave:Ct}),(0,K.jsx)(lZe,{isOpen:h!==null,onClose:()=>g(null),availableSpools:pt,initialSelectedIds:h??[],spoolmanMode:e}),(0,K.jsx)(pZe,{isOpen:ue,selectedCount:ce.size,isPending:Ye.isPending,availableLocations:Oe.map(e=>({id:e.id,name:e.name})),availableMaterials:E9((we??[]).map(e=>e.material)),availableSubtypes:E9((we??[]).map(e=>e.subtype)),availableBrands:E9((we??[]).map(e=>e.brand)),availableCategories:E9((we??[]).map(e=>e.category)),availableSlicerFilaments:E9((we??[]).map(e=>e.slicer_filament)),availableSlicerFilamentNames:E9((we??[]).map(e=>e.slicer_filament_name)),onClose:()=>de(!1),onApply:e=>Ye.mutate({ids:[...ce],update:e})}),fe&&(0,K.jsx)(Ad,{title:n(fe===`delete`?`inventory.bulk.deleteTitle`:fe===`archive`?`inventory.bulk.archiveTitle`:fe===`restore`?`inventory.bulk.restoreTitle`:`inventory.bulk.resetUsageTitle`),message:n(fe===`delete`?`inventory.bulk.deleteMessage`:fe===`archive`?`inventory.bulk.archiveMessage`:fe===`restore`?`inventory.bulk.restoreMessage`:`inventory.bulk.resetUsageMessage`,{count:ce.size}),confirmText:n(fe===`delete`?`common.delete`:fe===`archive`?`inventory.archive`:fe===`restore`?`inventory.restore`:`inventory.resetConsumedCounter`),variant:fe===`delete`?`danger`:`warning`,isLoading:Xe.isPending||Ze.isPending||Qe.isPending||qe.isPending,onConfirm:()=>{let e=[...ce];fe===`delete`?Xe.mutate(e):fe===`archive`?Ze.mutate(e):fe===`restore`?Qe.mutate(e):qe.mutate(e)},onCancel:()=>pe(null)}),_&&(0,K.jsx)(uZe,{onClose:()=>v(!1),onImported:e=>{v(!1),r.invalidateQueries({queryKey:Se}),i(n(`inventory.csv.importSuccess`,`{{count}} spools imported`,{count:e}),`success`)}}),(0,K.jsx)(dZe,{open:S,onClose:()=>C(!1),onPickLocation:e=>ht(String(e))})]})}function TZe({pageIndex:e,pageSize:t,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:a,t:o}){let s=t===-1;if(r<=1&&!s)return null;let c=s?n||1:t;return(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:s?`${n} ${o(n===1?`inventory.spool`:`inventory.spools`)}`:(0,K.jsxs)(K.Fragment,{children:[o(`inventory.showing`),` `,e*c+1,` `,o(`inventory.to`),` `,Math.min((e+1)*c,n),` `,o(`inventory.of`),` `,n,` `,o(`inventory.spools`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:o(`inventory.show`)}),(0,K.jsxs)(`select`,{value:t,onChange:e=>a(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[15,30,50,100].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:o(`inventory.all`)})]}),!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>i(0),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(Math.max(0,e-1)),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[o(`inventory.page`),` `,e+1,` `,o(`inventory.of`),` `,r]}),(0,K.jsx)(`button`,{onClick:()=>i(Math.min(r-1,e+1)),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(r-1),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})}function EZe({spool:e,remaining:t,pct:n,onClick:r,onPrintLabel:i,onCopy:a,t:o}){let s=U3({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`card`});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${e.archived_at?`opacity-50`:``}`,onClick:r,children:[(0,K.jsxs)(`div`,{className:`h-14 flex items-center justify-center`,style:s,children:[(0,K.jsx)(`span`,{className:`bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium`,children:Kd(e.color_name,e.rgba)||`-`}),a&&(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:`p-1.5 bg-black/20 hover:bg-black/40 text-white rounded-full transition-colors`,title:o(`inventory.copySpool`),children:(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-white`,children:[e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e.brand||`-`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,title:o(`inventory.labels.printOne`),"aria-label":o(`inventory.labels.printOne`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[`#`,e.id]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs text-bambu-gray mb-1`,children:[(0,K.jsx)(`span`,{children:o(`inventory.remaining`)}),(0,K.jsxs)(`span`,{children:[Math.round(n),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${n>50?`bg-bambu-green`:n>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(n,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray min-w-[40px] text-right`,children:[Math.round(t),`g`]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[o(`inventory.labelWeight`),`: `]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:O9(e.label_weight)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[o(`inventory.weightUsed`),`: `]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e.weight_used>0?O9(e.weight_used):`-`})]})]}),e.note&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate`,title:e.note,children:e.note})]})]})}function DZe({spool:e,remaining:t,pct:n,isSelected:r,onToggleSelected:i,onEdit:a,onCopy:o,onRestore:s,onArchive:c,onDelete:l,onPrintLabel:u,onResetConsumedCounter:d,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v}){return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${e.archived_at?`opacity-50`:``} ${r?`bg-bambu-green/10`:``}`,onClick:a,children:[(0,K.jsx)(`td`,{className:`w-10 px-3 py-3`,onClick:e=>e.stopPropagation(),children:i&&(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":_(`inventory.bulk.selectRow`),checked:!!r,onChange:i})}),f.map(r=>(0,K.jsx)(`td`,{className:`py-3 px-4`,children:A9[r]?.({spool:e,remaining:t,pct:n,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})},r)),(0,K.jsx)(`td`,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{onClick:a,className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:_(`common.edit`),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),o&&(0,K.jsx)(`button`,{onClick:o,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:_(`inventory.copySpool`),children:(0,K.jsx)(Ms,{className:`w-4 h-4`})}),u&&(0,K.jsx)(`button`,{onClick:u,className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:_(`inventory.labels.printOne`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),d&&e.weight_used>0&&(0,K.jsx)(`button`,{onClick:d,className:`p-1.5 text-bambu-gray hover:text-orange-400 rounded transition-colors`,title:_(`inventory.resetConsumedCounterTooltip`),children:(0,K.jsx)(qs,{className:`w-4 h-4`})}),e.archived_at?(0,K.jsx)(`button`,{onClick:s,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:_(`inventory.restore`),children:(0,K.jsx)(Al,{className:`w-4 h-4`})}):(0,K.jsx)(`button`,{onClick:c,className:`p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors`,title:_(`inventory.archive`),children:(0,K.jsx)(Oo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:l,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors`,title:_(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})}function OZe({spools:e,headerSpool:t,remaining:n,pct:r,isExpanded:i,onToggle:a,onEdit:o,onCopy:s,onArchive:c,onDelete:l,onPrintLabel:u,onResetConsumedCounter:d,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v,selectedIds:y,onToggleSelected:b,onToggleGroupSelected:x}){let S=!!y&&e.every(e=>y.has(e.id));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5`,onClick:a,children:[(0,K.jsx)(`td`,{className:`w-10 px-3 py-3`,onClick:e=>e.stopPropagation(),children:x&&(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":_(`inventory.bulk.selectGroup`),checked:S,onChange:t=>x(e.map(e=>e.id),t.target.checked)})}),f.map((a,o)=>(0,K.jsx)(`td`,{className:`py-3 px-4`,children:o===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?``:`-rotate-90`}`}),A9[a]?.({spool:t,remaining:n,pct:r,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})]}):a===`id`?(0,K.jsx)(`span`,{className:`text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full`,children:_(`inventory.groupedSpools`,{count:e.length})}):A9[a]?.({spool:t,remaining:n,pct:r,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})},a)),(0,K.jsx)(`td`,{className:`py-3 px-4`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.map(e=>`#${e.id}`).join(`, `)})})]}),i&&e.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(0,K.jsx)(DZe,{spool:e,remaining:t,pct:e.label_weight>0?t/e.label_weight*100:0,isSelected:y?.has(e.id),onToggleSelected:b?()=>b(e.id):void 0,onEdit:()=>o(e),onCopy:s?()=>s(e):void 0,onRestore:()=>{},onArchive:()=>c(e.id),onDelete:()=>l(e.id),onPrintLabel:u?()=>u(e.id):void 0,onResetConsumedCounter:d?()=>d(e.id):void 0,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v},e.id)})]})}function kZe({hasFilters:e,onAddSpool:t,t:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 px-4`,children:[(0,K.jsxs)(`div`,{className:`relative mb-6`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl`}),(0,K.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsx)(`div`,{className:`absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30`}),(0,K.jsx)(`div`,{className:`absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20`}),e?(0,K.jsx)(Rl,{className:`w-10 h-10 text-bambu-gray/40`,strokeWidth:1.5}):(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20`})}),(0,K.jsx)(`div`,{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md`,children:(0,K.jsx)(`span`,{className:`text-white text-lg font-bold leading-none`,children:`+`})})]})]})]}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2 text-center`,children:e?n(`inventory.noSpoolsMatch`):n(`inventory.noSpools`).split(`.`)[0]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center max-w-sm mb-6`,children:n(e?`inventory.noSpoolsMatchDesc`:`inventory.noSpools`)}),!e&&(0,K.jsxs)($,{onClick:t,children:[(0,K.jsx)(pl,{className:`w-4 h-4`}),n(`inventory.addSpool`)]})]})}function N9(e,t){let n=e?.[t];return typeof n==`string`?n:``}function AZe(e){return e.replace(/(https?:\/\/(?:makerworld|public-cdn)\.bblmw\.com\/[^\s"']+)/gi,e=>`/api/v1/makerworld/thumbnail?url=${encodeURIComponent(e)}`)}function P9(e){return e?/^https?:\/\/(makerworld|public-cdn)\.bblmw\.com\//i.test(e)?`/api/v1/makerworld/thumbnail?url=${encodeURIComponent(e)}`:e:``}function F9(e,t){let n=e?.[t];return typeof n==`number`?n:null}function jZe(e,t){let n=e?.[t];return n&&typeof n==`object`&&!Array.isArray(n)?n:void 0}function MZe(e,t=0,n=[]){n.push({folder:e,depth:t});for(let r of e.children??[])MZe(r,t+1,n);return n}function NZe(e,t){return t(e<1?`makerworld.phaseResolving`:`makerworld.phaseDownloading`)}function PZe(e){let[t,n]=(0,y.useState)(0);return(0,y.useEffect)(()=>{if(!e){n(0);return}let t=Date.now(),r=()=>n(Math.floor((Date.now()-t)/1e3));r();let i=window.setInterval(r,1e3);return()=>window.clearInterval(i)},[e]),t}function FZe(){let{t:e}=W(),{hasPermission:t}=dd(),{showToast:n}=Td(),r=no(),i=t(`makerworld:import`),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)({}),S=q({queryKey:[`makerworld-status`],queryFn:()=>Q.getMakerworldStatus()}),C=q({queryKey:[`library-folders`],queryFn:()=>Q.getLibraryFolders()}),w=q({queryKey:[`makerworld-recent-imports`],queryFn:()=>Q.getMakerworldRecentImports(10)}),T=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),E=T.data?.use_slicer_api??!1,D=T.data?.preferred_slicer||`bambu_studio`,O=T.data?.open_in_slicer||D,k=E?D:O,A=k===`orcaslicer`?`OrcaSlicer`:`Bambu Studio`,[j,M]=(0,y.useState)(null),N=(e,t)=>{M({kind:`libraryFile`,id:e,filename:t})},P=J({mutationFn:e=>Q.resolveMakerworldUrl(e),onSuccess:(e,t)=>{c(e),v(t),x({})},onError:t=>n(t.message||e(`makerworld.errors.resolveFailed`),`error`)});(0,y.useEffect)(()=>{s!==null&&a.trim()!==_.trim()&&(c(null),v(``),x({}))},[a,s,_]);let F=J({mutationFn:({instanceId:e,profileId:t})=>Q.importMakerworldInstance(s?.model_id??0,e,t,l),onSuccess:t=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),t.profile_id&&x(e=>({...e,[t.profile_id]:t})),n(t.was_existing?e(`makerworld.alreadyInLibrary`):e(`makerworld.importSuccess`,{filename:t.filename}),`success`)},onError:t=>n(t.message||e(`makerworld.errors.downloadFailed`),`error`)}),I=J({mutationFn:({libraryFileId:e})=>Q.deleteLibraryFile(e),onSuccess:(t,{profileId:i})=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),r.invalidateQueries({queryKey:[`makerworld-recent-imports`]}),x(e=>{let t={...e};return delete t[i],t}),m(null),n(e(`makerworld.importDeleted`),`success`)},onError:t=>{m(null),n(t.message||e(`makerworld.errors.deleteFailed`),`error`)}}),L=J({mutationFn:({instanceId:e,profileId:t})=>Q.importMakerworldInstance(s?.model_id??0,e,t,l),onSuccess:async e=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),r.invalidateQueries({queryKey:[`makerworld-recent-imports`]}),e.profile_id&&x(t=>({...t,[e.profile_id]:e})),E?N(e.library_file_id,e.filename):await te(e.library_file_id,e.filename,k)},onError:t=>n(t.message||e(`makerworld.errors.downloadFailed`),`error`)}),R=PZe(F.isPending||L.isPending),z=NZe(R,e),B=e=>{e?.preventDefault();let t=a.trim();t&&P.mutate(t)};(0,y.useEffect)(()=>{if(!h)return;let e=e=>{e.key===`Escape`?g(null):e.key===`ArrowLeft`?g(e=>e&&e.index>0?{...e,index:e.index-1}:e):e.key===`ArrowRight`&&g(e=>e&&e.indexwindow.removeEventListener(`keydown`,e)},[h]);let V=e=>{let t=(Array.isArray(e.pictures)?e.pictures:[]).filter(e=>typeof e==`object`&&!!e).map(e=>({name:N9(e,`name`)||`image`,url:N9(e,`url`)})).filter(e=>e.url);if(t.length>0)return t;let n=N9(e,`cover`);return n?[{name:`cover`,url:n}]:[]},ee=async()=>{if(!s)return;let e=s.instances.filter(e=>{let t=F9(e,`profileId`);return t!==null&&!b[t]});if(e.length!==0){f({current:0,total:e.length});try{for(let t=0;t{try{let{token:r}=await Q.createLibrarySlicerToken(e),i=Q.getLibrarySlicerDownloadUrl(e,r,t);VW(`${window.location.origin}${i}`,n)}catch{let t=Q.getLibraryFileDownloadUrl(e);VW(`${window.location.origin}${t}`,n)}},ne=s?.design,re=jZe(ne,`designCreator`),ie=s?.instances??[],H=(s?.already_imported_library_ids.length??0)>0,ae=S.data?.has_cloud_token??!1,oe=S.data?.can_download??!1,U=(0,y.useMemo)(()=>N9(ne,`coverUrl`),[ne]),se=N9(ne,`title`),ce=N9(ne,`summary`),le=N9(ne,`license`),ue=F9(ne,`downloadCount`);return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 max-w-screen-2xl space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(bc,{className:`w-7 h-7 text-bambu-green`}),e(`makerworld.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`makerworld.description`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[1fr_20rem]`,children:[(0,K.jsxs)(`div`,{className:`space-y-6 min-w-0`,children:[!ae&&(0,K.jsx)(_d,{className:`border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20`,children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-2`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-amber-600 dark:text-amber-400 mt-0.5 shrink-0`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`font-medium text-amber-900 dark:text-amber-100`,children:e(`makerworld.signInRequiredTitle`)}),(0,K.jsxs)(`p`,{className:`text-amber-800 dark:text-amber-200 mt-1`,children:[e(`makerworld.signInRequiredBody`),` `,(0,K.jsx)(wi,{to:`/profiles`,className:`underline`,children:e(`makerworld.openCloudSettings`)})]})]})]})})}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`makerworld.pasteUrlHeader`)})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`form`,{onSubmit:B,className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:e(`makerworld.pasteUrlPlaceholder`),className:`flex-1 min-w-0 px-3 py-2 border rounded bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700`,autoComplete:`off`}),(0,K.jsxs)($,{type:`submit`,variant:`primary`,disabled:!a.trim()||P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(No,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.resolveButton`)})]})]})})]}),s&&(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[U&&(0,K.jsx)(`img`,{src:P9(U),alt:se,className:`w-32 h-32 object-cover rounded`,loading:`lazy`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-xl font-semibold truncate`,children:se||e(`makerworld.untitledModel`)}),re&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-1`,children:e(`makerworld.byCreator`,{name:N9(re,`name`)})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 mt-2 text-xs text-gray-500 dark:text-gray-400`,children:[ue!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.downloadsCount`,{count:ue})}),le&&(0,K.jsxs)(`span`,{children:[e(`makerworld.licensePrefix`),`: `,le]}),H&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),` `,e(`makerworld.alreadyImported`)]})]}),ce&&(0,K.jsx)(`div`,{className:`mt-3 text-sm prose prose-sm max-w-none dark:prose-invert line-clamp-3`,dangerouslySetInnerHTML:{__html:VG.sanitize(AZe(ce))}}),s&&(0,K.jsxs)(`a`,{href:`https://makerworld.com/models/${s.model_id}${s.profile_id?`#profileId-${s.profile_id}`:``}`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-3 inline-flex items-center gap-1 text-xs text-brand-500 hover:underline`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),` `,e(`makerworld.openOnMakerworld`)]})]})]})})}),s&&ie.length>0&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`makerworld.platesHeader`,{count:ie.length})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-xs text-gray-600 dark:text-gray-400`,children:e(`makerworld.importTo`)}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`text-sm px-2 py-1 border rounded bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700`,disabled:d!==null,children:[(0,K.jsx)(`option`,{value:``,children:e(`makerworld.folderAuto`)}),(C.data??[]).filter(e=>!(e.is_external&&e.external_readonly)).flatMap(e=>MZe(e)).map(({folder:e,depth:t})=>(0,K.jsx)(`option`,{value:e.id,children:`${`— `.repeat(t)}${e.name}`},e.id))]}),(0,K.jsx)($,{variant:`primary`,size:`sm`,disabled:!i||!oe||d!==null||F.isPending||L.isPending,onClick:ee,children:d===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.importAll`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[e(`makerworld.importAllProgress`,{current:d.current,total:d.total}),R>0&&` · ${z} · ${R}s`]})]})})]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`grid gap-3`,children:ie.map((t,n)=>{let r=F9(t,`id`),a=F9(t,`profileId`),o=N9(t,`title`),s=N9(t,`cover`),c=F9(t,`materialCnt`),l=t?.needAms===!0,u=F9(t,`downloadCount`),f=t?.compatibility??null,p=t?.otherCompatibility??null,h=f?.devProductName??null,_=Array.isArray(p)?p.map(e=>e?.devProductName??``).filter(Boolean):[];if(r==null)return null;let v=F.isPending&&F.variables?.instanceId===r,y=L.isPending&&L.variables?.instanceId===r,x=a===null?void 0:b[a];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 border rounded border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(()=>{let n=V(t),r=n.length>0;return(0,K.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&g({images:n,index:0}),className:`relative w-16 h-16 shrink-0 rounded overflow-hidden group`,"aria-label":e(`makerworld.openGallery`),children:[s?(0,K.jsx)(`img`,{src:P9(s),alt:``,className:`w-16 h-16 object-cover`,loading:`lazy`}):(0,K.jsx)(`div`,{className:`w-16 h-16 bg-gray-100 dark:bg-gray-800`}),n.length>1&&(0,K.jsxs)(`span`,{className:`absolute bottom-0.5 right-0.5 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded flex items-center gap-1`,children:[(0,K.jsx)(Nc,{className:`w-2.5 h-2.5`}),n.length]})]})})(),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`font-medium truncate`,children:o||e(`makerworld.plateDefaultName`,{n:n+1})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-gray-500 dark:text-gray-400 mt-1`,children:[h&&(0,K.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`makerworld.slicedFor`,{printer:h,defaultValue:`Sliced for {{printer}}`})}),c!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.materialCount`,{count:c})}),l&&(0,K.jsx)(`span`,{children:e(`makerworld.amsRequired`)}),u!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.downloadsCount`,{count:u})})]}),_.length>0&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,title:_.join(`, `),children:e(`makerworld.alsoCompatible`,{printers:_.slice(0,6).join(`, `)+(_.length>6?`…`:``),defaultValue:`Also marked compatible: {{printers}}`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,disabled:!i||!oe||v||y||d!==null,onClick:()=>F.mutate({instanceId:r,profileId:a}),title:oe?void 0:e(`makerworld.signInRequiredTitle`),children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[z,R>0&&` · ${R}s`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.importToLibrary`)})]})}),(0,K.jsx)($,{variant:`primary`,size:`sm`,disabled:!i||!oe||v||y||d!==null,onClick:()=>L.mutate({instanceId:r,profileId:a}),title:oe?void 0:e(`makerworld.signInRequiredTitle`),children:y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[z,R>0&&` · ${R}s`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.sliceIn`,{slicer:A})})]})})]})]}),x&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pl-20 text-xs`,children:[(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-300`,children:x.was_existing?e(`makerworld.lastImportAlreadyInLibrary`):e(`makerworld.lastImportSuccess`)}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>{let e=x.folder_id?`/files?folder=${x.folder_id}`:`/files`;window.location.assign(e)},children:[(0,K.jsx)(cc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.viewInLibrary`)})]}),E?(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>N(x.library_file_id,x.filename),children:[(0,K.jsx)(ks,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`slice.action`,`Slice`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>te(x.library_file_id,x.filename,`bambu_studio`),children:[(0,K.jsx)(Js,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.openInBambuStudio`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>te(x.library_file_id,x.filename,`orcaslicer`),children:[(0,K.jsx)(Js,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.openInOrcaSlicer`)})]})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsx)($,{variant:`ghost`,size:`sm`,disabled:I.isPending&&I.variables?.profileId===a,onClick:()=>{a!==null&&m({libraryFileId:x.library_file_id,profileId:a,filename:x.filename})},title:e(`makerworld.deleteImport`),children:I.isPending&&I.variables?.profileId===a?(0,K.jsx)(X,{className:`w-3.5 h-3.5 animate-spin`}):(0,K.jsx)(bu,{className:`w-3.5 h-3.5 text-red-500`})})})]})]},r)})})})]})]}),(0,K.jsx)(`aside`,{className:`lg:sticky lg:top-6 lg:self-start min-w-0`,children:w.data&&w.data.length>0&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`makerworld.recentImportsHeader`)})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2 max-h-[28rem] overflow-y-auto -mx-2 px-2`,children:w.data.map(t=>(0,K.jsxs)(`div`,{className:`flex gap-2 p-2 border rounded border-gray-200 dark:border-gray-700`,children:[t.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getLibraryFileThumbnailUrl(t.library_file_id),alt:``,className:`w-12 h-12 shrink-0 object-cover rounded bg-gray-100 dark:bg-gray-800`,loading:`lazy`}):(0,K.jsx)(`div`,{className:`w-12 h-12 shrink-0 rounded bg-gray-100 dark:bg-gray-800`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium truncate`,title:t.filename,children:t.filename}),(0,K.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{let e=t.folder_id?`/files?folder=${t.folder_id}`:`/files`;window.location.assign(e)},title:e(`makerworld.viewInLibrary`),children:(0,K.jsx)(cc,{className:`w-3.5 h-3.5`})}),E?(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>N(t.library_file_id,t.filename),title:e(`slice.action`,`Slice`),children:(0,K.jsx)(ks,{className:`w-3.5 h-3.5`})}):(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>te(t.library_file_id,t.filename,`bambu_studio`),title:e(`makerworld.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}),t.source_url&&(0,K.jsx)(`a`,{href:t.source_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center h-7 w-7 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300`,title:e(`makerworld.openOnMakerworld`),children:(0,K.jsx)(bc,{className:`w-3.5 h-3.5`})})]})]})]},t.library_file_id))})})]})})]}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 pt-4 border-t border-gray-200 dark:border-gray-700`,children:e(`makerworld.disclaimer`)}),p&&(0,K.jsx)(Ad,{title:e(`makerworld.deleteImport`),message:e(`makerworld.confirmDelete`,{filename:p.filename}),confirmText:e(`makerworld.deleteImport`),variant:`danger`,isLoading:I.isPending,loadingText:e(`makerworld.importDeleting`),onCancel:()=>m(null),onConfirm:()=>I.mutate({libraryFileId:p.libraryFileId,profileId:p.profileId})}),j&&(0,K.jsx)(RW,{source:j,onClose:()=>M(null)}),h&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:()=>g(null),role:`dialog`,"aria-modal":`true`,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-4 right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white`,onClick:e=>{e.stopPropagation(),g(null)},"aria-label":e(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})}),h.images.length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute left-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white disabled:opacity-30`,disabled:h.index===0,onClick:e=>{e.stopPropagation(),g(e=>e&&{...e,index:Math.max(0,e.index-1)})},"aria-label":e(`makerworld.galleryPrev`),children:(0,K.jsx)(ss,{className:`w-6 h-6`})}),(0,K.jsx)(`button`,{type:`button`,className:`absolute right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white disabled:opacity-30`,disabled:h.index>=h.images.length-1,onClick:e=>{e.stopPropagation(),g(e=>e&&{...e,index:Math.min(e.images.length-1,e.index+1)})},"aria-label":e(`makerworld.galleryNext`),children:(0,K.jsx)(as,{className:`w-6 h-6`})})]}),(0,K.jsx)(`img`,{src:P9(h.images[h.index].url),alt:h.images[h.index].name,className:`max-w-[90vw] max-h-[90vh] object-contain`,onClick:e=>e.stopPropagation()}),h.images.length>1&&(0,K.jsxs)(`div`,{className:`absolute bottom-6 left-1/2 -translate-x-1/2 text-white bg-black/60 px-3 py-1 rounded text-xs`,children:[h.index+1,` / `,h.images.length]})]})]})}var IZe=[`DEBUG`,`INFO`,`WARNING`,`ERROR`],I9={DEBUG:`text-gray-400`,INFO:`text-blue-400`,WARNING:`text-yellow-400`,ERROR:`text-red-400`},LZe={DEBUG:Ko,INFO:Pc,WARNING:Cu,ERROR:ds};function RZe(){let e=no(),[t,n]=(0,y.useState)(!0),[r,i]=(0,y.useState)(new Set),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`ALL`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),p=(0,y.useRef)(null),{data:m,isLoading:h,refetch:g}=q({queryKey:[`application-logs`,s,a],queryFn:()=>ad.getLogs({limit:200,level:s===`ALL`?void 0:s,search:a||void 0}),refetchInterval:d?2e3:!1,enabled:l});(0,y.useEffect)(()=>{l||f(!1)},[l]);let _=J({mutationFn:()=>ad.clearLogs(),onSuccess:()=>{e.invalidateQueries({queryKey:[`application-logs`]})}});(0,y.useEffect)(()=>{t&&p.current&&m?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[m?.entries,t]);let v=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},b=e=>{let t=e.split(` `);return t.length>=2?t[1]:e},x=(0,y.useMemo)(()=>m?.entries??[],[m?.entries]),S=(0,y.useMemo)(()=>[...x].reverse(),[x]),C=({level:e})=>(0,K.jsx)(LZe[e]||Pc,{className:`w-3.5 h-3.5 ${I9[e]||`text-gray-400`}`});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(!l),className:`w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${d?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:(0,K.jsx)(Ko,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{className:`text-left`,children:[(0,K.jsx)(`p`,{className:`font-medium text-white`,children:`Application Logs`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:d?`Live streaming - ${m?.filtered_count??0} entries`:`View and filter application logs`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse`}),`Live`]}),l?(0,K.jsx)(cs,{className:`w-5 h-5 text-bambu-gray`}):(0,K.jsx)(is,{className:`w-5 h-5 text-bambu-gray`})]})]}),l&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[d?(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(!1)},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors`,children:[(0,K.jsx)(ou,{className:`w-4 h-4`}),`Stop`]}):(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(!0),g()},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors`,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),`Start`]}),(0,K.jsxs)(`button`,{onClick:()=>_.mutate(),disabled:_.isPending||x.length===0,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Clear`]}),(0,K.jsx)(`button`,{onClick:()=>g(),disabled:h,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h?`animate-spin`:``}`})}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary`}),`Auto-scroll`]}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[m?.filtered_count??0,`/`,m?.total_in_file??0]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Search message or logger name...`,value:a,onChange:e=>o(e.target.value),className:`w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),a&&(0,K.jsx)(`button`,{onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>c(`ALL`),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${s===`ALL`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`All`}),IZe.map((e,t)=>(0,K.jsx)(`button`,{onClick:()=>c(e),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${t===IZe.length-1?`rounded-r`:``} ${s===e?`${I9[e]} bg-bambu-dark-tertiary`:`text-bambu-gray hover:text-white`}`,children:e},e))]})]})]}),(0,K.jsx)(`div`,{ref:p,className:`overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]`,children:x.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[300px] text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:`No log entries found`}),(0,K.jsx)(`p`,{className:`text-sm`,children:`Log file may be empty or cleared`})]}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary/30`,children:S.map((e,t)=>{let n=r.has(t),i=e.message.includes(` +`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return FJe(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var zYe={tokenize:qYe,partial:!0};function BYe(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:WYe,continuation:{tokenize:GYe},exit:KYe}},text:{91:{name:`gfmFootnoteCall`,tokenize:UYe},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:VYe,resolveTo:HYe}}}}function VYe(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=M8(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function HYe(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function UYe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||R8(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(M8(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return R8(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function WYe(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||R8(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=M8(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return R8(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),W8(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function GYe(e,t,n){return e.check(X8,t,e.attempt(zYe,t,n))}function KYe(e){e.exit(`gfmFootnoteDefinition`)}function qYe(e,t,n){let r=this;return W8(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function JYe(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=K8(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var YYe=class{constructor(){this.map=[]}add(e,t,n){XYe(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function XYe(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):L8(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):z8(t)?W8(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||R8(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,z8(t)?W8(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return z8(t)?W8(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||L8(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return z8(t)?W8(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||L8(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||L8(n)?(e.exit(`tableRow`),t(n)):z8(n)?W8(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||R8(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function eXe(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new YYe;for(;++nn[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Q7(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function Z7(e,t,n,r,i){let a=[],o=Q7(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Q7(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tXe={name:`tasklistCheck`,tokenize:rXe};function nXe(){return{text:{91:tXe}}}function rXe(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return R8(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return L8(r)?t(r):z8(r)?e.check({tokenize:iXe},t,n)(r):n(r)}}function iXe(e,t,n){return W8(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function aXe(e){return A8([AYe(),BYe(),JYe(e),QYe(),nXe()])}var oXe={};function sXe(e){let t=this,n=e||oXe,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(aXe(n)),a.push(EYe()),o.push(DYe(n))}function cXe({folderId:e}){let{t}=W(),[n,r]=(0,y.useState)(!1),{data:i,isLoading:a,error:o}=q({queryKey:[`folder-readme`,e],queryFn:()=>Q.getLibraryFolderReadme(e),retry:!1,staleTime:3e4});return a||o||!i?null:(0,K.jsxs)(`div`,{className:`mb-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-center justify-between gap-2 px-3 py-2 text-left hover:bg-bambu-dark/40 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,title:i.filename,children:i.filename}),i.truncated&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 flex-shrink-0`,children:t(`fileManager.readme.truncated`)})]}),n?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}):(0,K.jsx)(cs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`})]}),!n&&(0,K.jsx)(`div`,{className:`px-4 py-3 border-t border-bambu-dark-tertiary max-h-96 overflow-y-auto text-sm text-bambu-gray-light leading-relaxed space-y-2`,children:(0,K.jsx)(Jqe,{remarkPlugins:[sXe],components:{h1:({children:e})=>(0,K.jsx)(`h1`,{className:`text-lg font-semibold text-white mt-2 mb-1`,children:e}),h2:({children:e})=>(0,K.jsx)(`h2`,{className:`text-base font-semibold text-white mt-2 mb-1`,children:e}),h3:({children:e})=>(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white mt-2 mb-1`,children:e}),p:({children:e})=>(0,K.jsx)(`p`,{className:`my-1`,children:e}),ul:({children:e})=>(0,K.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5 ml-2`,children:e}),ol:({children:e})=>(0,K.jsx)(`ol`,{className:`list-decimal list-inside space-y-0.5 ml-2`,children:e}),li:({children:e})=>(0,K.jsx)(`li`,{children:e}),code:({children:e,...t})=>t.className?(0,K.jsx)(`code`,{className:`block p-2 bg-bambu-dark rounded text-xs font-mono text-bambu-gray-light overflow-x-auto`,children:e}):(0,K.jsx)(`code`,{className:`px-1 py-0.5 bg-bambu-dark rounded text-xs font-mono text-bambu-green`,children:e}),pre:({children:e})=>(0,K.jsx)(`pre`,{className:`my-2`,children:e}),blockquote:({children:e})=>(0,K.jsx)(`blockquote`,{className:`border-l-2 border-bambu-dark-tertiary pl-3 text-bambu-gray italic`,children:e}),a:({children:e,href:t})=>(0,K.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`text-bambu-green hover:underline`,children:e}),table:({children:e})=>(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsx)(`table`,{className:`min-w-full text-xs border-collapse`,children:e})}),th:({children:e})=>(0,K.jsx)(`th`,{className:`border border-bambu-dark-tertiary px-2 py-1 text-left font-semibold text-white`,children:e}),td:({children:e})=>(0,K.jsx)(`td`,{className:`border border-bambu-dark-tertiary px-2 py-1`,children:e}),hr:()=>(0,K.jsx)(`hr`,{className:`border-bambu-dark-tertiary my-2`})},children:i.content})})]})}function lXe({open:e,onClose:t,onPickTag:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),{data:m=[],isLoading:h}=q({queryKey:M6,queryFn:Q.getLibraryTags,enabled:e}),g=()=>{i.invalidateQueries({queryKey:M6}),i.invalidateQueries({queryKey:[`library-files`]})},_=J({mutationFn:async()=>{let e=u.trim();if(!e)throw Error(r(`fileManager.tags.nameRequired`));return c?Q.updateLibraryTag(c.id,e):Q.createLibraryTag(e)},onSuccess:()=>{a(r(c?`fileManager.tags.updated`:`fileManager.tags.created`),`success`),s(!1),l(null),d(``),g()},onError:e=>{a(e.message||r(`fileManager.tags.saveFailed`),`error`)}}),v=J({mutationFn:e=>Q.deleteLibraryTag(e),onSuccess:()=>{a(r(`fileManager.tags.deleted`),`success`),p(null),g()},onError:e=>{a(e.message||r(`fileManager.tags.deleteFailed`),`error`)}}),b=()=>{l(null),d(``),s(!0)},x=e=>{l(e),d(e.name),s(!0)},S=(0,y.useCallback)(()=>{_.isPending||(s(!1),l(null),d(``))},[_.isPending]);(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(_.isPending||v.isPending||(o?S():f||t()))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,o,f,_.isPending,v.isPending,S,t]);let C=e=>{e.preventDefault(),_.mutate()};if(!e)return null;let w=`library-tags-modal-title`,T=`library-tag-editor-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>{_.isPending||v.isPending||t()}}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-4xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":w,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`h2`,{id:w,className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(fu,{className:`w-5 h-5 text-bambu-green`}),r(`fileManager.tags.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-0.5`,children:r(`fileManager.tags.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:b,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`fileManager.tags.add`)]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:t,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin mr-2`}),r(`common.loading`)]}):m.length===0?(0,K.jsx)(`div`,{className:`py-16 text-center text-bambu-gray`,children:r(`fileManager.tags.empty`)}):(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:r(`fileManager.tags.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right`,children:r(`fileManager.tags.fileCount`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right w-32`,children:r(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:m.map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 hover:bg-bambu-dark-tertiary/30 ${n?`cursor-pointer`:``}`,onClick:()=>{n&&(n(e.id),t())},children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white font-medium`,children:e.name}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right text-bambu-gray`,children:e.file_count}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded`,onClick:()=>x(e),title:r(`common.edit`),"aria-label":r(`fileManager.tags.editAria`,{name:e.name}),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded`,onClick:()=>p(e),title:r(`common.delete`),"aria-label":r(`fileManager.tags.deleteAria`,{name:e.name}),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},e.id))})]})})]}),o&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:S}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 shadow-2xl`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":T,children:[(0,K.jsx)(`h3`,{id:T,className:`text-lg font-semibold text-white mb-4`,children:r(c?`fileManager.tags.edit`:`fileManager.tags.add`)}),(0,K.jsxs)(`form`,{onSubmit:C,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`library-tag-name`,children:r(`fileManager.tags.name`)}),(0,K.jsx)(`input`,{id:`library-tag-name`,type:`text`,maxLength:64,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green mb-4`,placeholder:r(`fileManager.tags.createPlaceholder`),value:u,onChange:e=>d(e.target.value),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:S,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:_.isPending||!u.trim(),children:[_.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.save`)]})]})]})]})]}),f&&(0,K.jsx)(Ad,{title:r(`fileManager.tags.confirmDelete`,{name:f.name}),message:f.file_count>0?r(`fileManager.tags.confirmDeleteInUseMessage`,{count:f.file_count}):r(`fileManager.tags.confirmDeleteMessage`),confirmText:r(`common.delete`),variant:`danger`,isLoading:v.isPending,onConfirm:()=>v.mutate(f.id),onCancel:()=>p(null)})]})}var uXe=90;function dXe({onClose:e}){let{t}=W(),n=no(),{showToast:r}=Td(),[i,a]=(0,y.useState)(uXe),[o,s]=(0,y.useState)(!0),[c,l]=(0,y.useState)(i);(0,y.useEffect)(()=>{let e=window.setTimeout(()=>l(i),300);return()=>window.clearTimeout(e)},[i]);let u=q({queryKey:[`library-purge-preview`,c,o],queryFn:()=>Q.previewLibraryPurge(c,o),enabled:c>=1}),d=J({mutationFn:()=>Q.executeLibraryPurge(i,o),onSuccess:i=>{r(t(`libraryPurge.toast.success`,{count:i.moved_to_trash}),`success`),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]}),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),e()},onError:e=>r(e.message||t(`libraryPurge.toast.failed`),`error`)});(0,y.useEffect)(()=>{let t=t=>{t.key===`Escape`&&!d.isPending&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,d.isPending]);let f=u.data,p=f?.count??0,m=f?.total_bytes??0,h=p>0&&!d.isPending;return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-white dark:bg-gray-900 rounded-lg shadow-xl max-w-lg w-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2`,children:[(0,K.jsx)(bu,{className:`w-5 h-5`}),t(`libraryPurge.title`)]}),(0,K.jsx)(`button`,{onClick:e,className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-200`,"aria-label":t(`common.close`),disabled:d.isPending,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:t(`libraryPurge.description`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`purge-days`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:t(`libraryPurge.ageLabel`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`input`,{id:`purge-days`,type:`number`,min:1,max:3650,value:i,onChange:e=>a(Math.max(1,Math.min(3650,parseInt(e.target.value||`0`,10)||0))),className:`w-24 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:t(`libraryPurge.days`)})]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-gray-700 dark:text-gray-300`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`rounded border-gray-300`}),t(`libraryPurge.includeNeverPrinted`)]}),(0,K.jsxs)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/30 p-3`,children:[(0,K.jsx)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-600 dark:text-gray-300 mb-2`,children:t(`libraryPurge.effectsTitle`)}),(0,K.jsxs)(`ul`,{className:`text-xs text-gray-700 dark:text-gray-300 space-y-1 list-disc pl-4`,children:[(0,K.jsx)(`li`,{children:t(`libraryPurge.effect1`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect2`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect3`)}),(0,K.jsx)(`li`,{children:t(`libraryPurge.effect4`)})]})]}),(0,K.jsx)(`div`,{className:`rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50 p-3`,children:u.isLoading||u.isFetching?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,t(`libraryPurge.previewLoading`)]}):u.isError?(0,K.jsx)(`div`,{className:`text-sm text-red-600 dark:text-red-400`,children:u.error?.message??t(`libraryPurge.previewFailed`)}):(0,K.jsxs)(`div`,{className:`text-sm text-gray-900 dark:text-gray-100`,children:[(0,K.jsx)(`div`,{className:`font-medium`,children:t(`libraryPurge.previewSummary`,{count:p,size:Cd(m)})}),f?.sample_filenames&&f.sample_filenames.length>0&&(0,K.jsxs)(`ul`,{className:`mt-2 text-xs text-gray-600 dark:text-gray-400 space-y-0.5 list-disc pl-4`,children:[f.sample_filenames.map(e=>(0,K.jsx)(`li`,{className:`truncate`,children:e},e)),p>f.sample_filenames.length&&(0,K.jsx)(`li`,{className:`list-none italic text-gray-500`,children:t(`libraryPurge.andMore`,{count:p-f.sample_filenames.length})})]})]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-start text-xs text-amber-700 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 rounded px-3 py-2`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 mt-0.5 shrink-0`}),(0,K.jsx)(`span`,{children:t(`libraryPurge.warning`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 p-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:d.isPending,children:t(`common.cancel`)}),(0,K.jsx)($,{variant:`danger`,disabled:!h,onClick:()=>d.mutate(),children:d.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mr-1`}),t(`libraryPurge.purging`)]}):t(`libraryPurge.confirmCta`,{count:p})})]})]})})}function fXe({parentId:e,onClose:t,onSave:n,isLoading:r,t:i}){let[a,o]=(0,y.useState)(``);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`fileManager.newFolder`)})}),(0,K.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),n({name:a.trim(),parent_id:e})},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:i(`fileManager.folderName`)}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:i(`fileManager.folderNamePlaceholder`),autoFocus:!0,required:!0})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:t,children:i(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!a.trim()||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`common.create`)})]})]})]})})}function pXe({onClose:e,onSave:t,isLoading:n,t:r}){let[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(!1);return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(uc,{className:`w-5 h-5 text-bambu-green`}),r(`fileManager.linkExternalFolder`)]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:r(`fileManager.linkExternalFolderDescription`)})]}),(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),t({name:i.trim(),external_path:o.trim(),readonly:c,show_hidden:u})},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:r(`fileManager.folderName`)}),(0,K.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`,placeholder:r(`fileManager.externalFolderNamePlaceholder`),autoFocus:!0,required:!0})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:r(`fileManager.externalPath`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-3 py-2 text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green font-mono text-sm`,placeholder:`/mnt/nas/3d-prints`,required:!0}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`fileManager.externalPathHelp`)})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:r(`fileManager.readOnly`)}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`(`,r(`fileManager.readOnlyHelp`),`)`]})]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:u,onChange:e=>d(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:r(`fileManager.showHiddenFiles`)})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:e,children:r(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!i.trim()||!o.trim()||n,children:n?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):r(`fileManager.linkFolder`)})]})]})]})})}var mXe=`<>:"/\\|?*`;function hXe(e){for(let t of e)if(mXe.includes(t)||t.charCodeAt(0)<32)return t;return null}function gXe({type:e,currentName:t,onClose:n,onSave:r,isLoading:i,t:a}){let o=e===`file`?t.match(/(\.gcode\.3mf|\.3mf|\.gcode)$/i)?.[1]??``:``,s=e===`file`&&o?t.slice(0,-o.length):t,[c,l]=(0,y.useState)(s),u=e===`file`?hXe(c):null,d=u?a(`fileManager.invalidFilenameChar`,{char:u}):null;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(e===`file`?`fileManager.renameFile`:`fileManager.renameFolder`)})}),(0,K.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),d)return;let i=e===`file`?c.trim()+o:c.trim();c.trim()&&i!==t&&r(i)},className:`p-4 space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-1`,children:a(`common.name`)}),(0,K.jsxs)(`div`,{className:`flex items-center bg-bambu-dark border rounded focus-within:border-bambu-green ${d?`border-red-500`:`border-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`flex-1 bg-transparent px-3 py-2 text-white placeholder-bambu-gray focus:outline-none min-w-0`,autoFocus:!0,required:!0}),o&&(0,K.jsx)(`span`,{className:`pr-3 text-bambu-gray text-sm select-none whitespace-nowrap`,children:o})]}),d&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:d})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:n,children:a(`common.cancel`)}),(0,K.jsx)($,{type:`submit`,disabled:!c.trim()||c.trim()===s||!!d||i,children:i?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):a(`common.rename`)})]})]})]})})}function _Xe({folders:e,selectedFiles:t,currentFolderId:n,onClose:r,onMove:i,isLoading:a,t:o}){let[s,c]=(0,y.useState)(null),l=(e,t=0)=>{let n=[];for(let r of e)n.push({id:r.id,name:r.name,depth:t}),r.children.length>0&&n.push(...l(r.children,t+1));return n},u=[{id:null,name:o(`fileManager.rootNoFolder`),depth:0},...l(e)];return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:o(`fileManager.moveFiles`,{count:t.length})})}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-1`,children:u.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),disabled:e.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:e.id===n?`opacity-50 cursor-not-allowed text-bambu-gray`:`hover:bg-bambu-dark text-white`}`,style:{paddingLeft:`${12+e.depth*16}px`},children:[(0,K.jsx)(cc,{className:`w-4 h-4`}),e.name,e.id===n&&(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray ml-auto`,children:[`(`,o(`fileManager.current`),`)`]})]},e.id??`root`))}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:r,children:o(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>i(s),disabled:a,children:a?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):o(`common.move`)})]})]})]})})}function vXe({folder:e,onClose:t,onLink:n,isLoading:r,t:i}){let[a,o]=(0,y.useState)(`project`),[s,c]=(0,y.useState)(e.project_id||e.archive_id||null);(0,y.useState)(()=>{e.archive_id&&o(`archive`)});let{data:l}=q({queryKey:[`projects`],queryFn:()=>Q.getProjects(),select:e=>[...e].sort((e,t)=>e.name.localeCompare(t.name))}),{data:u}=q({queryKey:[`archives-for-link`],queryFn:()=>Q.getArchives(void 0,void 0,100)}),d=()=>{n(a===`project`?{project_id:s,archive_id:0}:{project_id:0,archive_id:s})},f=()=>{n({project_id:0,archive_id:0})},p=e.project_id||e.archive_id;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green`}),i(`fileManager.linkFolder`)]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i(`fileManager.linkFolderDescription`,{name:e.name})}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>{o(`project`),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a===`project`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Go,{className:`w-4 h-4`}),i(`fileManager.project`)]}),(0,K.jsxs)(`button`,{onClick:()=>{o(`archive`),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${a===`archive`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Oo,{className:`w-4 h-4`}),i(`fileManager.archive`)]})]}),(0,K.jsx)(`div`,{className:`max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2`,children:a===`project`?l&&l.length>0?l.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark-tertiary text-white`}`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full flex-shrink-0`,style:{backgroundColor:e.color||`#00ae42`}}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id)):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-4`,children:i(`fileManager.noProjectsFound`)}):u&&u.length>0?u.map(e=>(0,K.jsxs)(`button`,{onClick:()=>c(e.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${s===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark-tertiary text-white`}`,children:[(0,K.jsx)(Qs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.print_name||e.filename})]},e.id)):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center py-4`,children:i(`fileManager.noArchivesFound`)})})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-between`,children:[p&&(0,K.jsxs)($,{variant:`danger`,onClick:f,disabled:r,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 mr-2`}),i(`fileManager.unlink`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2 ${p?``:`ml-auto`}`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:i(`common.cancel`)}),(0,K.jsx)($,{onClick:d,disabled:!s||r,children:r?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):i(`fileManager.link`)})]})]})]})})}function $7({folder:e,selectedFolderId:t,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:s=!1,defaultExpanded:c=!0,hasPermission:l,t:u}){let[d,f]=(0,y.useState)(c),[p,m]=(0,y.useState)(!1),h=e.children.length>0,g=e.project_id||e.archive_id,_=e.is_external;return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1.5 rounded cursor-pointer transition-colors ${t===e.id?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,style:{paddingLeft:`${8+o*12}px`},onClick:()=>n(e.id),children:[h?(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),f(!d)},className:`p-0.5 hover:bg-bambu-dark-tertiary rounded`,children:(0,K.jsx)(as,{className:`w-3.5 h-3.5 transition-transform ${d?`rotate-90`:``}`})}):(0,K.jsx)(`div`,{className:`w-4.5`}),_?(0,K.jsx)(uc,{className:`w-4 h-4 text-purple-400 flex-shrink-0`}):(0,K.jsx)(cc,{className:`w-4 h-4 text-bambu-green flex-shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm flex-1 min-w-0 ${s?`break-all`:`truncate`}`,title:e.name,children:e.name}),g&&(0,K.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),i(e)},className:`flex-shrink-0 flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors`,title:`${e.project_name?`Project: ${e.project_name}`:`Archive: ${e.archive_name}`} (click to change)`,children:[(0,K.jsx)(Vc,{className:`w-3 h-3`}),e.project_name?(0,K.jsx)(Go,{className:`w-3 h-3`}):(0,K.jsx)(Oo,{className:`w-3 h-3`})]}),_&&e.external_readonly&&(0,K.jsx)(`span`,{title:u(`fileManager.readOnly`),children:(0,K.jsx)(qc,{className:`w-3 h-3 text-amber-400 flex-shrink-0`})}),e.file_count>0&&(0,K.jsx)(`span`,{className:`flex-shrink-0 text-xs text-bambu-gray`,children:e.file_count}),!g&&!_&&(0,K.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e)},className:`flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary`,title:u(`fileManager.linkToProjectOrArchive`),children:(0,K.jsx)(Vc,{className:`w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green`})}),(0,K.jsx)(`div`,{className:`flex-shrink-0 flex items-center gap-0.5 transition-opacity ${s?``:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`button`,{onClick:()=>m(!p),className:`p-1 rounded hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ws,{className:`w-3.5 h-3.5 text-bambu-gray`})}),p&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>m(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[120px]`,children:[(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:update_all`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:update_all`)&&(a(e),m(!1))},disabled:!l(`library:update_all`),title:l(`library:update_all`)?void 0:u(`fileManager.noPermissionRenameFolder`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5`}),u(`common.rename`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:update_all`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:update_all`)&&(i(e),m(!1))},disabled:!l(`library:update_all`),title:l(`library:update_all`)?void 0:u(`fileManager.noPermissionLinkFolder`),children:[(0,K.jsx)(Vc,{className:`w-3.5 h-3.5`}),u(g?`fileManager.changeLink`:`fileManager.linkTo`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${l(`library:delete_all`)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{l(`library:delete_all`)&&(r(e.id),m(!1))},disabled:!l(`library:delete_all`),title:l(`library:delete_all`)?void 0:u(`fileManager.noPermissionDeleteFolder`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),u(`common.delete`)]})]})]})]})})]}),h&&d&&(0,K.jsx)(`div`,{children:e.children.map(e=>(0,K.jsx)($7,{folder:e,selectedFolderId:t,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:s,defaultExpanded:c,hasPermission:l,t:u},e.id))})]})}function e9(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)}function t9(e){let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.endsWith(`.gcode.3mf`)?!1:t.endsWith(`.stl`)||t.endsWith(`.3mf`)||t.endsWith(`.step`)||t.endsWith(`.stp`)}function yXe({file:e,isSelected:t,isMobile:n,onSelect:r,onDelete:i,onDownload:a,onAddToQueue:o,onPrint:s,onSlice:c,useSlicerApi:l,onPreview3d:u,onRename:d,onGenerateThumbnail:f,onTagClick:p,thumbnailVersion:m,hasPermission:h,canModify:g,authEnabled:_,t:v}){let[b,x]=(0,y.useState)(!1);return(0,K.jsxs)(`div`,{className:`group relative bg-bambu-dark-secondary rounded-lg border transition-all cursor-pointer overflow-hidden ${t?`border-bambu-green ring-1 ring-bambu-green`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,onClick:()=>r(e.id),children:[(0,K.jsxs)(`div`,{className:`aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden`,children:[e.thumbnail_path?(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(e.id)}${m?(Q.getLibraryFileThumbnailUrl(e.id).includes(`?`)?`&`:`?`)+`v=${m}`:``}`,alt:e.filename,className:`w-full h-full object-cover`}):(0,K.jsx)(Qs,{className:`w-12 h-12 text-bambu-gray/30`}),(0,K.jsx)(`div`,{className:`absolute top-2 right-2 text-xs px-1.5 py-0.5 rounded font-medium ${e.file_type===`3mf`?`bg-bambu-green/90 text-white`:e.file_type===`gcode`||e.file_type===`gcode.3mf`?`bg-blue-500/90 text-white`:e.file_type===`stl`?`bg-purple-500/90 text-white`:`bg-bambu-gray/90 text-white`}`,children:e.file_type.toUpperCase()})]}),(0,K.jsxs)(`div`,{className:`p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-white truncate`,title:e.print_name||e.filename,children:e.print_name||e.filename}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-1 text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:Cd(e.file_size)}),e.print_time_seconds&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),Cf(e.print_time_seconds)]})]}),e.sliced_for_model&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Tl,{className:`w-3 h-3`}),e.sliced_for_model]}),e.print_count>0&&(0,K.jsx)(`div`,{className:`mt-1 text-xs text-bambu-green`,children:v(`fileManager.printedCount`,{count:e.print_count})}),_&&e.created_by_username&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray flex items-center gap-1`,children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),e.created_by_username]}),(e.tags?.length??0)>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,onClick:e=>e.stopPropagation(),children:e.tags.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>p?.(e.id),className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[10px] bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20 transition-colors max-w-full`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-2.5 h-2.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`absolute bottom-2 right-2 transition-opacity ${n?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{onClick:()=>x(!b),className:`p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary`,children:(0,K.jsx)(Ws,{className:`w-4 h-4 text-bambu-gray`})}),b&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>x(!1)}),(0,K.jsxs)(`div`,{className:`absolute right-0 bottom-8 z-20 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl py-1 min-w-[140px]`,children:[s&&e9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`printers:control`)?`text-bambu-green hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`printers:control`)&&(s(e),x(!1))},disabled:!h(`printers:control`),title:h(`printers:control`)?void 0:v(`fileManager.noPermissionPrint`),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5`}),v(`common.print`)]}),o&&e9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`queue:create`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`queue:create`)&&(o(e.id),x(!1))},disabled:!h(`queue:create`),title:h(`queue:create`)?void 0:v(`fileManager.noPermissionAddToQueue`),children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),v(`fileManager.schedulePrint`)]}),c&&l&&t9(e.filename)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:upload`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:upload`)&&(c(e),x(!1))},disabled:!h(`library:upload`),title:h(`library:upload`)?void 0:v(`fileManager.noPermissionSlice`),children:[(0,K.jsx)(ks,{className:`w-3.5 h-3.5`}),v(`slice.action`)]}),u&&(e.file_type===`3mf`||e.file_type===`gcode`||e.file_type===`stl`||e.file_type===`gcode.3mf`)&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:read`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:read`)&&(u(e),x(!1))},disabled:!h(`library:read`),title:h(`library:read`)?void 0:`You do not have permission to preview files`,children:[(0,K.jsx)(Wo,{className:`w-3.5 h-3.5`}),`3D Preview`]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${h(`library:read`)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{h(`library:read`)&&(a(e.id),x(!1))},disabled:!h(`library:read`),title:h(`library:read`)?void 0:v(`fileManager.noPermissionDownload`),children:[(0,K.jsx)(Vs,{className:`w-3.5 h-3.5`}),v(`common.download`)]}),d&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`update`,e.created_by_id)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`update`,e.created_by_id)&&(d(e),x(!1))},disabled:!g(`library`,`update`,e.created_by_id),title:g(`library`,`update`,e.created_by_id)?void 0:v(`fileManager.noPermissionRenameFile`),children:[(0,K.jsx)(vl,{className:`w-3.5 h-3.5`}),v(`common.rename`)]}),f&&e.file_type===`stl`&&(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`update`,e.created_by_id)?`text-white hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`update`,e.created_by_id)&&(f(e),x(!1))},disabled:!g(`library`,`update`,e.created_by_id),title:g(`library`,`update`,e.created_by_id)?void 0:v(`fileManager.noPermissionGenerateThumbnail`),children:[(0,K.jsx)(Mc,{className:`w-3.5 h-3.5`}),v(`fileManager.generateThumbnail`)]}),(0,K.jsxs)(`button`,{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${g(`library`,`delete`,e.created_by_id)?`text-red-400 hover:bg-bambu-dark`:`text-bambu-gray cursor-not-allowed`}`,onClick:()=>{g(`library`,`delete`,e.created_by_id)&&(i(e.id),x(!1))},disabled:!g(`library`,`delete`,e.created_by_id),title:g(`library`,`delete`,e.created_by_id)?void 0:v(`fileManager.noPermissionDeleteFile`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),v(`common.delete`)]})]})]})]}),(0,K.jsx)(`div`,{className:`absolute top-2 left-2 w-5 h-5 rounded border-2 flex items-center justify-center transition-all ${t?`bg-bambu-green border-bambu-green`:`border-white/30 bg-black/30 ${n?`opacity-100`:`opacity-0 group-hover:opacity-100`}`}`,children:t&&(0,K.jsx)(`div`,{className:`w-2 h-2 bg-white rounded-sm`})})]})}function bXe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,hasAnyPermission:i,canModify:a,authEnabled:o}=dd(),[s]=Mi(),c=$n(),l=s.get(`folder`),[u,d]=(0,y.useState)(l?parseInt(l,10):null),[f,p]=(0,y.useState)(`internal`),[m,h]=(0,y.useState)([]),[g,_]=(0,y.useState)(!1),[v,b]=(0,y.useState)(!1),[x,S]=(0,y.useState)(!1),[C,w]=(0,y.useState)(!1),[T,E]=(0,y.useState)([]),[D,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(!1),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)([]),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(null),[z,B]=(0,y.useState)(null),[V,ee]=(0,y.useState)(null),[te,ne]=(0,y.useState)(null),[re,ie]=(0,y.useState)(null),[H,ae]=(0,y.useState)(null),[oe,U]=(0,y.useState)({}),[se,ce]=(0,y.useState)(null),[le,ue]=(0,y.useState)(()=>localStorage.getItem(`library-view-mode`)||`grid`),[de,fe]=(0,y.useState)(()=>localStorage.getItem(`library-wrap-folders`)===`true`),[pe,me]=(0,y.useState)(()=>localStorage.getItem(`library-collapse-folders`)===`true`),[he,ge]=(0,y.useState)(()=>localStorage.getItem(`library-folder-sort-field`)===`activity`?`activity`:`name`),[_e,ve]=(0,y.useState)(()=>localStorage.getItem(`library-folder-sort-direction`)===`desc`?`desc`:`asc`),[ye,be]=(0,y.useState)(()=>{let e=localStorage.getItem(`library-sidebar-width`);return e?parseInt(e,10):256}),[xe,Se]=(0,y.useState)(!1),Ce=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!xe)return;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let e=e=>{if(!Ce.current)return;let t=Ce.current.parentElement?.getBoundingClientRect();if(!t)return;let n=e.clientX-t.left;be(Math.min(500,Math.max(200,n)))},t=()=>{Se(!1),document.body.style.userSelect=``,document.body.style.cursor=``,localStorage.setItem(`library-sidebar-width`,String(ye))};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.userSelect=``,document.body.style.cursor=``}},[xe,ye]);let[we,Te]=(0,y.useState)(``),[Ee,De]=(0,y.useState)(`all`),[Oe,ke]=(0,y.useState)(``),[Ae,je]=(0,y.useState)(()=>localStorage.getItem(`library-sort-field`)||`name`),[Me,Ne]=(0,y.useState)(()=>localStorage.getItem(`library-sort-direction`)||`asc`),Pe=WW();(0,y.useEffect)(()=>{let e=s.get(`folder`);e&&d(parseInt(e,10))},[s]);let{data:Fe}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),{data:Ie,isLoading:Le}=q({queryKey:[`library-folders`],queryFn:()=>Q.getLibraryFolders()}),Re=(0,y.useMemo)(()=>{if(!Ie)return Ie;let e=t=>[...t].sort((e,t)=>{let n=0;if(he===`name`)n=e.name.localeCompare(t.name);else{let r=e.latest_activity_at?new Date(e.latest_activity_at).getTime():null,i=t.latest_activity_at?new Date(t.latest_activity_at).getTime():null;if(r===null&&i===null)n=e.name.localeCompare(t.name);else if(r===null)return 1;else if(i===null)return-1;else n=r-i}return _e===`asc`?n:-n}).map(t=>({...t,children:e(t.children)}));return e(Ie)},[Ie,he,_e]),{data:ze}=q({queryKey:[`library-trash-count`],queryFn:async()=>{try{return(await Q.listLibraryTrash(1,0)).total}catch{return 0}},staleTime:3e4}),Be=u!==null&&we.trim().length>0,Ve=(0,y.useMemo)(()=>[...N].sort((e,t)=>e-t),[N]),{data:He=[]}=q({queryKey:[`library-tags`],queryFn:Q.getLibraryTags}),Ue=(0,y.useMemo)(()=>{let e=new Map;for(let t of He)e.set(t.id,t.name);return e},[He]);(0,y.useEffect)(()=>{He.length!==0&&P(e=>{let t=e.filter(e=>Ue.has(e));return t.length===e.length?e:t})},[He.length,Ue]);let We=(0,y.useCallback)(e=>{P(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),{data:Ge,isLoading:Ke}=q({queryKey:[`library-files`,u,f,Be,Ve],queryFn:()=>Q.getLibraryFiles(u,!1,void 0,u===null?f:void 0,Be,Ve)}),{data:qe}=q({queryKey:[`library-stats`],queryFn:()=>Q.getLibraryStats()}),{data:Je}=q({queryKey:[`users`],queryFn:()=>Q.getUsers()}),Ye=(0,y.useMemo)(()=>{if(!Ge)return[];let e=new Set(Ge.map(e=>e.file_type));return Array.from(e).sort()},[Ge]),Xe=(0,y.useMemo)(()=>{if(!Ge)return[];let e=[...Ge];if(we.trim()){let t=we.toLowerCase();e=e.filter(e=>e.filename.toLowerCase().includes(t)||e.print_name&&e.print_name.toLowerCase().includes(t))}if(Ee!==`all`&&(e=e.filter(e=>e.file_type===Ee)),Oe.trim()){let t=Oe.toLowerCase();e=e.filter(e=>e.created_by_username&&e.created_by_username.toLowerCase().includes(t))}return e.sort((e,t)=>{let n=0;switch(Ae){case`name`:n=(e.print_name||e.filename).localeCompare(t.print_name||t.filename);break;case`date`:n=(vf(e.created_at)?.getTime()??0)-(vf(t.created_at)?.getTime()??0);break;case`size`:n=e.file_size-t.file_size;break;case`type`:n=e.file_type.localeCompare(t.file_type);break;case`prints`:n=e.print_count-t.print_count;break}return Me===`asc`?n:-n}),e},[Ge,we,Ee,Oe,Ae,Me]),Ze=(0,y.useMemo)(()=>{if(!qe||!Fe)return!1;let e=(Fe.library_disk_warning_gb||5)*1024*1024*1024;return qe.disk_free_bytesQ.createLibraryFolder(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),_(!1),n(e(`fileManager.toast.folderCreated`),`success`)},onError:e=>n(e.message,`error`)}),$e=J({mutationFn:async e=>{let t=await Q.createExternalFolder(e);return await Q.scanExternalFolder(t.id),t},onSuccess:r=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-stats`]}),b(!1),d(r.id),n(e(`fileManager.toast.externalFolderLinked`),`success`)},onError:e=>n(e.message,`error`)}),et=J({mutationFn:e=>Q.scanExternalFolder(e),onSuccess:r=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),n(e(`fileManager.toast.folderScanned`,{added:r.added,removed:r.removed}),`success`)},onError:e=>n(e.message,`error`)}),tt=J({mutationFn:e=>Q.deleteLibraryFolder(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-stats`]}),u===L?.id&&d(null),R(null),n(e(`fileManager.toast.folderDeleted`),`success`)},onError:e=>{R(null),n(e.message,`error`)}}),nt=J({mutationFn:e=>Q.deleteLibraryFile(e),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),t.invalidateQueries({queryKey:[`library-trash-count`]}),h(e=>e.filter(e=>e!==L?.id)),R(null),n(e(`fileManager.toast.fileDeleted`),`success`)},onError:e=>{R(null),n(e.message,`error`)}}),rt=J({mutationFn:e=>Q.bulkDeleteLibrary(e,[]),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]}),t.invalidateQueries({queryKey:[`library-trash-count`]}),n(e(`fileManager.toast.filesDeleted`,{count:i.length}),`success`),h([]),R(null)},onError:e=>{R(null),n(e.message,`error`)}}),it=J({mutationFn:({fileIds:e,folderId:t})=>Q.moveLibraryFiles(e,t),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),h([]),S(!1),n(e(`fileManager.toast.filesMoved`),`success`)},onError:e=>n(e.message,`error`)}),at=J({mutationFn:({id:e,data:t})=>Q.updateLibraryFolder(e,t),onSuccess:(r,i)=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`project-folders`]}),t.invalidateQueries({queryKey:[`archive-folders`]}),I(null),n(i.data.project_id===0&&i.data.archive_id===0?e(`fileManager.toast.folderUnlinked`):e(`fileManager.toast.folderLinked`),`success`)},onError:e=>n(e.message,`error`)}),ot=J({mutationFn:({id:e,filename:t})=>Q.updateLibraryFile(e,{filename:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-files`]}),ae(null),n(e(`fileManager.toast.fileRenamed`),`success`)},onError:e=>{ae(null),n(e.message,`error`)}}),st=J({mutationFn:({id:e,name:t})=>Q.updateLibraryFolder(e,{name:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-files`]}),ae(null),n(e(`fileManager.toast.folderRenamed`),`success`)},onError:e=>{ae(null),n(e.message,`error`)}}),ct=J({mutationFn:()=>Q.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:r=>{if(t.invalidateQueries({queryKey:[`library-files`]}),r.succeeded>0){let e=Date.now(),t={};r.results.forEach(n=>{n.success&&(t[n.file_id]=e)}),U(e=>({...e,...t}))}r.succeeded>0&&r.failed===0?n(e(`fileManager.toast.thumbnailsGenerated`,{count:r.succeeded}),`success`):r.succeeded>0&&r.failed>0?n(e(`fileManager.toast.thumbnailsGeneratedPartial`,{succeeded:r.succeeded,failed:r.failed}),`success`):r.processed===0?n(e(`fileManager.toast.noStlMissingThumbnails`),`info`):n(e(`fileManager.toast.failedToGenerateThumbnails`,{error:r.results[0]?.error||`Unknown error`}),`error`)},onError:e=>n(e.message,`error`)}),lt=J({mutationFn:e=>Q.batchGenerateStlThumbnails({file_ids:[e]}),onSuccess:r=>{if(t.invalidateQueries({queryKey:[`library-files`]}),r.succeeded>0){let t=r.results[0]?.file_id;t&&U(e=>({...e,[t]:Date.now()})),n(e(`fileManager.toast.thumbnailGenerated`),`success`)}else n(e(`fileManager.toast.failedToGenerateThumbnail`,{error:r.results[0]?.error||`Unknown error`}),`error`)},onError:e=>n(e.message,`error`)}),ut=(0,y.useCallback)(e=>{let t=e.toLowerCase();return t.endsWith(`.gcode`)||t.includes(`.gcode.`)},[]),dt=(0,y.useMemo)(()=>Ge?Ge.filter(e=>m.includes(e.id)&&ut(e.filename)):[],[Ge,m,ut]),ft=(0,y.useCallback)(e=>{h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),pt=(0,y.useCallback)(()=>{Xe.length>0&&h(Xe.map(e=>e.id))},[Xe]),mt=(0,y.useCallback)(()=>{h([])},[]),ht=()=>{t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`library-folders`]}),t.invalidateQueries({queryKey:[`library-stats`]})},{isDraggingOver:gt,dragHandlers:_t}=GW({disabled:!r(`library:upload`)||C,onFiles:e=>{E(e),w(!0)}}),vt=e=>{Q.downloadLibraryFile(e).catch(e=>{console.error(`Library file download failed:`,e)})},yt=()=>{L&&(L.type===`file`?nt.mutate(L.id):L.type===`folder`?tt.mutate(L.id):L.type===`bulk`&&rt.mutate(m))},bt=tt.isPending||nt.isPending||rt.isPending,xt=e=>{ue(e),localStorage.setItem(`library-view-mode`,e)},St=Le||Ke,Ct=(0,y.useMemo)(()=>{if(!u||!Ie)return null;let e=t=>{for(let n of t){if(n.id===u)return n;let t=e(n.children);if(t)return t}return null};return e(Ie)},[u,Ie]);return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col relative`,..._t,children:[gt&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none`,children:(0,K.jsxs)(`div`,{className:`border-4 border-dashed border-bambu-green rounded-xl p-12 text-center`,children:[(0,K.jsx)(Du,{className:`w-16 h-16 mx-auto mb-4 text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-2xl font-semibold text-white mb-2`,children:e(`fileManager.dropFilesHere`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`fileManager.releaseToUpload`)})]})}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(cc,{className:`w-7 h-7 text-bambu-green`}),e(`fileManager.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`fileManager.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center bg-bambu-dark rounded-lg p-1`,children:[(0,K.jsx)(`button`,{onClick:()=>xt(`grid`),className:`p-1.5 rounded transition-colors ${le===`grid`?`bg-bambu-dark-secondary text-white`:`text-bambu-gray hover:text-white`}`,title:e(`fileManager.gridView`),children:(0,K.jsx)(zc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>xt(`list`),className:`p-1.5 rounded transition-colors ${le===`list`?`bg-bambu-dark-secondary text-white`:`text-bambu-gray hover:text-white`}`,title:e(`fileManager.listView`),children:(0,K.jsx)(Gc,{className:`w-4 h-4`})})]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>ct.mutate(),disabled:ct.isPending||!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?e(`fileManager.generateThumbnailsForMissing`):e(`fileManager.noPermissionGenerateThumbnail`),children:[ct.isPending?(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}):(0,K.jsx)(Mc,{className:`w-4 h-4 mr-2`}),e(`fileManager.generateThumbnails`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>b(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?e(`fileManager.linkExternalFolder`):e(`fileManager.noPermissionCreateFolder`),children:[(0,K.jsx)(uc,{className:`w-4 h-4 mr-2`}),e(`fileManager.linkExternal`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>_(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionCreateFolder`),children:[(0,K.jsx)(lc,{className:`w-4 h-4 mr-2`}),e(`fileManager.newFolder`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>A(!0),title:e(`fileManager.tags.manageTitle`),children:[(0,K.jsx)(fu,{className:`w-4 h-4 mr-2`}),e(`fileManager.tags.manage`)]}),r(`library:purge`)&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>O(!0),title:e(`libraryPurge.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`libraryPurge.headerButton`)]}),i(`library:delete_own`,`library:delete_all`)&&(0,K.jsxs)(wi,{to:`/files/trash`,className:`inline-flex items-center px-3 py-1.5 text-sm rounded bg-bambu-dark-secondary text-bambu-gray hover:text-white hover:bg-bambu-dark transition-colors`,title:e(`libraryTrash.headerTooltip`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-2`}),e(`libraryTrash.headerButton`),typeof ze==`number`&&ze>0&&(0,K.jsx)(`span`,{className:`ml-1.5 px-1.5 py-0.5 text-xs rounded-full bg-bambu-green/20 text-bambu-green`,children:ze})]}),(0,K.jsxs)($,{onClick:()=>w(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionUpload`),children:[(0,K.jsx)(Du,{className:`w-4 h-4 mr-2`}),e(`common.upload`)]})]})]}),Ze&&qe&&Fe&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg`,children:[(0,K.jsx)(Cu,{className:`w-5 h-5 text-amber-500 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`p`,{className:`text-sm text-amber-500 font-medium`,children:e(`fileManager.lowDiskSpaceWarning`)}),(0,K.jsx)(`p`,{className:`text-xs text-amber-500/80`,children:e(`fileManager.lowDiskSpaceDetails`,{free:Cd(qe.disk_free_bytes),total:Cd(qe.disk_total_bytes),threshold:Fe.library_disk_warning_gb})})]})]}),qe&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 sm:gap-6 mb-6 p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(rc,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.files`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:qe.total_files})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(cc,{className:`w-4 h-4 text-blue-400`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.folders`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:qe.total_folders})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(wc,{className:`w-4 h-4 text-amber-400`}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.size`),`:`]}),(0,K.jsx)(`span`,{className:`text-white font-medium`,children:Cd(qe.total_size_bytes)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm sm:ml-auto`,children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[e(`fileManager.free`),`:`]}),(0,K.jsx)(`span`,{className:`font-medium ${Ze?`text-amber-500`:`text-white`}`,children:Cd(qe.disk_free_bytes)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0`,children:[(0,K.jsx)(`div`,{className:`lg:hidden`,children:(0,K.jsxs)(`select`,{value:u===null?`__top:${f}`:String(u),onChange:e=>{let t=e.target.value;t.startsWith(`__top:`)?(d(null),p(t.slice(6))):d(parseInt(t,10))},className:`w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg px-3 py-2.5 text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsxs)(`option`,{value:`__top:internal`,children:[`📁 `,e(`fileManager.allFiles`)]}),Ie?.some(e=>e.is_external)&&(0,K.jsxs)(`option`,{value:`__top:external`,children:[`🔗 `,e(`fileManager.allExternal`)]}),Re&&(()=>{let e=(t,n=0)=>{let r=[];for(let i of t)r.push({id:i.id,name:i.name,fileCount:i.file_count,depth:n}),i.children.length>0&&r.push(...e(i.children,n+1));return r};return e(Re).map(e=>(0,K.jsxs)(`option`,{value:e.id,children:[`│ `.repeat(e.depth),`📂 `,e.name,` `,e.fileCount>0?`(${e.fileCount})`:``]},e.id))})()]})}),(0,K.jsxs)(`div`,{ref:Ce,className:`hidden lg:flex flex-shrink-0 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative`,style:{width:`${ye}px`},children:[(0,K.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 group/resize flex items-center justify-center transition-colors ${xe?`bg-bambu-green`:`hover:bg-bambu-green/50`}`,onMouseDown:e=>{e.preventDefault(),Se(!0)},onDoubleClick:()=>{be(256),localStorage.setItem(`library-sidebar-width`,`256`)},title:e(`fileManager.dragToResizeTooltip`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${xe?`opacity-100`:``}`,children:[(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`}),(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`}),(0,K.jsx)(`div`,{className:`w-0.5 h-0.5 rounded-full bg-white/70`})]})}),(0,K.jsxs)(`div`,{className:`p-3 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-medium text-white`,children:e(`fileManager.folders`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(`select`,{value:he,onChange:e=>{let t=e.target.value===`activity`?`activity`:`name`;ge(t),localStorage.setItem(`library-folder-sort-field`,t)},className:`text-xs px-1 py-0.5 rounded bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray focus:outline-none focus:border-bambu-green`,title:e(`fileManager.folderSort`),"aria-label":e(`fileManager.folderSort`),children:[(0,K.jsx)(`option`,{value:`name`,children:e(`fileManager.folderSortByName`)}),(0,K.jsx)(`option`,{value:`activity`,children:e(`fileManager.folderSortByActivity`)})]}),(0,K.jsx)(`button`,{onClick:()=>{let e=_e===`asc`?`desc`:`asc`;ve(e),localStorage.setItem(`library-folder-sort-direction`,e)},className:`text-bambu-gray hover:text-white hover:bg-bambu-dark p-1 rounded transition-colors`,title:e(_e===`asc`?`fileManager.ascending`:`fileManager.descending`),"aria-label":e(_e===`asc`?`fileManager.ascending`:`fileManager.descending`),children:_e===`asc`?(0,K.jsx)(Fo,{className:`w-3.5 h-3.5`}):(0,K.jsx)(ko,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:()=>{let e=!pe;me(e),localStorage.setItem(`library-collapse-folders`,String(e))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${pe?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:text-white hover:bg-bambu-dark`}`,title:e(pe?`fileManager.expandFoldersByDefault`:`fileManager.collapseFoldersByDefault`),children:e(`fileManager.collapse`)}),(0,K.jsx)(`button`,{onClick:()=>{let e=!de;fe(e),localStorage.setItem(`library-wrap-folders`,String(e))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${de?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:text-white hover:bg-bambu-dark`}`,title:e(de?`fileManager.disableTextWrapping`:`fileManager.enableTextWrapping`),children:e(`fileManager.wrap`)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null&&f===`internal`?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,onClick:()=>{d(null),p(`internal`)},children:[(0,K.jsx)(Qs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`text-sm`,children:e(`fileManager.allFiles`)})]}),Ie?.some(e=>e.is_external)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors ${u===null&&f===`external`?`bg-bambu-green/20 text-bambu-green`:`hover:bg-bambu-dark text-white`}`,onClick:()=>{d(null),p(`external`)},children:[(0,K.jsx)(uc,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`text-sm`,children:e(`fileManager.allExternal`)})]}),Re?.map(t=>(0,K.jsx)($7,{folder:t,selectedFolderId:u,onSelect:d,onDelete:e=>R({type:`folder`,id:e}),onLink:I,onRename:e=>ae({type:`folder`,id:e.id,name:e.name}),wrapNames:de,defaultExpanded:!pe,hasPermission:r,t:e},`${t.id}-${pe?`c`:`e`}`))]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 min-h-0`,children:[u!==null&&(0,K.jsx)(cXe,{folderId:u}),He.length>0&&(0,K.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium shrink-0`,children:e(`fileManager.tags.filterLabel`)}),He.map(e=>{let t=N.includes(e.id);return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>We(e.id),className:t?`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bambu-green/20 text-bambu-green border border-bambu-green/40 hover:bg-bambu-green/30 transition-colors`:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bambu-dark text-bambu-gray border border-bambu-dark-tertiary hover:text-white hover:border-bambu-green/40 transition-colors`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:e.name}),t&&(0,K.jsx)(Ru,{className:`w-3 h-3`})]},e.id)}),N.length>0&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>P([]),className:`ml-auto text-xs text-bambu-gray hover:text-white shrink-0`,children:e(`fileManager.tags.clearAll`)})]}),Ct?.is_external&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4 p-3 bg-purple-500/10 border border-purple-500/30 rounded-lg`,children:[(0,K.jsx)(uc,{className:`w-5 h-5 text-purple-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm font-medium text-purple-300`,children:e(`fileManager.externalFolder`)}),Ct.external_readonly&&(0,K.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-400 flex items-center gap-1`,children:[(0,K.jsx)(qc,{className:`w-3 h-3`}),e(`fileManager.readOnly`)]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray truncate font-mono`,title:Ct.external_path||``,children:Ct.external_path})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>u&&et.mutate(u),disabled:et.isPending,title:e(`fileManager.scanFolder`),children:[et.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Ol,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`fileManager.scanFolder`)})]})]}),Ge&&Ge.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 sm:gap-3 mb-4 p-2 sm:p-3 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-0 z-10 lg:static`,children:[(0,K.jsxs)(`div`,{className:`relative w-full sm:w-auto sm:flex-1 sm:max-w-xs`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:e(`fileManager.searchFiles`),value:we,onChange:e=>Te(e.target.value),className:`w-full pl-9 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green`}),Be&&(0,K.jsx)(`span`,{className:`absolute -bottom-4 left-0 text-[10px] text-bambu-gray whitespace-nowrap`,title:e(`fileManager.searchSubfoldersHint`),children:e(`fileManager.searchSubfoldersHint`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(mc,{className:`w-4 h-4 text-bambu-gray hidden sm:block`}),(0,K.jsxs)(`select`,{value:Ee,onChange:e=>De(e.target.value),className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`all`,children:e(`fileManager.allTypes`)}),Ye.map(e=>(0,K.jsx)(`option`,{value:e,children:e.toUpperCase()},e))]})]}),o&&(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`text`,placeholder:e(`fileManager.filterByUser`,{defaultValue:`Filter by user`}),value:Oe,onChange:e=>ke(e.target.value),list:`usernames-list`,className:`w-32 sm:w-40 px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-sm text-white placeholder-bambu-gray focus:outline-none focus:border-bambu-green ${Oe?`pr-7`:``}`,style:Oe?{WebkitAppearance:`none`,MozAppearance:`textfield`}:void 0}),Oe&&(0,K.jsx)(`button`,{onClick:()=>ke(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white z-10`,children:(0,K.jsx)(Ru,{className:`w-3 h-3`})}),(0,K.jsx)(`datalist`,{id:`usernames-list`,children:Je?.map(e=>(0,K.jsx)(`option`,{value:e.username},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`select`,{value:Ae,onChange:e=>{let t=e.target.value;je(t),localStorage.setItem(`library-sort-field`,t)},className:`bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1.5 text-sm text-white focus:outline-none focus:border-bambu-green`,children:[(0,K.jsx)(`option`,{value:`name`,children:e(`common.name`)}),(0,K.jsx)(`option`,{value:`date`,children:e(`common.date`)}),(0,K.jsx)(`option`,{value:`size`,children:e(`fileManager.size`)}),(0,K.jsx)(`option`,{value:`type`,children:e(`common.type`)}),(0,K.jsx)(`option`,{value:`prints`,children:e(`fileManager.prints`)})]}),(0,K.jsx)(`button`,{onClick:()=>Ne(e=>{let t=e===`asc`?`desc`:`asc`;return localStorage.setItem(`library-sort-direction`,t),t}),className:`p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors`,title:e(Me===`asc`?`fileManager.ascending`:`fileManager.descending`),children:Me===`asc`?(0,K.jsx)(Fo,{className:`w-4 h-4 text-white`}):(0,K.jsx)(ko,{className:`w-4 h-4 text-white`})})]}),(we||Ee!==`all`||Oe)&&(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray hidden sm:inline`,children:e(`fileManager.resultsCount`,{showing:Xe.length,total:Ge.length})})]}),Xe.length>0&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 mb-4 p-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary sticky top-[52px] z-10 lg:static`,children:[m.length===Xe.length&&m.length>0?(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:mt,children:[(0,K.jsx)(ou,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.deselectAll`)})]}):(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:pt,children:[(0,K.jsx)(iu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.selectAll`)})]}),m.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray ml-2`,children:e(`fileManager.selected`,{count:m.length})}),(0,K.jsx)(`div`,{className:`hidden sm:block flex-1`}),(0,K.jsxs)(`div`,{className:`w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0`,children:[dt.length===1&&(0,K.jsxs)($,{variant:`primary`,size:`sm`,onClick:()=>ee(dt[0]),disabled:!r(`printers:control`),title:r(`printers:control`)?void 0:e(`fileManager.noPermissionPrint`),children:[(0,K.jsx)(bl,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.print`)})]}),dt.length===1&&(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>ne(dt[0]),disabled:!r(`queue:create`),title:r(`queue:create`)?void 0:e(`fileManager.noPermissionAddToQueue`),children:[(0,K.jsx)(Ss,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.schedulePrint`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>S(!0),disabled:!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?void 0:e(`fileManager.noPermissionMoveFiles`),children:[(0,K.jsx)(cl,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.move`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:()=>M(!0),disabled:!i(`library:update_own`,`library:update_all`),title:i(`library:update_own`,`library:update_all`)?e(`fileManager.tags.bulkTooltip`):e(`fileManager.tags.noPermission`),children:[(0,K.jsx)(fu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`fileManager.tags.tagAction`)})]}),(0,K.jsxs)($,{variant:`danger`,size:`sm`,onClick:()=>{m.length===1?R({type:`file`,id:m[0]}):R({type:`bulk`,id:0,count:m.length})},disabled:!i(`library:delete_own`,`library:delete_all`),title:i(`library:delete_own`,`library:delete_all`)?void 0:e(`fileManager.noPermissionDeleteFiles`),children:[(0,K.jsx)(bu,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.delete`)})]}),(0,K.jsxs)($,{variant:`secondary`,size:`sm`,onClick:mt,children:[(0,K.jsx)(Ru,{className:`w-4 h-4 sm:mr-1`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:e(`common.clear`)})]})]})]})]}),St?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`fileManager.loadingFiles`)})]})}):Ge?.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(Qs,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:e(u===null?f===`external`?`fileManager.externalIsEmpty`:`fileManager.noFilesYet`:`fileManager.folderIsEmpty`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:e(u===null?f===`external`?`fileManager.externalEmptyDescription`:`fileManager.noFilesDescription`:`fileManager.folderEmptyDescription`)}),(0,K.jsxs)($,{onClick:()=>w(!0),disabled:!r(`library:upload`),title:r(`library:upload`)?void 0:e(`fileManager.noPermissionUpload`),children:[(0,K.jsx)(Sl,{className:`w-4 h-4 mr-2`}),e(`fileManager.uploadFiles`)]})]}):Xe.length===0?(0,K.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark rounded-2xl mb-4`,children:(0,K.jsx)(Rl,{className:`w-12 h-12 text-bambu-gray/50`})}),(0,K.jsx)(`h3`,{className:`text-lg font-medium text-white mb-2`,children:e(`fileManager.noMatchingFiles`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-center max-w-md mb-6`,children:e(`fileManager.noMatchingFilesDescription`)}),(0,K.jsx)($,{variant:`secondary`,onClick:()=>{Te(``),De(`all`)},children:e(`fileManager.clearFilters`)})]}):le===`grid`?(0,K.jsx)(`div`,{className:`flex-1 lg:overflow-y-auto`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 2xl:grid-cols-6 gap-4`,children:Xe.map(t=>(0,K.jsx)(yXe,{file:t,isSelected:m.includes(t.id),isMobile:Pe,t:e,onSelect:ft,onDelete:e=>R({type:`file`,id:e}),onDownload:vt,onAddToQueue:e=>{let t=Ge?.find(t=>t.id===e);t&&ne(t)},onPrint:B,onSlice:ie,useSlicerApi:Fe?.use_slicer_api??!1,onPreview3d:e=>{e9(e.filename)?c(`/gcode-viewer?library_file=${e.id}`):ce(e)},onRename:e=>ae({type:`file`,id:e.id,name:e.filename}),onGenerateThumbnail:e=>lt.mutate(e.id),onTagClick:We,thumbnailVersion:oe[t.id],hasPermission:r,canModify:a,authEnabled:o},t.id))})}):(0,K.jsx)(`div`,{className:`flex-1 lg:overflow-y-auto`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary overflow-x-auto`,children:[(0,K.jsxs)(`div`,{className:`hidden sm:grid ${o?`grid-cols-[auto_1fr_120px_100px_100px_100px_minmax(0,200px)_220px]`:`grid-cols-[auto_1fr_100px_100px_100px_minmax(0,200px)_220px]`} gap-4 px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary text-xs text-bambu-gray font-medium`,children:[(0,K.jsx)(`div`,{className:`w-6`}),(0,K.jsx)(`div`,{children:e(`common.name`)}),o&&(0,K.jsx)(`div`,{children:e(`fileManager.uploadedBy`,{defaultValue:`Uploaded By`})}),(0,K.jsx)(`div`,{children:e(`common.type`)}),(0,K.jsx)(`div`,{children:e(`fileManager.size`)}),(0,K.jsx)(`div`,{children:e(`fileManager.prints`)}),(0,K.jsx)(`div`,{children:e(`fileManager.tags.title`)}),(0,K.jsx)(`div`,{})]}),Xe.map(t=>(0,K.jsxs)(`div`,{className:`grid ${o?`grid-cols-[auto_1fr_120px_100px_100px_100px_minmax(0,200px)_220px]`:`grid-cols-[auto_1fr_100px_100px_100px_minmax(0,200px)_220px]`} gap-4 px-4 py-3 items-center border-b border-bambu-dark-tertiary last:border-b-0 cursor-pointer hover:bg-bambu-dark/50 transition-colors ${m.includes(t.id)?`bg-bambu-green/10`:``}`,onClick:()=>ft(t.id),children:[(0,K.jsx)(`div`,{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${m.includes(t.id)?`bg-bambu-green border-bambu-green`:`border-bambu-gray/50`}`,children:m.includes(t.id)&&(0,K.jsx)(`div`,{className:`w-2 h-2 bg-white rounded-sm`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`relative group/thumb`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden`,children:t.thumbnail_path?(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(t.id)}${oe[t.id]?(Q.getLibraryFileThumbnailUrl(t.id).includes(`?`)?`&`:`?`)+`v=${oe[t.id]}`:``}`,alt:``,className:`w-full h-full object-cover`}):(0,K.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,K.jsx)(Qs,{className:`w-5 h-5 text-bambu-gray/50`})})}),t.thumbnail_path&&(0,K.jsx)(`div`,{className:`absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block`,children:(0,K.jsx)(`div`,{className:`w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden`,children:(0,K.jsx)(`img`,{src:`${Q.getLibraryFileThumbnailUrl(t.id)}${oe[t.id]?(Q.getLibraryFileThumbnailUrl(t.id).includes(`?`)?`&`:`?`)+`v=${oe[t.id]}`:``}`,alt:t.filename,className:`w-full h-full object-contain`})})})]}),(0,K.jsx)(`div`,{className:`min-w-0`,children:(0,K.jsx)(`div`,{className:`text-sm text-white truncate`,children:t.print_name||t.filename})})]}),o&&(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray flex items-center gap-1`,children:t.created_by_username?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ou,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{className:`truncate`,children:t.created_by_username})]}):`-`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded font-medium ${t.file_type===`3mf`?`bg-bambu-green/20 text-bambu-green`:t.file_type===`gcode`||t.file_type===`gcode.3mf`?`bg-blue-500/20 text-blue-400`:t.file_type===`stl`?`bg-purple-500/20 text-purple-400`:`bg-bambu-gray/20 text-bambu-gray`}`,children:t.file_type.toUpperCase()})}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:Cd(t.file_size)}),(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:t.print_count>0?`${t.print_count}x`:`-`}),(0,K.jsx)(`div`,{className:`min-w-0`,onClick:e=>e.stopPropagation(),children:!t.tags||t.tags.length===0?(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray/50`,children:`-`}):(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:t.tags.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>We(e.id),className:`inline-flex items-center gap-0.5 px-1.5 py-0.5 rounded-full text-[10px] bg-bambu-green/10 text-bambu-green hover:bg-bambu-green/20 transition-colors max-w-full`,title:e.name,children:[(0,K.jsx)(fu,{className:`w-2.5 h-2.5 flex-shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,onClick:e=>e.stopPropagation(),children:[e9(t.filename)&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>r(`printers:control`)&&B(t),className:`p-1.5 rounded transition-colors ${r(`printers:control`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`printers:control`)?e(`common.print`):e(`fileManager.noPermissionPrint`),disabled:!r(`printers:control`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>{r(`queue:create`)&&ne(t)},className:`p-1.5 rounded transition-colors ${r(`queue:create`)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`queue:create`)?e(`fileManager.schedulePrint`):e(`fileManager.noPermissionAddToQueue`),disabled:!r(`queue:create`),children:(0,K.jsx)(Ss,{className:`w-4 h-4`})})]}),(Fe?.use_slicer_api??!1)&&t9(t.filename)&&(0,K.jsx)(`button`,{onClick:()=>r(`library:upload`)&&ie(t),className:`p-1.5 rounded transition-colors ${r(`library:upload`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:upload`)?e(`slice.action`):e(`fileManager.noPermissionSlice`),disabled:!r(`library:upload`),children:(0,K.jsx)(ks,{className:`w-4 h-4`})}),(t.file_type===`3mf`||t.file_type===`gcode`||t.file_type===`gcode.3mf`||t.file_type===`stl`)&&(0,K.jsx)(`button`,{onClick:()=>{r(`library:read`)&&(e9(t.filename)?c(`/gcode-viewer?library_file=${t.id}`):ce(t))},className:`p-1.5 rounded transition-colors ${r(`library:read`)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:read`)?`3D Preview`:`You do not have permission to preview files`,disabled:!r(`library:read`),children:(0,K.jsx)(Wo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>r(`library:read`)&&vt(t.id),className:`p-1.5 rounded transition-colors ${r(`library:read`)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:r(`library:read`)?e(`common.download`):e(`fileManager.noPermissionDownload`),disabled:!r(`library:read`),children:(0,K.jsx)(Vs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`library`,`update`,t.created_by_id)&&ae({type:`file`,id:t.id,name:t.filename}),className:`p-1.5 rounded transition-colors ${a(`library`,`update`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-white`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`update`,t.created_by_id)?e(`common.rename`):e(`fileManager.noPermissionRenameFile`),disabled:!a(`library`,`update`,t.created_by_id),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),t.file_type===`stl`&&(0,K.jsx)(`button`,{onClick:()=>a(`library`,`update`,t.created_by_id)&<.mutate(t.id),className:`p-1.5 rounded transition-colors ${a(`library`,`update`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`update`,t.created_by_id)?e(`fileManager.generateThumbnail`):e(`fileManager.noPermissionGenerateThumbnail`),disabled:lt.isPending||!a(`library`,`update`,t.created_by_id),children:(0,K.jsx)(Mc,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(`library`,`delete`,t.created_by_id)&&R({type:`file`,id:t.id}),className:`p-1.5 rounded transition-colors ${a(`library`,`delete`,t.created_by_id)?`hover:bg-bambu-dark text-bambu-gray hover:text-red-400`:`text-bambu-gray/50 cursor-not-allowed`}`,title:a(`library`,`delete`,t.created_by_id)?e(`common.delete`):e(`fileManager.noPermissionDeleteFile`),disabled:!a(`library`,`delete`,t.created_by_id),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})]},t.id))]})})]})]}),g&&(0,K.jsx)(fXe,{parentId:u,onClose:()=>_(!1),onSave:e=>Qe.mutate(e),isLoading:Qe.isPending,t:e}),v&&(0,K.jsx)(pXe,{onClose:()=>b(!1),onSave:e=>$e.mutate(e),isLoading:$e.isPending,t:e}),x&&Ie&&(0,K.jsx)(_Xe,{folders:Ie,selectedFiles:m,currentFolderId:u,onClose:()=>S(!1),onMove:e=>it.mutate({fileIds:m,folderId:e}),isLoading:it.isPending,t:e}),C&&(0,K.jsx)(qU,{folderId:u,onClose:()=>{w(!1),E([])},onUploadComplete:ht,initialFiles:T.length>0?T:void 0}),D&&(0,K.jsx)(dXe,{onClose:()=>O(!1)}),(0,K.jsx)(lXe,{open:k,onClose:()=>A(!1),onPickTag:e=>{N.includes(e)||P(t=>[...t,e])}}),(0,K.jsx)(BUe,{open:j,fileIds:m,onClose:()=>M(!1)}),F&&(0,K.jsx)(vXe,{folder:F,onClose:()=>I(null),onLink:e=>at.mutate({id:F.id,data:e}),isLoading:at.isPending,t:e}),L&&(0,K.jsx)(Ad,{title:L.type===`folder`?e(`fileManager.deleteFolder`):L.type===`bulk`?e(`fileManager.deleteFilesCount`,{count:L.count}):e(`fileManager.deleteFile`),message:L.type===`folder`?e(`fileManager.deleteFolderConfirm`):L.type===`bulk`?e(`fileManager.deleteFilesConfirm`,{count:L.count}):e(`fileManager.deleteFileConfirm`),confirmText:e(`common.delete`),variant:`danger`,isLoading:bt,loadingText:e(`fileManager.deleting`),onConfirm:yt,onCancel:()=>R(null)}),z&&(0,K.jsx)(sW,{mode:`reprint`,libraryFileId:z.id,archiveName:z.print_name||z.filename,onClose:()=>B(null),onSuccess:()=>{B(null),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`archives`]})}}),V&&(0,K.jsx)(sW,{mode:`reprint`,libraryFileId:V.id,archiveName:V.print_name||V.filename,onClose:()=>ee(null),onSuccess:()=>{ee(null),h([]),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`archives`]})}}),te&&(0,K.jsx)(sW,{mode:`add-to-queue`,libraryFileId:te.id,archiveName:te.print_name||te.filename,onClose:()=>ne(null),onSuccess:()=>{ne(null),h([]),t.invalidateQueries({queryKey:[`library-files`]}),t.invalidateQueries({queryKey:[`queue`]}),t.invalidateQueries({queryKey:[`archives`]})}}),re&&(0,K.jsx)(zW,{source:{kind:`libraryFile`,id:re.id,filename:re.filename},onClose:()=>ie(null)}),se&&(0,K.jsx)(zUe,{libraryFileId:se.id,title:se.print_name||se.filename,fileType:se.file_type,onClose:()=>ce(null),onSliceWithBambuddy:t9(se.filename)&&r(`library:upload`)?()=>{let e=se;ce(null),ie(e)}:void 0}),H&&(0,K.jsx)(gXe,{type:H.type,currentName:H.name,onClose:()=>ae(null),onSave:e=>{H.type===`file`?ot.mutate({id:H.id,filename:e}):st.mutate({id:H.id,name:e})},isLoading:ot.isPending||st.isPending,t:e})]})}function xXe(e){let t=vf(e);if(!t)return``;let n=Math.ceil((t.getTime()-Date.now())/(1e3*60*60*24));return n<=0?`any moment`:n===1?`1 day`:`${n} days`}function n9(e){let t=vf(e);return t?t.toLocaleString():e}function SXe(){let{t:e}=W(),t=$n(),n=no(),{showToast:r}=Td(),{hasPermission:i,authEnabled:a}=dd(),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(new Set),u=!a||i(`library:purge`),d=q({queryKey:[`library-trash`],queryFn:()=>Q.listLibraryTrash(200,0)}),f=q({queryKey:[`library-trash-settings`],queryFn:()=>Q.getLibraryTrashSettings(),enabled:u}),[p,m]=(0,y.useState)(null);(0,y.useEffect)(()=>{f.data&&p===null&&m(f.data.retention_days)},[f.data,p]);let h=J({mutationFn:e=>{let t=f.data;return Q.updateLibraryTrashSettings({retention_days:e,auto_purge_enabled:t?.auto_purge_enabled??!1,auto_purge_days:t?.auto_purge_days??90,auto_purge_include_never_printed:t?.auto_purge_include_never_printed??!0})},onSuccess:t=>{r(e(`libraryTrash.toast.retentionSaved`,{days:t.retention_days}),`success`),n.invalidateQueries({queryKey:[`library-trash-settings`]}),n.invalidateQueries({queryKey:[`library-trash`]})},onError:t=>r(t.message||e(`libraryTrash.toast.retentionFailed`),`error`)}),g=J({mutationFn:e=>Q.restoreLibraryTrash(e),onSuccess:()=>{r(e(`libraryTrash.toast.restored`),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]})},onError:t=>r(t.message||e(`libraryTrash.toast.restoreFailed`),`error`)}),_=J({mutationFn:e=>Q.hardDeleteLibraryTrash(e),onSuccess:()=>{r(e(`libraryTrash.toast.purged`),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.purgeFailed`),`error`)}),v=J({mutationFn:()=>Q.emptyLibraryTrash(),onSuccess:t=>{r(e(`libraryTrash.toast.emptied`,{count:t.deleted}),`success`),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.emptyFailed`),`error`)}),b=J({mutationFn:e=>Promise.all(e.map(e=>Q.restoreLibraryTrash(e))),onSuccess:(t,i)=>{r(e(`libraryTrash.toast.bulkRestored`,{count:i.length}),`success`),l(new Set),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]}),n.invalidateQueries({queryKey:[`library-files`]}),n.invalidateQueries({queryKey:[`library-folders`]})},onError:t=>r(t.message||e(`libraryTrash.toast.restoreFailed`),`error`)}),x=J({mutationFn:e=>Promise.all(e.map(e=>Q.hardDeleteLibraryTrash(e))),onSuccess:(t,i)=>{r(e(`libraryTrash.toast.bulkPurged`,{count:i.length}),`success`),l(new Set),n.invalidateQueries({queryKey:[`library-trash`]}),n.invalidateQueries({queryKey:[`library-trash-count`]})},onError:t=>r(t.message||e(`libraryTrash.toast.purgeFailed`),`error`)}),S=(0,y.useMemo)(()=>d.data?.items??[],[d.data?.items]),C=d.data?.retention_days??30,w=(0,y.useMemo)(()=>S.reduce((e,t)=>e+t.file_size,0),[S]),T=S.length>0&&S.every(e=>c.has(e.id)),E=c.size>0&&!T,D=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};return(0,K.jsxs)(`div`,{className:`p-6 max-w-screen-2xl mx-auto`,children:[(0,K.jsx)(`div`,{className:`flex items-center gap-3 mb-4`,children:(0,K.jsxs)(wi,{to:`/files`,className:`inline-flex items-center gap-1 text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),` `,e(`libraryTrash.backToFiles`)]})}),(0,K.jsxs)(`div`,{className:`flex items-start justify-between mb-6 gap-4 flex-wrap`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-gray-100`,children:e(`libraryTrash.title`)}),(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-1`,children:e(u?`libraryTrash.subtitleAdmin`:`libraryTrash.subtitleUser`,{days:C})})]}),S.length>0&&(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s({type:`empty`}),className:`text-red-600 dark:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.emptyTrash`)]})]}),u&&f.data&&(0,K.jsxs)(`div`,{className:`mb-4 border border-gray-200 dark:border-gray-700 rounded-lg p-3 flex items-center gap-3 bg-gray-50 dark:bg-gray-800/40`,children:[(0,K.jsx)(`label`,{htmlFor:`retention-days`,className:`text-sm font-medium text-gray-700 dark:text-gray-300`,children:e(`libraryTrash.retentionLabel`)}),(0,K.jsx)(`input`,{id:`retention-days`,type:`number`,min:1,max:365,value:p??f.data.retention_days,onChange:e=>m(Math.max(1,Math.min(365,parseInt(e.target.value||`0`,10)||0))),className:`w-20 rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm px-2 py-1 text-gray-900 dark:text-gray-100`}),(0,K.jsx)(`span`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:e(`libraryTrash.days`)}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>p!=null&&h.mutate(p),disabled:h.isPending||p==null||p===f.data.retention_days,className:`ml-auto`,children:[(0,K.jsx)(Nl,{className:`w-4 h-4 mr-1`}),e(`common.save`)]})]}),d.isLoading?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-gray-500 dark:text-gray-400`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),` `,e(`libraryTrash.loading`)]}):S.length===0?(0,K.jsx)(`div`,{className:`border border-dashed border-gray-300 dark:border-gray-700 rounded-lg p-12 text-center`,children:(0,K.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:e(`libraryTrash.empty`)})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`libraryTrash.summary`,{count:S.length,size:Cd(w)})}),c.size>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:e(`libraryTrash.selectionCount`,{count:c.size})}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>b.mutate(Array.from(c)),disabled:b.isPending,children:[(0,K.jsx)(Al,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.bulkRestore`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>s({type:`bulkDelete`,count:c.size}),disabled:x.isPending,className:`text-red-600 dark:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-4 h-4 mr-1`}),e(`libraryTrash.bulkPurge`)]})]})]}),(0,K.jsx)(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-lg overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-800 text-left text-gray-600 dark:text-gray-300`,children:(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`th`,{className:`px-3 py-2 w-10`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:T,ref:e=>{e&&(e.indeterminate=E)},onChange:()=>{l(e=>e.size===S.length?new Set:new Set(S.map(e=>e.id)))},"aria-label":e(`libraryTrash.selectAll`),className:`rounded border-gray-300 cursor-pointer`})}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.filename`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.folder`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium text-right`,children:e(`libraryTrash.col.size`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium whitespace-nowrap`,children:e(`libraryTrash.col.deleted`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium whitespace-nowrap`,children:e(`libraryTrash.col.autoPurge`)}),u&&(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e(`libraryTrash.col.owner`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium text-right`,children:e(`libraryTrash.col.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-gray-100 dark:divide-gray-800`,children:S.map(t=>(0,K.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-gray-800/50`,children:[(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,checked:c.has(t.id),onChange:()=>D(t.id),"aria-label":e(`libraryTrash.selectOne`,{filename:t.filename}),className:`rounded border-gray-300 cursor-pointer`})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-900 dark:text-gray-100 truncate max-w-md`,title:t.filename,children:t.filename}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400`,children:t.folder_name??`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-right text-gray-600 dark:text-gray-400 tabular-nums whitespace-nowrap`,children:Cd(t.file_size)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400 whitespace-nowrap`,children:n9(t.deleted_at)}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400 whitespace-nowrap`,children:(0,K.jsx)(`span`,{title:n9(t.auto_purge_at),children:e(`libraryTrash.autoPurgeIn`,{when:xXe(t.auto_purge_at)})})}),u&&(0,K.jsx)(`td`,{className:`px-3 py-2 text-gray-600 dark:text-gray-400`,children:t.created_by_username??`—`}),(0,K.jsxs)(`td`,{className:`px-3 py-2 text-right whitespace-nowrap`,children:[(0,K.jsxs)(`button`,{onClick:()=>g.mutate(t.id),disabled:g.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-xs text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300`,children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5`}),e(`libraryTrash.restore`)]}),(0,K.jsxs)(`button`,{onClick:()=>s({type:`delete`,id:t.id,filename:t.filename}),disabled:_.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-xs text-red-600 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300 ml-2`,children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5`}),e(`libraryTrash.purgeNow`)]})]})]},t.id))})]})})]}),o&&(0,K.jsx)(Ad,{onCancel:()=>s(null),onConfirm:()=>{o&&(o.type===`delete`?_.mutate(o.id):o.type===`bulkDelete`?x.mutate(Array.from(c)):v.mutate(),s(null))},title:o.type===`delete`?e(`libraryTrash.confirm.purgeTitle`):o.type===`bulkDelete`?e(`libraryTrash.confirm.bulkPurgeTitle`):e(`libraryTrash.confirm.emptyTitle`),message:o.type===`delete`?e(`libraryTrash.confirm.purgeBody`,{filename:o.filename}):o.type===`bulkDelete`?e(`libraryTrash.confirm.bulkPurgeBody`,{count:o.count}):e(`libraryTrash.confirm.emptyBody`,{count:S.length}),confirmText:e(`libraryTrash.confirm.cta`),variant:`danger`}),d.isError&&(0,K.jsxs)(`div`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:[d.error?.message??e(`libraryTrash.loadError`),(0,K.jsx)($,{variant:`secondary`,onClick:()=>t(`/files`),className:`ml-3`,children:e(`libraryTrash.backToFiles`)})]})]})}function CXe(e,t){let n=`token=${encodeURIComponent(t)}`,r=0;return e.querySelectorAll(`img[src*="/api/v1/"], video[src*="/api/v1/"]`).forEach(e=>{let t=e.getAttribute(`src`)||``;if(t.includes(n))return;let i=t.replace(/([?&])token=[^&]*(&|$)/,(e,t,n)=>n===`&`?t:``);e.src=`${i}${i.includes(`?`)?`&`:`?`}${n}`,r+=1}),r}function r9(){let{authEnabled:e,user:t,loading:n}=dd(),r=no(),i=(0,y.useRef)(!1),{data:a}=q({queryKey:[`camera-stream-token`,t?.id??null],queryFn:()=>Q.getCameraStreamToken(),enabled:!n&&(!e||t!==null),staleTime:3e3*1e3,refetchInterval:3e3*1e3});(0,y.useEffect)(()=>{let e=a?.token??null;return Ju(e),e&&CXe(document,e),()=>Ju(null)},[a?.token]),(0,y.useEffect)(()=>{if(!e)return;let t=e=>{let t=e.target;if(!(t instanceof HTMLImageElement||t instanceof HTMLVideoElement))return;let n=t.src||``,a=Yu();!a||!n.includes(`token=${encodeURIComponent(a)}`)||i.current||(i.current=!0,r.invalidateQueries({queryKey:[`camera-stream-token`]}),setTimeout(()=>{i.current=!1},5e3))};return document.addEventListener(`error`,t,!0),()=>document.removeEventListener(`error`,t,!0)},[e,r])}var i9=5,wXe=2e3,TXe=3e4,EXe=5e3;function DXe(){let{t:e}=W(),t=no(),{showToast:n}=Td(),{hasPermission:r,authEnabled:i,user:a}=dd(),{printerId:o}=ir(),s=parseInt(o||`0`,10),[c]=Mi(),l=parseInt(c.get(`fps`)||`15`,10),u=Math.min(Math.max(isNaN(l)?15:l,1),30);r9();let{data:d}=q({queryKey:[`camera-stream-token`,a?.id??null],queryFn:()=>Q.getCameraStreamToken(),enabled:i?!!a:!0,staleTime:3e3*1e3}),f=d?.token??Yu(),[p,m]=(0,y.useState)(`stream`),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!0),[w,T]=(0,y.useState)(Date.now()),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(0),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)(0),[I,L]=(0,y.useState)(1),[R,z]=(0,y.useState)({x:0,y:0}),[B,V]=(0,y.useState)(!1),[ee,te]=(0,y.useState)({x:0,y:0}),[ne,re]=(0,y.useState)(null),[ie,H]=(0,y.useState)(null),ae=(0,y.useRef)(null),oe=(0,y.useRef)(null),U=(0,y.useRef)(null),se=(0,y.useRef)(null),ce=(0,y.useRef)(null),{data:le}=q({queryKey:[`printer`,s],queryFn:()=>Q.getPrinter(s),enabled:s>0}),{data:ue}=q({queryKey:[`printerStatus`,s],queryFn:()=>Q.getPrinterStatus(s),refetchInterval:3e4,enabled:s>0}),de=J({mutationFn:e=>Q.setChamberLight(s,e),onMutate:async e=>{await t.cancelQueries({queryKey:[`printerStatus`,s]});let n=t.getQueryData([`printerStatus`,s]);return t.setQueryData([`printerStatus`,s],t=>({...t,chamber_light:e})),{previousStatus:n}},onSuccess:(e,t)=>{n(`Chamber light ${t?`on`:`off`}`)},onError:(r,i,a)=>{a?.previousStatus&&t.setQueryData([`printerStatus`,s],a.previousStatus),n(r.message||e(`printers.toast.failedToControlChamberLight`),`error`)}}),fe=(ue?.state===`RUNNING`||ue?.state===`PAUSE`)&&(ue?.printable_objects_count??0)>=2;(0,y.useEffect)(()=>(le&&(document.title=`${le.name} - Camera`),()=>{document.title=`Bambuddy`}),[le]);let pe=(0,y.useRef)(!1);(0,y.useEffect)(()=>{let e=`/api/v1/printers/${s}/camera/stop`;pe.current=!1;let t=()=>{if(s>0&&!pe.current){pe.current=!0;let t={},n=Ku();n&&(t.Authorization=`Bearer ${n}`),fetch(e,{method:`POST`,keepalive:!0,headers:t}).catch(()=>{})}},n=()=>{t()};window.addEventListener(`beforeunload`,n);let r=ae.current;return()=>{window.removeEventListener(`beforeunload`,n),r&&(r.src=``),t()}},[s]),(0,y.useEffect)(()=>{if(S&&!E){let e=setTimeout(()=>{C(!1)},p===`stream`?3e3:2e4);return()=>clearTimeout(e)}},[p,S,w,E]),(0,y.useEffect)(()=>{let e=()=>{k(!!document.fullscreenElement),L(1),z({x:0,y:0}),p===`stream`&&!E&&(ae.current&&(ae.current.src=``),setTimeout(()=>{C(!0),T(Date.now())},200))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[p,E]),(0,y.useEffect)(()=>{let e,t=()=>{clearTimeout(e),e=setTimeout(()=>{localStorage.setItem(`cameraWindowState`,JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener(`resize`,t),()=>{clearTimeout(e),window.removeEventListener(`resize`,t)}},[]),(0,y.useEffect)(()=>()=>{U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ce.current&&clearInterval(ce.current)},[]);let me=(0,y.useCallback)(()=>{if(A>=i9){N(!1),x(!0);return}let e=Math.min(wXe*2**A,TXe);N(!0),F(Math.ceil(e/1e3)),se.current=setInterval(()=>{F(e=>e<=1?(se.current&&clearInterval(se.current),0):e-1)},1e3),U.current=setTimeout(()=>{j(e=>e+1),N(!1),C(!0),x(!1),ae.current&&(ae.current.src=``),T(Date.now())},e)},[A]);(0,y.useEffect)(()=>{if(p!==`stream`||S||M||E){ce.current&&=(clearInterval(ce.current),null);return}return ce.current=setInterval(async()=>{try{let e=await Q.getCameraStatus(s);(e.stalled||!e.active&&!b)&&(console.log(`Stream issue detected: stalled=${e.stalled}, active=${e.active}, reconnecting...`),ce.current&&=(clearInterval(ce.current),null),C(!1),me())}catch{}},EXe),()=>{ce.current&&=(clearInterval(ce.current),null)}},[p,S,b,M,E,s,me]);let he=()=>{C(!1),p===`stream`&&A{if(C(!1),x(!1),j(0),N(!1),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&!localStorage.getItem(`cameraWindowState`)){let e=ae.current,t=e.naturalWidth,n=e.naturalHeight;if(t>0&&n>0){let e=window.outerWidth-window.innerWidth,r=window.outerHeight-window.innerHeight,i=t+16+e,a=n+45+16+r;try{window.resizeTo(i,a)}catch{}}}},_e=()=>{if(s>0){let e={},t=Ku();t&&(e.Authorization=`Bearer ${t}`),fetch(`/api/v1/printers/${s}/camera/stop`,{method:`POST`,headers:e}).catch(()=>{})}},ve=e=>{p===e||E||(D(!0),C(!0),x(!1),j(0),N(!1),L(1),z({x:0,y:0}),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&(ae.current.src=``),p===`stream`&&_e(),setTimeout(()=>{m(e),T(Date.now()),D(!1)},100))},ye=()=>{E||(D(!0),C(!0),x(!1),j(0),N(!1),U.current&&clearTimeout(U.current),se.current&&clearInterval(se.current),ae.current&&(ae.current.src=``),p===`stream`&&_e(),setTimeout(()=>{T(Date.now()),D(!1)},100))},be=()=>{oe.current&&(document.fullscreenElement?document.exitFullscreen():oe.current.requestFullscreen())},xe=()=>{L(e=>Math.min(e+.5,4))},Se=()=>{L(e=>{let t=Math.max(e-.5,1);return t===1&&z({x:0,y:0}),t})},Ce=e=>{e.preventDefault(),e.deltaY<0?xe():Se()},we=e=>{I>1&&(e.preventDefault(),V(!0),te({x:e.clientX-R.x,y:e.clientY-R.y}))},Te=(0,y.useCallback)(()=>{if(!oe.current)return{x:300,y:200};let e=oe.current.getBoundingClientRect(),t=e.width*(I-1)/2,n=e.height*(I-1)/2;return{x:Math.max(50,t),y:Math.max(50,n)}},[I]),Ee=e=>{if(B&&I>1){let t=e.clientX-ee.x,n=e.clientY-ee.y,r=Te();z({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},De=()=>{V(!1)},Oe=e=>{if(e.length<2)return 0;let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)},ke=e=>e.length<2?{x:e[0].clientX,y:e[0].clientY}:{x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2},Ae=e=>{e.touches.length===2?(e.preventDefault(),re(Oe(e.touches)),H(ke(e.touches))):e.touches.length===1&&I>1&&(e.preventDefault(),V(!0),te({x:e.touches[0].clientX-R.x,y:e.touches[0].clientY-R.y}))},je=e=>{if(e.touches.length===2&&ne!==null){e.preventDefault();let t=Oe(e.touches),n=t/ne;L(e=>{let t=Math.max(1,Math.min(4,e*n));return t===1&&z({x:0,y:0}),t}),re(t);let r=ke(e.touches);if(ie){let e=Te();z(t=>({x:Math.max(-e.x,Math.min(e.x,t.x+(r.x-ie.x))),y:Math.max(-e.y,Math.min(e.y,t.y+(r.y-ie.y)))}))}H(r)}else if(e.touches.length===1&&B&&I>1){e.preventDefault();let t=e.touches[0].clientX-ee.x,n=e.touches[0].clientY-ee.y,r=Te();z({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},Me=e=>{e.touches.length<2&&(re(null),H(null)),e.touches.length===0&&V(!1)},Ne=()=>{L(1),z({x:0,y:0})},Pe=E||i&&!f?``:(e=>f?`${e}&token=${encodeURIComponent(f)}`:Xu(e))(p===`stream`?`/api/v1/printers/${s}/camera/stream?fps=${u}&t=${w}`:`/api/v1/printers/${s}/camera/snapshot?t=${w}`),Fe=S||E||M;return s?(0,K.jsxs)(`div`,{ref:oe,className:`min-h-screen bg-black flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`h1`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[(0,K.jsx)(Qo,{className:`w-4 h-4`}),le?.name||`Printer ${s}`]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark rounded p-0.5`,children:[(0,K.jsx)(`button`,{onClick:()=>ve(`stream`),disabled:Fe,className:`px-3 py-1 text-xs rounded transition-colors ${p===`stream`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white disabled:opacity-50`}`,children:e(`camera.live`)}),(0,K.jsx)(`button`,{onClick:()=>ve(`snapshot`),disabled:Fe,className:`px-3 py-1 text-xs rounded transition-colors ${p===`snapshot`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white disabled:opacity-50`}`,children:e(`camera.snapshot`)})]}),(0,K.jsx)(`button`,{onClick:()=>de.mutate(!ue?.chamber_light),disabled:!ue?.connected||de.isPending||!r(`printers:control`),className:`p-1.5 rounded disabled:opacity-50 ${ue?.chamber_light?`bg-yellow-500/20 hover:bg-yellow-500/30`:`hover:bg-bambu-dark-tertiary`}`,title:r(`printers:control`)?e(`camera.chamberLight`):e(`printers.permission.noControl`),children:(0,K.jsx)(sT,{on:ue?.chamber_light??!1,className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>g(!0),disabled:!fe||!r(`printers:control`),className:`p-1.5 rounded disabled:opacity-50 ${fe&&r(`printers:control`)?`hover:bg-bambu-dark-tertiary`:``}`,title:r(`printers:control`)?e(fe?`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):e(`printers.permission.noControl`),children:(0,K.jsx)(cT,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:ye,disabled:Fe,className:`p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50`,title:e(p===`stream`?`camera.restartStream`:`camera.refreshSnapshot`),children:(0,K.jsx)(Ol,{className:`w-4 h-4 text-bambu-gray ${Fe?`animate-spin`:``}`})}),(0,K.jsx)(`button`,{onClick:()=>v(!0),className:`p-1.5 hover:bg-bambu-dark-tertiary rounded`,title:e(`camera.diagnose.button`),children:(0,K.jsx)(cu,{className:`w-4 h-4 text-bambu-gray`})}),(0,K.jsx)(`button`,{onClick:be,className:`p-1.5 hover:bg-bambu-dark-tertiary rounded`,title:e(O?`camera.exitFullscreen`:`camera.fullscreen`),children:O?(0,K.jsx)(il,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(el,{className:`w-4 h-4 text-bambu-gray`})})]})]}),(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center p-2 overflow-hidden`,onWheel:Ce,onMouseMove:Ee,onMouseUp:De,onMouseLeave:De,onTouchStart:Ae,onTouchMove:je,onTouchEnd:Me,style:{touchAction:`none`},children:(0,K.jsxs)(`div`,{className:`relative w-full h-full flex items-center justify-center`,children:[(S||E)&&!M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(Ol,{className:`w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(p===`stream`?`camera.connectingToCamera`:`camera.capturingSnapshot`)})]})}),M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/80 z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-4`,children:[(0,K.jsx)(Pu,{className:`w-10 h-10 text-orange-400 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:e(`camera.connectionLost`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-3`,children:e(`camera.reconnecting`,{countdown:P,attempt:Math.min(A+1,i9),max:i9})}),(0,K.jsx)(`button`,{onClick:ye,className:`px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors`,children:e(`camera.reconnectNow`)})]})}),b&&!M&&(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black z-10`,children:(0,K.jsxs)(`div`,{className:`text-center p-4`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12 text-orange-400 mx-auto mb-3`}),(0,K.jsx)(`p`,{className:`text-white mb-2`,children:e(`camera.cameraUnavailable`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-4 max-w-md`,children:e(`camera.cameraUnavailableDesc`)}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[(0,K.jsx)(`button`,{onClick:ye,className:`px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors`,children:e(`camera.retry`)}),(0,K.jsx)(`button`,{onClick:()=>v(!0),className:`px-4 py-2 bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white rounded transition-colors`,children:e(`camera.diagnose.button`)})]})]})}),(0,K.jsx)(`img`,{ref:ae,src:Pe,alt:e(`camera.cameraStream`),className:`max-w-full max-h-full object-contain select-none`,style:{transform:`scale(${I}) translate(${R.x/I}px, ${R.y/I}px) rotate(${le?.camera_rotation||0}deg)`,...le?.camera_rotation===90||le?.camera_rotation===270?{maxWidth:`100vh`,maxHeight:`100vw`}:{},cursor:I>1?B?`grabbing`:`grab`:`default`},onError:Pe?he:void 0,onLoad:Pe?ge:void 0,onMouseDown:we,draggable:!1},w),(0,K.jsxs)(`div`,{className:`absolute bottom-4 left-4 flex items-center gap-1.5 bg-black/60 rounded-lg px-2 py-1.5`,children:[(0,K.jsx)(`button`,{onClick:Se,disabled:I<=1,className:`p-1.5 hover:bg-white/10 rounded disabled:opacity-30`,title:e(`camera.zoomOut`),children:(0,K.jsx)(Vu,{className:`w-4 h-4 text-white`})}),(0,K.jsxs)(`button`,{onClick:Ne,className:`px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]`,title:e(`camera.resetZoom`),children:[Math.round(I*100),`%`]}),(0,K.jsx)(`button`,{onClick:xe,disabled:I>=4,className:`p-1.5 hover:bg-white/10 rounded disabled:opacity-30`,title:e(`camera.zoomIn`),children:(0,K.jsx)(zu,{className:`w-4 h-4 text-white`})})]})]})}),(0,K.jsx)(lT,{printerId:s,isOpen:h,onClose:()=>g(!1)}),_&&(0,K.jsx)(uT,{printerId:s,printerName:le?.name||null,onClose:()=>v(!1)})]}):(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-white`,children:e(`camera.invalidPrinterId`)})})}function OXe(e,t,n){if(!e)return``;if(!t)return e;let r=t.match(/plate_(\d+)\.gcode/);return r&&parseInt(r[1],10)>1?`${e} — ${n(`printers.plateNumber`,`Plate {{number}}`,{number:r[1]})}`:e}function kXe(e){let t=e.get(`show`)?.split(`,`)||[`progress`,`layers`,`eta`,`filename`,`status`],n=parseInt(e.get(`fps`)||`15`,10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=e.get(`camera`),a=i!==`false`&&i!==`0`;return{size:e.get(`size`)||`medium`,fps:r,showCamera:a,showProgress:t.includes(`progress`),showLayers:t.includes(`layers`),showEta:t.includes(`eta`),showFilename:t.includes(`filename`),showStatus:t.includes(`status`),showPrinter:t.includes(`printer`)}}function AXe(e,t){if(e.stg_cur_name)return e.stg_cur_name;switch(e.state){case`RUNNING`:return t(`streamOverlay.status.printing`);case`PAUSE`:return t(`streamOverlay.status.paused`);case`FINISH`:return t(`streamOverlay.status.finished`);case`FAILED`:return t(`streamOverlay.status.failed`);case`IDLE`:return t(`streamOverlay.status.idle`);default:return e.state||t(`streamOverlay.status.unknown`)}}function jXe(e){switch(e){case`small`:return{container:`p-3`,text:`text-sm`,textLarge:`text-lg`,progressHeight:`h-2`,icon:`w-3 h-3`,gap:`gap-2`,logoHeight:`h-12`};case`large`:return{container:`p-6`,text:`text-xl`,textLarge:`text-3xl`,progressHeight:`h-4`,icon:`w-6 h-6`,gap:`gap-4`,logoHeight:`h-24`};default:return{container:`p-4`,text:`text-base`,textLarge:`text-xl`,progressHeight:`h-3`,icon:`w-4 h-4`,gap:`gap-3`,logoHeight:`h-16`}}}function MXe(){let{printerId:e}=ir(),[t]=Mi(),{t:n}=W(),r=no(),i=parseInt(e||`0`,10),[a,o]=(0,y.useState)(Date.now()),s=(0,y.useMemo)(()=>kXe(t),[t]),c=jXe(s.size),{data:l}=q({queryKey:[`printer`,i],queryFn:()=>Q.getPrinter(i),enabled:i>0}),{data:u}=q({queryKey:[`printerStatus`,i],queryFn:()=>Q.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3}),{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings}),f=d?.time_format||`system`;(0,y.useEffect)(()=>{if(!i)return;let e=null,t=!1;return(async()=>{let n;try{n=(await Q.getWebSocketToken()).token}catch{}if(t)return;let a=window.location.protocol===`https:`?`wss:`:`ws:`,o=n?`?token=${encodeURIComponent(n)}`:``,s=`${a}//${window.location.host}/api/v1/ws${o}`;e=new WebSocket(s),e.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`printer_status`&&t.printer_id===i&&r.setQueryData([`printerStatus`,i],t.status)}catch{}},e.onerror=()=>{}})(),()=>{t=!0,e&&e.close()}},[i,r]),(0,y.useEffect)(()=>(document.title=l?`${l.name} - ${n(`streamOverlay.title`)}`:n(`streamOverlay.title`),()=>{document.title=`Bambuddy`}),[l,n]);let p=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-white`,children:n(`streamOverlay.invalidPrinterId`)})});if(!u)return(0,K.jsx)(`div`,{className:`min-h-screen bg-black flex items-center justify-center`,children:(0,K.jsx)(`p`,{className:`text-gray-400`,children:n(`common.loading`)})});let m=u.state===`RUNNING`||u.state===`PAUSE`,h=u.progress||0,g=Xu(`/api/v1/printers/${i}/camera/stream?fps=${s.fps}&t=${a}`);return(0,K.jsxs)(`div`,{className:`min-h-screen bg-black relative overflow-hidden`,children:[s.showCamera&&(0,K.jsx)(`img`,{src:g,alt:n(`streamOverlay.cameraStream`),className:`absolute inset-0 w-full h-full object-contain`,style:l?.camera_rotation?{transform:`rotate(${l.camera_rotation}deg)`}:void 0,onError:p},a),(0,K.jsx)(`a`,{href:`https://github.com/maziggy/bambuddy`,target:`_blank`,rel:`noopener noreferrer`,className:`absolute top-4 right-4 z-10`,children:(0,K.jsx)(`img`,{src:`/img/bambuddy_logo_dark_transparent.png`,alt:`Bambuddy`,className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),(0,K.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent`,children:(0,K.jsxs)(`div`,{className:`${c.container}`,children:[s.showPrinter&&l&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} mb-2`,children:[(0,K.jsx)(Tl,{className:`${c.icon} text-white/70`}),(0,K.jsx)(`span`,{className:`${c.text} text-white font-medium`,children:l.name})]}),s.showFilename&&u.current_print&&(0,K.jsx)(`div`,{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:OXe(u.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,``),u.gcode_file,n)}),s.showStatus&&(0,K.jsx)(`div`,{className:`${c.text} text-white/70 mb-2`,children:AXe(u,n)}),s.showProgress&&m&&(0,K.jsxs)(`div`,{className:`mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-1 ${c.text}`,children:[(0,K.jsx)(`span`,{className:`text-white/70`,children:n(`streamOverlay.progress`)}),(0,K.jsxs)(`span`,{className:`text-white font-bold`,children:[Math.round(h),`%`]})]}),(0,K.jsx)(`div`,{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:(0,K.jsx)(`div`,{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${h}%`}})})]}),m&&(s.showLayers||s.showEta)&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} flex-wrap`,children:[s.showLayers&&u.layer_num!=null&&u.total_layers!=null&&u.total_layers>0&&(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(Rc,{className:c.icon}),(0,K.jsxs)(`span`,{className:c.text,children:[(0,K.jsx)(`span`,{className:`text-white`,children:u.layer_num}),(0,K.jsx)(`span`,{className:`mx-1`,children:`/`}),(0,K.jsx)(`span`,{children:u.total_layers})]})]}),s.showEta&&u.remaining_time!=null&&u.remaining_time>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(yu,{className:c.icon}),(0,K.jsx)(`span`,{className:`${c.text} text-white`,children:Cf(u.remaining_time*60)})]}),(0,K.jsxs)(`div`,{className:`flex items-center ${c.gap} text-white/70`,children:[(0,K.jsx)(Ss,{className:c.icon}),(0,K.jsxs)(`span`,{className:`${c.text} text-white`,children:[n(`streamOverlay.eta`),` `,Sf(u.remaining_time,f,n)]})]})]})]}),!m&&(0,K.jsx)(`div`,{className:`${c.text} text-white/70 py-2`,children:u.connected?n(`streamOverlay.printerIdle`):n(`streamOverlay.printerOffline`)})]})})]})}function NXe(){let{t:e}=W(),{id:t}=ir(),{mode:n}=md(),{data:r,isLoading:i,error:a}=q({queryKey:[`external-link`,t],queryFn:()=>Q.getExternalLink(Number(t)),enabled:!!t});return i?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):a||!r?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-bambu-gray`,children:[(0,K.jsx)(Cu,{className:`w-12 h-12`}),(0,K.jsx)(`p`,{children:e(`common.linkNotFound`)})]}):(0,K.jsx)(`iframe`,{src:r.url,className:`h-full w-full border-0`,style:{colorScheme:n},title:r.name,sandbox:`allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox`})}function a9(){let{id:e}=ir(),t=$n(),n=no(),{t:r}=W(),{showToast:i}=Td(),a=!!e,[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)([]),[f,p]=(0,y.useState)(``),[m,h]=(0,y.useState)(!1),{data:g,isLoading:_}=q({queryKey:[`group`,e],queryFn:()=>Q.getGroup(Number(e)),enabled:a}),{data:v,isLoading:b}=q({queryKey:[`permissions`],queryFn:()=>Q.getPermissions()});a&&g&&!m&&(s(g.name),l(g.description||``),d(g.permissions),h(!0));let x=J({mutationFn:e=>Q.createGroup(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`groups`]}),n.invalidateQueries({queryKey:[`group`]}),i(r(`groups.toast.created`)),t(`/settings?tab=users`)},onError:e=>{i(e.message,`error`)}}),S=J({mutationFn:t=>Q.updateGroup(Number(e),t),onSuccess:a=>{n.invalidateQueries({queryKey:[`groups`]}),a&&n.setQueryData([`group`,e],a),i(r(`groups.toast.updated`)),t(`/settings?tab=users`)},onError:e=>{i(e.message,`error`)}}),C=x.isPending||S.isPending,w=()=>{if(!o.trim()){i(r(`groups.toast.enterGroupName`),`error`);return}a?S.mutate({name:o===g?.name?void 0:o,description:c,permissions:u}):x.mutate({name:o,description:c||void 0,permissions:u})},T=e=>{d(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},E=(e,t)=>{let n=e.permissions.map(e=>e.value);d(e=>{let r=e.filter(e=>!n.includes(e));return t?[...r,...n]:r})},D=e=>e.permissions.every(e=>u.includes(e.value)),O=e=>{let t=e.permissions.filter(e=>u.includes(e.value)).length;return t>0&&t{v&&d(v.all_permissions)},A=()=>{d([])},j=f.toLowerCase(),M=(0,y.useMemo)(()=>v?j?v.categories.map(e=>({...e,permissions:e.permissions.filter(e=>e.label.toLowerCase().includes(j))})).filter(e=>e.permissions.length>0):v.categories:[],[v,j]),N=v?.all_permissions.length??0;return _||b?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):(0,K.jsxs)(`div`,{className:`space-y-6 max-w-5xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>t(`/settings?tab=users`),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(jo,{className:`w-5 h-5`})}),(0,K.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:r(a?`groups.editor.title`:`groups.editor.createTitle`)})]}),a&&g?.is_system&&(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg bg-yellow-500/10 border border-yellow-500/20 text-yellow-400 text-sm`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 shrink-0`}),r(`groups.form.systemGroupWarning`)]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:r(`groups.form.groupName`)}),(0,K.jsx)(`input`,{type:`text`,value:o,onChange:e=>s(e.target.value),disabled:a&&g?.is_system,className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-50`,placeholder:r(`groups.form.groupNamePlaceholder`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-white mb-2`,children:r(`groups.form.description`)}),(0,K.jsx)(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),className:`w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`groups.form.descriptionPlaceholder`)})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[r(`groups.editor.permissionsSelected`,{count:u.length}),` / `,N]}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:k,children:r(`groups.editor.selectAll`)}),(0,K.jsx)($,{size:`sm`,variant:`ghost`,onClick:A,children:r(`groups.editor.clearAll`)})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),placeholder:r(`groups.editor.search`),className:`pl-9 pr-4 py-2 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors w-64`})]})]}),M.length===0?(0,K.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:r(`groups.editor.noResults`)}):(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:M.map(e=>{let t=v.categories.find(t=>t.name===e.name),n=t.permissions.filter(e=>u.includes(e.value)).length,r=t.permissions.length,i=D(t),a=O(t);return(0,K.jsxs)(_d,{children:[(0,K.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center justify-between px-4 py-3 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-t-xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>E(t,!i),className:`w-5 h-5 rounded border flex items-center justify-center transition-colors shrink-0 ${i?`bg-bambu-green border-bambu-green`:a?`bg-bambu-green/50 border-bambu-green`:`border-bambu-gray hover:border-white`}`,children:[i&&(0,K.jsx)(rs,{className:`w-3 h-3 text-white`}),a&&!i&&(0,K.jsx)(al,{className:`w-3 h-3 text-white`})]}),(0,K.jsx)(ql,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-white font-medium text-sm`,children:e.name})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray tabular-nums`,children:[n,`/`,r]})]}),(0,K.jsx)(`div`,{className:`p-3 space-y-1`,children:e.permissions.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:u.includes(e.value),onChange:()=>T(e.value),className:`w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary`}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.label})]},e.value))})]},e.name)})}),(0,K.jsx)(`div`,{className:`h-16`}),(0,K.jsxs)(`div`,{className:`fixed bottom-0 left-0 right-0 z-20 px-6 py-3 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-center justify-center gap-3`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:()=>t(`/settings?tab=users`),children:r(`common.cancel`)}),(0,K.jsx)($,{onClick:w,disabled:C||!o.trim(),children:C?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.saving`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),r(`common.save`)]})})]})]})}var PXe=1.65,o9=[`#1DB954`,`#3B82F6`,`#F59E0B`,`#EF4444`,`#8B5CF6`];function s9(e,t,n,r){return`${e}||${t??``}||${n??``}||${r??``}`}function c9(e,t){let n=new Date(e);return n.setDate(n.getDate()+Math.round(t)),n}function l9(e){return e.toLocaleDateString(void 0,{month:`short`,day:`numeric`,year:`numeric`})}function u9(e){return e.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function FXe(e){if(e.length<2)return null;let t=new Map;for(let n of e){let e=n.created_at.slice(0,10);t.set(e,(t.get(e)??0)+n.weight_used)}if(t.size<2)return null;let n=[...t.entries()].map(([e,t])=>({ms:new Date(e).getTime(),totalG:t})).sort((e,t)=>e.ms-t.ms),r=Date.now(),i=Math.LN2/30,a=[];for(let e=1;ee+t.weight,0);if(o===0)return null;let s=a.reduce((e,t)=>e+t.rate*t.weight,0)/o,c=a.reduce((e,t)=>e+t.weight*(t.rate-s)**2,0)/o;return{rate:s,stdDev:Math.sqrt(c)}}function IXe(e){let t=e.reduce((e,t)=>e+Math.max(0,t.weight_used-(t.weight_used_baseline??0)),0);if(t===0)return null;let n=Date.now(),r=(n-e.reduce((e,t)=>{let n=new Date(t.created_at).getTime();return nQ.getAllUsageHistory(5e3),staleTime:6e4,enabled:o}),{data:O=[]}=q({queryKey:[`shopping-list`],queryFn:Q.getShoppingList,staleTime:3e4,enabled:o}),k=T?.forecast_global_lead_time_days??0,A=(0,y.useMemo)(()=>{let e=new Map;for(let t of E)e.set(s9(t.material,t.subtype,t.brand,t.color_name),t);return e},[E]),j=(0,y.useMemo)(()=>{let e=new Map;for(let t of D){let n=e.get(t.spool_id)??[];n.push(t),e.set(t.spool_id,n)}return e},[D]),M=(0,y.useMemo)(()=>{let t=new Map;for(let n of e){if(n.archived_at)continue;let e=s9(n.material,n.subtype,n.brand,n.color_name),r=t.get(e)??{key:e,material:n.material,subtype:n.subtype,brand:n.brand,colorName:n.color_name,spools:[]};r.spools.push(n),t.set(e,r)}return[...t.values()]},[e]),N=(0,y.useMemo)(()=>{let e=new Date;return e.setHours(0,0,0,0),M.map(t=>{let n=A.get(t.key)??(t.colorName===null?null:A.get(s9(t.material,t.subtype,t.brand,null))??null),r=n?.lead_time_days??0,i=Math.max(k,r),a=n?.safety_margin_value??14,o=n?.safety_margin_unit??`days`,s=t.spools.reduce((e,t)=>e+Math.max(0,t.label_weight-t.weight_used),0),c=t.spools.reduce((e,t)=>e+t.label_weight,0),l=t.spools.reduce((e,t)=>e+Math.max(0,t.weight_used-(t.weight_used_baseline??0)),0),u=[];for(let e of t.spools)(e.weight_used_baseline??0)===0&&u.push(...j.get(e.id)??[]);let d=null,f=null,p=`none`,m=FXe(u);if(m!==null)d=m.rate,f=m.stdDev,p=`history`;else{let e=IXe(t.spools);e!==null&&(d=e,p=`delta`)}let h=PXe*(f??(d===null?0:d*.2))*Math.sqrt(i)+(o===`g`?a:d===null?a*5:d*a),g=d===null?0:d*i+h,_=d&&d>0?Math.floor(s/d):null,v=_===null?null:c9(e,_),y=d&&d>0?Math.floor((s-g)/d):null,b=y===null?null:c9(e,Math.max(0,y)),x=_!==null&&i>0&&_<=i,S=!x&&y!==null&&y<=0;return{group:t,settings:n,totalRemainingG:s,totalLabelG:c,totalSpools:t.spools.length,totalUsedG:l,dailyRateG:d,dailyRateStdDev:f,rateTier:p,effectiveLeadTimeDays:i,safetyStockG:h,reorderPointG:g,daysRemaining:_,daysUntilROP:y,projectedEmptyDate:v,reorderTriggerDate:b,reorderAlert:S,stockBreakAlert:x}})},[M,A,j,k]),P=(0,y.useMemo)(()=>[...new Set(M.map(e=>e.material))].sort(),[M]),F=(0,y.useMemo)(()=>[...new Set(M.map(e=>e.brand).filter(Boolean))].sort(),[M]),I=(0,y.useMemo)(()=>{let e=[...N];return m&&(e=e.filter(e=>e.group.material===m)),g&&(e=e.filter(e=>e.group.brand===g)),e.sort((e,t)=>{let n=0,r=0;switch(u){case`material`:n=[e.group.material,e.group.subtype??``,e.group.brand??``].join(` `).toLowerCase(),r=[t.group.material,t.group.subtype??``,t.group.brand??``].join(` `).toLowerCase();break;case`used`:n=e.totalUsedG,r=t.totalUsedG;break;case`days_left`:n=e.daysRemaining??999999,r=t.daysRemaining??999999;break;case`stock`:n=e.totalRemainingG,r=t.totalRemainingG;break}let i=nr);return f===`asc`?i:-i}),e},[N,u,f,m,g]),L=(0,y.useMemo)(()=>N.filter(e=>!e.settings?.alerts_snoozed&&(e.stockBreakAlert||e.reorderAlert)),[N]),R=(0,y.useMemo)(()=>[...N].filter(e=>e.dailyRateG!==null).sort((e,t)=>t.totalUsedG-e.totalUsedG).slice(0,5),[N]);if(!o)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-bambu-gray gap-3`,children:[(0,K.jsx)(qc,{className:`w-8 h-8 opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`forecast.noReadAccess`)})]});function z(e){u===e?p(e=>e===`asc`?`desc`:`asc`):(d(e),p(e===`days_left`?`asc`:`desc`))}let B=O.length>0?O.length:null;return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[L.length>0&&(0,K.jsxs)(`button`,{onClick:()=>l(e=>!e),className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors ${L.some(e=>e.stockBreakAlert)?`bg-red-500/15 border-red-500/30 text-red-300 hover:bg-red-500/25`:`bg-yellow-500/15 border-yellow-500/30 text-yellow-300 hover:bg-yellow-500/25`}`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4`}),r(`forecast.alertCount`,{count:L.length}),c?(0,K.jsx)(cs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(is,{className:`w-3.5 h-3.5`})]}),s&&(0,K.jsx)(HXe,{value:k,onSave:e=>{Q.updateSettings({forecast_global_lead_time_days:e}).then(()=>{t.invalidateQueries({queryKey:[`settings`]}),n(r(`forecast.globalLeadTimeSaved`),`success`)})}}),(0,K.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${m?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:r(`inventory.material`)}),P.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${g?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:r(`inventory.brand`)}),F.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`button`,{onClick:()=>S(e=>!e),className:`relative flex items-center gap-2 px-3 py-1.5 rounded-lg border border-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary text-sm transition-colors ml-auto`,children:[(0,K.jsx)(Jl,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:r(`forecast.shoppingList`)}),B&&(0,K.jsx)(`span`,{className:`absolute -top-1.5 -right-1.5 w-4 h-4 rounded-full bg-bambu-green text-white text-[10px] font-bold flex items-center justify-center`,children:B})]})]}),c&&L.length>0&&(0,K.jsx)(`div`,{className:`space-y-2`,children:L.map(e=>(0,K.jsx)(zXe,{forecast:e,onCart:()=>b(e)},e.group.key))}),x&&(0,K.jsx)(KXe,{items:O,forecasts:N,globalLeadTime:k,canWrite:s,onClose:()=>S(!1),onRemove:e=>{Q.removeFromShoppingList(e).then(()=>t.invalidateQueries({queryKey:[`shopping-list`]})).catch(()=>n(r(`forecast.failedSaveSettings`),`error`))},onClear:()=>{Q.clearShoppingList().then(()=>t.invalidateQueries({queryKey:[`shopping-list`]})).catch(()=>n(r(`forecast.failedSaveSettings`),`error`))}}),R.length>0&&(0,K.jsx)(VXe,{forecasts:R,days:C,onDaysChange:w}),N.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(xu,{className:`w-10 h-10 mb-3 opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm`,children:r(`forecast.noSpools`)})]}):(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`w-8 px-4 py-3`}),(0,K.jsx)(d9,{col:`material`,active:u,dir:f,onSort:z,children:r(`forecast.sku`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:r(`locations.spools`)}),(0,K.jsx)(d9,{col:`stock`,active:u,dir:f,onSort:z,children:r(`forecast.stock`)}),(0,K.jsx)(d9,{col:`used`,active:u,dir:f,onSort:z,children:r(`forecast.dailyRate`)}),(0,K.jsx)(d9,{col:`days_left`,active:u,dir:f,onSort:z,children:r(`forecast.daysLeft`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:r(`forecast.emptyBy`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:r(`forecast.reorderBy`)}),(0,K.jsx)(`th`,{className:`w-24 px-4 py-3`})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:I.map(e=>(0,K.jsx)(UXe,{forecast:e,globalLeadTime:k,canWrite:s,onSaved:()=>t.invalidateQueries({queryKey:[`sku-settings`]}),onCart:()=>b(e),showToast:n},e.group.key))})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-3 text-xs text-bambu-gray border-t border-bambu-dark-tertiary bg-bambu-dark-tertiary/20`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-bambu-green inline-block`}),r(`forecast.trendLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-blue-400 inline-block`}),r(`forecast.estimatedLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 rounded-full bg-bambu-gray/40 inline-block`}),r(`forecast.noDataLegend`)]})]})]}),v&&(0,K.jsx)(JXe,{forecast:v,onClose:()=>b(null),onAdd:e=>{Q.addToShoppingList(e).then(()=>{t.invalidateQueries({queryKey:[`shopping-list`]}),n(r(`forecast.addedToCart`),`success`),b(null),S(!0)}).catch(()=>n(r(`forecast.failedAddItem`),`error`))}})]})}function d9({col:e,active:t,dir:n,onSort:r,children:i}){return(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide cursor-pointer select-none hover:text-white transition-colors`,onClick:()=>r(e),children:(0,K.jsxs)(`span`,{className:`inline-flex items-center`,children:[i,t===e?n===`asc`?(0,K.jsx)(Io,{className:`w-3 h-3 ml-1 text-bambu-green`}):(0,K.jsx)(Ao,{className:`w-3 h-3 ml-1 text-bambu-green`}):(0,K.jsx)(Po,{className:`w-3 h-3 ml-1 opacity-40`})]})})}function zXe({forecast:e,onCart:t}){let{t:n}=W(),r=[e.group.brand,e.group.material,e.group.subtype,e.group.colorName].filter(Boolean).join(` `),i=e.stockBreakAlert;return(0,K.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-3 rounded-lg border text-sm ${i?`bg-red-500/10 border-red-500/30 text-red-300`:`bg-yellow-500/10 border-yellow-500/30 text-yellow-300`}`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-medium`,children:r}),i?(0,K.jsxs)(`span`,{className:`ml-2 text-xs opacity-80`,children:[n(`forecast.stockBreakRisk`),` — `,n(`forecast.stockBreakDetail`,{days:e.daysRemaining,lt:e.effectiveLeadTimeDays})]}):(0,K.jsxs)(`span`,{className:`ml-2 text-xs opacity-80`,children:[n(`forecast.reorderNow`),` — `,n(`forecast.reorderTriggerPassed`,{date:e.reorderTriggerDate?l9(e.reorderTriggerDate):`—`})]})]}),(0,K.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 px-2.5 py-1 rounded border border-current text-xs opacity-70 hover:opacity-100 transition-opacity`,children:[(0,K.jsx)(Jl,{className:`w-3 h-3`}),` `,n(`forecast.order`)]})]})}var BXe=[{label:`1W`,value:7},{label:`1M`,value:30},{label:`6M`,value:180}];function VXe({forecasts:e,days:t,onDaysChange:n}){let{t:r}=W(),i=Array.from({length:t+1},(e,t)=>t),a=e.map((e,n)=>({key:e.group.key,label:[e.group.brand,e.group.material,e.group.subtype,e.group.colorName].filter(Boolean).join(` `),color:o9[n%o9.length],rop:e.reorderPointG,points:LXe(e,t)})),o=i.map(e=>{let t={day:e,label:u9(c9(new Date,e))};for(let n of a){let r=n.points.find(t=>t.day===e);t[n.key]=r?.stock??0}return t}),s=(()=>{for(let e=t;e>=0;e--)if(a.some(t=>o[e]?.[t.key]>0))return e;return t})(),c=o.slice(0,s+1),l=a.filter(e=>e.rop>0);return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:r(`forecast.chartTitle`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray ml-1 hidden sm:inline`,children:r(`forecast.dashedLinesROP`)}),(0,K.jsx)(`div`,{className:`ml-auto flex items-center bg-bambu-dark-tertiary rounded-lg p-0.5`,children:BXe.map(e=>(0,K.jsx)(`button`,{onClick:()=>n(e.value),className:`px-2.5 py-1 text-xs font-medium rounded-md transition-colors ${t===e.value?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:e.label},e.value))})]}),(0,K.jsx)(mA,{width:`100%`,height:220,children:(0,K.jsxs)(sU,{data:c,margin:{top:4,right:8,bottom:0,left:0},children:[(0,K.jsx)(`defs`,{children:a.map(e=>(0,K.jsxs)(`linearGradient`,{id:`grad-${e.key}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,K.jsx)(`stop`,{offset:`5%`,stopColor:e.color,stopOpacity:.25}),(0,K.jsx)(`stop`,{offset:`95%`,stopColor:e.color,stopOpacity:.02})]},e.key))}),(0,K.jsx)(DV,{strokeDasharray:`3 3`,stroke:`#374151`,strokeOpacity:.5}),(0,K.jsx)(_H,{dataKey:`label`,tick:{fill:`#6B7280`,fontSize:10},interval:Math.max(0,Math.ceil(s/8)-1),axisLine:!1,tickLine:!1}),(0,K.jsx)(SH,{tick:{fill:`#6B7280`,fontSize:10},axisLine:!1,tickLine:!1,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(1)}kg`:`${e}g`,width:48}),(0,K.jsx)(lz,{content:({label:e,payload:t})=>t?.length?(0,K.jsxs)(`div`,{style:{background:`#1a1a2e`,border:`1px solid #374151`,borderRadius:8,fontSize:12,padding:`8px 12px`},children:[(0,K.jsx)(`div`,{style:{color:`#9CA3AF`,marginBottom:6},children:e}),t.map(e=>{let t=a.find(t=>t.key===String(e.dataKey));return typeof e.value==`number`?(0,K.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:6,color:`#E5E7EB`,marginBottom:2},children:[(0,K.jsx)(`span`,{style:{color:t?.color??`#9CA3AF`,fontSize:10},children:`●`}),(0,K.jsx)(`span`,{children:t?.label??String(e.dataKey)}),(0,K.jsxs)(`span`,{style:{color:`#9CA3AF`,marginLeft:4},children:[e.value,`g`]})]},String(e.dataKey)):null})]}):null}),(0,K.jsx)(fj,{formatter:e=>(0,K.jsx)(`span`,{style:{color:`#9CA3AF`,fontSize:11},children:a.find(t=>t.key===e)?.label??e})}),a.map(e=>(0,K.jsx)(YV,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:2,fill:`url(#grad-${e.key})`,dot:!1,activeDot:{r:3}},e.key)),l.map(e=>(0,K.jsx)(dV,{y:e.rop,stroke:e.color,strokeDasharray:`4 3`,strokeOpacity:.6},`rop-${e.key}`))]})})]})}function HXe({value:e,onSave:t}){let{t:n}=W(),[r,i]=(0,y.useState)(!1),[a,o]=(0,y.useState)(String(e));function s(){let e=parseInt(a,10);isNaN(e)||e<0||(t(e),i(!1))}return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 bg-bambu-dark-tertiary/40 rounded-lg border border-bambu-dark-tertiary text-xs text-bambu-gray`,children:[(0,K.jsx)(Pc,{className:`w-3.5 h-3.5 flex-shrink-0`,"aria-label":n(`forecast.globalLeadTimeHint`)}),(0,K.jsxs)(`span`,{className:`hidden sm:inline`,children:[n(`forecast.globalLeadTime`),`:`]}),r?(0,K.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault(),s()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:365,value:a,onChange:e=>o(e.target.value),className:`w-14 px-1.5 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:`d`}),(0,K.jsx)(`button`,{type:`submit`,className:`px-2 py-0.5 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80`,children:n(`forecast.save`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`text-xs text-bambu-gray hover:text-white`,children:`✕`})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsxs)(`span`,{className:`font-semibold text-white`,children:[e,`d`]}),(0,K.jsx)(`button`,{onClick:()=>{o(String(e)),i(!0)},className:`p-0.5 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function UXe({forecast:e,globalLeadTime:t,canWrite:n,onSaved:r,onCart:i,showToast:a}){let{t:o}=W(),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(String(e.settings?.lead_time_days??0)),[h,g]=(0,y.useState)(String(e.settings?.safety_margin_value??14)),[_,v]=(0,y.useState)(e.settings?.safety_margin_unit??`days`);(0,y.useEffect)(()=>{l||m(String(e.settings?.lead_time_days??0))},[e.settings?.lead_time_days,l]),(0,y.useEffect)(()=>{d||(g(String(e.settings?.safety_margin_value??14)),v(e.settings?.safety_margin_unit??`days`))},[e.settings?.safety_margin_value,e.settings?.safety_margin_unit,d]);let b=J({mutationFn:Q.upsertSkuSettings,onSuccess:()=>{r(),a(o(`forecast.settingsSaved`),`success`)},onError:()=>a(o(`forecast.failedSaveSettings`),`error`)}),x=e.settings?.alerts_snoozed??!1,S=[e.group.brand,e.group.material,e.group.subtype,e.group.colorName].filter(Boolean).join(` `),C=e.group.spools[0]?.rgba?Jd(e.group.spools[0].rgba):{backgroundColor:`#4B5563`},w=e.totalLabelG>0?Math.round(e.totalRemainingG/e.totalLabelG*100):0,T=x||e.daysRemaining===null?`text-bambu-gray`:e.stockBreakAlert?`text-red-400`:e.reorderAlert||e.daysRemaining<30?`text-yellow-400`:`text-green-400`;function E(t,n,r,i=x){b.mutate({material:e.group.material,subtype:e.group.subtype,brand:e.group.brand,color_name:e.group.colorName,lead_time_days:t,safety_margin_value:n,safety_margin_unit:r,alerts_snoozed:i})}function D(t){t.stopPropagation(),E(e.settings?.lead_time_days??0,e.settings?.safety_margin_value??14,e.settings?.safety_margin_unit??`days`,!x)}let O=e.rateTier===`history`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-bambu-green/15 text-bambu-green`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-green`}),o(`forecast.trend`)]}):e.rateTier===`delta`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-blue-400/15 text-blue-400`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-blue-400`}),o(`forecast.estimated`)]}):(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded bg-bambu-dark-tertiary text-bambu-gray/60`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-bambu-gray/40`}),o(`forecast.noData`)]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 cursor-pointer hover:bg-bambu-dark-tertiary/30 transition-colors ${x?``:e.stockBreakAlert?`bg-red-500/5`:e.reorderAlert?`bg-yellow-500/5`:``} ${x?`opacity-50`:``}`,onClick:()=>c(e=>!e),children:[(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`block w-5 h-5 rounded-full border border-black/20`,style:C})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm text-white`,children:S})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.totalSpools})}),(0,K.jsx)(`td`,{className:`px-4 py-3 min-w-[140px]`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${w>50?`bg-bambu-green`:w>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(w,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray min-w-[40px] text-right`,children:[Math.round(e.totalRemainingG),`g`]})]})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.dailyRateG===null?`—`:`${e.dailyRateG.toFixed(1)}g/d`}),O]})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm font-semibold ${T}`,children:e.daysRemaining===null?(0,K.jsx)(`span`,{className:`text-bambu-gray font-normal`,children:`—`}):`${e.daysRemaining}d`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.projectedEmptyDate?l9(e.projectedEmptyDate):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,children:(0,K.jsx)(`span`,{className:`text-sm ${!x&&e.reorderAlert?`text-yellow-400`:`text-bambu-gray`}`,children:e.reorderTriggerDate?l9(e.reorderTriggerDate):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-3`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[n&&(0,K.jsx)(`button`,{onClick:i,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:o(`forecast.addToCart`),children:(0,K.jsx)(Jl,{className:`w-4 h-4`})}),!x&&(e.stockBreakAlert?(0,K.jsx)(Cu,{className:`w-4 h-4 text-red-400`,"aria-label":o(`forecast.stockBreakRisk`)}):e.reorderAlert?(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400`,"aria-label":o(`forecast.reorderNow`)}):e.daysRemaining===null?null:(0,K.jsx)(rs,{className:`w-4 h-4 text-bambu-green/50`})),n&&(0,K.jsx)(`button`,{onClick:D,className:`p-1 rounded transition-colors ${x?`text-amber-400/80 hover:text-amber-300`:`text-slate-400 hover:text-white`}`,title:o(x?`forecast.alertsEnabled`:`forecast.alertsSnoozed`),children:(0,K.jsx)(zo,{className:`w-3.5 h-3.5`})}),(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c(e=>!e)},className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,children:s?(0,K.jsx)(cs,{className:`w-4 h-4`}):(0,K.jsx)(is,{className:`w-4 h-4`})})]})})]}),s&&(0,K.jsx)(`tr`,{className:`bg-bambu-dark-tertiary/10`,children:(0,K.jsx)(`td`,{colSpan:9,className:`px-6 py-4`,children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`grid gap-2 ${n?`grid-cols-2 sm:grid-cols-4`:`grid-cols-2`}`,children:[(0,K.jsx)(f9,{label:o(`forecast.effectiveLeadTime`),value:`${e.effectiveLeadTimeDays}d`,hint:o(`forecast.effectiveLeadTimeHint`,{global:t,sku:e.settings?.lead_time_days??0})}),(0,K.jsx)(f9,{label:o(`forecast.reorderPoint`),value:`${Math.round(e.reorderPointG)}g`,hint:o(`forecast.reorderPointHint`)}),n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(WXe,{label:o(`forecast.skuLeadTimeOverride`),hint:o(`forecast.skuLeadTimeHint`),unit:o(`forecast.leadTime`),editing:l,value:e.settings?.lead_time_days??0,inputValue:p,onInputChange:m,onEdit:()=>{m(String(e.settings?.lead_time_days??0)),u(!0)},onSave:()=>{let t=parseInt(p,10);!isNaN(t)&&t>=0&&(E(t,e.settings?.safety_margin_value??14,_),u(!1))},onCancel:()=>u(!1),isPending:b.isPending,saveLabel:o(`forecast.save`),cancelLabel:o(`forecast.cancel`)}),(0,K.jsx)(GXe,{value:e.settings?.safety_margin_value??14,unit:_,editing:d,inputValue:h,dailyRateG:e.dailyRateG,onInputChange:g,onUnitChange:e=>v(e),onEdit:()=>{g(String(e.settings?.safety_margin_value??14)),v(e.settings?.safety_margin_unit??`days`),f(!0)},onSave:()=>{let t=parseInt(h,10);!isNaN(t)&&t>=0&&(E(e.settings?.lead_time_days??0,t,_),f(!1))},onCancel:()=>f(!1),isPending:b.isPending,saveLabel:o(`forecast.save`),cancelLabel:o(`forecast.cancel`),safetyMarginLabel:o(`forecast.safetyMarginLabel`)})]})]}),e.group.spools.length>1&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary pt-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:o(`forecast.individualSpools`)}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:`#`}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.remaining`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.used`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`forecast.labelWeight`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:e.group.spools.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used),n=e.label_weight>0?t/e.label_weight*100:0;return(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-tertiary/30 transition-colors`,children:[(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray/70`,children:[`#`,e.id]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-24 h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden flex-shrink-0`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${n>50?`bg-bambu-green`:n>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(n,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[Math.round(t),`g`]})]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[Math.round(Math.max(0,e.weight_used-(e.weight_used_baseline??0))),`g`]})}),(0,K.jsx)(`td`,{className:`px-4 py-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[e.label_weight,`g`]})})]},e.id)})})]})})]})]})})})]})}function f9({label:e,value:t,hint:n}){return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3`,title:n,children:[(0,K.jsx)(`div`,{className:`text-xs font-medium text-white mb-1`,children:e}),(0,K.jsx)(`div`,{className:`text-lg font-semibold text-white`,children:t})]})}function WXe({label:e,hint:t,unit:n,editing:r,value:i,inputValue:a,onInputChange:o,onEdit:s,onSave:c,onCancel:l,isPending:u,saveLabel:d=`Save`,cancelLabel:f=`Cancel`}){return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-white`,children:e}),(0,K.jsx)(`span`,{title:t,children:(0,K.jsx)(Pc,{className:`w-3 h-3 text-bambu-gray/50`})})]}),r?(0,K.jsxs)(`form`,{className:`flex items-center gap-2`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:365,value:a,onChange:e=>o(e.target.value),className:`w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0,disabled:u}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n}),(0,K.jsx)(`button`,{type:`submit`,disabled:u,className:`px-2 py-1 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:d}),(0,K.jsx)(`button`,{type:`button`,onClick:l,disabled:u,className:`px-2 py-1 text-xs text-bambu-gray hover:text-white`,children:f})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold text-white`,children:i}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:n}),(0,K.jsx)(`button`,{onClick:s,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function GXe({value:e,unit:t,editing:n,inputValue:r,dailyRateG:i,onInputChange:a,onUnitChange:o,onEdit:s,onSave:c,onCancel:l,isPending:u,saveLabel:d=`Save`,cancelLabel:f=`Cancel`,safetyMarginLabel:p=`Safety Margin`}){let{t:m}=W(),h=t===`g`?e:i===null?null:Math.round(i*e),g=t===`days`?m(`forecast.safetyMarginHintDays`,{approx:h===null?``:m(`forecast.safetyMarginHintDaysApprox`,{g:h})}):m(`forecast.safetyMarginHintG`,{approx:i===null?``:m(`forecast.safetyMarginHintGApprox`,{days:Math.round(e/i)})});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-tertiary/40 rounded-lg p-3 space-y-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs font-medium text-white`,children:p}),(0,K.jsx)(`span`,{title:g,children:(0,K.jsx)(Pc,{className:`w-3 h-3 text-bambu-gray/50`})})]}),n?(0,K.jsxs)(`form`,{className:`flex items-center gap-2 flex-wrap`,onSubmit:e=>{e.preventDefault(),c()},children:[(0,K.jsx)(`input`,{type:`number`,min:0,max:t===`g`?1e4:365,value:r,onChange:e=>a(e.target.value),className:`w-20 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,autoFocus:!0,disabled:u}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded overflow-hidden text-xs`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`days`),className:`px-2 py-1 transition-colors ${t===`days`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`days`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`g`),className:`px-2 py-1 transition-colors ${t===`g`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`g`})]}),(0,K.jsx)(`button`,{type:`submit`,disabled:u,className:`px-2 py-1 bg-bambu-green text-white text-xs rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:d}),(0,K.jsx)(`button`,{type:`button`,onClick:l,disabled:u,className:`px-2 py-1 text-xs text-bambu-gray hover:text-white`,children:f})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold text-white`,children:e}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:t}),h!==null&&t===`days`&&(0,K.jsxs)(`span`,{className:`text-lg font-semibold text-white`,children:[`≈ `,h,`g`]}),t===`g`&&i!==null&&(0,K.jsxs)(`span`,{className:`text-lg font-semibold text-white`,children:[`≈ `,Math.round(e/i),`d`]}),(0,K.jsx)(`button`,{onClick:s,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(_l,{className:`w-3 h-3`})})]})]})}function KXe({items:e,forecasts:t,globalLeadTime:n,canWrite:r,onClose:i,onRemove:a,onClear:o}){let{t:s}=W(),c=no(),[l,u]=(0,y.useState)(`list`),d=J({mutationFn:async({id:e,status:t,item:n,avgSpoolG:r})=>{if(await Q.updateShoppingListStatus(e,t),t===`received`&&n){let t=r??1e3,i={material:n.material,subtype:n.subtype,brand:n.brand,label_weight:t,core_weight:0,core_weight_catalog_id:null,color_name:n.color_name,rgba:null,extra_colors:null,effect_type:null,nozzle_temp_min:null,nozzle_temp_max:null,note:n.note??null,tag_uid:null,tray_uuid:null,data_origin:`manual`,tag_type:null,cost_per_kg:null,last_scale_weight:null,last_weighed_at:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,added_full:null,last_used:null,encode_time:null,category:`Stock`,low_stock_threshold_pct:null};await Q.bulkCreateSpools(i,n.quantity_spools),await Q.removeFromShoppingList(e)}},onSuccess:()=>{c.invalidateQueries({queryKey:[`shopping-list`]}),c.invalidateQueries({queryKey:[`spools`]})}}),f=(0,y.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.group.key,n);return e},[t]),p=(0,y.useMemo)(()=>e.map(e=>({item:e,forecast:f.get(s9(e.material,e.subtype,e.brand,e.color_name))??null})),[e,f]),m=(0,y.useMemo)(()=>p.filter(({forecast:e})=>!e||e.dailyRateG===null?!1:e.stockBreakAlert||e.daysRemaining!==null&&e.daysRemaining<=e.effectiveLeadTimeDays),[p]);function h(){let t=[s(`forecast.qty`),s(`forecast.material`),s(`inventory.brand`),s(`inventory.subtype`),s(`inventory.color`),`${s(`forecast.weight`)} (g)`,`${s(`forecast.leadTime`)} (d)`,s(`forecast.expectedRestock`),s(`forecast.status`),s(`forecast.note`)],r=e.map(e=>{let t=f.get(s9(e.material,e.subtype,e.brand,e.color_name))??null,r=t&&t.totalSpools>0?t.totalLabelG/t.totalSpools:1e3,i=Math.round(e.quantity_spools*r),a=t?.effectiveLeadTimeDays??n??0,o=a>0?l9(c9(new Date,a)):``;return[e.quantity_spools,e.material,e.brand??``,e.subtype??``,e.color_name??``,i,a||``,o,e.status,e.note??``].map(e=>`"${String(e).replace(/"/g,`""`)}"`).join(`,`)}),i=[t.join(`,`),...r].join(` +`),a=new Blob([i],{type:`text/csv`}),o=URL.createObjectURL(a),c=document.createElement(`a`);c.href=o,c.download=`shopping-list-${new Date().toISOString().slice(0,10)}.csv`,c.click(),setTimeout(()=>URL.revokeObjectURL(o),100)}return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(Jl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-white`,children:s(`forecast.shoppingList`)}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:s(`forecast.shoppingListItems`,{count:e.length})}),e.length>0&&(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-tertiary rounded-md p-0.5 ml-1`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(`list`),className:`flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium rounded transition-colors ${l===`list`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(pl,{className:`w-3 h-3`}),s(`forecast.listView`)]}),(0,K.jsxs)(`button`,{onClick:()=>u(`logistics`),className:`flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium rounded transition-colors ${l===`logistics`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(ts,{className:`w-3 h-3`}),s(`forecast.logisticsView`),m.length>0&&(0,K.jsx)(`span`,{className:`w-3.5 h-3.5 rounded-full bg-red-500 text-white text-[9px] font-bold flex items-center justify-center`,children:m.length})]})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`button`,{onClick:h,className:`flex items-center gap-1.5 text-xs text-bambu-gray hover:text-white transition-colors px-2 py-1 rounded border border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`,children:[(0,K.jsx)(Vs,{className:`w-3 h-3`}),s(`forecast.downloadCsv`)]}),r&&(0,K.jsx)(`button`,{onClick:o,className:`text-xs text-red-400 hover:text-red-300 transition-colors px-2 py-1 rounded border border-red-500/20 hover:bg-red-500/10`,children:s(`forecast.clearAll`)})]}),(0,K.jsx)(`button`,{onClick:i,className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),e.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center py-8 text-bambu-gray`,children:[(0,K.jsx)(pl,{className:`w-8 h-8 mb-2 opacity-30`}),(0,K.jsx)(`p`,{className:`text-sm`,children:s(`forecast.shoppingListEmpty`)})]}):l===`list`?(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/20`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.qty`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.material`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.weight`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.leadTime`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.expectedRestock`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.status`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.note`)}),(0,K.jsx)(`th`,{className:`px-4 py-2 text-right text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:s(`forecast.actions`)})]})}),(0,K.jsx)(`tbody`,{className:`divide-y divide-bambu-dark-tertiary`,children:e.map(e=>{let t=[e.brand,e.material,e.subtype,e.color_name].filter(Boolean).join(` `),i=m.some(t=>t.item.id===e.id),o=f.get(s9(e.material,e.subtype,e.brand,e.color_name))??null,c=o&&o.totalSpools>0?o.totalLabelG/o.totalSpools:1e3,l=Math.round(e.quantity_spools*c),u=o?.effectiveLeadTimeDays??n??0,p=u>0?c9(new Date,u):null,h=e.status===`purchased`||e.status===`received`,g=e.status===`received`,_=d.isPending;return(0,K.jsxs)(`tr`,{className:`hover:bg-bambu-dark-tertiary/30 transition-colors ${i&&!h?`bg-red-500/5`:``}`,children:[(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsxs)(`span`,{className:`text-sm font-semibold text-bambu-green`,children:[e.quantity_spools,`×`]})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-white`,children:t}),i&&!h&&(0,K.jsx)(Cu,{className:`w-3.5 h-3.5 text-red-400 flex-shrink-0`,"aria-label":s(`forecast.stockBreakBefore`)})]})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-white`,children:l>=1e3?`${(l/1e3).toFixed(1)}kg`:`${l}g`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:u>0?`${u}d`:`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:p?l9(p):`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${g?`bg-bambu-green/20 text-bambu-green`:h?`bg-blue-400/20 text-blue-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:s(g?`forecast.received`:h?`forecast.purchased`:`forecast.pending`)})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.note||`—`})}),(0,K.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,K.jsx)(`div`,{className:`flex items-center justify-end gap-1`,children:r&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>d.mutate({id:e.id,status:h?`pending`:`purchased`}),disabled:_||g,title:s(h?`forecast.resetToPending`:`forecast.markPurchased`),className:`p-1.5 rounded transition-colors disabled:opacity-30 ${h?`text-blue-400 hover:text-blue-300`:`text-blue-400/50 hover:text-blue-400`}`,children:h?(0,K.jsx)(Al,{className:`w-4 h-4`}):(0,K.jsx)(Ps,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>d.mutate({id:e.id,status:`received`,item:e,avgSpoolG:c}),disabled:_||!h||g,title:s(`forecast.markReceived`),className:`p-1.5 rounded transition-colors text-bambu-green/50 hover:text-bambu-green disabled:opacity-30`,children:(0,K.jsx)(dl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>a(e.id),className:`p-1 text-bambu-gray hover:text-red-400 transition-colors`,title:s(`forecast.remove`),children:(0,K.jsx)(bu,{className:`w-3.5 h-3.5`})})]})})})]},e.id)})})]})}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary`,children:p.filter(({item:e})=>e.status!==`received`).map(({item:e,forecast:t})=>(0,K.jsx)(qXe,{item:e,forecast:t,globalLeadTime:n,canWrite:r,onRemove:()=>a(e.id)},e.id))})]})}function qXe({item:e,forecast:t,globalLeadTime:n,canWrite:r,onRemove:i}){let{t:a}=W(),o=[e.brand,e.material,e.subtype,e.color_name].filter(Boolean).join(` `),s=(0,y.useMemo)(()=>{if(!t||t.dailyRateG===null||t.dailyRateG<=0)return null;let n=t.dailyRateG,r=t.effectiveLeadTimeDays,i=t.totalSpools>0?t.totalLabelG/t.totalSpools:1e3,a=e.quantity_spools*i,o=Math.max(0,t.totalRemainingG-n*r),s=o+a,c=Math.ceil(s/n),l=Math.min(r+c+5,365),u=[];for(let e=0;e<=l;e++){let i=u9(c9(new Date,e));if(e===r)u.push({day:e,label:i,stock:Math.round(o),rop:Math.round(t.reorderPointG),safetyStock:Math.round(t.safetyStockG)}),u.push({day:e,label:i,stock:Math.round(s),rop:Math.round(t.reorderPointG),safetyStock:Math.round(t.safetyStockG),arrival:!0});else{let a=e{if(!t||t.dailyRateG===null||t.dailyRateG<=0)return null;let e=Math.floor(t.totalRemainingG/t.dailyRateG);return ee>=1e3?`${(e/1e3).toFixed(1)}kg`:`${e}g`,width:44}),(0,K.jsx)(lz,{contentStyle:{background:`#1a1a2e`,border:`1px solid #374151`,borderRadius:8,fontSize:11},labelStyle:{color:`#9CA3AF`},formatter:(e,t)=>typeof e==`number`?t===`stock`?`${e}g — ${a(`forecast.stock`)}`:t===`rop`?`${e}g — ${a(`forecast.reorderPoint`)}`:t===`safetyStock`?`${e}g — ${a(`forecast.safetyMarginLabel`)}`:`${e}`:``}),(0,K.jsx)(YV,{type:`linear`,dataKey:`stock`,stroke:`#1DB954`,strokeWidth:2,fill:`url(#cart-post-${e.id})`,dot:!1,activeDot:{r:3}}),t.reorderPointG>0&&(0,K.jsx)(dV,{y:t.reorderPointG,stroke:`#F59E0B`,strokeDasharray:`5 3`,strokeOpacity:.8,label:{value:`ROP`,position:`insideTopRight`,fill:`#F59E0B`,fontSize:9}}),t.safetyStockG>0&&(0,K.jsx)(dV,{y:t.safetyStockG,stroke:`#6B7280`,strokeDasharray:`3 3`,strokeOpacity:.6,label:{value:`SS`,position:`insideTopRight`,fill:`#6B7280`,fontSize:9}}),(0,K.jsx)(dV,{x:u9(c9(new Date,s.lt)),stroke:`#3B82F6`,strokeWidth:1.5,strokeDasharray:`4 3`,strokeOpacity:.9,label:{value:`+${s.arrivalG>=1e3?`${(s.arrivalG/1e3).toFixed(1)}kg`:`${Math.round(s.arrivalG)}g`} arrives (d${s.lt})`,position:`insideTopLeft`,fill:`#3B82F6`,fontSize:9}}),c!==null&&(0,K.jsx)(dV,{x:u9(c9(new Date,c)),stroke:`#EF4444`,strokeWidth:1.5,strokeOpacity:.9,label:{value:`OUT`,position:`insideTopLeft`,fill:`#EF4444`,fontSize:9}})]})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 mt-2 text-[10px] text-bambu-gray`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-yellow-400 border-dashed`}),` `,a(`forecast.ropLabel`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t border-bambu-gray border-dashed`}),` `,a(`forecast.safetyStockLegend`)]}),(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-blue-400 border-dashed`}),` `,a(`forecast.stockArrivalLegend`)]}),l&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,K.jsx)(`span`,{className:`inline-block w-4 border-t-2 border-red-400`}),` `,a(`forecast.stockoutLegend`)]})]})]}):null]})}function JXe({forecast:e,onClose:t,onAdd:n}){let{t:r}=W(),i=[e.group.brand,e.group.material,e.group.subtype,e.group.colorName].filter(Boolean).join(` `),[a,o]=(0,y.useState)(`qty`),[s,c]=(0,y.useState)(`1`),[l,u]=(0,y.useState)(`30`),[d,f]=(0,y.useState)(``),p=(0,y.useMemo)(()=>{if(!e.dailyRateG||e.dailyRateG<=0)return null;let t=e.dailyRateG*Number(l),n=e.group.spools.length>0?e.group.spools.reduce((e,t)=>e+t.label_weight,0)/e.group.spools.length:1e3;return Math.ceil(t/n)},[e,l]),m=a===`qty`?parseInt(s,10)||1:p??1;function h(t){t.preventDefault(),n({material:e.group.material,subtype:e.group.subtype,brand:e.group.brand,color_name:e.group.colorName,quantity_spools:m,note:d||null})}return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-2xl border border-bambu-dark-tertiary w-full max-w-sm shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 pt-5 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Jl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-base font-semibold text-white`,children:r(`forecast.addToCartTitle`)})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`form`,{onSubmit:h,className:`p-5 space-y-4`,children:[(0,K.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:i}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-tertiary rounded-lg p-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`qty`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors ${a===`qty`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:r(`forecast.byQuantity`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(`duration`),className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors ${a===`duration`?`bg-bambu-dark-secondary text-white shadow`:`text-bambu-gray hover:text-white`}`,children:r(`forecast.byDuration`)})]}),a===`qty`?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.numberOfSpools`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:99,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,autoFocus:!0})]}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.lastHowManyDays`)}),(0,K.jsx)(`input`,{type:`number`,min:1,max:365,value:l,onChange:e=>u(e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,autoFocus:!0})]}),e.dailyRateG===null?(0,K.jsx)(`div`,{className:`text-xs text-yellow-400 px-1`,children:r(`forecast.noUsageQty`)}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-bambu-dark-tertiary/50 rounded-lg`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`≈`}),(0,K.jsx)(`span`,{className:`text-sm font-semibold text-bambu-green`,children:r(`forecast.spoolCount`,{count:p??0})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[`at `,e.dailyRateG.toFixed(1),`g/day`]})]})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:r(`forecast.noteOptional`)}),(0,K.jsx)(`input`,{type:`text`,maxLength:200,value:d,onChange:e=>f(e.target.value),placeholder:r(`forecast.notePlaceholder`),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/40 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 pt-1`,children:[(0,K.jsx)(`button`,{type:`submit`,className:`flex-1 py-2 bg-bambu-green text-white text-sm font-medium rounded-lg hover:bg-bambu-green/80 transition-colors`,children:r(`forecast.addNSpools`,{count:m})}),(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`px-4 py-2 text-sm text-bambu-gray hover:text-white border border-bambu-dark-tertiary rounded-lg transition-colors`,children:r(`forecast.cancel`)})]})]})]})})}var p9={material:``,subtype:``,brand:``,color_name:``,rgba:`808080FF`,extra_colors:``,effect_type:``,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:``,note:``,cost_per_kg:null,category:``,low_stock_threshold_pct:null,location_id:null,spoolman_filament_id:null},YXe=new Set([`material`,`subtype`,`brand`,`rgba`,`color_name`,`label_weight`]);function m9(e,t=!1,n=!1){let r={};return t||n?(!e.material&&!e.spoolman_filament_id&&(r.material=`Material is required`),{isValid:Object.keys(r).length===0,errors:r}):(e.slicer_filament||(r.slicer_filament=`Slicer preset is required`),e.material||(r.material=`Material is required`),e.brand||(r.brand=`Brand is required`),e.subtype||(r.subtype=`Subtype is required`),{isValid:Object.keys(r).length===0,errors:r})}function h9({formData:e,updateField:t,cloudAuthenticated:n,loadingCloudPresets:r,presetInputValue:i,setPresetInputValue:a,selectedPresetOption:o,filamentOptions:s,availableBrands:c,availableMaterials:l,quickAdd:u,quantity:d,onQuantityChange:f,errors:p}){let{t:m}=W(),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(``),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(String(e.label_weight)),[M,N]=(0,y.useState)(!1),P=(0,y.useRef)(null),F=(0,y.useRef)(null),I=(0,y.useRef)(null),L=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{P.current&&!P.current.contains(e.target)&&g(!1),L.current&&!L.current.contains(e.target)&&C(!1),F.current&&!F.current.contains(e.target)&&v(!1),I.current&&!I.current.contains(e.target)&&x(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let R=(0,y.useMemo)(()=>{if(!i)return s;let e=i.toLowerCase();return s.filter(t=>t.displayName.toLowerCase().includes(e)||t.code.toLowerCase().includes(e))},[s,i]),z=(0,y.useMemo)(()=>{if(!w)return c;let e=w.toLowerCase();return c.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[c,w]),B=(0,y.useMemo)(()=>{if(!E)return TU;let e=E.toLowerCase();return TU.filter(t=>t.toLowerCase().includes(e))},[E]),V=(0,y.useMemo)(()=>{if(!O)return l;let e=O.toLowerCase();return l.filter(t=>t.toLowerCase().includes(e)).sort((t,n)=>{let r=t.toLowerCase()===e,i=n.toLowerCase()===e;return r&&!i?-1:!r&&i?1:t.localeCompare(n)})},[O,l]);(0,y.useEffect)(()=>{M||j(String(e.label_weight))},[e.label_weight,M]);let ee=e=>{t(`slicer_filament`,e.code),a(e.displayName),g(!1);let n=kU(e.name);n.material&&t(`material`,n.material),n.brand&&t(`brand`,n.brand),n.variant&&t(`subtype`,n.variant)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[!u&&(0,K.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-bambu-gray`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-3 h-3 animate-spin`}),` `,m(`inventory.loadingPresets`)]}):n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ws,{className:`w-3 h-3 text-bambu-green`}),` `,m(`inventory.cloudConnected`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cs,{className:`w-3 h-3`}),` `,m(`inventory.cloudNotConnected`)]})}),!u&&(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.slicerPreset`),` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:P,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.searchPresets`),value:i,onChange:e=>{a(e.target.value),g(!0)},onFocus:()=>{g(!0),a(``)}}),h&&(0,K.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:R.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noPresetsFound`)}):R.map(e=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary truncate ${o?.code===e.code?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>ee(e),children:e.displayName},`${e.code}::${e.name}`))})]}),o&&(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-bambu-gray`,children:[m(`inventory.selectedPreset`),`: `,(0,K.jsx)(`span`,{className:`font-mono text-bambu-green`,children:o.code})]}),p?.slicer_filament&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.slicer_filament})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.material`),` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:L,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.selectMaterial`),value:S?O:e.material,onChange:e=>{k(e.target.value),C(!0)},onFocus:()=>{C(!0),k(``)}}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),S&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[V.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):V.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.material===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`material`,n),C(!1),k(``)},children:n},n)),O&&!V.includes(O)&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`material`,O),C(!1),k(``)},children:m(`inventory.useCustomMaterial`,{material:O})})]})]}),p?.material&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.material})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.brand`),!u&&` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:F,children:[(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:m(`inventory.searchBrand`),value:_?w:e.brand,onChange:e=>{T(e.target.value),v(!0)},onFocus:()=>{v(!0),T(``)}}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),_&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[z.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):z.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.brand===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`brand`,n),v(!1),T(``)},children:n},n)),w&&!z.includes(w)&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`brand`,w),v(!1),T(``)},children:m(`inventory.useCustomBrand`,{brand:w})})]})]}),p?.brand&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.brand})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:[m(`inventory.subtype`),!u&&` *`]}),(0,K.jsxs)(`div`,{className:`relative`,ref:I,children:[(0,K.jsx)(`input`,{type:`text`,value:b?E:e.subtype,onChange:e=>{D(e.target.value),x(!0)},onFocus:()=>{x(!0),D(``)},placeholder:`Basic, Matte, Silk...`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),b&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-48 overflow-y-auto`,children:[B.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:m(`inventory.noResults`)}):B.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e.subtype===n?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(`subtype`,n),x(!1),D(``)},children:n},n)),E&&!TU.some(e=>e.toLowerCase()===E.toLowerCase().trim())&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(`subtype`,E),x(!1),D(``)},children:m(`inventory.useCustomBrand`,{brand:E})})]})]}),p?.subtype&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:p.subtype})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:m(`inventory.labelWeight`)}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:A,min:0,onFocus:()=>N(!0),onChange:e=>j(e.target.value),onBlur:()=>{N(!1);let n=A.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0){j(String(e.label_weight));return}let i=Math.round(r);t(`label_weight`,i),j(String(i))}}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]})]}),u&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:m(`inventory.quantity`)}),(0,K.jsx)(`input`,{type:`number`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:d,min:1,max:100,onChange:e=>{f(Math.max(1,Math.min(100,parseInt(e.target.value)||1)))}})]})]})}function XXe(e){let t=e.split(/[\s,]+/).map(e=>e.trim().replace(/^#/,``)).filter(Boolean),n=[],r=[];for(let e of t)(e.length===6||e.length===8)&&/^[0-9a-fA-F]+$/.test(e)?n.push(e.toLowerCase()):r.push(e);return{value:n.join(`,`),invalid:r}}function g9({formData:e,updateField:t,recentColors:n,onColorUsed:r,catalogColors:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(``),u=(e.rgba.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),d=u.substring(0,6),f=u.substring(6,8)===`00`,[p,m]=(0,y.useState)(f?u:d);(0,y.useEffect)(()=>{m(f?u:d)},[d,u,f]);let h=e=>u===(e.replace(`#`,``)+`FF`).substring(0,8).toUpperCase(),g=e=>Jd(e),_=(e,n,i,a)=>{let o=e.replace(`#`,``).toUpperCase();if(t(`rgba`,o.length===8?o:o+`FF`),t(`color_name`,n),i!==void 0){let e=i??``;w(e),E([]),D.current=e,t(`extra_colors`,e)}a!==void 0&&t(`effect_type`,a??``),r({name:n,hex:e})},v=(0,y.useMemo)(()=>{if(i.length===0)return[];let t=e.brand?.trim(),n=e.material?.toLowerCase().trim(),r=e.subtype?.toLowerCase().trim();if(!t&&!n)return[];let a=t?t.toLowerCase().split(/[\s\-_]+/).filter(e=>e.length>=2):[],o=e=>{if(a.length===0)return!0;let t=e.toLowerCase();return a.some(e=>t.includes(e))};if(t&&!n){let e=i.filter(e=>o(e.manufacturer));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}let s=n&&r?`${n} ${r}`:``;if(s){let e=i.filter(e=>o(e.manufacturer)&&e.material?.toLowerCase()===s);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}));let t=s.replace(/\+$/,``);if(t!==s){let e=i.filter(e=>o(e.manufacturer)&&e.material?.toLowerCase()===t);if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0}))}}if(n){let e=i.filter(e=>o(e.manufacturer)&&(!e.material||e.material.toLowerCase().startsWith(n)));if(e.length>0)return e.map(e=>({name:e.color_name,hex:e.hex_color.replace(`#`,``).substring(0,6),manufacturer:e.manufacturer,material:typeof e.material==`string`?e.material:void 0,extra_colors:e.extra_colors??null,effect_type:e.effect_type??null}))}return[]},[i,e.brand,e.material,e.subtype]),b=(0,y.useMemo)(()=>{if(!c)return v;if(v.length===0)return[];let e=c.toLowerCase();return v.filter(t=>t.name.toLowerCase().includes(e)||(t.manufacturer?.toLowerCase().includes(e)??!1)||(t.material?.toLowerCase().includes(e)??!1))},[c,v]),x=v.length>0,S=(0,y.useMemo)(()=>c?DU.filter(e=>e.name.toLowerCase().includes(c.toLowerCase())):o?DU:EU,[c,o]),[C,w]=(0,y.useState)(e.extra_colors),[T,E]=(0,y.useState)([]),D=(0,y.useRef)(e.extra_colors);(0,y.useEffect)(()=>{e.extra_colors!==D.current&&(w(e.extra_colors),E([]),D.current=e.extra_colors)},[e.extra_colors]);let O=(0,y.useMemo)(()=>U3({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`bar`}),[e.rgba,e.extra_colors,e.effect_type,e.subtype]),k=e=>{if(w(e),!e.trim()){E([]),D.current=``,t(`extra_colors`,``);return}let{value:n,invalid:r}=XXe(e);E(r),D.current=n,t(`extra_colors`,n)};return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`div`,{className:`h-10 rounded-lg border border-bambu-dark-tertiary`,style:O,"data-testid":`color-preview-banner`}),n.length>0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-bambu-gray shrink-0`,children:[(0,K.jsx)(Ss,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:a(`inventory.recentColors`)})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:n.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.name},e.hex))})]}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.searchColors`),value:c,onChange:e=>l(e.target.value)})]}),x?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:c?a(`inventory.searchResults`):`${e.brand}${e.material?` ${e.material}`:``}`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[b.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name,e.extra_colors,e.effect_type),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name,children:(0,K.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.manufacturer&&e.material?`${e.name} (${e.manufacturer} — ${e.material})`:e.manufacturer?`${e.name} (${e.manufacturer})`:e.name})},`${e.hex}-${e.name}-${e.manufacturer??``}`)),b.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:a(`inventory.noColorsFound`)})]})]}):(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:a(c?`inventory.searchResults`:o?`inventory.allColors`:`inventory.commonColors`)}),!c&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>s(!o),className:`flex items-center gap-1 hover:text-white transition-colors`,children:o?(0,K.jsxs)(K.Fragment,{children:[a(`inventory.showLess`),` `,(0,K.jsx)(cs,{className:`w-3 h-3`})]}):(0,K.jsxs)(K.Fragment,{children:[a(`inventory.showAll`),` `,(0,K.jsx)(is,{className:`w-3 h-3`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[S.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>_(e.hex,e.name),className:`w-6 h-6 rounded border-2 transition-all hover:scale-110 hover:z-20 relative group ${h(e.hex)?`border-bambu-green ring-1 ring-bambu-green/30 scale-110`:`border-bambu-dark-tertiary`}`,style:g(e.hex),title:e.name,children:(0,K.jsx)(`span`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 px-2 py-0.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-xs whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20 shadow-lg text-white`,children:e.name})},e.hex)),S.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray py-1`,children:a(`inventory.noColorsFound`)})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.colorName`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.colorNamePlaceholder`),value:e.color_name,onChange:e=>t(`color_name`,e.target.value)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.hexColor`)}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray`,children:`#`}),(0,K.jsx)(`input`,{type:`text`,className:`w-full pl-7 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono uppercase focus:outline-none focus:border-bambu-green`,placeholder:`RRGGBB`,value:p.toUpperCase(),onChange:e=>{let n=e.target.value.replace(`#`,``).replace(/[^0-9A-Fa-f]/g,``).toUpperCase(),r=n.length>8?n.substring(0,8):n;m(r),r.length===6?t(`rgba`,r+`FF`):r.length===8&&t(`rgba`,r)},onBlur:()=>{if(p.length===7){let e=p+`0`;m(e),t(`rgba`,e)}else if(p.length>0&&p.length<6){let e=p.padEnd(6,`0`);m(e),t(`rgba`,e+`FF`)}}})]}),(0,K.jsx)(`input`,{type:`color`,className:`w-11 h-[38px] rounded-lg cursor-pointer border border-bambu-dark-tertiary shrink-0 bg-transparent`,value:`#${d}`,onChange:e=>{t(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`)},title:a(`inventory.pickColor`)})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3 pt-2 border-t border-bambu-dark-tertiary/50`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:a(`inventory.extraColorsLabel`)}),(0,K.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm font-mono placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.extraColorsPlaceholder`),value:C,onChange:e=>k(e.target.value),"data-testid":`extra-colors-input`}),T.length>0&&(0,K.jsx)(`p`,{className:`text-xs text-red-400 mt-1`,children:a(`inventory.extraColorsInvalid`,{tokens:T.join(`, `)})}),!T.length&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:a(`inventory.extraColorsHint`)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1 flex items-center gap-1.5`,children:[(0,K.jsx)(ru,{className:`w-3.5 h-3.5`}),a(`inventory.colorEffectLabel`)]}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-stretch`,children:[(0,K.jsx)(`select`,{className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.effect_type,onChange:e=>t(`effect_type`,e.target.value),"data-testid":`effect-type-select`,children:B3.map(e=>(0,K.jsx)(`option`,{value:e.value,children:a(e.labelKey)},e.value||`none`))}),(0,K.jsx)(W3,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`preview`,className:`w-10 h-10`,shape:`square`})]})]})]})]})}function ZXe({catalog:e,value:t,onChange:n,catalogId:r,onCatalogIdChange:i}){let{t:a}=W(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(``),u=(0,y.useRef)(null),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{let e=e=>{u.current&&!u.current.contains(e.target)&&s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]),(0,y.useEffect)(()=>{if(e.length===0)return;let n=e.filter(e=>e.weight===t);if(r){let n=e.find(e=>e.id===r);if(n&&n.weight===t)return}n.length===1?i(n[0].id):n.length===0&&r!==null&&i(null)},[t,e,r,i]);let f=(0,y.useMemo)(()=>{if(!c)return e;let t=c.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(t)||e.weight.toString().includes(t))},[e,c]),p=(0,y.useMemo)(()=>e.filter(e=>e.weight===t),[e,t]),m=(0,y.useMemo)(()=>{if(o)return c;if(r){let t=e.find(e=>e.id===r);if(t)return t.name}return p.length>0?p[0].name:``},[o,c,r,e,p]);return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Pl,{className:`w-3.5 h-3.5 text-bambu-gray`}),a(`inventory.coreWeight`)]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 items-center`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 relative`,ref:u,children:[(0,K.jsx)(`input`,{ref:d,type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:a(`inventory.searchSpoolWeight`),value:m,onFocus:()=>{s(!0),l(``)},onChange:e=>{l(e.target.value),s(!0)}}),o&&(0,K.jsx)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:f.length===0?(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:a(`inventory.noResults`)}):f.map(e=>(0,K.jsxs)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex justify-between items-center ${(r?e.id===r:e.weight===t)?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{i(e.id),n(e.weight),s(!1),l(``)},children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.name}),(0,K.jsxs)(`span`,{className:`font-mono text-xs text-bambu-gray ml-2 shrink-0`,children:[e.weight,`g`]})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,K.jsx)(`input`,{type:`number`,className:`w-16 px-2 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm text-center font-mono focus:outline-none focus:border-bambu-green`,value:t,min:0,max:2e3,onChange:e=>{let t=parseInt(e.target.value);!isNaN(t)&&t>=0&&n(t)}}),(0,K.jsx)(`span`,{className:`text-bambu-gray text-sm`,children:`g`})]})]})]})}function _9({formData:e,updateField:t,spoolCatalog:n,currencySymbol:r,availableCategories:i,availableLocations:a=[],onCreateLocation:o,globalLowStockThreshold:s,spoolmanMode:c=!1}){let{t:l}=W(),{showToast:u}=Td(),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(``),[S,C]=(0,y.useState)(!1),w=Math.max(0,e.label_weight-e.weight_used),T=e.core_weight+w;return(0,y.useEffect)(()=>{p||f(String(T))},[p,T]),(0,y.useEffect)(()=>{_||g(String(w))},[_,w]),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[c?(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray px-1`,children:l(`inventory.spoolWeightManagedBySpoolman`)}):(0,K.jsx)(ZXe,{catalog:n,value:e.core_weight,onChange:e=>t(`core_weight`,e),catalogId:e.core_weight_catalog_id,onCatalogIdChange:e=>t(`core_weight_catalog_id`,e)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.currentWeight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:`number`,value:h,min:0,max:e.label_weight,onFocus:()=>v(!0),onChange:e=>{g(e.target.value)},onBlur:()=>{v(!1);let n=h.trim(),r=Number(n);if(!n||!Number.isFinite(r)||r<0||r>e.label_weight){g(String(w));return}let i=Math.round(r);t(`weight_used`,Math.max(0,e.label_weight-i)),g(String(i))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.label_weight,`g`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.measuredWeight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{type:`number`,value:d,min:0,onFocus:()=>m(!0),onChange:e=>{f(e.target.value)},onBlur:()=>{m(!1);let n=d.trim(),r=Number(n),i=e.core_weight,a=e.core_weight+e.label_weight;if(!n||!Number.isFinite(r)||ra){u(l(`inventory.measuredWeightError`,{min:i,max:a}),`error`),f(String(T));return}let o=Math.round(r),s=Math.max(0,Math.min(e.label_weight,o-e.core_weight));t(`weight_used`,Math.max(0,e.label_weight-s)),f(String(o))},className:`w-full px-3 py-2 pr-7 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`}),(0,K.jsx)(`span`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-xs text-bambu-gray`,children:`g`})]}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray shrink-0`,children:[`/ `,e.core_weight+e.label_weight,`g`]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.costPerKg`,`Cost per kg`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`span`,{className:`absolute left-3 top-1/2 -translate-y-1/2 text-bambu-gray text-sm pointer-events-none`,children:r}),(0,K.jsx)(`input`,{type:`number`,value:e.cost_per_kg??``,min:0,step:.01,placeholder:`0.00`,onChange:e=>{t(`cost_per_kg`,e.target.value===``?null:parseFloat(e.target.value))},style:{paddingLeft:`${Math.max(2,r.length*.6+1)}rem`},className:`w-full py-2 pr-3 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`})]})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-category`,children:l(`inventory.category`)}),(0,K.jsx)(`input`,{id:`spool-category`,type:`text`,list:`spool-category-options`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`inventory.categoryPlaceholder`),value:e.category,maxLength:50,onChange:e=>t(`category`,e.target.value)}),i.length>0&&(0,K.jsx)(`datalist`,{id:`spool-category-options`,children:i.map(e=>(0,K.jsx)(`option`,{value:e},e))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-low-stock-threshold`,children:l(`inventory.lowStockThresholdOverride`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(`input`,{id:`spool-low-stock-threshold`,type:`number`,className:`w-full px-3 py-2 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:String(s),value:e.low_stock_threshold_pct??``,min:1,max:99,step:1,onChange:e=>{let n=e.target.value;if(n===``){t(`low_stock_threshold_pct`,null);return}let r=Number(n);Number.isFinite(r)&&t(`low_stock_threshold_pct`,Math.min(99,Math.max(1,Math.round(r))))}}),(0,K.jsx)(`span`,{className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-bambu-gray pointer-events-none`,children:`%`})]})}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:l(`inventory.lowStockThresholdOverrideHelp`,{global:s})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:l(`inventory.note`)}),(0,K.jsx)(`textarea`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green resize-none min-h-[80px]`,placeholder:l(`inventory.notePlaceholder`),value:e.note,onChange:e=>t(`note`,e.target.value)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`spool-storage-location`,children:l(`inventory.storageLocation`)}),(0,K.jsxs)(`select`,{id:`spool-storage-location`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green`,value:e.location_id??``,onChange:e=>{let n=e.target.value;if(!n){t(`location_id`,null);return}t(`location_id`,Number(n))},children:[(0,K.jsx)(`option`,{value:``,children:l(`inventory.storageLocationNone`)}),a.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),o&&(0,K.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,maxLength:255,className:`flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`,placeholder:l(`locations.createPlaceholder`),value:b,onChange:e=>x(e.target.value)}),(0,K.jsx)(`button`,{type:`button`,className:`px-3 py-2 text-sm rounded-lg bg-bambu-dark-tertiary text-white hover:bg-bambu-gray-dark disabled:opacity-50`,disabled:!b.trim()||S,onClick:async()=>{let e=b.trim();if(!(!e||!o)){C(!0);try{let n=await o(e);n&&(t(`location_id`,n.id),x(``))}finally{C(!1)}}},children:l(`locations.addShort`)})]})]})]})}function QXe({filaments:e,isLoading:t,selectedId:n,onSelect:r}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),l=(0,y.useRef)(null),u=(0,y.useRef)(null),d=(0,y.useMemo)(()=>e.find(e=>e.id===n)??null,[e,n]);(0,y.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&(o(!1),c(``))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let f=(0,y.useMemo)(()=>{let t=s.toLowerCase().trim();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.material?.toLowerCase().includes(t)??!1)||(e.vendor?.name.toLowerCase().includes(t)??!1)||(e.color_name?.toLowerCase().includes(t)??!1)):e},[e,s]);(0,y.useEffect)(()=>{a&&u.current?.focus()},[a]);let p=()=>{o(!0),c(``)},m=e=>{r(e),o(!1),c(``)},h=e=>e?`#${e.replace(`#`,``)}`:`#808080`;return(0,K.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,children:i(`inventory.pickFromSpoolmanCatalog`)}),(0,K.jsxs)(`button`,{type:`button`,onClick:p,className:`w-full flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-left focus:outline-none focus:border-bambu-green hover:border-bambu-gray transition-colors`,children:[t?(0,K.jsx)(X,{className:`w-4 h-4 text-bambu-gray animate-spin shrink-0`}):d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full shrink-0 border border-white/20`,style:{backgroundColor:h(d.color_hex)},"aria-label":i(`inventory.spoolmanFilamentColorSwatch`)}),(0,K.jsxs)(`span`,{className:`text-white text-sm truncate flex-1`,children:[d.vendor?.name?`${d.vendor.name} — `:``,d.name]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`span`,{className:`text-bambu-gray text-sm flex-1`,children:i(`inventory.spoolmanFilamentCatalog`)})]}),(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray shrink-0 ml-auto`})]}),a&&(0,K.jsxs)(`div`,{className:`absolute z-50 w-full mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl`,children:[(0,K.jsx)(`div`,{className:`p-2 border-b border-bambu-dark-tertiary`,children:(0,K.jsx)(`input`,{ref:u,type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:i(`inventory.pickFromSpoolmanCatalog`),className:`w-full px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm placeholder-bambu-gray focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`ul`,{className:`max-h-56 overflow-y-auto py-1`,children:t?(0,K.jsxs)(`li`,{className:`flex items-center justify-center gap-2 py-4 text-bambu-gray text-sm`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsx)(`span`,{children:i(`common.loading`,`Loading…`)})]}):f.length===0?(0,K.jsx)(`li`,{className:`py-4 text-center text-bambu-gray text-sm`,children:i(`inventory.noSpoolmanFilaments`)}):f.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>m(e),className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bambu-dark-tertiary transition-colors ${e.id===n?`bg-bambu-dark-tertiary`:``}`,children:[(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full shrink-0 border border-white/20`,style:{backgroundColor:h(e.color_hex)},"aria-label":i(`inventory.spoolmanFilamentColorSwatch`)}),(0,K.jsxs)(`span`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`span`,{className:`block text-white text-sm truncate`,children:[e.vendor?.name?`${e.vendor.name} — `:``,e.name]}),(0,K.jsxs)(`span`,{className:`block text-bambu-gray text-xs truncate`,children:[[e.material,e.color_name].filter(Boolean).join(` · `),e.weight?` · ${e.weight}g`:``]})]})]})},e.id))})]})]})}function v9({formData:e,printersWithCalibrations:t,selectedProfiles:n,setSelectedProfiles:r,expandedPrinters:i,setExpandedPrinters:a}){let{t:o}=W(),s=e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},c=(e,t,n)=>{let i=`${e}:${t}:${n??`null`}`,a=`${e}:${n??`null`}`;r(e=>{let t=new Set(e);if(t.has(i))t.delete(i);else{for(let e of Array.from(t)){let n=e.split(`:`);`${n[0]}:${n[2]}`===a&&t.delete(e)}t.add(i)}return t})},l=()=>{let n=new Set;for(let{printer:r,calibrations:i}of t){if(!r.connected)continue;let t=i.filter(t=>LU(t,e)),a=new Map;for(let e of t){let t=`${e.extruder_id??`null`}`;a.has(t)||a.set(t,[]),a.get(t).push(e)}for(let[e,t]of a)if(t.length>0){let i=[...t].sort((e,t)=>t.k_value-e.k_value)[0];n.add(`${r.id}:${i.cali_idx}:${e}`)}}r(n)};if(!e.material)return(0,K.jsx)(`div`,{className:`p-6 bg-bambu-dark rounded-lg text-center`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`inventory.selectMaterialFirst`)})});if(t.length===0)return(0,K.jsx)(`div`,{className:`p-6 bg-bambu-dark rounded-lg text-center`,children:(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:o(`inventory.noPrintersConfigured`)})});let u=t.reduce((t,{printer:n,calibrations:r})=>n.connected?t+r.filter(t=>LU(t,e)).length:t,0),d=(e,t)=>{let r=`${e.id}:${t.cali_idx}:${t.extruder_id??`null`}`,i=n.has(r);return(0,K.jsxs)(`label`,{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer transition-all border ${i?`bg-bambu-green/10 border-bambu-green/30`:`bg-bambu-dark border-transparent hover:bg-bambu-dark/80`}`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:i,onChange:()=>c(String(e.id),t.cali_idx,t.extruder_id),className:`w-4 h-4 rounded border-bambu-dark-tertiary text-bambu-green focus:ring-bambu-green`}),(0,K.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,K.jsx)(`span`,{className:`text-sm font-medium ${i?`text-bambu-green`:`text-white`}`,children:t.name||t.filament_id})}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:(0,K.jsxs)(`span`,{className:`text-xs font-mono px-2 py-0.5 rounded bg-bambu-dark text-bambu-gray`,children:[`K=`,t.k_value.toFixed(3)]})})]},`${t.cali_idx}-${t.extruder_id}`)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[o(`inventory.matchingFilter`),`: `,e.brand||o(`inventory.anyBrand`),` / `,e.material,` / `,e.subtype||o(`inventory.anyVariant`)]}),u>0&&(0,K.jsxs)(`button`,{type:`button`,onClick:l,className:`flex items-center gap-1.5 px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray hover:text-white hover:border-bambu-green transition-colors`,children:[(0,K.jsx)(ru,{className:`w-3.5 h-3.5`}),o(`inventory.autoSelect`),` (`,u,`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-3`,children:t.map(({printer:t,calibrations:n})=>{let r=i.has(String(t.id)),a=n.filter(t=>LU(t,e)),c=a.length,l=a.some(e=>e.extruder_id!==void 0&&e.extruder_id!==null&&e.extruder_id>0),u=a.filter(e=>e.extruder_id===1),f=a.filter(e=>e.extruder_id===0||e.extruder_id===void 0||e.extruder_id===null);return(0,K.jsxs)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(String(t.id)),className:`w-full px-4 py-3 flex items-center justify-between bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r?(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray`}):(0,K.jsx)(as,{className:`w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`span`,{className:`font-medium text-white`,children:t.name}),c>0?(0,K.jsxs)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green`,children:[c,` `,o(c===1?`inventory.match`:`inventory.matches`)]}):(0,K.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray`,children:o(`inventory.noMatches`)})]}),(0,K.jsx)(`span`,{className:`text-xs px-2 py-1 rounded-full ${t.connected?`bg-green-500/20 text-green-500`:`bg-bambu-gray/20 text-bambu-gray`}`,children:t.connected?o(`inventory.connected`):o(`inventory.offline`)})]}),r&&(0,K.jsx)(`div`,{className:`px-4 py-3 space-y-3 bg-bambu-dark border-t border-bambu-dark-tertiary`,children:t.connected?c===0?(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:o(`inventory.noKProfilesMatch`)}):l?(0,K.jsxs)(K.Fragment,{children:[u.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.leftNozzle`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:u.map(e=>d(t,e))})]}),f.length>0&&(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:o(`inventory.rightNozzle`)}),(0,K.jsx)(`div`,{className:`space-y-2`,children:f.map(e=>d(t,e))})]})]}):(0,K.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>d(t,e))}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray italic py-2`,children:o(`inventory.printerOffline`)})})]},t.id)})}),n.size>0&&(0,K.jsx)(`div`,{className:`p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-white`,children:[(0,K.jsx)(`span`,{className:`font-semibold`,children:n.size}),` `,o(`inventory.profilesSelected`)]})})]})}function $Xe(e){let t=vf(e);return t?t.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`2-digit`,year:`2-digit`})+` `+t.toLocaleTimeString(`en-GB`,{hour:`2-digit`,minute:`2-digit`}):``}var eZe={completed:`text-bambu-green`,failed:`text-red-400`,aborted:`text-yellow-400`};function tZe({spoolId:e}){let{t}=W(),n=no(),{showToast:r}=Td(),{data:i,isLoading:a}=q({queryKey:[`spool-usage`,e],queryFn:()=>Q.getSpoolUsageHistory(e)}),o=J({mutationFn:()=>Q.clearSpoolUsageHistory(e),onSuccess:()=>{n.invalidateQueries({queryKey:[`spool-usage`,e]}),r(t(`inventory.historyCleared`),`success`)}});return a?(0,K.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,K.jsx)(X,{className:`w-5 h-5 animate-spin text-bambu-green`})}):!i||i.length===0?(0,K.jsxs)(`div`,{className:`text-center py-4 text-bambu-gray text-sm`,children:[(0,K.jsx)(Ss,{className:`w-5 h-5 mx-auto mb-2 opacity-50`}),t(`inventory.noUsageHistory`)]}):(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium text-white`,children:t(`inventory.usageHistory`)}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>o.mutate(),disabled:o.isPending,className:`text-xs text-bambu-gray hover:text-red-400`,children:[(0,K.jsx)(bu,{className:`w-3 h-3 mr-1`}),t(`inventory.clearHistory`)]})]}),(0,K.jsx)(`div`,{className:`max-h-48 overflow-y-auto space-y-1`,children:i.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-bambu-dark/50 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:$Xe(e.created_at)}),e.print_name&&(0,K.jsx)(`span`,{className:`text-white ml-2 truncate`,title:e.print_name,children:e.print_name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0 ml-2`,children:[(0,K.jsxs)(`span`,{className:`text-white font-medium`,children:[e.weight_used.toFixed(1),`g`]}),(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,e.percent_used,`%)`]}),(0,K.jsx)(`span`,{className:eZe[e.status]||`text-bambu-gray`,children:e.status})]})]},e.id))})]})}var y9=[`inventory-locations`];function b9(e){return e.invalidateQueries({queryKey:y9})}function x9(e,t){return Promise.all([e.invalidateQueries({queryKey:[...t]}),b9(e)])}var S9={tag_uid:null,tray_uuid:null,tag_type:null,data_origin:null};function nZe({isOpen:e,onClose:t,spool:n,mode:r,printersWithCalibrations:i=[],currencySymbol:a,onSpoolsCreated:o,spoolmanMode:s=!1,spoolsQueryKey:c=[`inventory-spools`]}){let{t:l}=W(),u=no(),{showToast:d}=Td(),f=()=>x9(u,c),p=r===`edit`,m=r===`copy`,[h,g]=(0,y.useState)(p9),[_,v]=(0,y.useState)({}),[b,x]=(0,y.useState)(`filament`),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1),[P,F]=(0,y.useState)([]),[I,L]=(0,y.useState)(``),[R,z]=(0,y.useState)([]),[B,V]=(0,y.useState)([]),[ee,te]=(0,y.useState)([]),[ne,re]=(0,y.useState)([]),[ie,H]=(0,y.useState)([]),[ae,oe]=(0,y.useState)([]),[U,se]=(0,y.useState)([]),[ce,le]=(0,y.useState)(new Set),[ue,de]=(0,y.useState)(new Set),fe=i.length>0?i:U,pe=ce.size,{data:me=[],isLoading:he,error:ge}=q({queryKey:[`spoolman-inventory-filaments`],queryFn:()=>Q.getSpoolmanInventoryFilaments(),enabled:s&&e,staleTime:6e4,retry:!1});(0,y.useEffect)(()=>{oe(NU())},[]),(0,y.useEffect)(()=>{let t=!1;return e&&((async()=>{N(!0);try{let[e,n]=await Promise.allSettled([(async()=>(await Q.getCloudStatus()).is_authenticated?{connected:!0,presets:await Q.getFilamentPresets()}:{connected:!1,presets:[]})(),(async()=>(await Q.orcaCloudStatus()).connected?{connected:!0,presets:(await Q.orcaCloudListProfiles()).filament}:{connected:!1,presets:[]})()]);if(t)return;let r=e.status===`fulfilled`&&e.value.connected,i=n.status===`fulfilled`&&n.value.connected,a=e.status===`fulfilled`?e.value.presets:[],o=n.status===`fulfilled`?n.value.presets:[];j(r||i),F([...a,...o])}catch(e){if(t)return;console.error(`Failed to fetch cloud presets:`,e),j(!1)}finally{t||N(!1)}})(),s||Q.getSpoolCatalog().then(z).catch(console.error),Q.getColorCatalog().then(H).catch(console.error),Q.getLocalPresets().then(e=>te(e.filament)).catch(console.error),Q.getBuiltinFilaments().then(re).catch(console.error),Q.getLocations().then(e=>V(e.map(e=>({id:e.id,name:e.name})))).catch(console.error),i.length===0&&(async()=>{try{let e=await Q.getPrinters(),t=await Promise.all(e.map(e=>Q.getPrinterStatus(e.id).catch(()=>null))),n=[];for(let r=0;r({cali_idx:e.slot_id,filament_id:e.filament_id,setting_id:e.setting_id||``,name:e.name,k_value:parseFloat(e.k_value)||0,n_coef:parseFloat(e.n_coef)||0,extruder_id:e.extruder_id,nozzle_diameter:e.nozzle_diameter}))}catch{}n.push({printer:{...i,connected:a},calibrations:o})}se(n)}catch(e){console.error(`Failed to fetch printer calibrations:`,e)}})()),()=>{t=!0}},[e,i.length]);let _e=(0,y.useMemo)(()=>jU(P,new Set,ee,ne),[P,ee,ne]),ve=(0,y.useMemo)(()=>{let e=AU(P,ee),t=ie.map(e=>e.manufacturer?.trim()).filter(e=>!!e),n=new Set([...e,...t]);return Array.from(n).sort((e,t)=>e.localeCompare(t))},[P,ee,ie]),ye=(0,y.useMemo)(()=>{let e=ie.map(e=>e.material?.trim()).filter(e=>!!e),t=new Set([...CU,...e]);return Array.from(t).sort((e,t)=>e.localeCompare(t))},[ie]),be=(0,y.useMemo)(()=>{let e=[];for(let t of ie){let n=t.manufacturer?.trim(),r=t.material?.trim();n&&r&&e.push({brand:n,material:r})}for(let t of P){let n=kU(t.name);n.brand&&n.material&&e.push({brand:n.brand,material:n.material})}for(let t of ee){let n=kU(t.name),r=t.filament_vendor?.trim()||n.brand,i=n.material;r&&i&&e.push({brand:r,material:i})}return e},[P,ie,ee]),xe=(0,y.useMemo)(()=>{let e=new Map;for(let t of be){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(n)||e.set(n,new Set),e.get(n).add(r)}return e},[be]),Se=(0,y.useMemo)(()=>{let e=new Map;for(let t of be){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(r)||e.set(r,new Set),e.get(r).add(n)}return e},[be]),Ce=(0,y.useMemo)(()=>{if(!h.material)return ve;let e=h.material.toLowerCase(),t=Se.get(e);return!t||t.size===0?ve:ve.filter(e=>t.has(e.toLowerCase()))},[ve,h.material,Se]),we=(0,y.useMemo)(()=>{if(!h.brand)return ye;let e=h.brand.toLowerCase(),t=xe.get(e);return!t||t.size===0?ye:ye.filter(e=>t.has(e.toLowerCase()))},[ye,h.brand,xe]),Te=(0,y.useMemo)(()=>MU(h.slicer_filament,_e),[h.slicer_filament,_e]);(0,y.useEffect)(()=>{if(e){if(n){let e=n.rgba&&/^[0-9A-Fa-f]{8}$/.test(n.rgba)?n.rgba:`808080FF`;if(g({material:n.material||``,subtype:n.subtype||``,brand:n.brand||``,color_name:n.color_name_is_synthesized?``:n.color_name||``,rgba:e,extra_colors:n.extra_colors||``,effect_type:n.effect_type||``,label_weight:n.label_weight||1e3,core_weight:n.core_weight||250,core_weight_catalog_id:n.core_weight_catalog_id??null,weight_used:m?0:n.weight_used||0,slicer_filament:n.slicer_filament||``,note:n.note||``,cost_per_kg:n.cost_per_kg??null,category:n.category||``,low_stock_threshold_pct:n.low_stock_threshold_pct??null,location_id:n.location_id??null,spoolman_filament_id:null}),L(n.slicer_filament_name||n.slicer_filament||``),n.k_profiles&&n.k_profiles.length>0){let e=new Set;for(let t of n.k_profiles)t.cali_idx!==null&&t.cali_idx!==void 0&&e.add(`${t.printer_id}:${t.cali_idx}:${t.extruder??`null`}`);le(e)}else le(new Set)}else g(p9),L(``),le(new Set),D(!1),k(1);v({}),x(`filament`),C(!1),T(!1)}},[e,n,r,m]),(0,y.useEffect)(()=>{if(!e||!n||w||h.location_id!=null)return;let t=n.storage_location?.trim();if(!t||B.length===0)return;let r=B.find(e=>e.name.toLowerCase()===t.toLowerCase());r&&g(e=>e.location_id===r.id?e:{...e,location_id:r.id})},[e,n,B,h.location_id,w]),(0,y.useEffect)(()=>{e&&fe.length>0&&de(new Set(fe.map(e=>String(e.printer.id))))},[e,fe]);let Ee=(e,t)=>{let n=YXe.has(e);s&&n&&h.spoolman_filament_id!==null&&d(l(`inventory.spoolmanFilamentUnlinked`),`info`),g(r=>({...r,[e]:t,...s&&n&&r.spoolman_filament_id!==null?{spoolman_filament_id:null}:{}})),e===`weight_used`&&C(!0),e===`location_id`&&T(!0),_[e]&&v(t=>({...t,[e]:void 0}))},De=e=>{let t=e.material||``,n=e.name||``,r=t&&n.startsWith(t)?n.slice(t.length).trim():n,i=(e.color_hex??``).replace(`#`,``).toUpperCase(),a=/^[0-9A-F]{6}$/.test(i)?i:`808080`;g(n=>({...n,spoolman_filament_id:e.id,material:t,subtype:r,brand:e.vendor?.name||``,rgba:`${a}FF`,color_name:e.color_name||``,label_weight:e.weight??n.label_weight})),d(l(`inventory.spoolmanFilamentSelected`),`success`)},Oe=e=>{oe(t=>PU(e,t))},ke=J({mutationFn:e=>s?Q.createSpoolmanInventorySpool(e):Q.createSpool(e),onSuccess:async e=>{e?.id&&!await Ve(e.id)||(await f(),o&&o([e]),d(l(`inventory.spoolCreated`),`success`),t())},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),Ae=J({mutationFn:({data:e,qty:t})=>s?Q.bulkCreateSpoolmanInventorySpools(e,t):Q.bulkCreateSpools(e,t),onSuccess:async e=>{let n=s&&`created`in e?e:null,r=n?n.created:e;if(ce.size>0)for(let e of r)await Ve(e.id);await f(),o&&o(r),n&&n.failed_count>0?d(l(`inventory.spoolsPartiallyCreated`,{created:r.length,total:n.requested_count}),`warning`):d(l(`inventory.spoolsCreated`,{count:r.length}),`success`),t()},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),je=J({mutationFn:e=>s?Q.updateSpoolmanInventorySpool(n.id,e):Q.updateSpool(n.id,e),onSuccess:async()=>{n?.id&&!await Ve(n.id)||(await f(),d(l(`inventory.spoolUpdated`),`success`),t())},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.saveFailed`),`error`)}}),Me=J({mutationFn:()=>s?Q.updateSpoolmanInventorySpool(n.id,S9):Q.updateSpool(n.id,S9),onSuccess:async()=>{await f(),d(l(`inventory.rfidCleared`,`RFID tag cleared`),`success`),t()},onError:e=>{e instanceof Uu&&e.status===503?d(l(`inventory.spoolmanUnreachable`),`error`):d(l(`inventory.tagClearFailed`),`error`)}}),{data:Ne}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),enabled:e&&p&&!s}),{data:Pe}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e&&p&&s}),Fe=(()=>{if(n)return s?Pe?.find(e=>e.spoolman_spool_id===n.id):Ne?.find(e=>e.spool_id===n.id)})(),{data:Ie}=q({queryKey:[`inventory-spools`],queryFn:()=>Q.getSpools(!0),enabled:e}),{data:Le}=q({queryKey:[`settings`],queryFn:Q.getSettings,enabled:e}),Re=(()=>{let e=new Set;for(let t of Ie??[]){let n=t.category?.trim();n&&e.add(n)}return Array.from(e).sort((e,t)=>e.localeCompare(t))})(),ze=Le?.low_stock_threshold??20,Be=J({mutationFn:async()=>{if(!Fe)throw Error(`No assignment`);if(s){if(!n)throw Error(`No spool`);await Q.unassignSpoolmanSlot(n.id);return}await Q.unassignSpool(Fe.printer_id,Fe.ams_id,Fe.tray_id)},onSuccess:async()=>{s?(await u.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),await u.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})):await u.invalidateQueries({queryKey:[`spool-assignments`]}),d(l(`inventory.unassignSuccess`,`Spool unassigned`),`success`),t()},onError:e=>{d(e.message,`error`)}}),Ve=async e=>{let t=s?Q.saveSpoolmanKProfiles:Q.saveSpoolKProfiles;if(ce.size===0)try{return await t(e,[]),!0}catch(e){return console.error(`Failed to save K-profiles:`,e),d(l(`inventory.kProfileSaveFailed`),`warning`),!1}let n=[],r=0;for(let e of ce){let[t,i,a]=e.split(`:`),o=parseInt(t),s=parseInt(i),c=a===`null`?0:parseInt(a),l=fe.find(e=>e.printer.id===o);if(l){let e=l.calibrations.find(e=>e.cali_idx===s);e?n.push({printer_id:o,extruder:c,nozzle_diameter:e.nozzle_diameter||`0.4`,k_value:e.k_value,name:e.name||null,cali_idx:e.cali_idx,setting_id:e.setting_id||null}):r++}else r++}if(r>0)return console.error(`saveKProfiles: ${r} profile key(s) could not be resolved`,Array.from(ce)),d(l(`inventory.kProfileSaveFailed`),`warning`),!1;if(n.length>0)try{return await t(e,n),!0}catch(e){return console.error(`Failed to save K-profiles:`,e),d(l(`inventory.kProfileSaveFailed`),`warning`),!1}return!0};if((0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let He=()=>{let e=m9(h,E,s);if(!e.isValid){v(e.errors),(e.errors.slicer_filament||e.errors.material||e.errors.brand||e.errors.subtype)&&x(`filament`);return}let t=Te?.displayName||I||null,n={material:h.material||null,subtype:h.subtype||null,brand:h.brand||null,color_name:h.color_name||null,rgba:h.rgba||null,extra_colors:h.extra_colors||null,effect_type:h.effect_type||null,label_weight:h.label_weight,...s?{}:{core_weight:h.core_weight,core_weight_catalog_id:h.core_weight_catalog_id},slicer_filament:h.slicer_filament||null,slicer_filament_name:t,nozzle_temp_min:null,nozzle_temp_max:null,note:h.note||null,cost_per_kg:h.cost_per_kg,category:h.category.trim()||null,low_stock_threshold_pct:h.low_stock_threshold_pct,...s?{spoolman_filament_id:h.spoolman_filament_id}:{}};(!p||S)&&(n.weight_used=h.weight_used),(!p||w)&&(n.location_id=h.location_id),p?je.mutate(n):O>1?Ae.mutate({data:n,qty:O}):ke.mutate(n)},Ue=ke.isPending||Ae.isPending||je.isPending||Me.isPending||Be.isPending;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-baseline gap-2`,children:[l(p?`inventory.editSpool`:m?`inventory.copySpool`:`inventory.addSpool`),p&&n&&(0,K.jsxs)(`span`,{className:`text-sm font-mono text-bambu-gray`,children:[`#`,n.id]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),r===`create`&&(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-amber-400`}),(0,K.jsx)(`span`,{className:`text-sm text-white`,children:l(`inventory.quickAdd`)})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{D(!E),E||x(`filament`)},className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${E?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${E?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,K.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,K.jsxs)(`button`,{onClick:()=>x(`filament`),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${b===`filament`?`text-bambu-green border-b-2 border-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(ml,{className:`w-4 h-4`}),l(`inventory.filamentInfoTab`)]}),!E&&(0,K.jsxs)(`button`,{onClick:()=>x(`pa-profile`),className:`flex-1 px-4 py-2.5 text-sm font-medium flex items-center justify-center gap-2 transition-colors ${b===`pa-profile`?`text-bambu-green border-b-2 border-bambu-green`:`text-bambu-gray hover:text-white`}`,children:[(0,K.jsx)(Ro,{className:`w-4 h-4`}),l(`inventory.paProfileTab`),pe>0&&(0,K.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded-full bg-bambu-green/20 text-bambu-green`,children:pe})]})]}),(0,K.jsx)(`div`,{className:`p-4 overflow-y-auto flex-1`,style:{scrollbarGutter:`stable`},children:b===`filament`?(0,K.jsxs)(`div`,{className:`space-y-6`,children:[s&&!p&&(0,K.jsx)(`div`,{children:ge?(0,K.jsx)(`p`,{className:`text-sm text-red-400 px-1`,children:l(`inventory.spoolmanCatalogLoadFailed`)}):(0,K.jsx)(QXe,{filaments:me,isLoading:he,selectedId:h.spoolman_filament_id,onSelect:De})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.filamentInfo`)}),(0,K.jsx)(h9,{formData:h,updateField:Ee,cloudAuthenticated:A,loadingCloudPresets:M,presetInputValue:I,setPresetInputValue:L,selectedPresetOption:Te,filamentOptions:_e,availableBrands:Ce,availableMaterials:we,quickAdd:E,quantity:O,onQuantityChange:k,errors:_})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.color`)}),(0,K.jsx)(g9,{formData:h,updateField:Ee,recentColors:ae,onColorUsed:Oe,catalogColors:ie})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-bambu-gray uppercase tracking-wide mb-3`,children:l(`inventory.additional`)}),(0,K.jsx)(_9,{formData:h,updateField:Ee,spoolCatalog:R,currencySymbol:a,availableCategories:Re,availableLocations:B,onCreateLocation:async e=>{try{let t=await Q.createLocation({name:e});return V(e=>[...e,{id:t.id,name:t.name}].sort((e,t)=>e.name.localeCompare(t.name))),await b9(u),{id:t.id,name:t.name}}catch(e){return console.error(e),d((e instanceof Error?e.message:l(`locations.saveFailed`))||l(`locations.saveFailed`),`error`),null}},globalLowStockThreshold:ze,spoolmanMode:s})]}),p&&n&&!s&&(0,K.jsx)(`div`,{children:(0,K.jsx)(tZe,{spoolId:n.id})})]}):(0,K.jsx)(v9,{formData:h,updateField:Ee,printersWithCalibrations:fe,selectedProfiles:ce,setSelectedProfiles:le,expandedPrinters:ue,setExpandedPrinters:de})}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t border-bambu-dark-tertiary flex-shrink-0`,children:[p&&(0,K.jsxs)(`div`,{className:`flex gap-2 mr-auto`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Me.mutate(),disabled:Ue||!n?.tag_uid,children:[(0,K.jsx)(fu,{className:`w-4 h-4`}),l(`inventory.clearRfid`,`Clear RFID Tag`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>Be.mutate(),disabled:Ue||!Fe,children:[(0,K.jsx)(Eu,{className:`w-4 h-4`}),l(`inventory.unassignSpool`,`Unassign`)]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 ml-auto`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:t,children:l(`common.cancel`)}),(0,K.jsx)($,{onClick:He,disabled:Ue,children:Ue?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),l(`common.saving`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),l(p?`common.save`:m?`inventory.copySpool`:`inventory.addSpool`)]})})]})]})]})]})}function rZe({isOpen:e,onClose:t,columns:n,defaultColumns:r,onSave:i}){let{t:a}=W(),[o,s]=(0,y.useState)(n),[c,l]=(0,y.useState)(null),u=(0,y.useRef)(null);if((0,y.useEffect)(()=>{e&&s(n.map(e=>({...e})))},[e,n]),(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let d=e=>{s(t=>t.map((t,n)=>n===e?{...t,visible:!t.visible}:t))},f=(e,t)=>{t<0||t>=o.length||s(n=>{let r=[...n],[i]=r.splice(e,1);return r.splice(t,0,i),r})},p=(e,t)=>{u.current=t,l(t),e.dataTransfer.effectAllowed=`move`},m=(e,t)=>{e.preventDefault(),e.dataTransfer.dropEffect=`move`;let n=u.current;n!==null&&n!==t&&(f(n,t),u.current=t,l(t))},h=e=>{e.preventDefault()},g=()=>{u.current=null,l(null)},_=()=>{s(r.map(e=>({...e})))},v=()=>{i(o),t()},b=o.filter(e=>e.visible).length;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:t,children:(0,K.jsx)(_d,{className:`w-full max-w-md max-h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(yd,{className:`p-6 flex flex-col min-h-0`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:a(`inventory.configureColumns`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:[a(`inventory.configureColumnsDesc`),(0,K.jsxs)(`span`,{className:`ml-2 text-bambu-gray/60`,children:[`(`,b,` `,a(`inventory.of`),` `,o.length,` `,a(`inventory.visible`),`)`]})]}),(0,K.jsx)(`div`,{className:`space-y-1 overflow-y-auto flex-1 min-h-0 pr-1`,children:o.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-lg border transition-colors ${c===t?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-tertiary/50`} ${e.visible?``:`opacity-50`}`,draggable:!0,onDragStart:e=>p(e,t),onDragOver:e=>m(e,t),onDrop:h,onDragEnd:g,children:[(0,K.jsx)(`div`,{className:`cursor-grab text-bambu-gray/50 hover:text-bambu-gray`,children:(0,K.jsx)(xc,{className:`w-4 h-4`})}),(0,K.jsx)(`span`,{className:`flex-1 font-medium text-sm text-white`,children:e.label}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(`button`,{onClick:()=>f(t,t-1),disabled:t===0,className:`p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed`,title:a(`inventory.moveUp`),children:(0,K.jsx)(cs,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>f(t,t+1),disabled:t===o.length-1,className:`p-1 rounded text-bambu-gray hover:bg-bambu-dark-secondary disabled:opacity-30 disabled:cursor-not-allowed`,title:a(`inventory.moveDown`),children:(0,K.jsx)(is,{className:`w-4 h-4`})})]}),(0,K.jsx)(`button`,{onClick:()=>d(t),className:`p-1.5 rounded transition-colors ${e.visible?`text-bambu-green hover:bg-bambu-green/10`:`text-bambu-gray/50 hover:bg-bambu-dark-secondary`}`,title:e.visible?a(`inventory.hideColumn`):a(`inventory.showColumn`),children:e.visible?(0,K.jsx)(Xs,{className:`w-4 h-4`}):(0,K.jsx)(Ys,{className:`w-4 h-4`})})]},e.id))}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)($,{variant:`secondary`,onClick:_,className:`mr-auto`,children:[(0,K.jsx)(Al,{className:`w-4 h-4`}),a(`inventory.reset`)]}),(0,K.jsx)($,{variant:`secondary`,onClick:t,children:a(`inventory.cancel`)}),(0,K.jsx)($,{onClick:v,children:a(`inventory.applyChanges`)})]})]})})})}var iZe=[{value:`ams_holder_74x33`,i18nKey:`amsHolderSmall`,fallbackLabel:`AMS holder — small (74 × 33 mm)`,fallbackHint:`Single label per page; matches the printable label from MakerWorld model 752566 (AMS Filament Label Holder).`},{value:`ams_holder_75x55`,i18nKey:`amsHolderLarge`,fallbackLabel:`AMS holder — large (75 × 55 mm)`,fallbackHint:`Single label per page; fits the cardstock-insert variant of the AMS Filament Label Holder. Roomy enough for swatch, brand, material, ID, and QR code.`},{value:`box_40x30`,i18nKey:`box40x30`,fallbackLabel:`Box label (40 × 30 mm)`,fallbackHint:`Single label per page; common DK/Brother roll size, good for filament-bag and storage-bin labels.`},{value:`box_62x29`,i18nKey:`box`,fallbackLabel:`Box label (62 × 29 mm)`,fallbackHint:`Single label per page; sized for Brother PT/QL and Dymo small labels.`},{value:`avery_l7160`,i18nKey:`averyL7160`,fallbackLabel:`Avery L7160 — A4 sheet (38.1 × 63.5 mm × 21)`,fallbackHint:`EU sheet stock; 21 labels per A4 page.`},{value:`avery_5160`,i18nKey:`avery5160`,fallbackLabel:`Avery 5160 — US Letter sheet (25.4 × 66.7 mm × 30)`,fallbackHint:`US sheet stock; 30 labels per Letter page.`}];function aZe(e){let t=window.URL.createObjectURL(e);if(!window.open(t,`_blank`)){let e=document.createElement(`a`);e.href=t,e.download=`bambuddy-labels.pdf`,document.body.appendChild(e),e.click(),document.body.removeChild(e)}setTimeout(()=>window.URL.revokeObjectURL(t),6e4)}function oZe(e){return Jd(e)}function sZe(e){return`${e.color_name??`${e.material}${e.subtype?` ${e.subtype}`:``}`}${e.brand?` · ${e.brand}`:``}`}function cZe(e){return[e.color_name,e.material,e.subtype,e.brand,`#${e.id}`].filter(Boolean).join(` `).toLowerCase()}function C9(e){if(!e)return[1,0];let t=e.replace(/^#/,``).slice(0,6);if(t.length!==6)return[1,0];let n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);if([n,r,i].some(Number.isNaN))return[1,0];let a=n/255,o=r/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=(c+l)/2,d=c-l;if((d===0?0:d/(1-Math.abs(2*u-1)))<.1)return[1,u];let f=0;return f=c===a?(o-s)/d%6:c===o?(s-a)/d+2:(a-o)/d+4,f*=60,f<0&&(f+=360),[0,f]}function lZe({isOpen:e,onClose:t,availableSpools:n,initialSelectedIds:r,spoolmanMode:i}){let{t:a}=W(),{showToast:o}=Td(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(new Set),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(``),[h,g]=(0,y.useState)(`id`);(0,y.useEffect)(()=>{if(e){let e=new Set(n.map(e=>e.id));u(new Set(r.filter(t=>e.has(t)))),f(``),m(``),g(`id`),c(null)}},[e]);let _=(0,y.useMemo)(()=>{let e=[...n];return h===`color`?(e.sort((e,t)=>{let n=C9(e.rgba),r=C9(t.rgba);return n[0]===r[0]?n[1]===r[1]?e.id-t.id:n[1]-r[1]:n[0]-r[0]}),e):(e.sort((e,t)=>e.id-t.id),e)},[n,h]),v=(0,y.useMemo)(()=>{let e=new Set;for(let t of _)t.material&&e.add(t.material.toUpperCase());return[...e].sort()},[_]),b=(0,y.useMemo)(()=>{let e=d.trim().toLowerCase();return _.filter(t=>!(p&&(t.material||``).toUpperCase()!==p||e&&!cZe(t).includes(e)))},[_,d,p]),x=b.length>0&&b.every(e=>l.has(e.id));if(!e)return null;let S=l.size,C=S===0;function w(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function T(){u(e=>{let t=new Set(e);for(let e of b)t.add(e.id);return t})}function E(){u(e=>{let t=new Set(e);for(let e of b)t.delete(e.id);return t})}function D(){u(new Set)}async function O(e){if(C||s)return;let n=_.filter(e=>l.has(e.id)).map(e=>e.id);c(e);try{aZe(i?await Q.printSpoolmanSpoolLabels({spool_ids:n,template:e}):await Q.printSpoolLabels({spool_ids:n,template:e})),t()}catch(e){o(a(`inventory.labels.error`,`Could not generate labels: {{msg}}`,{msg:e instanceof Error?e.message:String(e)}),`error`)}finally{c(null)}}return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start sm:items-center justify-center p-4 overflow-y-auto`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:t}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-3xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] overflow-hidden flex flex-col my-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Tl,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:a(`inventory.labels.title`,`Print spool labels`)}),S>0&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,a(`inventory.labels.selectedCount`,`{{count}} selected`,{count:S}),`)`]})]}),(0,K.jsx)(`button`,{onClick:t,className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,"aria-label":a(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-2 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none`}),(0,K.jsx)(`input`,{type:`search`,value:d,onChange:e=>f(e.target.value),placeholder:a(`inventory.labels.searchPlaceholder`,`Search name, brand, or #ID`),className:`w-full pl-9 pr-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray focus:outline-none focus:border-bambu-green`})]}),v.length>1&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:a(`inventory.labels.filterByMaterial`,`Material:`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>m(``),className:`px-2 py-0.5 text-xs rounded-full border transition ${p===``?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.allMaterials`,`All`)}),v.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>m(e),className:`px-2 py-0.5 text-xs rounded-full border transition ${p===e?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:e},e))]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray mr-1`,children:a(`inventory.labels.sortBy.label`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(`id`),className:`px-2 py-0.5 text-xs rounded-full border transition ${h===`id`?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.sortBy.id`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(`color`),className:`px-2 py-0.5 text-xs rounded-full border transition ${h===`color`?`bg-bambu-green text-bambu-dark border-bambu-green`:`bg-bambu-dark text-bambu-gray border-bambu-dark-tertiary hover:border-bambu-gray`}`,children:a(`inventory.labels.sortBy.color`)})]})]}),(0,K.jsxs)(`div`,{className:`px-4 pt-3 pb-2 flex items-center justify-between gap-3 flex-wrap`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:a(`inventory.labels.pickSpools`,`Pick which spools to print labels for:`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:x?E:T,disabled:b.length===0,className:`text-bambu-green hover:underline disabled:opacity-50 disabled:no-underline disabled:cursor-not-allowed`,children:x?a(`inventory.labels.deselectVisible`,`Deselect visible`):a(`inventory.labels.selectVisible`,`Select all visible ({{count}})`,{count:b.length})}),(0,K.jsx)(`button`,{type:`button`,onClick:D,disabled:S===0,className:`text-bambu-gray hover:text-white hover:underline disabled:opacity-50 disabled:no-underline disabled:cursor-not-allowed`,children:a(`inventory.labels.clearAll`,`Clear all`)})]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-2 pb-2 min-h-0`,children:b.length===0?(0,K.jsx)(`div`,{className:`text-center text-sm text-bambu-gray py-6`,children:_.length===0?a(`inventory.labels.noSpoolsToShow`,`No spools to show. Adjust your filter and try again.`):a(`inventory.labels.noMatches`,`No spools match the current search or filter.`)}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:b.map(e=>{let t=l.has(e.id);return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary/50 cursor-pointer`,children:[t?(0,K.jsx)(iu,{className:`w-4 h-4 text-bambu-green shrink-0`}):(0,K.jsx)(ou,{className:`w-4 h-4 text-bambu-gray shrink-0`}),(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>w(e.id),className:`sr-only`}),(0,K.jsx)(`span`,{className:`w-4 h-4 rounded border border-black/20 shrink-0`,style:oZe(e.rgba)}),(0,K.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-sm text-white`,children:sZe(e)}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray shrink-0`,children:[`#`,e.id]})]})},e.id)})})}),(0,K.jsx)(`div`,{className:`px-3 pt-2 pb-2 grid grid-cols-1 sm:grid-cols-2 gap-2 border-t border-bambu-dark-tertiary`,children:iZe.map(e=>{let t=s===e.value,n=a(`inventory.labels.templates.${e.i18nKey}.label`,e.fallbackLabel),r=a(`inventory.labels.templates.${e.i18nKey}.hint`,e.fallbackHint);return(0,K.jsxs)(`button`,{disabled:C||s!==null,onClick:()=>O(e.value),title:`${n} — ${r}`,className:`w-full text-left p-2.5 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-green hover:bg-bambu-green/10 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:border-bambu-dark-tertiary disabled:hover:bg-bambu-dark transition flex items-center gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`div`,{className:`font-medium text-white text-sm truncate`,children:n}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-0.5 truncate`,children:r})]}),t&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin text-bambu-green shrink-0`})]},e.value)})}),(0,K.jsx)(`div`,{className:`flex justify-end gap-2 px-5 py-2 border-t border-bambu-dark-tertiary`,children:(0,K.jsx)($,{variant:`secondary`,onClick:t,disabled:s!==null,children:a(`common.cancel`,`Cancel`)})})]})]})}function uZe({onClose:e,onImported:t}){let{t:n}=W(),[r,i]=(0,y.useState)(null),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),h=(0,y.useRef)(null),g=async e=>{i(e),c(null),m(null),u(!0);try{c(await Q.importSpoolsCsvPreview(e))}catch(e){m(e instanceof Error?e.message:n(`inventory.csv.previewError`,`Could not read the CSV file`))}finally{u(!1)}},_=e=>{let t=e.target.files?.[0];t&&g(t)},v=e=>{e.preventDefault(),o(!1);let t=e.dataTransfer.files?.[0];t&&g(t)},b=async()=>{if(r){f(!0),m(null);try{t((await Q.importSpoolsCsv(r)).created)}catch(e){m(e instanceof Error?e.message:n(`inventory.csv.importError`,`Import failed`)),f(!1)}}},x=e=>e===`valid`?(0,K.jsx)(ps,{className:`w-4 h-4 text-green-500 flex-shrink-0`}):e===`error`?(0,K.jsx)(ys,{className:`w-4 h-4 text-red-500 flex-shrink-0`}):(0,K.jsx)(gs,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),S=s?.valid_count??0;return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg w-full max-w-3xl border border-bambu-dark-tertiary flex flex-col max-h-[90vh]`,children:[(0,K.jsxs)(`div`,{className:`p-4 border-b border-bambu-dark-tertiary flex items-center justify-between`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:n(`inventory.csv.modalTitle`,`Import spools from CSV`)}),(0,K.jsx)(`button`,{onClick:e,className:`p-1 hover:bg-bambu-dark rounded`,children:(0,K.jsx)(Ru,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto flex-1`,children:[(0,K.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:e=>{e.preventDefault(),o(!1)},onDrop:v,onClick:()=>h.current?.click(),className:`border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors ${a?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Du,{className:`w-9 h-9 mx-auto mb-2 ${a?`text-bambu-green`:`text-bambu-gray`}`}),r?(0,K.jsxs)(`p`,{className:`text-white font-medium flex items-center justify-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4`}),` `,r.name]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.csv.selectFile`,`Choose a CSV file or drag it here`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1`,children:n(`inventory.csv.dragHint`,`Header: material (required), brand, subtype, color_name, rgba, …`)})]})]}),(0,K.jsx)(`input`,{ref:h,type:`file`,accept:`.csv,text/csv`,className:`hidden`,onChange:_}),l&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-bambu-gray py-4`,children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),n(`inventory.csv.parsing`,`Reading file…`)]}),p&&(0,K.jsxs)(`div`,{className:`p-3 bg-red-500/10 border border-red-500/30 rounded-lg flex items-start gap-3`,children:[(0,K.jsx)(ys,{className:`w-5 h-5 text-red-400 mt-0.5 flex-shrink-0`}),(0,K.jsx)(`p`,{className:`text-sm text-red-300 break-words`,children:p})]}),s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-sm`,children:[(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-green-500/10 text-green-400`,children:n(`inventory.csv.validCount`,`{{count}} valid`,{count:s.valid_count})}),(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-red-500/10 text-red-400`,children:n(`inventory.csv.errorCount`,`{{count}} error`,{count:s.error_count})}),(0,K.jsx)(`span`,{className:`px-2 py-1 rounded bg-bambu-dark text-bambu-gray`,children:n(`inventory.csv.skippedCount`,`{{count}} skipped`,{count:s.skipped_count})})]}),s.warnings.length>0&&(0,K.jsx)(`div`,{className:`p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg space-y-1`,children:s.warnings.map((e,t)=>(0,K.jsx)(`p`,{className:`text-xs text-yellow-300`,children:e},t))}),s.rows.length>0&&(0,K.jsx)(`div`,{className:`border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:(0,K.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{className:`bg-bambu-dark sticky top-0`,children:(0,K.jsxs)(`tr`,{className:`text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colRow`,`Row`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colStatus`,`Status`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.material`,`Material`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.brand`,`Brand`)}),(0,K.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:n(`inventory.csv.colColor`,`Color`)})]})}),(0,K.jsx)(`tbody`,{children:s.rows.map(e=>(0,K.jsxs)(`tr`,{className:`border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`td`,{className:`px-3 py-2 text-bambu-gray`,children:e.row_number}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[x(e.status),e.status===`error`&&e.reason&&(0,K.jsx)(`span`,{className:`text-xs text-red-400 break-words`,children:e.reason})]})}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:e.material||`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2 text-white`,children:e.brand||`—`}),(0,K.jsx)(`td`,{className:`px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.rgba&&(0,K.jsx)(`span`,{className:`inline-block w-4 h-4 rounded-full border border-bambu-dark-tertiary flex-shrink-0`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-white`,children:e.color_name||`—`}),e.resolved_color&&!e.cross_material_color&&(0,K.jsx)(`span`,{title:n(`inventory.csv.colorResolved`,`Color filled from catalog`),children:(0,K.jsx)(Mu,{className:`w-3.5 h-3.5 text-bambu-green flex-shrink-0`})}),e.cross_material_color&&(0,K.jsx)(`span`,{title:n(`inventory.csv.colorCrossMaterial`,`Color taken from a different material — no exact match in catalog`),children:(0,K.jsx)(Cu,{className:`w-3.5 h-3.5 text-yellow-500 flex-shrink-0`})}),e.duplicate_of_existing&&(0,K.jsx)(`span`,{title:n(`inventory.csv.duplicateExisting`,`A spool with this material, brand and color already exists — it will still be imported as a new spool`),children:(0,K.jsx)(Ms,{className:`w-3.5 h-3.5 text-amber-400 flex-shrink-0`})})]})})]},e.row_number))})]})})})]})]}),(0,K.jsxs)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:e,disabled:d,children:n(`common.cancel`)}),(0,K.jsx)($,{onClick:b,disabled:!s||S===0||d,children:d?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),n(`inventory.csv.importing`,`Importing…`)]}):S>0?n(`inventory.csv.importValidRows`,`Import {{count}} valid rows`,{count:S}):n(`inventory.csv.noValidRows`,`No valid rows`)})]})]})})}function dZe({open:e,onClose:t,onPickLocation:n}){let{t:r}=W(),i=no(),{showToast:a}=Td(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(``),[f,p]=(0,y.useState)(null),{data:m=[],isLoading:h}=q({queryKey:y9,queryFn:Q.getLocations,enabled:e}),g=()=>{b9(i),i.invalidateQueries({queryKey:[`inventory-spools`]}),i.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},_=J({mutationFn:async()=>{let e=u.trim();if(!e)throw Error(r(`locations.nameRequired`));return c?Q.updateLocation(c.id,{name:e}):Q.createLocation({name:e})},onSuccess:()=>{a(r(c?`locations.updated`:`locations.created`),`success`),s(!1),l(null),d(``),g()},onError:e=>{a(e.message||r(`locations.saveFailed`),`error`)}}),v=J({mutationFn:e=>Q.deleteLocation(e),onSuccess:()=>{a(r(`locations.deleted`),`success`),p(null),g()},onError:e=>{a(e.message||r(`locations.deleteFailed`),`error`)}}),b=()=>{l(null),d(``),s(!0)},x=e=>{l(e),d(e.name),s(!0)},S=(0,y.useCallback)(()=>{_.isPending||(s(!1),l(null),d(``))},[_.isPending]);(0,y.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(_.isPending||v.isPending||(o?S():f||t()))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,o,f,_.isPending,v.isPending,S,t]);let C=e=>{e.preventDefault(),_.mutate()};if(!e)return null;let w=`locations-modal-title`,T=`location-editor-title`;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:()=>{_.isPending||v.isPending||t()}}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-2xl mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-h-[90vh] flex flex-col`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":w,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h2`,{id:w,className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,K.jsx)(Zc,{className:`w-5 h-5 text-bambu-green`}),r(`locations.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm mt-0.5`,children:r(`locations.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{onClick:b,children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),r(`locations.add`)]}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-white rounded`,onClick:t,"aria-label":r(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})]}),(0,K.jsx)(`div`,{className:`overflow-y-auto`,children:h?(0,K.jsxs)(`div`,{className:`flex items-center justify-center py-16 text-bambu-gray`,children:[(0,K.jsx)(X,{className:`w-6 h-6 animate-spin mr-2`}),r(`common.loading`)]}):m.length===0?(0,K.jsx)(`div`,{className:`py-16 text-center text-bambu-gray`,children:r(`locations.empty`)}):(0,K.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary text-left text-bambu-gray`,children:[(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium`,children:r(`locations.name`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right`,children:r(`locations.spools`)}),(0,K.jsx)(`th`,{className:`px-4 py-3 font-medium text-right w-32`,children:r(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:m.map(e=>(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/60 hover:bg-bambu-dark-tertiary/30 cursor-pointer`,onClick:()=>{n&&(n(e.id),t())},children:[(0,K.jsx)(`td`,{className:`px-4 py-3 text-white font-medium`,children:e.name}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right text-bambu-gray`,children:e.spool_count}),(0,K.jsx)(`td`,{className:`px-4 py-3 text-right`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded`,onClick:()=>x(e),title:r(`common.edit`),"aria-label":r(`locations.editAria`,{name:e.name,defaultValue:`Edit ${e.name}`}),children:(0,K.jsx)(vl,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{type:`button`,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded disabled:opacity-40`,disabled:e.spool_count>0,onClick:()=>p(e),title:e.spool_count>0?r(`locations.deleteBlocked`):r(`common.delete`),"aria-label":r(`locations.deleteAria`,{name:e.name,defaultValue:`Delete ${e.name}`}),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]},e.id))})]})})]}),o&&(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:S}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-md mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-6 shadow-2xl`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":T,children:[(0,K.jsx)(`h3`,{id:T,className:`text-lg font-semibold text-white mb-4`,children:r(c?`locations.edit`:`locations.add`)}),(0,K.jsxs)(`form`,{onSubmit:C,children:[(0,K.jsx)(`label`,{className:`block text-sm font-medium text-bambu-gray mb-1`,htmlFor:`location-name`,children:r(`locations.name`)}),(0,K.jsx)(`input`,{id:`location-name`,type:`text`,maxLength:255,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:outline-none focus:border-bambu-green mb-4`,placeholder:r(`locations.createPlaceholder`),value:u,onChange:e=>d(e.target.value),autoFocus:!0}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,onClick:S,children:r(`common.cancel`)}),(0,K.jsxs)($,{type:`submit`,disabled:_.isPending||!u.trim(),children:[_.isPending&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),r(`common.save`)]})]})]})]})]}),f&&(0,K.jsx)(Ad,{title:r(`locations.confirmDelete`,{name:f.name}),message:r(`locations.confirmDeleteMessage`),confirmText:r(`common.delete`),variant:`danger`,isLoading:v.isPending,onConfirm:()=>v.mutate(f.id),onCancel:()=>p(null)})]})}var w9=[{id:`material`,type:`searchable`,labelKey:`inventory.material`},{id:`subtype`,type:`searchable`,labelKey:`inventory.subtype`},{id:`brand`,type:`searchable`,labelKey:`inventory.brand`},{id:`color_name`,type:`text`,labelKey:`inventory.colorName`},{id:`rgba`,type:`color`,labelKey:`inventory.color`,pattern:`^[0-9A-Fa-f]{6}([0-9A-Fa-f]{2})?$`},{id:`location_id`,type:`searchableClosed`,labelKey:`inventory.storageLocation`},{id:`slicer_filament_name`,type:`searchable`,labelKey:`inventory.slicerFilamentName`},{id:`slicer_filament`,type:`searchable`,labelKey:`inventory.slicerFilament`},{id:`cost_per_kg`,type:`number`,labelKey:`inventory.costPerKg`,min:0,step:.01},{id:`note`,type:`textarea`,labelKey:`inventory.note`},{id:`label_weight`,type:`number`,labelKey:`inventory.labelWeight`,min:1,step:1},{id:`core_weight`,type:`number`,labelKey:`inventory.coreWeight`,min:0,step:1},{id:`category`,type:`searchable`,labelKey:`inventory.category`},{id:`low_stock_threshold_pct`,type:`number`,labelKey:`inventory.lowStockThresholdOverride`,min:1,max:99,step:1}];function fZe({value:e,onChange:t,options:n,allowCustom:r,placeholderKey:i,disabled:a}){let{t:o}=W(),s=(0,y.useRef)(null),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(``);(0,y.useEffect)(()=>{if(!c)return;let e=e=>{s.current&&!s.current.contains(e.target)&&(l(!1),d(``))},t=e=>{e.key===`Escape`&&(l(!1),d(``))};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[c]);let f=c?u:n.find(t=>t.value===e)?.label??e,p=(0,y.useMemo)(()=>{if(!c)return n;let e=u.trim().toLowerCase();return e?n.filter(t=>t.label.toLowerCase().includes(e)||t.value.toLowerCase().includes(e)):n},[c,u,n]),m=c&&u.trim()&&!n.some(e=>e.value.toLowerCase()===u.trim().toLowerCase());return(0,K.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,K.jsx)(`input`,{type:`text`,disabled:a,value:f,onChange:e=>{d(e.target.value),l(!0),r&&t(e.target.value)},onFocus:()=>{l(!0),d(``)},placeholder:i?o(i):void 0,className:`w-full px-3 py-2 pr-9 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`}),(0,K.jsx)(is,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50 pointer-events-none`}),c&&(0,K.jsxs)(`div`,{className:`absolute z-50 left-0 right-0 mt-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg max-h-64 overflow-y-auto`,children:[p.length===0&&!r&&(0,K.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:o(`inventory.noResults`)}),p.map(n=>(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${e===n.value?`bg-bambu-green/10 text-bambu-green`:`text-white`}`,onClick:()=>{t(n.value),l(!1),d(``)},children:n.label},n.value)),r&&m&&(0,K.jsx)(`button`,{type:`button`,className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary text-bambu-green border-t border-bambu-dark-tertiary`,onClick:()=>{t(u.trim()),l(!1),d(``)},children:o(`inventory.bulk.useCustom`,{value:u.trim()})})]})]})}function T9(...e){let t=new Set;for(let n of e)for(let e of n){let n=e?.trim();n&&t.add(n)}return Array.from(t).sort((e,t)=>e.localeCompare(t))}function pZe({isOpen:e,selectedCount:t,isPending:n,availableLocations:r,availableMaterials:i,availableSubtypes:a,availableBrands:o,availableCategories:s,availableSlicerFilaments:c,availableSlicerFilamentNames:l,onClose:u,onApply:d}){let{t:f}=W(),{data:p=[]}=q({queryKey:[`bulk-edit-cloud-presets`],enabled:e,staleTime:300*1e3,queryFn:async()=>{let e=[];try{if((await Q.getCloudStatus()).is_authenticated){let t=await Q.getFilamentPresets();e.push(...t)}}catch{}try{if((await Q.orcaCloudStatus()).connected){let t=await Q.orcaCloudListProfiles();e.push(...t.filament)}}catch{}return e}}),{data:m}=q({queryKey:[`bulk-edit-local-presets`],enabled:e,staleTime:300*1e3,queryFn:Q.getLocalPresets}),{data:h=[]}=q({queryKey:[`builtin-filaments`],enabled:e,staleTime:300*1e3,queryFn:Q.getBuiltinFilaments}),g=(0,y.useMemo)(()=>jU(p,new Set,m?.filament??[],h),[p,m,h]),[_,v]=(0,y.useState)({}),b=(0,y.useMemo)(()=>T9(CU,i).map(e=>({value:e,label:e})),[i]),x=(0,y.useMemo)(()=>T9(TU,a).map(e=>({value:e,label:e})),[a]),S=(0,y.useMemo)(()=>T9(wU,o).map(e=>({value:e,label:e})),[o]),C=(0,y.useMemo)(()=>T9(s).map(e=>({value:e,label:e})),[s]),w=(0,y.useMemo)(()=>{let e=g.map(e=>({value:e.code,label:e.displayName})),t=c.filter(t=>!e.some(e=>e.value===t)).map(e=>({value:e,label:e}));return[...e,...t].sort((e,t)=>e.label.localeCompare(t.label))},[g,c]),T=(0,y.useMemo)(()=>{let e=g.map(e=>({value:e.displayName,label:e.displayName})),t=l.filter(t=>!e.some(e=>e.value===t)).map(e=>({value:e,label:e}));return[...e,...t].sort((e,t)=>e.label.localeCompare(t.label))},[g,l]),E=(0,y.useMemo)(()=>r.map(e=>({value:String(e.id),label:e.name})),[r]);if(!e)return null;let D=(e,t)=>{v(n=>({...n,[e]:t}))},O=e=>{v(t=>{let n={...t};return delete n[e],n})},k=(()=>{let e={};for(let t of w9){let n=_[t.id];if(n===void 0)continue;let r=typeof n==`string`?n.trim():n;if(!(r===``||r===null))if(t.type===`number`){let n=Number(r);Number.isFinite(n)&&(e[t.id]=n)}else if(t.id===`location_id`){let n=Number(r);Number.isFinite(n)&&n>0&&(e[t.id]=n)}else if(t.id===`rgba`){let n=String(r).replace(/^#/,``),i=n.length===6?`${n}FF`:n;/^[0-9A-Fa-f]{8}$/.test(i)&&(e[t.id]=i.toUpperCase())}else e[t.id]=String(r)}return e})(),A=Object.keys(k).length>0,j=w9.some(e=>{let t=_[e.id];return t===void 0||t.trim()===``?!1:k[e.id]===void 0}),M=e=>e===`material`?b:e===`subtype`?x:e===`brand`?S:e===`category`?C:e===`slicer_filament`?w:e===`slicer_filament_name`?T:e===`location_id`?E:[],N=e=>{let t=_[e.id]??``;if(e.type===`searchable`||e.type===`searchableClosed`)return(0,K.jsx)(fZe,{value:t,onChange:t=>{t===``?O(e.id):D(e.id,t)},options:M(e.id),allowCustom:e.type===`searchable`,disabled:n});if(e.type===`textarea`)return(0,K.jsx)(`textarea`,{disabled:n,value:t,onChange:t=>D(e.id,t.target.value),className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none resize-none min-h-[60px]`});if(e.type===`color`){let r=t.trim().replace(/^#/,``),i=r.length===6?`${r}FF`:r,a=t.trim()!==``&&!/^[0-9A-Fa-f]{8}$/.test(i);return(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{type:`color`,disabled:n,value:`#${(t||`808080`).replace(/^#/,``).slice(0,6)}`,onChange:t=>D(e.id,t.target.value.replace(/^#/,``).toUpperCase()),className:`h-9 w-12 rounded cursor-pointer`}),(0,K.jsx)(`input`,{type:`text`,disabled:n,value:t,onChange:t=>D(e.id,t.target.value.replace(/^#/,``).toUpperCase()),placeholder:`RRGGBB or RRGGBBAA`,className:`flex-1 px-3 py-2 bg-bambu-dark border rounded-lg text-white placeholder-bambu-gray/50 focus:outline-none ${a?`border-red-500 focus:border-red-500`:`border-bambu-dark-tertiary focus:border-bambu-green`}`,pattern:e.pattern})]}),a&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-red-400`,children:f(`inventory.bulk.invalidHex`)})]})}return(0,K.jsx)(`input`,{type:e.type===`number`?`number`:`text`,disabled:n,value:t,onChange:t=>D(e.id,t.target.value),min:e.min,max:e.max,step:e.step,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray/50 focus:border-bambu-green focus:outline-none`})};return(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50`,onClick:n?void 0:u,children:(0,K.jsxs)(`div`,{className:`w-full max-w-3xl bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg max-h-[90vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-5 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:f(`inventory.bulk.editTitle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-0.5`,children:f(`inventory.bulk.editSubtitle`,{count:t})})]}),(0,K.jsx)(`button`,{onClick:u,disabled:n,className:`p-1 text-bambu-gray hover:text-white transition-colors`,"aria-label":f(`common.close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsx)(`p`,{className:`px-5 pt-4 text-xs text-bambu-gray`,children:f(`inventory.bulk.editHint`)}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto p-5 space-y-3`,children:w9.map(e=>{let t=_[e.id]!==void 0;return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md p-2 transition-colors ${t?`bg-bambu-green/5 border border-bambu-green/30`:`border border-transparent`}`,children:[(0,K.jsx)(`div`,{className:`pt-2`,children:(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,checked:t,onChange:t=>{t.target.checked?D(e.id,``):O(e.id)},"aria-label":f(`inventory.bulk.toggleField`)})}),(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:f(e.labelKey)}),N(e)]})]},e.id)})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 p-5 border-t border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:f(`inventory.bulk.changeCount`,{count:Object.keys(k).length})}),(0,K.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,K.jsx)($,{variant:`secondary`,onClick:u,disabled:n,children:f(`common.cancel`)}),(0,K.jsx)($,{onClick:()=>d(k),disabled:!A||n||j,children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 mr-2 animate-spin`}),f(`inventory.bulk.applyPending`)]}):f(`inventory.bulk.applyButton`,{count:t})})]})]})]})})}function mZe(e){let t=e[0],n=0,r=0,i=0;for(let t of e)n+=t.label_weight,r+=t.weight_used,i+=t.core_weight;return{...t,label_weight:n,weight_used:r,core_weight:i}}function E9(e){let t=new Set;for(let n of e)if(typeof n==`string`){let e=n.trim();e&&t.add(e)}return Array.from(t).sort((e,t)=>e.localeCompare(t))}function hZe(e){return`${e.material}|${e.subtype||``}|${e.brand||``}|${e.color_name||``}|${e.rgba||``}|${e.extra_colors||``}|${e.effect_type||``}|${e.label_weight}`}var gZe=`bambuddy-inventory-columns`,D9=[{id:`id`,label:`#`,visible:!0},{id:`added_time`,label:`Added`,visible:!0},{id:`encode_time`,label:`Encoded`,visible:!1},{id:`last_used_time`,label:`Last Used`,visible:!1},{id:`rgba`,label:`Color`,visible:!0},{id:`material`,label:`Material`,visible:!0},{id:`subtype`,label:`Subtype`,visible:!0},{id:`color_name`,label:`Color Name`,visible:!1},{id:`brand`,label:`Brand`,visible:!0},{id:`slicer_filament`,label:`Slicer Filament`,visible:!1},{id:`location`,label:`Location`,visible:!0},{id:`storage_location`,label:`Storage Location`,visible:!1},{id:`label_weight`,label:`Label`,visible:!0},{id:`net`,label:`Net`,visible:!0},{id:`gross`,label:`Gross`,visible:!1},{id:`added_full`,label:`Full`,visible:!1},{id:`used`,label:`Used`,visible:!1},{id:`printed_total`,label:`Printed Total`,visible:!1},{id:`printed_since_weight`,label:`Printed Since Weight`,visible:!1},{id:`note`,label:`Note`,visible:!1},{id:`pa_k`,label:`PA(K)`,visible:!0},{id:`tag_id`,label:`Tag ID`,visible:!1},{id:`data_origin`,label:`Data Origin`,visible:!1},{id:`tag_type`,label:`Linked Tag Type`,visible:!1},{id:`stock`,label:`Stock`,visible:!1},{id:`remaining`,label:`Remaining`,visible:!0},{id:`spool_name`,label:`Spool`,visible:!1},{id:`cost_per_kg`,label:`Cost/kg`,visible:!1},{id:`weight_check`,label:`Weight Check`,visible:!1}];function _Ze(){try{let e=localStorage.getItem(gZe);if(e){let t=JSON.parse(e),n=new Set(D9.map(e=>e.id)),r=new Set(t.map(e=>e.id)),i=t.filter(e=>n.has(e.id)),a=D9.filter(e=>!r.has(e.id));return[...i,...a]}}catch{}return D9.map(e=>({...e}))}function vZe(e){try{localStorage.setItem(gZe,JSON.stringify(e))}catch{}}function O9(e,t=!1){return t&&e>=1e3?`${(e/1e3).toFixed(1)}kg`:`${Math.round(e)}g`}var yZe={PLA:`bg-green-500/20 text-green-400`,ABS:`bg-red-500/20 text-red-400`,PETG:`bg-blue-500/20 text-blue-400`,TPU:`bg-purple-500/20 text-purple-400`,ASA:`bg-orange-500/20 text-orange-400`,PA:`bg-yellow-500/20 text-yellow-400`,PC:`bg-cyan-500/20 text-cyan-400`,PET:`bg-sky-500/20 text-sky-400`};function k9(e,t=`system`){if(!e)return`-`;let n=vf(e);return n?uf(n,t):`-`}var bZe={id:()=>`#`,added_time:()=>`Added`,encode_time:()=>`Encoded`,last_used_time:()=>`Last Used`,rgba:e=>e(`inventory.color`),material:e=>e(`inventory.material`),subtype:e=>e(`inventory.subtype`),color_name:e=>e(`inventory.colorName`),brand:e=>e(`inventory.brand`),slicer_filament:e=>e(`inventory.slicerFilament`),location:()=>`Location`,storage_location:e=>e(`inventory.storageLocation`),label_weight:e=>e(`inventory.labelWeight`),net:e=>e(`inventory.net`),gross:()=>`Gross`,added_full:()=>`Full`,used:e=>e(`inventory.weightUsed`),printed_total:()=>`Printed Total`,printed_since_weight:()=>`Printed Since Weight`,note:e=>e(`inventory.note`),pa_k:()=>`PA(K)`,tag_id:()=>`Tag ID`,data_origin:()=>`Data Origin`,tag_type:()=>`Linked Tag Type`,stock:e=>e(`inventory.stock`),remaining:e=>e(`inventory.remaining`),spool_name:e=>e(`inventory.spoolName`),cost_per_kg:e=>e(`inventory.costPerKg`),weight_check:e=>e(`inventory.weightCheck`)},A9={id:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm font-medium text-white`,children:e.id}),added_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:k9(e.created_at,t)}),encode_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:k9(e.encode_time,t)}),last_used_time:({spool:e,dateFormat:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.last_used?k9(e.last_used,t):`Never`}),rgba:({spool:e})=>(0,K.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,K.jsx)(W3,{rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,effectSize:`table`,subtype:e.subtype})}),material:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:e.material}),subtype:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.subtype||`-`}),color_name:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:Kd(e.color_name,e.rgba)||`-`}),brand:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.brand||`-`}),slicer_filament:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,title:e.slicer_filament||void 0,children:e.slicer_filament_name||e.slicer_filament||`-`}),location:({spool:e,assignmentMap:t})=>{let n=t[e.id];if(!n)return(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`});let r=n.printer_name||`Printer ${n.printer_id}`,i=n.ams_id===254||n.ams_id===255,a=!i&&n.ams_id>=128;return(0,K.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-purple-500/20 text-purple-400`,children:[r,` `,If(n.ams_id,n.tray_id,a,i),n.ams_label?` (${n.ams_label})`:``]})},storage_location:({spool:e})=>e.storage_location?(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-500/20 text-blue-400`,children:e.storage_location}):(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}),label_weight:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:O9(e.label_weight)}),net:({remaining:e})=>(0,K.jsx)(`span`,{className:`text-sm text-white`,children:O9(e)}),gross:({spool:e,remaining:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:O9(t+e.core_weight)}),added_full:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.added_full==null?`-`:e.added_full?`Yes`:`No`}),used:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.weight_used>0?O9(e.weight_used):`-`}),printed_total:()=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`}),printed_since_weight:()=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`}),note:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray max-w-[150px] truncate block`,title:e.note||void 0,children:e.note||`-`}),pa_k:({spool:e})=>(e.k_profiles?.length??0)===0?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}):(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-bambu-green/20 text-bambu-green`,children:`K`}),tag_id:({spool:e})=>{let t=e.tag_uid||e.tray_uuid;return t?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray font-mono`,title:t,children:t.length>12?`${t.slice(0,6)}...${t.slice(-4)}`:t}):(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,children:`-`})},data_origin:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.data_origin||`-`}),tag_type:({spool:e})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.tag_type||`-`}),stock:({spool:e,t})=>e.slicer_filament?(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:`-`}):(0,K.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-amber-500/20 text-amber-400`,children:t(`inventory.stock`)}),remaining:({remaining:e,pct:t})=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${t>50?`bg-bambu-green`:t>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(t,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray min-w-[40px] text-right`,children:[Math.round(e),`g`]})]}),spool_name:({spool:e,catalogMap:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:(e.core_weight_catalog_id==null?void 0:t[e.core_weight_catalog_id])?.name||`-`}),cost_per_kg:({spool:e,currencySymbol:t})=>(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:e.cost_per_kg==null?`-`:`${t}${e.cost_per_kg.toFixed(2)}`}),weight_check:({spool:e,onSyncWeight:t})=>{let n=e.last_scale_weight;if(n==null)return(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray/50`,title:`No scale measurement`,children:`-`});let r=e.core_weight||0,i=Math.max(0,e.label_weight-e.weight_used)+r,a,o;n0?`+${Math.round(a)}`:`${Math.round(a)}`,c=o?`Scale: ${Math.round(n)}g\nCalculated: ${Math.round(i)}g\nDifference: ${s}g (within tolerance)`:`Scale: ${Math.round(n)}g\nCalculated: ${Math.round(i)}g\nDifference: ${s}g (mismatch!)`;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium ${o?`text-green-400`:`text-yellow-400`}`,title:c,children:[(0,K.jsxs)(`span`,{children:[Math.round(n),`g`]}),o?(0,K.jsx)(rs,{className:`w-3 h-3`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3 h-3`}),t&&(0,K.jsx)(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),n.preventDefault(),t(e)},className:`p-1 hover:bg-bambu-green/20 rounded transition-colors text-bambu-green`,title:`Sync: trust scale weight and reset tracking`,children:(0,K.jsx)(Ol,{className:`w-3.5 h-3.5`})})]})]})}},j9={id:e=>e.id,added_time:e=>e.created_at||``,encode_time:e=>e.encode_time||``,last_used_time:e=>e.last_used||``,material:e=>(e.material||``).toLowerCase(),subtype:e=>(e.subtype||``).toLowerCase(),color_name:e=>(e.color_name||``).toLowerCase(),brand:e=>(e.brand||``).toLowerCase(),slicer_filament:e=>(e.slicer_filament_name||e.slicer_filament||``).toLowerCase(),location:(e,t)=>{let n=t[e.id];if(!n)return``;let r=n.ams_id===254||n.ams_id===255,i=!r&&n.ams_id>=128,a=n.ams_label?` (${n.ams_label})`:``;return`${n.printer_name||``} ${If(n.ams_id,n.tray_id,i,r)}${a}`},storage_location:e=>(e.storage_location||``).toLowerCase(),label_weight:e=>e.label_weight,net:e=>Math.max(0,e.label_weight-e.weight_used),gross:e=>Math.max(0,e.label_weight-e.weight_used)+e.core_weight,used:e=>e.weight_used,remaining:e=>e.label_weight>0?Math.max(0,e.label_weight-e.weight_used)/e.label_weight:0,note:e=>(e.note||``).toLowerCase(),data_origin:e=>(e.data_origin||``).toLowerCase(),tag_type:e=>(e.tag_type||``).toLowerCase(),stock:e=>+!!e.slicer_filament,spool_name:e=>e.core_weight_catalog_id??0,cost_per_kg:e=>e.cost_per_kg??0,weight_check:e=>{if(e.last_scale_weight==null)return-1;let t=Math.max(0,e.label_weight-e.weight_used)+e.core_weight;return Math.abs(e.last_scale_weight-t)}},M9=`bambuddy-inventory-sort`;function xZe(){try{let e=localStorage.getItem(M9);if(e)return JSON.parse(e)}catch{}return null}function SZe(e){try{e?localStorage.setItem(M9,JSON.stringify(e)):localStorage.removeItem(M9)}catch{}}function CZe(){let{data:e}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),t=e!==void 0;return(0,K.jsx)(wZe,{spoolmanMode:e?.spoolman_enabled===`true`&&!!e?.spoolman_url,spoolmanModeReady:t})}function wZe({spoolmanMode:e=!1,spoolmanModeReady:t=!0}){let{t:n}=W(),r=no(),{showToast:i}=Td(),{hasPermission:a,loading:o}=dd(),s=!o&&a(`inventory:forecast_read`),[c,l]=Mi(),[u,d]=(0,y.useState)(null),f=(0,y.useRef)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(!1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(`active`),[E,D]=(0,y.useState)(`all`),[O,k]=(0,y.useState)(``),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(``),[P,F]=(0,y.useState)(``),[I,L]=(0,y.useState)(`all`),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`table`),[ee,te]=(0,y.useState)(xZe),[ne,re]=(0,y.useState)(_Ze),[ie,H]=(0,y.useState)(!1),[ae,oe]=(0,y.useState)(()=>{try{return localStorage.getItem(`bambuddy-inventory-group`)===`true`}catch{return!1}}),[U,se]=(0,y.useState)(new Set),[ce,le]=(0,y.useState)(new Set),[ue,de]=(0,y.useState)(!1),[fe,pe]=(0,y.useState)(null),me=(0,y.useCallback)(e=>{le(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),he=(0,y.useCallback)(()=>le(new Set),[]);(0,y.useEffect)(()=>{le(new Set)},[w,E,O,A,M,P,I,R]);let[ge,_e]=(0,y.useState)(0),[ve,ye]=(0,y.useState)(()=>{try{let e=localStorage.getItem(`bambuddy-inventory-pageSize`);if(e){let t=Number(e);if([15,30,50,100,-1].includes(t))return t}}catch{}return 15}),{data:be}=q({queryKey:[`settings`],queryFn:Q.getSettings}),xe=be?.date_format||`system`,Se=e?[`spoolman-inventory-spools`]:[`inventory-spools`],Ce=()=>x9(r,Se),{data:we,isLoading:Te}=q({queryKey:Se,queryFn:()=>e?Q.getSpoolmanInventorySpools(!0):Q.getSpools(!0),refetchInterval:3e4}),Ee=(0,y.useCallback)(async()=>{x(!0);try{await Q.exportSpoolsCsv()}catch(e){i(e instanceof Error?e.message:n(`inventory.csv.exportError`,`Export failed`),`error`)}finally{x(!1)}},[i,n]),De=e?n(`inventory.csv.spoolmanHint`,`In Spoolman mode, use Spoolman's built-in CSV import/export.`):void 0,{data:Oe=[]}=q({queryKey:y9,queryFn:Q.getLocations}),ke=c.get(`location_id`),Ae=ke===`__none__`?`__none__`:ke&&/^\d+$/.test(ke)&&Number(ke)>0?ke:``,je=c.get(`spool`),Me=je&&/^\d+$/.test(je)&&Number(je)>0?Number(je):null,Ne=we?.find(e=>e.id===Me)??null,Pe=(0,y.useCallback)(()=>{f.current=!0,l(e=>(e.delete(`spool`),e),{replace:!0})},[l]),{data:Fe,isError:Ie,error:Le}=q({queryKey:e?[`spoolman-inventory-spool`,Me]:[`inventory-spool`,Me],queryFn:()=>e?Q.getSpoolmanInventorySpool(Me):Q.getSpool(Me),enabled:t&&Me!==null&&Ne===null,staleTime:1/0,retry:(e,t)=>e<2&&!(t instanceof Uu&&t.status===404)});(0,y.useEffect)(()=>{if(!f.current){if(t&&Me&&Ne){Pe(),d({spool:Ne,mode:`edit`});return}if(Fe){Pe(),d({spool:Fe,mode:`edit`});return}Ie&&(Pe(),i(n(Le instanceof Uu&&Le.status===404?`inventory.deepLinkSpoolNotFound`:`inventory.deepLinkFetchFailed`),`error`))}},[t,Me,Ne,Fe,Ie,Le,Pe,i,n]);let{data:Re}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),refetchInterval:3e4}),{data:ze=[],isError:Be}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:e,refetchInterval:3e4,staleTime:1e4,retry:1}),Ve=(0,y.useRef)(!1);(0,y.useEffect)(()=>{Be&&!Ve.current?(Ve.current=!0,i(n(`inventory.spoolmanUnreachable`),`error`)):Be||(Ve.current=!1)},[Be,i,n]);let{data:He}=q({queryKey:[`spool-catalog`],queryFn:()=>Q.getSpoolCatalog()}),Ue=J({mutationFn:t=>e?Q.deleteSpoolmanInventorySpool(t):Q.deleteSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolDeleted`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.deleteSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.deleteFailed`),`error`)}}),We=J({mutationFn:t=>e?Q.archiveSpoolmanInventorySpool(t):Q.archiveSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolArchived`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.archiveSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.archiveFailed`),`error`)}}),Ge=J({mutationFn:t=>e?Q.restoreSpoolmanInventorySpool(t):Q.restoreSpool(t),onSuccess:()=>{Ce(),i(n(`inventory.spoolRestored`),`success`)},onError:e=>{e instanceof Uu&&e.status===404?i(n(`inventory.restoreSpoolNotFound`),`error`):e instanceof Uu&&e.status===503?i(n(`inventory.spoolmanUnreachable`),`error`):i(n(`inventory.restoreFailed`),`error`)}}),Ke=J({mutationFn:t=>e?Q.resetSpoolmanInventorySpoolConsumedCounter(t):Q.resetSpoolConsumedCounter(t),onSuccess:()=>{r.invalidateQueries({queryKey:Se}),i(n(`inventory.consumedCounterReset`),`success`)},onError:()=>{i(n(`inventory.resetConsumedCounterFailed`),`error`)}}),qe=J({mutationFn:t=>e?Q.bulkResetSpoolmanInventorySpoolConsumedCounter(t):Q.bulkResetSpoolConsumedCounter(t),onSuccess:e=>{r.invalidateQueries({queryKey:Se}),i(n(`inventory.allConsumedCountersReset`,{count:e.reset}),`success`),pe(null),he()},onError:()=>{i(n(`inventory.resetConsumedCounterFailed`),`error`)}}),Je=e=>(e.not_found?.length??0)+(e.errors?.length??0),Ye=J({mutationFn:async({ids:t,update:n})=>e?Q.bulkUpdateSpoolmanInventorySpools(t,n):Q.bulkUpdateSpools(t,n),onSuccess:e=>{Ce();let t=Je(e);if(e.updated===0){i(n(`inventory.bulk.updateAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.updatePartial`,{ok:e.updated,failed:t}),`warning`):i(n(`inventory.bulk.updateSuccess`,{count:e.updated}),`success`),de(!1),he()},onError:e=>{i(e.message||n(`inventory.bulk.updateFailed`),`error`)}}),Xe=J({mutationFn:async t=>e?Q.bulkDeleteSpoolmanInventorySpools(t):Q.bulkDeleteSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.deleted===0){i(n(`inventory.bulk.deleteAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.deletePartial`,{ok:e.deleted,failed:t}),`warning`):i(n(`inventory.bulk.deleteSuccess`,{count:e.deleted}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.deleteFailed`),`error`)}}),Ze=J({mutationFn:async t=>e?Q.bulkArchiveSpoolmanInventorySpools(t):Q.bulkArchiveSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.archived===0&&t>0){i(n(`inventory.bulk.archiveAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.archivePartial`,{ok:e.archived,failed:t}),`warning`):i(n(`inventory.bulk.archiveSuccess`,{count:e.archived}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.archiveFailed`),`error`)}}),Qe=J({mutationFn:async t=>e?Q.bulkRestoreSpoolmanInventorySpools(t):Q.bulkRestoreSpools(t),onSuccess:e=>{Ce();let t=Je(e);if(e.restored===0&&t>0){i(n(`inventory.bulk.restoreAllFailed`,{count:t}),`error`);return}t>0?i(n(`inventory.bulk.restorePartial`,{ok:e.restored,failed:t}),`warning`):i(n(`inventory.bulk.restoreSuccess`,{count:e.restored}),`success`),pe(null),he()},onError:e=>{i(e.message||n(`inventory.bulk.restoreFailed`),`error`)}}),$e=(0,y.useMemo)(()=>(we??[]).map(e=>e.id),[we]),et=async t=>{if(t.last_scale_weight!=null)try{e?await Q.syncSpoolmanSpoolWeight(t.id,t.last_scale_weight):await od.updateSpoolWeight(t.id,t.last_scale_weight),r.invalidateQueries({queryKey:Se}),i(`Synced "${[t.brand,t.material,t.color_name].filter(Boolean).join(` `)}" to scale weight`,`success`)}catch(e){let t=e instanceof Uu&&e.status===404,r=e instanceof Uu&&e.status===503;i(n(t?`inventory.syncWeightSpoolNotFound`:r?`inventory.syncWeightSpoolmanUnreachable`:`inventory.syncWeightFailed`),`error`)}},tt=be?.low_stock_threshold??20,[nt,rt]=(0,y.useState)(!1),[it,at]=(0,y.useState)(tt.toString());(0,y.useEffect)(()=>{nt||at(tt.toString())},[tt,nt]);let ot=J({mutationFn:e=>Q.updateSettings({low_stock_threshold:e}),onSuccess:()=>{r.invalidateQueries({queryKey:[`settings`]}),i(n(`common.saved`),`success`),rt(!1)},onError:()=>{i(n(`inventory.lowStockThresholdError`),`error`)}}),st=(0,y.useMemo)(()=>{if(!we)return null;let e=0,t=0,n=0,r=0,i={};for(let a of we){if(t+=Math.max(0,a.weight_used-(a.weight_used_baseline??0)),a.archived_at)continue;r++;let o=Math.max(0,a.label_weight-a.weight_used);e+=o,(a.label_weight>0?o/a.label_weight*100:0)<(a.low_stock_threshold_pct??tt)&&n++;let s=a.material||`Unknown`;i[s]||(i[s]={count:0,weight:0}),i[s].count++,i[s].weight+=o}return{totalWeight:e,totalConsumed:t,lowStock:n,byMaterial:i,totalSpools:r}},[we,tt]),ct=(Re?.length??0)+(e?ze.length:0),lt=$d(be?.currency||`USD`),ut=(0,y.useMemo)(()=>{let e={};for(let t of Re||[])e[t.spool_id]={printer_id:t.printer_id,printer_name:t.printer_name,ams_id:t.ams_id,tray_id:t.tray_id,ams_label:t.ams_label??null};for(let t of ze)typeof t?.spoolman_spool_id!=`number`||t.spoolman_spool_id<=0||typeof t.printer_id!=`number`||typeof t.ams_id!=`number`||typeof t.tray_id!=`number`||e[t.spoolman_spool_id]||(e[t.spoolman_spool_id]={printer_id:t.printer_id,printer_name:t.printer_name??null,ams_id:t.ams_id,tray_id:t.tray_id,ams_label:t.ams_label??null});return e},[Re,ze]),dt=(0,y.useMemo)(()=>{let e={};for(let t of He||[])e[t.id]=t;return e},[He]),ft=(0,y.useMemo)(()=>st?Object.entries(st.byMaterial).sort((e,t)=>t[1].weight-e[1].weight).slice(0,4):[],[st]),pt=(0,y.useMemo)(()=>{let e=we||[];if(e=w===`active`?e.filter(e=>!e.archived_at):e.filter(e=>!!e.archived_at),E===`used`?e=e.filter(e=>e.weight_used>0):E===`new`?e=e.filter(e=>e.weight_used===0):E===`lowstock`&&(e=e.filter(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(e.label_weight>0?t/e.label_weight*100:0)<(e.low_stock_threshold_pct??tt)})),O&&(e=e.filter(e=>e.material===O)),A&&(e=e.filter(e=>e.brand===A)),M&&(e=M===`__none__`?e.filter(e=>!e.category):e.filter(e=>e.category===M)),P){let t=Number(P);e=e.filter(e=>e.core_weight_catalog_id===t)}if(Ae)if(Ae===`__none__`)e=e.filter(e=>!e.location_id&&!e.storage_location?.trim());else{let t=Number(Ae),n=Oe.find(e=>e.id===t)?.name?.trim().toLowerCase();e=e.filter(e=>e.location_id==null?n?(e.storage_location||``).trim().toLowerCase()===n:!1:e.location_id===t)}return I===`stock`?e=e.filter(e=>!e.slicer_filament):I===`configured`&&(e=e.filter(e=>!!e.slicer_filament)),R&&(e=hU(e,R)),e},[we,w,E,O,A,M,P,I,Ae,R,tt,Oe]),mt=()=>_e(0),ht=(0,y.useCallback)(e=>{l(t=>(t.delete(`location_id`),e&&t.set(`location_id`,e),t),{replace:!0}),mt()},[l]),gt=[...new Set(we?.map(e=>e.material)||[])].sort(),_t=[...new Set(we?.map(e=>e.brand).filter(Boolean)||[])].sort(),vt=[...new Set(we?.map(e=>e.category?.trim()).filter(Boolean)||[])].sort(),yt=(we??[]).some(e=>!e.category),bt=[...new Set(we?.map(e=>e.core_weight_catalog_id).filter(e=>e!=null)||[])].sort((e,t)=>{let n=(dt[e]?.name||``).toLowerCase(),r=(dt[t]?.name||``).toLowerCase();return n.localeCompare(r)}),xt=(we??[]).some(e=>!e.location_id&&!e.storage_location?.trim()),St=w!==`active`||E!==`all`||!!O||!!A||!!M||!!P||!!Ae||I!==`all`||!!R,Ct=e=>{re(e),vZe(e)},wt=(0,y.useMemo)(()=>ne.filter(e=>e.visible).map(e=>e.id),[ne]),Tt=e=>{j9[e]&&(te(t=>{let n;return n=t?.column===e?t.direction===`asc`?{column:e,direction:`desc`}:null:{column:e,direction:`asc`},SZe(n),n}),mt())},Et=(0,y.useMemo)(()=>{if(!ee)return pt;let e=j9[ee.column];return e?[...pt].sort((t,n)=>{let r=e(t,ut),i=e(n,ut);return ri?ee.direction===`asc`?1:-1:0}):pt},[pt,ee,ut]),Dt=(0,y.useMemo)(()=>{if(!ae)return Et.map(e=>({type:`single`,spool:e}));let e=new Map;for(let t of Et)if(!(t.weight_used>0||ut[t.id])){let n=hZe(t),r=e.get(n);r?r.push(t):e.set(n,[t])}let t=[],n=new Set;for(let r of Et){if(r.weight_used>0||ut[r.id]){t.push({type:`single`,spool:r});continue}let i=hZe(r);if(n.has(i))continue;n.add(i);let a=e.get(i);a.length===1?t.push({type:`single`,spool:a[0]}):t.push({type:`group`,key:i,spools:a,representative:a[0]})}return t},[Et,ae,ut]),Ot=ve===-1,kt=Dt.length,At=Ot?kt||1:ve,jt=Math.max(1,Math.ceil(kt/At)),Mt=Ot?0:Math.min(ge,jt-1),G=Ot?Dt:Dt.slice(Mt*At,(Mt+1)*At),Nt=()=>{let e=!ae;oe(e),se(new Set),mt();try{localStorage.setItem(`bambuddy-inventory-group`,String(e))}catch{}},Pt=e=>{se(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},Ft=e=>{ye(e),_e(0);try{localStorage.setItem(`bambuddy-inventory-pageSize`,String(e))}catch{}};return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(pl,{className:`w-7 h-7 text-bambu-green`}),n(`inventory.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:n(`inventory.subtitle`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)($,{variant:`secondary`,disabled:e,onClick:()=>v(!0),title:De,children:[(0,K.jsx)(Du,{className:`w-4 h-4`}),n(`inventory.csv.importButton`,`Import CSV`)]}),(0,K.jsxs)($,{variant:`secondary`,disabled:e||b,onClick:Ee,title:De,children:[b?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(Vs,{className:`w-4 h-4`}),n(`inventory.csv.exportButton`,`Export CSV`)]}),(0,K.jsxs)($,{variant:`secondary`,onClick:()=>C(!0),children:[(0,K.jsx)(Zc,{className:`w-4 h-4`}),n(`locations.manage`)]}),(0,K.jsxs)($,{variant:`secondary`,disabled:pt.length===0,onClick:()=>g(pt.map(e=>e.id)),title:pt.length===0?n(`inventory.labels.noSpoolsTitle`,`No spools to label`):n(`inventory.labels.bulkTitle`,`Pick spools to print labels for from the {{count}} currently shown`,{count:pt.length}),children:[(0,K.jsx)(Tl,{className:`w-4 h-4`}),n(`inventory.labels.printLabels`,`Print labels…`)]}),(0,K.jsxs)($,{onClick:()=>d({spool:null,mode:`create`}),children:[(0,K.jsx)(Sl,{className:`w-4 h-4`}),n(`inventory.addSpool`)]})]})]}),st&&!Te&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(pl,{className:`w-4 h-4 text-bambu-green`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.totalInventory`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:O9(st.totalWeight,!0)}),(0,K.jsxs)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:[st.totalSpools,` `,st.totalSpools===1?n(`inventory.spool`):n(`inventory.spools`)]})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(xu,{className:`w-4 h-4 text-blue-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.totalConsumed`)})]}),st.totalConsumed>0&&$e.length>0&&(0,K.jsx)(`button`,{onClick:()=>m({type:`reset-all-consumed-counters`}),className:`p-1 text-bambu-gray hover:text-red-400 rounded transition-colors`,title:n(`inventory.resetAllConsumedCountersTooltip`),"aria-label":n(`inventory.resetAllConsumedCounters`),children:(0,K.jsx)(qs,{className:`w-3.5 h-3.5`})})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:O9(st.totalConsumed,!0)}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:n(`inventory.sinceTracking`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Rc,{className:`w-4 h-4 text-green-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.byMaterial`)})]}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:ft.map(([e,t])=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${yZe[e]||`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[e,` `,(0,K.jsx)(`span`,{className:`opacity-70`,children:O9(t.weight,!0)})]},e))})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Tl,{className:`w-4 h-4 text-purple-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.inPrinter`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold text-white`,children:ct}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1`,children:n(`inventory.loadedInAms`)})]}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,K.jsx)(Cu,{className:`w-4 h-4 text-yellow-400`}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray font-medium uppercase tracking-wide`,children:n(`inventory.lowStock`)})]}),(0,K.jsx)(`div`,{className:`text-xl font-bold ${st.lowStock>0?`text-yellow-400`:`text-white`}`,children:st.lowStock}),(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray mt-1 flex items-center gap-2`,children:nt?(0,K.jsxs)(`form`,{onSubmit:e=>{e.preventDefault();let t=parseFloat(it);!isNaN(t)&&t>=.1&&t<=99.9?ot.mutate(t):i(n(`inventory.lowStockThresholdError`),`error`)},className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`<`}),(0,K.jsx)(`input`,{type:`text`,inputMode:`decimal`,pattern:`^\\d{0,2}(\\.\\d?)?$`,maxLength:4,value:it,onChange:e=>{let t=e.target.value.replace(/[^\d.]/g,``);/^\d{0,2}(\.\d?)?$/.test(t)&&at(t)},className:`px-1.5 py-1 rounded border border-bambu-dark-tertiary text-xs text-white bg-bambu-dark-secondary focus:outline-none focus:border-bambu-green w-14 text-center`,onWheel:e=>e.currentTarget.blur(),disabled:ot.isPending}),(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`%`}),(0,K.jsx)($,{type:`submit`,size:`sm`,disabled:ot.isPending,children:n(`common.save`)}),(0,K.jsx)($,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>rt(!1),disabled:ot.isPending,children:n(`common.cancel`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray`,children:[`< `,tt,`%`]}),(0,K.jsx)(`button`,{className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:n(`common.edit`),onClick:()=>{at(tt.toString()),rt(!0)},children:(0,K.jsx)(_l,{className:`w-4 h-4`})})]})})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1 max-w-md ${B===`forecast`?`invisible pointer-events-none`:``}`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,K.jsx)(`input`,{type:`text`,value:R,onChange:e=>{z(e.target.value),mt()},placeholder:n(`inventory.search`),className:`w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),R&&(0,K.jsx)(`button`,{onClick:()=>{z(``),mt()},className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B===`table`&&(0,K.jsxs)(`button`,{onClick:()=>H(!0),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,title:n(`inventory.configureColumns`),children:[(0,K.jsx)(As,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.columns`)})]}),B!==`forecast`&&(0,K.jsxs)(`button`,{onClick:Nt,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${ae?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,title:n(`inventory.groupSimilar`),children:[(0,K.jsx)(Sc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.groupSimilar`)})]}),(0,K.jsxs)(`div`,{className:`flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>V(`table`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${B===`table`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(du,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.table`)})]}),(0,K.jsxs)(`button`,{onClick:()=>V(`cards`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${B===`cards`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(zc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`inventory.cards`)})]}),(0,K.jsxs)(`button`,{onClick:()=>s&&V(`forecast`),disabled:!s,title:s?void 0:n(`forecast.noReadAccess`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${B===`forecast`?`bg-bambu-green text-white`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[s?(0,K.jsx)(Su,{className:`w-4 h-4`}):(0,K.jsx)(qc,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`hidden sm:inline`,children:n(`forecast.title`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${B===`forecast`?`hidden`:``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>{T(`active`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${w===`active`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(pl,{className:`w-3.5 h-3.5`}),n(`inventory.active`)]}),(0,K.jsxs)(`button`,{onClick:()=>{T(`archived`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${w===`archived`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5`}),n(`inventory.archived`)]})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>{D(`all`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${E===`all`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.all`)}),(0,K.jsxs)(`button`,{onClick:()=>{D(`used`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${E===`used`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Ss,{className:`w-3.5 h-3.5`}),n(`inventory.used`)]}),(0,K.jsx)(`button`,{onClick:()=>{D(`new`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${E===`new`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.new`)}),(0,K.jsxs)(`button`,{onClick:()=>{D(`lowstock`),mt()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${E===`lowstock`?`bg-yellow-500/20 text-yellow-400`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),n(`inventory.lowStock`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>{L(`all`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`all`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.all`)}),(0,K.jsx)(`button`,{onClick:()=>{L(`stock`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`stock`?`bg-amber-500/20 text-amber-400`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.stock`)}),(0,K.jsx)(`button`,{onClick:()=>{L(`configured`),mt()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${I===`configured`?`bg-bambu-green/20 text-bambu-green`:`text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:n(`inventory.configured`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`select`,{value:O,onChange:e=>{k(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${O?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.material`)}),gt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(0,K.jsxs)(`select`,{value:A,onChange:e=>{j(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${A?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.brand`)}),_t.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))]}),(vt.length>0||M)&&(0,K.jsxs)(`select`,{value:M,onChange:e=>{N(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${M?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.category`)}),vt.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),yt&&(0,K.jsx)(`option`,{value:`__none__`,children:n(`inventory.categoryNone`)})]}),bt.length>0&&(0,K.jsxs)(`select`,{value:P,onChange:e=>{F(e.target.value),mt()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${P?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.spoolName`)}),bt.map(e=>(0,K.jsx)(`option`,{value:e,children:dt[e]?.name||`#${e}`},e))]}),(Oe.length>0||Ae)&&(0,K.jsxs)(`select`,{value:Ae,onChange:e=>{ht(e.target.value)},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${Ae?`bg-bambu-green/20 text-bambu-green border-bambu-green/30`:`bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary`}`,children:[(0,K.jsx)(`option`,{value:``,children:n(`inventory.storageLocation`)}),Oe.map(e=>(0,K.jsx)(`option`,{value:String(e.id),children:e.name},e.id)),xt&&(0,K.jsx)(`option`,{value:`__none__`,children:n(`inventory.storageLocationNone`)})]}),St&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`w-px h-5 bg-bambu-dark-tertiary`}),(0,K.jsxs)(`button`,{onClick:()=>{T(`active`),D(`all`),k(``),j(``),N(``),F(``),L(`all`),z(``),l(e=>(e.delete(`location_id`),e),{replace:!0}),mt()},className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors`,children:[(0,K.jsx)(Ru,{className:`w-3.5 h-3.5`}),n(`inventory.clearFilters`)]})]}),B!==`forecast`&&(0,K.jsxs)(`span`,{className:`ml-auto text-xs text-bambu-gray`,children:[Et.length,` `,Et.length===1?n(`inventory.spool`):n(`inventory.spools`),ae&&kt0&&B!==`forecast`&&(0,K.jsxs)(`div`,{className:`sticky top-2 z-10 mb-4 flex items-center gap-2 px-3 py-2 bg-bambu-green/10 border border-bambu-green/30 rounded-lg backdrop-blur-sm`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-green font-medium`,children:n(`inventory.bulk.selectionCount`,{count:ce.size})}),(0,K.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>de(!0),children:[(0,K.jsx)(_l,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.edit`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>g([...ce]),children:[(0,K.jsx)(Tl,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.printLabels`)]}),(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`reset-consumed-counter`),children:[(0,K.jsx)(qs,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.resetUsage`)]}),w===`archived`?(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`restore`),children:[(0,K.jsx)(Al,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.restore`)]}):(0,K.jsxs)($,{size:`sm`,variant:`secondary`,onClick:()=>pe(`archive`),children:[(0,K.jsx)(Oo,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.archive`)]}),(0,K.jsxs)($,{size:`sm`,variant:`danger`,onClick:()=>pe(`delete`),children:[(0,K.jsx)(bu,{className:`w-3.5 h-3.5 mr-1.5`}),n(`inventory.bulk.delete`)]}),(0,K.jsx)(`button`,{className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,onClick:he,title:n(`inventory.bulk.clearSelection`),"aria-label":n(`inventory.bulk.clearSelection`),children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]})]}),Te?(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})}):B===`forecast`?(0,K.jsx)(RXe,{spools:we||[]}):B===`cards`?G.length>0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:G.map(e=>{if(e.type===`group`){let{key:t,spools:r,representative:i}=e,a=r.reduce((e,t)=>e+Math.max(0,t.label_weight-t.weight_used),0),o=U3({rgba:i.rgba,extraColors:i.extra_colors,effectType:i.effect_type,subtype:i.subtype,effectSize:`groupheader`}),s=U.has(t);return(0,K.jsxs)(`div`,{className:`col-span-full`,children:[(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer`,onClick:()=>Pt(t),children:[(0,K.jsx)(`div`,{className:`h-10 flex items-center px-4 gap-3`,style:o,children:(0,K.jsx)(`span`,{className:`bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium`,children:Kd(i.color_name,i.rgba)||`-`})}),(0,K.jsxs)(`div`,{className:`px-4 py-3 flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${s?``:`-rotate-90`}`}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-white`,children:[i.material,i.subtype?` ${i.subtype}`:``]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:i.brand||`-`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray`,title:n(`inventory.remaining`),children:O9(a)}),(0,K.jsx)(`span`,{className:`text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full`,children:n(`inventory.groupedSpools`,{count:r.length})})]})]})]}),s&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4`,children:r.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(0,K.jsx)(EZe,{spool:e,remaining:t,pct:e.label_weight>0?t/e.label_weight*100:0,onClick:()=>d({spool:e,mode:`edit`}),onPrintLabel:()=>g([e.id]),onCopy:()=>d({spool:e,mode:`copy`}),t:n},e.id)})})]},`group-${t}`)}let t=e.spool,r=Math.max(0,t.label_weight-t.weight_used);return(0,K.jsx)(EZe,{spool:t,remaining:r,pct:t.label_weight>0?r/t.label_weight*100:0,onClick:()=>d({spool:t,mode:`edit`}),onPrintLabel:()=>g([t.id]),onCopy:()=>d({spool:t,mode:`copy`}),t:n},t.id)})}),(0,K.jsx)(TZe,{pageIndex:Mt,pageSize:ve,totalRows:kt,totalPages:jt,onPageChange:_e,onPageSizeChange:Ft,t:n})]}):(0,K.jsx)(kZe,{hasFilters:St,onAddSpool:()=>d({spool:null,mode:`create`}),t:n}):G.length>0?(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`div`,{className:`overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30`,children:[(0,K.jsx)(`th`,{className:`w-10 px-3 py-3`,children:(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":n(`inventory.bulk.selectAllVisible`),checked:G.length>0&&G.every(e=>(e.type===`group`?e.spools.map(e=>e.id):[e.spool.id]).every(e=>ce.has(e))),onChange:e=>{if(e.target.checked){let e=new Set(ce);for(let t of G){let n=t.type===`group`?t.spools.map(e=>e.id):[t.spool.id];for(let t of n)e.add(t)}le(e)}else{let e=new Set(ce);for(let t of G){let n=t.type===`group`?t.spools.map(e=>e.id):[t.spool.id];for(let t of n)e.delete(t)}le(e)}}})}),wt.map(e=>{let t=!!j9[e],r=ee?.column===e;return(0,K.jsx)(`th`,{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${e===`remaining`?`min-w-[150px]`:``} ${t?`cursor-pointer hover:text-bambu-green transition-colors`:``} ${r?`text-bambu-green`:`text-bambu-gray`}`,onClick:t?()=>Tt(e):void 0,children:(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[bZe[e]?.(n)??e,t&&(r?ee.direction===`asc`?(0,K.jsx)(Io,{className:`w-3 h-3`}):(0,K.jsx)(Ao,{className:`w-3 h-3`}):(0,K.jsx)(Po,{className:`w-3 h-3 opacity-30`}))]})},e)}),(0,K.jsx)(`th`,{className:`text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide`,children:n(`common.actions`)})]})}),(0,K.jsx)(`tbody`,{children:G.map(e=>{if(e.type===`group`){let{key:t,spools:r}=e,i=U.has(t),a=mZe(r),o=Math.max(0,a.label_weight-a.weight_used);return(0,K.jsx)(OZe,{spools:r,headerSpool:a,remaining:o,pct:a.label_weight>0?o/a.label_weight*100:0,isExpanded:i,onToggle:()=>Pt(t),selectedIds:ce,onToggleSelected:me,onToggleGroupSelected:(e,t)=>{le(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r})},onEdit:e=>d({spool:e,mode:`edit`}),onCopy:e=>d({spool:e,mode:`copy`}),onArchive:e=>m({type:`archive`,spoolId:e}),onDelete:e=>m({type:`delete`,spoolId:e}),onPrintLabel:e=>g([e]),onResetConsumedCounter:e=>m({type:`reset-consumed-counter`,spoolId:e}),visibleColumns:wt,assignmentMap:ut,catalogMap:dt,currencySymbol:lt,dateFormat:xe,t:n,onSyncWeight:et},`group-${t}`)}let t=e.spool,r=Math.max(0,t.label_weight-t.weight_used);return(0,K.jsx)(DZe,{spool:t,remaining:r,pct:t.label_weight>0?r/t.label_weight*100:0,isSelected:ce.has(t.id),onToggleSelected:()=>me(t.id),onEdit:()=>d({spool:t,mode:`edit`}),onCopy:()=>d({spool:t,mode:`copy`}),onRestore:()=>Ge.mutate(t.id),onArchive:()=>m({type:`archive`,spoolId:t.id}),onDelete:()=>m({type:`delete`,spoolId:t.id}),onPrintLabel:()=>g([t.id]),onResetConsumedCounter:()=>m({type:`reset-consumed-counter`,spoolId:t.id}),visibleColumns:wt,assignmentMap:ut,catalogMap:dt,currencySymbol:lt,dateFormat:xe,t:n,onSyncWeight:et},t.id)})})]})}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:Ot?`${kt} ${n(kt===1?`inventory.spool`:`inventory.spools`)}`:(0,K.jsxs)(K.Fragment,{children:[n(`inventory.showing`),` `,Mt*At+1,` `,n(`inventory.to`),` `,Math.min((Mt+1)*At,kt),` `,n(`inventory.of`),` `,kt,` `,n(`inventory.spools`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:n(`inventory.show`)}),(0,K.jsxs)(`select`,{value:ve,onChange:e=>Ft(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[15,30,50,100].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:n(`inventory.all`)})]}),!Ot&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>_e(0),disabled:Mt===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,title:`First page`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>_e(e=>Math.max(0,e-1)),disabled:Mt===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[n(`inventory.page`),` `,Mt+1,` `,n(`inventory.of`),` `,jt]}),(0,K.jsx)(`button`,{onClick:()=>_e(e=>Math.min(jt-1,e+1)),disabled:Mt>=jt-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>_e(jt-1),disabled:Mt>=jt-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,title:`Last page`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})]}):(0,K.jsx)(kZe,{hasFilters:St,onAddSpool:()=>d({spool:null,mode:`create`}),t:n}),u!==null&&(0,K.jsx)(nZe,{isOpen:!0,onClose:()=>d(null),spool:u.spool,mode:u.mode,currencySymbol:lt,spoolmanMode:e,spoolsQueryKey:Se}),p&&(0,K.jsx)(Ad,{title:p.type===`delete`?n(`common.delete`):p.type===`archive`?n(`inventory.archive`):p.type===`reset-consumed-counter`?n(`inventory.resetConsumedCounter`):n(`inventory.resetAllConsumedCounters`),message:p.type===`delete`?n(`inventory.deleteConfirm`):p.type===`archive`?n(`inventory.archiveConfirm`):p.type===`reset-consumed-counter`?n(`inventory.resetConsumedCounterConfirm`):n(`inventory.resetAllConsumedCountersConfirm`,{count:$e.length}),confirmText:p.type===`delete`?n(`common.delete`):p.type===`archive`?n(`inventory.archive`):n(`inventory.resetConsumedCounter`),variant:p.type===`archive`?`warning`:`danger`,onConfirm:()=>{p.type===`delete`?Ue.mutate(p.spoolId):p.type===`archive`?We.mutate(p.spoolId):p.type===`reset-consumed-counter`?Ke.mutate(p.spoolId):qe.mutate($e),m(null)},onCancel:()=>m(null)}),(0,K.jsx)(rZe,{isOpen:ie,onClose:()=>H(!1),columns:ne,defaultColumns:D9,onSave:Ct}),(0,K.jsx)(lZe,{isOpen:h!==null,onClose:()=>g(null),availableSpools:pt,initialSelectedIds:h??[],spoolmanMode:e}),(0,K.jsx)(pZe,{isOpen:ue,selectedCount:ce.size,isPending:Ye.isPending,availableLocations:Oe.map(e=>({id:e.id,name:e.name})),availableMaterials:E9((we??[]).map(e=>e.material)),availableSubtypes:E9((we??[]).map(e=>e.subtype)),availableBrands:E9((we??[]).map(e=>e.brand)),availableCategories:E9((we??[]).map(e=>e.category)),availableSlicerFilaments:E9((we??[]).map(e=>e.slicer_filament)),availableSlicerFilamentNames:E9((we??[]).map(e=>e.slicer_filament_name)),onClose:()=>de(!1),onApply:e=>Ye.mutate({ids:[...ce],update:e})}),fe&&(0,K.jsx)(Ad,{title:n(fe===`delete`?`inventory.bulk.deleteTitle`:fe===`archive`?`inventory.bulk.archiveTitle`:fe===`restore`?`inventory.bulk.restoreTitle`:`inventory.bulk.resetUsageTitle`),message:n(fe===`delete`?`inventory.bulk.deleteMessage`:fe===`archive`?`inventory.bulk.archiveMessage`:fe===`restore`?`inventory.bulk.restoreMessage`:`inventory.bulk.resetUsageMessage`,{count:ce.size}),confirmText:n(fe===`delete`?`common.delete`:fe===`archive`?`inventory.archive`:fe===`restore`?`inventory.restore`:`inventory.resetConsumedCounter`),variant:fe===`delete`?`danger`:`warning`,isLoading:Xe.isPending||Ze.isPending||Qe.isPending||qe.isPending,onConfirm:()=>{let e=[...ce];fe===`delete`?Xe.mutate(e):fe===`archive`?Ze.mutate(e):fe===`restore`?Qe.mutate(e):qe.mutate(e)},onCancel:()=>pe(null)}),_&&(0,K.jsx)(uZe,{onClose:()=>v(!1),onImported:e=>{v(!1),r.invalidateQueries({queryKey:Se}),i(n(`inventory.csv.importSuccess`,`{{count}} spools imported`,{count:e}),`success`)}}),(0,K.jsx)(dZe,{open:S,onClose:()=>C(!1),onPickLocation:e=>ht(String(e))})]})}function TZe({pageIndex:e,pageSize:t,totalRows:n,totalPages:r,onPageChange:i,onPageSizeChange:a,t:o}){let s=t===-1;if(r<=1&&!s)return null;let c=s?n||1:t;return(0,K.jsxs)(`div`,{className:`flex items-center justify-between pt-2 text-sm`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:s?`${n} ${o(n===1?`inventory.spool`:`inventory.spools`)}`:(0,K.jsxs)(K.Fragment,{children:[o(`inventory.showing`),` `,e*c+1,` `,o(`inventory.to`),` `,Math.min((e+1)*c,n),` `,o(`inventory.of`),` `,n,` `,o(`inventory.spools`)]})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:o(`inventory.show`)}),(0,K.jsxs)(`select`,{value:t,onChange:e=>a(Number(e.target.value)),className:`px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green`,children:[[15,30,50,100].map(e=>(0,K.jsx)(`option`,{value:e,children:e},e)),(0,K.jsx)(`option`,{value:-1,children:o(`inventory.all`)})]}),!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{onClick:()=>i(0),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ls,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(Math.max(0,e-1)),disabled:e===0,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(ss,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-bambu-gray px-2 whitespace-nowrap`,children:[o(`inventory.page`),` `,e+1,` `,o(`inventory.of`),` `,r]}),(0,K.jsx)(`button`,{onClick:()=>i(Math.min(r-1,e+1)),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(as,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:()=>i(r-1),disabled:e>=r-1,className:`p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors`,children:(0,K.jsx)(us,{className:`w-4 h-4`})})]})]})]})}function EZe({spool:e,remaining:t,pct:n,onClick:r,onPrintLabel:i,onCopy:a,t:o}){let s=U3({rgba:e.rgba,extraColors:e.extra_colors,effectType:e.effect_type,subtype:e.subtype,effectSize:`card`});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${e.archived_at?`opacity-50`:``}`,onClick:r,children:[(0,K.jsxs)(`div`,{className:`h-14 flex items-center justify-center`,style:s,children:[(0,K.jsx)(`span`,{className:`bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium`,children:Kd(e.color_name,e.rgba)||`-`}),a&&(0,K.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:`p-1.5 bg-black/20 hover:bg-black/40 text-white rounded-full transition-colors`,title:o(`inventory.copySpool`),children:(0,K.jsx)(Ms,{className:`w-3.5 h-3.5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h3`,{className:`font-semibold text-white`,children:[e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e.brand||`-`})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i&&(0,K.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,title:o(`inventory.labels.printOne`),"aria-label":o(`inventory.labels.printOne`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[`#`,e.id]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-xs text-bambu-gray mb-1`,children:[(0,K.jsx)(`span`,{children:o(`inventory.remaining`)}),(0,K.jsxs)(`span`,{children:[Math.round(n),`%`]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${n>50?`bg-bambu-green`:n>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(n,100)}%`}})}),(0,K.jsxs)(`span`,{className:`text-xs text-bambu-gray min-w-[40px] text-right`,children:[Math.round(t),`g`]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[o(`inventory.labelWeight`),`: `]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:O9(e.label_weight)})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`span`,{className:`text-bambu-gray/60`,children:[o(`inventory.weightUsed`),`: `]}),(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e.weight_used>0?O9(e.weight_used):`-`})]})]}),e.note&&(0,K.jsx)(`div`,{className:`text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate`,title:e.note,children:e.note})]})]})}function DZe({spool:e,remaining:t,pct:n,isSelected:r,onToggleSelected:i,onEdit:a,onCopy:o,onRestore:s,onArchive:c,onDelete:l,onPrintLabel:u,onResetConsumedCounter:d,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v}){return(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${e.archived_at?`opacity-50`:``} ${r?`bg-bambu-green/10`:``}`,onClick:a,children:[(0,K.jsx)(`td`,{className:`w-10 px-3 py-3`,onClick:e=>e.stopPropagation(),children:i&&(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":_(`inventory.bulk.selectRow`),checked:!!r,onChange:i})}),f.map(r=>(0,K.jsx)(`td`,{className:`py-3 px-4`,children:A9[r]?.({spool:e,remaining:t,pct:n,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})},r)),(0,K.jsx)(`td`,{className:`py-3 px-4`,children:(0,K.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(`button`,{onClick:a,className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:_(`common.edit`),children:(0,K.jsx)(_l,{className:`w-4 h-4`})}),o&&(0,K.jsx)(`button`,{onClick:o,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:_(`inventory.copySpool`),children:(0,K.jsx)(Ms,{className:`w-4 h-4`})}),u&&(0,K.jsx)(`button`,{onClick:u,className:`p-1.5 text-bambu-gray hover:text-white rounded transition-colors`,title:_(`inventory.labels.printOne`),children:(0,K.jsx)(Tl,{className:`w-4 h-4`})}),d&&e.weight_used>0&&(0,K.jsx)(`button`,{onClick:d,className:`p-1.5 text-bambu-gray hover:text-orange-400 rounded transition-colors`,title:_(`inventory.resetConsumedCounterTooltip`),children:(0,K.jsx)(qs,{className:`w-4 h-4`})}),e.archived_at?(0,K.jsx)(`button`,{onClick:s,className:`p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors`,title:_(`inventory.restore`),children:(0,K.jsx)(Al,{className:`w-4 h-4`})}):(0,K.jsx)(`button`,{onClick:c,className:`p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors`,title:_(`inventory.archive`),children:(0,K.jsx)(Oo,{className:`w-4 h-4`})}),(0,K.jsx)(`button`,{onClick:l,className:`p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors`,title:_(`common.delete`),children:(0,K.jsx)(bu,{className:`w-4 h-4`})})]})})]})}function OZe({spools:e,headerSpool:t,remaining:n,pct:r,isExpanded:i,onToggle:a,onEdit:o,onCopy:s,onArchive:c,onDelete:l,onPrintLabel:u,onResetConsumedCounter:d,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v,selectedIds:y,onToggleSelected:b,onToggleGroupSelected:x}){let S=!!y&&e.every(e=>y.has(e.id));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`tr`,{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5`,onClick:a,children:[(0,K.jsx)(`td`,{className:`w-10 px-3 py-3`,onClick:e=>e.stopPropagation(),children:x&&(0,K.jsx)(`input`,{type:`checkbox`,className:`h-4 w-4 cursor-pointer`,"aria-label":_(`inventory.bulk.selectGroup`),checked:S,onChange:t=>x(e.map(e=>e.id),t.target.checked)})}),f.map((a,o)=>(0,K.jsx)(`td`,{className:`py-3 px-4`,children:o===0?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(is,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?``:`-rotate-90`}`}),A9[a]?.({spool:t,remaining:n,pct:r,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})]}):a===`id`?(0,K.jsx)(`span`,{className:`text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full`,children:_(`inventory.groupedSpools`,{count:e.length})}):A9[a]?.({spool:t,remaining:n,pct:r,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v})},a)),(0,K.jsx)(`td`,{className:`py-3 px-4`,children:(0,K.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:e.map(e=>`#${e.id}`).join(`, `)})})]}),i&&e.map(e=>{let t=Math.max(0,e.label_weight-e.weight_used);return(0,K.jsx)(DZe,{spool:e,remaining:t,pct:e.label_weight>0?t/e.label_weight*100:0,isSelected:y?.has(e.id),onToggleSelected:b?()=>b(e.id):void 0,onEdit:()=>o(e),onCopy:s?()=>s(e):void 0,onRestore:()=>{},onArchive:()=>c(e.id),onDelete:()=>l(e.id),onPrintLabel:u?()=>u(e.id):void 0,onResetConsumedCounter:d?()=>d(e.id):void 0,visibleColumns:f,assignmentMap:p,catalogMap:m,currencySymbol:h,dateFormat:g,t:_,onSyncWeight:v},e.id)})]})}function kZe({hasFilters:e,onAddSpool:t,t:n}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 px-4`,children:[(0,K.jsxs)(`div`,{className:`relative mb-6`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl`}),(0,K.jsxs)(`div`,{className:`relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsx)(`div`,{className:`absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30`}),(0,K.jsx)(`div`,{className:`absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20`}),e?(0,K.jsx)(Rl,{className:`w-10 h-10 text-bambu-gray/40`,strokeWidth:1.5}):(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20`})}),(0,K.jsx)(`div`,{className:`absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md`,children:(0,K.jsx)(`span`,{className:`text-white text-lg font-bold leading-none`,children:`+`})})]})]})]}),(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2 text-center`,children:e?n(`inventory.noSpoolsMatch`):n(`inventory.noSpools`).split(`.`)[0]}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray text-center max-w-sm mb-6`,children:n(e?`inventory.noSpoolsMatchDesc`:`inventory.noSpools`)}),!e&&(0,K.jsxs)($,{onClick:t,children:[(0,K.jsx)(pl,{className:`w-4 h-4`}),n(`inventory.addSpool`)]})]})}function N9(e,t){let n=e?.[t];return typeof n==`string`?n:``}function AZe(e){return e.replace(/(https?:\/\/(?:makerworld|public-cdn)\.bblmw\.com\/[^\s"']+)/gi,e=>`/api/v1/makerworld/thumbnail?url=${encodeURIComponent(e)}`)}function P9(e){return e?/^https?:\/\/(makerworld|public-cdn)\.bblmw\.com\//i.test(e)?`/api/v1/makerworld/thumbnail?url=${encodeURIComponent(e)}`:e:``}function F9(e,t){let n=e?.[t];return typeof n==`number`?n:null}function jZe(e,t){let n=e?.[t];return n&&typeof n==`object`&&!Array.isArray(n)?n:void 0}function MZe(e,t=0,n=[]){n.push({folder:e,depth:t});for(let r of e.children??[])MZe(r,t+1,n);return n}function NZe(e,t){return t(e<1?`makerworld.phaseResolving`:`makerworld.phaseDownloading`)}function PZe(e){let[t,n]=(0,y.useState)(0);return(0,y.useEffect)(()=>{if(!e){n(0);return}let t=Date.now(),r=()=>n(Math.floor((Date.now()-t)/1e3));r();let i=window.setInterval(r,1e3);return()=>window.clearInterval(i)},[e]),t}function FZe(){let{t:e}=W(),{hasPermission:t}=dd(),{showToast:n}=Td(),r=no(),i=t(`makerworld:import`),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(``),[b,x]=(0,y.useState)({}),S=q({queryKey:[`makerworld-status`],queryFn:()=>Q.getMakerworldStatus()}),C=q({queryKey:[`library-folders`],queryFn:()=>Q.getLibraryFolders()}),w=q({queryKey:[`makerworld-recent-imports`],queryFn:()=>Q.getMakerworldRecentImports(10)}),T=q({queryKey:[`settings`],queryFn:()=>Q.getSettings()}),E=T.data?.use_slicer_api??!1,D=T.data?.preferred_slicer||`bambu_studio`,O=T.data?.open_in_slicer||D,k=E?D:O,A=k===`orcaslicer`?`OrcaSlicer`:`Bambu Studio`,[j,M]=(0,y.useState)(null),N=(e,t)=>{M({kind:`libraryFile`,id:e,filename:t})},P=J({mutationFn:e=>Q.resolveMakerworldUrl(e),onSuccess:(e,t)=>{c(e),v(t),x({})},onError:t=>n(t.message||e(`makerworld.errors.resolveFailed`),`error`)});(0,y.useEffect)(()=>{s!==null&&a.trim()!==_.trim()&&(c(null),v(``),x({}))},[a,s,_]);let F=J({mutationFn:({instanceId:e,profileId:t})=>Q.importMakerworldInstance(s?.model_id??0,e,t,l),onSuccess:t=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),t.profile_id&&x(e=>({...e,[t.profile_id]:t})),n(t.was_existing?e(`makerworld.alreadyInLibrary`):e(`makerworld.importSuccess`,{filename:t.filename}),`success`)},onError:t=>n(t.message||e(`makerworld.errors.downloadFailed`),`error`)}),I=J({mutationFn:({libraryFileId:e})=>Q.deleteLibraryFile(e),onSuccess:(t,{profileId:i})=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),r.invalidateQueries({queryKey:[`makerworld-recent-imports`]}),x(e=>{let t={...e};return delete t[i],t}),m(null),n(e(`makerworld.importDeleted`),`success`)},onError:t=>{m(null),n(t.message||e(`makerworld.errors.deleteFailed`),`error`)}}),L=J({mutationFn:({instanceId:e,profileId:t})=>Q.importMakerworldInstance(s?.model_id??0,e,t,l),onSuccess:async e=>{r.invalidateQueries({queryKey:[`library-files`]}),r.invalidateQueries({queryKey:[`library-folders`]}),r.invalidateQueries({queryKey:[`makerworld-recent-imports`]}),e.profile_id&&x(t=>({...t,[e.profile_id]:e})),E?N(e.library_file_id,e.filename):await te(e.library_file_id,e.filename,k)},onError:t=>n(t.message||e(`makerworld.errors.downloadFailed`),`error`)}),R=PZe(F.isPending||L.isPending),z=NZe(R,e),B=e=>{e?.preventDefault();let t=a.trim();t&&P.mutate(t)};(0,y.useEffect)(()=>{if(!h)return;let e=e=>{e.key===`Escape`?g(null):e.key===`ArrowLeft`?g(e=>e&&e.index>0?{...e,index:e.index-1}:e):e.key===`ArrowRight`&&g(e=>e&&e.indexwindow.removeEventListener(`keydown`,e)},[h]);let V=e=>{let t=(Array.isArray(e.pictures)?e.pictures:[]).filter(e=>typeof e==`object`&&!!e).map(e=>({name:N9(e,`name`)||`image`,url:N9(e,`url`)})).filter(e=>e.url);if(t.length>0)return t;let n=N9(e,`cover`);return n?[{name:`cover`,url:n}]:[]},ee=async()=>{if(!s)return;let e=s.instances.filter(e=>{let t=F9(e,`profileId`);return t!==null&&!b[t]});if(e.length!==0){f({current:0,total:e.length});try{for(let t=0;t{try{let{token:r}=await Q.createLibrarySlicerToken(e),i=Q.getLibrarySlicerDownloadUrl(e,r,t);HW(`${window.location.origin}${i}`,n)}catch{let t=Q.getLibraryFileDownloadUrl(e);HW(`${window.location.origin}${t}`,n)}},ne=s?.design,re=jZe(ne,`designCreator`),ie=s?.instances??[],H=(s?.already_imported_library_ids.length??0)>0,ae=S.data?.has_cloud_token??!1,oe=S.data?.can_download??!1,U=(0,y.useMemo)(()=>N9(ne,`coverUrl`),[ne]),se=N9(ne,`title`),ce=N9(ne,`summary`),le=N9(ne,`license`),ue=F9(ne,`downloadCount`);return(0,K.jsxs)(`div`,{className:`p-4 md:p-8 max-w-screen-2xl space-y-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,K.jsx)(bc,{className:`w-7 h-7 text-bambu-green`}),e(`makerworld.title`)]}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`makerworld.description`)})]}),(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[1fr_20rem]`,children:[(0,K.jsxs)(`div`,{className:`space-y-6 min-w-0`,children:[!ae&&(0,K.jsx)(_d,{className:`border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20`,children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3 py-2`,children:[(0,K.jsx)(ds,{className:`w-5 h-5 text-amber-600 dark:text-amber-400 mt-0.5 shrink-0`}),(0,K.jsxs)(`div`,{className:`text-sm`,children:[(0,K.jsx)(`p`,{className:`font-medium text-amber-900 dark:text-amber-100`,children:e(`makerworld.signInRequiredTitle`)}),(0,K.jsxs)(`p`,{className:`text-amber-800 dark:text-amber-200 mt-1`,children:[e(`makerworld.signInRequiredBody`),` `,(0,K.jsx)(wi,{to:`/profiles`,className:`underline`,children:e(`makerworld.openCloudSettings`)})]})]})]})})}),(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`makerworld.pasteUrlHeader`)})}),(0,K.jsx)(yd,{children:(0,K.jsxs)(`form`,{onSubmit:B,className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:e(`makerworld.pasteUrlPlaceholder`),className:`flex-1 min-w-0 px-3 py-2 border rounded bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700`,autoComplete:`off`}),(0,K.jsxs)($,{type:`submit`,variant:`primary`,disabled:!a.trim()||P.isPending,children:[P.isPending?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}):(0,K.jsx)(No,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.resolveButton`)})]})]})})]}),s&&(0,K.jsx)(_d,{children:(0,K.jsx)(yd,{children:(0,K.jsxs)(`div`,{className:`flex gap-4 py-2`,children:[U&&(0,K.jsx)(`img`,{src:P9(U),alt:se,className:`w-32 h-32 object-cover rounded`,loading:`lazy`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`h3`,{className:`text-xl font-semibold truncate`,children:se||e(`makerworld.untitledModel`)}),re&&(0,K.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-1`,children:e(`makerworld.byCreator`,{name:N9(re,`name`)})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 mt-2 text-xs text-gray-500 dark:text-gray-400`,children:[ue!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.downloadsCount`,{count:ue})}),le&&(0,K.jsxs)(`span`,{children:[e(`makerworld.licensePrefix`),`: `,le]}),H&&(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-600 dark:text-emerald-400`,children:[(0,K.jsx)(rs,{className:`w-3 h-3`}),` `,e(`makerworld.alreadyImported`)]})]}),ce&&(0,K.jsx)(`div`,{className:`mt-3 text-sm prose prose-sm max-w-none dark:prose-invert line-clamp-3`,dangerouslySetInnerHTML:{__html:HG.sanitize(AZe(ce))}}),s&&(0,K.jsxs)(`a`,{href:`https://makerworld.com/models/${s.model_id}${s.profile_id?`#profileId-${s.profile_id}`:``}`,target:`_blank`,rel:`noopener noreferrer`,className:`mt-3 inline-flex items-center gap-1 text-xs text-brand-500 hover:underline`,children:[(0,K.jsx)(Js,{className:`w-3 h-3`}),` `,e(`makerworld.openOnMakerworld`)]})]})]})})}),s&&ie.length>0&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`makerworld.platesHeader`,{count:ie.length})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`label`,{className:`text-xs text-gray-600 dark:text-gray-400`,children:e(`makerworld.importTo`)}),(0,K.jsxs)(`select`,{value:l??``,onChange:e=>u(e.target.value?Number(e.target.value):null),className:`text-sm px-2 py-1 border rounded bg-white dark:bg-gray-800 border-gray-300 dark:border-gray-700`,disabled:d!==null,children:[(0,K.jsx)(`option`,{value:``,children:e(`makerworld.folderAuto`)}),(C.data??[]).filter(e=>!(e.is_external&&e.external_readonly)).flatMap(e=>MZe(e)).map(({folder:e,depth:t})=>(0,K.jsx)(`option`,{value:e.id,children:`${`— `.repeat(t)}${e.name}`},e.id))]}),(0,K.jsx)($,{variant:`primary`,size:`sm`,disabled:!i||!oe||d!==null||F.isPending||L.isPending,onClick:ee,children:d===null?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.importAll`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[e(`makerworld.importAllProgress`,{current:d.current,total:d.total}),R>0&&` · ${z} · ${R}s`]})]})})]})]})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`grid gap-3`,children:ie.map((t,n)=>{let r=F9(t,`id`),a=F9(t,`profileId`),o=N9(t,`title`),s=N9(t,`cover`),c=F9(t,`materialCnt`),l=t?.needAms===!0,u=F9(t,`downloadCount`),f=t?.compatibility??null,p=t?.otherCompatibility??null,h=f?.devProductName??null,_=Array.isArray(p)?p.map(e=>e?.devProductName??``).filter(Boolean):[];if(r==null)return null;let v=F.isPending&&F.variables?.instanceId===r,y=L.isPending&&L.variables?.instanceId===r,x=a===null?void 0:b[a];return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-3 border rounded border-gray-200 dark:border-gray-700`,children:[(0,K.jsxs)(`div`,{className:`flex gap-3 items-center`,children:[(()=>{let n=V(t),r=n.length>0;return(0,K.jsxs)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&g({images:n,index:0}),className:`relative w-16 h-16 shrink-0 rounded overflow-hidden group`,"aria-label":e(`makerworld.openGallery`),children:[s?(0,K.jsx)(`img`,{src:P9(s),alt:``,className:`w-16 h-16 object-cover`,loading:`lazy`}):(0,K.jsx)(`div`,{className:`w-16 h-16 bg-gray-100 dark:bg-gray-800`}),n.length>1&&(0,K.jsxs)(`span`,{className:`absolute bottom-0.5 right-0.5 bg-black/70 text-white text-[10px] px-1.5 py-0.5 rounded flex items-center gap-1`,children:[(0,K.jsx)(Nc,{className:`w-2.5 h-2.5`}),n.length]})]})})(),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`font-medium truncate`,children:o||e(`makerworld.plateDefaultName`,{n:n+1})}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-3 text-xs text-gray-500 dark:text-gray-400 mt-1`,children:[h&&(0,K.jsx)(`span`,{className:`font-medium text-gray-700 dark:text-gray-300`,children:e(`makerworld.slicedFor`,{printer:h,defaultValue:`Sliced for {{printer}}`})}),c!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.materialCount`,{count:c})}),l&&(0,K.jsx)(`span`,{children:e(`makerworld.amsRequired`)}),u!==null&&(0,K.jsx)(`span`,{children:e(`makerworld.downloadsCount`,{count:u})})]}),_.length>0&&(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,title:_.join(`, `),children:e(`makerworld.alsoCompatible`,{printers:_.slice(0,6).join(`, `)+(_.length>6?`…`:``),defaultValue:`Also marked compatible: {{printers}}`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,disabled:!i||!oe||v||y||d!==null,onClick:()=>F.mutate({instanceId:r,profileId:a}),title:oe?void 0:e(`makerworld.signInRequiredTitle`),children:v?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[z,R>0&&` · ${R}s`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vs,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.importToLibrary`)})]})}),(0,K.jsx)($,{variant:`primary`,size:`sm`,disabled:!i||!oe||v||y||d!==null,onClick:()=>L.mutate({instanceId:r,profileId:a}),title:oe?void 0:e(`makerworld.signInRequiredTitle`),children:y?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),(0,K.jsxs)(`span`,{className:`ml-2`,children:[z,R>0&&` · ${R}s`]})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Js,{className:`w-4 h-4`}),(0,K.jsx)(`span`,{className:`ml-2`,children:e(`makerworld.sliceIn`,{slicer:A})})]})})]})]}),x&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 pl-20 text-xs`,children:[(0,K.jsx)(rs,{className:`w-3.5 h-3.5 text-emerald-600 dark:text-emerald-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-300`,children:x.was_existing?e(`makerworld.lastImportAlreadyInLibrary`):e(`makerworld.lastImportSuccess`)}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>{let e=x.folder_id?`/files?folder=${x.folder_id}`:`/files`;window.location.assign(e)},children:[(0,K.jsx)(cc,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.viewInLibrary`)})]}),E?(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>N(x.library_file_id,x.filename),children:[(0,K.jsx)(ks,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`slice.action`,`Slice`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>te(x.library_file_id,x.filename,`bambu_studio`),children:[(0,K.jsx)(Js,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.openInBambuStudio`)})]}),(0,K.jsxs)($,{variant:`ghost`,size:`sm`,onClick:()=>te(x.library_file_id,x.filename,`orcaslicer`),children:[(0,K.jsx)(Js,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`span`,{className:`ml-1.5`,children:e(`makerworld.openInOrcaSlicer`)})]})]}),(0,K.jsx)(`div`,{className:`ml-auto`,children:(0,K.jsx)($,{variant:`ghost`,size:`sm`,disabled:I.isPending&&I.variables?.profileId===a,onClick:()=>{a!==null&&m({libraryFileId:x.library_file_id,profileId:a,filename:x.filename})},title:e(`makerworld.deleteImport`),children:I.isPending&&I.variables?.profileId===a?(0,K.jsx)(X,{className:`w-3.5 h-3.5 animate-spin`}):(0,K.jsx)(bu,{className:`w-3.5 h-3.5 text-red-500`})})})]})]},r)})})})]})]}),(0,K.jsx)(`aside`,{className:`lg:sticky lg:top-6 lg:self-start min-w-0`,children:w.data&&w.data.length>0&&(0,K.jsxs)(_d,{children:[(0,K.jsx)(vd,{children:(0,K.jsx)(`h2`,{className:`text-base font-semibold`,children:e(`makerworld.recentImportsHeader`)})}),(0,K.jsx)(yd,{children:(0,K.jsx)(`div`,{className:`flex flex-col gap-2 max-h-[28rem] overflow-y-auto -mx-2 px-2`,children:w.data.map(t=>(0,K.jsxs)(`div`,{className:`flex gap-2 p-2 border rounded border-gray-200 dark:border-gray-700`,children:[t.thumbnail_path?(0,K.jsx)(`img`,{src:Q.getLibraryFileThumbnailUrl(t.library_file_id),alt:``,className:`w-12 h-12 shrink-0 object-cover rounded bg-gray-100 dark:bg-gray-800`,loading:`lazy`}):(0,K.jsx)(`div`,{className:`w-12 h-12 shrink-0 rounded bg-gray-100 dark:bg-gray-800`}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 flex flex-col gap-1`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium truncate`,title:t.filename,children:t.filename}),(0,K.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{let e=t.folder_id?`/files?folder=${t.folder_id}`:`/files`;window.location.assign(e)},title:e(`makerworld.viewInLibrary`),children:(0,K.jsx)(cc,{className:`w-3.5 h-3.5`})}),E?(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>N(t.library_file_id,t.filename),title:e(`slice.action`,`Slice`),children:(0,K.jsx)(ks,{className:`w-3.5 h-3.5`})}):(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>te(t.library_file_id,t.filename,`bambu_studio`),title:e(`makerworld.openInBambuStudio`),children:(0,K.jsx)(Js,{className:`w-3.5 h-3.5`})}),t.source_url&&(0,K.jsx)(`a`,{href:t.source_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center justify-center h-7 w-7 rounded text-gray-500 hover:text-gray-700 dark:hover:text-gray-300`,title:e(`makerworld.openOnMakerworld`),children:(0,K.jsx)(bc,{className:`w-3.5 h-3.5`})})]})]})]},t.library_file_id))})})]})})]}),(0,K.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 pt-4 border-t border-gray-200 dark:border-gray-700`,children:e(`makerworld.disclaimer`)}),p&&(0,K.jsx)(Ad,{title:e(`makerworld.deleteImport`),message:e(`makerworld.confirmDelete`,{filename:p.filename}),confirmText:e(`makerworld.deleteImport`),variant:`danger`,isLoading:I.isPending,loadingText:e(`makerworld.importDeleting`),onCancel:()=>m(null),onConfirm:()=>I.mutate({libraryFileId:p.libraryFileId,profileId:p.profileId})}),j&&(0,K.jsx)(zW,{source:j,onClose:()=>M(null)}),h&&(0,K.jsxs)(`div`,{className:`fixed inset-0 bg-black/90 flex items-center justify-center z-50`,onClick:()=>g(null),role:`dialog`,"aria-modal":`true`,children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute top-4 right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white`,onClick:e=>{e.stopPropagation(),g(null)},"aria-label":e(`common.close`,`Close`),children:(0,K.jsx)(Ru,{className:`w-5 h-5`})}),h.images.length>1&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,className:`absolute left-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white disabled:opacity-30`,disabled:h.index===0,onClick:e=>{e.stopPropagation(),g(e=>e&&{...e,index:Math.max(0,e.index-1)})},"aria-label":e(`makerworld.galleryPrev`),children:(0,K.jsx)(ss,{className:`w-6 h-6`})}),(0,K.jsx)(`button`,{type:`button`,className:`absolute right-4 p-2 bg-white/10 hover:bg-white/20 rounded-full text-white disabled:opacity-30`,disabled:h.index>=h.images.length-1,onClick:e=>{e.stopPropagation(),g(e=>e&&{...e,index:Math.min(e.images.length-1,e.index+1)})},"aria-label":e(`makerworld.galleryNext`),children:(0,K.jsx)(as,{className:`w-6 h-6`})})]}),(0,K.jsx)(`img`,{src:P9(h.images[h.index].url),alt:h.images[h.index].name,className:`max-w-[90vw] max-h-[90vh] object-contain`,onClick:e=>e.stopPropagation()}),h.images.length>1&&(0,K.jsxs)(`div`,{className:`absolute bottom-6 left-1/2 -translate-x-1/2 text-white bg-black/60 px-3 py-1 rounded text-xs`,children:[h.index+1,` / `,h.images.length]})]})]})}var IZe=[`DEBUG`,`INFO`,`WARNING`,`ERROR`],I9={DEBUG:`text-gray-400`,INFO:`text-blue-400`,WARNING:`text-yellow-400`,ERROR:`text-red-400`},LZe={DEBUG:Ko,INFO:Pc,WARNING:Cu,ERROR:ds};function RZe(){let e=no(),[t,n]=(0,y.useState)(!0),[r,i]=(0,y.useState)(new Set),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`ALL`),[l,u]=(0,y.useState)(!1),[d,f]=(0,y.useState)(!1),p=(0,y.useRef)(null),{data:m,isLoading:h,refetch:g}=q({queryKey:[`application-logs`,s,a],queryFn:()=>ad.getLogs({limit:200,level:s===`ALL`?void 0:s,search:a||void 0}),refetchInterval:d?2e3:!1,enabled:l});(0,y.useEffect)(()=>{l||f(!1)},[l]);let _=J({mutationFn:()=>ad.clearLogs(),onSuccess:()=>{e.invalidateQueries({queryKey:[`application-logs`]})}});(0,y.useEffect)(()=>{t&&p.current&&m?.entries&&(p.current.scrollTop=p.current.scrollHeight)},[m?.entries,t]);let v=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},b=e=>{let t=e.split(` `);return t.length>=2?t[1]:e},x=(0,y.useMemo)(()=>m?.entries??[],[m?.entries]),S=(0,y.useMemo)(()=>[...x].reverse(),[x]),C=({level:e})=>(0,K.jsx)(LZe[e]||Pc,{className:`w-3.5 h-3.5 ${I9[e]||`text-gray-400`}`});return(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg overflow-hidden`,children:[(0,K.jsxs)(`button`,{onClick:()=>u(!l),className:`w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${d?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:(0,K.jsx)(Ko,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{className:`text-left`,children:[(0,K.jsx)(`p`,{className:`font-medium text-white`,children:`Application Logs`}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:d?`Live streaming - ${m?.filtered_count??0} entries`:`View and filter application logs`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d&&(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs`,children:[(0,K.jsx)(`span`,{className:`w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse`}),`Live`]}),l?(0,K.jsx)(cs,{className:`w-5 h-5 text-bambu-gray`}):(0,K.jsx)(is,{className:`w-5 h-5 text-bambu-gray`})]})]}),l&&(0,K.jsxs)(`div`,{className:`border-t border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[d?(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(!1)},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors`,children:[(0,K.jsx)(ou,{className:`w-4 h-4`}),`Stop`]}):(0,K.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),f(!0),g()},className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors`,children:[(0,K.jsx)(bl,{className:`w-4 h-4`}),`Start`]}),(0,K.jsxs)(`button`,{onClick:()=>_.mutate(),disabled:_.isPending||x.length===0,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50`,children:[(0,K.jsx)(bu,{className:`w-4 h-4`}),`Clear`]}),(0,K.jsx)(`button`,{onClick:()=>g(),disabled:h,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50`,children:(0,K.jsx)(Ol,{className:`w-4 h-4 ${h?`animate-spin`:``}`})}),(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary`}),`Auto-scroll`]}),(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[m?.filtered_count??0,`/`,m?.total_in_file??0]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`div`,{className:`relative flex-1`,children:[(0,K.jsx)(Rl,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,K.jsx)(`input`,{type:`text`,placeholder:`Search message or logger name...`,value:a,onChange:e=>o(e.target.value),className:`w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),a&&(0,K.jsx)(`button`,{onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{onClick:()=>c(`ALL`),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${s===`ALL`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:`All`}),IZe.map((e,t)=>(0,K.jsx)(`button`,{onClick:()=>c(e),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${t===IZe.length-1?`rounded-r`:``} ${s===e?`${I9[e]} bg-bambu-dark-tertiary`:`text-bambu-gray hover:text-white`}`,children:e},e))]})]})]}),(0,K.jsx)(`div`,{ref:p,className:`overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]`,children:x.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[300px] text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`mb-2`,children:`No log entries found`}),(0,K.jsx)(`p`,{className:`text-sm`,children:`Log file may be empty or cleared`})]}):(0,K.jsx)(`div`,{className:`divide-y divide-bambu-dark-tertiary/30`,children:S.map((e,t)=>{let n=r.has(t),i=e.message.includes(` `);return(0,K.jsx)(`div`,{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${n?`bg-bambu-dark-secondary/30`:``}`,onClick:()=>i&&v(t),children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray/70 shrink-0 w-20`,children:b(e.timestamp)}),(0,K.jsx)(`span`,{className:`shrink-0`,children:(0,K.jsx)(C,{level:e.level})}),(0,K.jsxs)(`span`,{className:`text-purple-400/80 shrink-0 max-w-[200px] truncate`,title:e.logger_name,children:[`[`,e.logger_name,`]`]}),(0,K.jsx)(`span`,{className:`flex-1 ${I9[e.level]||`text-white/80`} ${!n&&i?`truncate`:``}`,children:n?(0,K.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:e.message}):e.message.split(` `)[0]}),i&&(0,K.jsx)(`span`,{className:`text-bambu-gray/50 shrink-0`,children:n?(0,K.jsx)(cs,{className:`w-3.5 h-3.5`}):(0,K.jsx)(is,{className:`w-3.5 h-3.5`})})]})},t)})})}),(0,K.jsx)(`div`,{className:`flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray`,children:d?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`w-2 h-2 bg-green-500 rounded-full animate-pulse`}),`Auto-refreshing every 2 seconds`]}):(0,K.jsx)(`span`,{children:`Click Start to enable live log streaming`})})]})]})}function zZe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function L9({icon:e,label:t,value:n,subValue:r,color:i=`text-bambu-green`}){return(0,K.jsxs)(`div`,{className:`flex items-start gap-3 p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:(0,K.jsx)(e,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t}),(0,K.jsx)(`p`,{className:`text-lg font-semibold text-white truncate`,children:n}),r&&(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:r})]})]})}function BZe({percent:e,color:t=`bg-bambu-green`}){return(0,K.jsx)(`div`,{className:`w-full h-2 bg-bambu-dark rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full ${t} transition-all duration-300`,style:{width:`${Math.min(100,e)}%`}})})}function R9({title:e,icon:t,children:n}){return(0,K.jsxs)(_d,{className:`p-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-4`,children:[(0,K.jsx)(t,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e})]}),n]})}function VZe(){let{t:e}=W(),t=no(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),{data:u,isLoading:d,refetch:f,isFetching:p}=q({queryKey:[`systemInfo`],queryFn:Q.getSystemInfo,refetchInterval:3e4}),{data:m}=q({queryKey:[`debugLogging`],queryFn:ad.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:h}=q({queryKey:[`settings`],queryFn:Q.getSettings}),{data:g}=q({queryKey:[`library-stats`],queryFn:Q.getLibraryStats}),{data:_}=q({queryKey:[`printers`],queryFn:Q.getPrinters}),{data:v,refetch:b,isFetching:x}=q({queryKey:[`systemHealth`],queryFn:Q.getSystemHealth,staleTime:60*1e3}),S=h?.time_format||`system`,C=async()=>{s(!0);try{let e=await ad.setDebugLogging(!m?.enabled);t.setQueryData([`debugLogging`],e)}catch(e){console.error(`Failed to toggle debug logging:`,e)}finally{s(!1)}},w=async()=>{r(null),a(!0);try{await ad.downloadSupportBundle()}catch(e){r(e instanceof Error?e.message:`Failed to download support bundle`)}finally{a(!1)}};if(d)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,K.jsx)(X,{className:`w-8 h-8 text-bambu-green animate-spin`})});if(!u)return(0,K.jsx)(`div`,{className:`p-6 text-center text-bambu-gray`,children:e(`system.failedToLoad`,`Failed to load system information`)});let T=u.storage.disk_percent_used>90?`bg-red-500`:u.storage.disk_percent_used>75?`bg-yellow-500`:`bg-bambu-green`,E=u.memory.percent_used>90?`bg-red-500`:u.memory.percent_used>75?`bg-yellow-500`:`bg-bambu-green`;return(0,K.jsxs)(`div`,{className:`p-6 space-y-6`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`system.title`,`System Information`)}),(0,K.jsx)(`p`,{className:`text-bambu-gray mt-1`,children:e(`system.subtitle`,`Monitor system resources and database statistics`)})]}),(0,K.jsxs)(`button`,{onClick:()=>f(),disabled:p,className:`flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50`,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${p?`animate-spin`:``}`}),e(`common.refresh`,`Refresh`)]})]}),(0,K.jsx)(R9,{title:e(`system.application`,`Application`),icon:Vl,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,K.jsx)(L9,{icon:Vl,label:e(`system.version`,`Version`),value:`v${u.app.version}`}),(0,K.jsx)(L9,{icon:Ss,label:e(`system.uptime`,`System Uptime`),value:u.system.uptime_formatted}),(0,K.jsx)(L9,{icon:Vl,label:e(`system.hostname`,`Hostname`),value:u.system.hostname})]})}),(0,K.jsx)(R9,{title:e(`support.title`,`Support & Troubleshooting`),icon:Ec,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`support.description`,`Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.`)}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg ${m?.enabled?`bg-amber-500/20 text-amber-500`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:(0,K.jsx)(Ko,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium text-white`,children:e(`support.debugLogging`,`Debug Logging`)}),(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[m?.enabled?e(`support.debugLoggingEnabled`,`Capturing detailed logs`):e(`support.debugLoggingDisabled`,`Normal logging level`),m?.enabled&&m.duration_seconds!==null&&(0,K.jsxs)(`span`,{className:`text-amber-400 ml-2`,children:[`(`,Math.floor(m.duration_seconds/60),`m `,m.duration_seconds%60,`s)`]})]})]})]}),(0,K.jsxs)(`button`,{onClick:C,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${m?.enabled?`bg-amber-500/20 text-amber-400 hover:bg-amber-500/30`:`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`} disabled:opacity-50`,children:[o&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),m?.enabled?e(`support.disableDebug`,`Disable`):e(`support.enableDebug`,`Enable`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green`,children:(0,K.jsx)(Vs,{className:`w-5 h-5`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`font-medium text-white`,children:e(`support.supportBundle`,`Support Bundle`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`support.supportBundleDescription`,`Download system info and logs as a ZIP file`)})]})]}),(0,K.jsxs)(`button`,{onClick:w,disabled:i||!m?.enabled,className:`px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed`,title:m?.enabled?void 0:e(`support.enableDebugFirst`,`Enable debug logging first`),children:[i&&(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),i?e(`support.bundleGenerating`,`Generating...`):e(`common.download`,`Download`)]})]}),i&&(0,K.jsxs)(`div`,{className:`p-3 bg-bambu-dark-tertiary/40 rounded-lg space-y-1`,children:[(0,K.jsxs)(`p`,{className:`text-sm font-medium text-white flex items-center gap-2`,children:[(0,K.jsx)(X,{className:`w-3.5 h-3.5 animate-spin text-bambu-green`}),e(`support.bundleGenerating`,`Generating...`)]}),(0,K.jsxs)(`ul`,{className:`text-xs text-bambu-gray list-disc list-inside space-y-0.5 pl-1`,children:[(0,K.jsx)(`li`,{children:e(`support.bundleStepConnection`,`Running printer connectivity checks`)}),(0,K.jsx)(`li`,{children:e(`support.bundleStepVirtualPrinters`,`Running virtual-printer setup checks`)}),(0,K.jsx)(`li`,{children:e(`support.bundleStepLogScan`,`Scanning recent logs for known issues`)}),(0,K.jsx)(`li`,{children:e(`support.bundleStepBuild`,`Building the support bundle ZIP`)})]})]}),n&&(0,K.jsx)(`div`,{className:`p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm`,children:n}),!m?.enabled&&(0,K.jsx)(`div`,{className:`p-4 bg-bambu-dark-tertiary/50 rounded-lg`,children:(0,K.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{className:`text-amber-400 font-medium`,children:e(`support.instructions`,`To report an issue:`)}),(0,K.jsx)(`br`,{}),`1. `,e(`support.step1`,`Enable debug logging`),(0,K.jsx)(`br`,{}),`2. `,e(`support.step2`,`Reproduce the issue`),(0,K.jsx)(`br`,{}),`3. `,e(`support.step3`,`Download the support bundle`),(0,K.jsx)(`br`,{}),`4. `,e(`support.step4`,`Attach the ZIP file to your issue report`)]})}),(0,K.jsxs)(`div`,{className:`p-4 bg-bambu-dark rounded-lg space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e(`support.privacyTitle`,`What's in the support bundle?`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 text-sm`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-bambu-green font-medium mb-1`,children:e(`support.collected`,`Collected:`)}),(0,K.jsxs)(`ul`,{className:`text-bambu-gray space-y-0.5`,children:[(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem1`,`App version and debug mode`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem2`,`OS, architecture, Python version`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem3`,`Database statistics (counts only)`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem4`,`Printer models and nozzle counts`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem5`,`Non-sensitive settings (themes, formats)`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem6`,`Debug logs (sanitized)`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem7`,`Printer connectivity and firmware versions`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem8`,`Integration status (Spoolman, MQTT, HA)`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem9`,`Network interfaces (subnets only)`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem10`,`Python package versions`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem11`,`Database health checks`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.collectItem12`,`Docker environment details`)]})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-red-400 font-medium mb-1`,children:e(`support.notCollected`,`NOT collected:`)}),(0,K.jsxs)(`ul`,{className:`text-bambu-gray space-y-0.5`,children:[(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem1`,`Printer names and serial numbers`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem2`,`Access codes and passwords`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem3`,`Email addresses`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem4`,`API keys and tokens`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem5`,`Webhook URLs`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem6`,`Your hostname or username`)]}),(0,K.jsxs)(`li`,{children:[`• `,e(`support.notItem7`,`IP addresses`)]})]})]})]}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray/70`,children:e(`support.privacyNote`,`Email addresses in logs are replaced with [EMAIL], printer names with [PRINTER], serial numbers with [SERIAL], and IP addresses with [IP].`)})]}),(0,K.jsx)(RZe,{})]})}),(0,K.jsxs)(R9,{title:e(`diagnostic.sectionTitle`,`Connection Diagnostic`),icon:cu,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mb-4`,children:e(`diagnostic.sectionDescription`,`Check why a printer won't connect or won't print — port reachability, LAN developer mode, Docker network mode, and credentials.`)}),_&&_.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:_.map(t=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`font-medium text-white`,children:t.name}),(0,K.jsx)(`span`,{className:`text-sm text-bambu-gray ml-2`,children:t.ip_address})]}),(0,K.jsxs)(`button`,{onClick:()=>l(t),className:`flex items-center gap-2 px-3 py-1.5 text-sm bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-white rounded-lg transition-colors flex-shrink-0`,children:[(0,K.jsx)(cu,{className:`w-4 h-4`}),e(`diagnostic.runButton`,`Run diagnostic`)]})]},t.id))}):(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`diagnostic.noPrinters`,`No printers configured.`)})]}),(0,K.jsxs)(R9,{title:e(`systemHealth.sectionTitle`),icon:Dc,children:[(0,K.jsxs)(`div`,{className:`flex items-start justify-between gap-3 mb-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`systemHealth.sectionDescription`)}),(0,K.jsxs)(`button`,{onClick:()=>b(),disabled:x,className:`flex items-center gap-2 px-3 py-1.5 text-sm bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary text-white rounded-lg transition-colors flex-shrink-0 disabled:opacity-50`,children:[(0,K.jsx)(Ol,{className:`w-4 h-4 ${x?`animate-spin`:``}`}),e(`systemHealth.rescan`)]})]}),v?(0,K.jsx)(cp,{result:v}):(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`common.loading`)})]}),(0,K.jsxs)(R9,{title:e(`system.database`,`Database`),icon:Is,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mb-4`,children:[(0,K.jsx)(L9,{icon:Is,label:e(`system.dbEngine`,`Database Engine`),value:u.database.engine||`SQLite`}),(0,K.jsx)(L9,{icon:Is,label:e(`system.dbVersion`,`Version`),value:u.database.version||`unknown`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4 mb-4`,children:[(0,K.jsx)(L9,{icon:Oo,label:e(`system.totalArchives`,`Total Archives`),value:u.database.archives}),(0,K.jsx)(L9,{icon:ms,label:e(`system.completed`,`Completed`),value:u.database.archives_completed,color:`text-green-500`}),(0,K.jsx)(L9,{icon:ys,label:e(`system.failed`,`Failed`),value:u.database.archives_failed,color:`text-red-500`}),(0,K.jsx)(L9,{icon:X,label:e(`system.printing`,`Printing`),value:u.database.archives_printing,color:`text-yellow-500`})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsx)(L9,{icon:Tl,label:e(`system.printers`,`Printers`),value:u.database.printers}),(0,K.jsx)(L9,{icon:ml,label:e(`system.filaments`,`Filaments`),value:u.database.filaments}),(0,K.jsx)(L9,{icon:sc,label:e(`system.projects`,`Projects`),value:u.database.projects}),(0,K.jsx)(L9,{icon:xl,label:e(`system.smartPlugs`,`Smart Plugs`),value:u.database.smart_plugs})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4 mt-4`,children:[(0,K.jsx)(L9,{icon:Ss,label:e(`system.totalPrintTime`,`Total Print Time`),value:u.database.total_print_time_formatted}),(0,K.jsx)(L9,{icon:Oo,label:e(`system.totalFilament`,`Total Filament Used`),value:`${u.database.total_filament_kg} kg`,subValue:`${u.database.total_filament_grams.toLocaleString()} g`})]})]}),(0,K.jsxs)(R9,{title:e(`system.connectedPrinters`,`Connected Printers`),icon:Tl,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-4 mb-4`,children:[(0,K.jsx)(`div`,{className:`text-3xl font-bold text-bambu-green`,children:u.printers.connected}),(0,K.jsx)(`div`,{className:`text-bambu-gray`,children:e(`system.ofTotal`,`of {{total}} printers connected`,{total:u.printers.total})})]}),u.printers.connected_list.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:u.printers.connected_list.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-bambu-green`}),(0,K.jsx)(`span`,{className:`font-medium text-white`,children:e.name})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-4 text-sm text-bambu-gray`,children:[(0,K.jsx)(`span`,{children:e.model}),(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded ${e.state===`RUNNING`?`bg-bambu-green/20 text-bambu-green`:e.state===`IDLE`?`bg-blue-500/20 text-blue-400`:`bg-bambu-dark-tertiary`}`,children:e.state})]})]},e.id))}):(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:e(`system.noPrintersConnected`,`No printers connected`)})]}),(0,K.jsx)(R9,{title:e(`system.storage`,`Storage`),icon:wc,children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`system.diskUsage`,`Disk Usage`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[u.storage.disk_used_formatted,` / `,u.storage.disk_total_formatted]})]}),(0,K.jsx)(BZe,{percent:u.storage.disk_percent_used,color:T}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[u.storage.disk_free_formatted,` `,e(`system.free`,`free`),` (`,(100-u.storage.disk_percent_used).toFixed(1),`%)`]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,K.jsx)(L9,{icon:Oo,label:e(`system.archiveStorage`,`Archive Storage`),value:u.storage.archive_size_formatted}),(0,K.jsx)(L9,{icon:Is,label:e(`system.databaseSize`,`Database Size`),value:u.storage.database_size_formatted}),g&&(0,K.jsx)(L9,{icon:cc,label:e(`system.fileManagerStorage`,`File Manager`),value:zZe(g.total_size_bytes),subValue:`${g.total_files} files, ${g.total_folders} folders`})]})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,K.jsx)(R9,{title:e(`system.memory`,`Memory`),icon:tl,children:(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex justify-between text-sm mb-1`,children:[(0,K.jsx)(`span`,{className:`text-bambu-gray`,children:e(`system.memoryUsage`,`Memory Usage`)}),(0,K.jsxs)(`span`,{className:`text-white`,children:[u.memory.used_formatted,` / `,u.memory.total_formatted]})]}),(0,K.jsx)(BZe,{percent:u.memory.percent_used,color:E}),(0,K.jsxs)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:[u.memory.available_formatted,` `,e(`system.available`,`available`)]})]})})}),(0,K.jsx)(R9,{title:e(`system.cpu`,`CPU`),icon:Ns,children:(0,K.jsx)(`div`,{className:`space-y-4`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,K.jsx)(L9,{icon:Ns,label:e(`system.cores`,`Cores`),value:u.cpu.count,subValue:`${u.cpu.count_logical} logical`}),(0,K.jsx)(L9,{icon:Ns,label:e(`system.usage`,`Usage`),value:`${u.cpu.percent}%`})]})})})]}),(0,K.jsx)(R9,{title:e(`system.systemDetails`,`System Details`),icon:Vl,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:[(0,K.jsx)(L9,{icon:Vl,label:e(`system.os`,`Operating System`),value:u.system.platform,subValue:u.system.platform_release}),(0,K.jsx)(L9,{icon:Ns,label:e(`system.architecture`,`Architecture`),value:u.system.architecture}),(0,K.jsx)(L9,{icon:Vl,label:e(`system.python`,`Python`),value:u.system.python_version}),(0,K.jsx)(L9,{icon:Ss,label:e(`system.bootTime`,`Boot Time`),value:bf(u.system.boot_time,S)})]})}),c&&(0,K.jsx)(ip,{printerId:c.id,printerName:c.name,onClose:()=>l(null)})]})}var z9=`auth_remember_me`,B9=`auth_post_login_redirect`;function V9(e){return e?`persistent`:`session`}function HZe(){try{let e=sessionStorage.getItem(z9)===`1`;return sessionStorage.removeItem(z9),e}catch(e){return console.warn(`consumeSavedRememberMe: sessionStorage unavailable, Remember Me preference lost across OIDC redirect`,e),!1}}function H9(e){return!e||!e.startsWith(`/`)||e.startsWith(`//`)||e.startsWith(`/login`)?null:e}function UZe(e){let t=H9(e);if(t)try{sessionStorage.setItem(B9,t)}catch(e){console.warn(`stashPostLoginRedirect: sessionStorage unavailable, post-login target will be lost across OIDC redirect`,e)}}function WZe(){try{let e=sessionStorage.getItem(B9);return sessionStorage.removeItem(B9),H9(e)}catch(e){return console.warn(`consumePostLoginRedirect: sessionStorage unavailable`,e),null}}function GZe({provider:e,onClick:t,disabled:n}){let{t:r}=W(),[i,a]=(0,y.useState)(!1);return(0,K.jsxs)(`button`,{type:`button`,onClick:t,disabled:n,className:`w-full flex items-center justify-center gap-3 py-3 px-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary hover:border-bambu-green/50 rounded-lg text-white font-medium transition-colors disabled:opacity-50`,children:[e.has_icon&&!i?(0,K.jsx)(`img`,{src:Q.oidcProviderIconUrl(e.id),alt:``,className:`w-5 h-5 object-contain`,onError:()=>a(!0)}):(0,K.jsx)(ql,{className:`w-5 h-5 text-bambu-green`}),r(`login.twoFA.signInWith`,{provider:e.name})]})}function KZe(){let e=$n(),t=Xn(),[n]=Mi(),{t:r}=W(),{login:i,loginWithToken:a}=dd(),{showToast:o}=Td(),{mode:s}=md();function c(){let e=t.state?.from;if(e?.pathname){let t=H9(`${e.pathname}${e.search??``}`);if(t)return t}return WZe()??`/`}let[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(``),[_,v]=(0,y.useState)(`credentials`),[b,x]=(0,y.useState)(``),[S,C]=(0,y.useState)([]),[w,T]=(0,y.useState)(`totp`),[E,D]=(0,y.useState)(``),[O,k]=(0,y.useState)(!1),A=(0,y.useRef)(null),[j,M]=(0,y.useState)(!1),[N,P]=(0,y.useState)(``),[F,I]=(0,y.useState)(``),[L,R]=(0,y.useState)(``),{data:z}=q({queryKey:[`advancedAuthStatus`],queryFn:()=>Q.getAdvancedAuthStatus()}),{data:B}=q({queryKey:[`oidcProviders`],queryFn:()=>Q.getOIDCProviders()});(0,y.useEffect)(()=>{let t=window.location.hash,n=t.startsWith(`#reset_token=`)?t.slice(13):null;n&&(P(n),v(`reset-password`),e(`/login`,{replace:!0}))},[]),(0,y.useEffect)(()=>{let t=window.location.hash,i=t.startsWith(`#oidc_token=`)?t.slice(12):null,s=n.get(`oidc_error`);if(!i&&!s)return;let l=HZe();if(s){o({oidc_provider_error:r(`login.oidcErrors.providerError`),missing_parameters:r(`login.oidcErrors.missingParameters`),invalid_state:r(`login.oidcErrors.invalidState`),state_expired:r(`login.oidcErrors.stateExpired`),provider_not_found:r(`login.oidcErrors.providerNotFound`),discovery_failed:r(`login.oidcErrors.discoveryFailed`),invalid_discovery_document:r(`login.oidcErrors.invalidDiscovery`),token_exchange_network_error:r(`login.oidcErrors.networkError`),token_exchange_bad_response:r(`login.oidcErrors.badResponse`),no_id_token:r(`login.oidcErrors.noIdToken`),token_validation_failed:r(`login.oidcErrors.validationFailed`),nonce_mismatch:r(`login.oidcErrors.nonceMismatch`),missing_sub_claim:r(`login.oidcErrors.missingSubClaim`),no_linked_account:r(`login.oidcErrors.noLinkedAccount`),account_inactive:r(`login.oidcErrors.accountInactive`),user_resolution_failed:r(`login.oidcErrors.userResolutionFailed`),internal_error:r(`login.oidcErrors.internalError`)}[s]??(s.startsWith(`token_exchange_`)?r(`login.oidcErrors.tokenExchangeFailed`):r(`login.oidcLoginFailed`)),`error`),e(`/login`,{replace:!0});return}i&&Q.exchangeOIDCToken(i).then(t=>{if(t.requires_2fa&&t.pre_auth_token){M(l),x(t.pre_auth_token);let n=t.two_fa_methods??[];C(n),n.includes(`totp`)?T(`totp`):n.includes(`email`)?T(`email`):T(`backup`),v(`2fa`),e(`/login`,{replace:!0})}else t.access_token&&t.user?(a(t.access_token,t.user,V9(l)),o(r(`login.loginSuccess`)),e(c(),{replace:!0})):(o(r(`login.oidcLoginFailed`),`error`),e(`/login`,{replace:!0}))}).catch(t=>{console.error(`OIDC token exchange failed`,t),o(r(`login.oidcLoginFailed`),`error`),e(`/login`,{replace:!0})})},[n]);let V=J({mutationFn:()=>i(l,d,V9(j)),onSuccess:t=>{if(t.requires_2fa&&t.pre_auth_token){x(t.pre_auth_token);let e=t.two_fa_methods??[];C(e),e.includes(`totp`)?T(`totp`):e.includes(`email`)?T(`email`):T(`backup`),v(`2fa`)}else t.access_token&&t.user&&(o(r(`login.loginSuccess`)),e(c(),{replace:!0}))},onError:e=>{o(e.message||r(`login.loginFailed`),`error`)}}),ee=J({mutationFn:e=>Q.forgotPassword({email:e}),onSuccess:e=>{o(e.message,`success`),m(!1),g(``)},onError:e=>{o(e.message,`error`)}}),te=J({mutationFn:()=>Q.forgotPasswordConfirm(N,F),onSuccess:e=>{o(e.message,`success`),v(`credentials`),P(``),I(``),R(``)},onError:e=>{o(e.message||r(`login.resetPassword.resetFailed`),`error`)}}),ne=J({mutationFn:()=>Q.sendEmailOTP(b),onSuccess:e=>{k(!0),e.pre_auth_token&&x(e.pre_auth_token),o(e.message,`success`)},onError:e=>{o(e.message||r(`login.twoFA.sendCodeFailed`),`error`)}}),re=J({mutationFn:()=>Q.verify2FA({pre_auth_token:b,code:E,method:w}),onSuccess:t=>{t.access_token&&t.user?(a(t.access_token,t.user,V9(j)),o(r(`login.loginSuccess`)),e(c(),{replace:!0})):(console.error(`2FA verify: unexpected response shape`,t),o(r(`login.loginFailed`),`error`))},onError:e=>{o(e.message||r(`login.twoFA.invalidCode`),`error`),D(``)}}),ie=J({mutationFn:e=>Q.getOIDCAuthorizeUrl(e),onSuccess:e=>{if(j)try{sessionStorage.setItem(z9,`1`)}catch(e){console.warn(`setItem auth_remember_me failed, Remember Me will not carry through OIDC redirect`,e)}let n=t.state?.from;n?.pathname&&UZe(`${n.pathname}${n.search??``}`),window.location.href=e.auth_url},onError:e=>{o(e.message||r(`login.oidcLoginFailed`),`error`)}}),H=e=>{if(e.preventDefault(),!l||!d){o(r(`login.enterCredentials`),`error`);return}V.mutate()},ae=e=>{if(e.preventDefault(),!E.trim()){o(r(`login.twoFA.enterCode`),`error`);return}re.mutate()},oe=e=>{if(e.preventDefault(),!h){o(r(`login.enterEmail`),`error`);return}ee.mutate(h)},U=e=>{T(e),D(``),k(!1),setTimeout(()=>A.current?.focus(),0)};return _===`reset-password`?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:(0,K.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center mb-4`,children:(0,K.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-bambu-green/20 flex items-center justify-center`,children:(0,K.jsx)(Ic,{className:`w-7 h-7 text-bambu-green`})})}),(0,K.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:r(`login.resetPassword.title`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:r(`login.resetPassword.subtitle`)})]}),(0,K.jsxs)(`form`,{onSubmit:e=>{if(e.preventDefault(),F!==L){o(r(`login.resetPassword.passwordsDoNotMatch`),`error`);return}if(F.length<8){o(r(`login.resetPassword.passwordTooShort`),`error`);return}te.mutate()},className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`new-password`,className:`block text-sm font-medium text-white mb-2`,children:r(`login.resetPassword.newPassword`)}),(0,K.jsx)(`input`,{id:`new-password`,type:`password`,required:!0,value:F,onChange:e=>I(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`login.resetPassword.newPasswordPlaceholder`),autoFocus:!0,autoComplete:`new-password`,minLength:8})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`confirm-password`,className:`block text-sm font-medium text-white mb-2`,children:r(`login.resetPassword.confirmPassword`)}),(0,K.jsx)(`input`,{id:`confirm-password`,type:`password`,required:!0,value:L,onChange:e=>R(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`login.resetPassword.confirmPasswordPlaceholder`),autoComplete:`new-password`})]}),(0,K.jsx)(`button`,{type:`submit`,disabled:te.isPending||!F||!L,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed`,children:te.isPending?r(`login.resetPassword.saving`):r(`login.resetPassword.submit`)})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{v(`credentials`),P(``),I(``),R(``)},className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:r(`login.resetPassword.backToLogin`)})})]})}):_===`2fa`?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:(0,K.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center mb-4`,children:(0,K.jsx)(`div`,{className:`w-14 h-14 rounded-full bg-bambu-green/20 flex items-center justify-center`,children:(0,K.jsx)(ql,{className:`w-7 h-7 text-bambu-green`})})}),(0,K.jsx)(`h2`,{className:`text-2xl font-bold text-white`,children:r(`login.twoFA.title`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:r(`login.twoFA.subtitle`)})]}),S.length>1&&(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[S.includes(`totp`)&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>U(`totp`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${w===`totp`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,K.jsx)(eu,{className:`w-4 h-4`}),r(`login.twoFA.methodAuthenticator`)]}),S.includes(`email`)&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>U(`email`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${w===`email`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Xc,{className:`w-4 h-4`}),r(`login.twoFA.methodEmail`)]}),S.includes(`backup`)&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>U(`backup`),className:`flex-1 flex flex-col items-center gap-1 py-2 px-3 rounded-lg border text-xs font-medium transition-colors ${w===`backup`?`border-bambu-green bg-bambu-green/10 text-bambu-green`:`border-bambu-dark-tertiary text-bambu-gray hover:border-bambu-green/50`}`,children:[(0,K.jsx)(Ic,{className:`w-4 h-4`}),r(`login.twoFA.methodBackup`)]})]}),(0,K.jsxs)(`form`,{onSubmit:ae,className:`space-y-4`,children:[w===`totp`&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:r(`login.twoFA.instructionsTotp`)}),w===`email`&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:r(O?`login.twoFA.instructionsEmail`:`login.twoFA.instructionsEmailNotSent`)}),!O&&(0,K.jsx)($,{type:`button`,variant:`secondary`,className:`w-full`,onClick:()=>ne.mutate(),disabled:ne.isPending,children:ne.isPending?r(`login.twoFA.sendingCode`):r(`login.twoFA.sendCodeButton`)}),O&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>{k(!1),ne.mutate()},className:`text-xs text-bambu-gray hover:text-bambu-green transition-colors`,children:r(`login.twoFA.resendCode`)})]}),w===`backup`&&(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:r(`login.twoFA.instructionsBackup`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`twofa-code`,className:`block text-sm font-medium text-white mb-2`,children:r(w===`backup`?`login.twoFA.backupCodeLabel`:`login.twoFA.codeLabel`)}),(0,K.jsx)(`input`,{ref:A,id:`twofa-code`,type:`text`,inputMode:w===`backup`?`text`:`numeric`,autoComplete:`one-time-code`,value:E,onChange:e=>D(e.target.value.trim()),disabled:w===`email`&&!O,className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray text-center tracking-widest text-xl font-mono focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors disabled:opacity-40`,placeholder:r(w===`backup`?`login.twoFA.backupCodePlaceholder`:`login.twoFA.codePlaceholder`),maxLength:w===`backup`?8:6,autoFocus:!0})]}),(0,K.jsx)(`button`,{type:`submit`,disabled:re.isPending||!E.trim()||w===`email`&&!O,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed`,children:re.isPending?r(`login.twoFA.verifyingButton`):r(`login.twoFA.verifyButton`)})]}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>{v(`credentials`),x(``),D(``),k(!1)},className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:r(`login.twoFA.backToLogin`)})})]})}):(0,K.jsxs)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:[(0,K.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center mb-6`,children:(0,K.jsx)(`img`,{src:s===`dark`?`/img/bambuddy_logo_dark_transparent.png`:`/img/bambuddy_logo_light.png`,alt:`Bambuddy`,className:`h-16`})}),(0,K.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:r(`login.title`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:r(`login.subtitle`)})]}),(0,K.jsxs)(`form`,{className:`mt-8 space-y-6`,onSubmit:H,children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`username`,className:`block text-sm font-medium text-white mb-2`,children:z?.advanced_auth_enabled?r(`login.usernameOrEmail`):r(`login.username`)}),(0,K.jsx)(`input`,{id:`username`,type:`text`,required:!0,value:l,onChange:e=>u(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:z?.advanced_auth_enabled?r(`login.usernameOrEmailPlaceholder`):r(`login.usernamePlaceholder`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`password`,className:`block text-sm font-medium text-white mb-2`,children:r(`login.password`)||`Password`}),(0,K.jsx)(`input`,{id:`password`,type:`password`,required:!0,value:d,onChange:e=>f(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`login.passwordPlaceholder`),autoComplete:`current-password`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`input`,{id:`remember-me`,type:`checkbox`,checked:j,onChange:e=>M(e.target.checked),className:`h-4 w-4 rounded border-bambu-dark-tertiary bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green/50 cursor-pointer`}),(0,K.jsx)(`label`,{htmlFor:`remember-me`,className:`text-sm text-bambu-gray cursor-pointer`,children:r(`login.rememberMe`)})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`button`,{type:`submit`,disabled:V.isPending,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green`,children:V.isPending?r(`login.signingIn`):r(`login.signIn`)})}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(`button`,{type:`button`,onClick:()=>m(!0),className:`text-sm text-bambu-gray hover:text-bambu-green transition-colors`,children:r(`login.forgotPassword`)})})]}),B&&B.length>0&&(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,K.jsx)(`div`,{className:`w-full border-t border-bambu-dark-tertiary`})}),(0,K.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,K.jsx)(`span`,{className:`px-2 bg-bambu-dark-secondary text-bambu-gray`,children:r(`login.twoFA.orContinueWith`)})})]}),(0,K.jsx)(`div`,{className:`space-y-2`,children:B.map(e=>(0,K.jsx)(GZe,{provider:e,onClick:()=>ie.mutate(e.id),disabled:ie.isPending},e.id))})]})]}),p&&(0,K.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,onClick:()=>m(!1),children:(0,K.jsxs)(_d,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:[(0,K.jsx)(vd,{children:(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Xc,{className:`w-5 h-5 text-bambu-green`}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`login.forgotPasswordTitle`)})]}),(0,K.jsx)($,{variant:`ghost`,size:`sm`,onClick:()=>{m(!1),g(``)},children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]})}),(0,K.jsx)(yd,{children:z?.advanced_auth_enabled?(0,K.jsxs)(`form`,{onSubmit:oe,className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:r(`login.forgotPasswordEmailMessage`)}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`forgot-email`,className:`block text-sm font-medium text-white mb-2`,children:r(`login.emailAddress`)}),(0,K.jsx)(`input`,{id:`forgot-email`,type:`email`,required:!0,value:h,onChange:e=>g(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:r(`login.emailPlaceholder`)})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)($,{type:`button`,variant:`secondary`,className:`flex-1`,onClick:()=>{m(!1),g(``)},children:r(`login.cancel`)}),(0,K.jsx)($,{type:`submit`,className:`flex-1`,disabled:ee.isPending,children:ee.isPending?r(`login.sending`):r(`login.sendResetEmail`)})]})]}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-bambu-gray`,children:r(`login.forgotPasswordMessage`)}),(0,K.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-4 space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-sm text-white font-medium`,children:r(`login.howToReset`)}),(0,K.jsxs)(`ol`,{className:`text-sm text-bambu-gray space-y-1 list-decimal list-inside`,children:[(0,K.jsx)(`li`,{children:r(`login.resetStep1`)}),(0,K.jsx)(`li`,{children:r(`login.resetStep2`)}),(0,K.jsx)(`li`,{children:r(`login.resetStep3`)}),(0,K.jsx)(`li`,{children:r(`login.resetStep4`)})]})]}),(0,K.jsx)($,{variant:`secondary`,className:`w-full`,onClick:()=>m(!1),children:r(`login.gotIt`)})]})})]})})]})}function qZe(){let e=$n(),{t}=W(),{showToast:n}=Td(),{mode:r}=md(),{refreshAuth:i}=dd(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(``),[d,f]=(0,y.useState)(``),p=J({mutationFn:()=>Q.setupAuth({auth_enabled:a,admin_username:a?s:void 0,admin_password:a?l:void 0}),onSuccess:async r=>{await i(),r.auth_enabled?r.admin_created?(n(t(`setup.toast.authEnabledAdminCreated`)),e(`/login`)):(n(t(`setup.toast.authEnabledExistingAdmins`)),e(`/login`)):(n(t(`setup.toast.setupCompleted`)),e(`/`))},onError:e=>{n(e.message,`error`)}});return(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-bambu-dark p-4`,children:(0,K.jsxs)(`div`,{className:`max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg`,children:[(0,K.jsxs)(`div`,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center mb-6`,children:(0,K.jsx)(`img`,{src:r===`dark`?`/img/bambuddy_logo_dark_transparent.png`:`/img/bambuddy_logo_light.png`,alt:`Bambuddy`,className:`h-16`})}),(0,K.jsx)(`h2`,{className:`text-3xl font-bold text-white`,children:t(`setup.title`)}),(0,K.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray`,children:t(`setup.subtitle`)})]}),(0,K.jsxs)(`form`,{className:`mt-8 space-y-6`,onSubmit:e=>{if(e.preventDefault(),a&&(s||l)){if(!s||!l){n(t(`setup.toast.enterBothCredentials`),`error`);return}if(l!==d){n(t(`setup.toast.passwordsDoNotMatch`),`error`);return}if(l.length<6){n(t(`setup.toast.passwordTooShort`),`error`);return}}p.mutate()},children:[(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`input`,{id:`auth-enabled`,type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary`}),(0,K.jsx)(`label`,{htmlFor:`auth-enabled`,className:`ml-3 block text-sm font-medium text-white`,children:t(`setup.enableAuth`)})]}),a&&(0,K.jsxs)(`div`,{className:`space-y-4 mt-4`,children:[(0,K.jsx)(`div`,{className:`p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(Pc,{className:`w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0`}),(0,K.jsxs)(`div`,{className:`text-sm text-bambu-gray`,children:[(0,K.jsx)(`p`,{className:`text-white font-medium mb-1`,children:t(`setup.adminAccount`)}),(0,K.jsx)(`p`,{children:t(`setup.adminAccountDesc`)})]})]})}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{htmlFor:`admin-username`,className:`block text-sm font-medium text-white mb-2`,children:[t(`setup.adminUsername`),` `,(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:t(`setup.optionalIfAdminExists`)})]}),(0,K.jsx)(`input`,{id:`admin-username`,type:`text`,value:s,onChange:e=>c(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:t(`setup.adminUsernamePlaceholder`),autoComplete:`username`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`label`,{htmlFor:`admin-password`,className:`block text-sm font-medium text-white mb-2`,children:[t(`setup.adminPassword`),` `,(0,K.jsx)(`span`,{className:`text-bambu-gray text-xs`,children:t(`setup.optionalIfAdminExists`)})]}),(0,K.jsx)(`input`,{id:`admin-password`,type:`password`,value:l,onChange:e=>u(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:t(`setup.adminPasswordPlaceholder`),minLength:6,autoComplete:`new-password`})]}),l&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{htmlFor:`confirm-password`,className:`block text-sm font-medium text-white mb-2`,children:t(`setup.confirmPassword`)}),(0,K.jsx)(`input`,{id:`confirm-password`,type:`password`,value:d,onChange:e=>f(e.target.value),className:`block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors`,placeholder:t(`setup.confirmPasswordPlaceholder`),minLength:6,autoComplete:`new-password`})]})]})]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(`button`,{type:`submit`,disabled:p.isPending,className:`w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green`,children:p.isPending?t(`setup.settingUp`):t(`setup.completeSetup`)})})]})]})})}function JZe(){let{t:e}=W(),{user:t}=dd(),{showToast:n}=Td(),r=no(),i=$n(),[a,o]=(0,y.useState)(!0),[s,c]=(0,y.useState)(!0),[l,u]=(0,y.useState)(!0),[d,f]=(0,y.useState)(!0),[p,m]=(0,y.useState)(!1),{data:h,isLoading:g}=q({queryKey:[`advancedAuthStatus`],queryFn:Q.getAdvancedAuthStatus,staleTime:300*1e3}),{data:_,isLoading:v}=q({queryKey:[`settings`],queryFn:Q.getSettings,staleTime:300*1e3}),{data:b,isLoading:x}=q({queryKey:[`user-email-preferences`],queryFn:()=>Q.getUserEmailPreferences()});(0,y.useEffect)(()=>{(h&&!h.advanced_auth_enabled||_&&!_.user_notifications_enabled)&&i(`/settings`,{replace:!0})},[h,_,i]),(0,y.useEffect)(()=>{b&&(o(b.notify_print_start),c(b.notify_print_complete),u(b.notify_print_failed),f(b.notify_print_stopped),m(!1))},[b]);let S=J({mutationFn:()=>Q.updateUserEmailPreferences({notify_print_start:a,notify_print_complete:s,notify_print_failed:l,notify_print_stopped:d}),onSuccess:()=>{r.invalidateQueries({queryKey:[`user-email-preferences`]}),m(!1),n(e(`notifications.userEmail.saveSuccess`),`success`)},onError:t=>{n(t.message||e(`notifications.userEmail.saveError`),`error`)}}),C=(e,t)=>{e(!t),m(!0)};return x||g||v?(0,K.jsx)(`div`,{className:`flex items-center justify-center h-64`,children:(0,K.jsx)(X,{className:`w-8 h-8 animate-spin text-bambu-green`})}):(0,K.jsxs)(`div`,{className:`p-4 md:p-6 max-w-2xl mx-auto`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-6`,children:[(0,K.jsx)(Bo,{className:`w-7 h-7 text-bambu-green`}),(0,K.jsx)(`h1`,{className:`text-2xl font-bold text-white`,children:e(`notifications.userEmail.title`)})]}),(0,K.jsx)(_d,{className:`mb-6 border-blue-500/30 bg-blue-500/5`,children:(0,K.jsx)(yd,{className:`py-4`,children:(0,K.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0`,children:(0,K.jsx)(Xc,{className:`w-5 h-5 text-blue-400`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-white font-medium`,children:e(`notifications.userEmail.emailNotifications`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`notifications.userEmail.emailNotificationsDesc`)}),t?.email?(0,K.jsxs)(`p`,{className:`text-sm text-blue-400 mt-2`,children:[e(`notifications.userEmail.sendingTo`),`: `,(0,K.jsx)(`strong`,{children:t.email})]}):(0,K.jsx)(`p`,{className:`text-sm text-yellow-400 mt-2`,children:e(`notifications.userEmail.noEmailWarning`)})]})]})})}),(0,K.jsxs)(_d,{className:`mb-6`,children:[(0,K.jsxs)(vd,{children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e(`notifications.userEmail.printJobNotifications`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e(`notifications.userEmail.printJobNotificationsDesc`)})]}),(0,K.jsxs)(yd,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${a?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(ms,{className:`w-5 h-5 ${a?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`notifications.userEmail.printJobStarts`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`notifications.userEmail.printJobStartsDesc`)})]})]}),(0,K.jsx)(`button`,{onClick:()=>C(o,a),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${a?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,role:`switch`,"aria-checked":a,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${s?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(ms,{className:`w-5 h-5 ${s?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`notifications.userEmail.printJobFinishes`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`notifications.userEmail.printJobFinishesDesc`)})]})]}),(0,K.jsx)(`button`,{onClick:()=>C(c,s),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${s?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,role:`switch`,"aria-checked":s,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(ms,{className:`w-5 h-5 ${l?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`notifications.userEmail.printErrors`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`notifications.userEmail.printErrorsDesc`)})]})]}),(0,K.jsx)(`button`,{onClick:()=>C(u,l),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${l?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,role:`switch`,"aria-checked":l,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-bambu-dark rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-10 h-10 rounded-full flex items-center justify-center ${d?`bg-bambu-green/20`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(ms,{className:`w-5 h-5 ${d?`text-bambu-green`:`text-bambu-gray`}`})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:e(`notifications.userEmail.printJobStops`)}),(0,K.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:e(`notifications.userEmail.printJobStopsDesc`)})]})]}),(0,K.jsx)(`button`,{onClick:()=>C(f,d),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${d?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,role:`switch`,"aria-checked":d,children:(0,K.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d?`translate-x-6`:`translate-x-1`}`})})]})]})]}),(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)($,{onClick:()=>S.mutate(),disabled:!p||S.isPending||!t?.email,children:S.isPending?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{className:`w-4 h-4 animate-spin`}),e(`common.saving`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Nl,{className:`w-4 h-4`}),e(`common.save`)]})})})]})}function YZe(){let e=$n(),[t]=Mi(),{t:n}=W();if(window!==window.top)return(0,K.jsxs)(`div`,{style:{padding:32,color:`#f88`},children:[`GCode viewer static files not found. Check that the`,` `,(0,K.jsx)(`code`,{children:`gcode_viewer/`}),` directory exists and restart uvicorn.`]});let r=t.has(`archive`),i=t.has(`library_file`),a=r?`/archives`:i?`/files`:`/`,o=n(r?`gcodeViewer.backToArchives`:i?`gcodeViewer.backToFiles`:`gcodeViewer.back`),s=()=>{window.history.length>1?e(-1):e(a)},c=`/gcode-viewer/${window.location.search}`;return(0,K.jsxs)(`div`,{style:{height:`calc(100vh - 3.5rem)`,display:`flex`,flexDirection:`column`},children:[(0,K.jsx)(`div`,{className:`flex items-center gap-2 px-4 py-2 border-b border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:s,className:`inline-flex items-center gap-1.5 text-sm text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors`,children:[(0,K.jsx)(jo,{className:`w-4 h-4`}),o]})}),(0,K.jsx)(`iframe`,{src:c,title:`GCode Viewer`,style:{display:`block`,width:`100%`,flex:1,border:`none`}})]})}function XZe(){let e=(0,y.useRef)(null),t=(0,y.useRef)(null),n=no(),[r,i]=(0,y.useState)(!1),a=(0,y.useRef)(new Map),{showToast:o}=Td(),{t:s}=W(),c=(0,y.useRef)(new Set),l=(0,y.useRef)(null),u=(0,y.useRef)(new Map),d=(0,y.useRef)(null),f=(0,y.useRef)([]),p=(0,y.useRef)(!1),m=(0,y.useRef)(()=>{}),h=(0,y.useCallback)(()=>{if(p.current||f.current.length===0)return;p.current=!0;let e=()=>{let t=f.current.shift();t?requestAnimationFrame(()=>{m.current(t),f.current.length>0?setTimeout(e,16):p.current=!1}):p.current=!1};e()},[]),g=(0,y.useCallback)(async()=>{if(e.current?.readyState===WebSocket.OPEN)return;let n;try{n=(await Q.getWebSocketToken()).token}catch{}let r=window.location.protocol===`https:`?`wss:`:`ws:`,a=n?`?token=${encodeURIComponent(n)}`:``,o=`${r}//${window.location.host}/api/v1/ws${a}`,s=new WebSocket(o),c=null;s.onopen=()=>{console.log(`[WebSocket] Connected`),i(!0),c=window.setInterval(()=>{s.readyState===WebSocket.OPEN&&s.send(JSON.stringify({type:`ping`}))},3e4)},s.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`printer_status`&&t.printer_id!==void 0&&t.data?m.current(t):(f.current.push(t),h())}catch{}},s.onclose=n=>{console.log(`[WebSocket] Closed`,n.code,n.reason),c&&=(clearInterval(c),null),i(!1),e.current=null,t.current=window.setTimeout(()=>{g()},3e3)},s.onerror=e=>{console.error(`[WebSocket] Error`,e),s.close()},e.current=s},[h]),_=(0,y.useCallback)((e,t)=>{let r=u.current.get(e)||{};u.current.set(e,{...r,...t}),d.current||=window.setTimeout(()=>{let e=new Map(u.current);u.current.clear(),d.current=null,requestAnimationFrame(()=>{e.forEach((e,t)=>{n.setQueryData([`printerStatus`,t],t=>{let n={...t,...e};return n.wifi_signal==null&&t?.wifi_signal!=null&&(n.wifi_signal=t.wifi_signal),n})})})},100)},[n]),v=(0,y.useCallback)(e=>{c.current.add(e),l.current&&clearTimeout(l.current),l.current=window.setTimeout(()=>{let e=Array.from(c.current);c.current.clear(),l.current=null;let t=0;e.forEach(e=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[e]})})},t),t+=500})},3e3)},[n]),b=(0,y.useCallback)(e=>{switch(e.type){case`printer_status`:e.printer_id!==void 0&&e.data&&_(e.printer_id,e.data);break;case`print_start`:e.printer_id!==void 0&&n.invalidateQueries({queryKey:[`printerStatus`,e.printer_id]});break;case`missing_spool_assignment`:{if(e.printer_id===void 0||!Array.isArray(e.missing_slots))break;let t=e.missing_slots.map(e=>e&&typeof e.slot==`string`?e.slot:`Unknown`).filter(e=>e.length>0);if(t.length===0){a.current.delete(e.printer_id);break}let n=t.join(`|`);if(a.current.get(e.printer_id)===n)break;a.current.set(e.printer_id,n),o(s(`printers.toast.missingSpoolAssignment`,{printer:e.printer_name||`Printer ${e.printer_id}`,slots:t.join(`, `)}),`warning`);break}case`print_complete`:v(`archives`),v(`archiveStats`);break;case`archive_created`:v(`archives`),v(`archiveStats`);break;case`archive_updated`:v(`archives`);break;case`pong`:break;case`plate_not_empty`:window.dispatchEvent(new CustomEvent(`plate-not-empty`,{detail:{printer_id:e.printer_id,printer_name:e.printer_name,message:e.message}}));break;case`inventory_changed`:v(`inventory-spools`),v(`spoolman-inventory-spools`),v(y9[0]);break;case`spool_assignment_changed`:v(`spool-assignments`),v(`slotPresets`);break;case`spool_auto_assigned`:v(`inventory-spools`),v(`spool-assignments`);break;case`spool_usage_logged`:v(`inventory-spools`);break;case`unknown_tag`:{let t=e;window.dispatchEvent(new CustomEvent(`unknown-tag`,{detail:{printer_id:t.printer_id,ams_id:t.ams_id,tray_id:t.tray_id,tag_uid:t.tag_uid,tray_uuid:t.tray_uuid,tray_type:t.tray_type,tray_color:t.tray_color,tray_sub_brands:t.tray_sub_brands,tray_count:t.tray_count}}));break}case`background_dispatch`:window.dispatchEvent(new CustomEvent(`background-dispatch`,{detail:e.data||{}}));break;case`spoolbuddy_weight`:window.dispatchEvent(new CustomEvent(`spoolbuddy-weight`,{detail:e}));break;case`spoolbuddy_tag_matched`:window.dispatchEvent(new CustomEvent(`spoolbuddy-tag-matched`,{detail:e})),v(`inventory-spools`);break;case`spoolbuddy_unknown_tag`:window.dispatchEvent(new CustomEvent(`spoolbuddy-unknown-tag`,{detail:e}));break;case`spoolbuddy_tag_removed`:window.dispatchEvent(new CustomEvent(`spoolbuddy-tag-removed`,{detail:e}));break;case`spoolbuddy_tag_written`:window.dispatchEvent(new CustomEvent(`spoolbuddy-tag-written`,{detail:e})),v(`inventory-spools`);break;case`spoolbuddy_tag_write_failed`:window.dispatchEvent(new CustomEvent(`spoolbuddy-tag-write-failed`,{detail:e}));break;case`spoolbuddy_online`:window.dispatchEvent(new CustomEvent(`spoolbuddy-online`,{detail:e})),v(`spoolbuddy-devices`),v(`spoolbuddy-update-check`);break;case`spoolbuddy_offline`:window.dispatchEvent(new CustomEvent(`spoolbuddy-offline`,{detail:e})),v(`spoolbuddy-devices`);break;case`spoolbuddy_update`:v(`spoolbuddy-devices`),v(`spoolbuddy-update-check`);break}},[n,v,_,o,s]);return(0,y.useEffect)(()=>{m.current=b},[b]),(0,y.useEffect)(()=>(g(),()=>{t.current&&clearTimeout(t.current),l.current&&clearTimeout(l.current),d.current&&clearTimeout(d.current),e.current&&e.current.close()}),[g]),{isConnected:r,sendMessage:(0,y.useCallback)(t=>{e.current?.readyState===WebSocket.OPEN&&e.current.send(JSON.stringify(t))},[])}}function ZZe({children:e}){let{authEnabled:t,user:n,loading:r}=dd(),{data:i}=q({queryKey:[`color-catalog-map`],queryFn:async()=>(await Q.getColorNameMap()).colors,staleTime:1/0,gcTime:1/0,retry:2,enabled:!r&&(!t||n!==null)});return(0,y.useEffect)(()=>{i&&Vd(i)},[i]),(0,K.jsx)(K.Fragment,{children:e})}function QZe({selectedPrinterId:e,onPrinterChange:t,deviceOnline:n}){let{t:r}=W(),[i,a]=(0,y.useState)(new Date),{data:o=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),s=_o({queries:o.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:1e4}))}),c=(0,y.useMemo)(()=>o.filter((e,t)=>s[t]?.data?.connected),[o,s]);(0,y.useEffect)(()=>{let n=c.some(t=>t.id===e);(!e||!n)&&c.length>0&&t(c[0].id)},[c,e,t]);let{data:l}=q({queryKey:[`settings`],queryFn:Q.getSettings});return(0,y.useEffect)(()=>{let e=setInterval(()=>a(new Date),1e3);return()=>clearInterval(e)},[]),(0,K.jsxs)(`div`,{className:`h-12 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0`,children:[(0,K.jsx)(`div`,{className:`flex items-center shrink-0`,children:(0,K.jsx)(`img`,{src:`/img/spoolbuddy_logo_dark_small.png`,alt:`SpoolBuddy`,width:113,height:28,className:`h-7 w-auto`})}),(0,K.jsx)(`div`,{className:`flex-1 flex justify-center`,children:(0,K.jsx)(`select`,{value:e??``,onChange:e=>t(Number(e.target.value)),className:`bg-bambu-dark text-white text-base px-4 py-2 rounded border border-bambu-dark-tertiary focus:outline-none focus:border-bambu-green min-w-[180px]`,children:c.length===0?(0,K.jsx)(`option`,{value:``,children:r(`spoolbuddy.status.noPrinters`,`No printers online`)}):c.map(e=>(0,K.jsx)(`option`,{value:e.id,children:e.name},e.id))})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,K.jsx)(`div`,{className:`flex items-center`,title:n?r(`spoolbuddy.status.backend`,`Backend`):r(`spoolbuddy.status.offline`,`Offline`),children:n?(0,K.jsx)(`div`,{className:`flex items-end gap-0.5 h-4`,children:[1,2,3,4].map(e=>(0,K.jsx)(`div`,{className:`w-1 rounded-sm ${e<=4?`bg-white`:`bg-bambu-dark-tertiary`}`,style:{height:`${e*4}px`}},e))}):(0,K.jsx)(Pu,{className:`w-5 h-5 text-red-400`})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full ${n?`bg-bambu-green shadow-[0_0_6px_rgba(34,197,94,0.5)]`:`bg-bambu-gray`}`}),(0,K.jsx)(`span`,{className:`text-sm text-white/50`,children:n?r(`spoolbuddy.status.backend`,`Backend`):r(`spoolbuddy.status.offline`,`Offline`)})]}),(0,K.jsx)(`span`,{className:`text-white/50 text-base font-mono min-w-[50px] text-right`,children:xf(i,l?.time_format||`system`)})]})]})}var $Ze=[{to:`/spoolbuddy`,labelKey:`spoolbuddy.nav.dashboard`,fallback:`Dashboard`,icon:(0,K.jsx)(`svg`,{className:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6`})})},{to:`/spoolbuddy/ams`,labelKey:`spoolbuddy.nav.ams`,fallback:`AMS`,icon:(0,K.jsx)(`svg`,{className:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10`})})},{to:`/spoolbuddy/write-tag`,labelKey:`spoolbuddy.nav.writeTag`,fallback:`Write`,icon:(0,K.jsxs)(`svg`,{className:`w-6 h-6`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,children:[(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0`}),(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z`})]})},{to:`/spoolbuddy/inventory`,labelKey:`spoolbuddy.nav.inventory`,fallback:`Inventory`,icon:(0,K.jsx)(`svg`,{className:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4`})})},{to:`/spoolbuddy/settings`,labelKey:`spoolbuddy.nav.settings`,fallback:`Settings`,icon:(0,K.jsxs)(`svg`,{className:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:[(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z`}),(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`})]})}];function eQe(){let{t:e}=W();return(0,K.jsx)(`nav`,{className:`h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0`,children:$Ze.map(t=>(0,K.jsxs)(Ti,{to:t.to,end:t.to===`/spoolbuddy`,className:({isActive:e})=>`flex-1 flex flex-col items-center justify-center gap-1 transition-colors ${e?`text-bambu-green bg-bambu-dark`:`text-white/50 hover:text-white/70 hover:bg-bambu-dark-tertiary`}`,children:[t.icon,(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:e(t.labelKey,t.fallback)})]},t.to))})}function tQe({alert:e}){let{t}=W(),n=e?e.type===`error`?`bg-red-500`:e.type===`warning`?`bg-amber-500`:`bg-bambu-green`:`bg-bambu-green`;return(0,K.jsxs)(`div`,{className:`h-9 bg-bambu-dark-secondary border-t-2 ${e?e.type===`error`?`border-red-500`:e.type===`warning`?`border-amber-500`:`border-bambu-dark-tertiary`:`border-bambu-dark-tertiary`} flex items-center px-3 gap-3 shrink-0`,children:[(0,K.jsx)(`div`,{className:`w-3.5 h-3.5 rounded-full ${n}`}),(0,K.jsx)(`div`,{className:`flex-1 text-sm text-white/50 truncate`,children:e?(0,K.jsx)(`span`,{children:e.message}):(0,K.jsx)(`span`,{className:`text-bambu-green`,children:t(`spoolbuddy.status.systemReady`,`System Ready`)})})]})}function nQe({isOpen:e,onClose:t,deviceId:n,deviceOnline:r}){let{t:i}=W(),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(!1),[l,u]=(0,y.useState)(new Map),{data:d=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters(),enabled:e}),{data:f=[]}=q({queryKey:[`smart-plugs`],queryFn:()=>Q.getSmartPlugs(),enabled:e}),p=d.map(e=>{let t=f.find(t=>t.printer_id===e.id&&t.plug_type!==`mqtt`&&t.enabled);if(!t)return null;let n=l.get(t.id);return{plug:t,printer:e,status:n?{state:n.state,reachable:!0,device_name:null,energy:null}:null,loading:n?.loading??!1}}).filter(Boolean);(0,y.useEffect)(()=>{!e||f.length===0||f.filter(e=>e.printer_id!==null&&e.plug_type!==`mqtt`&&e.enabled).forEach(async e=>{try{let t=await Q.getSmartPlugStatus(e.id);u(n=>{let r=new Map(n);return r.set(e.id,{loading:!1,state:t.state}),r})}catch{u(t=>{let n=new Map(t);return n.set(e.id,{loading:!1,state:null}),n})}})},[e,f]),(0,y.useEffect)(()=>{e||(o(null),c(!1))},[e]);let m=(0,y.useCallback)(async e=>{u(t=>{let n=new Map(t),r=n.get(e.id);return n.set(e.id,{loading:!0,state:r?.state??null}),n});try{await Q.controlSmartPlug(e.id,`toggle`);let t=await Q.getSmartPlugStatus(e.id);u(n=>{let r=new Map(n);return r.set(e.id,{loading:!1,state:t.state}),r})}catch{u(t=>{let n=new Map(t),r=n.get(e.id);return n.set(e.id,{loading:!1,state:r?.state??null}),n})}},[]),h=(0,y.useCallback)(async e=>{if(n){c(!0);try{await od.systemCommand(n,e),setTimeout(()=>t(),500)}catch{c(!1)}}},[n,t]),g=(0,y.useCallback)(()=>{a&&(a.type===`system`?h(a.command):m(a.plug),o(null))},[a,h,m]);if(!e)return null;let _=e=>e===`ON`||e===`on`;return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-40 bg-black/50`,onPointerDown:t}),(0,K.jsxs)(`div`,{className:`fixed top-0 left-0 right-0 z-50 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary rounded-b-2xl shadow-2xl animate-slide-down`,children:[(0,K.jsx)(`div`,{className:`flex justify-center pt-2 pb-1`,children:(0,K.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-zinc-600`})}),(0,K.jsxs)(`div`,{className:`px-4 pb-4 max-h-[80vh] overflow-y-auto`,children:[p.length>0&&(0,K.jsxs)(`div`,{className:`mb-4`,children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-zinc-500 uppercase tracking-wide mb-2`,children:i(`spoolbuddy.quickMenu.printerPower`,`Printer Power`)}),(0,K.jsx)(`div`,{className:`space-y-1`,children:p.map(({plug:e,printer:t,loading:n})=>{let r=l.get(e.id),i=_(r?.state??null);return(0,K.jsxs)(`button`,{onClick:()=>o({type:`plug`,plug:e,printer:t,currentState:r?.state??null}),disabled:n,className:`w-full flex items-center gap-2 px-3 py-1.5 rounded-lg bg-zinc-800/60 hover:bg-zinc-700/60 transition-colors min-h-[36px]`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0 ${i?`bg-green-500`:`bg-zinc-600`}`}),n&&(0,K.jsx)(X,{className:`w-3 h-3 animate-spin text-zinc-400 shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1 text-sm text-zinc-200 text-left truncate`,children:t.name}),(0,K.jsx)(`span`,{className:`text-xs font-medium ${i?`text-green-400`:`text-zinc-500`}`,children:r?.state??`—`})]},e.id)})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-zinc-500 uppercase tracking-wide mb-2`,children:i(`spoolbuddy.quickMenu.systemControls`,`System`)}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsx)(U9,{icon:(0,K.jsx)(jl,{className:`w-4 h-4`}),label:i(`spoolbuddy.quickMenu.restartDaemon`,`Restart Daemon`),onClick:()=>o({type:`system`,command:`restart_daemon`}),disabled:!n||!r||s}),(0,K.jsx)(U9,{icon:(0,K.jsx)(ol,{className:`w-4 h-4`}),label:i(`spoolbuddy.quickMenu.restartBrowser`,`Restart Browser`),onClick:()=>o({type:`system`,command:`restart_browser`}),disabled:!n||!r||s}),(0,K.jsx)(U9,{icon:(0,K.jsx)(jl,{className:`w-4 h-4`}),label:i(`spoolbuddy.quickMenu.reboot`,`Reboot`),onClick:()=>o({type:`system`,command:`reboot`}),disabled:!n||!r||s,variant:`warning`}),(0,K.jsx)(U9,{icon:(0,K.jsx)(Cl,{className:`w-4 h-4`}),label:i(`spoolbuddy.quickMenu.shutdown`,`Shutdown`),onClick:()=>o({type:`system`,command:`shutdown`}),disabled:!n||!r||s,variant:`danger`})]})]}),(0,K.jsx)(`div`,{className:`flex justify-center mt-3`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-zinc-600`,children:[(0,K.jsx)(is,{className:`w-3 h-3`}),(0,K.jsx)(`span`,{children:i(`spoolbuddy.quickMenu.swipeToClose`,`Swipe down to close`)})]})})]})]}),a&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60`,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-2xl p-5 mx-4 max-w-sm w-full border border-zinc-700`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100 mb-2`,children:i(`spoolbuddy.quickMenu.confirmTitle`,`Confirm`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-400 mb-5`,children:a.type===`plug`?_(a.currentState)?i(`spoolbuddy.quickMenu.confirmPlugOff`,`Turn off {{name}}?`,{name:a.printer.name}):i(`spoolbuddy.quickMenu.confirmPlugOn`,`Turn on {{name}}?`,{name:a.printer.name}):a.command===`shutdown`?i(`spoolbuddy.quickMenu.confirmShutdown`,`Are you sure you want to shut down the SpoolBuddy? You will need physical access to turn it back on.`):a.command===`reboot`?i(`spoolbuddy.quickMenu.confirmReboot`,`Are you sure you want to reboot the SpoolBuddy?`):a.command===`restart_daemon`?i(`spoolbuddy.quickMenu.confirmRestartDaemon`,`Restart the SpoolBuddy daemon? NFC and scale will be temporarily unavailable.`):i(`spoolbuddy.quickMenu.confirmRestartBrowser`,`Restart the kiosk browser? The display will briefly go blank.`)}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>o(null),className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:i(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:g,disabled:s,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium text-white transition-colors min-h-[44px] ${a.type===`plug`?_(a.currentState)?`bg-red-600 hover:bg-red-700`:`bg-green-600 hover:bg-green-700`:a.command===`shutdown`?`bg-red-600 hover:bg-red-700`:a.command===`reboot`?`bg-amber-600 hover:bg-amber-700`:`bg-blue-600 hover:bg-blue-700`} disabled:opacity-50`,children:s?(0,K.jsx)(X,{className:`w-4 h-4 animate-spin mx-auto`}):a.type===`plug`?_(a.currentState)?i(`spoolbuddy.quickMenu.turnOff`,`Turn Off`):i(`spoolbuddy.quickMenu.turnOn`,`Turn On`):i(`spoolbuddy.quickMenu.confirm`,`Confirm`)})]})]})})]})}function U9({icon:e,label:t,onClick:n,disabled:r,variant:i=`default`}){return(0,K.jsxs)(`button`,{onClick:n,disabled:r,className:`flex items-center gap-2.5 p-3 rounded-xl transition-colors min-h-[48px] disabled:opacity-40 ${{default:`bg-zinc-800/60 hover:bg-zinc-700/60 text-zinc-300`,warning:`bg-amber-900/30 hover:bg-amber-900/50 text-amber-400`,danger:`bg-red-900/30 hover:bg-red-900/50 text-red-400`}[i]}`,children:[e,(0,K.jsx)(`span`,{className:`text-sm font-medium`,children:t})]})}var rQe={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,unknownTrayUuid:null,deviceOnline:!1,deviceId:null};function iQe(e,t){switch(t.type){case`WEIGHT_UPDATE`:return{...e,weight:t.weight,weightStable:t.stable,rawAdc:t.rawAdc,deviceId:t.deviceId,deviceOnline:!0};case`TAG_MATCHED`:return{...e,matchedSpool:t.spool,unknownTagUid:null,unknownTrayUuid:null,deviceId:t.deviceId};case`UNKNOWN_TAG`:return{...e,matchedSpool:null,unknownTagUid:t.tagUid,unknownTrayUuid:t.trayUuid??null,deviceId:t.deviceId};case`TAG_REMOVED`:return{...e,matchedSpool:null,unknownTagUid:null,unknownTrayUuid:null};case`DEVICE_ONLINE`:return{...e,deviceOnline:!0,deviceId:t.deviceId};case`DEVICE_OFFLINE`:return{...e,deviceOnline:!1,weight:null,weightStable:!1,rawAdc:null};default:return e}}function aQe(){let[e,t]=(0,y.useReducer)(iQe,rQe),n=(0,y.useCallback)(e=>{let n=e.detail;t({type:`WEIGHT_UPDATE`,weight:n.weight_grams??n.data?.weight_grams,stable:n.stable??n.data?.stable??!1,rawAdc:n.raw_adc??n.data?.raw_adc??null,deviceId:n.device_id??n.data?.device_id??``})},[]),r=(0,y.useCallback)(e=>{let n=e.detail,r=n.spool??n.data?.spool;r&&t({type:`TAG_MATCHED`,spool:{id:r.id,tag_uid:n.tag_uid??n.data?.tag_uid??``,material:r.material??``,subtype:r.subtype??null,color_name:r.color_name??null,rgba:r.rgba??null,brand:r.brand??null,label_weight:r.label_weight??0,core_weight:r.core_weight??0,weight_used:r.weight_used??0},deviceId:n.device_id??n.data?.device_id??``})},[]),i=(0,y.useCallback)(e=>{let n=e.detail;t({type:`UNKNOWN_TAG`,tagUid:n.tag_uid??n.data?.tag_uid??``,trayUuid:n.tray_uuid??n.data?.tray_uuid??null,deviceId:n.device_id??n.data?.device_id??``})},[]),a=(0,y.useCallback)(e=>{let n=e.detail;t({type:`TAG_REMOVED`,deviceId:n.device_id??n.data?.device_id??``})},[]),o=(0,y.useCallback)(e=>{let n=e.detail;t({type:`DEVICE_ONLINE`,deviceId:n.device_id??n.data?.device_id??``})},[]),s=(0,y.useCallback)(e=>{let n=e.detail;t({type:`DEVICE_OFFLINE`,deviceId:n.device_id??n.data?.device_id??``})},[]);(0,y.useEffect)(()=>(window.addEventListener(`spoolbuddy-weight`,n),window.addEventListener(`spoolbuddy-tag-matched`,r),window.addEventListener(`spoolbuddy-unknown-tag`,i),window.addEventListener(`spoolbuddy-tag-removed`,a),window.addEventListener(`spoolbuddy-online`,o),window.addEventListener(`spoolbuddy-offline`,s),()=>{window.removeEventListener(`spoolbuddy-weight`,n),window.removeEventListener(`spoolbuddy-tag-matched`,r),window.removeEventListener(`spoolbuddy-unknown-tag`,i),window.removeEventListener(`spoolbuddy-tag-removed`,a),window.removeEventListener(`spoolbuddy-online`,o),window.removeEventListener(`spoolbuddy-offline`,s)}),[n,r,i,a,o,s]);let c=e.matchedSpool?Math.max(0,e.matchedSpool.label_weight-e.matchedSpool.weight_used):null,l=e.weight!==null&&e.matchedSpool?Math.max(0,e.weight-e.matchedSpool.core_weight):null;return{...e,remainingWeight:c,netWeight:l}}var oQe=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(f()):typeof define==`function`&&define.amd?define([`react`],r):typeof e==`object`?e.ReactSimpleKeyboard=r(f()):n.ReactSimpleKeyboard=r(n.React)})(e,(function(e){return function(){var t={981:function(){typeof Element>`u`||`remove`in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<`u`&&`document`in self&&((!(`classList`in document.createElement(`_`))||document.createElementNS&&!(`classList`in document.createElementNS(`http://www.w3.org/2000/svg`,`g`)))&&function(e){if(`Element`in e){var t=`classList`,n=`prototype`,r=e.Element[n],i=Object,a=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,``)},o=Array[n].indexOf||function(e){for(var t=0,n=this.length;t1?arguments[1]:void 0)}},7916:function(e,t,n){var r=n(6080),i=n(9565),a=n(8981),o=n(6319),s=n(4209),c=n(3517),l=n(6198),u=n(4659),d=n(4527),f=n(81),p=n(851),m=Array;e.exports=function(e){var t=a(e),n=c(this),h=arguments.length,g=h>1?arguments[1]:void 0,_=g!==void 0;_&&(g=r(g,h>2?arguments[2]:void 0));var v,y,b,x,S,C,w=p(t),T=0;if(!w||this===m&&s(w))for(v=l(t),y=n?new this(v):m(v);v>T;T++)C=_?g(t[T],T):t[T],u(y,T,C);else for(y=n?new this:[],S=(x=f(t,w)).next;!(b=i(S,x)).done;T++)C=_?o(x,g,[b.value,T],!0):b.value,u(y,T,C);return d(y,T),y}},9617:function(e,t,n){var r=n(5397),i=n(5610),a=n(6198),o=function(e){return function(t,n,o){var s=r(t),c=a(s);if(c===0)return!e&&-1;var l,u=i(o,c);if(e&&n!=n){for(;c>u;)if((l=s[u++])!=l)return!0}else for(;c>u;u++)if((e||u in s)&&s[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:o(!0),indexOf:o(!1)}},9213:function(e,t,n){var r=n(6080),i=n(7055),a=n(8981),o=n(6198),s=n(1469),c=n(4659),l=function(e){var t=e===1,n=e===2,l=e===3,u=e===4,d=e===6,f=e===7,p=e===5||d;return function(m,h,g){for(var _,v,y=a(m),b=i(y),x=o(b),S=r(h,g),C=0,w=0,T=t?s(m,x):n||f?s(m,0):void 0;x>C;C++)if((p||C in b)&&(v=S(_=b[C],C,y),e))if(t)c(T,C,v);else if(v)switch(e){case 3:return!0;case 5:return _;case 6:return C;case 2:c(T,w++,_)}else switch(e){case 4:return!1;case 7:c(T,w++,_)}return d?-1:l||u?u:T}};e.exports={forEach:l(0),map:l(1),filter:l(2),some:l(3),every:l(4),find:l(5),findIndex:l(6),filterReject:l(7)}},597:function(e,t,n){var r=n(9039),i=n(8227),a=n(9519),o=i(`species`);e.exports=function(e){return a>=51||!r((function(){var t=[];return(t.constructor={})[o]=function(){return{foo:1}},t[e](Boolean).foo!==1}))}},4598:function(e,t,n){var r=n(9039);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){return 1},1)}))}},926:function(e,t,n){var r=n(9306),i=n(8981),a=n(7055),o=n(6198),s=TypeError,c=`Reduce of empty array with no initial value`,l=function(e){return function(t,n,l,u){var d=i(t),f=a(d),p=o(d);if(r(n),p===0&&l<2)throw new s(c);var m=e?p-1:0,h=e?-1:1;if(l<2)for(;;){if(m in f){u=f[m],m+=h;break}if(m+=h,e?m<0:p<=m)throw new s(c)}for(;e?m>=0:p>m;m+=h)m in f&&(u=n(u,f[m],m,d));return u}};e.exports={left:l(!1),right:l(!0)}},4527:function(e,t,n){var r=n(3724),i=n(4376),a=TypeError,o=Object.getOwnPropertyDescriptor;e.exports=r&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}()?function(e,t){if(i(e)&&!o(e,`length`).writable)throw new a(`Cannot set read only .length`);return e.length=t}:function(e,t){return e.length=t}},7680:function(e,t,n){e.exports=n(9504)([].slice)},4488:function(e,t,n){var r=n(7680),i=Math.floor,a=function(e,t){var n=e.length;if(n<8)for(var o,s,c=1;c0;)e[s]=e[--s];s!==c++&&(e[s]=o)}else for(var l=i(n/2),u=a(r(e,0,l),t),d=a(r(e,l),t),f=u.length,p=d.length,m=0,h=0;m9007199254740991)throw t(`Maximum allowed index exceeded`);return e}},7400:function(e){e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},9296:function(e,t,n){var r=n(4055)(`span`).classList,i=r&&r.constructor&&r.constructor.prototype;e.exports=i===Object.prototype?void 0:i},8727:function(e){e.exports=[`constructor`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`toLocaleString`,`toString`,`valueOf`]},3709:function(e,t,n){var r=n(2839).match(/firefox\/(\d+)/i);e.exports=!!r&&+r[1]},3763:function(e,t,n){var r=n(2839);e.exports=/MSIE|Trident/.test(r)},6193:function(e,t,n){e.exports=n(4215)===`NODE`},2839:function(e,t,n){var r=n(4576).navigator,i=r&&r.userAgent;e.exports=i?String(i):``},9519:function(e,t,n){var r,i,a=n(4576),o=n(2839),s=a.process,c=a.Deno,l=s&&s.versions||c&&c.version,u=l&&l.v8;u&&(i=(r=u.split(`.`))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!i&&o&&(!(r=o.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=o.match(/Chrome\/(\d+)/))&&(i=+r[1]),e.exports=i},3607:function(e,t,n){var r=n(2839).match(/AppleWebKit\/(\d+)\./);e.exports=!!r&&+r[1]},4215:function(e,t,n){var r=n(4576),i=n(2839),a=n(2195),o=function(e){return i.slice(0,e.length)===e};e.exports=o(`Bun/`)?`BUN`:o(`Cloudflare-Workers`)?`CLOUDFLARE`:o(`Deno/`)?`DENO`:o(`Node.js/`)?`NODE`:r.Bun&&typeof Bun.version==`string`?`BUN`:r.Deno&&typeof Deno.version==`object`?`DENO`:a(r.process)===`process`?`NODE`:r.window&&r.document?`BROWSER`:`REST`},6518:function(e,t,n){var r=n(4576),i=n(7347).f,a=n(6699),o=n(6840),s=n(9433),c=n(7740),l=n(2796);e.exports=function(e,t){var n,u,d,f,p,m=e.target,h=e.global,g=e.stat;if(n=h?r:g?r[m]||s(m,{}):r[m]&&r[m].prototype)for(u in t){if(f=t[u],d=e.dontCallGetSet?(p=i(n,u))&&p.value:n[u],!l(h?u:m+(g?`.`:`#`)+u,e.forced)&&d!==void 0){if(typeof f==typeof d)continue;c(f,d)}(e.sham||d&&d.sham)&&a(f,`sham`,!0),o(n,u,f,e)}}},9039:function(e){e.exports=function(e){try{return!!e()}catch{return!0}}},9228:function(e,t,n){n(7495);var r=n(9565),i=n(6840),a=n(7323),o=n(9039),s=n(8227),c=n(6699),l=s(`species`),u=RegExp.prototype;e.exports=function(e,t,n,d){var f=s(e),p=!o((function(){var t={};return t[f]=function(){return 7},``[e](t)!==7})),m=p&&!o((function(){var t=!1,n=/a/;if(e===`split`){var r={};r[l]=function(){return n},(n={constructor:r,flags:``})[f]=/./[f]}return n.exec=function(){return t=!0,null},n[f](``),!t}));if(!p||!m||n){var h=/./[f],g=t(f,``[e],(function(e,t,n,i,o){var s=t.exec;return s===a||s===u.exec?p&&!o?{done:!0,value:r(h,t,n,i)}:{done:!0,value:r(e,n,t,i)}:{done:!1}}));i(String.prototype,e,g[0]),i(u,f,g[1])}d&&c(u[f],`sham`,!0)}},8745:function(e,t,n){var r=n(616),i=Function.prototype,a=i.apply,o=i.call;e.exports=typeof Reflect==`object`&&Reflect.apply||(r?o.bind(a):function(){return o.apply(a,arguments)})},6080:function(e,t,n){var r=n(7476),i=n(9306),a=n(616),o=r(r.bind);e.exports=function(e,t){return i(e),t===void 0?e:a?o(e,t):function(){return e.apply(t,arguments)}}},616:function(e,t,n){e.exports=!n(9039)((function(){var e=function(){}.bind();return typeof e!=`function`||e.hasOwnProperty(`prototype`)}))},566:function(e,t,n){var r=n(9504),i=n(9306),a=n(34),o=n(9297),s=n(7680),c=n(616),l=Function,u=r([].concat),d=r([].join),f={};e.exports=c?l.bind:function(e){var t=i(this),n=t.prototype,r=s(arguments,1),c=function(){var n=u(r,s(arguments));return this instanceof c?function(e,t,n){if(!o(f,t)){for(var r=[],i=0;i]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,n,r,d,f){var p=n+e.length,m=r.length,h=u;return d!==void 0&&(d=i(d),h=l),s(f,h,(function(i,s){var l;switch(o(s,0)){case`$`:return`$`;case`&`:return e;case"`":return c(t,0,n);case`'`:return c(t,p);case`<`:l=d[c(s,1,-1)];break;default:var u=+s;if(u===0)return i;if(u>m){var f=a(u/10);return f===0?i:f<=m?r[f-1]===void 0?o(s,1):r[f-1]+o(s,1):i}l=r[u-1]}return l===void 0?``:l}))}},4576:function(e,t,n){var r=function(e){return e&&e.Math===Math&&e};e.exports=r(typeof globalThis==`object`&&globalThis)||r(typeof window==`object`&&window)||r(typeof self==`object`&&self)||r(typeof n.g==`object`&&n.g)||r(typeof this==`object`&&this)||function(){return this}()||Function(`return this`)()},9297:function(e,t,n){var r=n(9504),i=n(8981),a=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return a(i(e),t)}},421:function(e){e.exports={}},397:function(e,t,n){e.exports=n(7751)(`document`,`documentElement`)},5917:function(e,t,n){var r=n(3724),i=n(9039),a=n(4055);e.exports=!r&&!i((function(){return Object.defineProperty(a(`div`),"a",{get:function(){return 7}}).a!==7}))},7055:function(e,t,n){var r=n(9504),i=n(9039),a=n(2195),o=Object,s=r(``.split);e.exports=i((function(){return!o(`z`).propertyIsEnumerable(0)}))?function(e){return a(e)===`String`?s(e,``):o(e)}:o},3167:function(e,t,n){var r=n(4901),i=n(34),a=n(2967);e.exports=function(e,t,n){var o,s;return a&&r(o=t.constructor)&&o!==n&&i(s=o.prototype)&&s!==n.prototype&&a(e,s),e}},3706:function(e,t,n){var r=n(9504),i=n(4901),a=n(7629),o=r(Function.toString);i(a.inspectSource)||(a.inspectSource=function(e){return o(e)}),e.exports=a.inspectSource},1181:function(e,t,n){var r,i,a,o=n(8622),s=n(4576),c=n(34),l=n(6699),u=n(9297),d=n(7629),f=n(6119),p=n(421),m=`Object already initialized`,h=s.TypeError,g=s.WeakMap;if(o||d.state){var _=d.state||=new g;_.get=_.get,_.has=_.has,_.set=_.set,r=function(e,t){if(_.has(e))throw new h(m);return t.facade=e,_.set(e,t),t},i=function(e){return _.get(e)||{}},a=function(e){return _.has(e)}}else{var v=f(`state`);p[v]=!0,r=function(e,t){if(u(e,v))throw new h(m);return t.facade=e,l(e,v,t),t},i=function(e){return u(e,v)?e[v]:{}},a=function(e){return u(e,v)}}e.exports={set:r,get:i,has:a,enforce:function(e){return a(e)?i(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!c(t)||(n=i(t)).type!==e)throw new h(`Incompatible receiver, `+e+` required`);return n}}}},4209:function(e,t,n){var r=n(8227),i=n(6269),a=r(`iterator`),o=Array.prototype;e.exports=function(e){return e!==void 0&&(i.Array===e||o[a]===e)}},4376:function(e,t,n){var r=n(2195);e.exports=Array.isArray||function(e){return r(e)===`Array`}},4901:function(e){var t=typeof document==`object`&&document.all;e.exports=t===void 0&&t!==void 0?function(e){return typeof e==`function`||e===t}:function(e){return typeof e==`function`}},3517:function(e,t,n){var r=n(9504),i=n(9039),a=n(4901),o=n(6955),s=n(7751),c=n(3706),l=function(){},u=s(`Reflect`,`construct`),d=/^\s*(?:class|function)\b/,f=r(d.exec),p=!d.test(l),m=function(e){if(!a(e))return!1;try{return u(l,[],e),!0}catch{return!1}},h=function(e){if(!a(e))return!1;switch(o(e)){case`AsyncFunction`:case`GeneratorFunction`:case`AsyncGeneratorFunction`:return!1}try{return p||!!f(d,c(e))}catch{return!0}};h.sham=!0,e.exports=!u||i((function(){var e;return m(m.call)||!m(Object)||!m((function(){e=!0}))||e}))?h:m},2796:function(e,t,n){var r=n(9039),i=n(4901),a=/#|\.prototype\./,o=function(e,t){var n=c[s(e)];return n===u||n!==l&&(i(t)?r(t):!!t)},s=o.normalize=function(e){return String(e).replace(a,`.`).toLowerCase()},c=o.data={},l=o.NATIVE=`N`,u=o.POLYFILL=`P`;e.exports=o},2087:function(e,t,n){var r=n(34),i=Math.floor;e.exports=Number.isInteger||function(e){return!r(e)&&isFinite(e)&&i(e)===e}},4117:function(e){e.exports=function(e){return e==null}},34:function(e,t,n){var r=n(4901);e.exports=function(e){return typeof e==`object`?e!==null:r(e)}},3925:function(e,t,n){var r=n(34);e.exports=function(e){return r(e)||e===null}},6395:function(e){e.exports=!1},5810:function(e,t,n){var r=n(34),i=n(1181).get;e.exports=function(e){if(!r(e))return!1;var t=i(e);return!!t&&t.type===`RawJSON`}},788:function(e,t,n){var r=n(34),i=n(2195),a=n(8227)(`match`);e.exports=function(e){var t;return r(e)&&((t=e[a])===void 0?i(e)===`RegExp`:!!t)}},757:function(e,t,n){var r=n(7751),i=n(4901),a=n(1625),o=n(7040),s=Object;e.exports=o?function(e){return typeof e==`symbol`}:function(e){var t=r(`Symbol`);return i(t)&&a(t.prototype,s(e))}},9539:function(e,t,n){var r=n(9565),i=n(8551),a=n(5966);e.exports=function(e,t,n){var o,s;i(e);try{if(!(o=a(e,`return`))){if(t===`throw`)throw n;return n}o=r(o,e)}catch(e){s=!0,o=e}if(t===`throw`)throw n;if(s)throw o;return i(o),n}},3994:function(e,t,n){var r=n(7657).IteratorPrototype,i=n(2360),a=n(6980),o=n(687),s=n(6269),c=function(){return this};e.exports=function(e,t,n,l){var u=t+` Iterator`;return e.prototype=i(r,{next:a(+!l,n)}),o(e,u,!1,!0),s[u]=c,e}},1088:function(e,t,n){var r=n(6518),i=n(9565),a=n(6395),o=n(350),s=n(4901),c=n(3994),l=n(2787),u=n(2967),d=n(687),f=n(6699),p=n(6840),m=n(8227),h=n(6269),g=n(7657),_=o.PROPER,v=o.CONFIGURABLE,y=g.IteratorPrototype,b=g.BUGGY_SAFARI_ITERATORS,x=m(`iterator`),S=`keys`,C=`values`,w=`entries`,T=function(){return this};e.exports=function(e,t,n,o,m,g,E){c(n,t,o);var D,O,k,A=function(e){if(e===m&&F)return F;if(!b&&e&&e in N)return N[e];switch(e){case S:case C:case w:return function(){return new n(this,e)}}return function(){return new n(this)}},j=t+` Iterator`,M=!1,N=e.prototype,P=N[x]||N[`@@iterator`]||m&&N[m],F=!b&&P||A(m),I=t===`Array`&&N.entries||P;if(I&&(D=l(I.call(new e)))!==Object.prototype&&D.next&&(a||l(D)===y||(u?u(D,y):s(D[x])||p(D,x,T)),d(D,j,!0,!0),a&&(h[j]=T)),_&&m===C&&P&&P.name!==C&&(!a&&v?f(N,`name`,C):(M=!0,F=function(){return i(P,this)})),m)if(O={values:A(C),keys:g?F:A(S),entries:A(w)},E)for(k in O)(b||M||!(k in N))&&p(N,k,O[k]);else r({target:t,proto:!0,forced:b||M},O);return a&&!E||N[x]===F||p(N,x,F,{name:m}),h[t]=F,O}},7657:function(e,t,n){var r,i,a,o=n(9039),s=n(4901),c=n(34),l=n(2360),u=n(2787),d=n(6840),f=n(8227),p=n(6395),m=f(`iterator`),h=!1;[].keys&&(`next`in(a=[].keys())?(i=u(u(a)))!==Object.prototype&&(r=i):h=!0),!c(r)||o((function(){var e={};return r[m].call(e)!==e}))?r={}:p&&(r=l(r)),s(r[m])||d(r,m,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:h}},6269:function(e){e.exports={}},6198:function(e,t,n){var r=n(8014);e.exports=function(e){return r(e.length)}},283:function(e,t,n){var r=n(9504),i=n(9039),a=n(4901),o=n(9297),s=n(3724),c=n(350).CONFIGURABLE,l=n(3706),u=n(1181),d=u.enforce,f=u.get,p=String,m=Object.defineProperty,h=r(``.slice),g=r(``.replace),_=r([].join),v=s&&!i((function(){return m((function(){}),`length`,{value:8}).length!==8})),y=String(String).split(`String`),b=e.exports=function(e,t,n){h(p(t),0,7)===`Symbol(`&&(t=`[`+g(p(t),/^Symbol\(([^)]*)\).*$/,`$1`)+`]`),n&&n.getter&&(t=`get `+t),n&&n.setter&&(t=`set `+t),(!o(e,`name`)||c&&e.name!==t)&&(s?m(e,`name`,{value:t,configurable:!0}):e.name=t),v&&n&&o(n,`arity`)&&e.length!==n.arity&&m(e,`length`,{value:n.arity});try{n&&o(n,`constructor`)&&n.constructor?s&&m(e,`prototype`,{writable:!1}):e.prototype&&=void 0}catch{}var r=d(e);return o(r,`source`)||(r.source=_(y,typeof t==`string`?t:``)),e};Function.prototype.toString=b((function(){return a(this)&&f(this).source||l(this)}),`toString`)},741:function(e){var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function(e){var r=+e;return(r>0?n:t)(r)}},7819:function(e,t,n){e.exports=!n(9039)((function(){var e=`9007199254740993`,t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e}))},5749:function(e,t,n){var r=n(788),i=TypeError;e.exports=function(e){if(r(e))throw new i(`The method doesn't accept regular expressions`);return e}},4213:function(e,t,n){var r=n(3724),i=n(9504),a=n(9565),o=n(9039),s=n(1072),c=n(3717),l=n(8773),u=n(8981),d=n(7055),f=Object.assign,p=Object.defineProperty,m=i([].concat);e.exports=!f||o((function(){if(r&&f({b:1},f(p({},`a`,{enumerable:!0,get:function(){p(this,`b`,{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var e={},t={},n=Symbol(`assign detection`),i=`abcdefghijklmnopqrst`;return e[n]=7,i.split(``).forEach((function(e){t[e]=e})),f({},e)[n]!==7||s(f({},t)).join(``)!==i}))?function(e,t){for(var n=u(e),i=arguments.length,o=1,f=c.f,p=l.f;i>o;)for(var h,g=d(arguments[o++]),_=f?m(s(g),f(g)):s(g),v=_.length,y=0;v>y;)h=_[y++],r&&!a(p,g,h)||(n[h]=g[h]);return n}:f},2360:function(e,t,n){var r,i=n(8551),a=n(6801),o=n(8727),s=n(421),c=n(397),l=n(4055),u=n(6119),d=`prototype`,f=`script`,p=u(`IE_PROTO`),m=function(){},h=function(e){return`<`+f+`>`+e+``},g=function(e){e.write(h(``)),e.close();var t=e.parentWindow.Object;return e=null,t},_=function(){try{r=new ActiveXObject(`htmlfile`)}catch{}var e,t,n;_=typeof document<`u`?document.domain&&r?g(r):(t=l(`iframe`),n=`java`+f+`:`,t.style.display=`none`,c.appendChild(t),t.src=String(n),(e=t.contentWindow.document).open(),e.write(h(`document.F=Object`)),e.close(),e.F):g(r);for(var i=o.length;i--;)delete _[d][o[i]];return _()};s[p]=!0,e.exports=Object.create||function(e,t){var n;return e===null?n=_():(m[d]=i(e),n=new m,m[d]=null,n[p]=e),t===void 0?n:a.f(n,t)}},6801:function(e,t,n){var r=n(3724),i=n(8686),a=n(4913),o=n(8551),s=n(5397),c=n(1072);t.f=r&&!i?Object.defineProperties:function(e,t){o(e);for(var n,r=s(t),i=c(t),l=i.length,u=0;l>u;)a.f(e,n=i[u++],r[n]);return e}},4913:function(e,t,n){var r=n(3724),i=n(5917),a=n(8686),o=n(8551),s=n(6969),c=TypeError,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=`enumerable`,f=`configurable`,p=`writable`;t.f=r?a?function(e,t,n){if(o(e),t=s(t),o(n),typeof e==`function`&&t===`prototype`&&`value`in n&&p in n&&!n[p]){var r=u(e,t);r&&r[p]&&(e[t]=n.value,n={configurable:f in n?n[f]:r[f],enumerable:d in n?n[d]:r[d],writable:!1})}return l(e,t,n)}:l:function(e,t,n){if(o(e),t=s(t),o(n),i)try{return l(e,t,n)}catch{}if(`get`in n||`set`in n)throw new c(`Accessors not supported`);return`value`in n&&(e[t]=n.value),e}},7347:function(e,t,n){var r=n(3724),i=n(9565),a=n(8773),o=n(6980),s=n(5397),c=n(6969),l=n(9297),u=n(5917),d=Object.getOwnPropertyDescriptor;t.f=r?d:function(e,t){if(e=s(e),t=c(t),u)try{return d(e,t)}catch{}if(l(e,t))return o(!i(a.f,e,t),e[t])}},298:function(e,t,n){var r=n(2195),i=n(5397),a=n(8480).f,o=n(7680),s=typeof window==`object`&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return s&&r(e)===`Window`?function(e){try{return a(e)}catch{return o(s)}}(e):a(i(e))}},8480:function(e,t,n){var r=n(1828),i=n(8727).concat(`length`,`prototype`);t.f=Object.getOwnPropertyNames||function(e){return r(e,i)}},3717:function(e,t){t.f=Object.getOwnPropertySymbols},2787:function(e,t,n){var r=n(9297),i=n(4901),a=n(8981),o=n(6119),s=n(2211),c=o(`IE_PROTO`),l=Object,u=l.prototype;e.exports=s?l.getPrototypeOf:function(e){var t=a(e);if(r(t,c))return t[c];var n=t.constructor;return i(n)&&t instanceof n?n.prototype:t instanceof l?u:null}},1625:function(e,t,n){e.exports=n(9504)({}.isPrototypeOf)},1828:function(e,t,n){var r=n(9504),i=n(9297),a=n(5397),o=n(9617).indexOf,s=n(421),c=r([].push);e.exports=function(e,t){var n,r=a(e),l=0,u=[];for(n in r)!i(s,n)&&i(r,n)&&c(u,n);for(;t.length>l;)i(r,n=t[l++])&&(~o(u,n)||c(u,n));return u}},1072:function(e,t,n){var r=n(1828),i=n(8727);e.exports=Object.keys||function(e){return r(e,i)}},8773:function(e,t){var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor;t.f=r&&!n.call({1:2},1)?function(e){var t=r(this,e);return!!t&&t.enumerable}:n},2551:function(e,t,n){var r=n(6395),i=n(4576),a=n(9039),o=n(3607);e.exports=r||!a((function(){if(!(o&&o<535)){var e=Math.random();__defineSetter__.call(null,e,(function(){})),delete i[e]}}))},2967:function(e,t,n){var r=n(6706),i=n(34),a=n(7750),o=n(3506);e.exports=Object.setPrototypeOf||(`__proto__`in{}?function(){var e,t=!1,n={};try{(e=r(Object.prototype,`__proto__`,`set`))(n,[]),t=n instanceof Array}catch{}return function(n,r){return a(n),o(r),i(n)&&(t?e(n,r):n.__proto__=r),n}}():void 0)},3179:function(e,t,n){var r=n(2140),i=n(6955);e.exports=r?{}.toString:function(){return`[object `+i(this)+`]`}},4270:function(e,t,n){var r=n(9565),i=n(4901),a=n(34),o=TypeError;e.exports=function(e,t){var n,s;if(t===`string`&&i(n=e.toString)&&!a(s=r(n,e))||i(n=e.valueOf)&&!a(s=r(n,e))||t!==`string`&&i(n=e.toString)&&!a(s=r(n,e)))return s;throw new o(`Can't convert object to primitive value`)}},5031:function(e,t,n){var r=n(7751),i=n(9504),a=n(8480),o=n(3717),s=n(8551),c=i([].concat);e.exports=r(`Reflect`,`ownKeys`)||function(e){var t=a.f(s(e)),n=o.f;return n?c(t,n(e)):t}},8235:function(e,t,n){var r=n(9504),i=n(9297),a=SyntaxError,o=parseInt,s=String.fromCharCode,c=r(``.charAt),l=r(``.slice),u=r(/./.exec),d={'\\"':`"`,"\\\\":`\\`,"\\/":`/`,"\\b":`\b`,"\\f":`\f`,"\\n":` `,"\\r":`\r`,"\\t":` `},f=/^[\da-f]{4}$/i,p=/^[\u0000-\u001F]$/;e.exports=function(e,t){for(var n=!0,r=``;t0&&(!p.multiline||p.multiline&&v(T,p.lastIndex-1)!==` @@ -8757,5 +8757,5 @@ ${t.slice(l+2)}`,d+=1;else break}t.push({indent:l,number:parseInt(s,10),content: In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function a(e,t){if(e){if(typeof e==`string`)return o(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function o(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n`u`||`remove`in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<`u`&&`document`in self&&((!(`classList`in document.createElement(`_`))||document.createElementNS&&!(`classList`in document.createElementNS(`http://www.w3.org/2000/svg`,`g`)))&&function(e){if(`Element`in e){var t=`classList`,n=`prototype`,r=e.Element[n],i=Object,a=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,``)},o=Array[n].indexOf||function(e){for(var t=0,n=this.length;t2&&arguments[2]!==void 0&&arguments[2]?Object.assign({},this.getDefaultDiplay(),t):t||this.getDefaultDiplay())[e]||e}},{key:`getUpdatedInput`,value:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:n,i=arguments.length>4&&arguments[4]!==void 0&&arguments[4],a=this.getOptions(),o=[n,r,i],s=t;return(e===`{bksp}`||e===`{backspace}`)&&s.length>0?s=this.removeAt.apply(this,[s].concat(o)):(e===`{delete}`||e===`{forwarddelete}`)&&s.length>0?s=this.removeForwardsAt.apply(this,[s].concat(o)):e===`{space}`?s=this.addStringAt.apply(this,[s,` `].concat(o)):e!==`{tab}`||typeof a.tabCharOnTab==`boolean`&&!1===a.tabCharOnTab?e!==`{enter}`&&e!==`{numpadenter}`||!a.newLineOnEnter?e.includes(`numpad`)&&Number.isInteger(Number(e[e.length-2]))?s=this.addStringAt.apply(this,[s,e[e.length-2]].concat(o)):e===`{numpaddivide}`?s=this.addStringAt.apply(this,[s,`/`].concat(o)):e===`{numpadmultiply}`?s=this.addStringAt.apply(this,[s,`*`].concat(o)):e===`{numpadsubtract}`?s=this.addStringAt.apply(this,[s,`-`].concat(o)):e===`{numpadadd}`?s=this.addStringAt.apply(this,[s,`+`].concat(o)):e===`{numpaddecimal}`?s=this.addStringAt.apply(this,[s,`.`].concat(o)):e===`{`||e===`}`?s=this.addStringAt.apply(this,[s,e].concat(o)):e.includes(`{`)||e.includes(`}`)||(s=this.addStringAt.apply(this,[s,e].concat(o))):s=this.addStringAt.apply(this,[s,` `].concat(o)):s=this.addStringAt.apply(this,[s,` `].concat(o)),a.debug&&console.log(`Input will be: `+s),s}},{key:`updateCaretPos`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.updateCaretPosAction(e,t);this.dispatch((function(e){e.setCaretPosition(n)}))}},{key:`updateCaretPosAction`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=this.getOptions(),r=this.getCaretPosition();return r!=null&&(t?r>0&&(r-=e):r+=e),n.debug&&console.log(`Caret at:`,r),r}},{key:`addStringAt`,value:function(e,t){var n,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e.length,a=arguments.length>4&&arguments[4]!==void 0&&arguments[4];return r||r===0?(n=[e.slice(0,r),t,e.slice(i)].join(``),this.isMaxLengthReached()||a&&this.updateCaretPos(t.length)):n=e+t,n}},{key:`removeAt`,value:function(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e.length,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(n===0&&r===0)return e;if(n===r){var a=/([\uD800-\uDBFF][\uDC00-\uDFFF])/g;n&&n>=0?e.substring(n-2,n).match(a)?(t=e.substr(0,n-2)+e.substr(n),i&&this.updateCaretPos(2,!0)):(t=e.substr(0,n-1)+e.substr(n),i&&this.updateCaretPos(1,!0)):e.slice(-2).match(a)?(t=e.slice(0,-2),i&&this.updateCaretPos(2,!0)):(t=e.slice(0,-1),i&&this.updateCaretPos(1,!0))}else t=e.slice(0,n)+e.slice(r),i&&this.dispatch((function(e){e.setCaretPosition(n)}));return t}},{key:`removeForwardsAt`,value:function(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:e.length,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,i=arguments.length>3&&arguments[3]!==void 0&&arguments[3];return e!=null&&e.length&&n!==null?(n===r?t=e.substring(n,n+2).match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g)?e.substr(0,n)+e.substr(n+2):e.substr(0,n)+e.substr(n+1):(t=e.slice(0,n)+e.slice(r),i&&this.dispatch((function(e){e.setCaretPosition(n)}))),t):e}},{key:`handleMaxLength`,value:function(e,t){var n=this.getOptions(),r=n.maxLength,i=e[n.inputName||`default`],a=t.length-1>=r;if(t.length<=i.length)return!1;if(Number.isInteger(r))return n.debug&&console.log(`maxLength (num) reached:`,a),a?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1);if(s(r)===`object`){var o=t.length-1>=r[n.inputName||`default`];return n.debug&&console.log(`maxLength (obj) reached:`,o),o?(this.maxLengthReached=!0,!0):(this.maxLengthReached=!1,!1)}}},{key:`isMaxLengthReached`,value:function(){return!!this.maxLengthReached}},{key:`isTouchDevice`,value:function(){return`ontouchstart`in window||navigator.maxTouchPoints}},{key:`pointerEventsSupported`,value:function(){return!!window.PointerEvent}},{key:`camelCase`,value:function(e){return e?e.toLowerCase().trim().split(/[.\-_\s]/g).reduce((function(e,t){return t.length?e+t[0].toUpperCase()+t.slice(1):e})):``}},{key:`chunkArray`,value:function(e,t){return i(Array(Math.ceil(e.length/t))).map((function(n,r){return e.slice(t*r,t+t*r)}))}},{key:`escapeRegex`,value:function(e){return e.replace(/[-\/\\^$*+?.()|[\]{}]/g,`\\$&`)}},{key:`getRtlOffset`,value:function(e,t){var n=e,r=t.indexOf(`‫`);return r=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o,s=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){c=!0,o=e},f:function(){try{s||n.return==null||n.return()}finally{if(c)throw o}}}}(Object.getOwnPropertyNames(e.prototype));try{for(r.s();!(n=r.n()).done;){var i=n.value;i===`constructor`||i===`bindMethods`||(t[i]=t[i].bind(t))}}catch(e){r.e(e)}finally{r.f()}}}],t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();l(d,`noop`,(function(){}));var f=d;function p(e){return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(e,t){for(var n=0;n1?t?.toLowerCase():t}},{key:`keyCodeToKey`,value:function(e){return{8:`Backspace`,9:`Tab`,13:`Enter`,16:`Shift`,17:`Ctrl`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Esc`,32:`Space`,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,48:`0`,49:`1`,50:`2`,51:`3`,52:`4`,53:`5`,54:`6`,55:`7`,56:`8`,57:`9`,65:`A`,66:`B`,67:`C`,68:`D`,69:`E`,70:`F`,71:`G`,72:`H`,73:`I`,74:`J`,75:`K`,76:`L`,77:`M`,78:`N`,79:`O`,80:`P`,81:`Q`,82:`R`,83:`S`,84:`T`,85:`U`,86:`V`,87:`W`,88:`X`,89:`Y`,90:`Z`,91:`Meta`,96:`Numpad0`,97:`Numpad1`,98:`Numpad2`,99:`Numpad3`,100:`Numpad4`,101:`Numpad5`,102:`Numpad6`,103:`Numpad7`,104:`Numpad8`,105:`Numpad9`,106:`NumpadMultiply`,107:`NumpadAdd`,109:`NumpadSubtract`,110:`NumpadDecimal`,111:`NumpadDivide`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`}[e]||``}}],t&&m(e.prototype,t),n&&m(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}();function v(e){return v=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},v(e)}function y(e,t){for(var n=0;n0&&arguments[0]!==void 0?arguments[0]:r())},c.appendChild(t)}));var l=a>0,u=document.createElement(`div`);u.classList.add(`hg-candidate-box-prev`),l&&u.classList.add(`hg-candidate-box-btn-active`);var d=function(){l&&n.renderPage({candidateListPages:r,targetElement:i,pageIndex:a-1,nbPages:o,onItemSelected:s})};this.options.useTouchEvents?u.ontouchstart=d:u.onclick=d,this.candidateBoxElement.appendChild(u),this.candidateBoxElement.appendChild(c);var f=ae.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:e;this.caretPosition=e,this.caretPositionEnd=t}},{key:`getInputCandidates`,value:function(e){var t=this,n=this.options,r=n.layoutCandidates,i=n.layoutCandidatesCaseSensitiveMatch;if(!r||T(r)!==`object`)return{};var a=Object.keys(r).filter((function(n){var r=e.substring(0,t.getCaretPositionEnd()||0)||e,a=RegExp(`${t.utilities.escapeRegex(n)}\$`,i?`g`:`gi`);return!!C(r.matchAll(a)).length}));if(a.length>1){var o=a.sort((function(e,t){return t.length-e.length}))[0];return{candidateKey:o,candidateValue:r[o]}}if(a.length){var s=a[0];return{candidateKey:s,candidateValue:r[s]}}return{}}},{key:`showCandidatesBox`,value:function(e,t,n){var r=this;this.candidateBox&&this.candidateBox.show({candidateValue:t,targetElement:n,onSelect:function(t,n){var i=r.options,a=i.layoutCandidatesCaseSensitiveMatch,o=i.disableCandidateNormalization,s=i.enableLayoutCandidatesKeyPress,c=t;o||(c=t.normalize(`NFD`)),typeof r.options.beforeInputUpdate==`function`&&r.options.beforeInputUpdate(r);var l=r.getInput(r.options.inputName,!0),u=r.getCaretPositionEnd()||0,d=l.substring(0,u||0)||l,f=RegExp(`${r.utilities.escapeRegex(e)}\$`,a?`g`:`gi`),p=d.replace(f,c),m=l.replace(d,p),h=p.length-d.length,g=(u||l.length)+h;g<0&&(g=0),r.setInput(m,r.options.inputName,!0),r.setCaretPosition(g),s&&typeof r.options.onKeyPress==`function`&&r.options.onKeyPress(t,n),typeof r.options.onChange==`function`&&r.options.onChange(r.getInput(r.options.inputName,!0),n),typeof r.options.onChangeAll==`function`&&r.options.onChangeAll(r.getAllInputs(),n)}})}},{key:`handleButtonClicked`,value:function(e,t){var n=this.options,r=n.inputName,i=r===void 0?this.defaultName:r,a=n.debug;if(e!==`{//}`){this.input[i]||(this.input[i]=``),typeof this.options.beforeInputUpdate==`function`&&this.options.beforeInputUpdate(this);var o=this.utilities.getUpdatedInput(e,this.input[i],this.caretPosition,this.caretPositionEnd);if(this.utilities.isStandardButton(e)&&this.activeInputElement&&this.input[i]&&this.input[i]===o&&this.caretPosition===0&&this.caretPositionEnd===o.length)return this.setInput(``,this.options.inputName,!0),this.setCaretPosition(0),this.activeInputElement.value=``,this.activeInputElement.setSelectionRange(0,0),void this.handleButtonClicked(e,t);if(typeof this.options.onKeyPress==`function`&&this.options.onKeyPress(e,t),this.input[i]!==o&&(!this.options.inputPattern||this.options.inputPattern&&this.inputPatternIsValid(o))){if(this.options.maxLength&&this.utilities.handleMaxLength(this.input,o))return;var s=this.utilities.getUpdatedInput(e,this.input[i],this.caretPosition,this.caretPositionEnd,!0);if(this.setInput(s,this.options.inputName,!0),a&&console.log(`Input changed:`,this.getAllInputs()),this.options.debug&&console.log(`Caret at: `,this.getCaretPosition(),this.getCaretPositionEnd(),`(${this.keyboardDOMClass})`,t?.type),this.options.syncInstanceInputs&&this.syncInstanceInputs(),typeof this.options.onChange==`function`&&this.options.onChange(this.getInput(this.options.inputName,!0),t),typeof this.options.onChangeAll==`function`&&this.options.onChangeAll(this.getAllInputs(),t),t!=null&&t.target&&this.options.enableLayoutCandidates){var c,l=this.getInputCandidates(o),u=l.candidateKey,d=l.candidateValue;u&&d?this.showCandidatesBox(u,d,this.keyboardDOM):(c=this.candidateBox)==null||c.destroy()}}this.caretPositionEnd&&this.caretPosition!==this.caretPositionEnd&&(this.setCaretPosition(this.caretPositionEnd,this.caretPositionEnd),this.activeInputElement&&this.activeInputElement.setSelectionRange(this.caretPositionEnd,this.caretPositionEnd),this.options.debug&&console.log(`Caret position aligned`,this.caretPosition)),a&&console.log(`Key pressed:`,e)}}},{key:`getMouseHold`,value:function(){return this.isMouseHold}},{key:`setMouseHold`,value:function(e){this.options.syncInstanceInputs?this.dispatch((function(t){t.isMouseHold=e})):this.isMouseHold=e}},{key:`handleButtonMouseDown`,value:function(e,t){var n=this;t&&(this.options.preventMouseDownDefault&&t.preventDefault(),this.options.stopMouseDownPropagation&&t.stopPropagation(),t.target.classList.add(this.activeButtonClass)),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdTimeout&&clearTimeout(this.holdTimeout),this.setMouseHold(!0),this.options.disableButtonHold||(this.holdTimeout=window.setTimeout((function(){(n.getMouseHold()&&(!e.includes(`{`)&&!e.includes(`}`)||e===`{delete}`||e===`{backspace}`||e===`{bksp}`||e===`{space}`||e===`{tab}`)||e===`{arrowright}`||e===`{arrowleft}`||e===`{arrowup}`||e===`{arrowdown}`)&&(n.options.debug&&console.log(`Button held:`,e),n.handleButtonHold(e)),clearTimeout(n.holdTimeout)}),500))}},{key:`handleButtonMouseUp`,value:function(e,t){var n=this;t&&(this.options.preventMouseUpDefault&&t.preventDefault&&t.preventDefault(),this.options.stopMouseUpPropagation&&t.stopPropagation&&t.stopPropagation(),!(t.target===this.keyboardDOM||t.target&&this.keyboardDOM.contains(t.target)||this.candidateBox&&this.candidateBox.candidateBoxElement&&(t.target===this.candidateBox.candidateBoxElement||t.target&&this.candidateBox.candidateBoxElement.contains(t.target)))&&this.candidateBox&&this.candidateBox.destroy()),this.recurseButtons((function(e){e.classList.remove(n.activeButtonClass)})),this.setMouseHold(!1),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),e&&typeof this.options.onKeyReleased==`function`&&this.options.onKeyReleased(e,t)}},{key:`handleKeyboardContainerMouseDown`,value:function(e){this.options.preventMouseDownDefault&&e.preventDefault()}},{key:`handleButtonHold`,value:function(e){var t=this;this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdInteractionTimeout=window.setTimeout((function(){t.getMouseHold()?(t.handleButtonClicked(e),t.handleButtonHold(e)):clearTimeout(t.holdInteractionTimeout)}),100)}},{key:`syncInstanceInputs`,value:function(){var e=this;this.dispatch((function(t){t.replaceInput(e.input),t.setCaretPosition(e.caretPosition,e.caretPositionEnd)}))}},{key:`clearInput`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName;this.input[e]=``,this.setCaretPosition(0),this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:`getInput`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName,t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.options.syncInstanceInputs&&!t&&this.syncInstanceInputs(),this.options.rtl?`‫`+this.input[e].replace(`‫`,``).replace(`‬`,``)+`‬`:this.input[e]}},{key:`getAllInputs`,value:function(){var e=this,t={};return Object.keys(this.input).forEach((function(n){t[n]=e.getInput(n,!0)})),t}},{key:`setInput`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.inputName||this.defaultName,n=arguments.length>2?arguments[2]:void 0;this.input[t]=e,!n&&this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:`replaceInput`,value:function(e){this.input=e}},{key:`setOptions`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=this.changedOptions(e);this.options=Object.assign(this.options,e),t.length&&(this.options.debug&&console.log(`changedOptions`,t),this.onSetOptions(t),this.render())}},{key:`changedOptions`,value:function(e){var t=this;return Object.keys(e).filter((function(n){return JSON.stringify(e[n])!==JSON.stringify(t.options[n])}))}},{key:`onSetOptions`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];e.includes(`layoutName`)&&this.candidateBox&&this.candidateBox.destroy(),(e.includes(`layoutCandidatesPageSize`)||e.includes(`layoutCandidates`))&&this.candidateBox&&(this.candidateBox.destroy(),this.candidateBox=new S({utilities:this.utilities,options:this.options}))}},{key:`resetRows`,value:function(){this.keyboardRowsDOM&&this.keyboardRowsDOM.remove(),this.keyboardDOM.className=this.keyboardDOMClass,this.keyboardDOM.setAttribute(`data-skInstance`,this.currentInstanceName),this.buttonElements={}}},{key:`dispatch`,value:function(e){if(!window.SimpleKeyboardInstances)throw console.warn(`SimpleKeyboardInstances is not defined. Dispatch cannot be called.`),Error(`INSTANCES_VAR_ERROR`);return Object.keys(window.SimpleKeyboardInstances).forEach((function(t){e(window.SimpleKeyboardInstances[t],t)}))}},{key:`addButtonTheme`,value:function(e,t){var n=this;t&&e&&(e.split(` `).forEach((function(r){t.split(` `).forEach((function(t){n.options.buttonTheme||(n.options.buttonTheme=[]);var i=!1;n.options.buttonTheme.map((function(e){if(e!=null&&e.class.split(` `).includes(t)){i=!0;var n=e.buttons.split(` `);n.includes(r)||(i=!0,n.push(r),e.buttons=n.join(` `))}return e})),i||n.options.buttonTheme.push({class:t,buttons:e})}))})),this.render())}},{key:`removeButtonTheme`,value:function(e,t){var n=this;if(!e&&!t)return this.options.buttonTheme=[],void this.render();e&&Array.isArray(this.options.buttonTheme)&&this.options.buttonTheme.length&&(e.split(` `).forEach((function(e){var r;(r=n.options)==null||(r=r.buttonTheme)==null||r.map((function(r,i){if(r&&t&&t.includes(r.class)||!t){var a,o=r?.buttons.split(` `).filter((function(t){return t!==e}));r&&o!=null&&o.length?r.buttons=o.join(` `):((a=n.options.buttonTheme)==null||a.splice(i,1),r=null)}return r}))})),this.render())}},{key:`getButtonElement`,value:function(e){var t,n=this.buttonElements[e];return n&&(t=n.length>1?n:n[0]),t}},{key:`inputPatternIsValid`,value:function(e){var t,n=this.options.inputPattern;if((t=n instanceof RegExp?n:n[this.options.inputName||this.defaultName])&&e){var r=t.test(e);return this.options.debug&&console.log(`inputPattern ("${t}"): ${r?`passed`:`did not pass!`}`),r}return!0}},{key:`setEventListeners`,value:function(){if(this.isFirstKeyboardInstance||!this.allKeyboardInstances){this.options.debug&&console.log(`Caret handling started (${this.keyboardDOMClass})`);var e=this.options.physicalKeyboardHighlightPreventDefault,t=e!==void 0&&e;document.addEventListener(`keyup`,this.handleKeyUp,t),document.addEventListener(`keydown`,this.handleKeyDown,t),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`touchend`,this.handleTouchEnd),this.options.updateCaretOnSelectionChange&&document.addEventListener(`selectionchange`,this.handleSelectionChange),document.addEventListener(`select`,this.handleSelect)}}},{key:`handleKeyUp`,value:function(e){this.caretEventHandler(e),this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyUp(e)}},{key:`handleKeyDown`,value:function(e){this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyDown(e)}},{key:`handleMouseUp`,value:function(e){this.caretEventHandler(e)}},{key:`handleTouchEnd`,value:function(e){this.caretEventHandler(e)}},{key:`handleSelect`,value:function(e){this.caretEventHandler(e)}},{key:`handleSelectionChange`,value:function(e){navigator.userAgent.includes(`Firefox`)||this.caretEventHandler(e)}},{key:`caretEventHandler`,value:function(e){var t,n=this;e.target.tagName&&(t=e.target.tagName.toLowerCase()),this.dispatch((function(r){var i=e.target===r.keyboardDOM||e.target&&r.keyboardDOM.contains(e.target);if(n.options.syncInstanceInputs&&Array.isArray(e.path)&&(i=e.path.some((function(e){var t;return e==null||(t=e.hasAttribute)==null?void 0:t.call(e,`data-skInstance`)}))),(t===`textarea`||t===`input`&&[`text`,`search`,`url`,`tel`,`password`].includes(e.target.type))&&!r.options.disableCaretPositioning){var a=e.target.selectionStart,o=e.target.selectionEnd;r.options.rtl&&(a=r.utilities.getRtlOffset(a,r.getInput()),o=r.utilities.getRtlOffset(o,r.getInput())),r.setCaretPosition(a,o),r.activeInputElement=e.target,r.options.debug&&console.log(`Caret at: `,r.getCaretPosition(),r.getCaretPositionEnd(),e&&e.target.tagName.toLowerCase(),`(${r.keyboardDOMClass})`,e?.type)}else !r.options.disableCaretPositioning&&i||e?.type===`selectionchange`||(r.setCaretPosition(null),r.activeInputElement=null,r.options.debug&&console.log(`Caret position reset due to "${e?.type}" event`,e))}))}},{key:`recurseButtons`,value:function(e){var t=this;e&&Object.keys(this.buttonElements).forEach((function(n){return t.buttonElements[n].forEach(e)}))}},{key:`destroy`,value:function(){this.options.debug&&console.log(`Destroying simple-keyboard instance: ${this.currentInstanceName}`);var e=this.options.physicalKeyboardHighlightPreventDefault,t=e!==void 0&&e;document.removeEventListener(`keyup`,this.handleKeyUp,t),document.removeEventListener(`keydown`,this.handleKeyDown,t),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`touchend`,this.handleTouchEnd),document.removeEventListener(`select`,this.handleSelect),this.options.updateCaretOnSelectionChange&&document.removeEventListener(`selectionchange`,this.handleSelectionChange),document.onpointerup=null,document.ontouchend=null,document.ontouchcancel=null,document.onmouseup=null,this.recurseButtons((function(e){e&&=(e.onpointerdown=null,e.onpointerup=null,e.onpointercancel=null,e.ontouchstart=null,e.ontouchend=null,e.ontouchcancel=null,e.onclick=null,e.onmousedown=null,e.onmouseup=null,e.remove(),null)})),this.keyboardDOM.onpointerdown=null,this.keyboardDOM.ontouchstart=null,this.keyboardDOM.onmousedown=null,this.resetRows(),this.candidateBox&&=(this.candidateBox.destroy(),null),this.activeInputElement=null,this.keyboardDOM.removeAttribute(`data-skInstance`),this.keyboardDOM.innerHTML=``,window.SimpleKeyboardInstances[this.currentInstanceName]=null,delete window.SimpleKeyboardInstances[this.currentInstanceName],this.initialized=!1}},{key:`getButtonThemeClasses`,value:function(e){var t=this.options.buttonTheme,n=[];return Array.isArray(t)&&t.forEach((function(t){if(t&&t.class&&typeof t.class==`string`&&t.buttons&&typeof t.buttons==`string`){var r=t.class.split(` `);t.buttons.split(` `).includes(e)&&(n=[].concat(C(n),C(r)))}else console.warn(`Incorrect "buttonTheme". Please check the documentation.`,t)})),n}},{key:`setDOMButtonAttributes`,value:function(e,t){var n=this.options.buttonAttributes;Array.isArray(n)&&n.forEach((function(n){n.attribute&&typeof n.attribute==`string`&&n.value&&typeof n.value==`string`?n.buttons&&typeof n.buttons==`string`?n.buttons.split(` `).includes(e)&&t(n.attribute,n.value):t(n.attribute,n.value):console.warn(`Incorrect "buttonAttributes". Please check the documentation.`,n)}))}},{key:`onTouchDeviceDetected`,value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:`disableContextualWindow`,value:function(){window.oncontextmenu=function(e){var t;if((t=e.target.classList)!=null&&t.contains(`hg-button`))return e.preventDefault(),e.stopPropagation(),!1}}},{key:`processAutoTouchEvents`,value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log(`autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`))}},{key:`onInit`,value:function(){this.options.debug&&console.log(`${this.keyboardDOMClass} Initialized`),this.setEventListeners(),typeof this.options.onInit==`function`&&this.options.onInit(this)}},{key:`beforeFirstRender`,value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),typeof this.options.beforeFirstRender==`function`&&this.options.beforeFirstRender(this),this.isFirstKeyboardInstance&&this.utilities.pointerEventsSupported()&&!this.options.useTouchEvents&&!this.options.useMouseEvents&&this.options.debug&&console.log(`Using PointerEvents as it is supported by this browser`),this.options.useTouchEvents&&this.options.debug&&console.log(`useTouchEvents has been enabled. Only touch events will be used.`)}},{key:`beforeRender`,value:function(){typeof this.options.beforeRender==`function`&&this.options.beforeRender(this)}},{key:`onRender`,value:function(){typeof this.options.onRender==`function`&&this.options.onRender(this)}},{key:`onModulesLoaded`,value:function(){typeof this.options.onModulesLoaded==`function`&&this.options.onModulesLoaded(this)}},{key:`loadModules`,value:function(){var e=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach((function(t){var n=e.utilities.isConstructor(t)?new t(e):t(e);n.init&&n.init(e)})),this.keyboardPluginClasses=`modules-loaded`,this.render(),this.onModulesLoaded())}},{key:`getModuleProp`,value:function(e,t){return!!this.modules[e]&&this.modules[e][t]}},{key:`getModulesList`,value:function(){return Object.keys(this.modules)}},{key:`parseRowDOMContainers`,value:function(e,t,n,r){var i=this,a=Array.from(e.children),o=0;return a.length&&n.forEach((function(n,s){var c=r[s];if(!(c&&c>n))return!1;var l=n-o,u=c-o,d=document.createElement(`div`);d.className+=`hg-button-container`;var f=`${i.options.layoutName}-r${t}c${s}`;d.setAttribute(`data-skUID`,f);var p=a.splice(l,u-l+1);o+=u-l,p.forEach((function(e){return d.appendChild(e)})),a.splice(l,0,d),e.innerHTML=``,a.forEach((function(t){return e.appendChild(t)})),i.options.debug&&console.log(`rowDOMContainer`,p,l,u,o+1)})),e}},{key:`render`,value:function(){var e=this;this.resetRows(),this.initialized||this.beforeFirstRender(),this.beforeRender();var t=`hg-layout-${this.options.layoutName}`,n=this.options.layout||{default:["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",`{tab} q w e r t y u i o p [ ] \\`,`{lock} a s d f g h j k l ; ' {enter}`,`{shift} z x c v b n m , . / {shift}`,`.com @ {space}`],shift:[`~ ! @ # $ % ^ & * ( ) _ + {bksp}`,`{tab} Q W E R T Y U I O P { } |`,`{lock} A S D F G H J K L : " {enter}`,`{shift} Z X C V B N M < > ? {shift}`,`.com @ {space}`]},r=this.options.useTouchEvents||!1,i=r?`hg-touch-events`:``,a=this.options.useMouseEvents||!1,o=this.options.disableRowButtonContainers;this.keyboardDOM.className=this.getKeyboardClassString(this.options.theme,t,this.keyboardPluginClasses,i),this.keyboardDOM.setAttribute(`data-skInstance`,this.currentInstanceName),this.keyboardRowsDOM=document.createElement(`div`),this.keyboardRowsDOM.className=`hg-rows`,n[this.options.layoutName||this.defaultName].forEach((function(t,n){var i=t.split(` `);e.options.excludeFromLayout&&e.options.excludeFromLayout[e.options.layoutName||e.defaultName]&&(i=i.filter((function(t){return e.options.excludeFromLayout&&!e.options.excludeFromLayout[e.options.layoutName||e.defaultName].includes(t)})));var s=document.createElement(`div`);s.className+=`hg-row`;var c=[],l=[];i.forEach((function(t,i){var u,d=!o&&typeof t==`string`&&t.length>1&&t.indexOf(`[`)===0,f=!o&&typeof t==`string`&&t.length>1&&t.indexOf(`]`)===t.length-1;d&&(c.push(i),t=t.replace(/\[/g,``)),f&&(l.push(i),t=t.replace(/\]/g,``));var p=e.utilities.getButtonClass(t),m=e.utilities.getButtonDisplayName(t,e.options.display,e.options.mergeDisplay),h=e.options.useButtonTag?`button`:`div`,g=document.createElement(h);g.className+=`hg-button ${p}`,(u=g.classList).add.apply(u,C(e.getButtonThemeClasses(t))),e.setDOMButtonAttributes(t,(function(e,t){g.setAttribute(e,t)})),e.activeButtonClass=`hg-activeButton`,!e.utilities.pointerEventsSupported()||r||a?r?(g.ontouchstart=function(n){e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.ontouchend=function(n){e.handleButtonMouseUp(t,n)},g.ontouchcancel=function(n){e.handleButtonMouseUp(t,n)}):(g.onclick=function(n){e.setMouseHold(!1),typeof e.options.onKeyReleased==`function`||e.options.useMouseEvents&&e.options.clickOnMouseDown||e.handleButtonClicked(t,n)},g.onmousedown=function(n){(typeof e.options.onKeyReleased==`function`||e.options.useMouseEvents&&e.options.clickOnMouseDown)&&!e.isMouseHold&&e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.onmouseup=function(n){e.handleButtonMouseUp(t,n)}):(g.onpointerdown=function(n){e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.onpointerup=function(n){e.handleButtonMouseUp(t,n)},g.onpointercancel=function(n){e.handleButtonMouseUp(t,n)}),g.setAttribute(`data-skBtn`,t);var _=`${e.options.layoutName}-r${n}b${i}`;g.setAttribute(`data-skBtnUID`,_);var v=document.createElement(`span`);v.innerHTML=m,g.appendChild(v),e.buttonElements[t]||(e.buttonElements[t]=[]),e.buttonElements[t].push(g),s.appendChild(g)})),s=e.parseRowDOMContainers(s,n,c,l),e.keyboardRowsDOM.appendChild(s)})),this.keyboardDOM.appendChild(this.keyboardRowsDOM),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||r||a?r?(document.ontouchend=function(t){return e.handleButtonMouseUp(void 0,t)},document.ontouchcancel=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.ontouchstart=function(t){return e.handleKeyboardContainerMouseDown(t)}):r||(document.onmouseup=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.onmousedown=function(t){return e.handleKeyboardContainerMouseDown(t)}):(document.onpointerup=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.onpointerdown=function(t){return e.handleKeyboardContainerMouseDown(t)}),this.onInit())}}],t&&D(e.prototype,t),n&&D(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}(),j=A;return r}()},442:function(t){t.exports=e}},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e].call(a.exports,a,a.exports,r),a.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){r.r(i),r.d(i,{KeyboardReact:function(){return u},default:function(){return d}}),r(981);var e=r(442),t=r(548),n=r.n(t);function a(e){return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t{e?.(t)},[t,e]);let d=(0,y.useCallback)(e=>{if(a.current)return;let t=e.target;if(!t.closest(`[data-vkb="false"]`)){if(t instanceof HTMLInputElement){if(!sQe.has(t.type))return}else if(!(t instanceof HTMLTextAreaElement))return;c.current=t,n(!0),s(`default`),l.current?.setInput?.(c.current.value),setTimeout(()=>{(t.closest(`.bg-zinc-800, .rounded-lg, [data-vkb-group]`)??t).scrollIntoView({behavior:`smooth`,block:`nearest`})},100)}},[]),f=(0,y.useCallback)(()=>{setTimeout(()=>{let e=document.activeElement;e&&(u.current?.contains(e)||e===c.current)||(n(!1),c.current=null)},150)},[]);(0,y.useEffect)(()=>(document.addEventListener(`focusin`,d),document.addEventListener(`focusout`,f),()=>{document.removeEventListener(`focusin`,d),document.removeEventListener(`focusout`,f)}),[d,f]);let p=(0,y.useCallback)(()=>{a.current=!0,i(!0),c.current?.blur(),c.current=null,setTimeout(()=>{n(!1),i(!1),a.current=!1},400)},[]),m=(0,y.useCallback)(e=>{let t=c.current;if(t){if(e===`{shift}`){s(e=>e==="default"?`shift`:`default`);return}if(e===`{lock}`){s(e=>e==="default"?`shift`:`default`);return}if(e===`{close}`){p();return}e===`{bksp}`?W9(t,t.value.slice(0,-1)):e===`{space}`?W9(t,t.value+` `):(W9(t,t.value+e),o===`shift`&&s(`default`)),t.focus(),l.current?.setInput?.(t.value)}},[o,p]);return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[9998] bg-transparent`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),r||p()},onTouchStart:e=>{e.preventDefault(),e.stopPropagation(),r||p()},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),!r&&(0,K.jsx)(`div`,{ref:u,className:`relative z-[9999] shrink-0`,onMouseDown:e=>e.preventDefault(),onTouchStart:e=>{e.target.closest(`.hg-button`)||e.preventDefault()},children:(0,K.jsx)(oQe.default,{keyboardRef:e=>{l.current=e},layoutName:o,onKeyPress:m,theme:`simple-keyboard vkb-theme`,layout:{default:[`1 2 3 4 5 6 7 8 9 0 {bksp}`,`q w e r t y u i o p`,`{lock} a s d f g h j k l`,`{shift} z x c v b n m . @`,`{space} {close}`],shift:[`! @ # $ % ^ & * ( ) {bksp}`,`Q W E R T Y U I O P`,`{lock} A S D F G H J K L`,`{shift} Z X C V B N M , _`,`{space} {close}`]},display:{"{bksp}":`⌫`,"{close}":`✕ Close`,"{shift}":`⇧`,"{lock}":`⇪`,"{space}":` `}})})]}):null}function lQe(){Zd();let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(100),{i18n:o}=W(),s=$n(),c=Xn(),l=aQe(),{setViewportSuppressed:u}=Td();(0,y.useEffect)(()=>(u(!0),()=>u(!1)),[u]);let{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings});(0,y.useEffect)(()=>{d?.language&&d.language!==o.language&&o.changeLanguage(d.language)},[d?.language,o]);let{data:f=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:3e4}),p=f[0],m=l.deviceOnline||!!p?.online,h=(0,y.useMemo)(()=>({...l,deviceOnline:m}),[l,m]),g=(0,y.useRef)(!1);(0,y.useEffect)(()=>{p&&!g.current&&(a(p.display_brightness),g.current=!0)},[p]),(0,y.useEffect)(()=>{let e=document.documentElement,t=e.classList.contains(`dark`);return e.classList.add(`dark`),()=>{t||e.classList.remove(`dark`)}},[]);let{data:_}=q({queryKey:[`spoolbuddy-update-check`,p?.device_id],queryFn:()=>p?od.checkDaemonUpdate(p.device_id):Promise.resolve(null),enabled:!!p,refetchInterval:300*1e3,staleTime:0}),v=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!m){let e=`SpoolBuddy device disconnected`;r({type:`warning`,message:e}),v.current=e}else if(_?.update_available&&_.latest_version){let e=`Update available: v${_.latest_version}`;r({type:`info`,message:e}),v.current=e}else v.current&&=(r(null),null)},[m,_?.update_available,_?.latest_version]);let b=!!(l.matchedSpool||l.unknownTagUid||l.unknownTrayUuid),x=(0,y.useRef)(!1);(0,y.useEffect)(()=>{b&&!x.current&&c.pathname!==`/spoolbuddy`&&s(`/spoolbuddy`),x.current=b},[b,c.pathname,s]);let{data:S=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),C=_o({queries:S.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:1e4,select:e=>({connected:e?.connected})}))}),w=(0,y.useMemo)(()=>S.filter((e,t)=>C[t]?.data?.connected),[S,C]),T=(0,y.useRef)(null),E=(0,y.useRef)(!1),D=(0,y.useRef)(null),O=(0,y.useCallback)(e=>{T.current={x:e.touches[0].clientX,y:e.touches[0].clientY},E.current=!1},[]),k=(0,y.useCallback)(n=>{if(!T.current)return;let r=n.changedTouches[0].clientX-T.current.x,i=n.changedTouches[0].clientY-T.current.y,a=T.current.y;if(T.current=null,E.current=!1,i>=50&&Math.abs(i)>Math.abs(r)&&a<120){N(!0);return}if(w.length<2||Math.abs(r)<50||Math.abs(i)>Math.abs(r))return;let o=w.findIndex(t=>t.id===e);t(w[r<0?(o+1)%w.length:(o-1+w.length)%w.length].id)},[w,e,t]);(0,y.useEffect)(()=>{let e=D.current;if(!e)return;let t=e=>{if(!T.current)return;let t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);if(E.current){e.preventDefault();return}t>10&&t>n&&(E.current=!0,e.preventDefault())};return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[]);let[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{ref:D,"data-spoolbuddy-kiosk":!0,className:`w-screen h-screen bg-bambu-dark text-white flex flex-col overflow-hidden`,style:{...i<100?{filter:`brightness(${i/100})`}:void 0,overscrollBehaviorX:`none`},onTouchStart:O,onTouchEnd:k,children:[(0,K.jsx)(`button`,{onClick:()=>N(!0),className:`w-full h-1.5 bg-bambu-dark-secondary flex justify-center items-center shrink-0 touch-none`,"aria-label":`Open quick menu`,children:(0,K.jsx)(`div`,{className:`w-8 h-0.5 rounded-full bg-zinc-600`})}),(0,K.jsx)(QZe,{selectedPrinterId:e,onPrinterChange:t,deviceOnline:m}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:(0,K.jsx)(kr,{context:{selectedPrinterId:e,setSelectedPrinterId:t,sbState:h,setAlert:r,displayBrightness:i,setDisplayBrightness:a}})}),!A&&(0,K.jsx)(tQe,{alert:n}),!A&&(0,K.jsx)(eQe,{}),(0,K.jsx)(cQe,{onVisibilityChange:j})]}),(0,K.jsx)(nQe,{isOpen:M,onClose:()=>N(!1),deviceId:p?.device_id??null,deviceOnline:m})]})}function G9({color:e,isEmpty:t,size:n=32}){return t?(0,K.jsx)(`div`,{className:`rounded-full border-2 border-dashed border-zinc-500 flex items-center justify-center`,style:{width:n,height:n},children:(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-zinc-600`})}):(0,K.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 32 32`,children:[(0,K.jsx)(`circle`,{cx:`16`,cy:`16`,r:`14`,fill:e,stroke:`white`,strokeWidth:`1.5`,strokeOpacity:`0.7`}),(0,K.jsx)(`circle`,{cx:`16`,cy:`16`,r:`11`,fill:e,style:{filter:`brightness(0.85)`}})]})}var uQe=`spoolbuddy-default-core-weight`;function dQe(){try{let e=localStorage.getItem(uQe);if(e){let t=parseInt(e,10);if(t>=0&&t<=500)return t}}catch{}return 250}function fQe({spool:e,scaleWeight:t,onClose:n,onSyncWeight:r,onAssignToAms:i,isAssigned:a,onUnassignFromAms:o}){let{t:s}=W(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(!1),f=qd(e.rgba),p=e.core_weight&&e.core_weight>0?e.core_weight:dQe(),m=t===null?null:Math.round(Math.max(0,t)),h=m===null?null:Math.round(Math.max(0,m-p)),g=Math.round(e.label_weight||1e3),_=h===null?null:Math.min(100,Math.round(h/g*100)),v=_===null?`#808080`:_>50?`#22c55e`:_>20?`#eab308`:`#ef4444`,b=Math.max(0,(e.label_weight||0)-(e.weight_used||0))+p,x=m===null?null:m-b,S=x===null?null:Math.abs(x)<=50,C=async()=>{if(t!==null){l(!0);try{await od.updateSpoolWeight(e.id,Math.round(t)),d(!0),r?.(),setTimeout(()=>d(!1),3e3)}catch(e){console.error(`Failed to sync weight:`,e)}finally{l(!1)}}};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-4 max-w-md`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsx)(G9,{color:f,isEmpty:!1,size:100}),_!==null&&(0,K.jsxs)(`div`,{className:`absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg`,style:{backgroundColor:v},children:[_,`%`]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]}),h!==null&&(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-3xl font-bold font-mono text-zinc-100`,children:[h,`g`]}),(0,K.jsxs)(`span`,{className:`text-sm text-zinc-500`,children:[`/ `,g,`g`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:s(`spoolbuddy.spool.remaining`,`Remaining`)}),(0,K.jsx)(`div`,{className:`mt-2 max-w-xs`,children:(0,K.jsx)(`div`,{className:`h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${_}%`,backgroundColor:v}})})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-4 w-full`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.grossWeight`,`Gross weight`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300`,children:m===null?`—`:`${m}g`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.spool.coreWeight`,`Core`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[p,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.spoolSize`,`Spool size`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[g,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.spool.scaleWeight`,`Scale`)}),m===null?(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`—`}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 font-mono ${S?`text-green-500`:`text-yellow-500`}`,children:[m,`g`,S?(0,K.jsx)(rs,{className:`w-3.5 h-3.5`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`button`,{onClick:C,className:`p-1 hover:bg-green-500/20 rounded transition-colors text-green-500`,title:s(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`),children:(0,K.jsx)(Ol,{className:`w-4 h-4`})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.tagId`,`Tag`)}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-zinc-400 truncate max-w-[120px]`,title:e.tag_uid||``,children:e.tag_uid?e.tag_uid.slice(-8):`—`})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[i&&(0,K.jsx)(`button`,{onClick:a?void 0:i,disabled:!!a,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px] disabled:opacity-50 disabled:cursor-not-allowed`,children:s(`spoolbuddy.modal.assignToAms`,`Assign to AMS`)}),o&&(0,K.jsxs)(`button`,{onClick:o,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-red-600/20 text-red-400 hover:bg-red-600/30 transition-colors min-h-[44px]`,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 inline mr-1`}),s(`inventory.unassignSpool`)]}),(0,K.jsx)(`button`,{onClick:C,disabled:t===null||c,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${u?`bg-green-600/20 text-green-400`:i?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600 disabled:opacity-40 disabled:cursor-not-allowed`:`bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed`}`,children:c?`...`:u?s(`spoolbuddy.dashboard.weightSynced`,`Synced!`):s(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`)}),n&&(0,K.jsx)(`button`,{onClick:n,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:s(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function pQe({tagUid:e,scaleWeight:t,coreWeight:n,onLinkSpool:r,onAddToInventory:i,onClose:a}){let{t:o}=W(),s=n??dQe(),c=t===null?null:Math.round(Math.max(0,t)),l=c===null?null:Math.round(Math.max(0,c-s));return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-5`,children:[(0,K.jsx)(`div`,{className:`w-20 h-20 rounded-2xl bg-green-500/15 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-10 h-10 text-green-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z`})})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:o(`spoolbuddy.dashboard.newTag`,`New Tag Detected`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500 font-mono mt-1`,children:e})]}),c!==null&&(0,K.jsxs)(`div`,{className:`text-sm text-zinc-400`,children:[(0,K.jsxs)(`span`,{className:`font-mono font-semibold`,children:[c,`g`]}),` `,o(`spoolbuddy.dashboard.onScale`,`on scale`),l!==null&&l>0&&(0,K.jsxs)(`span`,{className:`text-zinc-500`,children:[` • ~`,l,`g filament`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 justify-center`,children:[i&&(0,K.jsx)(`button`,{onClick:i,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:o(`spoolbuddy.modal.addToInventory`,`Add to Inventory`)}),r&&(0,K.jsxs)(`button`,{onClick:r,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 inline-block mr-1.5 -mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1`})}),o(`inventory.assignSpool`,`Assign Spool`)]}),a&&(0,K.jsx)(`button`,{onClick:a,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:o(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function mQe(e){return e?`#${e.slice(0,6)}`:`#808080`}function hQe(e){return!e.tray_type||e.tray_type===``}function gQe(e){if(e.tray_type)return null;let t=e.state??null;return t===9||t===10?`physical`:`reset`}function _Qe(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function vQe({className:e}){return(0,K.jsx)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{d:`M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z`,fill:`#C3C2C1`})})}function yQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 35 53`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z`,fill:`#C3C2C1`}),(0,K.jsx)(`path`,{d:`M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z`,fill:`#1F8FEB`})]})}function bQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z`,fill:`#1F8FEB`}),(0,K.jsx)(`path`,{d:`M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z`,fill:`#C3C2C1`})]})}function xQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function SQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`8`,width:`3`,height:`4.5`,fill:`#d4a017`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#d4a017`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function CQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:`#c62828`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#c62828`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function wQe({humidity:e,goodThreshold:t=40,fairThreshold:n=60}){let r,i;return e<=t?(r=`#22a352`,i=vQe):e<=n?(r=`#d4a017`,i=yQe):(r=`#c62828`,i=bQe),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(i,{className:`w-3 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums text-xs`,style:{color:r},children:[e,`%`]})]})}function TQe({temp:e,goodThreshold:t=28,fairThreshold:n=35}){let r,i;return e<=t?(r=`#22a352`,i=xQe):e<=n?(r=`#d4a017`,i=SQe):(r=`#c62828`,i=CQe),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(i,{className:`w-3 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums text-xs`,style:{color:r},children:[e,`°C`]})]})}function K9({side:e}){return(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 text-[9px] font-bold rounded`,style:{backgroundColor:`#1a4d2e`,color:`#00ae42`},children:e})}function EQe({tray:e,slotIndex:t,isActive:n,fillOverride:r,spoolmanFill:i,onClick:a}){let o=hQe(e),s=gQe(e),c=mQe(e.tray_color),l=e.remain!==null&&e.remain!==void 0&&e.remain>=0?e.remain:null,u=i??(r===0&&l!==null&&l>0?null:r)??l;return(0,K.jsxs)(`div`,{className:`relative flex flex-col items-center p-2.5 rounded-lg transition-all ${n?`ring-2 ring-bambu-green`:``} ${a?`cursor-pointer hover:bg-white/5`:``}`,onClick:a,title:a?`AMS Slot ${t+1}`:void 0,children:[(0,K.jsxs)(`div`,{className:`relative w-16 h-16 mb-1`,children:[o?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:c}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:c,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]}),n&&(0,K.jsx)(`div`,{className:`absolute -bottom-1 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-bambu-green rounded-full`})]}),(0,K.jsx)(`span`,{className:`text-sm text-white/70 truncate max-w-full`,title:s===`reset`?`Spool loaded — slot not configured`:void 0,children:o?s===`reset`?`?`:`Empty`:e.tray_type||`Unknown`}),!o&&u!==null&&u>=0&&(0,K.jsx)(`div`,{className:`w-full h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mt-1`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${u}%`,backgroundColor:Rf(u)}})}),(0,K.jsx)(`span`,{className:`absolute top-1 right-1 text-xs text-white/30`,children:t+1})]})}function DQe({unit:e,activeSlot:t,onConfigureSlot:n,isDualNozzle:r,nozzleSide:i,thresholds:a,fillOverrides:o,spoolmanFillOverrides:s}){let c=e.tray||[],l=e.is_ams_ht,u=l?1:4;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium text-base`,children:_Qe(e.id)}),r&&i&&(0,K.jsx)(K9,{side:i})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.temp!=null&&(0,K.jsx)(TQe,{temp:e.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair}),e.humidity!=null&&(0,K.jsx)(wQe,{humidity:e.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair})]})]}),(0,K.jsx)(`div`,{className:`grid ${l?`grid-cols-1 max-w-[100px] mx-auto`:`grid-cols-4`} gap-2`,children:Array.from({length:u}).map((r,i)=>{let a=c[i]||{id:i,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null};return(0,K.jsx)(EQe,{tray:a,slotIndex:i,isActive:t===i,fillOverride:o?.[`${e.id}-${i}`]??null,spoolmanFill:s?.[`${e.id}-${i}`]??null,onClick:n?()=>n(e.id,i,hQe(a)?null:a):void 0},i)})})]})}function q9(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function J9(e){return!e.tray_type||e.tray_type===``}function OQe(e){return e?`#${e.slice(0,6)}`:`#808080`}var Y9=e=>(e??``).trim().toUpperCase();function kQe(e,t){let n=Y9(e),r=Y9(t);return!n||!r?`none`:n===r?`exact`:r.includes(n)||n.includes(r)?`partial`:`none`}function AQe(e,t){let n=Y9(e),r=Y9(t);return!n||!r?!1:n===r}function jQe({isOpen:e,onClose:t,spool:n,printerId:r,spoolmanMode:i=!1}){let{t:a}=W(),o=no(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null);(0,y.useEffect)(()=>{e&&(c(null),u(null),f(!1),m(null),g(null))},[e]);let _=(0,y.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,y.useEffect)(()=>(e&&document.addEventListener(`keydown`,_),()=>document.removeEventListener(`keydown`,_)),[e,_]);let{data:v}=q({queryKey:[`printerStatus`,r],queryFn:()=>Q.getPrinterStatus(r),enabled:e&&r!==null,refetchInterval:5e3}),{data:b}=q({queryKey:[`printer`,r],queryFn:()=>Q.getPrinter(r),enabled:e&&r!==null}),{data:x}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),enabled:e,staleTime:300*1e3}),{data:S}=q({queryKey:[`spool-assignments`,r],queryFn:()=>Q.getAssignments(r),enabled:e&&r!==null,staleTime:30*1e3}),{data:C=[]}=q({queryKey:[`spoolman-slot-assignments`,r],queryFn:()=>Q.getSpoolmanSlotAssignments(r??void 0),enabled:e&&!!i&&r!==null,staleTime:30*1e3}),w=i?C.find(e=>e.spoolman_spool_id===n.id):void 0,T=(0,y.useMemo)(()=>{let e={};if(!S)return e;for(let t of S){let n=t.spool;if(n&&n.label_weight>0&&n.weight_used!=null){let r=Math.round(Math.max(0,n.label_weight-n.weight_used)/n.label_weight*100);e[`${t.ams_id}-${t.tray_id}`]=r}}return e},[S]),E=x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0,D=v?.connected??!1,O=(0,y.useMemo)(()=>v?.ams??[],[v?.ams]),k=(0,y.useMemo)(()=>O.filter(e=>!e.is_ams_ht),[O]),A=(0,y.useMemo)(()=>O.filter(e=>e.is_ams_ht),[O]),j=(0,y.useMemo)(()=>[...v?.vt_tray??[]].sort((e,t)=>(e.id??254)-(t.id??254)),[v?.vt_tray]),M=b?.nozzle_count===2||v?.temperatures?.nozzle_2!==void 0,N=(0,y.useRef)({});(0,y.useEffect)(()=>{v?.ams_extruder_map&&Object.keys(v.ams_extruder_map).length>0&&(N.current=v.ams_extruder_map)},[v?.ams_extruder_map]);let P=v?.ams_extruder_map&&Object.keys(v.ams_extruder_map).length>0?v.ams_extruder_map:N.current,F=(0,y.useCallback)(e=>{if(!M)return null;let t=P[String(e)],n=e>=128?e-128:e;return(t===void 0?n:t)===1?`L`:`R`},[M,P]),I=J({mutationFn:async({amsId:e,trayId:t})=>{if(!r)throw Error(`No printer selected`);return i?await Q.assignSpoolmanSlot({spoolman_spool_id:n.id,printer_id:r,ams_id:e,tray_id:t}):await Q.assignSpool({spool_id:n.id,printer_id:r,ams_id:e,tray_id:t})},onSuccess:e=>{u(`success`);let n=e&&`pending_config`in e&&e.pending_config;c(n?a(`spoolbuddy.modal.assignPendingInsert`,`Assigned. Slot will configure when you insert the spool.`):a(`spoolbuddy.modal.assignSuccess`,`Assigned!`)),o.invalidateQueries({queryKey:[`slotPresets`]}),o.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),o.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),setTimeout(()=>t(),n?2500:1500)},onError:e=>{u(`error`),c(e instanceof Error?e.message:a(`spoolbuddy.modal.assignError`,`Failed to assign spool.`))}}),L=I.isPending,R=(0,y.useCallback)((e,t)=>{if(e===254||e===255){let n=e===254?254:254+t;return j.find(e=>(e.id??254)===n)||null}return O.find(t=>t.id===e)?.tray?.find(e=>e.id===t)||null},[O,j]),z=(0,y.useCallback)((e,t)=>e<=3?`${q9(e)} ${a(`ams.slot`,`Slot`)} ${t+1}`:e>=128&&e<=135?q9(e):e===254?a(`printers.extL`,`Ext-L`):M?a(`printers.extR`,`Ext-R`):a(`printers.ext`,`Ext`),[a,M]),B=(0,y.useCallback)((e,t)=>{u(`info`),c(a(`spoolbuddy.modal.assigning`,`Configuring slot...`)),I.mutate({amsId:e,trayId:t})},[I,a]),V=(0,y.useCallback)((e,t)=>{if(!L){if(!x?.disable_filament_warnings){let r=R(e,t);if(r&&!J9(r)){let i=r.tray_sub_brands||r.tray_type||``,a=kQe(n.material,i),o=n.slicer_filament_name||n.slicer_filament,s=r.tray_type||``,c=AQe(o,s);if(a!==`exact`){let r;r=a===`none`&&!c?`material_profile`:a===`partial`&&!c?`partial_profile`:a===`none`?`material`:`partial`;let l=z(e,t);g({amsId:e,trayId:t}),m({type:r,spoolMaterial:n.material||``,trayMaterial:i||``,spoolProfile:o||void 0,trayProfile:s||void 0,location:l}),f(!0);return}}}B(e,t)}},[L,x?.disable_filament_warnings,n,R,z,B]),ee=(0,y.useCallback)(()=>{h&&(f(!1),m(null),B(h.amsId,h.trayId),g(null))},[h,B]),te=(0,y.useMemo)(()=>{let e=[];for(let t of A){let n=t.tray?.[0]||{id:0,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null},r=T[`${t.id}-0`]??null,i=n.remain!=null&&n.remain>=0?n.remain:null,a=r===0&&i!==null&&i>0?null:r;e.push({key:`ht-${t.id}`,label:q9(t.id),amsId:t.id,trayId:0,tray:n,isEmpty:J9(n),nozzleSide:F(t.id),effectiveFill:a??i})}for(let t of j){let n=t.id??254,r=n-254,i=T[`255-${r}`]??null,o=t.remain!=null&&t.remain>=0?t.remain:null,s=i===0&&o!==null&&o>0?null:i;e.push({key:`ext-${n}`,label:M?n===254?a(`printers.extL`,`Ext-L`):a(`printers.extR`,`Ext-R`):a(`printers.ext`,`Ext`),amsId:255,trayId:r,tray:t,isEmpty:J9(t),nozzleSide:M?n===254?`L`:`R`:null,effectiveFill:s??o})}return e},[A,j,M,a,F,T]);return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] bg-bambu-dark flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-zinc-800 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(`div`,{className:`w-7 h-7 rounded-full shrink-0`,style:Jd(n.rgba)}),(0,K.jsx)(`div`,{className:`min-w-0`,children:(0,K.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-100 truncate`,children:[a(`spoolbuddy.modal.assignToAmsTitle`,`Assign to AMS`),(0,K.jsxs)(`span`,{className:`font-normal text-zinc-500 ml-2`,children:[n.color_name||`Unknown`,` • `,n.brand,` `,n.material,n.subtype&&` ${n.subtype}`]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 ml-2 shrink-0`,children:[`#`,n.id]})]})})]}),(0,K.jsx)(`button`,{onClick:t,disabled:L,className:`p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 transition-colors shrink-0 disabled:opacity-50`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),s&&(0,K.jsxs)(`div`,{className:`mx-5 mt-3 p-3 rounded-lg flex items-center gap-3 border shrink-0 ${l===`info`?`bg-blue-500/10 border-blue-500/40`:l===`success`?`bg-green-500/10 border-green-500/40`:`bg-red-500/10 border-red-500/40`}`,children:[l===`info`&&(0,K.jsx)(X,{className:`w-4 h-4 text-blue-400 animate-spin shrink-0`}),l===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-green-400 shrink-0`}),l===`error`&&(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm ${l===`info`?`text-blue-300`:l===`success`?`text-green-300`:`text-red-300`}`,children:s})]}),(0,K.jsx)(`div`,{className:`flex-1 flex flex-col gap-3 p-4 min-h-0 overflow-y-auto`,children:!D&&r?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`text-center text-white/50`,children:(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:a(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)})})}):O.length===0&&j.length===0?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:a(`spoolbuddy.ams.noData`,`No AMS detected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:a(`spoolbuddy.ams.connectAms`,`Connect an AMS to see filament slots`)})]})}):(0,K.jsxs)(K.Fragment,{children:[k.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 flex-1 min-h-0`,children:k.map(e=>(0,K.jsx)(DQe,{unit:e,activeSlot:w?.ams_id===e.id?w.tray_id??null:null,onConfigureSlot:(t,n)=>V(e.id,n),isDualNozzle:M,nozzleSide:F(e.id),thresholds:E,fillOverrides:T},e.id))}),te.length>0&&(0,K.jsx)(`div`,{className:`flex gap-2 shrink-0`,children:te.map(({key:e,label:t,amsId:n,trayId:r,tray:i,isEmpty:a,nozzleSide:o,effectiveFill:s})=>{let c=OQe(i.tray_color);return(0,K.jsxs)(`div`,{onClick:()=>V(n,r),className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-2 ${w&&w.ams_id===n&&w.tray_id===r?`ring-2 ring-bambu-green`:``} ${L?`opacity-50 pointer-events-none`:``}`,children:[(0,K.jsx)(`div`,{className:`relative w-10 h-10 shrink-0`,children:a?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:c}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:c,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-white/50 font-medium`,children:t}),o&&(0,K.jsx)(K9,{side:o})]}),(0,K.jsx)(`div`,{className:`text-sm text-white/80 truncate`,children:a?`Empty`:i.tray_type||`?`})]}),!a&&s!=null&&s>=0&&(0,K.jsx)(`div`,{className:`w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden shrink-0 flex flex-col-reverse`,children:(0,K.jsx)(`div`,{className:`w-full rounded-full`,style:{height:`${s}%`,backgroundColor:Rf(s)}})})]},e)})})]})}),(0,K.jsx)(`div`,{className:`flex justify-end gap-3 px-5 py-3 border-t border-zinc-800 shrink-0`,children:(0,K.jsx)(`button`,{onClick:t,disabled:L,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-800 text-zinc-300 hover:bg-zinc-700 transition-colors min-h-[44px] disabled:opacity-50`,children:l===`success`?a(`spoolbuddy.dashboard.close`,`Close`):a(`spoolbuddy.modal.cancel`,`Cancel`)})})]}),d&&p&&(()=>{let e=``;return p.type===`material`?e=a(`inventory.assignMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location}):p.type===`partial`?e=a(`inventory.assignPartialMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location}):p.type===`material_profile`?e=`${a(`inventory.assignMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location})}\n\n${a(`inventory.assignProfileMismatchMessage`,{spoolProfile:p.spoolProfile||a(`common.unknown`),trayProfile:p.trayProfile||a(`common.unknown`),location:p.location})}`:p.type===`partial_profile`&&(e=`${a(`inventory.assignPartialMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location})}\n\n${a(`inventory.assignProfileMismatchMessage`,{spoolProfile:p.spoolProfile||a(`common.unknown`),trayProfile:p.trayProfile||a(`common.unknown`),location:p.location})}`),e=`${e}\n\n${a(`inventory.assignReconfigureNote`)}`,(0,K.jsx)(Ad,{title:a(`inventory.assignMismatchTitle`),message:e,confirmText:a(`inventory.assignMismatchConfirm`),variant:`warning`,isLoading:I.isPending,onConfirm:ee,onCancel:()=>{I.isPending||(f(!1),g(null),m(null))}})})()]}):null}function MQe({isOpen:e,onClose:t,tagId:n,untaggedSpools:r,onLink:i}){let{t:a}=W(),[o,s]=(0,y.useState)(null),c=(0,y.useCallback)(()=>{s(null),t()},[t]),l=(0,y.useCallback)(e=>{e.key===`Escape`&&c()},[c]);return(0,y.useEffect)(()=>(e&&(document.addEventListener(`keydown`,l),document.body.style.overflow=`hidden`),()=>{document.removeEventListener(`keydown`,l),document.body.style.overflow=``}),[e,l]),e?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in`,onClick:c,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-xl shadow-2xl w-full max-w-lg mx-4 animate-slide-up`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-zinc-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-zinc-100`,children:a(`spoolbuddy.dashboard.linkTagTitle`,`Link Tag to Spool`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500 font-mono`,children:n})]}),(0,K.jsx)(`button`,{onClick:c,className:`p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-700 transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`px-5 py-4 space-y-3 max-h-[400px] overflow-y-auto`,children:[(0,K.jsx)(`p`,{className:`text-sm text-zinc-400`,children:a(`spoolbuddy.dashboard.selectSpool`,`Select a spool to link this tag to:`)}),r.length===0?(0,K.jsx)(`div`,{className:`text-center py-8 text-zinc-500`,children:a(`spoolbuddy.dashboard.noUntagged`,`No spools without tags found`)}):(0,K.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`w-full flex items-center gap-3 p-3 rounded-lg border-2 transition-all text-left ${o?.id===e.id?`border-green-500 bg-green-500/10`:`border-zinc-700 hover:border-green-500/50 hover:bg-zinc-700/50`}`,children:[(0,K.jsx)(G9,{color:qd(e.rgba),isEmpty:!1,size:40}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`font-medium text-zinc-100 truncate`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`div`,{className:`text-sm text-zinc-400 truncate`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]})]}),(0,K.jsxs)(`div`,{className:`text-sm font-mono text-zinc-500`,children:[Math.max(0,e.label_weight-e.weight_used),`g`]})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 px-5 py-4 border-t border-zinc-700`,children:[(0,K.jsx)(`button`,{onClick:c,className:`px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:a(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:()=>{o&&(i(o),s(null))},disabled:!o,className:`px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors min-h-[44px]`,children:a(`spoolbuddy.dashboard.linkTag`,`Link Tag`)})]})]})}):null}function NQe(e){return e?e.replace(/[^0-9a-f]/gi,``).toUpperCase():``}function PQe(e,t){let n=NQe(e),r=NQe(t);return!n||!r?!1:n===r?!0:n.endsWith(r)||r.endsWith(n)}var FQe=[`#00AE42`,`#FF6B35`,`#3B82F6`,`#EF4444`,`#A855F7`,`#FBBF24`,`#14B8A6`,`#EC4899`,`#F97316`,`#22C55E`];function IQe(){let{t:e}=W(),[t,n]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=setInterval(()=>{n(e=>(e+1)%FQe.length)},5e3);return()=>clearInterval(e)},[]);let r=FQe[t];return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsxs)(`div`,{className:`relative mb-6 flex items-center justify-center`,style:{width:160,height:160},children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:[0,1].map(e=>(0,K.jsx)(`div`,{className:`absolute rounded-full border spoolbuddy-optimized-ping`,style:{width:80,height:80,borderColor:`${r}4D`,transition:`border-color 140ms linear`,animationDelay:`${e*.8}s`}},e))}),(0,K.jsxs)(`div`,{className:`relative overflow-hidden rounded-full`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full opacity-30 spoolbuddy-spool-glow`,style:{background:`radial-gradient(circle, ${r} 0%, transparent 70%)`}}),(0,K.jsx)(`div`,{className:`relative`,style:{transition:`opacity 140ms linear`},children:(0,K.jsx)(G9,{color:r,isEmpty:!1,size:100})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xl font-medium text-zinc-300`,children:e(`spoolbuddy.dashboard.readyToScan`,`Ready to scan`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500`,children:e(`spoolbuddy.dashboard.idleMessage`,`Place a spool on the scale to identify it`)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-center gap-2 text-sm text-zinc-600`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,K.jsx)(`span`,{children:e(`spoolbuddy.dashboard.nfcHint`,`NFC tag will be read automatically`)})]})]})}function LQe(){let{t:e}=W();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsx)(`div`,{className:`relative mb-6 flex items-center justify-center`,style:{width:160,height:160},children:(0,K.jsx)(`div`,{className:`w-24 h-24 rounded-full bg-zinc-800 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-12 h-12 text-zinc-600`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,d:`M18.364 5.636a9 9 0 010 12.728m0 0l-12.728-12.728m12.728 12.728L5.636 5.636m12.728 0a9 9 0 00-12.728 0m0 12.728a9 9 0 010-12.728`})})})}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-lg font-medium text-zinc-500`,children:e(`spoolbuddy.status.deviceOffline`,`Device Offline`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600`,children:e(`spoolbuddy.status.connectDisplay`,`Connect the SpoolBuddy display to scan spools`)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-center gap-2 text-xs text-zinc-600`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.14 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})}),(0,K.jsx)(`span`,{children:e(`spoolbuddy.status.waitingConnection`,`Waiting for device connection...`)})]})]})}function RQe(){let{sbState:e,selectedPrinterId:t}=nr(),{t:n}=W(),{showToast:r}=Td(),{data:i}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),a=i?.spoolman_enabled===`true`&&!!i?.spoolman_url,{data:o=[],refetch:s}=q({queryKey:a?[`spoolman-inventory-spools`]:[`inventory-spools`],queryFn:()=>a?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),enabled:i!==void 0}),{data:c=[]}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:a,staleTime:3*1e3,refetchInterval:3*1e3,refetchIntervalInBackground:!1}),{data:l=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),u=_o({queries:l.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:1e4,select:e=>({connected:e?.connected,awaiting_plate_clear:e?.awaiting_plate_clear===!0})}))}),d=l.map((e,t)=>({printer:e,pending:u[t]?.data?.awaiting_plate_clear===!0})).filter(e=>e.pending),f=no(),p=J({mutationFn:e=>Q.clearPlate(e),onSuccess:(e,t)=>{f.setQueryData([`printerStatus`,t],e=>e&&{...e,awaiting_plate_clear:!1}),r(n(`spoolbuddy.dashboard.plateClearedToast`,`Plate marked as cleared`),`success`)},onError:()=>{r(n(`spoolbuddy.dashboard.plateClearFailed`,`Could not mark plate as cleared`),`error`)}}),m=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{f.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),f.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},onError:()=>r(n(`inventory.unassignFailed`,`Failed to unassign spool`),`error`)}),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(null),M=e.matchedSpool?.tag_uid??e.unknownTagUid??null,N=e.weight,P=e.weightStable,F=(0,y.useRef)(null);N===null?F.current=null:(F.current===null||Math.abs(N-F.current)>=3||P)&&(F.current=N);let I=F.current,L=(0,y.useMemo)(()=>{if(e.matchedSpool?.id){let t=o.find(t=>t.id===e.matchedSpool?.id);if(t)return t}return h&&(o.find(e=>PQe(e.tag_uid,h))||A)||null},[h,e.matchedSpool,o,A]),R=(0,y.useMemo)(()=>{if(L&&!A)return L;let t=e.matchedSpool;return t?{id:t.id,tag_uid:t.tag_uid,material:t.material,subtype:t.subtype,color_name:t.color_name,rgba:t.rgba,brand:t.brand,label_weight:t.label_weight,core_weight:t.core_weight,weight_used:t.weight_used}:null},[L,A,e.matchedSpool]),z=a&&R!=null?c.some(e=>e.spoolman_spool_id===R.id):!1,B=(0,y.useMemo)(()=>a?o.filter(e=>!e.tag_uid&&!e.tray_uuid&&!e.archived_at):o.filter(e=>!e.tag_uid&&!e.archived_at),[o,a]);(0,y.useEffect)(()=>{if(M){let e=b===M;(h!==null&&h!==M||!e&&h!==M)&&(g(M),v(null),x(null),j(null)),!e&&N!==null&&P&&v(Math.round(Math.max(0,N)))}else b&&(g(null),x(null),v(null),j(null))},[M,N,P,h,b]);let V=()=>{x(h)},ee=async t=>{if(h)try{if(a){let i=e.unknownTagUid||void 0,a=!e.unknownTagUid&&e.unknownTrayUuid?e.unknownTrayUuid:void 0;if(!i&&!a){r(n(`spoolman.linkFailed`),`error`);return}let o=await Q.linkTagToSpoolmanSpool(t.id,{tray_uuid:a,tag_uid:i});if(!o){r(n(`spoolman.linkFailed`),`error`);return}let{id:s,material:c,subtype:l,color_name:u,rgba:d,brand:f,label_weight:p,core_weight:m,weight_used:h}=o;j({id:s,material:c,subtype:l,color_name:u,rgba:d,brand:f,label_weight:p,core_weight:m,weight_used:h}),r(n(`spoolman.linkSuccess`),`success`)}else await Q.linkTagToSpool(t.id,{tag_uid:h,tag_type:`generic`,data_origin:`nfc_link`});s()}catch(e){console.error(`Failed to link tag:`,e),r(n(`spoolman.linkFailed`),`error`)}finally{C(!1)}},te=async()=>{if(h){k(!0);try{let t=ne??_;if(a){let n=await Q.createSpoolmanInventorySpool({material:`PLA`,subtype:null,color_name:null,rgba:null,extra_colors:null,effect_type:null,brand:null,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:null,last_used:null,encode_time:null,tag_uid:null,tray_uuid:null,data_origin:null,tag_type:null,cost_per_kg:null,last_scale_weight:t===null?null:Math.round(t),last_weighed_at:t===null?null:new Date().toISOString(),category:null,low_stock_threshold_pct:null});await Q.linkTagToSpoolmanSpool(n.id,{tag_uid:e.unknownTagUid||void 0,tray_uuid:!e.unknownTagUid&&e.unknownTrayUuid?e.unknownTrayUuid:void 0})}else await Q.createSpool({material:`PLA`,subtype:null,color_name:null,rgba:null,extra_colors:null,effect_type:null,brand:null,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:null,last_used:null,encode_time:null,tag_uid:h,tray_uuid:null,data_origin:`spoolbuddy`,tag_type:`generic`,cost_per_kg:null,last_scale_weight:t===null?null:Math.round(t),last_weighed_at:t===null?null:new Date().toISOString(),category:null,low_stock_threshold_pct:null})}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Failed to quick-add spool:`,t),r(t||n(`spoolbuddy.errors.quickAddFailed`,`Failed to add spool`),`error`)}finally{D(!1),k(!1),s()}}},ne=N!==null&&(M===h||M===null&&h!==null)?N:null,re=o.length,ie=new Set(o.map(e=>e.material)).size,H=new Set(o.filter(e=>e.brand).map(e=>e.brand)).size;return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-6 px-4 py-1.5 bg-zinc-800/50 rounded-xl border border-zinc-700/50 mb-3 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:re}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.inventory.spools`,`Spools`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:ie}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.material`,`Materials`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:H}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.brand`,`Brands`)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex gap-4 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`w-5/12 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`border border-dashed border-zinc-700/50 rounded-xl p-4`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-3`,children:n(`spoolbuddy.dashboard.device`,`Device`)}),(0,K.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full ${e.deviceOnline?`bg-green-500`:`bg-red-500`}`}),(0,K.jsx)(`span`,{className:`text-base text-zinc-400`,children:e.deviceOnline?n(`spoolbuddy.status.online`,`Online`):n(`spoolbuddy.status.offline`,`Disconnected`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 ${e.deviceOnline?`text-green-500`:`text-zinc-500`}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3`})}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.scaleWeight`,`Scale`)})]}),(0,K.jsx)(`span`,{className:`text-lg font-mono font-semibold text-zinc-100`,children:I===null?`—`:`${Math.abs(I)<=20?0:Math.round(Math.max(0,I))}g`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 ${e.deviceOnline?`text-green-500`:`text-zinc-500`}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z`})}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:`NFC`})]}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${M?`text-green-500`:`text-zinc-500`}`,children:M?n(`spoolbuddy.dashboard.tagDetected`,`Tag detected`):n(`spoolbuddy.dashboard.noTag`,`No tag`)})]})]})]}),l.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 border border-dashed border-zinc-700/50 rounded-xl p-4`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-2.5`,children:n(`spoolbuddy.dashboard.printers`,`Printers`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 overflow-hidden`,children:l.map((e,t)=>{let n=u[t]?.data?.connected??!1;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1 bg-zinc-800/50 rounded-lg`,title:`${e.name} — ${n?`Online`:`Offline`}`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0 ${n?`bg-green-500`:`bg-zinc-600`}`}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 truncate max-w-[100px]`,children:e.name})]},e.id)})}),d.length>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,"data-testid":`plate-clear-section`,"aria-label":n(`spoolbuddy.dashboard.plateReadyLabel`,`Plates ready to clear`),children:d.map(({printer:e})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>p.mutate(e.id),disabled:p.isPending,"data-testid":`plate-clear-button-${e.id}`,title:n(`spoolbuddy.dashboard.plateReady`,`Plate ready: {{name}}`,{name:e.name}),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-amber-500/10 hover:bg-amber-500/20 active:bg-amber-500/30 border border-amber-500/30 text-amber-200 transition-colors disabled:opacity-60 disabled:cursor-wait`,children:[(0,K.jsxs)(`svg`,{className:`w-3 h-3 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12 9v4`}),(0,K.jsx)(`path`,{d:`M12 17h.01`}),(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`})]}),(0,K.jsx)(`span`,{className:`text-xs truncate max-w-[100px]`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs opacity-70`,"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:n(`spoolbuddy.dashboard.plateClearAction`,`Clear`)})]},e.id))})]})]}),(0,K.jsx)(`div`,{className:`w-7/12 min-h-0`,children:(0,K.jsxs)(`div`,{className:`border border-dashed border-zinc-700/50 rounded-xl p-6 h-full flex flex-col`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-4 shrink-0`,children:n(`spoolbuddy.dashboard.currentSpool`,`Current Spool`)}),(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:e.deviceOnline?(L||e.matchedSpool)&&h&&b!==h?(0,K.jsx)(fQe,{spool:(()=>{let t=L??e.matchedSpool;return{id:t.id,tag_uid:h,material:t.material,subtype:t.subtype,color_name:t.color_name,rgba:t.rgba,brand:t.brand,label_weight:t.label_weight,core_weight:t.core_weight,weight_used:t.weight_used}})(),scaleWeight:ne??_,onSyncWeight:()=>s(),onAssignToAms:()=>T(!0),isAssigned:z,onUnassignFromAms:z&&L?.id!=null?()=>m.mutate(L.id):void 0,onClose:V}):M&&h&&!L&&!e.matchedSpool&&b!==h?(0,K.jsx)(pQe,{tagUid:h,scaleWeight:ne??_,onLinkSpool:B.length>0?()=>C(!0):void 0,onAddToInventory:()=>D(!0),onClose:V}):(0,K.jsx)(IQe,{}):(0,K.jsx)(LQe,{})})]})})]}),R&&!A&&h&&(0,K.jsx)(jQe,{isOpen:w,onClose:()=>T(!1),spool:R,printerId:t,spoolmanMode:a}),h&&(0,K.jsx)(MQe,{isOpen:S,onClose:()=>C(!1),tagId:h,untaggedSpools:B,onLink:ee}),E&&h&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-2xl p-6 mx-4 max-w-sm w-full border border-zinc-700`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100 mb-3`,children:n(`spoolbuddy.modal.addToInventory`,`Add to Inventory`)}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg mb-4`,children:[(0,K.jsx)(`svg`,{className:`w-5 h-5 text-amber-500 shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,K.jsx)(`p`,{className:`text-sm text-amber-200/80`,children:n(`spoolbuddy.modal.quickAddHint`,`For best results, add the spool in the Bambuddy web interface first (with material, color, brand), then use "Assign Spool" here to assign the NFC tag.`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-400 mb-1`,children:n(`spoolbuddy.modal.quickAddDesc`,`This will create a basic PLA spool entry with this NFC tag. You can edit the details later in Bambuddy.`)}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 font-mono mb-5`,children:h}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>D(!1),className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:n(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:te,disabled:O,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-50 transition-colors min-h-[44px]`,children:O?n(`common.saving`,`Saving...`):n(`spoolbuddy.modal.addAnyway`,`Add Anyway`)})]})]})})]})}function zQe(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function BQe(e){return e?{O1D:`H2D`,O1E:`H2D Pro`,O2D:`H2D Pro`,O1C:`H2C`,O1C2:`H2C`,O1S:`H2S`,"BL-P001":`X1C`,"BL-P002":`X1`,"BL-P003":`X1E`,N6:`X2D`,N9:`A2L`,C11:`P1S`,C12:`P1P`,C13:`P2S`,N2S:`A1`,N1:`A1 Mini`,X1C:`X1C`,X1:`X1`,X1E:`X1E`,X2D:`X2D`,P1S:`P1S`,P1P:`P1P`,P2S:`P2S`,A1:`A1`,"A1 Mini":`A1 Mini`,A2L:`A2L`,H2D:`H2D`,"H2D Pro":`H2D Pro`,H2C:`H2C`,H2S:`H2S`}[e]||e:``}function X9(e){return!e.tray_type||e.tray_type===``}function VQe(e){return e?`#${e.slice(0,6)}`:`#808080`}function HQe(){let{selectedPrinterId:e,setAlert:t}=nr(),{t:n}=W(),r=no(),{showToast:i}=Td(),{data:a}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),enabled:e!==null,staleTime:30*1e3}),{data:o}=q({queryKey:[`printer`,e],queryFn:()=>Q.getPrinter(e),enabled:e!==null,staleTime:60*1e3}),{data:s}=q({queryKey:[`slotPresets`,e],queryFn:()=>Q.getSlotPresets(e),enabled:e!==null,staleTime:120*1e3}),{data:c}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),staleTime:300*1e3}),{data:l}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,staleTime:60*1e3}),u=l?.enabled&&l?.connected,{data:d}=q({queryKey:[`linked-spools`],queryFn:Q.getLinkedSpools,enabled:!!u,staleTime:30*1e3}),f=d?.linked,{data:p=[]}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:!!u,staleTime:30*1e3}),{data:m=[]}=q({queryKey:[`spoolman-inventory-spools`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:!!u,staleTime:30*1e3}),{data:h}=q({queryKey:[`spool-assignments`,e],queryFn:()=>Q.getAssignments(e),enabled:e!==null,staleTime:30*1e3}),g=(0,y.useMemo)(()=>{let e={};if(!h)return e;for(let t of h){let n=t.spool;if(n&&n.label_weight>0&&n.weight_used!=null){let r=Math.round(Math.max(0,n.label_weight-n.weight_used)/n.label_weight*100);e[`${t.ams_id}-${t.tray_id}`]=r}}return e},[h]),_=o?.serial_number??``,v=(0,y.useCallback)((t,n,r)=>{if(e!==null&&p.length&&m.length){let r=p.find(r=>r.printer_id===e&&r.ams_id===t&&r.tray_id===n);if(r){let e=m.find(e=>e.id===r.spoolman_spool_id);if(e&&(e.label_weight??0)>0)return Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100)}}if(f&&_){let e=(r?.tray_uuid||r?.tag_uid||Hf(_,t,n))?.toUpperCase(),i=zf(e?f[e]:void 0);if(i!==null)return i}return null},[f,_,e,p,m]),b=a?.connected??!1,x=(0,y.useRef)({});(0,y.useEffect)(()=>{e&&a?.ams&&a.ams.length>0&&(x.current[e]=a.ams)},[a?.ams,e]);let S=(0,y.useMemo)(()=>{let t=a?.ams;return t&&t.length>0?t:(e?x.current[e]:null)??[]},[a?.ams,e]),C=(0,y.useMemo)(()=>S.filter(e=>!e.is_ams_ht),[S]),w=(0,y.useMemo)(()=>S.filter(e=>e.is_ams_ht),[S]),T=(0,y.useMemo)(()=>{let e={};if(!f||!_)return e;for(let t of C)for(let n=0;n<(t.tray?.length??0);n++){let r=t.tray[n],i=v(t.id,n,X9(r)?null:r);i!==null&&(e[`${t.id}-${n}`]=i)}return e},[f,_,C,v]),E=(0,y.useRef)(void 0),D=a?.tray_now;D!==void 0&&D!==255?E.current=D:D===255&&(E.current=void 0);let O=D!==void 0&&D!==255?D:E.current,k=o?.nozzle_count===2||a?.temperatures?.nozzle_2!==void 0,A=(0,y.useMemo)(()=>[...a?.vt_tray??[]].sort((e,t)=>(e.id??254)-(t.id??254)),[a?.vt_tray]),j=c?{humidityGood:Number(c.ams_humidity_good)||40,humidityFair:Number(c.ams_humidity_fair)||60,tempGood:Number(c.ams_temp_good)||28,tempFair:Number(c.ams_temp_fair)||35}:void 0,M=(0,y.useRef)({});(0,y.useEffect)(()=>{a?.ams_extruder_map&&Object.keys(a.ams_extruder_map).length>0&&(M.current=a.ams_extruder_map)},[a?.ams_extruder_map]);let N=a?.ams_extruder_map&&Object.keys(a.ams_extruder_map).length>0?a.ams_extruder_map:M.current,P=(0,y.useCallback)(e=>{if(!k)return null;let t=N[String(e)],n=e>=128?e-128:e;return(t===void 0?n:t)===1?`L`:`R`},[k,N]),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(null),[z,B]=(0,y.useState)(null),[V,ee]=(0,y.useState)(null),te=(0,y.useCallback)((e,t)=>h?.find(n=>n.ams_id===Number(e)&&n.tray_id===Number(t)),[h]),ne=(0,y.useCallback)((e,t,n)=>{if(!f||!_)return;let r=(n?.tray_uuid||n?.tag_uid||Hf(_,e,t))?.toUpperCase();return r?f[r]:void 0},[f,_]),re=J({mutationFn:({printerId:e,amsId:t,trayId:n})=>Q.unassignSpool(e,t,n),onSuccess:()=>{r.invalidateQueries({queryKey:[`spool-assignments`,e]}),r.invalidateQueries({queryKey:[`spool-assignments`]}),i(n(`inventory.unassignSuccess`,`Spool unassigned`),`success`),R(null)}}),ie=J({mutationFn:e=>Q.unlinkSpool(e),onSuccess:e=>{i(n(`spoolman.unlinkSuccess`)||e?.message,`success`),r.invalidateQueries({queryKey:[`linked-spools`]}),r.invalidateQueries({queryKey:[`unlinked-spools`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),r.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),R(null)},onError:e=>{i(e.message||n(`spoolman.unlinkFailed`),`error`)}}),H=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{i(n(`inventory.unassignSuccess`,`Spool unassigned`),`success`),r.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),r.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),r.invalidateQueries({queryKey:[`unlinked-spools`]}),r.invalidateQueries({queryKey:[`linked-spools`]}),R(null)},onError:e=>{i(e.message||n(`inventory.assignFailed`,`Failed to unassign spool`),`error`)}}),ae=(0,y.useCallback)(e=>O===void 0?null:e<=3&&Math.floor(O/4)===e?O%4:e>=128&&e<=135&&O===Lf(e,0,!1)?0:null,[O]),oe=(0,y.useCallback)((e,t,n)=>{let r=Lf(e,t,!1),i=s?.[r],a=N[String(e)],o=e>=128?e-128:e,c=a===void 0?o:a;R({amsId:e,trayId:t,trayCount:n&&e>=128?1:4,tray:n,trayType:n?.tray_type||void 0,trayColor:n?.tray_color||void 0,traySubBrands:n?.tray_sub_brands||void 0,trayInfoIdx:n?.tray_info_idx||void 0,extruderId:k?c:void 0,caliIdx:n?.cali_idx,savedPresetId:i?.preset_id,location:`${zQe(e)} Slot ${t+1}`})},[s,N,k]),U=(0,y.useCallback)(e=>{let t=e.id??254,n=t-254,r=s?.[1020+n];R({amsId:255,trayId:n,trayCount:1,tray:X9(e)?null:e,trayType:e.tray_type||void 0,trayColor:e.tray_color||void 0,traySubBrands:e.tray_sub_brands||void 0,trayInfoIdx:e.tray_info_idx||void 0,extruderId:k?+(t===254):void 0,caliIdx:e.cali_idx,savedPresetId:r?.preset_id,location:k?t===254?`Ext-L`:`Ext-R`:`External`})},[s,k]),se=(0,y.useCallback)(()=>{if(!L)return;let{tray:e,location:t,...n}=L;R(null),I(n)},[L]),ce=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n,trayType:r,trayColor:i,location:a}=L;R(null),B({printerId:e,amsId:t,trayId:n,trayInfo:{type:r||``,material:r,color:i?.slice(0,6)||``,location:a}})},[L,e]),le=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n,tray:r}=L,i=(r?.tray_uuid||r?.tag_uid||Hf(_,t,n))?.toUpperCase()||``;R(null),ee({tagUid:r?.tag_uid||i,trayUuid:r?.tray_uuid||``,printerId:e,amsId:t,trayId:n})},[L,e,_]),ue=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n}=L;re.mutate({printerId:e,amsId:t,trayId:n})},[L,e,re]);(0,y.useEffect)(()=>{if(!b&&e){t({type:`warning`,message:n(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)});return}for(let e of S){let n=e.tray||[];for(let r=0;r=0&&i.remain<15&&i.tray_type){let n=e.id===254||e.id===255,a=!n&&e.id>=128,o=If(e.id,r,a,n);t({type:`warning`,message:`Low Filament: ${i.tray_type} (${o}) - ${i.remain}% remaining`});return}}}t(null)},[S,b,e,t,n]);let de=(0,y.useMemo)(()=>{let e=[];for(let t of w){let n=t.tray?.[0]||{id:0,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null},r=v(t.id,0,X9(n)?null:n),i=g[`${t.id}-0`]??null,a=n.remain!=null&&n.remain>=0?n.remain:null,o=i===0&&a!==null&&a>0?null:i;e.push({key:`ht-${t.id}`,label:zQe(t.id),tray:n,isEmpty:X9(n),isActive:ae(t.id)===0,temp:t.temp,humidity:t.humidity,nozzleSide:P(t.id),effectiveFill:r??o??a,onClick:()=>oe(t.id,0,X9(n)?null:n)})}for(let t of A){let r=t.id??254,i=k&&O===254?r===254&&a?.active_extruder===1||r===255&&a?.active_extruder===0:O===r,o=r-254,s=v(255,o,X9(t)?null:t),c=g[`255-${o}`]??null,l=t.remain!=null&&t.remain>=0?t.remain:null,u=c===0&&l!==null&&l>0?null:c;e.push({key:`ext-${r}`,label:k?r===254?n(`printers.extL`,`Ext-L`):n(`printers.extR`,`Ext-R`):n(`printers.ext`,`Ext`),tray:t,isEmpty:X9(t),isActive:i,nozzleSide:null,effectiveFill:s??u??l,onClick:()=>U(t)})}return e},[w,A,k,O,a?.active_extruder,n,ae,P,oe,U,g,v]);return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:e?b?S.length===0&&A.length===0?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.noData`,`No AMS detected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.ams.connectAms`,`Connect an AMS to see filament slots`)})]})}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 h-full`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:C.map(e=>(0,K.jsx)(DQe,{unit:e,activeSlot:ae(e.id),onConfigureSlot:oe,isDualNozzle:k,nozzleSide:P(e.id),thresholds:j,fillOverrides:g,spoolmanFillOverrides:T},e.id))}),de.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:de.map(({key:e,label:t,tray:n,isEmpty:r,isActive:i,temp:a,humidity:o,nozzleSide:s,effectiveFill:c,onClick:l})=>{let u=VQe(n.tray_color);return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-3 ${i?`ring-2 ring-bambu-green`:``}`,onClick:l,children:[(0,K.jsxs)(`div`,{className:`relative w-10 h-10 flex-shrink-0`,children:[r?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:u}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:u,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]}),i&&(0,K.jsx)(`div`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 bg-bambu-green rounded-full`})]}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-white/50 font-medium truncate`,children:t}),s&&(0,K.jsx)(K9,{side:s})]}),(0,K.jsx)(`div`,{className:`text-sm text-white/80 truncate`,children:r?`Empty`:n.tray_type||`?`}),(a!=null||o!=null)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[a!=null&&(0,K.jsx)(TQe,{temp:a,goodThreshold:j?.tempGood,fairThreshold:j?.tempFair}),o!=null&&(0,K.jsx)(wQe,{humidity:o,goodThreshold:j?.humidityGood,fairThreshold:j?.humidityFair})]})]}),!r&&c!=null&&c>=0&&(0,K.jsx)(`div`,{className:`w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden flex-shrink-0 flex flex-col-reverse`,children:(0,K.jsx)(`div`,{className:`w-full rounded-full`,style:{height:`${c}%`,backgroundColor:Rf(c)}})})]},e)})})]}):(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsx)(`div`,{className:`text-center text-white/50`,children:(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)})})}):(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.noPrinter`,`No printer selected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.ams.selectPrinter`,`Select a printer from the top bar`)})]})})}),F&&e&&(0,K.jsx)(WU,{isOpen:!!F,onClose:()=>I(null),printerId:e,slotInfo:F,printerModel:BQe(o?.model??null)||void 0,fullScreen:!0,onSuccess:()=>{r.invalidateQueries({queryKey:[`slotPresets`,e]}),r.invalidateQueries({queryKey:[`printerStatus`,e]})}}),L&&e&&(()=>{let t=te(L.amsId,L.trayId),r=ne(L.amsId,L.trayId,L.tray),i=u?p.find(t=>t.printer_id===e&&t.ams_id===L.amsId&&t.tray_id===L.trayId):void 0,a=i?m.find(e=>e.id===i.spoolman_spool_id)??null:null;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>R(null)}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-sm mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[L.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${L.trayColor.slice(0,6)}`}}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:L.location}),L.traySubBrands&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,L.traySubBrands,`)`]})]}),(0,K.jsx)(`button`,{onClick:()=>R(null),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-2`,children:[!u&&t?.spool&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`inventory.assignedSpool`,`Assigned spool`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.spool.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(t.spool.rgba)}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[t.spool.brand?`${t.spool.brand} `:``,t.spool.material,t.spool.color_name?` - ${t.spool.color_name}`:``]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0 ml-auto`,children:[`#`,t.spool.id]})]})]}),u&&r&&!a&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`spoolman.linkedSpool`,`Linked spool`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[`Spoolman #`,r.id,r.remaining_weight==null?``:` (${Math.round(r.remaining_weight)}g)`]})})]}),u&&a&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`inventory.assignedSpool`,`Assigned spool`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(a.rgba)}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[a.brand?`${a.brand} `:``,a.material,a.color_name?` - ${a.color_name}`:``]})]})]}),(0,K.jsxs)(`button`,{onClick:se,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-blue transition-colors text-left`,children:[(0,K.jsx)(Hl,{className:`w-5 h-5 text-bambu-blue flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`configureAmsSlot.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.configureDesc`,`Set filament preset, K-profile, and color`)})]})]}),!u&&(Xf(L?.tray)?null:t?(0,K.jsxs)(`button`,{onClick:ue,disabled:re.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`,`Unassign`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unassignDesc`,`Remove inventory spool from this slot`)})]})]}):(0,K.jsxs)(`button`,{onClick:ce,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors text-left`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.assignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.assignDesc`,`Track a spool from your inventory`)})]})]})),u&&(r?.id?(0,K.jsxs)(`button`,{onClick:()=>ie.mutate(r.id),disabled:ie.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left active:opacity-50`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unlinkDesc`,`Remove Spoolman link from this slot`)})]})]}):a?(0,K.jsxs)(`button`,{onClick:()=>H.mutate(a.id),disabled:H.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left active:opacity-50`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unassignDesc`,`Remove inventory spool from this slot`)})]})]}):(0,K.jsxs)(`button`,{onClick:le,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors text-left`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.assignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.linkDesc`,`Link a Spoolman spool to this slot`)})]})]}))]})]})]})})(),z&&(0,K.jsx)(hU,{isOpen:!!z,onClose:()=>{B(null),r.invalidateQueries({queryKey:[`spool-assignments`,e]}),r.invalidateQueries({queryKey:[`spool-assignments`]})},printerId:z.printerId,amsId:z.amsId,trayId:z.trayId,trayInfo:z.trayInfo,spoolmanEnabled:!!u}),V&&(0,K.jsx)(pU,{isOpen:!!V,onClose:()=>ee(null),tagUid:V.tagUid,trayUuid:V.trayUuid,printerId:V.printerId,amsId:V.amsId,trayId:V.trayId})]})}function UQe({type:e,deviceId:t,onClose:n}){let{t:r}=W(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!i&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,n]);let f=(0,y.useCallback)(async()=>{a(!0),s(``),l(``),d(!0);try{s(r(`spoolbuddy.diagnostic.queuing`,`Queuing diagnostic on device... -`)),await od.queueDiagnostics(t,e);let n=null,i=0;for(;i<60&&!n;){await new Promise(e=>setTimeout(e,500));try{n=await od.getDiagnosticResult(t,e);break}catch{i++,i%4==0&&s(e=>e+`.`)}}if(!n)throw Error(`Diagnostic timed out - device did not report results`);s(n.output),n.success||l(`Exit code: ${n.exit_code}`)}catch(e){l(e instanceof Error?e.message:`Unknown error`),s(``)}finally{a(!1)}},[e,t,r]);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg shadow-xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col animate-slide-up`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center p-4 border-b border-zinc-700`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e===`scale`?r(`spoolbuddy.diagnostic.scaleTitle`,`Scale Diagnostic`):e===`read_tag`?r(`spoolbuddy.diagnostic.readTagTitle`,`Read Tag Diagnostic`):r(`spoolbuddy.diagnostic.nfcTitle`,`NFC Reader Diagnostic`)}),(0,K.jsx)(`button`,{onClick:n,className:`text-zinc-400 hover:text-white transition-colors`,"aria-label":`Close`,children:(0,K.jsx)(Ru,{size:20})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-auto p-4 bg-black/50 font-mono text-sm`,children:i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-green-400`,children:[(0,K.jsx)(`div`,{className:`animate-spin w-4 h-4 border-2 border-green-400 border-t-transparent rounded-full`}),(0,K.jsx)(`span`,{children:r(`spoolbuddy.diagnostic.running`,`Running diagnostic on device...`)})]}):o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-green-400 whitespace-pre-wrap break-words`,children:o}),c&&(0,K.jsxs)(`div`,{className:`text-red-400 mt-2`,children:[`❌ `,c]})]}):u?(0,K.jsx)(`div`,{children:c?(0,K.jsxs)(`div`,{className:`text-red-400`,children:[`ERROR: `,c]}):(0,K.jsx)(`span`,{className:`text-green-400`,children:r(`spoolbuddy.diagnostic.completed`,`Diagnostic completed successfully.`)})}):(0,K.jsxs)(`div`,{className:`text-zinc-500`,children:[r(`spoolbuddy.diagnostic.clickStart`,`Click "Run Diagnostic" to start the hardware diagnostic on`),` `,t,`.`]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t border-zinc-700 bg-zinc-800`,children:[(0,K.jsx)(`button`,{onClick:f,disabled:i,className:`flex-1 flex items-center justify-center gap-2 bg-green-600 hover:bg-green-700 disabled:bg-gray-600 disabled:cursor-not-allowed px-4 py-2 rounded font-semibold text-white transition-colors`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`animate-spin w-4 h-4 border-2 border-white border-t-transparent rounded-full`}),r(`spoolbuddy.diagnostic.runningBtn`,`Running...`)]}):u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jl,{size:16}),r(`spoolbuddy.diagnostic.runAgain`,`Run Again`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bl,{size:16}),r(`spoolbuddy.diagnostic.runBtn`,`Run Diagnostic`)]})}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 rounded bg-zinc-700 hover:bg-zinc-600 text-white font-semibold transition-colors`,children:r(`spoolbuddy.diagnostic.close`,`Close`)})]})]})})}function WQe(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function GQe(e){if(!e)return`-`;let t=vf(e);return t?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})+` `+t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):`-`}var KQe=[{label:`Off`,value:0},{label:`1m`,value:60},{label:`2m`,value:120},{label:`5m`,value:300},{label:`10m`,value:600},{label:`30m`,value:1800}];function qQe({device:e}){let{t}=W(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{!i&&e.backend_url&&a(e.backend_url)},[e.backend_url,i]),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.nfcReader`,`NFC Reader`)}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.type`,`Type`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.nfc_reader_type||`N/A`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.connection`,`Connection`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.nfc_connection||`N/A`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.status.status`,`Status`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${e.nfc_ok?`bg-green-500`:e.nfc_reader_type?`bg-red-500`:`bg-zinc-600`}`}),(0,K.jsx)(`span`,{className:e.nfc_ok?`text-green-400`:e.nfc_reader_type?`text-red-400`:`text-zinc-500`,children:e.nfc_ok?t(`spoolbuddy.status.nfcReady`,`Ready`):e.nfc_reader_type?t(`common.error`,`Error`):t(`spoolbuddy.settings.notConnected`,`N/A`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.deviceInfo`,`Device Info`)}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.hostname`,`Host`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 truncate ml-2`,children:e.hostname})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`IP`}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:e.ip_address})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.uptime`,`Uptime`)}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:WQe(e.uptime_s)})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`ID`}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono truncate ml-2`,children:e.device_id})]})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:t(`spoolbuddy.settings.systemConfig`,`Backend & Auth`)}),(0,K.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`http://192.168.1.100:5000`,className:`w-full px-2 py-1.5 rounded bg-zinc-900 border border-zinc-700 text-zinc-100 text-xs`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),placeholder:t(`spoolbuddy.settings.apiTokenPlaceholder`,`API token`),className:`flex-1 px-2 py-1.5 rounded bg-zinc-900 border border-zinc-700 text-zinc-100 text-xs`}),(0,K.jsx)(`button`,{onClick:async()=>{if(!i.trim()){d({type:`error`,text:t(`spoolbuddy.settings.systemFieldsRequired`,`Backend URL is required.`)});return}l(!0),d(null);try{await od.updateSystemConfig(e.device_id,i.trim(),o.trim()||void 0),d({type:`ok`,text:t(`spoolbuddy.settings.systemQueued`,`Config queued.`)})}catch(e){d({type:`error`,text:e instanceof Error?e.message:t(`common.error`,`Error`)})}finally{l(!1)}},disabled:c,className:`px-3 py-1.5 rounded bg-green-700 hover:bg-green-600 disabled:bg-zinc-700 text-xs font-medium text-zinc-100`,children:t(`spoolbuddy.settings.saveConfig`,`Save`)})]}),u&&(0,K.jsx)(`div`,{className:`text-xs ${u.type===`ok`?`text-green-400`:`text-red-400`}`,children:u.text})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 flex flex-col gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>r(`nfc`),className:`flex-1 bg-blue-700 hover:bg-blue-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(Mu,{className:`w-4 h-4 text-blue-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-blue-100`,children:t(`spoolbuddy.settings.nfcDiagnostic`,`NFC Diagnostic`)})]}),(0,K.jsxs)(`button`,{onClick:()=>r(`scale`),className:`flex-1 bg-yellow-700 hover:bg-yellow-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-yellow-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-yellow-100`,children:t(`spoolbuddy.settings.scaleDiagnostic`,`Scale Diagnostic`)})]}),(0,K.jsxs)(`button`,{onClick:()=>r(`read_tag`),className:`flex-1 bg-emerald-700 hover:bg-emerald-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-emerald-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-emerald-100`,children:t(`spoolbuddy.settings.readTagDiagnostic`,`Read Tag`)})]})]})]}),n&&e&&(0,K.jsx)(UQe,{type:n,deviceId:e.device_id,onClose:()=>r(null)})]})}function JQe({device:e,onBrightnessChange:t}){let{t:n}=W(),[r,i]=(0,y.useState)(e.display_brightness),[a,o]=(0,y.useState)(e.display_blank_timeout),[s,c]=(0,y.useState)(!1),l=(0,y.useRef)(void 0),u=(0,y.useRef)(void 0);(0,y.useEffect)(()=>{i(e.display_brightness),o(e.display_blank_timeout)},[e.display_brightness,e.display_blank_timeout]);let d=(0,y.useCallback)(()=>{c(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),1500)},[]),f=(0,y.useCallback)((t,n)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{od.updateDisplay(e.device_id,t,n).then(()=>d()).catch(e=>console.error(`Failed to update display:`,e))},300)},[e.device_id,d]),p=e=>{i(e),t(e),f(e,a)},m=e=>{o(e),f(r,e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:n(`spoolbuddy.settings.brightness`,`Brightness`)}),s&&(0,K.jsxs)(`span`,{className:`text-xs text-green-400 flex items-center gap-1 animate-pulse`,children:[(0,K.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}),n(`spoolbuddy.settings.saved`,`Saved`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 text-zinc-500 flex-shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`})}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,value:r,onChange:e=>p(parseInt(e.target.value)),className:`flex-1 h-2 bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-sm font-mono text-zinc-400 w-10 text-right`,children:[r,`%`]})]}),!e.has_backlight&&(0,K.jsx)(`p`,{className:`text-xs text-zinc-600 mt-2`,children:n(`spoolbuddy.settings.noBacklight`,`No DSI backlight detected. Brightness control requires a DSI display.`)})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1`,children:n(`spoolbuddy.settings.screenBlank`,`Screen Blank Timeout`)}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-3`,children:n(`spoolbuddy.settings.screenBlankDesc`,`Screen turns off after inactivity. Touch to wake.`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:KQe.map(e=>(0,K.jsx)(`button`,{onClick:()=>m(e.value),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors min-h-[40px] ${a===e.value?`bg-green-600 text-white`:`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`}`,children:e.label},e.value))})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-600 text-center`,children:n(`spoolbuddy.settings.displayNote`,`Brightness is applied as a software filter.`)})]})}function YQe({step:e,labels:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center w-16 shrink-0 pt-1`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${e===`tare`?`bg-green-600 text-white`:`bg-green-600/20 text-green-400`}`,children:e===`weight`?(0,K.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}):`1`}),(0,K.jsx)(`span`,{className:`text-[10px] mt-0.5 ${e===`tare`?`text-green-400 font-medium`:`text-green-400/60`}`,children:t.tare}),(0,K.jsx)(`div`,{className:`w-px h-5 my-1 ${e===`weight`?`bg-green-600/40`:`bg-zinc-700`}`}),(0,K.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${e===`weight`?`bg-green-600 text-white`:`bg-zinc-700 text-zinc-500`}`,children:`2`}),(0,K.jsx)(`span`,{className:`text-[10px] mt-0.5 ${e===`weight`?`text-green-400 font-medium`:`text-zinc-600`}`,children:t.weight})]})}function XQe({device:e,weight:t,weightStable:n,rawAdc:r}){let{t:i}=W(),a=no(),[o,s]=(0,y.useState)(`idle`),[c,l]=(0,y.useState)(`500`),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),v=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);let b=(0,y.useCallback)(e=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>h(null),e)},[]);(0,y.useEffect)(()=>{if(!g)return;let e=()=>Date.now()-g.startedAtMs,t=setInterval(()=>{a.invalidateQueries({queryKey:[`spoolbuddy-devices`]})},1e3),n=setTimeout(()=>{_(null),h({type:`error`,msg:i(`spoolbuddy.settings.tareTimedOut`,`Tare timed out — is the SpoolBuddy daemon running?`)}),b(5e3)},Math.max(0,15e3-e()));return()=>{clearInterval(t),clearTimeout(n)}},[g,a,i,b]),(0,y.useEffect)(()=>{g&&(e?.last_calibrated_at??null)!==g.snapshot&&(_(null),h({type:`ok`,msg:i(`spoolbuddy.settings.tareComplete`,`Tare complete!`)}),b(3e3))},[e?.last_calibrated_at,g,i,b]);let x=e=>{e===`backspace`?l(e=>e.slice(0,-1)||``):e===`.`&&!c.includes(`.`)?l(e=>e+`.`):e>=`0`&&e<=`9`&&l(t=>t===`0`?e:t+e)};return o===`idle`?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-lg font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`})]}),(0,K.jsxs)(`div`,{className:`text-xs text-zinc-500 text-right`,children:[(0,K.jsxs)(`span`,{children:[i(`spoolbuddy.settings.tareOffset`,`Tare`),`: `,e.tare_offset]}),(0,K.jsx)(`span`,{className:`mx-1.5`,children:`·`}),(0,K.jsxs)(`span`,{children:[i(`spoolbuddy.settings.calFactor`,`Factor`),`: `,e.calibration_factor.toFixed(2)]})]})]}),e.last_calibrated_at&&(0,K.jsxs)(`div`,{className:`text-xs text-zinc-600 mt-1`,children:[i(`spoolbuddy.settings.lastCalibrated`,`Last calibrated`),`: `,GQe(e.last_calibrated_at)]})]}),m&&(0,K.jsx)(`div`,{className:`rounded-lg px-3 py-2 mb-3 text-sm ${m.type===`ok`?`bg-green-900/30 text-green-300 border border-green-800`:`bg-red-900/30 text-red-300 border border-red-800`}`,children:m.msg}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:async()=>{p(!0),h(null),v.current&&=(clearTimeout(v.current),null);let t=e?.last_calibrated_at??null;try{await od.tare(e.device_id),h({type:`ok`,msg:i(`spoolbuddy.settings.tareSet`,`Tare command sent. Waiting for device...`)}),_({snapshot:t,startedAtMs:Date.now()})}catch{h({type:`error`,msg:i(`spoolbuddy.settings.tareFailed`,`Failed to send tare command`)}),b(5e3)}finally{p(!1)}},disabled:f,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px] flex items-center justify-center gap-2`,children:[f&&(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),i(`spoolbuddy.weight.tare`,`Tare`)]}),(0,K.jsx)(`button`,{onClick:()=>{s(`tare`),h(null)},className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:i(`spoolbuddy.weight.calibrate`,`Calibrate`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(YQe,{step:o,labels:{tare:i(`spoolbuddy.weight.tare`,`Tare`),weight:i(`spoolbuddy.settings.knownWeight`,`Known weight`)}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 rounded-lg px-3 py-1.5 mb-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0 ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-sm font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`}),(0,K.jsx)(`span`,{className:`text-xs ml-auto ${n?`text-green-400`:`text-amber-400`}`,children:n?i(`spoolbuddy.settings.stable`,`Stable`):i(`spoolbuddy.settings.settling`,`Settling...`)})]}),m&&(0,K.jsx)(`div`,{className:`rounded-lg px-3 py-1.5 mb-1.5 text-xs ${m.type===`ok`?`bg-green-900/30 text-green-300 border border-green-800`:`bg-red-900/30 text-red-300 border border-red-800`}`,children:m.msg}),o===`tare`?(0,K.jsx)(`p`,{className:`text-sm text-zinc-300 mb-3`,children:i(`spoolbuddy.settings.calStep1`,`Remove all items from the scale and press Set Zero.`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 shrink-0`,children:i(`spoolbuddy.settings.knownWeight`,`Known weight`)}),(0,K.jsxs)(`div`,{className:`flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1 text-right text-lg font-mono text-zinc-100`,children:[c||`0`,(0,K.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`g`})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1 mb-1.5`,children:[`7`,`8`,`9`,`backspace`,`4`,`5`,`6`,`.`,`1`,`2`,`3`,`0`].map(e=>(0,K.jsx)(`button`,{onClick:()=>x(e),className:`rounded text-lg font-medium transition-colors h-[48px] active:scale-95 ${e===`backspace`?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700`}`,children:e===`backspace`?`⌫`:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{s(`idle`),h(null)},className:`flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors h-[40px]`,children:i(`common.cancel`,`Cancel`)}),(0,K.jsxs)(`button`,{onClick:async()=>{if(o===`tare`){p(!0),h(null);try{d(r),await od.tare(e.device_id),h({type:`ok`,msg:i(`spoolbuddy.settings.zeroSet`,`Zero point set. Place known weight on scale.`)}),s(`weight`)}catch{h({type:`error`,msg:i(`spoolbuddy.settings.tareFailed`,`Failed to send tare command`)})}finally{p(!1)}}else if(o===`weight`){let t=parseFloat(c);if(r===null||!t||t<=0)return;p(!0),h(null);try{await od.setCalibrationFactor(e.device_id,t,r,u??void 0),h({type:`ok`,msg:i(`spoolbuddy.settings.calibrationDone`,`Calibration complete!`)}),b(3e3),s(`idle`)}catch{h({type:`error`,msg:i(`spoolbuddy.settings.calibrationFailed`,`Calibration failed`)}),b(5e3)}finally{p(!1)}}},disabled:f,className:`flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors h-[40px] flex items-center justify-center gap-2`,children:[f&&(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),o===`tare`?i(`spoolbuddy.settings.setZero`,`Set Zero`):i(`spoolbuddy.settings.calibrateNow`,`Calibrate`)]})]})]})]})}function ZQe({device:e}){let{t}=W(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),u=e.update_status===`pending`||e.update_status===`updating`;(0,y.useEffect)(()=>{u&&n===`applying`&&r(null)},[u,n]),(0,y.useEffect)(()=>{let e=()=>{u&&setTimeout(()=>window.location.reload(),1e3)};return window.addEventListener(`spoolbuddy-online`,e),()=>window.removeEventListener(`spoolbuddy-online`,e)},[u]);let{data:d,refetch:f}=q({queryKey:[`spoolbuddy-update-check`,e.device_id],queryFn:()=>od.checkDaemonUpdate(e.device_id),staleTime:0}),{data:p}=q({queryKey:[`spoolbuddy-ssh-key`],queryFn:()=>od.getSSHPublicKey(),enabled:o,staleTime:1/0}),m=async()=>{r(`checking`),a(null);try{await f()}finally{r(null)}},h=async()=>{r(`applying`),a(null);try{await od.triggerUpdate(e.device_id)}catch(e){a(e instanceof Error?e.message:`Failed to trigger update`),r(null)}},g=n!=null||u,_=()=>{p?.public_key&&(navigator.clipboard.writeText(p.public_key),l(!0),setTimeout(()=>l(!1),2e3))},v=e.firmware_version||(d?.current_version&&d.current_version!==`0.0.0`?d.current_version:null);return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.currentVersion`,`Current Version`)}),(0,K.jsx)(`span`,{className:`text-zinc-200 font-mono`,children:v||(0,K.jsx)(`span`,{className:`text-zinc-500 italic text-xs`,children:t(`spoolbuddy.settings.versionPending`,`Waiting for daemon...`)})})]}),g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin text-green-400 flex-shrink-0`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),(0,K.jsx)(`span`,{className:`text-green-300 text-xs`,children:n===`checking`?t(`spoolbuddy.settings.checking`,`Checking for updates...`):e.update_message||t(`spoolbuddy.settings.updateWaiting`,`Updating...`)})]}):e.update_status===`error`?(0,K.jsx)(`p`,{className:`text-xs text-red-300`,children:e.update_message||t(`spoolbuddy.settings.updateFailed`,`Update failed`)}):i?(0,K.jsx)(`p`,{className:`text-xs text-red-300`,children:i}):d?.update_available?(0,K.jsxs)(`p`,{className:`text-xs text-green-300`,children:[t(`spoolbuddy.settings.updateAvailable`,`Update available`),`: `,v,` → `,d.latest_version]}):null,!g&&(d?.update_available?(0,K.jsx)(`button`,{onClick:h,disabled:!e.online,className:`w-full px-3 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors`,children:e.online?t(`spoolbuddy.settings.applyUpdate`,`Apply Update`):t(`spoolbuddy.settings.deviceOffline`,`Device Offline`)}):(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:m,className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors`,children:t(`spoolbuddy.settings.checkUpdates`,`Check for Updates`)}),(0,K.jsx)(`button`,{onClick:h,disabled:!e.online,className:`px-3 py-2 rounded-lg text-xs font-medium bg-zinc-700 text-zinc-400 hover:bg-zinc-600 hover:text-zinc-200 disabled:opacity-40 transition-colors`,children:t(`spoolbuddy.settings.forceUpdate`,`Force Update`)})]}))]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`w-full flex justify-between items-center text-xs`,children:[(0,K.jsx)(`span`,{className:`font-medium text-zinc-400`,children:t(`spoolbuddy.settings.sshSetup`,`SSH Setup`)}),(0,K.jsx)(`svg`,{className:`w-3 h-3 text-zinc-500 transition-transform ${o?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]}),o&&(0,K.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t(`spoolbuddy.settings.sshDescription`,`SSH key is deployed automatically. For manual setup, add this key to ~/.ssh/authorized_keys on the device.`)}),p?.public_key?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`pre`,{className:`bg-zinc-900 rounded p-2 text-[10px] text-zinc-400 font-mono break-all whitespace-pre-wrap`,children:p.public_key}),(0,K.jsx)(`button`,{onClick:_,className:`absolute top-1 right-1 px-1.5 py-0.5 rounded text-[10px] bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors`,children:c?t(`common.copied`,`Copied!`):t(`common.copy`,`Copy`)})]}):(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 italic`,children:t(`spoolbuddy.settings.sshKeyLoading`,`Loading...`)})]})]})]})}function QQe({percent:e,color:t}){return(0,K.jsx)(`div`,{className:`w-full h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all ${t}`,style:{width:`${Math.min(100,Math.max(0,e))}%`}})})}function $Qe(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}function e$e({device:e}){let{t}=W(),n=e.system_stats;if(!n)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`p`,{className:`text-sm text-zinc-500`,children:t(`spoolbuddy.settings.systemStatsWaiting`,`Waiting for system stats...`)})});let r=n.memory,i=n.disk,a=(n.cpu_temp_c??0)>=80?`text-red-400`:(n.cpu_temp_c??0)>=65?`text-amber-400`:`text-green-400`,o=(r?.percent??0)>=90?`bg-red-500`:(r?.percent??0)>=70?`bg-amber-500`:`bg-green-500`,s=(i?.percent??0)>=90?`bg-red-500`:(i?.percent??0)>=70?`bg-amber-500`:`bg-green-500`;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:`CPU`}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.cores`,`Cores`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.cpu_count??`-`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.loadAvg`,`Load Avg`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.load_avg?n.load_avg.join(` / `):`-`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.temp`,`Temp`)}),(0,K.jsx)(`span`,{className:`font-mono font-medium ${a}`,children:n.cpu_temp_c==null?`-`:`${n.cpu_temp_c}\u00B0C`})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.memory`,`Memory`)}),r?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(QQe,{percent:r.percent??0,color:o}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.used`,`Used`)}),(0,K.jsxs)(`span`,{className:`text-zinc-300 font-mono`,children:[r.used_mb,` / `,r.total_mb,` MB`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.available`,`Free`)}),(0,K.jsxs)(`span`,{className:`text-zinc-300 font-mono`,children:[r.available_mb,` MB`]})]})]})]}):(0,K.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`-`})]})]}),(0,K.jsx)(`div`,{className:`bg-zinc-800 rounded-lg px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 shrink-0`,children:t(`spoolbuddy.settings.disk`,`Disk`)}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(QQe,{percent:i.percent??0,color:s})}),(0,K.jsxs)(`span`,{className:`text-xs text-zinc-300 font-mono shrink-0`,children:[i.used_gb,` / `,i.total_gb,` GB`]})]}):(0,K.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`-`})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1.5`,children:t(`spoolbuddy.settings.osInfo`,`OS`)}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[n.os?.os&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.distro`,`Distro`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 truncate ml-2`,children:n.os.os})]}),n.os?.kernel&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.kernel`,`Kernel`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono truncate ml-2`,children:n.os.kernel})]}),n.os?.arch&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.arch`,`Arch`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.os.arch})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1.5`,children:t(`spoolbuddy.settings.runtime`,`Runtime`)}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[n.os?.python&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`Python`}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.os.python})]}),n.system_uptime_s!=null&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.systemUptime`,`Uptime`)}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:$Qe(n.system_uptime_s)})]})]})]})]})]})}function t$e(){let{sbState:e,setDisplayBrightness:t}=nr(),{t:n}=W(),[r,i]=(0,y.useState)(`device`),{data:a=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:1e4}),o=e.deviceId?a.find(t=>t.device_id===e.deviceId)??a[0]:a[0],s=[{id:`device`,label:n(`spoolbuddy.settings.tabDevice`,`Device`)},{id:`display`,label:n(`spoolbuddy.settings.tabDisplay`,`Display`)},{id:`scale`,label:n(`spoolbuddy.settings.tabScale`,`Scale`)},{id:`updates`,label:n(`spoolbuddy.settings.tabUpdates`,`Updates`)},{id:`system`,label:n(`spoolbuddy.settings.tabSystem`,`System`)}];return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-zinc-100 mb-3`,children:n(`spoolbuddy.nav.settings`,`Settings`)}),(0,K.jsx)(`div`,{className:`flex gap-1 bg-zinc-800/50 rounded-lg p-1 mb-4`,children:s.map(e=>(0,K.jsx)(`button`,{onClick:()=>i(e.id),className:`flex-1 px-2 py-2 rounded-md text-sm font-medium transition-colors min-h-[36px] ${r===e.id?`bg-zinc-700 text-zinc-100`:`text-zinc-500 hover:text-zinc-300`}`,children:e.label},e.id))}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:o?(0,K.jsxs)(K.Fragment,{children:[r===`device`&&(0,K.jsx)(qQe,{device:o}),r===`display`&&(0,K.jsx)(JQe,{device:o,onBrightnessChange:t}),r===`scale`&&(0,K.jsx)(XQe,{device:o,weight:e.weight,weightStable:e.weightStable,rawAdc:e.rawAdc}),r===`updates`&&(0,K.jsx)(ZQe,{device:o}),r===`system`&&(0,K.jsx)(e$e,{device:o})]}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`div`,{className:`text-center text-zinc-500`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.settings.noDevice`,`No SpoolBuddy device found`)})})})})]})}function n$e({device:e,weight:t,weightStable:n,rawAdc:r}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(`idle`),[l,u]=(0,y.useState)(`500`),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),h=e=>{e===`backspace`?u(e=>e.slice(0,-1)||``):e===`.`&&!l.includes(`.`)?u(e=>e+`.`):e>=`0`&&e<=`9`&&u(t=>t===`0`?e:t+e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-400`,children:i(`spoolbuddy.settings.currentWeight`,`Current weight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-lg font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mt-3 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:i(`spoolbuddy.settings.tareOffset`,`Tare offset`)}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.tare_offset})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:i(`spoolbuddy.settings.calFactor`,`Cal. factor`)}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.calibration_factor.toFixed(2)})]})]})]}),s===`idle`?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:async()=>{m(!0);try{await od.tare(e.device_id)}catch(e){console.error(`Failed to tare:`,e)}finally{m(!1)}},disabled:p,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px]`,children:p?`...`:i(`spoolbuddy.weight.tare`,`Tare`)}),(0,K.jsx)(`button`,{onClick:()=>{c(`tare`)},className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:i(`spoolbuddy.weight.calibrate`,`Calibrate`)})]}):(0,K.jsxs)(`div`,{className:`bg-zinc-800 border border-zinc-700 rounded-lg p-3 space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-zinc-200`,children:s===`tare`?i(`spoolbuddy.settings.calStep1`,`Step 1: Remove all items from the scale`):i(`spoolbuddy.settings.calStep2`,`Step 2: Place known weight on scale`)}),s===`weight`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:i(`spoolbuddy.settings.knownWeight`,`Known weight (g)`)}),(0,K.jsxs)(`div`,{className:`flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1.5 text-right text-base font-mono text-zinc-100`,children:[l||`0`,(0,K.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`g`})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:[`7`,`8`,`9`,`backspace`,`4`,`5`,`6`,`.`,`1`,`2`,`3`,`0`].map(e=>(0,K.jsx)(`button`,{onClick:()=>h(e),className:`py-2 rounded text-sm font-medium transition-colors min-h-[36px] ${e===`backspace`?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700`}`,children:e===`backspace`?`⌫`:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>c(`idle`),className:`flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[40px]`,children:i(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:async()=>{if(s===`tare`){o(!0);try{f(r),await od.tare(e.device_id),c(`weight`)}catch(e){console.error(`Failed to tare:`,e)}finally{o(!1)}}else if(s===`weight`){let t=parseFloat(l);if(r===null||!t||t<=0)return;o(!0);try{await od.setCalibrationFactor(e.device_id,t,r,d??void 0),c(`idle`)}catch(e){console.error(`Failed to calibrate:`,e)}finally{o(!1)}}},disabled:a,className:`flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors min-h-[40px]`,children:a?`...`:s===`tare`?i(`spoolbuddy.settings.setZero`,`Set Zero`):i(`spoolbuddy.settings.calibrateNow`,`Calibrate`)})]})]})]})}function r$e(){let{sbState:e}=nr(),{t}=W(),n=$n(),{data:r=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:1e4}),i=e.deviceId?r.find(t=>t.device_id===e.deviceId)??r[0]:r[0];return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`button`,{onClick:()=>n(`/spoolbuddy/settings`),className:`p-1.5 rounded-lg text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800 transition-colors`,children:(0,K.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 19l-7-7 7-7`})})}),(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-zinc-100`,children:t(`spoolbuddy.settings.scaleCalibration`,`Scale Calibration`)})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:i?(0,K.jsx)(n$e,{device:i,weight:e.weight,weightStable:e.weightStable,rawAdc:e.rawAdc}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`div`,{className:`text-center text-zinc-500`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:t(`spoolbuddy.settings.noDevice`,`No SpoolBuddy device found`)})})})})]})}var i$e=[`PLA`,`PETG`,`ABS`,`ASA`,`TPU`,`PA`,`PC`,`PVA`,`HIPS`];function a$e(){let{t:e}=W(),{showToast:t}=Td(),{sbState:n}=nr(),[r,i]=(0,y.useState)(`existing`),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`idle`),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),{data:b}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),x=b!==void 0,S=b?.spoolman_enabled===`true`&&!!b?.spoolman_url,{data:C=[],refetch:w}=q({queryKey:[S?`spoolman-inventory-spools`:`inventory-spools`,`write-tag`],queryFn:()=>S?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),refetchInterval:1e4,enabled:x}),{data:T=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:5e3}),{data:E}=q({queryKey:[`settings`],queryFn:Q.getSettings}),D=T[0],O=n.deviceOnline,k=$d(E?.currency||`USD`),A=(0,y.useMemo)(()=>{let e;if(r===`existing`)e=C.filter(e=>!e.tag_uid&&!e.archived_at);else if(r===`replace`)e=C.filter(e=>(e.tag_uid||e.tray_uuid)&&!e.archived_at);else return[];if(s){let t=s.toLowerCase();e=e.filter(e=>e.material?.toLowerCase().includes(t)||e.color_name?.toLowerCase().includes(t)||e.brand?.toLowerCase().includes(t)||e.subtype?.toLowerCase().includes(t))}return e},[C,r,s]),j=(0,y.useCallback)(e=>{let t=e.detail;(t.sak??t.data?.sak)===0&&(g(!0),v(t.tag_uid??t.data?.tag_uid??null))},[]),M=(0,y.useCallback)(e=>{let t=e.detail;g(!0),v(t.tag_uid??t.data?.tag_uid??null)},[]),N=(0,y.useCallback)(()=>{g(!1),v(null)},[]),P=(0,y.useCallback)(t=>{let n=t.detail;(n.spool_id===a?.id||n.data?.spool_id===a?.id)&&(u(`success`),f(e(`spoolbuddy.writeTag.writeSuccess`,`Tag written successfully!`)),w(),setTimeout(()=>{u(`idle`),o(null),f(``)},5e3))},[a,e,w]),F=(0,y.useCallback)(t=>{let n=t.detail;(n.spool_id===a?.id||n.data?.spool_id===a?.id)&&(u(`error`),f(n.message??n.data?.message??e(`spoolbuddy.writeTag.writeFailed`,`Write failed`)))},[a,e]);(0,y.useEffect)(()=>(window.addEventListener(`spoolbuddy-unknown-tag`,j),window.addEventListener(`spoolbuddy-tag-matched`,M),window.addEventListener(`spoolbuddy-tag-removed`,N),window.addEventListener(`spoolbuddy-tag-written`,P),window.addEventListener(`spoolbuddy-tag-write-failed`,F),()=>{window.removeEventListener(`spoolbuddy-unknown-tag`,j),window.removeEventListener(`spoolbuddy-tag-matched`,M),window.removeEventListener(`spoolbuddy-tag-removed`,N),window.removeEventListener(`spoolbuddy-tag-written`,P),window.removeEventListener(`spoolbuddy-tag-write-failed`,F)}),[j,M,N,P,F]),(0,y.useEffect)(()=>{o(null),u(`idle`),f(``),c(``)},[r]);let I=async()=>{if(!(!a||!D)){u(`writing`),f(e(`spoolbuddy.writeTag.waiting`,`Waiting for SpoolBuddy...`));try{let e=await od.writeTag(D.device_id,a.id);if(e?.warnings?.length)for(let n of e.warnings)t(n,`warning`)}catch{u(`error`),f(e(`spoolbuddy.writeTag.queueFailed`,`Failed to queue write command`))}}},L=async()=>{if(D){try{await od.cancelWrite(D.device_id)}catch{}u(`idle`),f(``)}},R=async()=>{if(!(!a||!o$e(a))){m(!0),u(`idle`),f(``);try{S?await Q.linkTagToSpoolmanSpool(a.id,{tag_uid:``,tray_uuid:``}):await Q.linkTagToSpool(a.id,{tag_uid:``,tray_uuid:``,data_origin:`manual`}),await w(),o(null),u(`success`),f(e(`spoolbuddy.writeTag.untagSuccess`,`Tag removed from spool`)),setTimeout(()=>{u(`idle`),f(``)},2500)}catch{u(`error`),f(e(`spoolbuddy.writeTag.untagFailed`,`Failed to remove tag from spool`))}finally{m(!1)}}},z=(0,y.useCallback)(e=>{o(e),u(`idle`),f(``),w()},[w]),B=a&&O&&l!==`writing`&&l!==`success`;return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`flex border-b border-bambu-dark-tertiary shrink-0`,children:[{key:`existing`,label:e(`spoolbuddy.writeTag.tabExisting`,`Existing Spool`)},{key:`new`,label:e(`spoolbuddy.writeTag.tabNew`,`New Spool`)},{key:`replace`,label:e(`spoolbuddy.writeTag.tabReplace`,`Replace Tag`)}].map(e=>(0,K.jsx)(`button`,{onClick:()=>i(e.key),className:`flex-1 py-3 text-sm font-medium transition-colors ${r===e.key?`text-bambu-green border-b-2 border-bambu-green bg-bambu-dark`:`text-zinc-400 hover:text-zinc-200 hover:bg-bambu-dark-tertiary`}`,children:e.label},e.key))}),(0,K.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden border-r border-bambu-dark-tertiary`,children:r===`new`?(0,K.jsx)(c$e,{currencySymbol:k,onCreated:z,selectedSpool:a,spoolmanMode:S,t:e}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`p-3 shrink-0`,children:(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:e(`spoolbuddy.writeTag.searchPlaceholder`,`Search by material, color, brand...`),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 pb-3 space-y-2`,children:A.length===0?(0,K.jsx)(`div`,{className:`text-center text-zinc-500 py-8 text-sm`,children:r===`existing`?e(`spoolbuddy.writeTag.noUntaggedSpools`,`No spools without tags`):e(`spoolbuddy.writeTag.noTaggedSpools`,`No spools with tags`)}):A.map(e=>(0,K.jsx)(s$e,{spool:e,selected:a?.id===e.id,showTag:r===`replace`,onClick:()=>{o(e),u(`idle`),f(``)}},e.id))})]})}),(0,K.jsx)(`div`,{className:`w-[340px] flex flex-col items-center justify-center p-6 shrink-0`,children:(0,K.jsx)(l$e,{writeStatus:l,writeMessage:d,selectedSpool:a,tagOnReader:h,tagUid:_,deviceOnline:O,canWrite:!!B,isReplace:r===`replace`,canUntag:r===`replace`&&!!a&&o$e(a),untagging:p,onWrite:I,onUntag:R,onCancel:L,onRetry:()=>{u(`idle`),f(``)},t:e})})]})]})}function o$e(e){return!!(e.tag_uid||e.tray_uuid)}function s$e({spool:e,selected:t,showTag:n,onClick:r}){let i=Math.max(0,e.label_weight-e.weight_used),a=e.label_weight>0?Math.round(i/e.label_weight*100):0;return(0,K.jsxs)(`button`,{onClick:r,className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${t?`bg-bambu-green/15 border border-bambu-green/50`:`bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-transparent`}`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full shrink-0 border border-white/10`,style:e.rgba?Jd(e.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-zinc-400`,children:[e.color_name&&(0,K.jsx)(`span`,{children:e.color_name}),(0,K.jsxs)(`span`,{children:[i,`g / `,e.label_weight,`g (`,a,`%)`]})]}),n&&e.tag_uid&&(0,K.jsx)(`div`,{className:`text-xs text-zinc-500 mt-0.5 font-mono`,children:e.tag_uid})]}),t&&(0,K.jsx)(`svg`,{className:`w-5 h-5 text-bambu-green shrink-0`,fill:`currentColor`,viewBox:`0 0 20 20`,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,clipRule:`evenodd`})})]})}function c$e({currencySymbol:e,onCreated:t,selectedSpool:n,spoolmanMode:r,t:i}){let{data:a=[]}=q({queryKey:[r?`spoolman-inventory-spools`:`inventory-spools`,`write-tag-form`],queryFn:()=>r?Q.getSpoolmanInventorySpools(!0):Q.getSpools(!0)}),{data:o}=q({queryKey:[`settings`],queryFn:Q.getSettings}),[s,c]=(0,y.useState)(`simple`),[l,u]=(0,y.useState)(`filament`),[d,f]=(0,y.useState)(p9),[p,m]=(0,y.useState)({}),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)([]),[A,j]=(0,y.useState)([]),[M,N]=(0,y.useState)([]),[P,F]=(0,y.useState)([]),[I,L]=(0,y.useState)([]),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)([]),[ee,te]=(0,y.useState)([]),[ne,re]=(0,y.useState)(new Set),[ie,H]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{V(MU())},[]),(0,y.useEffect)(()=>{let e=!1;return(async()=>{if(s===`full`){D(!0);try{let[t,n]=await Promise.allSettled([(async()=>(await Q.getCloudStatus()).is_authenticated?{connected:!0,presets:await Q.getFilamentPresets()}:{connected:!1,presets:[]})(),(async()=>(await Q.orcaCloudStatus()).connected?{connected:!0,presets:(await Q.orcaCloudListProfiles()).filament}:{connected:!1,presets:[]})()]);if(e)return;let r=t.status===`fulfilled`&&t.value.connected,i=n.status===`fulfilled`&&n.value.connected,a=t.status===`fulfilled`?t.value.presets:[],o=n.status===`fulfilled`?n.value.presets:[];T(r||i),k([...a,...o])}catch{e||T(!1)}finally{e||D(!1)}Q.getSpoolCatalog().then(t=>{e||F(t)}).catch(()=>void 0),Q.getColorCatalog().then(t=>{e||L(t)}).catch(()=>void 0),Q.getLocalPresets().then(t=>{e||j(t.filament)}).catch(()=>void 0),Q.getBuiltinFilaments().then(t=>{e||N(t)}).catch(()=>void 0);try{let t=await Q.getPrinters(),n=await Promise.all(t.map(e=>Q.getPrinterStatus(e.id).catch(()=>null))),r=[];for(let e=0;e({cali_idx:e.slot_id,filament_id:e.filament_id,setting_id:e.setting_id||``,name:e.name,k_value:parseFloat(e.k_value)||0,n_coef:parseFloat(e.n_coef)||0,extruder_id:e.extruder_id,nozzle_diameter:e.nozzle_diameter}))}catch{}r.push({printer:{...i,connected:a},calibrations:o})}e||te(r)}catch{}}})(),()=>{e=!0}},[s]),(0,y.useEffect)(()=>{ee.length>0&&H(new Set(ee.map(e=>String(e.printer.id))))},[ee]);let ae=(0,y.useMemo)(()=>AU(O,new Set,A,M),[O,A,M]),oe=(0,y.useMemo)(()=>jU(d.slicer_filament,ae),[d.slicer_filament,ae]),U=(0,y.useMemo)(()=>{let e=kU(O,A),t=I.map(e=>e.manufacturer?.trim()).filter(e=>!!e);return Array.from(new Set([...e,...t])).sort((e,t)=>e.localeCompare(t))},[O,A,I]),se=(0,y.useMemo)(()=>{let e=I.map(e=>e.material?.trim()).filter(e=>!!e);return Array.from(new Set([...SU,...e])).sort((e,t)=>e.localeCompare(t))},[I]),ce=(0,y.useMemo)(()=>{let e=[];for(let t of I){let n=t.manufacturer?.trim(),r=t.material?.trim();n&&r&&e.push({brand:n,material:r})}for(let t of O){let n=OU(t.name);n.brand&&n.material&&e.push({brand:n.brand,material:n.material})}for(let t of A){let n=OU(t.name),r=t.filament_vendor?.trim()||n.brand,i=n.material;r&&i&&e.push({brand:r,material:i})}return e},[O,I,A]),le=(0,y.useMemo)(()=>{let e=new Map;for(let t of ce){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(n)||e.set(n,new Set),e.get(n).add(r)}return e},[ce]),ue=(0,y.useMemo)(()=>{let e=new Map;for(let t of ce){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(r)||e.set(r,new Set),e.get(r).add(n)}return e},[ce]),de=(0,y.useMemo)(()=>{if(!d.material)return U;let e=d.material.toLowerCase(),t=ue.get(e);return!t||t.size===0?U:U.filter(e=>t.has(e.toLowerCase()))},[U,d.material,ue]),fe=(0,y.useMemo)(()=>{if(!d.brand)return se;let e=d.brand.toLowerCase(),t=le.get(e);return!t||t.size===0?se:se.filter(e=>t.has(e.toLowerCase()))},[se,d.brand,le]),pe=(e,t)=>{f(n=>({...n,[e]:t})),p[e]&&m(t=>({...t,[e]:void 0}))},me=e=>{V(t=>NU(e,t))},he=async e=>{let t=r?Q.saveSpoolmanKProfiles:Q.saveSpoolKProfiles;if(ne.size===0){try{await t(e,[])}catch{}return}let n=[];for(let e of ne){let[t,r,i]=e.split(`:`),a=parseInt(t),o=parseInt(r),s=i===`null`?0:parseInt(i),c=ee.find(e=>e.printer.id===a);if(c){let e=c.calibrations.find(e=>e.cali_idx===o);e&&n.push({printer_id:a,extruder:s,nozzle_diameter:e.nozzle_diameter||`0.4`,k_value:e.k_value,name:e.name||null,cali_idx:e.cali_idx,setting_id:e.setting_id||null})}}n.length>0&&await t(e,n)},ge=async()=>{C(null);let e=m9(d,s===`simple`?!0:h);if(!e.isValid){m(e.errors),u(`filament`);return}let n=oe?.displayName||R||null,a={material:d.material,subtype:d.subtype||null,brand:d.brand||null,color_name:d.color_name||null,rgba:d.rgba||null,extra_colors:d.extra_colors||null,effect_type:d.effect_type||null,label_weight:d.label_weight,core_weight:d.core_weight,core_weight_catalog_id:d.core_weight_catalog_id,weight_used:d.weight_used,slicer_filament:d.slicer_filament||null,slicer_filament_name:n,nozzle_temp_min:null,nozzle_temp_max:null,note:d.note||null,cost_per_kg:d.cost_per_kg,added_full:null,last_used:null,encode_time:null,tag_uid:null,tray_uuid:null,data_origin:null,tag_type:null,last_scale_weight:null,last_weighed_at:null,category:d.category.trim()||null,low_stock_threshold_pct:d.low_stock_threshold_pct};x(!0);try{if(_>1){let e=r?await Q.bulkCreateSpoolmanInventorySpools(a,_):await Q.bulkCreateSpools(a,_),n=r&&e&&typeof e==`object`&&`created`in e?e.created:e;for(let e of n)await he(e.id);n.length>0&&t(n[0])}else{let e=r?await Q.createSpoolmanInventorySpool(a):await Q.createSpool(a);await he(e.id),t(e)}}catch{C(i(`spoolbuddy.writeTag.createFailed`,`Failed to create spool`))}finally{x(!1)}},_e=`#${(d.rgba||`808080FF`).slice(0,6)}`;return(0,K.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-200`,children:i(`spoolbuddy.writeTag.viewMode`,`View`)}),(0,K.jsxs)(`div`,{className:`flex rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(`simple`),className:`px-3 py-1.5 text-xs font-medium ${s===`simple`?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-zinc-400`}`,children:i(`spoolbuddy.writeTag.simpleView`,`Simple`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(`full`),className:`px-3 py-1.5 text-xs font-medium ${s===`full`?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-zinc-400`}`,children:i(`spoolbuddy.writeTag.fullView`,`Full`)})]})]}),s===`simple`?n?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-6 text-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`div`,{className:`w-12 h-12 rounded-full mb-4 border border-white/10`,style:n.rgba?Jd(n.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`p`,{className:`text-white font-medium`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:n.color_name}),(0,K.jsxs)(`p`,{className:`text-zinc-500 text-xs mt-1`,children:[n.label_weight,`g`]}),(0,K.jsx)(`p`,{className:`text-bambu-green text-sm mt-4`,children:i(`spoolbuddy.writeTag.spoolCreated`,`Spool created! Ready to write.`)})]}):(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.material`,`Material`)}),(0,K.jsx)(`select`,{value:d.material,onChange:e=>pe(`material`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,children:i$e.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.colorName`,`Color Name`)}),(0,K.jsx)(`input`,{type:`text`,value:d.color_name,onChange:e=>pe(`color_name`,e.target.value),placeholder:`Jade White`,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.color`,`Color`)}),(0,K.jsx)(`input`,{type:`color`,value:_e,onChange:e=>pe(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`),className:`w-10 h-9 bg-transparent border border-bambu-dark-tertiary rounded cursor-pointer`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.brand`,`Brand`)}),(0,K.jsx)(`input`,{type:`text`,value:d.brand,onChange:e=>pe(`brand`,e.target.value),placeholder:`Polymaker`,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.weight`,`Weight (g)`)}),(0,K.jsx)(`input`,{type:`number`,value:d.label_weight,onChange:e=>pe(`label_weight`,parseInt(e.target.value)||0),min:0,max:1e4,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`})]}),(0,K.jsx)(`button`,{onClick:ge,disabled:b||!d.material,className:`w-full py-2.5 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded transition-colors`,children:b?i(`spoolbuddy.writeTag.creating`,`Creating...`):i(`spoolbuddy.writeTag.createSpool`,`Create Spool`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-200`,children:i(`inventory.quickAdd`,`Quick Add`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${h?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4.5 w-4.5 rounded-full bg-white transition-transform ${h?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`flex border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>u(`filament`),className:`flex-1 py-2.5 text-sm font-medium ${l===`filament`?`bg-bambu-green/15 text-bambu-green`:`bg-bambu-dark-secondary text-zinc-400`}`,children:i(`inventory.filamentInfoTab`,`Filament`)}),!h&&(0,K.jsx)(`button`,{onClick:()=>u(`pa-profile`),className:`flex-1 py-2.5 text-sm font-medium ${l===`pa-profile`?`bg-bambu-green/15 text-bambu-green`:`bg-bambu-dark-secondary text-zinc-400`}`,children:i(`inventory.paProfileTab`,`PA Profile`)})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-3`,children:l===`filament`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(h9,{formData:d,updateField:pe,cloudAuthenticated:w,loadingCloudPresets:E,presetInputValue:R,setPresetInputValue:z,selectedPresetOption:oe,filamentOptions:ae,availableBrands:de,availableMaterials:fe,quickAdd:h,quantity:_,onQuantityChange:v,errors:p}),(0,K.jsx)(g9,{formData:d,updateField:pe,recentColors:B,onColorUsed:me,catalogColors:I}),(0,K.jsx)(_9,{formData:d,updateField:pe,spoolCatalog:P,currencySymbol:e,availableCategories:Array.from(new Set(a.map(e=>e.category?.trim()).filter(e=>!!e))).sort((e,t)=>e.localeCompare(t)),globalLowStockThreshold:o?.low_stock_threshold??20})]}):(0,K.jsx)(v9,{formData:d,updateField:pe,printersWithCalibrations:ee,selectedProfiles:ne,setSelectedProfiles:re,expandedPrinters:ie,setExpandedPrinters:H})})]}),S&&(0,K.jsx)(`div`,{className:`text-sm text-red-400 bg-red-900/20 border border-red-900/40 rounded-lg px-3 py-2`,children:S}),s===`full`&&(0,K.jsx)(`button`,{onClick:ge,disabled:b,className:`w-full py-3 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded transition-colors`,children:b?i(`spoolbuddy.writeTag.creating`,`Creating...`):i(`spoolbuddy.writeTag.createSpool`,`Create Spool`)}),s===`full`&&n&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4 text-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`div`,{className:`w-12 h-12 rounded-full mb-4 border border-white/10`,style:n.rgba?Jd(n.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`p`,{className:`text-white font-medium`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:n.color_name}),(0,K.jsxs)(`p`,{className:`text-zinc-500 text-xs mt-1`,children:[n.label_weight,`g`]}),(0,K.jsx)(`p`,{className:`text-bambu-green text-sm mt-4`,children:i(`spoolbuddy.writeTag.spoolCreated`,`Spool created! Ready to write.`)})]})]})}function l$e({writeStatus:e,writeMessage:t,selectedSpool:n,tagOnReader:r,tagUid:i,deviceOnline:a,canWrite:o,isReplace:s,canUntag:c,untagging:l,onWrite:u,onUntag:d,onCancel:f,onRetry:p,t:m}){if(e===`success`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-8 h-8 text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})})}),(0,K.jsx)(`p`,{className:`text-green-400 font-medium`,children:t}),n&&(0,K.jsxs)(`p`,{className:`text-zinc-400 text-sm`,children:[n.brand?`${n.brand} `:``,n.material,n.color_name?` - ${n.color_name}`:``]})]});if(e===`error`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-8 h-8 text-red-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})}),(0,K.jsx)(`p`,{className:`text-red-400 font-medium`,children:t}),(0,K.jsx)(`button`,{onClick:p,className:`px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-white text-sm rounded transition-colors`,children:m(`spoolbuddy.writeTag.tryAgain`,`Try Again`)})]});if(e===`writing`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsxs)(`div`,{className:`relative w-16 h-16`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-bambu-green/30 animate-ping`}),(0,K.jsx)(`div`,{className:`absolute inset-2 rounded-full border-2 border-bambu-green/50 animate-pulse`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-bambu-green`})})]}),(0,K.jsx)(`p`,{className:`text-bambu-green font-medium`,children:m(`spoolbuddy.writeTag.writing`,`Writing tag...`)}),(0,K.jsx)(`p`,{className:`text-zinc-500 text-xs`,children:t}),(0,K.jsx)(`button`,{onClick:f,className:`px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-zinc-400 text-sm rounded transition-colors`,children:m(`spoolbuddy.writeTag.cancel`,`Cancel`)})]});if(!a)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-3`,children:[(0,K.jsx)(Z9,{className:`w-12 h-12 text-zinc-600`}),(0,K.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:m(`spoolbuddy.writeTag.deviceOffline`,`SpoolBuddy is offline`)})]});if(!n)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-3`,children:[(0,K.jsx)(Z9,{className:`w-12 h-12 text-zinc-600`}),(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:m(`spoolbuddy.writeTag.selectSpool`,`Select a spool, then place a blank NTAG on the reader`)})]});let h=n.rgba?Jd(n.rgba):{backgroundColor:`#666`};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4 w-full`,children:[(0,K.jsx)(`div`,{className:`relative w-16 h-16`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-bambu-green/10`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-bambu-green`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-zinc-600 animate-pulse`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-zinc-500`})})]})}),r?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-bambu-green text-sm font-medium`,children:m(`spoolbuddy.writeTag.tagReady`,`Tag detected — ready to write`)}),i&&(0,K.jsx)(`p`,{className:`text-zinc-500 text-xs font-mono`,children:i})]}):(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:m(`spoolbuddy.writeTag.placeTag`,`Place an NTAG on the reader`)}),(0,K.jsxs)(`div`,{className:`w-full bg-bambu-dark-secondary rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 shrink-0`,style:h}),(0,K.jsxs)(`div`,{className:`text-left min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-xs`,children:n.color_name})]})]}),(0,K.jsxs)(`div`,{className:`text-xs text-zinc-500`,children:[n.label_weight,`g`]})]}),s&&n.tag_uid&&(0,K.jsx)(`p`,{className:`text-yellow-500/80 text-xs`,children:m(`spoolbuddy.writeTag.replaceWarning`,`Old tag will be unlinked. New tag will replace it.`)}),(0,K.jsx)(`button`,{onClick:u,disabled:!o,className:`w-full py-3 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-40 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors text-sm`,children:s?m(`spoolbuddy.writeTag.replaceTag`,`Replace Tag`):m(`spoolbuddy.writeTag.writeTag`,`Write Tag`)}),s&&c&&(0,K.jsx)(`button`,{onClick:d,disabled:l,className:`w-full py-2.5 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary disabled:opacity-40 disabled:cursor-not-allowed text-zinc-200 rounded-lg transition-colors text-sm`,children:l?m(`spoolbuddy.writeTag.untagging`,`Removing tag...`):m(`spoolbuddy.writeTag.untagSpool`,`Untag Selected Spool`)})]})}function Z9({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0`}),(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z`})]})}var u$e=`spoolbuddy-default-core-weight`;function d$e(){try{let e=localStorage.getItem(u$e);if(e){let t=parseInt(e,10);if(t>=0&&t<=500)return t}}catch{}return 250}function f$e({spool:e,liveScaleWeight:t,persistedGrossWeight:n,onClose:r,onSyncWeight:i,onAssignToAms:a,isAssigned:o,onUnassignFromAms:s,className:c}){let{t:l}=W(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),{data:g}=q({queryKey:[`spool-k-profiles`,e.id],queryFn:()=>Q.getSpoolKProfiles(e.id),enabled:!e.k_profiles||e.k_profiles.length===0,staleTime:300*1e3}),_=e.k_profiles&&e.k_profiles.length>0?e.k_profiles:g,v=qd(e.rgba),b=e.core_weight&&e.core_weight>0?e.core_weight:d$e(),x=t===null?null:Math.round(Math.max(0,t)),S=m??(n===void 0?x:n===null?null:Math.round(Math.max(0,n))),C=Math.round(Math.max(0,(e.label_weight||0)-(e.weight_used||0))),w=x!==null&&x>=10?Math.round(Math.max(0,x-b)):C,T=Math.round(e.label_weight||1e3),E=T>0?Math.min(100,Math.round(w/T*100)):null,D=E===null?`#808080`:E>50?`#22c55e`:E>20?`#eab308`:`#ef4444`,O=Math.max(0,(e.label_weight||0)-(e.weight_used||0))+b,k=x===null?null:x-O,A=k===null?null:Math.abs(k)<=50,j=S??Math.round(O),M=e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null?`${e.nozzle_temp_min}-${e.nozzle_temp_max}\u00B0C`:null,N=e.slicer_filament_name||e.slicer_filament||null,P=e.note?.trim()||null,F=_&&_.length>0?Array.from(new Set(_.map(e=>e.k_value.toFixed(3)))).join(`, `):null,I=async()=>{if(t===null)return;let n=Math.round(Math.max(0,t));d(!0);try{await od.updateSpoolWeight(e.id,n),h(n),p(!0),i?.(),setTimeout(()=>p(!1),3e3)}catch(e){console.error(`Failed to sync weight:`,e)}finally{d(!1)}};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-4 max-w-md ${c??``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsx)(G9,{color:v,isEmpty:!1,size:100}),E!==null&&(0,K.jsxs)(`div`,{className:`absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg`,style:{backgroundColor:D},children:[E,`%`]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]}),(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-3xl font-bold font-mono text-zinc-100`,children:[w,`g`]}),(0,K.jsxs)(`span`,{className:`text-sm text-zinc-500`,children:[`/ `,T,`g`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:l(`spoolbuddy.spool.remaining`,`Remaining`)}),(0,K.jsx)(`div`,{className:`mt-2 max-w-xs`,children:(0,K.jsx)(`div`,{className:`h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${E??0}%`,backgroundColor:D}})})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-4 w-full`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.grossWeight`,`Gross weight`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[j,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.spool.coreWeight`,`Core`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[b,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.spoolSize`,`Spool size`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[T,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.spool.scaleWeight`,`Scale`)}),x===null?(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`—`}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 font-mono ${A?`text-green-500`:`text-yellow-500`}`,children:[x,`g`,A?(0,K.jsx)(rs,{className:`w-3.5 h-3.5`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`button`,{onClick:I,className:`p-1 hover:bg-green-500/20 rounded transition-colors text-green-500`,title:l(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`),children:(0,K.jsx)(Ol,{className:`w-4 h-4`})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.tagId`,`Tag`)}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-zinc-400 truncate max-w-[120px]`,title:e.tag_uid||``,children:e.tag_uid?e.tag_uid.slice(-8):`—`})]}),M&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.nozzleTemp`,`Nozzle`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300`,children:M})]}),e.cost_per_kg!=null&&e.cost_per_kg>0&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.costPerKg`,`Cost/kg`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[e.cost_per_kg.toFixed(2),`/kg`]})]}),F&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.kProfiles`,`K-Profile`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300 truncate max-w-[220px] text-right`,title:F,children:F})]}),N&&(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-1`,children:l(`spoolbuddy.inventory.slicerFilament`,`Slicer Filament`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-300 whitespace-pre-wrap break-words`,children:N})]}),P&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-1`,children:l(`spoolbuddy.inventory.note`,`Note`)}),(0,K.jsx)(`p`,{className:`text-sm leading-5 text-zinc-300 whitespace-pre-wrap break-words max-h-[3.75rem] overflow-y-auto pr-1`,children:P})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[a&&(0,K.jsx)(`button`,{onClick:o?void 0:a,disabled:!!o,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px] disabled:opacity-50 disabled:cursor-not-allowed`,children:l(`spoolbuddy.modal.assignToAms`,`Assign to AMS`)}),s&&(0,K.jsxs)(`button`,{onClick:s,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-red-600/20 text-red-400 hover:bg-red-600/30 transition-colors min-h-[44px]`,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 inline mr-1`}),l(`inventory.unassignSpool`)]}),(0,K.jsx)(`button`,{onClick:I,disabled:t===null||u,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${f?`bg-green-600/20 text-green-400`:a?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600 disabled:opacity-40 disabled:cursor-not-allowed`:`bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed`}`,children:u?`...`:f?l(`spoolbuddy.dashboard.weightSynced`,`Synced!`):l(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`)}),r&&(0,K.jsx)(`button`,{onClick:r,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:l(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function p$e(e){return qd(e.rgba)}function m$e(e){return Math.max(0,e.label_weight-e.weight_used)}function h$e(e){return e.label_weight<=0?0:Math.max(0,Math.min(100,(e.label_weight-e.weight_used)/e.label_weight*100))}function g$e(e){let t=[e.material];return e.subtype&&t.push(e.subtype),t.join(` `)}function _$e(e){let t=e.ams_id===254||e.ams_id===255,n=!t&&e.ams_id>=128;return If(e.ams_id,e.tray_id,n,t)}function v$e({color:e,size:t=56}){return(0,K.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 56 56`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:e}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:e,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]})}function y$e(){let{sbState:e,selectedPrinterId:t}=nr(),{t:n}=W(),{showToast:r}=Td(),i=no(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),{data:p}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),m=p?.spoolman_enabled===`true`&&!!p?.spoolman_url,{data:h=[],isLoading:g,refetch:_}=q({queryKey:m?[`spoolman-inventory-spools`]:[`inventory-spools`],queryFn:()=>m?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),enabled:p!==void 0,refetchInterval:3e4}),{data:v=[]}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),refetchInterval:3e4,enabled:!m}),{data:b=[]}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),refetchInterval:3e4,enabled:m}),x=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),i.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},onError:()=>r(n(`inventory.unassignFailed`,`Failed to unassign spool`),`error`)}),S=(0,y.useMemo)(()=>{if(m){let e={};return b.forEach(t=>{e[t.spoolman_spool_id]={ams_id:t.ams_id,tray_id:t.tray_id}}),e}let e={};return v.forEach(t=>{e[t.spool_id]={ams_id:t.ams_id,tray_id:t.tray_id,printer_name:t.printer_name}}),e},[m,v,b]),C=(0,y.useMemo)(()=>h.filter(e=>!e.archived_at),[h]),w=(0,y.useMemo)(()=>new Set(Object.keys(S).map(Number)),[S]),T=(0,y.useMemo)(()=>C.filter(e=>w.has(e.id)).length,[C,w]),E=(0,y.useMemo)(()=>{let e=new Set;return C.forEach(t=>e.add(t.material)),Array.from(e).sort()},[C]),D=(0,y.useMemo)(()=>{let e=C;return s===`in_ams`?e=e.filter(e=>w.has(e.id)):s!==`all`&&(e=e.filter(e=>e.material===s)),e=mU(e,a.trim()),[...e].sort((e,t)=>{let n=+!w.has(e.id),r=+!w.has(t.id);return n===r?new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime():n-r})},[C,s,a,w]);return(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`px-3 pt-3 pb-2 space-y-2.5`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-white/40`}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`spoolbuddy.inventory.searchPlaceholder`,`Search spools...`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-white/30 focus:outline-none focus:border-bambu-green`}),a&&(0,K.jsx)(`button`,{onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/60`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5 overflow-x-auto no-scrollbar`,children:[(0,K.jsx)(Q9,{active:s===`all`,onClick:()=>c(`all`),label:`${n(`spoolbuddy.inventory.all`,`All`)} (${C.length})`,green:!0}),T>0&&(0,K.jsx)(Q9,{active:s===`in_ams`,onClick:()=>c(`in_ams`),label:`${n(`spoolbuddy.inventory.inAms`,`In AMS`)} (${T})`}),E.map(e=>(0,K.jsx)(Q9,{active:s===e,onClick:()=>c(s===e?`all`:e),label:e},e))]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 pb-3`,children:g?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(`div`,{className:`w-8 h-8 border-2 border-bambu-green border-t-transparent rounded-full animate-spin`})}):D.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-white/30`,children:[(0,K.jsx)(pl,{className:`w-12 h-12 mb-3`}),(0,K.jsx)(`p`,{className:`text-sm`,children:a||s!==`all`?n(`spoolbuddy.inventory.noResults`,`No spools match your filters`):n(`spoolbuddy.inventory.empty`,`No spools in inventory`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(130px,1fr))] gap-2`,children:D.map(e=>(0,K.jsx)(b$e,{spool:e,assignment:S[e.id],onClick:()=>u(e.id)},e.id))})}),l!=null&&(()=>{let n=h.find(e=>e.id===l);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x$e,{spool:n,assignment:S[n.id],sbState:e,onSyncWeight:()=>{_()},onAssignToAms:()=>f(!0),onUnassignFromAms:m&&S[n.id]?()=>x.mutate(n.id):void 0,onClose:()=>{u(null),f(!1)}}),(0,K.jsx)(jQe,{isOpen:d,onClose:()=>f(!1),spool:n,printerId:t,spoolmanMode:m})]}):null})()]})}function Q9({active:e,onClick:t,label:n,green:r}){return(0,K.jsx)(`button`,{onClick:t,className:`px-4 py-1.5 rounded-full text-sm font-medium border whitespace-nowrap shrink-0 transition-colors ${e?r?`bg-bambu-green/20 text-bambu-green border-bambu-green/50`:`bg-white/10 text-white border-white/20`:`bg-transparent text-white/40 border-bambu-dark-tertiary hover:text-white/60`}`,children:n})}function b$e({spool:e,assignment:t,onClick:n}){let r=p$e(e),i=h$e(e),a=m$e(e),o=Kd(e.color_name,e.rgba);return(0,K.jsxs)(`button`,{onClick:n,className:`bg-bambu-dark-secondary rounded-xl p-3 flex flex-col items-center text-center gap-1.5 border border-transparent hover:border-bambu-green/50 transition-colors`,children:[(0,K.jsx)(v$e,{color:r,size:56}),(0,K.jsx)(`p`,{className:`text-xs font-semibold text-white leading-tight truncate w-full`,children:g$e(e)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 max-w-full`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 border border-white/10`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-[11px] text-white/50 truncate`,children:o||`-`})]}),(0,K.jsxs)(`div`,{className:`w-full space-y-0.5`,children:[(0,K.jsx)(`div`,{className:`h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${i>50?`bg-bambu-green`:i>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(i,100)}%`}})}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white/40`,children:[Math.round(a),`g (`,Math.round(i),`%)`]})]}),t&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] font-bold bg-bambu-green/20 text-bambu-green`,children:_$e(t)})]})}function x$e({spool:e,assignment:t,sbState:n,onSyncWeight:r,onAssignToAms:i,onUnassignFromAms:a,onClose:o}){let s=n.deviceOnline&&n.weight!==null?Math.round(n.weight):null,c=e.last_scale_weight==null?null:Math.round(e.last_scale_weight);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4`,onClick:o,children:(0,K.jsx)(`div`,{className:`w-full max-w-md bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-2xl p-4 overflow-y-auto max-h-[90vh]`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-1 rounded-md text-xs font-bold bg-bambu-green/20 text-bambu-green`,children:_$e(t)}),t.printer_name&&(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:t.printer_name})]}),(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(f$e,{spool:e,liveScaleWeight:s,persistedGrossWeight:c,onSyncWeight:r,onAssignToAms:i,isAssigned:!!t,onUnassignFromAms:a,onClose:o,className:`max-w-md`})})]})})})}var S$e=class extends y.Component{state={error:null,errorInfo:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.setState({errorInfo:t}),console.error(`React crash:`,e,t)}render(){return this.state.error?(0,K.jsxs)(`div`,{style:{padding:24,color:`#ef4444`,backgroundColor:`#18181b`,minHeight:`100vh`,fontFamily:`monospace`},children:[(0,K.jsx)(`h1`,{style:{fontSize:20,marginBottom:12},children:`UI Crash`}),(0,K.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,fontSize:14},children:this.state.error.message}),(0,K.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,fontSize:12,color:`#a1a1aa`,marginTop:12},children:this.state.error.stack}),(0,K.jsx)(`button`,{onClick:()=>{this.setState({error:null,errorInfo:null})},style:{marginTop:16,padding:`8px 16px`,backgroundColor:`#3b82f6`,color:`#fff`,border:`none`,borderRadius:8,cursor:`pointer`},children:`Retry`})]}):this.props.children}},C$e=new $a({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function w$e(){return r9(),null}function T$e({children:e}){return XZe(),(0,K.jsx)(K.Fragment,{children:e})}function E$e({children:e}){let{authEnabled:t,loading:n,user:r}=dd(),i=Xn();return n?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):t&&!r?(0,K.jsx)(Or,{to:`/login`,replace:!0,state:{from:i}}):(0,K.jsx)(K.Fragment,{children:e})}function $9({permission:e,children:t}){let{authEnabled:n,loading:r,user:i,hasPermission:a}=dd(),o=Xn();return r?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):n?i?a(e)?(0,K.jsx)(K.Fragment,{children:t}):(0,K.jsx)(Or,{to:`/`,replace:!0}):(0,K.jsx)(Or,{to:`/login`,replace:!0,state:{from:o}}):(0,K.jsx)(K.Fragment,{children:t})}function D$e({children:e}){let{authEnabled:t,loading:n}=dd();return n?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):t?(0,K.jsx)(Or,{to:`/login`,replace:!0}):(0,K.jsx)(K.Fragment,{children:e})}function O$e(){return(0,K.jsx)(S$e,{children:(0,K.jsx)(Od,{children:(0,K.jsx)(ro,{client:C$e,children:(0,K.jsx)(ud,{children:(0,K.jsx)(pd,{children:(0,K.jsx)(ZZe,{children:(0,K.jsxs)(Xke,{children:[(0,K.jsx)(w$e,{}),(0,K.jsx)(xi,{children:(0,K.jsxs)(Mr,{children:[(0,K.jsx)(Ar,{path:`/setup`,element:(0,K.jsx)(D$e,{children:(0,K.jsx)(qZe,{})})}),(0,K.jsx)(Ar,{path:`/login`,element:(0,K.jsx)(KZe,{})}),(0,K.jsx)(Ar,{path:`/camera/:printerId`,element:(0,K.jsx)(DXe,{})}),(0,K.jsx)(Ar,{path:`/overlay/:printerId`,element:(0,K.jsx)(MXe,{})}),(0,K.jsxs)(Ar,{element:(0,K.jsx)(E$e,{children:(0,K.jsx)(T$e,{children:(0,K.jsx)(lQe,{})})}),children:[(0,K.jsx)(Ar,{path:`spoolbuddy`,element:(0,K.jsx)(RQe,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/ams`,element:(0,K.jsx)(HQe,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/write-tag`,element:(0,K.jsx)(a$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/inventory`,element:(0,K.jsx)(y$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/settings`,element:(0,K.jsx)(t$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/calibration`,element:(0,K.jsx)(r$e,{})})]}),(0,K.jsxs)(Ar,{element:(0,K.jsx)(E$e,{children:(0,K.jsx)(T$e,{children:(0,K.jsx)(Dp,{})})}),children:[(0,K.jsx)(Ar,{index:!0,element:(0,K.jsx)(Gke,{})}),(0,K.jsx)(Ar,{path:`archives`,element:(0,K.jsx)(hze,{})}),(0,K.jsx)(Ar,{path:`queue`,element:(0,K.jsx)(mVe,{})}),(0,K.jsx)(Ar,{path:`stats`,element:(0,K.jsx)(NVe,{})}),(0,K.jsx)(Ar,{path:`profiles`,element:(0,K.jsx)(wUe,{})}),(0,K.jsx)(Ar,{path:`maintenance`,element:(0,K.jsx)(kUe,{})}),(0,K.jsx)(Ar,{path:`projects`,element:(0,K.jsx)(MUe,{})}),(0,K.jsx)(Ar,{path:`projects/:id`,element:(0,K.jsx)(RUe,{})}),(0,K.jsx)(Ar,{path:`inventory`,element:(0,K.jsx)(CZe,{})}),(0,K.jsx)(Ar,{path:`files`,element:(0,K.jsx)(bXe,{})}),(0,K.jsx)(Ar,{path:`files/trash`,element:(0,K.jsx)(SXe,{})}),(0,K.jsx)(Ar,{path:`makerworld`,element:(0,K.jsx)($9,{permission:`makerworld:view`,children:(0,K.jsx)(FZe,{})})}),(0,K.jsx)(Ar,{path:`settings`,element:(0,K.jsx)($9,{permission:`settings:read`,children:(0,K.jsx)(tUe,{})})}),(0,K.jsx)(Ar,{path:`groups/new`,element:(0,K.jsx)($9,{permission:`groups:create`,children:(0,K.jsx)(a9,{})})}),(0,K.jsx)(Ar,{path:`groups/:id/edit`,element:(0,K.jsx)($9,{permission:`groups:update`,children:(0,K.jsx)(a9,{})})}),(0,K.jsx)(Ar,{path:`users`,element:(0,K.jsx)(Or,{to:`/settings?tab=users`,replace:!0})}),(0,K.jsx)(Ar,{path:`groups`,element:(0,K.jsx)(Or,{to:`/settings?tab=users`,replace:!0})}),(0,K.jsx)(Ar,{path:`system`,element:(0,K.jsx)(VZe,{})}),(0,K.jsx)(Ar,{path:`notifications`,element:(0,K.jsx)(JZe,{})}),(0,K.jsx)(Ar,{path:`gcode-viewer`,element:(0,K.jsx)(YZe,{})}),(0,K.jsx)(Ar,{path:`external/:id`,element:(0,K.jsx)(NXe,{})}),(0,K.jsx)(Ar,{path:`camera-tokens`,element:(0,K.jsx)(Or,{to:`/settings?tab=apikeys#card-camera-tokens`,replace:!0})})]})]})})]})})})})})})})}(0,b.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(y.StrictMode,{children:(0,K.jsx)(O$e,{})})); \ No newline at end of file +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function w(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&arguments[1]!==void 0?arguments[1]:e;this.caretPosition=e,this.caretPositionEnd=t}},{key:`getInputCandidates`,value:function(e){var t=this,n=this.options,r=n.layoutCandidates,i=n.layoutCandidatesCaseSensitiveMatch;if(!r||T(r)!==`object`)return{};var a=Object.keys(r).filter((function(n){var r=e.substring(0,t.getCaretPositionEnd()||0)||e,a=RegExp(`${t.utilities.escapeRegex(n)}\$`,i?`g`:`gi`);return!!C(r.matchAll(a)).length}));if(a.length>1){var o=a.sort((function(e,t){return t.length-e.length}))[0];return{candidateKey:o,candidateValue:r[o]}}if(a.length){var s=a[0];return{candidateKey:s,candidateValue:r[s]}}return{}}},{key:`showCandidatesBox`,value:function(e,t,n){var r=this;this.candidateBox&&this.candidateBox.show({candidateValue:t,targetElement:n,onSelect:function(t,n){var i=r.options,a=i.layoutCandidatesCaseSensitiveMatch,o=i.disableCandidateNormalization,s=i.enableLayoutCandidatesKeyPress,c=t;o||(c=t.normalize(`NFD`)),typeof r.options.beforeInputUpdate==`function`&&r.options.beforeInputUpdate(r);var l=r.getInput(r.options.inputName,!0),u=r.getCaretPositionEnd()||0,d=l.substring(0,u||0)||l,f=RegExp(`${r.utilities.escapeRegex(e)}\$`,a?`g`:`gi`),p=d.replace(f,c),m=l.replace(d,p),h=p.length-d.length,g=(u||l.length)+h;g<0&&(g=0),r.setInput(m,r.options.inputName,!0),r.setCaretPosition(g),s&&typeof r.options.onKeyPress==`function`&&r.options.onKeyPress(t,n),typeof r.options.onChange==`function`&&r.options.onChange(r.getInput(r.options.inputName,!0),n),typeof r.options.onChangeAll==`function`&&r.options.onChangeAll(r.getAllInputs(),n)}})}},{key:`handleButtonClicked`,value:function(e,t){var n=this.options,r=n.inputName,i=r===void 0?this.defaultName:r,a=n.debug;if(e!==`{//}`){this.input[i]||(this.input[i]=``),typeof this.options.beforeInputUpdate==`function`&&this.options.beforeInputUpdate(this);var o=this.utilities.getUpdatedInput(e,this.input[i],this.caretPosition,this.caretPositionEnd);if(this.utilities.isStandardButton(e)&&this.activeInputElement&&this.input[i]&&this.input[i]===o&&this.caretPosition===0&&this.caretPositionEnd===o.length)return this.setInput(``,this.options.inputName,!0),this.setCaretPosition(0),this.activeInputElement.value=``,this.activeInputElement.setSelectionRange(0,0),void this.handleButtonClicked(e,t);if(typeof this.options.onKeyPress==`function`&&this.options.onKeyPress(e,t),this.input[i]!==o&&(!this.options.inputPattern||this.options.inputPattern&&this.inputPatternIsValid(o))){if(this.options.maxLength&&this.utilities.handleMaxLength(this.input,o))return;var s=this.utilities.getUpdatedInput(e,this.input[i],this.caretPosition,this.caretPositionEnd,!0);if(this.setInput(s,this.options.inputName,!0),a&&console.log(`Input changed:`,this.getAllInputs()),this.options.debug&&console.log(`Caret at: `,this.getCaretPosition(),this.getCaretPositionEnd(),`(${this.keyboardDOMClass})`,t?.type),this.options.syncInstanceInputs&&this.syncInstanceInputs(),typeof this.options.onChange==`function`&&this.options.onChange(this.getInput(this.options.inputName,!0),t),typeof this.options.onChangeAll==`function`&&this.options.onChangeAll(this.getAllInputs(),t),t!=null&&t.target&&this.options.enableLayoutCandidates){var c,l=this.getInputCandidates(o),u=l.candidateKey,d=l.candidateValue;u&&d?this.showCandidatesBox(u,d,this.keyboardDOM):(c=this.candidateBox)==null||c.destroy()}}this.caretPositionEnd&&this.caretPosition!==this.caretPositionEnd&&(this.setCaretPosition(this.caretPositionEnd,this.caretPositionEnd),this.activeInputElement&&this.activeInputElement.setSelectionRange(this.caretPositionEnd,this.caretPositionEnd),this.options.debug&&console.log(`Caret position aligned`,this.caretPosition)),a&&console.log(`Key pressed:`,e)}}},{key:`getMouseHold`,value:function(){return this.isMouseHold}},{key:`setMouseHold`,value:function(e){this.options.syncInstanceInputs?this.dispatch((function(t){t.isMouseHold=e})):this.isMouseHold=e}},{key:`handleButtonMouseDown`,value:function(e,t){var n=this;t&&(this.options.preventMouseDownDefault&&t.preventDefault(),this.options.stopMouseDownPropagation&&t.stopPropagation(),t.target.classList.add(this.activeButtonClass)),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdTimeout&&clearTimeout(this.holdTimeout),this.setMouseHold(!0),this.options.disableButtonHold||(this.holdTimeout=window.setTimeout((function(){(n.getMouseHold()&&(!e.includes(`{`)&&!e.includes(`}`)||e===`{delete}`||e===`{backspace}`||e===`{bksp}`||e===`{space}`||e===`{tab}`)||e===`{arrowright}`||e===`{arrowleft}`||e===`{arrowup}`||e===`{arrowdown}`)&&(n.options.debug&&console.log(`Button held:`,e),n.handleButtonHold(e)),clearTimeout(n.holdTimeout)}),500))}},{key:`handleButtonMouseUp`,value:function(e,t){var n=this;t&&(this.options.preventMouseUpDefault&&t.preventDefault&&t.preventDefault(),this.options.stopMouseUpPropagation&&t.stopPropagation&&t.stopPropagation(),!(t.target===this.keyboardDOM||t.target&&this.keyboardDOM.contains(t.target)||this.candidateBox&&this.candidateBox.candidateBoxElement&&(t.target===this.candidateBox.candidateBoxElement||t.target&&this.candidateBox.candidateBoxElement.contains(t.target)))&&this.candidateBox&&this.candidateBox.destroy()),this.recurseButtons((function(e){e.classList.remove(n.activeButtonClass)})),this.setMouseHold(!1),this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),e&&typeof this.options.onKeyReleased==`function`&&this.options.onKeyReleased(e,t)}},{key:`handleKeyboardContainerMouseDown`,value:function(e){this.options.preventMouseDownDefault&&e.preventDefault()}},{key:`handleButtonHold`,value:function(e){var t=this;this.holdInteractionTimeout&&clearTimeout(this.holdInteractionTimeout),this.holdInteractionTimeout=window.setTimeout((function(){t.getMouseHold()?(t.handleButtonClicked(e),t.handleButtonHold(e)):clearTimeout(t.holdInteractionTimeout)}),100)}},{key:`syncInstanceInputs`,value:function(){var e=this;this.dispatch((function(t){t.replaceInput(e.input),t.setCaretPosition(e.caretPosition,e.caretPositionEnd)}))}},{key:`clearInput`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName;this.input[e]=``,this.setCaretPosition(0),this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:`getInput`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.inputName||this.defaultName,t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.options.syncInstanceInputs&&!t&&this.syncInstanceInputs(),this.options.rtl?`‫`+this.input[e].replace(`‫`,``).replace(`‬`,``)+`‬`:this.input[e]}},{key:`getAllInputs`,value:function(){var e=this,t={};return Object.keys(this.input).forEach((function(n){t[n]=e.getInput(n,!0)})),t}},{key:`setInput`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.inputName||this.defaultName,n=arguments.length>2?arguments[2]:void 0;this.input[t]=e,!n&&this.options.syncInstanceInputs&&this.syncInstanceInputs()}},{key:`replaceInput`,value:function(e){this.input=e}},{key:`setOptions`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=this.changedOptions(e);this.options=Object.assign(this.options,e),t.length&&(this.options.debug&&console.log(`changedOptions`,t),this.onSetOptions(t),this.render())}},{key:`changedOptions`,value:function(e){var t=this;return Object.keys(e).filter((function(n){return JSON.stringify(e[n])!==JSON.stringify(t.options[n])}))}},{key:`onSetOptions`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];e.includes(`layoutName`)&&this.candidateBox&&this.candidateBox.destroy(),(e.includes(`layoutCandidatesPageSize`)||e.includes(`layoutCandidates`))&&this.candidateBox&&(this.candidateBox.destroy(),this.candidateBox=new S({utilities:this.utilities,options:this.options}))}},{key:`resetRows`,value:function(){this.keyboardRowsDOM&&this.keyboardRowsDOM.remove(),this.keyboardDOM.className=this.keyboardDOMClass,this.keyboardDOM.setAttribute(`data-skInstance`,this.currentInstanceName),this.buttonElements={}}},{key:`dispatch`,value:function(e){if(!window.SimpleKeyboardInstances)throw console.warn(`SimpleKeyboardInstances is not defined. Dispatch cannot be called.`),Error(`INSTANCES_VAR_ERROR`);return Object.keys(window.SimpleKeyboardInstances).forEach((function(t){e(window.SimpleKeyboardInstances[t],t)}))}},{key:`addButtonTheme`,value:function(e,t){var n=this;t&&e&&(e.split(` `).forEach((function(r){t.split(` `).forEach((function(t){n.options.buttonTheme||(n.options.buttonTheme=[]);var i=!1;n.options.buttonTheme.map((function(e){if(e!=null&&e.class.split(` `).includes(t)){i=!0;var n=e.buttons.split(` `);n.includes(r)||(i=!0,n.push(r),e.buttons=n.join(` `))}return e})),i||n.options.buttonTheme.push({class:t,buttons:e})}))})),this.render())}},{key:`removeButtonTheme`,value:function(e,t){var n=this;if(!e&&!t)return this.options.buttonTheme=[],void this.render();e&&Array.isArray(this.options.buttonTheme)&&this.options.buttonTheme.length&&(e.split(` `).forEach((function(e){var r;(r=n.options)==null||(r=r.buttonTheme)==null||r.map((function(r,i){if(r&&t&&t.includes(r.class)||!t){var a,o=r?.buttons.split(` `).filter((function(t){return t!==e}));r&&o!=null&&o.length?r.buttons=o.join(` `):((a=n.options.buttonTheme)==null||a.splice(i,1),r=null)}return r}))})),this.render())}},{key:`getButtonElement`,value:function(e){var t,n=this.buttonElements[e];return n&&(t=n.length>1?n:n[0]),t}},{key:`inputPatternIsValid`,value:function(e){var t,n=this.options.inputPattern;if((t=n instanceof RegExp?n:n[this.options.inputName||this.defaultName])&&e){var r=t.test(e);return this.options.debug&&console.log(`inputPattern ("${t}"): ${r?`passed`:`did not pass!`}`),r}return!0}},{key:`setEventListeners`,value:function(){if(this.isFirstKeyboardInstance||!this.allKeyboardInstances){this.options.debug&&console.log(`Caret handling started (${this.keyboardDOMClass})`);var e=this.options.physicalKeyboardHighlightPreventDefault,t=e!==void 0&&e;document.addEventListener(`keyup`,this.handleKeyUp,t),document.addEventListener(`keydown`,this.handleKeyDown,t),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`touchend`,this.handleTouchEnd),this.options.updateCaretOnSelectionChange&&document.addEventListener(`selectionchange`,this.handleSelectionChange),document.addEventListener(`select`,this.handleSelect)}}},{key:`handleKeyUp`,value:function(e){this.caretEventHandler(e),this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyUp(e)}},{key:`handleKeyDown`,value:function(e){this.options.physicalKeyboardHighlight&&this.physicalKeyboard.handleHighlightKeyDown(e)}},{key:`handleMouseUp`,value:function(e){this.caretEventHandler(e)}},{key:`handleTouchEnd`,value:function(e){this.caretEventHandler(e)}},{key:`handleSelect`,value:function(e){this.caretEventHandler(e)}},{key:`handleSelectionChange`,value:function(e){navigator.userAgent.includes(`Firefox`)||this.caretEventHandler(e)}},{key:`caretEventHandler`,value:function(e){var t,n=this;e.target.tagName&&(t=e.target.tagName.toLowerCase()),this.dispatch((function(r){var i=e.target===r.keyboardDOM||e.target&&r.keyboardDOM.contains(e.target);if(n.options.syncInstanceInputs&&Array.isArray(e.path)&&(i=e.path.some((function(e){var t;return e==null||(t=e.hasAttribute)==null?void 0:t.call(e,`data-skInstance`)}))),(t===`textarea`||t===`input`&&[`text`,`search`,`url`,`tel`,`password`].includes(e.target.type))&&!r.options.disableCaretPositioning){var a=e.target.selectionStart,o=e.target.selectionEnd;r.options.rtl&&(a=r.utilities.getRtlOffset(a,r.getInput()),o=r.utilities.getRtlOffset(o,r.getInput())),r.setCaretPosition(a,o),r.activeInputElement=e.target,r.options.debug&&console.log(`Caret at: `,r.getCaretPosition(),r.getCaretPositionEnd(),e&&e.target.tagName.toLowerCase(),`(${r.keyboardDOMClass})`,e?.type)}else !r.options.disableCaretPositioning&&i||e?.type===`selectionchange`||(r.setCaretPosition(null),r.activeInputElement=null,r.options.debug&&console.log(`Caret position reset due to "${e?.type}" event`,e))}))}},{key:`recurseButtons`,value:function(e){var t=this;e&&Object.keys(this.buttonElements).forEach((function(n){return t.buttonElements[n].forEach(e)}))}},{key:`destroy`,value:function(){this.options.debug&&console.log(`Destroying simple-keyboard instance: ${this.currentInstanceName}`);var e=this.options.physicalKeyboardHighlightPreventDefault,t=e!==void 0&&e;document.removeEventListener(`keyup`,this.handleKeyUp,t),document.removeEventListener(`keydown`,this.handleKeyDown,t),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`touchend`,this.handleTouchEnd),document.removeEventListener(`select`,this.handleSelect),this.options.updateCaretOnSelectionChange&&document.removeEventListener(`selectionchange`,this.handleSelectionChange),document.onpointerup=null,document.ontouchend=null,document.ontouchcancel=null,document.onmouseup=null,this.recurseButtons((function(e){e&&=(e.onpointerdown=null,e.onpointerup=null,e.onpointercancel=null,e.ontouchstart=null,e.ontouchend=null,e.ontouchcancel=null,e.onclick=null,e.onmousedown=null,e.onmouseup=null,e.remove(),null)})),this.keyboardDOM.onpointerdown=null,this.keyboardDOM.ontouchstart=null,this.keyboardDOM.onmousedown=null,this.resetRows(),this.candidateBox&&=(this.candidateBox.destroy(),null),this.activeInputElement=null,this.keyboardDOM.removeAttribute(`data-skInstance`),this.keyboardDOM.innerHTML=``,window.SimpleKeyboardInstances[this.currentInstanceName]=null,delete window.SimpleKeyboardInstances[this.currentInstanceName],this.initialized=!1}},{key:`getButtonThemeClasses`,value:function(e){var t=this.options.buttonTheme,n=[];return Array.isArray(t)&&t.forEach((function(t){if(t&&t.class&&typeof t.class==`string`&&t.buttons&&typeof t.buttons==`string`){var r=t.class.split(` `);t.buttons.split(` `).includes(e)&&(n=[].concat(C(n),C(r)))}else console.warn(`Incorrect "buttonTheme". Please check the documentation.`,t)})),n}},{key:`setDOMButtonAttributes`,value:function(e,t){var n=this.options.buttonAttributes;Array.isArray(n)&&n.forEach((function(n){n.attribute&&typeof n.attribute==`string`&&n.value&&typeof n.value==`string`?n.buttons&&typeof n.buttons==`string`?n.buttons.split(` `).includes(e)&&t(n.attribute,n.value):t(n.attribute,n.value):console.warn(`Incorrect "buttonAttributes". Please check the documentation.`,n)}))}},{key:`onTouchDeviceDetected`,value:function(){this.processAutoTouchEvents(),this.disableContextualWindow()}},{key:`disableContextualWindow`,value:function(){window.oncontextmenu=function(e){var t;if((t=e.target.classList)!=null&&t.contains(`hg-button`))return e.preventDefault(),e.stopPropagation(),!1}}},{key:`processAutoTouchEvents`,value:function(){this.options.autoUseTouchEvents&&(this.options.useTouchEvents=!0,this.options.debug&&console.log(`autoUseTouchEvents: Touch device detected, useTouchEvents enabled.`))}},{key:`onInit`,value:function(){this.options.debug&&console.log(`${this.keyboardDOMClass} Initialized`),this.setEventListeners(),typeof this.options.onInit==`function`&&this.options.onInit(this)}},{key:`beforeFirstRender`,value:function(){this.utilities.isTouchDevice()&&this.onTouchDeviceDetected(),typeof this.options.beforeFirstRender==`function`&&this.options.beforeFirstRender(this),this.isFirstKeyboardInstance&&this.utilities.pointerEventsSupported()&&!this.options.useTouchEvents&&!this.options.useMouseEvents&&this.options.debug&&console.log(`Using PointerEvents as it is supported by this browser`),this.options.useTouchEvents&&this.options.debug&&console.log(`useTouchEvents has been enabled. Only touch events will be used.`)}},{key:`beforeRender`,value:function(){typeof this.options.beforeRender==`function`&&this.options.beforeRender(this)}},{key:`onRender`,value:function(){typeof this.options.onRender==`function`&&this.options.onRender(this)}},{key:`onModulesLoaded`,value:function(){typeof this.options.onModulesLoaded==`function`&&this.options.onModulesLoaded(this)}},{key:`loadModules`,value:function(){var e=this;Array.isArray(this.options.modules)&&(this.options.modules.forEach((function(t){var n=e.utilities.isConstructor(t)?new t(e):t(e);n.init&&n.init(e)})),this.keyboardPluginClasses=`modules-loaded`,this.render(),this.onModulesLoaded())}},{key:`getModuleProp`,value:function(e,t){return!!this.modules[e]&&this.modules[e][t]}},{key:`getModulesList`,value:function(){return Object.keys(this.modules)}},{key:`parseRowDOMContainers`,value:function(e,t,n,r){var i=this,a=Array.from(e.children),o=0;return a.length&&n.forEach((function(n,s){var c=r[s];if(!(c&&c>n))return!1;var l=n-o,u=c-o,d=document.createElement(`div`);d.className+=`hg-button-container`;var f=`${i.options.layoutName}-r${t}c${s}`;d.setAttribute(`data-skUID`,f);var p=a.splice(l,u-l+1);o+=u-l,p.forEach((function(e){return d.appendChild(e)})),a.splice(l,0,d),e.innerHTML=``,a.forEach((function(t){return e.appendChild(t)})),i.options.debug&&console.log(`rowDOMContainer`,p,l,u,o+1)})),e}},{key:`render`,value:function(){var e=this;this.resetRows(),this.initialized||this.beforeFirstRender(),this.beforeRender();var t=`hg-layout-${this.options.layoutName}`,n=this.options.layout||{default:["` 1 2 3 4 5 6 7 8 9 0 - = {bksp}",`{tab} q w e r t y u i o p [ ] \\`,`{lock} a s d f g h j k l ; ' {enter}`,`{shift} z x c v b n m , . / {shift}`,`.com @ {space}`],shift:[`~ ! @ # $ % ^ & * ( ) _ + {bksp}`,`{tab} Q W E R T Y U I O P { } |`,`{lock} A S D F G H J K L : " {enter}`,`{shift} Z X C V B N M < > ? {shift}`,`.com @ {space}`]},r=this.options.useTouchEvents||!1,i=r?`hg-touch-events`:``,a=this.options.useMouseEvents||!1,o=this.options.disableRowButtonContainers;this.keyboardDOM.className=this.getKeyboardClassString(this.options.theme,t,this.keyboardPluginClasses,i),this.keyboardDOM.setAttribute(`data-skInstance`,this.currentInstanceName),this.keyboardRowsDOM=document.createElement(`div`),this.keyboardRowsDOM.className=`hg-rows`,n[this.options.layoutName||this.defaultName].forEach((function(t,n){var i=t.split(` `);e.options.excludeFromLayout&&e.options.excludeFromLayout[e.options.layoutName||e.defaultName]&&(i=i.filter((function(t){return e.options.excludeFromLayout&&!e.options.excludeFromLayout[e.options.layoutName||e.defaultName].includes(t)})));var s=document.createElement(`div`);s.className+=`hg-row`;var c=[],l=[];i.forEach((function(t,i){var u,d=!o&&typeof t==`string`&&t.length>1&&t.indexOf(`[`)===0,f=!o&&typeof t==`string`&&t.length>1&&t.indexOf(`]`)===t.length-1;d&&(c.push(i),t=t.replace(/\[/g,``)),f&&(l.push(i),t=t.replace(/\]/g,``));var p=e.utilities.getButtonClass(t),m=e.utilities.getButtonDisplayName(t,e.options.display,e.options.mergeDisplay),h=e.options.useButtonTag?`button`:`div`,g=document.createElement(h);g.className+=`hg-button ${p}`,(u=g.classList).add.apply(u,C(e.getButtonThemeClasses(t))),e.setDOMButtonAttributes(t,(function(e,t){g.setAttribute(e,t)})),e.activeButtonClass=`hg-activeButton`,!e.utilities.pointerEventsSupported()||r||a?r?(g.ontouchstart=function(n){e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.ontouchend=function(n){e.handleButtonMouseUp(t,n)},g.ontouchcancel=function(n){e.handleButtonMouseUp(t,n)}):(g.onclick=function(n){e.setMouseHold(!1),typeof e.options.onKeyReleased==`function`||e.options.useMouseEvents&&e.options.clickOnMouseDown||e.handleButtonClicked(t,n)},g.onmousedown=function(n){(typeof e.options.onKeyReleased==`function`||e.options.useMouseEvents&&e.options.clickOnMouseDown)&&!e.isMouseHold&&e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.onmouseup=function(n){e.handleButtonMouseUp(t,n)}):(g.onpointerdown=function(n){e.handleButtonClicked(t,n),e.handleButtonMouseDown(t,n)},g.onpointerup=function(n){e.handleButtonMouseUp(t,n)},g.onpointercancel=function(n){e.handleButtonMouseUp(t,n)}),g.setAttribute(`data-skBtn`,t);var _=`${e.options.layoutName}-r${n}b${i}`;g.setAttribute(`data-skBtnUID`,_);var v=document.createElement(`span`);v.innerHTML=m,g.appendChild(v),e.buttonElements[t]||(e.buttonElements[t]=[]),e.buttonElements[t].push(g),s.appendChild(g)})),s=e.parseRowDOMContainers(s,n,c,l),e.keyboardRowsDOM.appendChild(s)})),this.keyboardDOM.appendChild(this.keyboardRowsDOM),this.onRender(),this.initialized||(this.initialized=!0,!this.utilities.pointerEventsSupported()||r||a?r?(document.ontouchend=function(t){return e.handleButtonMouseUp(void 0,t)},document.ontouchcancel=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.ontouchstart=function(t){return e.handleKeyboardContainerMouseDown(t)}):r||(document.onmouseup=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.onmousedown=function(t){return e.handleKeyboardContainerMouseDown(t)}):(document.onpointerup=function(t){return e.handleButtonMouseUp(void 0,t)},this.keyboardDOM.onpointerdown=function(t){return e.handleKeyboardContainerMouseDown(t)}),this.onInit())}}],t&&D(e.prototype,t),n&&D(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n}(),j=A;return r}()},442:function(t){t.exports=e}},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e].call(a.exports,a,a.exports,r),a.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return function(){r.r(i),r.d(i,{KeyboardReact:function(){return u},default:function(){return d}}),r(981);var e=r(442),t=r(548),n=r.n(t);function a(e){return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t{e?.(t)},[t,e]);let d=(0,y.useCallback)(e=>{if(a.current)return;let t=e.target;if(!t.closest(`[data-vkb="false"]`)){if(t instanceof HTMLInputElement){if(!sQe.has(t.type))return}else if(!(t instanceof HTMLTextAreaElement))return;c.current=t,n(!0),s(`default`),l.current?.setInput?.(c.current.value),setTimeout(()=>{(t.closest(`.bg-zinc-800, .rounded-lg, [data-vkb-group]`)??t).scrollIntoView({behavior:`smooth`,block:`nearest`})},100)}},[]),f=(0,y.useCallback)(()=>{setTimeout(()=>{let e=document.activeElement;e&&(u.current?.contains(e)||e===c.current)||(n(!1),c.current=null)},150)},[]);(0,y.useEffect)(()=>(document.addEventListener(`focusin`,d),document.addEventListener(`focusout`,f),()=>{document.removeEventListener(`focusin`,d),document.removeEventListener(`focusout`,f)}),[d,f]);let p=(0,y.useCallback)(()=>{a.current=!0,i(!0),c.current?.blur(),c.current=null,setTimeout(()=>{n(!1),i(!1),a.current=!1},400)},[]),m=(0,y.useCallback)(e=>{let t=c.current;if(t){if(e===`{shift}`){s(e=>e==="default"?`shift`:`default`);return}if(e===`{lock}`){s(e=>e==="default"?`shift`:`default`);return}if(e===`{close}`){p();return}e===`{bksp}`?W9(t,t.value.slice(0,-1)):e===`{space}`?W9(t,t.value+` `):(W9(t,t.value+e),o===`shift`&&s(`default`)),t.focus(),l.current?.setInput?.(t.value)}},[o,p]);return t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`fixed inset-0 z-[9998] bg-transparent`,onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),r||p()},onTouchStart:e=>{e.preventDefault(),e.stopPropagation(),r||p()},onClick:e=>{e.preventDefault(),e.stopPropagation()}}),!r&&(0,K.jsx)(`div`,{ref:u,className:`relative z-[9999] shrink-0`,onMouseDown:e=>e.preventDefault(),onTouchStart:e=>{e.target.closest(`.hg-button`)||e.preventDefault()},children:(0,K.jsx)(oQe.default,{keyboardRef:e=>{l.current=e},layoutName:o,onKeyPress:m,theme:`simple-keyboard vkb-theme`,layout:{default:[`1 2 3 4 5 6 7 8 9 0 {bksp}`,`q w e r t y u i o p`,`{lock} a s d f g h j k l`,`{shift} z x c v b n m . @`,`{space} {close}`],shift:[`! @ # $ % ^ & * ( ) {bksp}`,`Q W E R T Y U I O P`,`{lock} A S D F G H J K L`,`{shift} Z X C V B N M , _`,`{space} {close}`]},display:{"{bksp}":`⌫`,"{close}":`✕ Close`,"{shift}":`⇧`,"{lock}":`⇪`,"{space}":` `}})})]}):null}function lQe(){Zd();let[e,t]=(0,y.useState)(null),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(100),{i18n:o}=W(),s=$n(),c=Xn(),l=aQe(),{setViewportSuppressed:u}=Td();(0,y.useEffect)(()=>(u(!0),()=>u(!1)),[u]);let{data:d}=q({queryKey:[`settings`],queryFn:Q.getSettings});(0,y.useEffect)(()=>{d?.language&&d.language!==o.language&&o.changeLanguage(d.language)},[d?.language,o]);let{data:f=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:3e4}),p=f[0],m=l.deviceOnline||!!p?.online,h=(0,y.useMemo)(()=>({...l,deviceOnline:m}),[l,m]),g=(0,y.useRef)(!1);(0,y.useEffect)(()=>{p&&!g.current&&(a(p.display_brightness),g.current=!0)},[p]),(0,y.useEffect)(()=>{let e=document.documentElement,t=e.classList.contains(`dark`);return e.classList.add(`dark`),()=>{t||e.classList.remove(`dark`)}},[]);let{data:_}=q({queryKey:[`spoolbuddy-update-check`,p?.device_id],queryFn:()=>p?od.checkDaemonUpdate(p.device_id):Promise.resolve(null),enabled:!!p,refetchInterval:300*1e3,staleTime:0}),v=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!m){let e=`SpoolBuddy device disconnected`;r({type:`warning`,message:e}),v.current=e}else if(_?.update_available&&_.latest_version){let e=`Update available: v${_.latest_version}`;r({type:`info`,message:e}),v.current=e}else v.current&&=(r(null),null)},[m,_?.update_available,_?.latest_version]);let b=!!(l.matchedSpool||l.unknownTagUid||l.unknownTrayUuid),x=(0,y.useRef)(!1);(0,y.useEffect)(()=>{b&&!x.current&&c.pathname!==`/spoolbuddy`&&s(`/spoolbuddy`),x.current=b},[b,c.pathname,s]);let{data:S=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),C=_o({queries:S.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:1e4,select:e=>({connected:e?.connected})}))}),w=(0,y.useMemo)(()=>S.filter((e,t)=>C[t]?.data?.connected),[S,C]),T=(0,y.useRef)(null),E=(0,y.useRef)(!1),D=(0,y.useRef)(null),O=(0,y.useCallback)(e=>{T.current={x:e.touches[0].clientX,y:e.touches[0].clientY},E.current=!1},[]),k=(0,y.useCallback)(n=>{if(!T.current)return;let r=n.changedTouches[0].clientX-T.current.x,i=n.changedTouches[0].clientY-T.current.y,a=T.current.y;if(T.current=null,E.current=!1,i>=50&&Math.abs(i)>Math.abs(r)&&a<120){N(!0);return}if(w.length<2||Math.abs(r)<50||Math.abs(i)>Math.abs(r))return;let o=w.findIndex(t=>t.id===e);t(w[r<0?(o+1)%w.length:(o-1+w.length)%w.length].id)},[w,e,t]);(0,y.useEffect)(()=>{let e=D.current;if(!e)return;let t=e=>{if(!T.current)return;let t=Math.abs(e.touches[0].clientX-T.current.x),n=Math.abs(e.touches[0].clientY-T.current.y);if(E.current){e.preventDefault();return}t>10&&t>n&&(E.current=!0,e.preventDefault())};return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[]);let[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(!1);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{ref:D,"data-spoolbuddy-kiosk":!0,className:`w-screen h-screen bg-bambu-dark text-white flex flex-col overflow-hidden`,style:{...i<100?{filter:`brightness(${i/100})`}:void 0,overscrollBehaviorX:`none`},onTouchStart:O,onTouchEnd:k,children:[(0,K.jsx)(`button`,{onClick:()=>N(!0),className:`w-full h-1.5 bg-bambu-dark-secondary flex justify-center items-center shrink-0 touch-none`,"aria-label":`Open quick menu`,children:(0,K.jsx)(`div`,{className:`w-8 h-0.5 rounded-full bg-zinc-600`})}),(0,K.jsx)(QZe,{selectedPrinterId:e,onPrinterChange:t,deviceOnline:m}),(0,K.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:(0,K.jsx)(kr,{context:{selectedPrinterId:e,setSelectedPrinterId:t,sbState:h,setAlert:r,displayBrightness:i,setDisplayBrightness:a}})}),!A&&(0,K.jsx)(tQe,{alert:n}),!A&&(0,K.jsx)(eQe,{}),(0,K.jsx)(cQe,{onVisibilityChange:j})]}),(0,K.jsx)(nQe,{isOpen:M,onClose:()=>N(!1),deviceId:p?.device_id??null,deviceOnline:m})]})}function G9({color:e,isEmpty:t,size:n=32}){return t?(0,K.jsx)(`div`,{className:`rounded-full border-2 border-dashed border-zinc-500 flex items-center justify-center`,style:{width:n,height:n},children:(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full bg-zinc-600`})}):(0,K.jsxs)(`svg`,{width:n,height:n,viewBox:`0 0 32 32`,children:[(0,K.jsx)(`circle`,{cx:`16`,cy:`16`,r:`14`,fill:e,stroke:`white`,strokeWidth:`1.5`,strokeOpacity:`0.7`}),(0,K.jsx)(`circle`,{cx:`16`,cy:`16`,r:`11`,fill:e,style:{filter:`brightness(0.85)`}})]})}var uQe=`spoolbuddy-default-core-weight`;function dQe(){try{let e=localStorage.getItem(uQe);if(e){let t=parseInt(e,10);if(t>=0&&t<=500)return t}}catch{}return 250}function fQe({spool:e,scaleWeight:t,onClose:n,onSyncWeight:r,onAssignToAms:i,isAssigned:a,onUnassignFromAms:o}){let{t:s}=W(),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(!1),f=qd(e.rgba),p=e.core_weight&&e.core_weight>0?e.core_weight:dQe(),m=t===null?null:Math.round(Math.max(0,t)),h=m===null?null:Math.round(Math.max(0,m-p)),g=Math.round(e.label_weight||1e3),_=h===null?null:Math.min(100,Math.round(h/g*100)),v=_===null?`#808080`:_>50?`#22c55e`:_>20?`#eab308`:`#ef4444`,b=Math.max(0,(e.label_weight||0)-(e.weight_used||0))+p,x=m===null?null:m-b,S=x===null?null:Math.abs(x)<=50,C=async()=>{if(t!==null){l(!0);try{await od.updateSpoolWeight(e.id,Math.round(t)),d(!0),r?.(),setTimeout(()=>d(!1),3e3)}catch(e){console.error(`Failed to sync weight:`,e)}finally{l(!1)}}};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-4 max-w-md`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsx)(G9,{color:f,isEmpty:!1,size:100}),_!==null&&(0,K.jsxs)(`div`,{className:`absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg`,style:{backgroundColor:v},children:[_,`%`]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]}),h!==null&&(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-3xl font-bold font-mono text-zinc-100`,children:[h,`g`]}),(0,K.jsxs)(`span`,{className:`text-sm text-zinc-500`,children:[`/ `,g,`g`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:s(`spoolbuddy.spool.remaining`,`Remaining`)}),(0,K.jsx)(`div`,{className:`mt-2 max-w-xs`,children:(0,K.jsx)(`div`,{className:`h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${_}%`,backgroundColor:v}})})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-4 w-full`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.grossWeight`,`Gross weight`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300`,children:m===null?`—`:`${m}g`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.spool.coreWeight`,`Core`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[p,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.spoolSize`,`Spool size`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[g,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.spool.scaleWeight`,`Scale`)}),m===null?(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`—`}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 font-mono ${S?`text-green-500`:`text-yellow-500`}`,children:[m,`g`,S?(0,K.jsx)(rs,{className:`w-3.5 h-3.5`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`button`,{onClick:C,className:`p-1 hover:bg-green-500/20 rounded transition-colors text-green-500`,title:s(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`),children:(0,K.jsx)(Ol,{className:`w-4 h-4`})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:s(`spoolbuddy.dashboard.tagId`,`Tag`)}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-zinc-400 truncate max-w-[120px]`,title:e.tag_uid||``,children:e.tag_uid?e.tag_uid.slice(-8):`—`})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[i&&(0,K.jsx)(`button`,{onClick:a?void 0:i,disabled:!!a,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px] disabled:opacity-50 disabled:cursor-not-allowed`,children:s(`spoolbuddy.modal.assignToAms`,`Assign to AMS`)}),o&&(0,K.jsxs)(`button`,{onClick:o,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-red-600/20 text-red-400 hover:bg-red-600/30 transition-colors min-h-[44px]`,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 inline mr-1`}),s(`inventory.unassignSpool`)]}),(0,K.jsx)(`button`,{onClick:C,disabled:t===null||c,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${u?`bg-green-600/20 text-green-400`:i?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600 disabled:opacity-40 disabled:cursor-not-allowed`:`bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed`}`,children:c?`...`:u?s(`spoolbuddy.dashboard.weightSynced`,`Synced!`):s(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`)}),n&&(0,K.jsx)(`button`,{onClick:n,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:s(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function pQe({tagUid:e,scaleWeight:t,coreWeight:n,onLinkSpool:r,onAddToInventory:i,onClose:a}){let{t:o}=W(),s=n??dQe(),c=t===null?null:Math.round(Math.max(0,t)),l=c===null?null:Math.round(Math.max(0,c-s));return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-5`,children:[(0,K.jsx)(`div`,{className:`w-20 h-20 rounded-2xl bg-green-500/15 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-10 h-10 text-green-500`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z`})})}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:o(`spoolbuddy.dashboard.newTag`,`New Tag Detected`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500 font-mono mt-1`,children:e})]}),c!==null&&(0,K.jsxs)(`div`,{className:`text-sm text-zinc-400`,children:[(0,K.jsxs)(`span`,{className:`font-mono font-semibold`,children:[c,`g`]}),` `,o(`spoolbuddy.dashboard.onScale`,`on scale`),l!==null&&l>0&&(0,K.jsxs)(`span`,{className:`text-zinc-500`,children:[` • ~`,l,`g filament`]})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2 justify-center`,children:[i&&(0,K.jsx)(`button`,{onClick:i,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:o(`spoolbuddy.modal.addToInventory`,`Add to Inventory`)}),r&&(0,K.jsxs)(`button`,{onClick:r,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 inline-block mr-1.5 -mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1`})}),o(`inventory.assignSpool`,`Assign Spool`)]}),a&&(0,K.jsx)(`button`,{onClick:a,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:o(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function mQe(e){return e?`#${e.slice(0,6)}`:`#808080`}function hQe(e){return!e.tray_type||e.tray_type===``}function gQe(e){if(e.tray_type)return null;let t=e.state??null;return t===9||t===10?`physical`:`reset`}function _Qe(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function vQe({className:e}){return(0,K.jsx)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,K.jsx)(`path`,{d:`M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z`,fill:`#C3C2C1`})})}function yQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 35 53`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z`,fill:`#C3C2C1`}),(0,K.jsx)(`path`,{d:`M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z`,fill:`#1F8FEB`})]})}function bQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z`,fill:`#1F8FEB`}),(0,K.jsx)(`path`,{d:`M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z`,fill:`#C3C2C1`})]})}function xQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function SQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`8`,width:`3`,height:`4.5`,fill:`#d4a017`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#d4a017`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function CQe({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,K.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:`#c62828`,rx:`0.5`}),(0,K.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#c62828`}),(0,K.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function wQe({humidity:e,goodThreshold:t=40,fairThreshold:n=60}){let r,i;return e<=t?(r=`#22a352`,i=vQe):e<=n?(r=`#d4a017`,i=yQe):(r=`#c62828`,i=bQe),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(i,{className:`w-3 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums text-xs`,style:{color:r},children:[e,`%`]})]})}function TQe({temp:e,goodThreshold:t=28,fairThreshold:n=35}){let r,i;return e<=t?(r=`#22a352`,i=xQe):e<=n?(r=`#d4a017`,i=SQe):(r=`#c62828`,i=CQe),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,K.jsx)(i,{className:`w-3 h-3.5`}),(0,K.jsxs)(`span`,{className:`font-medium tabular-nums text-xs`,style:{color:r},children:[e,`°C`]})]})}function K9({side:e}){return(0,K.jsx)(`span`,{className:`inline-flex items-center justify-center w-4 h-4 text-[9px] font-bold rounded`,style:{backgroundColor:`#1a4d2e`,color:`#00ae42`},children:e})}function EQe({tray:e,slotIndex:t,isActive:n,fillOverride:r,spoolmanFill:i,onClick:a}){let o=hQe(e),s=gQe(e),c=mQe(e.tray_color),l=e.remain!==null&&e.remain!==void 0&&e.remain>=0?e.remain:null,u=i??(r===0&&l!==null&&l>0?null:r)??l;return(0,K.jsxs)(`div`,{className:`relative flex flex-col items-center p-2.5 rounded-lg transition-all ${n?`ring-2 ring-bambu-green`:``} ${a?`cursor-pointer hover:bg-white/5`:``}`,onClick:a,title:a?`AMS Slot ${t+1}`:void 0,children:[(0,K.jsxs)(`div`,{className:`relative w-16 h-16 mb-1`,children:[o?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-3 h-3 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:c}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:c,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]}),n&&(0,K.jsx)(`div`,{className:`absolute -bottom-1 left-1/2 -translate-x-1/2 w-2.5 h-2.5 bg-bambu-green rounded-full`})]}),(0,K.jsx)(`span`,{className:`text-sm text-white/70 truncate max-w-full`,title:s===`reset`?`Spool loaded — slot not configured`:void 0,children:o?s===`reset`?`?`:`Empty`:e.tray_type||`Unknown`}),!o&&u!==null&&u>=0&&(0,K.jsx)(`div`,{className:`w-full h-1 bg-bambu-dark-tertiary rounded-full overflow-hidden mt-1`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${u}%`,backgroundColor:Rf(u)}})}),(0,K.jsx)(`span`,{className:`absolute top-1 right-1 text-xs text-white/30`,children:t+1})]})}function DQe({unit:e,activeSlot:t,onConfigureSlot:n,isDualNozzle:r,nozzleSide:i,thresholds:a,fillOverrides:o,spoolmanFillOverrides:s}){let c=e.tray||[],l=e.is_ams_ht,u=l?1:4;return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-white font-medium text-base`,children:_Qe(e.id)}),r&&i&&(0,K.jsx)(K9,{side:i})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.temp!=null&&(0,K.jsx)(TQe,{temp:e.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair}),e.humidity!=null&&(0,K.jsx)(wQe,{humidity:e.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair})]})]}),(0,K.jsx)(`div`,{className:`grid ${l?`grid-cols-1 max-w-[100px] mx-auto`:`grid-cols-4`} gap-2`,children:Array.from({length:u}).map((r,i)=>{let a=c[i]||{id:i,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null};return(0,K.jsx)(EQe,{tray:a,slotIndex:i,isActive:t===i,fillOverride:o?.[`${e.id}-${i}`]??null,spoolmanFill:s?.[`${e.id}-${i}`]??null,onClick:n?()=>n(e.id,i,hQe(a)?null:a):void 0},i)})})]})}function q9(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function J9(e){return!e.tray_type||e.tray_type===``}function OQe(e){return e?`#${e.slice(0,6)}`:`#808080`}var Y9=e=>(e??``).trim().toUpperCase();function kQe(e,t){let n=Y9(e),r=Y9(t);return!n||!r?`none`:n===r?`exact`:r.includes(n)||n.includes(r)?`partial`:`none`}function AQe(e,t){let n=Y9(e),r=Y9(t);return!n||!r?!1:n===r}function jQe({isOpen:e,onClose:t,spool:n,printerId:r,spoolmanMode:i=!1}){let{t:a}=W(),o=no(),[s,c]=(0,y.useState)(null),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null);(0,y.useEffect)(()=>{e&&(c(null),u(null),f(!1),m(null),g(null))},[e]);let _=(0,y.useCallback)(e=>{e.key===`Escape`&&t()},[t]);(0,y.useEffect)(()=>(e&&document.addEventListener(`keydown`,_),()=>document.removeEventListener(`keydown`,_)),[e,_]);let{data:v}=q({queryKey:[`printerStatus`,r],queryFn:()=>Q.getPrinterStatus(r),enabled:e&&r!==null,refetchInterval:5e3}),{data:b}=q({queryKey:[`printer`,r],queryFn:()=>Q.getPrinter(r),enabled:e&&r!==null}),{data:x}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),enabled:e,staleTime:300*1e3}),{data:S}=q({queryKey:[`spool-assignments`,r],queryFn:()=>Q.getAssignments(r),enabled:e&&r!==null,staleTime:30*1e3}),{data:C=[]}=q({queryKey:[`spoolman-slot-assignments`,r],queryFn:()=>Q.getSpoolmanSlotAssignments(r??void 0),enabled:e&&!!i&&r!==null,staleTime:30*1e3}),w=i?C.find(e=>e.spoolman_spool_id===n.id):void 0,T=(0,y.useMemo)(()=>{let e={};if(!S)return e;for(let t of S){let n=t.spool;if(n&&n.label_weight>0&&n.weight_used!=null){let r=Math.round(Math.max(0,n.label_weight-n.weight_used)/n.label_weight*100);e[`${t.ams_id}-${t.tray_id}`]=r}}return e},[S]),E=x?{humidityGood:Number(x.ams_humidity_good)||40,humidityFair:Number(x.ams_humidity_fair)||60,tempGood:Number(x.ams_temp_good)||28,tempFair:Number(x.ams_temp_fair)||35}:void 0,D=v?.connected??!1,O=(0,y.useMemo)(()=>v?.ams??[],[v?.ams]),k=(0,y.useMemo)(()=>O.filter(e=>!e.is_ams_ht),[O]),A=(0,y.useMemo)(()=>O.filter(e=>e.is_ams_ht),[O]),j=(0,y.useMemo)(()=>[...v?.vt_tray??[]].sort((e,t)=>(e.id??254)-(t.id??254)),[v?.vt_tray]),M=b?.nozzle_count===2||v?.temperatures?.nozzle_2!==void 0,N=(0,y.useRef)({});(0,y.useEffect)(()=>{v?.ams_extruder_map&&Object.keys(v.ams_extruder_map).length>0&&(N.current=v.ams_extruder_map)},[v?.ams_extruder_map]);let P=v?.ams_extruder_map&&Object.keys(v.ams_extruder_map).length>0?v.ams_extruder_map:N.current,F=(0,y.useCallback)(e=>{if(!M)return null;let t=P[String(e)],n=e>=128?e-128:e;return(t===void 0?n:t)===1?`L`:`R`},[M,P]),I=J({mutationFn:async({amsId:e,trayId:t})=>{if(!r)throw Error(`No printer selected`);return i?await Q.assignSpoolmanSlot({spoolman_spool_id:n.id,printer_id:r,ams_id:e,tray_id:t}):await Q.assignSpool({spool_id:n.id,printer_id:r,ams_id:e,tray_id:t})},onSuccess:e=>{u(`success`);let n=e&&`pending_config`in e&&e.pending_config;c(n?a(`spoolbuddy.modal.assignPendingInsert`,`Assigned. Slot will configure when you insert the spool.`):a(`spoolbuddy.modal.assignSuccess`,`Assigned!`)),o.invalidateQueries({queryKey:[`slotPresets`]}),o.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),o.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),setTimeout(()=>t(),n?2500:1500)},onError:e=>{u(`error`),c(e instanceof Error?e.message:a(`spoolbuddy.modal.assignError`,`Failed to assign spool.`))}}),L=I.isPending,R=(0,y.useCallback)((e,t)=>{if(e===254||e===255){let n=e===254?254:254+t;return j.find(e=>(e.id??254)===n)||null}return O.find(t=>t.id===e)?.tray?.find(e=>e.id===t)||null},[O,j]),z=(0,y.useCallback)((e,t)=>e<=3?`${q9(e)} ${a(`ams.slot`,`Slot`)} ${t+1}`:e>=128&&e<=135?q9(e):e===254?a(`printers.extL`,`Ext-L`):M?a(`printers.extR`,`Ext-R`):a(`printers.ext`,`Ext`),[a,M]),B=(0,y.useCallback)((e,t)=>{u(`info`),c(a(`spoolbuddy.modal.assigning`,`Configuring slot...`)),I.mutate({amsId:e,trayId:t})},[I,a]),V=(0,y.useCallback)((e,t)=>{if(!L){if(!x?.disable_filament_warnings){let r=R(e,t);if(r&&!J9(r)){let i=r.tray_sub_brands||r.tray_type||``,a=kQe(n.material,i),o=n.slicer_filament_name||n.slicer_filament,s=r.tray_type||``,c=AQe(o,s);if(a!==`exact`){let r;r=a===`none`&&!c?`material_profile`:a===`partial`&&!c?`partial_profile`:a===`none`?`material`:`partial`;let l=z(e,t);g({amsId:e,trayId:t}),m({type:r,spoolMaterial:n.material||``,trayMaterial:i||``,spoolProfile:o||void 0,trayProfile:s||void 0,location:l}),f(!0);return}}}B(e,t)}},[L,x?.disable_filament_warnings,n,R,z,B]),ee=(0,y.useCallback)(()=>{h&&(f(!1),m(null),B(h.amsId,h.trayId),g(null))},[h,B]),te=(0,y.useMemo)(()=>{let e=[];for(let t of A){let n=t.tray?.[0]||{id:0,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null},r=T[`${t.id}-0`]??null,i=n.remain!=null&&n.remain>=0?n.remain:null,a=r===0&&i!==null&&i>0?null:r;e.push({key:`ht-${t.id}`,label:q9(t.id),amsId:t.id,trayId:0,tray:n,isEmpty:J9(n),nozzleSide:F(t.id),effectiveFill:a??i})}for(let t of j){let n=t.id??254,r=n-254,i=T[`255-${r}`]??null,o=t.remain!=null&&t.remain>=0?t.remain:null,s=i===0&&o!==null&&o>0?null:i;e.push({key:`ext-${n}`,label:M?n===254?a(`printers.extL`,`Ext-L`):a(`printers.extR`,`Ext-R`):a(`printers.ext`,`Ext`),amsId:255,trayId:r,tray:t,isEmpty:J9(t),nozzleSide:M?n===254?`L`:`R`:null,effectiveFill:s??o})}return e},[A,j,M,a,F,T]);return e?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`fixed inset-0 z-[60] bg-bambu-dark flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-zinc-800 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,K.jsx)(`div`,{className:`w-7 h-7 rounded-full shrink-0`,style:Jd(n.rgba)}),(0,K.jsx)(`div`,{className:`min-w-0`,children:(0,K.jsxs)(`h2`,{className:`text-sm font-semibold text-zinc-100 truncate`,children:[a(`spoolbuddy.modal.assignToAmsTitle`,`Assign to AMS`),(0,K.jsxs)(`span`,{className:`font-normal text-zinc-500 ml-2`,children:[n.color_name||`Unknown`,` • `,n.brand,` `,n.material,n.subtype&&` ${n.subtype}`]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 ml-2 shrink-0`,children:[`#`,n.id]})]})})]}),(0,K.jsx)(`button`,{onClick:t,disabled:L,className:`p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800 transition-colors shrink-0 disabled:opacity-50`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),s&&(0,K.jsxs)(`div`,{className:`mx-5 mt-3 p-3 rounded-lg flex items-center gap-3 border shrink-0 ${l===`info`?`bg-blue-500/10 border-blue-500/40`:l===`success`?`bg-green-500/10 border-green-500/40`:`bg-red-500/10 border-red-500/40`}`,children:[l===`info`&&(0,K.jsx)(X,{className:`w-4 h-4 text-blue-400 animate-spin shrink-0`}),l===`success`&&(0,K.jsx)(ps,{className:`w-4 h-4 text-green-400 shrink-0`}),l===`error`&&(0,K.jsx)(ys,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,K.jsx)(`span`,{className:`text-sm ${l===`info`?`text-blue-300`:l===`success`?`text-green-300`:`text-red-300`}`,children:s})]}),(0,K.jsx)(`div`,{className:`flex-1 flex flex-col gap-3 p-4 min-h-0 overflow-y-auto`,children:!D&&r?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`text-center text-white/50`,children:(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:a(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)})})}):O.length===0&&j.length===0?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:a(`spoolbuddy.ams.noData`,`No AMS detected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:a(`spoolbuddy.ams.connectAms`,`Connect an AMS to see filament slots`)})]})}):(0,K.jsxs)(K.Fragment,{children:[k.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3 flex-1 min-h-0`,children:k.map(e=>(0,K.jsx)(DQe,{unit:e,activeSlot:w?.ams_id===e.id?w.tray_id??null:null,onConfigureSlot:(t,n)=>V(e.id,n),isDualNozzle:M,nozzleSide:F(e.id),thresholds:E,fillOverrides:T},e.id))}),te.length>0&&(0,K.jsx)(`div`,{className:`flex gap-2 shrink-0`,children:te.map(({key:e,label:t,amsId:n,trayId:r,tray:i,isEmpty:a,nozzleSide:o,effectiveFill:s})=>{let c=OQe(i.tray_color);return(0,K.jsxs)(`div`,{onClick:()=>V(n,r),className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-2 ${w&&w.ams_id===n&&w.tray_id===r?`ring-2 ring-bambu-green`:``} ${L?`opacity-50 pointer-events-none`:``}`,children:[(0,K.jsx)(`div`,{className:`relative w-10 h-10 shrink-0`,children:a?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:c}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:c,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]})}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-white/50 font-medium`,children:t}),o&&(0,K.jsx)(K9,{side:o})]}),(0,K.jsx)(`div`,{className:`text-sm text-white/80 truncate`,children:a?`Empty`:i.tray_type||`?`})]}),!a&&s!=null&&s>=0&&(0,K.jsx)(`div`,{className:`w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden shrink-0 flex flex-col-reverse`,children:(0,K.jsx)(`div`,{className:`w-full rounded-full`,style:{height:`${s}%`,backgroundColor:Rf(s)}})})]},e)})})]})}),(0,K.jsx)(`div`,{className:`flex justify-end gap-3 px-5 py-3 border-t border-zinc-800 shrink-0`,children:(0,K.jsx)(`button`,{onClick:t,disabled:L,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-800 text-zinc-300 hover:bg-zinc-700 transition-colors min-h-[44px] disabled:opacity-50`,children:l===`success`?a(`spoolbuddy.dashboard.close`,`Close`):a(`spoolbuddy.modal.cancel`,`Cancel`)})})]}),d&&p&&(()=>{let e=``;return p.type===`material`?e=a(`inventory.assignMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location}):p.type===`partial`?e=a(`inventory.assignPartialMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location}):p.type===`material_profile`?e=`${a(`inventory.assignMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location})}\n\n${a(`inventory.assignProfileMismatchMessage`,{spoolProfile:p.spoolProfile||a(`common.unknown`),trayProfile:p.trayProfile||a(`common.unknown`),location:p.location})}`:p.type===`partial_profile`&&(e=`${a(`inventory.assignPartialMismatchMessage`,{spoolMaterial:p.spoolMaterial,trayMaterial:p.trayMaterial,location:p.location})}\n\n${a(`inventory.assignProfileMismatchMessage`,{spoolProfile:p.spoolProfile||a(`common.unknown`),trayProfile:p.trayProfile||a(`common.unknown`),location:p.location})}`),e=`${e}\n\n${a(`inventory.assignReconfigureNote`)}`,(0,K.jsx)(Ad,{title:a(`inventory.assignMismatchTitle`),message:e,confirmText:a(`inventory.assignMismatchConfirm`),variant:`warning`,isLoading:I.isPending,onConfirm:ee,onCancel:()=>{I.isPending||(f(!1),g(null),m(null))}})})()]}):null}function MQe({isOpen:e,onClose:t,tagId:n,untaggedSpools:r,onLink:i}){let{t:a}=W(),[o,s]=(0,y.useState)(null),c=(0,y.useCallback)(()=>{s(null),t()},[t]),l=(0,y.useCallback)(e=>{e.key===`Escape`&&c()},[c]);return(0,y.useEffect)(()=>(e&&(document.addEventListener(`keydown`,l),document.body.style.overflow=`hidden`),()=>{document.removeEventListener(`keydown`,l),document.body.style.overflow=``}),[e,l]),e?(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in`,onClick:c,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-xl shadow-2xl w-full max-w-lg mx-4 animate-slide-up`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-4 border-b border-zinc-700`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-zinc-100`,children:a(`spoolbuddy.dashboard.linkTagTitle`,`Link Tag to Spool`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500 font-mono`,children:n})]}),(0,K.jsx)(`button`,{onClick:c,className:`p-2 rounded-lg text-zinc-500 hover:text-zinc-300 hover:bg-zinc-700 transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`px-5 py-4 space-y-3 max-h-[400px] overflow-y-auto`,children:[(0,K.jsx)(`p`,{className:`text-sm text-zinc-400`,children:a(`spoolbuddy.dashboard.selectSpool`,`Select a spool to link this tag to:`)}),r.length===0?(0,K.jsx)(`div`,{className:`text-center py-8 text-zinc-500`,children:a(`spoolbuddy.dashboard.noUntagged`,`No spools without tags found`)}):(0,K.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:`w-full flex items-center gap-3 p-3 rounded-lg border-2 transition-all text-left ${o?.id===e.id?`border-green-500 bg-green-500/10`:`border-zinc-700 hover:border-green-500/50 hover:bg-zinc-700/50`}`,children:[(0,K.jsx)(G9,{color:qd(e.rgba),isEmpty:!1,size:40}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`font-medium text-zinc-100 truncate`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`div`,{className:`text-sm text-zinc-400 truncate`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]})]}),(0,K.jsxs)(`div`,{className:`text-sm font-mono text-zinc-500`,children:[Math.max(0,e.label_weight-e.weight_used),`g`]})]},e.id))})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 px-5 py-4 border-t border-zinc-700`,children:[(0,K.jsx)(`button`,{onClick:c,className:`px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:a(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:()=>{o&&(i(o),s(null))},disabled:!o,className:`px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors min-h-[44px]`,children:a(`spoolbuddy.dashboard.linkTag`,`Link Tag`)})]})]})}):null}function NQe(e){return e?e.replace(/[^0-9a-f]/gi,``).toUpperCase():``}function PQe(e,t){let n=NQe(e),r=NQe(t);return!n||!r?!1:n===r?!0:n.endsWith(r)||r.endsWith(n)}var FQe=[`#00AE42`,`#FF6B35`,`#3B82F6`,`#EF4444`,`#A855F7`,`#FBBF24`,`#14B8A6`,`#EC4899`,`#F97316`,`#22C55E`];function IQe(){let{t:e}=W(),[t,n]=(0,y.useState)(0);(0,y.useEffect)(()=>{let e=setInterval(()=>{n(e=>(e+1)%FQe.length)},5e3);return()=>clearInterval(e)},[]);let r=FQe[t];return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsxs)(`div`,{className:`relative mb-6 flex items-center justify-center`,style:{width:160,height:160},children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center pointer-events-none`,children:[0,1].map(e=>(0,K.jsx)(`div`,{className:`absolute rounded-full border spoolbuddy-optimized-ping`,style:{width:80,height:80,borderColor:`${r}4D`,transition:`border-color 140ms linear`,animationDelay:`${e*.8}s`}},e))}),(0,K.jsxs)(`div`,{className:`relative overflow-hidden rounded-full`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full opacity-30 spoolbuddy-spool-glow`,style:{background:`radial-gradient(circle, ${r} 0%, transparent 70%)`}}),(0,K.jsx)(`div`,{className:`relative`,style:{transition:`opacity 140ms linear`},children:(0,K.jsx)(G9,{color:r,isEmpty:!1,size:100})})]})]}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xl font-medium text-zinc-300`,children:e(`spoolbuddy.dashboard.readyToScan`,`Ready to scan`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-500`,children:e(`spoolbuddy.dashboard.idleMessage`,`Place a spool on the scale to identify it`)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-center gap-2 text-sm text-zinc-600`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,K.jsx)(`span`,{children:e(`spoolbuddy.dashboard.nfcHint`,`NFC tag will be read automatically`)})]})]})}function LQe(){let{t:e}=W();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,K.jsx)(`div`,{className:`relative mb-6 flex items-center justify-center`,style:{width:160,height:160},children:(0,K.jsx)(`div`,{className:`w-24 h-24 rounded-full bg-zinc-800 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-12 h-12 text-zinc-600`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`1.5`,d:`M18.364 5.636a9 9 0 010 12.728m0 0l-12.728-12.728m12.728 12.728L5.636 5.636m12.728 0a9 9 0 00-12.728 0m0 12.728a9 9 0 010-12.728`})})})}),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-lg font-medium text-zinc-500`,children:e(`spoolbuddy.status.deviceOffline`,`Device Offline`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-600`,children:e(`spoolbuddy.status.connectDisplay`,`Connect the SpoolBuddy display to scan spools`)})]}),(0,K.jsxs)(`div`,{className:`mt-6 flex items-center gap-2 text-xs text-zinc-600`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.14 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0`})}),(0,K.jsx)(`span`,{children:e(`spoolbuddy.status.waitingConnection`,`Waiting for device connection...`)})]})]})}function RQe(){let{sbState:e,selectedPrinterId:t}=nr(),{t:n}=W(),{showToast:r}=Td(),{data:i}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),a=i?.spoolman_enabled===`true`&&!!i?.spoolman_url,{data:o=[],refetch:s}=q({queryKey:a?[`spoolman-inventory-spools`]:[`inventory-spools`],queryFn:()=>a?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),enabled:i!==void 0}),{data:c=[]}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:a,staleTime:3*1e3,refetchInterval:3*1e3,refetchIntervalInBackground:!1}),{data:l=[]}=q({queryKey:[`printers`],queryFn:()=>Q.getPrinters()}),u=_o({queries:l.map(e=>({queryKey:[`printerStatus`,e.id],queryFn:()=>Q.getPrinterStatus(e.id),refetchInterval:1e4,select:e=>({connected:e?.connected,awaiting_plate_clear:e?.awaiting_plate_clear===!0})}))}),d=l.map((e,t)=>({printer:e,pending:u[t]?.data?.awaiting_plate_clear===!0})).filter(e=>e.pending),f=no(),p=J({mutationFn:e=>Q.clearPlate(e),onSuccess:(e,t)=>{f.setQueryData([`printerStatus`,t],e=>e&&{...e,awaiting_plate_clear:!1}),r(n(`spoolbuddy.dashboard.plateClearedToast`,`Plate marked as cleared`),`success`)},onError:()=>{r(n(`spoolbuddy.dashboard.plateClearFailed`,`Could not mark plate as cleared`),`error`)}}),m=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{f.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),f.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},onError:()=>r(n(`inventory.unassignFailed`,`Failed to unassign spool`),`error`)}),[h,g]=(0,y.useState)(null),[_,v]=(0,y.useState)(null),[b,x]=(0,y.useState)(null),[S,C]=(0,y.useState)(!1),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)(!1),[A,j]=(0,y.useState)(null),M=e.matchedSpool?.tag_uid??e.unknownTagUid??null,N=e.weight,P=e.weightStable,F=(0,y.useRef)(null);N===null?F.current=null:(F.current===null||Math.abs(N-F.current)>=3||P)&&(F.current=N);let I=F.current,L=(0,y.useMemo)(()=>{if(e.matchedSpool?.id){let t=o.find(t=>t.id===e.matchedSpool?.id);if(t)return t}return h&&(o.find(e=>PQe(e.tag_uid,h))||A)||null},[h,e.matchedSpool,o,A]),R=(0,y.useMemo)(()=>{if(L&&!A)return L;let t=e.matchedSpool;return t?{id:t.id,tag_uid:t.tag_uid,material:t.material,subtype:t.subtype,color_name:t.color_name,rgba:t.rgba,brand:t.brand,label_weight:t.label_weight,core_weight:t.core_weight,weight_used:t.weight_used}:null},[L,A,e.matchedSpool]),z=a&&R!=null?c.some(e=>e.spoolman_spool_id===R.id):!1,B=(0,y.useMemo)(()=>a?o.filter(e=>!e.tag_uid&&!e.tray_uuid&&!e.archived_at):o.filter(e=>!e.tag_uid&&!e.archived_at),[o,a]);(0,y.useEffect)(()=>{if(M){let e=b===M;(h!==null&&h!==M||!e&&h!==M)&&(g(M),v(null),x(null),j(null)),!e&&N!==null&&P&&v(Math.round(Math.max(0,N)))}else b&&(g(null),x(null),v(null),j(null))},[M,N,P,h,b]);let V=()=>{x(h)},ee=async t=>{if(h)try{if(a){let i=e.unknownTagUid||void 0,a=!e.unknownTagUid&&e.unknownTrayUuid?e.unknownTrayUuid:void 0;if(!i&&!a){r(n(`spoolman.linkFailed`),`error`);return}let o=await Q.linkTagToSpoolmanSpool(t.id,{tray_uuid:a,tag_uid:i});if(!o){r(n(`spoolman.linkFailed`),`error`);return}let{id:s,material:c,subtype:l,color_name:u,rgba:d,brand:f,label_weight:p,core_weight:m,weight_used:h}=o;j({id:s,material:c,subtype:l,color_name:u,rgba:d,brand:f,label_weight:p,core_weight:m,weight_used:h}),r(n(`spoolman.linkSuccess`),`success`)}else await Q.linkTagToSpool(t.id,{tag_uid:h,tag_type:`generic`,data_origin:`nfc_link`});s()}catch(e){console.error(`Failed to link tag:`,e),r(n(`spoolman.linkFailed`),`error`)}finally{C(!1)}},te=async()=>{if(h){k(!0);try{let t=ne??_;if(a){let n=await Q.createSpoolmanInventorySpool({material:`PLA`,subtype:null,color_name:null,rgba:null,extra_colors:null,effect_type:null,brand:null,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:null,last_used:null,encode_time:null,tag_uid:null,tray_uuid:null,data_origin:null,tag_type:null,cost_per_kg:null,last_scale_weight:t===null?null:Math.round(t),last_weighed_at:t===null?null:new Date().toISOString(),category:null,low_stock_threshold_pct:null});await Q.linkTagToSpoolmanSpool(n.id,{tag_uid:e.unknownTagUid||void 0,tray_uuid:!e.unknownTagUid&&e.unknownTrayUuid?e.unknownTrayUuid:void 0})}else await Q.createSpool({material:`PLA`,subtype:null,color_name:null,rgba:null,extra_colors:null,effect_type:null,brand:null,label_weight:1e3,core_weight:250,core_weight_catalog_id:null,weight_used:0,slicer_filament:null,slicer_filament_name:null,nozzle_temp_min:null,nozzle_temp_max:null,note:null,added_full:null,last_used:null,encode_time:null,tag_uid:h,tray_uuid:null,data_origin:`spoolbuddy`,tag_type:`generic`,cost_per_kg:null,last_scale_weight:t===null?null:Math.round(t),last_weighed_at:t===null?null:new Date().toISOString(),category:null,low_stock_threshold_pct:null})}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`Failed to quick-add spool:`,t),r(t||n(`spoolbuddy.errors.quickAddFailed`,`Failed to add spool`),`error`)}finally{D(!1),k(!1),s()}}},ne=N!==null&&(M===h||M===null&&h!==null)?N:null,re=o.length,ie=new Set(o.map(e=>e.material)).size,H=new Set(o.filter(e=>e.brand).map(e=>e.brand)).size;return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-6 px-4 py-1.5 bg-zinc-800/50 rounded-xl border border-zinc-700/50 mb-3 shrink-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:re}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.inventory.spools`,`Spools`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:ie}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.material`,`Materials`)})]}),(0,K.jsx)(`div`,{className:`w-px h-5 bg-zinc-700`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xl font-bold text-zinc-100`,children:H}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.brand`,`Brands`)})]})]}),(0,K.jsxs)(`div`,{className:`flex-1 flex gap-4 min-h-0`,children:[(0,K.jsxs)(`div`,{className:`w-5/12 flex flex-col min-h-0`,children:[(0,K.jsxs)(`div`,{className:`border border-dashed border-zinc-700/50 rounded-xl p-4`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-3`,children:n(`spoolbuddy.dashboard.device`,`Device`)}),(0,K.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-2.5 h-2.5 rounded-full ${e.deviceOnline?`bg-green-500`:`bg-red-500`}`}),(0,K.jsx)(`span`,{className:`text-base text-zinc-400`,children:e.deviceOnline?n(`spoolbuddy.status.online`,`Online`):n(`spoolbuddy.status.offline`,`Disconnected`)})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 ${e.deviceOnline?`text-green-500`:`text-zinc-500`}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M3 6l3 1m0 0l-3 9a5.002 5.002 0 006.001 0M6 7l3 9M6 7l6-2m6 2l3-1m-3 1l-3 9a5.002 5.002 0 006.001 0M18 7l3 9m-3-9l-6-2m0-2v2m0 16V5m0 16H9m3 0h3`})}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:n(`spoolbuddy.spool.scaleWeight`,`Scale`)})]}),(0,K.jsx)(`span`,{className:`text-lg font-mono font-semibold text-zinc-100`,children:I===null?`—`:`${Math.abs(I)<=20?0:Math.round(Math.max(0,I))}g`})]}),(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-3 bg-zinc-800/50 rounded-lg`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 ${e.deviceOnline?`text-green-500`:`text-zinc-500`}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A2 2 0 013 12V7a4 4 0 014-4z`})}),(0,K.jsx)(`span`,{className:`text-sm text-zinc-500`,children:`NFC`})]}),(0,K.jsx)(`span`,{className:`text-sm font-medium ${M?`text-green-500`:`text-zinc-500`}`,children:M?n(`spoolbuddy.dashboard.tagDetected`,`Tag detected`):n(`spoolbuddy.dashboard.noTag`,`No tag`)})]})]})]}),l.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 border border-dashed border-zinc-700/50 rounded-xl p-4`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-2.5`,children:n(`spoolbuddy.dashboard.printers`,`Printers`)}),(0,K.jsx)(`div`,{className:`flex flex-wrap gap-2 overflow-hidden`,children:l.map((e,t)=>{let n=u[t]?.data?.connected??!1;return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2.5 py-1 bg-zinc-800/50 rounded-lg`,title:`${e.name} — ${n?`Online`:`Offline`}`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0 ${n?`bg-green-500`:`bg-zinc-600`}`}),(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 truncate max-w-[100px]`,children:e.name})]},e.id)})}),d.length>0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,"data-testid":`plate-clear-section`,"aria-label":n(`spoolbuddy.dashboard.plateReadyLabel`,`Plates ready to clear`),children:d.map(({printer:e})=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>p.mutate(e.id),disabled:p.isPending,"data-testid":`plate-clear-button-${e.id}`,title:n(`spoolbuddy.dashboard.plateReady`,`Plate ready: {{name}}`,{name:e.name}),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-lg bg-amber-500/10 hover:bg-amber-500/20 active:bg-amber-500/30 border border-amber-500/30 text-amber-200 transition-colors disabled:opacity-60 disabled:cursor-wait`,children:[(0,K.jsxs)(`svg`,{className:`w-3 h-3 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12 9v4`}),(0,K.jsx)(`path`,{d:`M12 17h.01`}),(0,K.jsx)(`path`,{d:`M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`})]}),(0,K.jsx)(`span`,{className:`text-xs truncate max-w-[100px]`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs opacity-70`,"aria-hidden":`true`,children:`·`}),(0,K.jsx)(`span`,{className:`text-xs font-medium`,children:n(`spoolbuddy.dashboard.plateClearAction`,`Clear`)})]},e.id))})]})]}),(0,K.jsx)(`div`,{className:`w-7/12 min-h-0`,children:(0,K.jsxs)(`div`,{className:`border border-dashed border-zinc-700/50 rounded-xl p-6 h-full flex flex-col`,children:[(0,K.jsx)(`h2`,{className:`text-sm font-semibold text-zinc-400 uppercase tracking-wide mb-4 shrink-0`,children:n(`spoolbuddy.dashboard.currentSpool`,`Current Spool`)}),(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center min-h-0`,children:e.deviceOnline?(L||e.matchedSpool)&&h&&b!==h?(0,K.jsx)(fQe,{spool:(()=>{let t=L??e.matchedSpool;return{id:t.id,tag_uid:h,material:t.material,subtype:t.subtype,color_name:t.color_name,rgba:t.rgba,brand:t.brand,label_weight:t.label_weight,core_weight:t.core_weight,weight_used:t.weight_used}})(),scaleWeight:ne??_,onSyncWeight:()=>s(),onAssignToAms:()=>T(!0),isAssigned:z,onUnassignFromAms:z&&L?.id!=null?()=>m.mutate(L.id):void 0,onClose:V}):M&&h&&!L&&!e.matchedSpool&&b!==h?(0,K.jsx)(pQe,{tagUid:h,scaleWeight:ne??_,onLinkSpool:B.length>0?()=>C(!0):void 0,onAddToInventory:()=>D(!0),onClose:V}):(0,K.jsx)(IQe,{}):(0,K.jsx)(LQe,{})})]})})]}),R&&!A&&h&&(0,K.jsx)(jQe,{isOpen:w,onClose:()=>T(!1),spool:R,printerId:t,spoolmanMode:a}),h&&(0,K.jsx)(MQe,{isOpen:S,onClose:()=>C(!1),tagId:h,untaggedSpools:B,onLink:ee}),E&&h&&(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-2xl p-6 mx-4 max-w-sm w-full border border-zinc-700`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100 mb-3`,children:n(`spoolbuddy.modal.addToInventory`,`Add to Inventory`)}),(0,K.jsxs)(`div`,{className:`flex gap-2.5 p-3 bg-amber-500/10 border border-amber-500/20 rounded-lg mb-4`,children:[(0,K.jsx)(`svg`,{className:`w-5 h-5 text-amber-500 shrink-0 mt-0.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`2`,d:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})}),(0,K.jsx)(`p`,{className:`text-sm text-amber-200/80`,children:n(`spoolbuddy.modal.quickAddHint`,`For best results, add the spool in the Bambuddy web interface first (with material, color, brand), then use "Assign Spool" here to assign the NFC tag.`)})]}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-400 mb-1`,children:n(`spoolbuddy.modal.quickAddDesc`,`This will create a basic PLA spool entry with this NFC tag. You can edit the details later in Bambuddy.`)}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 font-mono mb-5`,children:h}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(`button`,{onClick:()=>D(!1),className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:n(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:te,disabled:O,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-50 transition-colors min-h-[44px]`,children:O?n(`common.saving`,`Saving...`):n(`spoolbuddy.modal.addAnyway`,`Add Anyway`)})]})]})})]})}function zQe(e){return e<=3?`AMS ${String.fromCharCode(65+e)}`:e>=128&&e<=135?`AMS HT ${String.fromCharCode(65+e-128)}`:`AMS ${e}`}function BQe(e){return e?{O1D:`H2D`,O1E:`H2D Pro`,O2D:`H2D Pro`,O1C:`H2C`,O1C2:`H2C`,O1S:`H2S`,"BL-P001":`X1C`,"BL-P002":`X1`,"BL-P003":`X1E`,N6:`X2D`,N9:`A2L`,C11:`P1S`,C12:`P1P`,C13:`P2S`,N2S:`A1`,N1:`A1 Mini`,X1C:`X1C`,X1:`X1`,X1E:`X1E`,X2D:`X2D`,P1S:`P1S`,P1P:`P1P`,P2S:`P2S`,A1:`A1`,"A1 Mini":`A1 Mini`,A2L:`A2L`,H2D:`H2D`,"H2D Pro":`H2D Pro`,H2C:`H2C`,H2S:`H2S`}[e]||e:``}function X9(e){return!e.tray_type||e.tray_type===``}function VQe(e){return e?`#${e.slice(0,6)}`:`#808080`}function HQe(){let{selectedPrinterId:e,setAlert:t}=nr(),{t:n}=W(),r=no(),{showToast:i}=Td(),{data:a}=q({queryKey:[`printerStatus`,e],queryFn:()=>Q.getPrinterStatus(e),enabled:e!==null,staleTime:30*1e3}),{data:o}=q({queryKey:[`printer`,e],queryFn:()=>Q.getPrinter(e),enabled:e!==null,staleTime:60*1e3}),{data:s}=q({queryKey:[`slotPresets`,e],queryFn:()=>Q.getSlotPresets(e),enabled:e!==null,staleTime:120*1e3}),{data:c}=q({queryKey:[`settings`],queryFn:()=>Q.getSettings(),staleTime:300*1e3}),{data:l}=q({queryKey:[`spoolman-status`],queryFn:Q.getSpoolmanStatus,staleTime:60*1e3}),u=l?.enabled&&l?.connected,{data:d}=q({queryKey:[`linked-spools`],queryFn:Q.getLinkedSpools,enabled:!!u,staleTime:30*1e3}),f=d?.linked,{data:p=[]}=q({queryKey:[`spoolman-slot-assignments-all`],queryFn:()=>Q.getSpoolmanSlotAssignments(),enabled:!!u,staleTime:30*1e3}),{data:m=[]}=q({queryKey:[`spoolman-inventory-spools`],queryFn:()=>Q.getSpoolmanInventorySpools(!1),enabled:!!u,staleTime:30*1e3}),{data:h}=q({queryKey:[`spool-assignments`,e],queryFn:()=>Q.getAssignments(e),enabled:e!==null,staleTime:30*1e3}),g=(0,y.useMemo)(()=>{let e={};if(!h)return e;for(let t of h){let n=t.spool;if(n&&n.label_weight>0&&n.weight_used!=null){let r=Math.round(Math.max(0,n.label_weight-n.weight_used)/n.label_weight*100);e[`${t.ams_id}-${t.tray_id}`]=r}}return e},[h]),_=o?.serial_number??``,v=(0,y.useCallback)((t,n,r)=>{if(e!==null&&p.length&&m.length){let r=p.find(r=>r.printer_id===e&&r.ams_id===t&&r.tray_id===n);if(r){let e=m.find(e=>e.id===r.spoolman_spool_id);if(e&&(e.label_weight??0)>0)return Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100)}}if(f&&_){let e=(r?.tray_uuid||r?.tag_uid||Hf(_,t,n))?.toUpperCase(),i=zf(e?f[e]:void 0);if(i!==null)return i}return null},[f,_,e,p,m]),b=a?.connected??!1,x=(0,y.useRef)({});(0,y.useEffect)(()=>{e&&a?.ams&&a.ams.length>0&&(x.current[e]=a.ams)},[a?.ams,e]);let S=(0,y.useMemo)(()=>{let t=a?.ams;return t&&t.length>0?t:(e?x.current[e]:null)??[]},[a?.ams,e]),C=(0,y.useMemo)(()=>S.filter(e=>!e.is_ams_ht),[S]),w=(0,y.useMemo)(()=>S.filter(e=>e.is_ams_ht),[S]),T=(0,y.useMemo)(()=>{let e={};if(!f||!_)return e;for(let t of C)for(let n=0;n<(t.tray?.length??0);n++){let r=t.tray[n],i=v(t.id,n,X9(r)?null:r);i!==null&&(e[`${t.id}-${n}`]=i)}return e},[f,_,C,v]),E=(0,y.useRef)(void 0),D=a?.tray_now;D!==void 0&&D!==255?E.current=D:D===255&&(E.current=void 0);let O=D!==void 0&&D!==255?D:E.current,k=o?.nozzle_count===2||a?.temperatures?.nozzle_2!==void 0,A=(0,y.useMemo)(()=>[...a?.vt_tray??[]].sort((e,t)=>(e.id??254)-(t.id??254)),[a?.vt_tray]),j=c?{humidityGood:Number(c.ams_humidity_good)||40,humidityFair:Number(c.ams_humidity_fair)||60,tempGood:Number(c.ams_temp_good)||28,tempFair:Number(c.ams_temp_fair)||35}:void 0,M=(0,y.useRef)({});(0,y.useEffect)(()=>{a?.ams_extruder_map&&Object.keys(a.ams_extruder_map).length>0&&(M.current=a.ams_extruder_map)},[a?.ams_extruder_map]);let N=a?.ams_extruder_map&&Object.keys(a.ams_extruder_map).length>0?a.ams_extruder_map:M.current,P=(0,y.useCallback)(e=>{if(!k)return null;let t=N[String(e)],n=e>=128?e-128:e;return(t===void 0?n:t)===1?`L`:`R`},[k,N]),[F,I]=(0,y.useState)(null),[L,R]=(0,y.useState)(null),[z,B]=(0,y.useState)(null),[V,ee]=(0,y.useState)(null),te=(0,y.useCallback)((e,t)=>h?.find(n=>n.ams_id===Number(e)&&n.tray_id===Number(t)),[h]),ne=(0,y.useCallback)((e,t,n)=>{if(!f||!_)return;let r=(n?.tray_uuid||n?.tag_uid||Hf(_,e,t))?.toUpperCase();return r?f[r]:void 0},[f,_]),re=J({mutationFn:({printerId:e,amsId:t,trayId:n})=>Q.unassignSpool(e,t,n),onSuccess:()=>{r.invalidateQueries({queryKey:[`spool-assignments`,e]}),r.invalidateQueries({queryKey:[`spool-assignments`]}),i(n(`inventory.unassignSuccess`,`Spool unassigned`),`success`),R(null)}}),ie=J({mutationFn:e=>Q.unlinkSpool(e),onSuccess:e=>{i(n(`spoolman.unlinkSuccess`)||e?.message,`success`),r.invalidateQueries({queryKey:[`linked-spools`]}),r.invalidateQueries({queryKey:[`unlinked-spools`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),r.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),R(null)},onError:e=>{i(e.message||n(`spoolman.unlinkFailed`),`error`)}}),H=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{i(n(`inventory.unassignSuccess`,`Spool unassigned`),`success`),r.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),r.invalidateQueries({queryKey:[`spoolman-slot-assignments-all`]}),r.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),r.invalidateQueries({queryKey:[`unlinked-spools`]}),r.invalidateQueries({queryKey:[`linked-spools`]}),R(null)},onError:e=>{i(e.message||n(`inventory.assignFailed`,`Failed to unassign spool`),`error`)}}),ae=(0,y.useCallback)(e=>O===void 0?null:e<=3&&Math.floor(O/4)===e?O%4:e>=128&&e<=135&&O===Lf(e,0,!1)?0:null,[O]),oe=(0,y.useCallback)((e,t,n)=>{let r=Lf(e,t,!1),i=s?.[r],a=N[String(e)],o=e>=128?e-128:e,c=a===void 0?o:a;R({amsId:e,trayId:t,trayCount:n&&e>=128?1:4,tray:n,trayType:n?.tray_type||void 0,trayColor:n?.tray_color||void 0,traySubBrands:n?.tray_sub_brands||void 0,trayInfoIdx:n?.tray_info_idx||void 0,extruderId:k?c:void 0,caliIdx:n?.cali_idx,savedPresetId:i?.preset_id,location:`${zQe(e)} Slot ${t+1}`})},[s,N,k]),U=(0,y.useCallback)(e=>{let t=e.id??254,n=t-254,r=s?.[1020+n];R({amsId:255,trayId:n,trayCount:1,tray:X9(e)?null:e,trayType:e.tray_type||void 0,trayColor:e.tray_color||void 0,traySubBrands:e.tray_sub_brands||void 0,trayInfoIdx:e.tray_info_idx||void 0,extruderId:k?+(t===254):void 0,caliIdx:e.cali_idx,savedPresetId:r?.preset_id,location:k?t===254?`Ext-L`:`Ext-R`:`External`})},[s,k]),se=(0,y.useCallback)(()=>{if(!L)return;let{tray:e,location:t,...n}=L;R(null),I(n)},[L]),ce=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n,trayType:r,trayColor:i,location:a}=L;R(null),B({printerId:e,amsId:t,trayId:n,trayInfo:{type:r||``,material:r,color:i?.slice(0,6)||``,location:a}})},[L,e]),le=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n,tray:r}=L,i=(r?.tray_uuid||r?.tag_uid||Hf(_,t,n))?.toUpperCase()||``;R(null),ee({tagUid:r?.tag_uid||i,trayUuid:r?.tray_uuid||``,printerId:e,amsId:t,trayId:n})},[L,e,_]),ue=(0,y.useCallback)(()=>{if(!L||!e)return;let{amsId:t,trayId:n}=L;re.mutate({printerId:e,amsId:t,trayId:n})},[L,e,re]);(0,y.useEffect)(()=>{if(!b&&e){t({type:`warning`,message:n(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)});return}for(let e of S){let n=e.tray||[];for(let r=0;r=0&&i.remain<15&&i.tray_type){let n=e.id===254||e.id===255,a=!n&&e.id>=128,o=If(e.id,r,a,n);t({type:`warning`,message:`Low Filament: ${i.tray_type} (${o}) - ${i.remain}% remaining`});return}}}t(null)},[S,b,e,t,n]);let de=(0,y.useMemo)(()=>{let e=[];for(let t of w){let n=t.tray?.[0]||{id:0,tray_color:null,tray_type:``,tray_sub_brands:null,tray_id_name:null,tray_info_idx:null,remain:-1,k:null,cali_idx:null,tag_uid:null,tray_uuid:null,nozzle_temp_min:null,nozzle_temp_max:null},r=v(t.id,0,X9(n)?null:n),i=g[`${t.id}-0`]??null,a=n.remain!=null&&n.remain>=0?n.remain:null,o=i===0&&a!==null&&a>0?null:i;e.push({key:`ht-${t.id}`,label:zQe(t.id),tray:n,isEmpty:X9(n),isActive:ae(t.id)===0,temp:t.temp,humidity:t.humidity,nozzleSide:P(t.id),effectiveFill:r??o??a,onClick:()=>oe(t.id,0,X9(n)?null:n)})}for(let t of A){let r=t.id??254,i=k&&O===254?r===254&&a?.active_extruder===1||r===255&&a?.active_extruder===0:O===r,o=r-254,s=v(255,o,X9(t)?null:t),c=g[`255-${o}`]??null,l=t.remain!=null&&t.remain>=0?t.remain:null,u=c===0&&l!==null&&l>0?null:c;e.push({key:`ext-${r}`,label:k?r===254?n(`printers.extL`,`Ext-L`):n(`printers.extR`,`Ext-R`):n(`printers.ext`,`Ext`),tray:t,isEmpty:X9(t),isActive:i,nozzleSide:null,effectiveFill:s??u??l,onClick:()=>U(t)})}return e},[w,A,k,O,a?.active_extruder,n,ae,P,oe,U,g,v]);return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsx)(`div`,{className:`flex-1 min-h-0`,children:e?b?S.length===0&&A.length===0?(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(Rc,{className:`w-12 h-12 mx-auto mb-3 opacity-50`}),(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.noData`,`No AMS detected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.ams.connectAms`,`Connect an AMS to see filament slots`)})]})}):(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 h-full`,children:[(0,K.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:C.map(e=>(0,K.jsx)(DQe,{unit:e,activeSlot:ae(e.id),onConfigureSlot:oe,isDualNozzle:k,nozzleSide:P(e.id),thresholds:j,fillOverrides:g,spoolmanFillOverrides:T},e.id))}),de.length>0&&(0,K.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-3`,children:de.map(({key:e,label:t,tray:n,isEmpty:r,isActive:i,temp:a,humidity:o,nozzleSide:s,effectiveFill:c,onClick:l})=>{let u=VQe(n.tray_color);return(0,K.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg px-3 py-2 cursor-pointer hover:bg-bambu-dark-secondary/80 transition-all flex items-center gap-3 ${i?`ring-2 ring-bambu-green`:``}`,onClick:l,children:[(0,K.jsxs)(`div`,{className:`relative w-10 h-10 flex-shrink-0`,children:[r?(0,K.jsx)(`div`,{className:`w-full h-full rounded-full border-2 border-dashed border-gray-500 flex items-center justify-center`,children:(0,K.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full bg-gray-600`})}):(0,K.jsxs)(`svg`,{viewBox:`0 0 56 56`,className:`w-full h-full`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:u}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:u,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]}),i&&(0,K.jsx)(`div`,{className:`absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-1.5 h-1.5 bg-bambu-green rounded-full`})]}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`span`,{className:`text-xs text-white/50 font-medium truncate`,children:t}),s&&(0,K.jsx)(K9,{side:s})]}),(0,K.jsx)(`div`,{className:`text-sm text-white/80 truncate`,children:r?`Empty`:n.tray_type||`?`}),(a!=null||o!=null)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[a!=null&&(0,K.jsx)(TQe,{temp:a,goodThreshold:j?.tempGood,fairThreshold:j?.tempFair}),o!=null&&(0,K.jsx)(wQe,{humidity:o,goodThreshold:j?.humidityGood,fairThreshold:j?.humidityFair})]})]}),!r&&c!=null&&c>=0&&(0,K.jsx)(`div`,{className:`w-1.5 h-8 bg-bambu-dark-tertiary rounded-full overflow-hidden flex-shrink-0 flex flex-col-reverse`,children:(0,K.jsx)(`div`,{className:`w-full rounded-full`,style:{height:`${c}%`,backgroundColor:Rf(c)}})})]},e)})})]}):(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsx)(`div`,{className:`text-center text-white/50`,children:(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.printerDisconnected`,`Printer disconnected`)})})}):(0,K.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,K.jsxs)(`div`,{className:`text-center text-white/50`,children:[(0,K.jsx)(`p`,{className:`text-lg mb-2`,children:n(`spoolbuddy.ams.noPrinter`,`No printer selected`)}),(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.ams.selectPrinter`,`Select a printer from the top bar`)})]})})}),F&&e&&(0,K.jsx)(GU,{isOpen:!!F,onClose:()=>I(null),printerId:e,slotInfo:F,printerModel:BQe(o?.model??null)||void 0,fullScreen:!0,onSuccess:()=>{r.invalidateQueries({queryKey:[`slotPresets`,e]}),r.invalidateQueries({queryKey:[`printerStatus`,e]})}}),L&&e&&(()=>{let t=te(L.amsId,L.trayId),r=ne(L.amsId,L.trayId,L.tray),i=u?p.find(t=>t.printer_id===e&&t.ams_id===L.amsId&&t.tray_id===L.trayId):void 0,a=i?m.find(e=>e.id===i.spoolman_spool_id)??null:null;return(0,K.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>R(null)}),(0,K.jsxs)(`div`,{className:`relative w-full max-w-sm mx-4 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[L.trayColor&&(0,K.jsx)(`span`,{className:`w-4 h-4 rounded-full border border-black/20`,style:{backgroundColor:`#${L.trayColor.slice(0,6)}`}}),(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:L.location}),L.traySubBrands&&(0,K.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[`(`,L.traySubBrands,`)`]})]}),(0,K.jsx)(`button`,{onClick:()=>R(null),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,K.jsx)(Ru,{className:`w-5 h-5`})})]}),(0,K.jsxs)(`div`,{className:`p-4 space-y-2`,children:[!u&&t?.spool&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`inventory.assignedSpool`,`Assigned spool`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t.spool.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(t.spool.rgba)}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[t.spool.brand?`${t.spool.brand} `:``,t.spool.material,t.spool.color_name?` - ${t.spool.color_name}`:``]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0 ml-auto`,children:[`#`,t.spool.id]})]})]}),u&&r&&!a&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`spoolman.linkedSpool`,`Linked spool`)}),(0,K.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[`Spoolman #`,r.id,r.remaining_weight==null?``:` (${Math.round(r.remaining_weight)}g)`]})})]}),u&&a&&(0,K.jsxs)(`div`,{className:`p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary mb-3`,children:[(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray mb-1`,children:n(`inventory.assignedSpool`,`Assigned spool`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a.rgba&&(0,K.jsx)(`span`,{className:`w-3 h-3 rounded-full border border-black/20 flex-shrink-0`,style:Jd(a.rgba)}),(0,K.jsxs)(`span`,{className:`text-sm text-white`,children:[a.brand?`${a.brand} `:``,a.material,a.color_name?` - ${a.color_name}`:``]})]})]}),(0,K.jsxs)(`button`,{onClick:se,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-blue transition-colors text-left`,children:[(0,K.jsx)(Hl,{className:`w-5 h-5 text-bambu-blue flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`configureAmsSlot.title`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.configureDesc`,`Set filament preset, K-profile, and color`)})]})]}),!u&&(Xf(L?.tray)?null:t?(0,K.jsxs)(`button`,{onClick:ue,disabled:re.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`,`Unassign`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unassignDesc`,`Remove inventory spool from this slot`)})]})]}):(0,K.jsxs)(`button`,{onClick:ce,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors text-left`,children:[(0,K.jsx)(pl,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.assignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.assignDesc`,`Track a spool from your inventory`)})]})]})),u&&(r?.id?(0,K.jsxs)(`button`,{onClick:()=>ie.mutate(r.id),disabled:ie.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left active:opacity-50`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unlinkDesc`,`Remove Spoolman link from this slot`)})]})]}):a?(0,K.jsxs)(`button`,{onClick:()=>H.mutate(a.id),disabled:H.isPending,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-amber-500 transition-colors text-left active:opacity-50`,children:[(0,K.jsx)(Eu,{className:`w-5 h-5 text-amber-400 flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-amber-400 font-medium`,children:n(`inventory.unassignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.unassignDesc`,`Remove inventory spool from this slot`)})]})]}):(0,K.jsxs)(`button`,{onClick:le,className:`w-full flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors text-left`,children:[(0,K.jsx)(Vc,{className:`w-5 h-5 text-bambu-green flex-shrink-0`}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`text-white font-medium`,children:n(`inventory.assignSpool`)}),(0,K.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:n(`spoolbuddy.ams.linkDesc`,`Link a Spoolman spool to this slot`)})]})]}))]})]})]})})(),z&&(0,K.jsx)(gU,{isOpen:!!z,onClose:()=>{B(null),r.invalidateQueries({queryKey:[`spool-assignments`,e]}),r.invalidateQueries({queryKey:[`spool-assignments`]})},printerId:z.printerId,amsId:z.amsId,trayId:z.trayId,trayInfo:z.trayInfo,spoolmanEnabled:!!u}),V&&(0,K.jsx)(mU,{isOpen:!!V,onClose:()=>ee(null),tagUid:V.tagUid,trayUuid:V.trayUuid,printerId:V.printerId,amsId:V.amsId,trayId:V.trayId})]})}function UQe({type:e,deviceId:t,onClose:n}){let{t:r}=W(),[i,a]=(0,y.useState)(!1),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(``),[u,d]=(0,y.useState)(!1);(0,y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!i&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,n]);let f=(0,y.useCallback)(async()=>{a(!0),s(``),l(``),d(!0);try{s(r(`spoolbuddy.diagnostic.queuing`,`Queuing diagnostic on device... +`)),await od.queueDiagnostics(t,e);let n=null,i=0;for(;i<60&&!n;){await new Promise(e=>setTimeout(e,500));try{n=await od.getDiagnosticResult(t,e);break}catch{i++,i%4==0&&s(e=>e+`.`)}}if(!n)throw Error(`Diagnostic timed out - device did not report results`);s(n.output),n.success||l(`Exit code: ${n.exit_code}`)}catch(e){l(e instanceof Error?e.message:`Unknown error`),s(``)}finally{a(!1)}},[e,t,r]);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 animate-fade-in`,onClick:n,children:(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg shadow-xl w-full max-w-2xl mx-4 max-h-[80vh] flex flex-col animate-slide-up`,onClick:e=>e.stopPropagation(),children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center p-4 border-b border-zinc-700`,children:[(0,K.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e===`scale`?r(`spoolbuddy.diagnostic.scaleTitle`,`Scale Diagnostic`):e===`read_tag`?r(`spoolbuddy.diagnostic.readTagTitle`,`Read Tag Diagnostic`):r(`spoolbuddy.diagnostic.nfcTitle`,`NFC Reader Diagnostic`)}),(0,K.jsx)(`button`,{onClick:n,className:`text-zinc-400 hover:text-white transition-colors`,"aria-label":`Close`,children:(0,K.jsx)(Ru,{size:20})})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-auto p-4 bg-black/50 font-mono text-sm`,children:i?(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-green-400`,children:[(0,K.jsx)(`div`,{className:`animate-spin w-4 h-4 border-2 border-green-400 border-t-transparent rounded-full`}),(0,K.jsx)(`span`,{children:r(`spoolbuddy.diagnostic.running`,`Running diagnostic on device...`)})]}):o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`text-green-400 whitespace-pre-wrap break-words`,children:o}),c&&(0,K.jsxs)(`div`,{className:`text-red-400 mt-2`,children:[`❌ `,c]})]}):u?(0,K.jsx)(`div`,{children:c?(0,K.jsxs)(`div`,{className:`text-red-400`,children:[`ERROR: `,c]}):(0,K.jsx)(`span`,{className:`text-green-400`,children:r(`spoolbuddy.diagnostic.completed`,`Diagnostic completed successfully.`)})}):(0,K.jsxs)(`div`,{className:`text-zinc-500`,children:[r(`spoolbuddy.diagnostic.clickStart`,`Click "Run Diagnostic" to start the hardware diagnostic on`),` `,t,`.`]})}),(0,K.jsxs)(`div`,{className:`flex gap-2 p-4 border-t border-zinc-700 bg-zinc-800`,children:[(0,K.jsx)(`button`,{onClick:f,disabled:i,className:`flex-1 flex items-center justify-center gap-2 bg-green-600 hover:bg-green-700 disabled:bg-gray-600 disabled:cursor-not-allowed px-4 py-2 rounded font-semibold text-white transition-colors`,children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`animate-spin w-4 h-4 border-2 border-white border-t-transparent rounded-full`}),r(`spoolbuddy.diagnostic.runningBtn`,`Running...`)]}):u?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(jl,{size:16}),r(`spoolbuddy.diagnostic.runAgain`,`Run Again`)]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(bl,{size:16}),r(`spoolbuddy.diagnostic.runBtn`,`Run Diagnostic`)]})}),(0,K.jsx)(`button`,{onClick:n,className:`px-4 py-2 rounded bg-zinc-700 hover:bg-zinc-600 text-white font-semibold transition-colors`,children:r(`spoolbuddy.diagnostic.close`,`Close`)})]})]})})}function WQe(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function GQe(e){if(!e)return`-`;let t=vf(e);return t?t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})+` `+t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):`-`}var KQe=[{label:`Off`,value:0},{label:`1m`,value:60},{label:`2m`,value:120},{label:`5m`,value:300},{label:`10m`,value:600},{label:`30m`,value:1800}];function qQe({device:e}){let{t}=W(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(``),[c,l]=(0,y.useState)(!1),[u,d]=(0,y.useState)(null);return(0,y.useEffect)(()=>{!i&&e.backend_url&&a(e.backend_url)},[e.backend_url,i]),(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.nfcReader`,`NFC Reader`)}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.type`,`Type`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.nfc_reader_type||`N/A`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.connection`,`Connection`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:e.nfc_connection||`N/A`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.status.status`,`Status`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${e.nfc_ok?`bg-green-500`:e.nfc_reader_type?`bg-red-500`:`bg-zinc-600`}`}),(0,K.jsx)(`span`,{className:e.nfc_ok?`text-green-400`:e.nfc_reader_type?`text-red-400`:`text-zinc-500`,children:e.nfc_ok?t(`spoolbuddy.status.nfcReady`,`Ready`):e.nfc_reader_type?t(`common.error`,`Error`):t(`spoolbuddy.settings.notConnected`,`N/A`)})]})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.deviceInfo`,`Device Info`)}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.hostname`,`Host`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 truncate ml-2`,children:e.hostname})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`IP`}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:e.ip_address})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.uptime`,`Uptime`)}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:WQe(e.uptime_s)})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`ID`}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono truncate ml-2`,children:e.device_id})]})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 space-y-2`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:t(`spoolbuddy.settings.systemConfig`,`Backend & Auth`)}),(0,K.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),placeholder:`http://192.168.1.100:5000`,className:`w-full px-2 py-1.5 rounded bg-zinc-900 border border-zinc-700 text-zinc-100 text-xs`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`input`,{type:`password`,value:o,onChange:e=>s(e.target.value),placeholder:t(`spoolbuddy.settings.apiTokenPlaceholder`,`API token`),className:`flex-1 px-2 py-1.5 rounded bg-zinc-900 border border-zinc-700 text-zinc-100 text-xs`}),(0,K.jsx)(`button`,{onClick:async()=>{if(!i.trim()){d({type:`error`,text:t(`spoolbuddy.settings.systemFieldsRequired`,`Backend URL is required.`)});return}l(!0),d(null);try{await od.updateSystemConfig(e.device_id,i.trim(),o.trim()||void 0),d({type:`ok`,text:t(`spoolbuddy.settings.systemQueued`,`Config queued.`)})}catch(e){d({type:`error`,text:e instanceof Error?e.message:t(`common.error`,`Error`)})}finally{l(!1)}},disabled:c,className:`px-3 py-1.5 rounded bg-green-700 hover:bg-green-600 disabled:bg-zinc-700 text-xs font-medium text-zinc-100`,children:t(`spoolbuddy.settings.saveConfig`,`Save`)})]}),u&&(0,K.jsx)(`div`,{className:`text-xs ${u.type===`ok`?`text-green-400`:`text-red-400`}`,children:u.text})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 flex flex-col gap-2`,children:[(0,K.jsxs)(`button`,{onClick:()=>r(`nfc`),className:`flex-1 bg-blue-700 hover:bg-blue-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(Mu,{className:`w-4 h-4 text-blue-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-blue-100`,children:t(`spoolbuddy.settings.nfcDiagnostic`,`NFC Diagnostic`)})]}),(0,K.jsxs)(`button`,{onClick:()=>r(`scale`),className:`flex-1 bg-yellow-700 hover:bg-yellow-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(Bu,{className:`w-4 h-4 text-yellow-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-yellow-100`,children:t(`spoolbuddy.settings.scaleDiagnostic`,`Scale Diagnostic`)})]}),(0,K.jsxs)(`button`,{onClick:()=>r(`read_tag`),className:`flex-1 bg-emerald-700 hover:bg-emerald-600 transition-colors rounded-lg p-2 flex items-center gap-2`,children:[(0,K.jsx)(nc,{className:`w-4 h-4 text-emerald-300 shrink-0`}),(0,K.jsx)(`span`,{className:`text-xs font-medium text-emerald-100`,children:t(`spoolbuddy.settings.readTagDiagnostic`,`Read Tag`)})]})]})]}),n&&e&&(0,K.jsx)(UQe,{type:n,deviceId:e.device_id,onClose:()=>r(null)})]})}function JQe({device:e,onBrightnessChange:t}){let{t:n}=W(),[r,i]=(0,y.useState)(e.display_brightness),[a,o]=(0,y.useState)(e.display_blank_timeout),[s,c]=(0,y.useState)(!1),l=(0,y.useRef)(void 0),u=(0,y.useRef)(void 0);(0,y.useEffect)(()=>{i(e.display_brightness),o(e.display_blank_timeout)},[e.display_brightness,e.display_blank_timeout]);let d=(0,y.useCallback)(()=>{c(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>c(!1),1500)},[]),f=(0,y.useCallback)((t,n)=>{l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{od.updateDisplay(e.device_id,t,n).then(()=>d()).catch(e=>console.error(`Failed to update display:`,e))},300)},[e.device_id,d]),p=e=>{i(e),t(e),f(e,a)},m=e=>{o(e),f(r,e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300`,children:n(`spoolbuddy.settings.brightness`,`Brightness`)}),s&&(0,K.jsxs)(`span`,{className:`text-xs text-green-400 flex items-center gap-1 animate-pulse`,children:[(0,K.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}),n(`spoolbuddy.settings.saved`,`Saved`)]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`svg`,{className:`w-4 h-4 text-zinc-500 flex-shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`})}),(0,K.jsx)(`input`,{type:`range`,min:0,max:100,value:r,onChange:e=>p(parseInt(e.target.value)),className:`flex-1 h-2 bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-green-500`}),(0,K.jsxs)(`span`,{className:`text-sm font-mono text-zinc-400 w-10 text-right`,children:[r,`%`]})]}),!e.has_backlight&&(0,K.jsx)(`p`,{className:`text-xs text-zinc-600 mt-2`,children:n(`spoolbuddy.settings.noBacklight`,`No DSI backlight detected. Brightness control requires a DSI display.`)})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1`,children:n(`spoolbuddy.settings.screenBlank`,`Screen Blank Timeout`)}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-3`,children:n(`spoolbuddy.settings.screenBlankDesc`,`Screen turns off after inactivity. Touch to wake.`)}),(0,K.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:KQe.map(e=>(0,K.jsx)(`button`,{onClick:()=>m(e.value),className:`px-3 py-2 rounded-lg text-sm font-medium transition-colors min-h-[40px] ${a===e.value?`bg-green-600 text-white`:`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`}`,children:e.label},e.value))})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-600 text-center`,children:n(`spoolbuddy.settings.displayNote`,`Brightness is applied as a software filter.`)})]})}function YQe({step:e,labels:t}){return(0,K.jsxs)(`div`,{className:`flex flex-col items-center w-16 shrink-0 pt-1`,children:[(0,K.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${e===`tare`?`bg-green-600 text-white`:`bg-green-600/20 text-green-400`}`,children:e===`weight`?(0,K.jsx)(`svg`,{className:`w-3.5 h-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}):`1`}),(0,K.jsx)(`span`,{className:`text-[10px] mt-0.5 ${e===`tare`?`text-green-400 font-medium`:`text-green-400/60`}`,children:t.tare}),(0,K.jsx)(`div`,{className:`w-px h-5 my-1 ${e===`weight`?`bg-green-600/40`:`bg-zinc-700`}`}),(0,K.jsx)(`div`,{className:`flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold ${e===`weight`?`bg-green-600 text-white`:`bg-zinc-700 text-zinc-500`}`,children:`2`}),(0,K.jsx)(`span`,{className:`text-[10px] mt-0.5 ${e===`weight`?`text-green-400 font-medium`:`text-zinc-600`}`,children:t.weight})]})}function XQe({device:e,weight:t,weightStable:n,rawAdc:r}){let{t:i}=W(),a=no(),[o,s]=(0,y.useState)(`idle`),[c,l]=(0,y.useState)(`500`),[u,d]=(0,y.useState)(null),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),[g,_]=(0,y.useState)(null),v=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>{v.current&&clearTimeout(v.current)},[]);let b=(0,y.useCallback)(e=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>h(null),e)},[]);(0,y.useEffect)(()=>{if(!g)return;let e=()=>Date.now()-g.startedAtMs,t=setInterval(()=>{a.invalidateQueries({queryKey:[`spoolbuddy-devices`]})},1e3),n=setTimeout(()=>{_(null),h({type:`error`,msg:i(`spoolbuddy.settings.tareTimedOut`,`Tare timed out — is the SpoolBuddy daemon running?`)}),b(5e3)},Math.max(0,15e3-e()));return()=>{clearInterval(t),clearTimeout(n)}},[g,a,i,b]),(0,y.useEffect)(()=>{g&&(e?.last_calibrated_at??null)!==g.snapshot&&(_(null),h({type:`ok`,msg:i(`spoolbuddy.settings.tareComplete`,`Tare complete!`)}),b(3e3))},[e?.last_calibrated_at,g,i,b]);let x=e=>{e===`backspace`?l(e=>e.slice(0,-1)||``):e===`.`&&!c.includes(`.`)?l(e=>e+`.`):e>=`0`&&e<=`9`&&l(t=>t===`0`?e:t+e)};return o===`idle`?(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 mb-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-lg font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`})]}),(0,K.jsxs)(`div`,{className:`text-xs text-zinc-500 text-right`,children:[(0,K.jsxs)(`span`,{children:[i(`spoolbuddy.settings.tareOffset`,`Tare`),`: `,e.tare_offset]}),(0,K.jsx)(`span`,{className:`mx-1.5`,children:`·`}),(0,K.jsxs)(`span`,{children:[i(`spoolbuddy.settings.calFactor`,`Factor`),`: `,e.calibration_factor.toFixed(2)]})]})]}),e.last_calibrated_at&&(0,K.jsxs)(`div`,{className:`text-xs text-zinc-600 mt-1`,children:[i(`spoolbuddy.settings.lastCalibrated`,`Last calibrated`),`: `,GQe(e.last_calibrated_at)]})]}),m&&(0,K.jsx)(`div`,{className:`rounded-lg px-3 py-2 mb-3 text-sm ${m.type===`ok`?`bg-green-900/30 text-green-300 border border-green-800`:`bg-red-900/30 text-red-300 border border-red-800`}`,children:m.msg}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsxs)(`button`,{onClick:async()=>{p(!0),h(null),v.current&&=(clearTimeout(v.current),null);let t=e?.last_calibrated_at??null;try{await od.tare(e.device_id),h({type:`ok`,msg:i(`spoolbuddy.settings.tareSet`,`Tare command sent. Waiting for device...`)}),_({snapshot:t,startedAtMs:Date.now()})}catch{h({type:`error`,msg:i(`spoolbuddy.settings.tareFailed`,`Failed to send tare command`)}),b(5e3)}finally{p(!1)}},disabled:f,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px] flex items-center justify-center gap-2`,children:[f&&(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),i(`spoolbuddy.weight.tare`,`Tare`)]}),(0,K.jsx)(`button`,{onClick:()=>{s(`tare`),h(null)},className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:i(`spoolbuddy.weight.calibrate`,`Calibrate`)})]})]}):(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsx)(YQe,{step:o,labels:{tare:i(`spoolbuddy.weight.tare`,`Tare`),weight:i(`spoolbuddy.settings.knownWeight`,`Known weight`)}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 bg-zinc-800 rounded-lg px-3 py-1.5 mb-1.5`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full shrink-0 ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-sm font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`}),(0,K.jsx)(`span`,{className:`text-xs ml-auto ${n?`text-green-400`:`text-amber-400`}`,children:n?i(`spoolbuddy.settings.stable`,`Stable`):i(`spoolbuddy.settings.settling`,`Settling...`)})]}),m&&(0,K.jsx)(`div`,{className:`rounded-lg px-3 py-1.5 mb-1.5 text-xs ${m.type===`ok`?`bg-green-900/30 text-green-300 border border-green-800`:`bg-red-900/30 text-red-300 border border-red-800`}`,children:m.msg}),o===`tare`?(0,K.jsx)(`p`,{className:`text-sm text-zinc-300 mb-3`,children:i(`spoolbuddy.settings.calStep1`,`Remove all items from the scale and press Set Zero.`)}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-400 shrink-0`,children:i(`spoolbuddy.settings.knownWeight`,`Known weight`)}),(0,K.jsxs)(`div`,{className:`flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1 text-right text-lg font-mono text-zinc-100`,children:[c||`0`,(0,K.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`g`})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1 mb-1.5`,children:[`7`,`8`,`9`,`backspace`,`4`,`5`,`6`,`.`,`1`,`2`,`3`,`0`].map(e=>(0,K.jsx)(`button`,{onClick:()=>x(e),className:`rounded text-lg font-medium transition-colors h-[48px] active:scale-95 ${e===`backspace`?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700`}`,children:e===`backspace`?`⌫`:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>{s(`idle`),h(null)},className:`flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors h-[40px]`,children:i(`common.cancel`,`Cancel`)}),(0,K.jsxs)(`button`,{onClick:async()=>{if(o===`tare`){p(!0),h(null);try{d(r),await od.tare(e.device_id),h({type:`ok`,msg:i(`spoolbuddy.settings.zeroSet`,`Zero point set. Place known weight on scale.`)}),s(`weight`)}catch{h({type:`error`,msg:i(`spoolbuddy.settings.tareFailed`,`Failed to send tare command`)})}finally{p(!1)}}else if(o===`weight`){let t=parseFloat(c);if(r===null||!t||t<=0)return;p(!0),h(null);try{await od.setCalibrationFactor(e.device_id,t,r,u??void 0),h({type:`ok`,msg:i(`spoolbuddy.settings.calibrationDone`,`Calibration complete!`)}),b(3e3),s(`idle`)}catch{h({type:`error`,msg:i(`spoolbuddy.settings.calibrationFailed`,`Calibration failed`)}),b(5e3)}finally{p(!1)}}},disabled:f,className:`flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors h-[40px] flex items-center justify-center gap-2`,children:[f&&(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),o===`tare`?i(`spoolbuddy.settings.setZero`,`Set Zero`):i(`spoolbuddy.settings.calibrateNow`,`Calibrate`)]})]})]})]})}function ZQe({device:e}){let{t}=W(),[n,r]=(0,y.useState)(null),[i,a]=(0,y.useState)(null),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(!1),u=e.update_status===`pending`||e.update_status===`updating`;(0,y.useEffect)(()=>{u&&n===`applying`&&r(null)},[u,n]),(0,y.useEffect)(()=>{let e=()=>{u&&setTimeout(()=>window.location.reload(),1e3)};return window.addEventListener(`spoolbuddy-online`,e),()=>window.removeEventListener(`spoolbuddy-online`,e)},[u]);let{data:d,refetch:f}=q({queryKey:[`spoolbuddy-update-check`,e.device_id],queryFn:()=>od.checkDaemonUpdate(e.device_id),staleTime:0}),{data:p}=q({queryKey:[`spoolbuddy-ssh-key`],queryFn:()=>od.getSSHPublicKey(),enabled:o,staleTime:1/0}),m=async()=>{r(`checking`),a(null);try{await f()}finally{r(null)}},h=async()=>{r(`applying`),a(null);try{await od.triggerUpdate(e.device_id)}catch(e){a(e instanceof Error?e.message:`Failed to trigger update`),r(null)}},g=n!=null||u,_=()=>{p?.public_key&&(navigator.clipboard.writeText(p.public_key),l(!0),setTimeout(()=>l(!1),2e3))},v=e.firmware_version||(d?.current_version&&d.current_version!==`0.0.0`?d.current_version:null);return(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3 space-y-3`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.currentVersion`,`Current Version`)}),(0,K.jsx)(`span`,{className:`text-zinc-200 font-mono`,children:v||(0,K.jsx)(`span`,{className:`text-zinc-500 italic text-xs`,children:t(`spoolbuddy.settings.versionPending`,`Waiting for daemon...`)})})]}),g?(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`svg`,{className:`w-4 h-4 animate-spin text-green-400 flex-shrink-0`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,K.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,K.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),(0,K.jsx)(`span`,{className:`text-green-300 text-xs`,children:n===`checking`?t(`spoolbuddy.settings.checking`,`Checking for updates...`):e.update_message||t(`spoolbuddy.settings.updateWaiting`,`Updating...`)})]}):e.update_status===`error`?(0,K.jsx)(`p`,{className:`text-xs text-red-300`,children:e.update_message||t(`spoolbuddy.settings.updateFailed`,`Update failed`)}):i?(0,K.jsx)(`p`,{className:`text-xs text-red-300`,children:i}):d?.update_available?(0,K.jsxs)(`p`,{className:`text-xs text-green-300`,children:[t(`spoolbuddy.settings.updateAvailable`,`Update available`),`: `,v,` → `,d.latest_version]}):null,!g&&(d?.update_available?(0,K.jsx)(`button`,{onClick:h,disabled:!e.online,className:`w-full px-3 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors`,children:e.online?t(`spoolbuddy.settings.applyUpdate`,`Apply Update`):t(`spoolbuddy.settings.deviceOffline`,`Device Offline`)}):(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:m,className:`flex-1 px-3 py-2 rounded-lg text-xs font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors`,children:t(`spoolbuddy.settings.checkUpdates`,`Check for Updates`)}),(0,K.jsx)(`button`,{onClick:h,disabled:!e.online,className:`px-3 py-2 rounded-lg text-xs font-medium bg-zinc-700 text-zinc-400 hover:bg-zinc-600 hover:text-zinc-200 disabled:opacity-40 transition-colors`,children:t(`spoolbuddy.settings.forceUpdate`,`Force Update`)})]}))]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsxs)(`button`,{onClick:()=>s(!o),className:`w-full flex justify-between items-center text-xs`,children:[(0,K.jsx)(`span`,{className:`font-medium text-zinc-400`,children:t(`spoolbuddy.settings.sshSetup`,`SSH Setup`)}),(0,K.jsx)(`svg`,{className:`w-3 h-3 text-zinc-500 transition-transform ${o?`rotate-180`:``}`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M19 9l-7 7-7-7`})})]}),o&&(0,K.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500`,children:t(`spoolbuddy.settings.sshDescription`,`SSH key is deployed automatically. For manual setup, add this key to ~/.ssh/authorized_keys on the device.`)}),p?.public_key?(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`pre`,{className:`bg-zinc-900 rounded p-2 text-[10px] text-zinc-400 font-mono break-all whitespace-pre-wrap`,children:p.public_key}),(0,K.jsx)(`button`,{onClick:_,className:`absolute top-1 right-1 px-1.5 py-0.5 rounded text-[10px] bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors`,children:c?t(`common.copied`,`Copied!`):t(`common.copy`,`Copy`)})]}):(0,K.jsx)(`span`,{className:`text-[10px] text-zinc-500 italic`,children:t(`spoolbuddy.settings.sshKeyLoading`,`Loading...`)})]})]})]})}function QQe({percent:e,color:t}){return(0,K.jsx)(`div`,{className:`w-full h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all ${t}`,style:{width:`${Math.min(100,Math.max(0,e))}%`}})})}function $Qe(e){let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h ${r}m`:n>0?`${n}h ${r}m`:`${r}m`}function e$e({device:e}){let{t}=W(),n=e.system_stats;if(!n)return(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`p`,{className:`text-sm text-zinc-500`,children:t(`spoolbuddy.settings.systemStatsWaiting`,`Waiting for system stats...`)})});let r=n.memory,i=n.disk,a=(n.cpu_temp_c??0)>=80?`text-red-400`:(n.cpu_temp_c??0)>=65?`text-amber-400`:`text-green-400`,o=(r?.percent??0)>=90?`bg-red-500`:(r?.percent??0)>=70?`bg-amber-500`:`bg-green-500`,s=(i?.percent??0)>=90?`bg-red-500`:(i?.percent??0)>=70?`bg-amber-500`:`bg-green-500`;return(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:`CPU`}),(0,K.jsxs)(`div`,{className:`space-y-1.5 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.cores`,`Cores`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.cpu_count??`-`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.loadAvg`,`Load Avg`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.load_avg?n.load_avg.join(` / `):`-`})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.temp`,`Temp`)}),(0,K.jsx)(`span`,{className:`font-mono font-medium ${a}`,children:n.cpu_temp_c==null?`-`:`${n.cpu_temp_c}\u00B0C`})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-2`,children:t(`spoolbuddy.settings.memory`,`Memory`)}),r?(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(QQe,{percent:r.percent??0,color:o}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.used`,`Used`)}),(0,K.jsxs)(`span`,{className:`text-zinc-300 font-mono`,children:[r.used_mb,` / `,r.total_mb,` MB`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.available`,`Free`)}),(0,K.jsxs)(`span`,{className:`text-zinc-300 font-mono`,children:[r.available_mb,` MB`]})]})]})]}):(0,K.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`-`})]})]}),(0,K.jsx)(`div`,{className:`bg-zinc-800 rounded-lg px-3 py-2`,children:(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 shrink-0`,children:t(`spoolbuddy.settings.disk`,`Disk`)}),i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`flex-1`,children:(0,K.jsx)(QQe,{percent:i.percent??0,color:s})}),(0,K.jsxs)(`span`,{className:`text-xs text-zinc-300 font-mono shrink-0`,children:[i.used_gb,` / `,i.total_gb,` GB`]})]}):(0,K.jsx)(`span`,{className:`text-xs text-zinc-500`,children:`-`})]})}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1.5`,children:t(`spoolbuddy.settings.osInfo`,`OS`)}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[n.os?.os&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.distro`,`Distro`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 truncate ml-2`,children:n.os.os})]}),n.os?.kernel&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.kernel`,`Kernel`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono truncate ml-2`,children:n.os.kernel})]}),n.os?.arch&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.arch`,`Arch`)}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.os.arch})]})]})]}),(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-3`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-semibold text-zinc-300 mb-1.5`,children:t(`spoolbuddy.settings.runtime`,`Runtime`)}),(0,K.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[n.os?.python&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`Python`}),(0,K.jsx)(`span`,{className:`text-zinc-300 font-mono`,children:n.os.python})]}),n.system_uptime_s!=null&&(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:t(`spoolbuddy.settings.systemUptime`,`Uptime`)}),(0,K.jsx)(`span`,{className:`text-zinc-300`,children:$Qe(n.system_uptime_s)})]})]})]})]})]})}function t$e(){let{sbState:e,setDisplayBrightness:t}=nr(),{t:n}=W(),[r,i]=(0,y.useState)(`device`),{data:a=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:1e4}),o=e.deviceId?a.find(t=>t.device_id===e.deviceId)??a[0]:a[0],s=[{id:`device`,label:n(`spoolbuddy.settings.tabDevice`,`Device`)},{id:`display`,label:n(`spoolbuddy.settings.tabDisplay`,`Display`)},{id:`scale`,label:n(`spoolbuddy.settings.tabScale`,`Scale`)},{id:`updates`,label:n(`spoolbuddy.settings.tabUpdates`,`Updates`)},{id:`system`,label:n(`spoolbuddy.settings.tabSystem`,`System`)}];return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-zinc-100 mb-3`,children:n(`spoolbuddy.nav.settings`,`Settings`)}),(0,K.jsx)(`div`,{className:`flex gap-1 bg-zinc-800/50 rounded-lg p-1 mb-4`,children:s.map(e=>(0,K.jsx)(`button`,{onClick:()=>i(e.id),className:`flex-1 px-2 py-2 rounded-md text-sm font-medium transition-colors min-h-[36px] ${r===e.id?`bg-zinc-700 text-zinc-100`:`text-zinc-500 hover:text-zinc-300`}`,children:e.label},e.id))}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:o?(0,K.jsxs)(K.Fragment,{children:[r===`device`&&(0,K.jsx)(qQe,{device:o}),r===`display`&&(0,K.jsx)(JQe,{device:o,onBrightnessChange:t}),r===`scale`&&(0,K.jsx)(XQe,{device:o,weight:e.weight,weightStable:e.weightStable,rawAdc:e.rawAdc}),r===`updates`&&(0,K.jsx)(ZQe,{device:o}),r===`system`&&(0,K.jsx)(e$e,{device:o})]}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`div`,{className:`text-center text-zinc-500`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:n(`spoolbuddy.settings.noDevice`,`No SpoolBuddy device found`)})})})})]})}function n$e({device:e,weight:t,weightStable:n,rawAdc:r}){let{t:i}=W(),[a,o]=(0,y.useState)(!1),[s,c]=(0,y.useState)(`idle`),[l,u]=(0,y.useState)(`500`),[d,f]=(0,y.useState)(null),[p,m]=(0,y.useState)(!1),h=e=>{e===`backspace`?u(e=>e.slice(0,-1)||``):e===`.`&&!l.includes(`.`)?u(e=>e+`.`):e>=`0`&&e<=`9`&&u(t=>t===`0`?e:t+e)};return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`div`,{className:`bg-zinc-800 rounded-lg p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-400`,children:i(`spoolbuddy.settings.currentWeight`,`Current weight`)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`div`,{className:`w-2 h-2 rounded-full ${n?`bg-green-500`:`bg-amber-500 animate-pulse`}`}),(0,K.jsx)(`span`,{className:`text-lg font-mono text-zinc-200`,children:t===null?`-- g`:`${t.toFixed(1)} g`})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 mt-3 text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:i(`spoolbuddy.settings.tareOffset`,`Tare offset`)}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.tare_offset})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:i(`spoolbuddy.settings.calFactor`,`Cal. factor`)}),(0,K.jsx)(`span`,{className:`text-zinc-400 font-mono`,children:e.calibration_factor.toFixed(2)})]})]})]}),s===`idle`?(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:async()=>{m(!0);try{await od.tare(e.device_id)}catch(e){console.error(`Failed to tare:`,e)}finally{m(!1)}},disabled:p,className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-200 hover:bg-zinc-600 disabled:opacity-40 transition-colors min-h-[44px]`,children:p?`...`:i(`spoolbuddy.weight.tare`,`Tare`)}),(0,K.jsx)(`button`,{onClick:()=>{c(`tare`)},className:`flex-1 px-4 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px]`,children:i(`spoolbuddy.weight.calibrate`,`Calibrate`)})]}):(0,K.jsxs)(`div`,{className:`bg-zinc-800 border border-zinc-700 rounded-lg p-3 space-y-2`,children:[(0,K.jsx)(`div`,{className:`text-sm font-medium text-zinc-200`,children:s===`tare`?i(`spoolbuddy.settings.calStep1`,`Step 1: Remove all items from the scale`):i(`spoolbuddy.settings.calStep2`,`Step 2: Place known weight on scale`)}),s===`weight`&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:i(`spoolbuddy.settings.knownWeight`,`Known weight (g)`)}),(0,K.jsxs)(`div`,{className:`flex-1 bg-zinc-900 border border-zinc-600 rounded px-3 py-1.5 text-right text-base font-mono text-zinc-100`,children:[l||`0`,(0,K.jsx)(`span`,{className:`text-zinc-500 ml-1`,children:`g`})]})]}),(0,K.jsx)(`div`,{className:`grid grid-cols-4 gap-1`,children:[`7`,`8`,`9`,`backspace`,`4`,`5`,`6`,`.`,`1`,`2`,`3`,`0`].map(e=>(0,K.jsx)(`button`,{onClick:()=>h(e),className:`py-2 rounded text-sm font-medium transition-colors min-h-[36px] ${e===`backspace`?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600`:`bg-zinc-800 text-zinc-100 hover:bg-zinc-700 border border-zinc-700`}`,children:e===`backspace`?`⌫`:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`button`,{onClick:()=>c(`idle`),className:`flex-1 px-4 py-2 rounded-lg text-sm bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[40px]`,children:i(`common.cancel`,`Cancel`)}),(0,K.jsx)(`button`,{onClick:async()=>{if(s===`tare`){o(!0);try{f(r),await od.tare(e.device_id),c(`weight`)}catch(e){console.error(`Failed to tare:`,e)}finally{o(!1)}}else if(s===`weight`){let t=parseFloat(l);if(r===null||!t||t<=0)return;o(!0);try{await od.setCalibrationFactor(e.device_id,t,r,d??void 0),c(`idle`)}catch(e){console.error(`Failed to calibrate:`,e)}finally{o(!1)}}},disabled:a,className:`flex-1 px-4 py-2 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 transition-colors min-h-[40px]`,children:a?`...`:s===`tare`?i(`spoolbuddy.settings.setZero`,`Set Zero`):i(`spoolbuddy.settings.calibrateNow`,`Calibrate`)})]})]})]})}function r$e(){let{sbState:e}=nr(),{t}=W(),n=$n(),{data:r=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:1e4}),i=e.deviceId?r.find(t=>t.device_id===e.deviceId)??r[0]:r[0];return(0,K.jsxs)(`div`,{className:`h-full flex flex-col p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3 mb-4`,children:[(0,K.jsx)(`button`,{onClick:()=>n(`/spoolbuddy/settings`),className:`p-1.5 rounded-lg text-zinc-400 hover:text-zinc-200 hover:bg-zinc-800 transition-colors`,children:(0,K.jsx)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M15 19l-7-7 7-7`})})}),(0,K.jsx)(`h1`,{className:`text-xl font-semibold text-zinc-100`,children:t(`spoolbuddy.settings.scaleCalibration`,`Scale Calibration`)})]}),(0,K.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:i?(0,K.jsx)(n$e,{device:i,weight:e.weight,weightStable:e.weightStable,rawAdc:e.rawAdc}):(0,K.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,K.jsx)(`div`,{className:`text-center text-zinc-500`,children:(0,K.jsx)(`p`,{className:`text-sm`,children:t(`spoolbuddy.settings.noDevice`,`No SpoolBuddy device found`)})})})})]})}var i$e=[`PLA`,`PETG`,`ABS`,`ASA`,`TPU`,`PA`,`PC`,`PVA`,`HIPS`];function a$e(){let{t:e}=W(),{showToast:t}=Td(),{sbState:n}=nr(),[r,i]=(0,y.useState)(`existing`),[a,o]=(0,y.useState)(null),[s,c]=(0,y.useState)(``),[l,u]=(0,y.useState)(`idle`),[d,f]=(0,y.useState)(``),[p,m]=(0,y.useState)(!1),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(null),{data:b}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),x=b!==void 0,S=b?.spoolman_enabled===`true`&&!!b?.spoolman_url,{data:C=[],refetch:w}=q({queryKey:[S?`spoolman-inventory-spools`:`inventory-spools`,`write-tag`],queryFn:()=>S?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),refetchInterval:1e4,enabled:x}),{data:T=[]}=q({queryKey:[`spoolbuddy-devices`],queryFn:()=>od.getDevices(),refetchInterval:5e3}),{data:E}=q({queryKey:[`settings`],queryFn:Q.getSettings}),D=T[0],O=n.deviceOnline,k=$d(E?.currency||`USD`),A=(0,y.useMemo)(()=>{let e;if(r===`existing`)e=C.filter(e=>!e.tag_uid&&!e.archived_at);else if(r===`replace`)e=C.filter(e=>(e.tag_uid||e.tray_uuid)&&!e.archived_at);else return[];if(s){let t=s.toLowerCase();e=e.filter(e=>e.material?.toLowerCase().includes(t)||e.color_name?.toLowerCase().includes(t)||e.brand?.toLowerCase().includes(t)||e.subtype?.toLowerCase().includes(t))}return e},[C,r,s]),j=(0,y.useCallback)(e=>{let t=e.detail;(t.sak??t.data?.sak)===0&&(g(!0),v(t.tag_uid??t.data?.tag_uid??null))},[]),M=(0,y.useCallback)(e=>{let t=e.detail;g(!0),v(t.tag_uid??t.data?.tag_uid??null)},[]),N=(0,y.useCallback)(()=>{g(!1),v(null)},[]),P=(0,y.useCallback)(t=>{let n=t.detail;(n.spool_id===a?.id||n.data?.spool_id===a?.id)&&(u(`success`),f(e(`spoolbuddy.writeTag.writeSuccess`,`Tag written successfully!`)),w(),setTimeout(()=>{u(`idle`),o(null),f(``)},5e3))},[a,e,w]),F=(0,y.useCallback)(t=>{let n=t.detail;(n.spool_id===a?.id||n.data?.spool_id===a?.id)&&(u(`error`),f(n.message??n.data?.message??e(`spoolbuddy.writeTag.writeFailed`,`Write failed`)))},[a,e]);(0,y.useEffect)(()=>(window.addEventListener(`spoolbuddy-unknown-tag`,j),window.addEventListener(`spoolbuddy-tag-matched`,M),window.addEventListener(`spoolbuddy-tag-removed`,N),window.addEventListener(`spoolbuddy-tag-written`,P),window.addEventListener(`spoolbuddy-tag-write-failed`,F),()=>{window.removeEventListener(`spoolbuddy-unknown-tag`,j),window.removeEventListener(`spoolbuddy-tag-matched`,M),window.removeEventListener(`spoolbuddy-tag-removed`,N),window.removeEventListener(`spoolbuddy-tag-written`,P),window.removeEventListener(`spoolbuddy-tag-write-failed`,F)}),[j,M,N,P,F]),(0,y.useEffect)(()=>{o(null),u(`idle`),f(``),c(``)},[r]);let I=async()=>{if(!(!a||!D)){u(`writing`),f(e(`spoolbuddy.writeTag.waiting`,`Waiting for SpoolBuddy...`));try{let e=await od.writeTag(D.device_id,a.id);if(e?.warnings?.length)for(let n of e.warnings)t(n,`warning`)}catch{u(`error`),f(e(`spoolbuddy.writeTag.queueFailed`,`Failed to queue write command`))}}},L=async()=>{if(D){try{await od.cancelWrite(D.device_id)}catch{}u(`idle`),f(``)}},R=async()=>{if(!(!a||!o$e(a))){m(!0),u(`idle`),f(``);try{S?await Q.linkTagToSpoolmanSpool(a.id,{tag_uid:``,tray_uuid:``}):await Q.linkTagToSpool(a.id,{tag_uid:``,tray_uuid:``,data_origin:`manual`}),await w(),o(null),u(`success`),f(e(`spoolbuddy.writeTag.untagSuccess`,`Tag removed from spool`)),setTimeout(()=>{u(`idle`),f(``)},2500)}catch{u(`error`),f(e(`spoolbuddy.writeTag.untagFailed`,`Failed to remove tag from spool`))}finally{m(!1)}}},z=(0,y.useCallback)(e=>{o(e),u(`idle`),f(``),w()},[w]),B=a&&O&&l!==`writing`&&l!==`success`;return(0,K.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,K.jsx)(`div`,{className:`flex border-b border-bambu-dark-tertiary shrink-0`,children:[{key:`existing`,label:e(`spoolbuddy.writeTag.tabExisting`,`Existing Spool`)},{key:`new`,label:e(`spoolbuddy.writeTag.tabNew`,`New Spool`)},{key:`replace`,label:e(`spoolbuddy.writeTag.tabReplace`,`Replace Tag`)}].map(e=>(0,K.jsx)(`button`,{onClick:()=>i(e.key),className:`flex-1 py-3 text-sm font-medium transition-colors ${r===e.key?`text-bambu-green border-b-2 border-bambu-green bg-bambu-dark`:`text-zinc-400 hover:text-zinc-200 hover:bg-bambu-dark-tertiary`}`,children:e.label},e.key))}),(0,K.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,K.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden border-r border-bambu-dark-tertiary`,children:r===`new`?(0,K.jsx)(c$e,{currencySymbol:k,onCreated:z,selectedSpool:a,spoolmanMode:S,t:e}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`p-3 shrink-0`,children:(0,K.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:e(`spoolbuddy.writeTag.searchPlaceholder`,`Search by material, color, brand...`),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 pb-3 space-y-2`,children:A.length===0?(0,K.jsx)(`div`,{className:`text-center text-zinc-500 py-8 text-sm`,children:r===`existing`?e(`spoolbuddy.writeTag.noUntaggedSpools`,`No spools without tags`):e(`spoolbuddy.writeTag.noTaggedSpools`,`No spools with tags`)}):A.map(e=>(0,K.jsx)(s$e,{spool:e,selected:a?.id===e.id,showTag:r===`replace`,onClick:()=>{o(e),u(`idle`),f(``)}},e.id))})]})}),(0,K.jsx)(`div`,{className:`w-[340px] flex flex-col items-center justify-center p-6 shrink-0`,children:(0,K.jsx)(l$e,{writeStatus:l,writeMessage:d,selectedSpool:a,tagOnReader:h,tagUid:_,deviceOnline:O,canWrite:!!B,isReplace:r===`replace`,canUntag:r===`replace`&&!!a&&o$e(a),untagging:p,onWrite:I,onUntag:R,onCancel:L,onRetry:()=>{u(`idle`),f(``)},t:e})})]})]})}function o$e(e){return!!(e.tag_uid||e.tray_uuid)}function s$e({spool:e,selected:t,showTag:n,onClick:r}){let i=Math.max(0,e.label_weight-e.weight_used),a=e.label_weight>0?Math.round(i/e.label_weight*100):0;return(0,K.jsxs)(`button`,{onClick:r,className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${t?`bg-bambu-green/15 border border-bambu-green/50`:`bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary border border-transparent`}`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full shrink-0 border border-white/10`,style:e.rgba?Jd(e.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-sm font-medium text-white truncate`,children:[e.brand?`${e.brand} `:``,e.material,e.subtype?` ${e.subtype}`:``]}),(0,K.jsxs)(`span`,{className:`text-[10px] font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-zinc-400`,children:[e.color_name&&(0,K.jsx)(`span`,{children:e.color_name}),(0,K.jsxs)(`span`,{children:[i,`g / `,e.label_weight,`g (`,a,`%)`]})]}),n&&e.tag_uid&&(0,K.jsx)(`div`,{className:`text-xs text-zinc-500 mt-0.5 font-mono`,children:e.tag_uid})]}),t&&(0,K.jsx)(`svg`,{className:`w-5 h-5 text-bambu-green shrink-0`,fill:`currentColor`,viewBox:`0 0 20 20`,children:(0,K.jsx)(`path`,{fillRule:`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,clipRule:`evenodd`})})]})}function c$e({currencySymbol:e,onCreated:t,selectedSpool:n,spoolmanMode:r,t:i}){let{data:a=[]}=q({queryKey:[r?`spoolman-inventory-spools`:`inventory-spools`,`write-tag-form`],queryFn:()=>r?Q.getSpoolmanInventorySpools(!0):Q.getSpools(!0)}),{data:o}=q({queryKey:[`settings`],queryFn:Q.getSettings}),[s,c]=(0,y.useState)(`simple`),[l,u]=(0,y.useState)(`filament`),[d,f]=(0,y.useState)(p9),[p,m]=(0,y.useState)({}),[h,g]=(0,y.useState)(!1),[_,v]=(0,y.useState)(1),[b,x]=(0,y.useState)(!1),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(!1),[E,D]=(0,y.useState)(!1),[O,k]=(0,y.useState)([]),[A,j]=(0,y.useState)([]),[M,N]=(0,y.useState)([]),[P,F]=(0,y.useState)([]),[I,L]=(0,y.useState)([]),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)([]),[ee,te]=(0,y.useState)([]),[ne,re]=(0,y.useState)(new Set),[ie,H]=(0,y.useState)(new Set);(0,y.useEffect)(()=>{V(NU())},[]),(0,y.useEffect)(()=>{let e=!1;return(async()=>{if(s===`full`){D(!0);try{let[t,n]=await Promise.allSettled([(async()=>(await Q.getCloudStatus()).is_authenticated?{connected:!0,presets:await Q.getFilamentPresets()}:{connected:!1,presets:[]})(),(async()=>(await Q.orcaCloudStatus()).connected?{connected:!0,presets:(await Q.orcaCloudListProfiles()).filament}:{connected:!1,presets:[]})()]);if(e)return;let r=t.status===`fulfilled`&&t.value.connected,i=n.status===`fulfilled`&&n.value.connected,a=t.status===`fulfilled`?t.value.presets:[],o=n.status===`fulfilled`?n.value.presets:[];T(r||i),k([...a,...o])}catch{e||T(!1)}finally{e||D(!1)}Q.getSpoolCatalog().then(t=>{e||F(t)}).catch(()=>void 0),Q.getColorCatalog().then(t=>{e||L(t)}).catch(()=>void 0),Q.getLocalPresets().then(t=>{e||j(t.filament)}).catch(()=>void 0),Q.getBuiltinFilaments().then(t=>{e||N(t)}).catch(()=>void 0);try{let t=await Q.getPrinters(),n=await Promise.all(t.map(e=>Q.getPrinterStatus(e.id).catch(()=>null))),r=[];for(let e=0;e({cali_idx:e.slot_id,filament_id:e.filament_id,setting_id:e.setting_id||``,name:e.name,k_value:parseFloat(e.k_value)||0,n_coef:parseFloat(e.n_coef)||0,extruder_id:e.extruder_id,nozzle_diameter:e.nozzle_diameter}))}catch{}r.push({printer:{...i,connected:a},calibrations:o})}e||te(r)}catch{}}})(),()=>{e=!0}},[s]),(0,y.useEffect)(()=>{ee.length>0&&H(new Set(ee.map(e=>String(e.printer.id))))},[ee]);let ae=(0,y.useMemo)(()=>jU(O,new Set,A,M),[O,A,M]),oe=(0,y.useMemo)(()=>MU(d.slicer_filament,ae),[d.slicer_filament,ae]),U=(0,y.useMemo)(()=>{let e=AU(O,A),t=I.map(e=>e.manufacturer?.trim()).filter(e=>!!e);return Array.from(new Set([...e,...t])).sort((e,t)=>e.localeCompare(t))},[O,A,I]),se=(0,y.useMemo)(()=>{let e=I.map(e=>e.material?.trim()).filter(e=>!!e);return Array.from(new Set([...CU,...e])).sort((e,t)=>e.localeCompare(t))},[I]),ce=(0,y.useMemo)(()=>{let e=[];for(let t of I){let n=t.manufacturer?.trim(),r=t.material?.trim();n&&r&&e.push({brand:n,material:r})}for(let t of O){let n=kU(t.name);n.brand&&n.material&&e.push({brand:n.brand,material:n.material})}for(let t of A){let n=kU(t.name),r=t.filament_vendor?.trim()||n.brand,i=n.material;r&&i&&e.push({brand:r,material:i})}return e},[O,I,A]),le=(0,y.useMemo)(()=>{let e=new Map;for(let t of ce){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(n)||e.set(n,new Set),e.get(n).add(r)}return e},[ce]),ue=(0,y.useMemo)(()=>{let e=new Map;for(let t of ce){let n=t.brand.toLowerCase(),r=t.material.toLowerCase();e.has(r)||e.set(r,new Set),e.get(r).add(n)}return e},[ce]),de=(0,y.useMemo)(()=>{if(!d.material)return U;let e=d.material.toLowerCase(),t=ue.get(e);return!t||t.size===0?U:U.filter(e=>t.has(e.toLowerCase()))},[U,d.material,ue]),fe=(0,y.useMemo)(()=>{if(!d.brand)return se;let e=d.brand.toLowerCase(),t=le.get(e);return!t||t.size===0?se:se.filter(e=>t.has(e.toLowerCase()))},[se,d.brand,le]),pe=(e,t)=>{f(n=>({...n,[e]:t})),p[e]&&m(t=>({...t,[e]:void 0}))},me=e=>{V(t=>PU(e,t))},he=async e=>{let t=r?Q.saveSpoolmanKProfiles:Q.saveSpoolKProfiles;if(ne.size===0){try{await t(e,[])}catch{}return}let n=[];for(let e of ne){let[t,r,i]=e.split(`:`),a=parseInt(t),o=parseInt(r),s=i===`null`?0:parseInt(i),c=ee.find(e=>e.printer.id===a);if(c){let e=c.calibrations.find(e=>e.cali_idx===o);e&&n.push({printer_id:a,extruder:s,nozzle_diameter:e.nozzle_diameter||`0.4`,k_value:e.k_value,name:e.name||null,cali_idx:e.cali_idx,setting_id:e.setting_id||null})}}n.length>0&&await t(e,n)},ge=async()=>{C(null);let e=m9(d,s===`simple`?!0:h);if(!e.isValid){m(e.errors),u(`filament`);return}let n=oe?.displayName||R||null,a={material:d.material,subtype:d.subtype||null,brand:d.brand||null,color_name:d.color_name||null,rgba:d.rgba||null,extra_colors:d.extra_colors||null,effect_type:d.effect_type||null,label_weight:d.label_weight,core_weight:d.core_weight,core_weight_catalog_id:d.core_weight_catalog_id,weight_used:d.weight_used,slicer_filament:d.slicer_filament||null,slicer_filament_name:n,nozzle_temp_min:null,nozzle_temp_max:null,note:d.note||null,cost_per_kg:d.cost_per_kg,added_full:null,last_used:null,encode_time:null,tag_uid:null,tray_uuid:null,data_origin:null,tag_type:null,last_scale_weight:null,last_weighed_at:null,category:d.category.trim()||null,low_stock_threshold_pct:d.low_stock_threshold_pct};x(!0);try{if(_>1){let e=r?await Q.bulkCreateSpoolmanInventorySpools(a,_):await Q.bulkCreateSpools(a,_),n=r&&e&&typeof e==`object`&&`created`in e?e.created:e;for(let e of n)await he(e.id);n.length>0&&t(n[0])}else{let e=r?await Q.createSpoolmanInventorySpool(a):await Q.createSpool(a);await he(e.id),t(e)}}catch{C(i(`spoolbuddy.writeTag.createFailed`,`Failed to create spool`))}finally{x(!1)}},_e=`#${(d.rgba||`808080FF`).slice(0,6)}`;return(0,K.jsxs)(`div`,{className:`p-3 space-y-3 overflow-y-auto h-full`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-200`,children:i(`spoolbuddy.writeTag.viewMode`,`View`)}),(0,K.jsxs)(`div`,{className:`flex rounded-lg overflow-hidden border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(`simple`),className:`px-3 py-1.5 text-xs font-medium ${s===`simple`?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-zinc-400`}`,children:i(`spoolbuddy.writeTag.simpleView`,`Simple`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>c(`full`),className:`px-3 py-1.5 text-xs font-medium ${s===`full`?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-zinc-400`}`,children:i(`spoolbuddy.writeTag.fullView`,`Full`)})]})]}),s===`simple`?n?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-6 text-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`div`,{className:`w-12 h-12 rounded-full mb-4 border border-white/10`,style:n.rgba?Jd(n.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`p`,{className:`text-white font-medium`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:n.color_name}),(0,K.jsxs)(`p`,{className:`text-zinc-500 text-xs mt-1`,children:[n.label_weight,`g`]}),(0,K.jsx)(`p`,{className:`text-bambu-green text-sm mt-4`,children:i(`spoolbuddy.writeTag.spoolCreated`,`Spool created! Ready to write.`)})]}):(0,K.jsxs)(`div`,{className:`p-4 space-y-4 overflow-y-auto bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.material`,`Material`)}),(0,K.jsx)(`select`,{value:d.material,onChange:e=>pe(`material`,e.target.value),className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`,children:i$e.map(e=>(0,K.jsx)(`option`,{value:e,children:e},e))})]}),(0,K.jsxs)(`div`,{className:`flex gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex-1`,children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.colorName`,`Color Name`)}),(0,K.jsx)(`input`,{type:`text`,value:d.color_name,onChange:e=>pe(`color_name`,e.target.value),placeholder:`Jade White`,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.color`,`Color`)}),(0,K.jsx)(`input`,{type:`color`,value:_e,onChange:e=>pe(`rgba`,e.target.value.replace(`#`,``).toUpperCase()+`FF`),className:`w-10 h-9 bg-transparent border border-bambu-dark-tertiary rounded cursor-pointer`})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.brand`,`Brand`)}),(0,K.jsx)(`input`,{type:`text`,value:d.brand,onChange:e=>pe(`brand`,e.target.value),placeholder:`Polymaker`,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-bambu-green`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`block text-xs text-zinc-400 mb-1`,children:i(`spoolbuddy.writeTag.weight`,`Weight (g)`)}),(0,K.jsx)(`input`,{type:`number`,value:d.label_weight,onChange:e=>pe(`label_weight`,parseInt(e.target.value)||0),min:0,max:1e4,className:`w-full px-3 py-2 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-sm text-white focus:outline-none focus:border-bambu-green`})]}),(0,K.jsx)(`button`,{onClick:ge,disabled:b||!d.material,className:`w-full py-2.5 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded transition-colors`,children:b?i(`spoolbuddy.writeTag.creating`,`Creating...`):i(`spoolbuddy.writeTag.createSpool`,`Create Spool`)})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-2 bg-bambu-dark-secondary rounded-lg border border-bambu-dark-tertiary`,children:[(0,K.jsx)(`span`,{className:`text-sm text-zinc-200`,children:i(`inventory.quickAdd`,`Quick Add`)}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${h?`bg-bambu-green`:`bg-bambu-dark-tertiary`}`,children:(0,K.jsx)(`span`,{className:`inline-block h-4.5 w-4.5 rounded-full bg-white transition-transform ${h?`translate-x-6`:`translate-x-1`}`})})]}),(0,K.jsxs)(`div`,{className:`flex border border-bambu-dark-tertiary rounded-lg overflow-hidden`,children:[(0,K.jsx)(`button`,{onClick:()=>u(`filament`),className:`flex-1 py-2.5 text-sm font-medium ${l===`filament`?`bg-bambu-green/15 text-bambu-green`:`bg-bambu-dark-secondary text-zinc-400`}`,children:i(`inventory.filamentInfoTab`,`Filament`)}),!h&&(0,K.jsx)(`button`,{onClick:()=>u(`pa-profile`),className:`flex-1 py-2.5 text-sm font-medium ${l===`pa-profile`?`bg-bambu-green/15 text-bambu-green`:`bg-bambu-dark-secondary text-zinc-400`}`,children:i(`inventory.paProfileTab`,`PA Profile`)})]}),(0,K.jsx)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg p-3`,children:l===`filament`?(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(h9,{formData:d,updateField:pe,cloudAuthenticated:w,loadingCloudPresets:E,presetInputValue:R,setPresetInputValue:z,selectedPresetOption:oe,filamentOptions:ae,availableBrands:de,availableMaterials:fe,quickAdd:h,quantity:_,onQuantityChange:v,errors:p}),(0,K.jsx)(g9,{formData:d,updateField:pe,recentColors:B,onColorUsed:me,catalogColors:I}),(0,K.jsx)(_9,{formData:d,updateField:pe,spoolCatalog:P,currencySymbol:e,availableCategories:Array.from(new Set(a.map(e=>e.category?.trim()).filter(e=>!!e))).sort((e,t)=>e.localeCompare(t)),globalLowStockThreshold:o?.low_stock_threshold??20})]}):(0,K.jsx)(v9,{formData:d,updateField:pe,printersWithCalibrations:ee,selectedProfiles:ne,setSelectedProfiles:re,expandedPrinters:ie,setExpandedPrinters:H})})]}),S&&(0,K.jsx)(`div`,{className:`text-sm text-red-400 bg-red-900/20 border border-red-900/40 rounded-lg px-3 py-2`,children:S}),s===`full`&&(0,K.jsx)(`button`,{onClick:ge,disabled:b,className:`w-full py-3 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-50 disabled:cursor-not-allowed text-white text-sm font-medium rounded transition-colors`,children:b?i(`spoolbuddy.writeTag.creating`,`Creating...`):i(`spoolbuddy.writeTag.createSpool`,`Create Spool`)}),s===`full`&&n&&(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-4 text-center bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg`,children:[(0,K.jsx)(`div`,{className:`w-12 h-12 rounded-full mb-4 border border-white/10`,style:n.rgba?Jd(n.rgba):{backgroundColor:`#666`}}),(0,K.jsxs)(`p`,{className:`text-white font-medium`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:n.color_name}),(0,K.jsxs)(`p`,{className:`text-zinc-500 text-xs mt-1`,children:[n.label_weight,`g`]}),(0,K.jsx)(`p`,{className:`text-bambu-green text-sm mt-4`,children:i(`spoolbuddy.writeTag.spoolCreated`,`Spool created! Ready to write.`)})]})]})}function l$e({writeStatus:e,writeMessage:t,selectedSpool:n,tagOnReader:r,tagUid:i,deviceOnline:a,canWrite:o,isReplace:s,canUntag:c,untagging:l,onWrite:u,onUntag:d,onCancel:f,onRetry:p,t:m}){if(e===`success`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-green-500/20 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-8 h-8 text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})})}),(0,K.jsx)(`p`,{className:`text-green-400 font-medium`,children:t}),n&&(0,K.jsxs)(`p`,{className:`text-zinc-400 text-sm`,children:[n.brand?`${n.brand} `:``,n.material,n.color_name?` - ${n.color_name}`:``]})]});if(e===`error`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsx)(`div`,{className:`w-16 h-16 rounded-full bg-red-500/20 flex items-center justify-center`,children:(0,K.jsx)(`svg`,{className:`w-8 h-8 text-red-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})}),(0,K.jsx)(`p`,{className:`text-red-400 font-medium`,children:t}),(0,K.jsx)(`button`,{onClick:p,className:`px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-white text-sm rounded transition-colors`,children:m(`spoolbuddy.writeTag.tryAgain`,`Try Again`)})]});if(e===`writing`)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4`,children:[(0,K.jsxs)(`div`,{className:`relative w-16 h-16`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-bambu-green/30 animate-ping`}),(0,K.jsx)(`div`,{className:`absolute inset-2 rounded-full border-2 border-bambu-green/50 animate-pulse`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-bambu-green`})})]}),(0,K.jsx)(`p`,{className:`text-bambu-green font-medium`,children:m(`spoolbuddy.writeTag.writing`,`Writing tag...`)}),(0,K.jsx)(`p`,{className:`text-zinc-500 text-xs`,children:t}),(0,K.jsx)(`button`,{onClick:f,className:`px-4 py-2 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary text-zinc-400 text-sm rounded transition-colors`,children:m(`spoolbuddy.writeTag.cancel`,`Cancel`)})]});if(!a)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-3`,children:[(0,K.jsx)(Z9,{className:`w-12 h-12 text-zinc-600`}),(0,K.jsx)(`p`,{className:`text-zinc-500 text-sm`,children:m(`spoolbuddy.writeTag.deviceOffline`,`SpoolBuddy is offline`)})]});if(!n)return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-3`,children:[(0,K.jsx)(Z9,{className:`w-12 h-12 text-zinc-600`}),(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:m(`spoolbuddy.writeTag.selectSpool`,`Select a spool, then place a blank NTAG on the reader`)})]});let h=n.rgba?Jd(n.rgba):{backgroundColor:`#666`};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center text-center space-y-4 w-full`,children:[(0,K.jsx)(`div`,{className:`relative w-16 h-16`,children:r?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full bg-bambu-green/10`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-bambu-green`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`absolute inset-0 rounded-full border-2 border-zinc-600 animate-pulse`}),(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,K.jsx)(Z9,{className:`w-8 h-8 text-zinc-500`})})]})}),r?(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-bambu-green text-sm font-medium`,children:m(`spoolbuddy.writeTag.tagReady`,`Tag detected — ready to write`)}),i&&(0,K.jsx)(`p`,{className:`text-zinc-500 text-xs font-mono`,children:i})]}):(0,K.jsx)(`p`,{className:`text-zinc-400 text-sm`,children:m(`spoolbuddy.writeTag.placeTag`,`Place an NTAG on the reader`)}),(0,K.jsxs)(`div`,{className:`w-full bg-bambu-dark-secondary rounded-lg p-3 space-y-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`div`,{className:`w-8 h-8 rounded-full border border-white/10 shrink-0`,style:h}),(0,K.jsxs)(`div`,{className:`text-left min-w-0`,children:[(0,K.jsxs)(`p`,{className:`text-white text-sm font-medium truncate`,children:[n.brand?`${n.brand} `:``,n.material]}),n.color_name&&(0,K.jsx)(`p`,{className:`text-zinc-400 text-xs`,children:n.color_name})]})]}),(0,K.jsxs)(`div`,{className:`text-xs text-zinc-500`,children:[n.label_weight,`g`]})]}),s&&n.tag_uid&&(0,K.jsx)(`p`,{className:`text-yellow-500/80 text-xs`,children:m(`spoolbuddy.writeTag.replaceWarning`,`Old tag will be unlinked. New tag will replace it.`)}),(0,K.jsx)(`button`,{onClick:u,disabled:!o,className:`w-full py-3 bg-bambu-green hover:bg-bambu-green/80 disabled:opacity-40 disabled:cursor-not-allowed text-white font-medium rounded-lg transition-colors text-sm`,children:s?m(`spoolbuddy.writeTag.replaceTag`,`Replace Tag`):m(`spoolbuddy.writeTag.writeTag`,`Write Tag`)}),s&&c&&(0,K.jsx)(`button`,{onClick:d,disabled:l,className:`w-full py-2.5 bg-bambu-dark-tertiary hover:bg-bambu-dark-secondary disabled:opacity-40 disabled:cursor-not-allowed text-zinc-200 rounded-lg transition-colors text-sm`,children:l?m(`spoolbuddy.writeTag.untagging`,`Removing tag...`):m(`spoolbuddy.writeTag.untagSpool`,`Untag Selected Spool`)})]})}function Z9({className:e}){return(0,K.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0`}),(0,K.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z`})]})}var u$e=`spoolbuddy-default-core-weight`;function d$e(){try{let e=localStorage.getItem(u$e);if(e){let t=parseInt(e,10);if(t>=0&&t<=500)return t}}catch{}return 250}function f$e({spool:e,liveScaleWeight:t,persistedGrossWeight:n,onClose:r,onSyncWeight:i,onAssignToAms:a,isAssigned:o,onUnassignFromAms:s,className:c}){let{t:l}=W(),[u,d]=(0,y.useState)(!1),[f,p]=(0,y.useState)(!1),[m,h]=(0,y.useState)(null),{data:g}=q({queryKey:[`spool-k-profiles`,e.id],queryFn:()=>Q.getSpoolKProfiles(e.id),enabled:!e.k_profiles||e.k_profiles.length===0,staleTime:300*1e3}),_=e.k_profiles&&e.k_profiles.length>0?e.k_profiles:g,v=qd(e.rgba),b=e.core_weight&&e.core_weight>0?e.core_weight:d$e(),x=t===null?null:Math.round(Math.max(0,t)),S=m??(n===void 0?x:n===null?null:Math.round(Math.max(0,n))),C=Math.round(Math.max(0,(e.label_weight||0)-(e.weight_used||0))),w=x!==null&&x>=10?Math.round(Math.max(0,x-b)):C,T=Math.round(e.label_weight||1e3),E=T>0?Math.min(100,Math.round(w/T*100)):null,D=E===null?`#808080`:E>50?`#22c55e`:E>20?`#eab308`:`#ef4444`,O=Math.max(0,(e.label_weight||0)-(e.weight_used||0))+b,k=x===null?null:x-O,A=k===null?null:Math.abs(k)<=50,j=S??Math.round(O),M=e.nozzle_temp_min!=null&&e.nozzle_temp_max!=null?`${e.nozzle_temp_min}-${e.nozzle_temp_max}\u00B0C`:null,N=e.slicer_filament_name||e.slicer_filament||null,P=e.note?.trim()||null,F=_&&_.length>0?Array.from(new Set(_.map(e=>e.k_value.toFixed(3)))).join(`, `):null,I=async()=>{if(t===null)return;let n=Math.round(Math.max(0,t));d(!0);try{await od.updateSpoolWeight(e.id,n),h(n),p(!0),i?.(),setTimeout(()=>p(!1),3e3)}catch(e){console.error(`Failed to sync weight:`,e)}finally{d(!1)}};return(0,K.jsxs)(`div`,{className:`flex flex-col items-center space-y-4 max-w-md ${c??``}`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-5`,children:[(0,K.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,K.jsx)(G9,{color:v,isEmpty:!1,size:100}),E!==null&&(0,K.jsxs)(`div`,{className:`absolute -bottom-2 -right-2 px-2 py-0.5 rounded-full text-xs font-bold text-white shadow-lg`,style:{backgroundColor:D},children:[E,`%`]})]}),(0,K.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`h3`,{className:`text-lg font-semibold text-zinc-100`,children:e.color_name||`Unknown color`}),(0,K.jsxs)(`span`,{className:`text-xs font-mono text-zinc-500 shrink-0`,children:[`#`,e.id]})]}),(0,K.jsxs)(`p`,{className:`text-sm text-zinc-400`,children:[e.brand,` • `,e.material,e.subtype&&` ${e.subtype}`]}),(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,K.jsxs)(`span`,{className:`text-3xl font-bold font-mono text-zinc-100`,children:[w,`g`]}),(0,K.jsxs)(`span`,{className:`text-sm text-zinc-500`,children:[`/ `,T,`g`]})]}),(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mt-0.5`,children:l(`spoolbuddy.spool.remaining`,`Remaining`)}),(0,K.jsx)(`div`,{className:`mt-2 max-w-xs`,children:(0,K.jsx)(`div`,{className:`h-2 bg-zinc-700 rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${E??0}%`,backgroundColor:D}})})})]})]})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-6 gap-y-2 text-sm bg-zinc-800 rounded-lg p-4 w-full`,children:[(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.grossWeight`,`Gross weight`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[j,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.spool.coreWeight`,`Core`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[b,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.spoolSize`,`Spool size`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[T,`g`]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.spool.scaleWeight`,`Scale`)}),x===null?(0,K.jsx)(`span`,{className:`text-zinc-500`,children:`—`}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 font-mono ${A?`text-green-500`:`text-yellow-500`}`,children:[x,`g`,A?(0,K.jsx)(rs,{className:`w-3.5 h-3.5`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cu,{className:`w-3.5 h-3.5`}),(0,K.jsx)(`button`,{onClick:I,className:`p-1 hover:bg-green-500/20 rounded transition-colors text-green-500`,title:l(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`),children:(0,K.jsx)(Ol,{className:`w-4 h-4`})})]})]})]}),(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.dashboard.tagId`,`Tag`)}),(0,K.jsx)(`span`,{className:`font-mono text-xs text-zinc-400 truncate max-w-[120px]`,title:e.tag_uid||``,children:e.tag_uid?e.tag_uid.slice(-8):`—`})]}),M&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.nozzleTemp`,`Nozzle`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300`,children:M})]}),e.cost_per_kg!=null&&e.cost_per_kg>0&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.costPerKg`,`Cost/kg`)}),(0,K.jsxs)(`span`,{className:`font-mono text-zinc-300`,children:[e.cost_per_kg.toFixed(2),`/kg`]})]}),F&&(0,K.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,K.jsx)(`span`,{className:`text-zinc-500`,children:l(`spoolbuddy.inventory.kProfiles`,`K-Profile`)}),(0,K.jsx)(`span`,{className:`font-mono text-zinc-300 truncate max-w-[220px] text-right`,title:F,children:F})]}),N&&(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-1`,children:l(`spoolbuddy.inventory.slicerFilament`,`Slicer Filament`)}),(0,K.jsx)(`p`,{className:`text-sm text-zinc-300 whitespace-pre-wrap break-words`,children:N})]}),P&&(0,K.jsxs)(`div`,{className:`col-span-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-zinc-500 mb-1`,children:l(`spoolbuddy.inventory.note`,`Note`)}),(0,K.jsx)(`p`,{className:`text-sm leading-5 text-zinc-300 whitespace-pre-wrap break-words max-h-[3.75rem] overflow-y-auto pr-1`,children:P})]})]}),(0,K.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[a&&(0,K.jsx)(`button`,{onClick:o?void 0:a,disabled:!!o,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-green-600 text-white hover:bg-green-700 transition-colors min-h-[44px] disabled:opacity-50 disabled:cursor-not-allowed`,children:l(`spoolbuddy.modal.assignToAms`,`Assign to AMS`)}),s&&(0,K.jsxs)(`button`,{onClick:s,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-red-600/20 text-red-400 hover:bg-red-600/30 transition-colors min-h-[44px]`,children:[(0,K.jsx)(Eu,{className:`w-4 h-4 inline mr-1`}),l(`inventory.unassignSpool`)]}),(0,K.jsx)(`button`,{onClick:I,disabled:t===null||u,className:`px-5 py-2.5 rounded-lg text-sm font-medium transition-colors min-h-[44px] ${f?`bg-green-600/20 text-green-400`:a?`bg-zinc-700 text-zinc-300 hover:bg-zinc-600 disabled:opacity-40 disabled:cursor-not-allowed`:`bg-green-600 text-white hover:bg-green-700 disabled:opacity-40 disabled:cursor-not-allowed`}`,children:u?`...`:f?l(`spoolbuddy.dashboard.weightSynced`,`Synced!`):l(`spoolbuddy.dashboard.syncWeight`,`Sync Weight`)}),r&&(0,K.jsx)(`button`,{onClick:r,className:`px-5 py-2.5 rounded-lg text-sm font-medium bg-zinc-700 text-zinc-300 hover:bg-zinc-600 transition-colors min-h-[44px]`,children:l(`spoolbuddy.dashboard.close`,`Close`)})]})]})}function p$e(e){return qd(e.rgba)}function m$e(e){return Math.max(0,e.label_weight-e.weight_used)}function h$e(e){return e.label_weight<=0?0:Math.max(0,Math.min(100,(e.label_weight-e.weight_used)/e.label_weight*100))}function g$e(e){let t=[e.material];return e.subtype&&t.push(e.subtype),t.join(` `)}function _$e(e){let t=e.ams_id===254||e.ams_id===255,n=!t&&e.ams_id>=128;return If(e.ams_id,e.tray_id,n,t)}function v$e({color:e,size:t=56}){return(0,K.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 56 56`,children:[(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`26`,fill:e}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`20`,fill:e,style:{filter:`brightness(0.85)`}}),(0,K.jsx)(`ellipse`,{cx:`20`,cy:`20`,rx:`6`,ry:`4`,fill:`white`,opacity:`0.3`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`8`,fill:`#2d2d2d`}),(0,K.jsx)(`circle`,{cx:`28`,cy:`28`,r:`5`,fill:`#1a1a1a`})]})}function y$e(){let{sbState:e,selectedPrinterId:t}=nr(),{t:n}=W(),{showToast:r}=Td(),i=no(),[a,o]=(0,y.useState)(``),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(null),[d,f]=(0,y.useState)(!1),{data:p}=q({queryKey:[`spoolman-settings`],queryFn:Q.getSpoolmanSettings,staleTime:300*1e3}),m=p?.spoolman_enabled===`true`&&!!p?.spoolman_url,{data:h=[],isLoading:g,refetch:_}=q({queryKey:m?[`spoolman-inventory-spools`]:[`inventory-spools`],queryFn:()=>m?Q.getSpoolmanInventorySpools(!1):Q.getSpools(!1),enabled:p!==void 0,refetchInterval:3e4}),{data:v=[]}=q({queryKey:[`spool-assignments`],queryFn:()=>Q.getAssignments(),refetchInterval:3e4,enabled:!m}),{data:b=[]}=q({queryKey:[`spoolman-slot-assignments`],queryFn:()=>Q.getSpoolmanSlotAssignments(),refetchInterval:3e4,enabled:m}),x=J({mutationFn:e=>Q.unassignSpoolmanSlot(e),onSuccess:()=>{i.invalidateQueries({queryKey:[`spoolman-slot-assignments`]}),i.invalidateQueries({queryKey:[`spoolman-inventory-spools`]})},onError:()=>r(n(`inventory.unassignFailed`,`Failed to unassign spool`),`error`)}),S=(0,y.useMemo)(()=>{if(m){let e={};return b.forEach(t=>{e[t.spoolman_spool_id]={ams_id:t.ams_id,tray_id:t.tray_id}}),e}let e={};return v.forEach(t=>{e[t.spool_id]={ams_id:t.ams_id,tray_id:t.tray_id,printer_name:t.printer_name}}),e},[m,v,b]),C=(0,y.useMemo)(()=>h.filter(e=>!e.archived_at),[h]),w=(0,y.useMemo)(()=>new Set(Object.keys(S).map(Number)),[S]),T=(0,y.useMemo)(()=>C.filter(e=>w.has(e.id)).length,[C,w]),E=(0,y.useMemo)(()=>{let e=new Set;return C.forEach(t=>e.add(t.material)),Array.from(e).sort()},[C]),D=(0,y.useMemo)(()=>{let e=C;return s===`in_ams`?e=e.filter(e=>w.has(e.id)):s!==`all`&&(e=e.filter(e=>e.material===s)),e=hU(e,a.trim()),[...e].sort((e,t)=>{let n=+!w.has(e.id),r=+!w.has(t.id);return n===r?new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime():n-r})},[C,s,a,w]);return(0,K.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,K.jsxs)(`div`,{className:`px-3 pt-3 pb-2 space-y-2.5`,children:[(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Rl,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-white/40`}),(0,K.jsx)(`input`,{type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:n(`spoolbuddy.inventory.searchPlaceholder`,`Search spools...`),className:`w-full pl-9 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-sm text-white placeholder-white/30 focus:outline-none focus:border-bambu-green`}),a&&(0,K.jsx)(`button`,{onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/60`,children:(0,K.jsx)(Ru,{className:`w-4 h-4`})})]}),(0,K.jsxs)(`div`,{className:`flex gap-1.5 overflow-x-auto no-scrollbar`,children:[(0,K.jsx)(Q9,{active:s===`all`,onClick:()=>c(`all`),label:`${n(`spoolbuddy.inventory.all`,`All`)} (${C.length})`,green:!0}),T>0&&(0,K.jsx)(Q9,{active:s===`in_ams`,onClick:()=>c(`in_ams`),label:`${n(`spoolbuddy.inventory.inAms`,`In AMS`)} (${T})`}),E.map(e=>(0,K.jsx)(Q9,{active:s===e,onClick:()=>c(s===e?`all`:e),label:e},e))]})]}),(0,K.jsx)(`div`,{className:`flex-1 overflow-y-auto px-3 pb-3`,children:g?(0,K.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,K.jsx)(`div`,{className:`w-8 h-8 border-2 border-bambu-green border-t-transparent rounded-full animate-spin`})}):D.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 text-white/30`,children:[(0,K.jsx)(pl,{className:`w-12 h-12 mb-3`}),(0,K.jsx)(`p`,{className:`text-sm`,children:a||s!==`all`?n(`spoolbuddy.inventory.noResults`,`No spools match your filters`):n(`spoolbuddy.inventory.empty`,`No spools in inventory`)})]}):(0,K.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(130px,1fr))] gap-2`,children:D.map(e=>(0,K.jsx)(b$e,{spool:e,assignment:S[e.id],onClick:()=>u(e.id)},e.id))})}),l!=null&&(()=>{let n=h.find(e=>e.id===l);return n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(x$e,{spool:n,assignment:S[n.id],sbState:e,onSyncWeight:()=>{_()},onAssignToAms:()=>f(!0),onUnassignFromAms:m&&S[n.id]?()=>x.mutate(n.id):void 0,onClose:()=>{u(null),f(!1)}}),(0,K.jsx)(jQe,{isOpen:d,onClose:()=>f(!1),spool:n,printerId:t,spoolmanMode:m})]}):null})()]})}function Q9({active:e,onClick:t,label:n,green:r}){return(0,K.jsx)(`button`,{onClick:t,className:`px-4 py-1.5 rounded-full text-sm font-medium border whitespace-nowrap shrink-0 transition-colors ${e?r?`bg-bambu-green/20 text-bambu-green border-bambu-green/50`:`bg-white/10 text-white border-white/20`:`bg-transparent text-white/40 border-bambu-dark-tertiary hover:text-white/60`}`,children:n})}function b$e({spool:e,assignment:t,onClick:n}){let r=p$e(e),i=h$e(e),a=m$e(e),o=Kd(e.color_name,e.rgba);return(0,K.jsxs)(`button`,{onClick:n,className:`bg-bambu-dark-secondary rounded-xl p-3 flex flex-col items-center text-center gap-1.5 border border-transparent hover:border-bambu-green/50 transition-colors`,children:[(0,K.jsx)(v$e,{color:r,size:56}),(0,K.jsx)(`p`,{className:`text-xs font-semibold text-white leading-tight truncate w-full`,children:g$e(e)}),(0,K.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 max-w-full`,children:[(0,K.jsx)(`span`,{className:`w-2.5 h-2.5 rounded-full shrink-0 border border-white/10`,style:Jd(e.rgba)}),(0,K.jsx)(`span`,{className:`text-[11px] text-white/50 truncate`,children:o||`-`})]}),(0,K.jsxs)(`div`,{className:`w-full space-y-0.5`,children:[(0,K.jsx)(`div`,{className:`h-1.5 bg-bambu-dark-tertiary rounded-full overflow-hidden`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full ${i>50?`bg-bambu-green`:i>20?`bg-yellow-500`:`bg-red-500`}`,style:{width:`${Math.min(i,100)}%`}})}),(0,K.jsxs)(`p`,{className:`text-[11px] text-white/40`,children:[Math.round(a),`g (`,Math.round(i),`%)`]})]}),t&&(0,K.jsx)(`span`,{className:`px-2 py-0.5 rounded text-[10px] font-bold bg-bambu-green/20 text-bambu-green`,children:_$e(t)})]})}function x$e({spool:e,assignment:t,sbState:n,onSyncWeight:r,onAssignToAms:i,onUnassignFromAms:a,onClose:o}){let s=n.deviceOnline&&n.weight!==null?Math.round(n.weight):null,c=e.last_scale_weight==null?null:Math.round(e.last_scale_weight);return(0,K.jsx)(`div`,{className:`fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4`,onClick:o,children:(0,K.jsx)(`div`,{className:`w-full max-w-md bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-2xl p-4 overflow-y-auto max-h-[90vh]`,onClick:e=>e.stopPropagation(),children:(0,K.jsxs)(`div`,{className:`space-y-3`,children:[t&&(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-1 rounded-md text-xs font-bold bg-bambu-green/20 text-bambu-green`,children:_$e(t)}),t.printer_name&&(0,K.jsx)(`span`,{className:`text-xs text-zinc-400`,children:t.printer_name})]}),(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(f$e,{spool:e,liveScaleWeight:s,persistedGrossWeight:c,onSyncWeight:r,onAssignToAms:i,isAssigned:!!t,onUnassignFromAms:a,onClose:o,className:`max-w-md`})})]})})})}var S$e=class extends y.Component{state={error:null,errorInfo:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.setState({errorInfo:t}),console.error(`React crash:`,e,t)}render(){return this.state.error?(0,K.jsxs)(`div`,{style:{padding:24,color:`#ef4444`,backgroundColor:`#18181b`,minHeight:`100vh`,fontFamily:`monospace`},children:[(0,K.jsx)(`h1`,{style:{fontSize:20,marginBottom:12},children:`UI Crash`}),(0,K.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,fontSize:14},children:this.state.error.message}),(0,K.jsx)(`pre`,{style:{whiteSpace:`pre-wrap`,fontSize:12,color:`#a1a1aa`,marginTop:12},children:this.state.error.stack}),(0,K.jsx)(`button`,{onClick:()=>{this.setState({error:null,errorInfo:null})},style:{marginTop:16,padding:`8px 16px`,backgroundColor:`#3b82f6`,color:`#fff`,border:`none`,borderRadius:8,cursor:`pointer`},children:`Retry`})]}):this.props.children}},C$e=new $a({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function w$e(){return r9(),null}function T$e({children:e}){return XZe(),(0,K.jsx)(K.Fragment,{children:e})}function E$e({children:e}){let{authEnabled:t,loading:n,user:r}=dd(),i=Xn();return n?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):t&&!r?(0,K.jsx)(Or,{to:`/login`,replace:!0,state:{from:i}}):(0,K.jsx)(K.Fragment,{children:e})}function $9({permission:e,children:t}){let{authEnabled:n,loading:r,user:i,hasPermission:a}=dd(),o=Xn();return r?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):n?i?a(e)?(0,K.jsx)(K.Fragment,{children:t}):(0,K.jsx)(Or,{to:`/`,replace:!0}):(0,K.jsx)(Or,{to:`/login`,replace:!0,state:{from:o}}):(0,K.jsx)(K.Fragment,{children:t})}function D$e({children:e}){let{authEnabled:t,loading:n}=dd();return n?(0,K.jsx)(`div`,{className:`min-h-screen flex items-center justify-center`,children:`Loading...`}):t?(0,K.jsx)(Or,{to:`/login`,replace:!0}):(0,K.jsx)(K.Fragment,{children:e})}function O$e(){return(0,K.jsx)(S$e,{children:(0,K.jsx)(Od,{children:(0,K.jsx)(ro,{client:C$e,children:(0,K.jsx)(ud,{children:(0,K.jsx)(pd,{children:(0,K.jsx)(ZZe,{children:(0,K.jsxs)(Yke,{children:[(0,K.jsx)(w$e,{}),(0,K.jsx)(xi,{children:(0,K.jsxs)(Mr,{children:[(0,K.jsx)(Ar,{path:`/setup`,element:(0,K.jsx)(D$e,{children:(0,K.jsx)(qZe,{})})}),(0,K.jsx)(Ar,{path:`/login`,element:(0,K.jsx)(KZe,{})}),(0,K.jsx)(Ar,{path:`/camera/:printerId`,element:(0,K.jsx)(DXe,{})}),(0,K.jsx)(Ar,{path:`/overlay/:printerId`,element:(0,K.jsx)(MXe,{})}),(0,K.jsxs)(Ar,{element:(0,K.jsx)(E$e,{children:(0,K.jsx)(T$e,{children:(0,K.jsx)(lQe,{})})}),children:[(0,K.jsx)(Ar,{path:`spoolbuddy`,element:(0,K.jsx)(RQe,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/ams`,element:(0,K.jsx)(HQe,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/write-tag`,element:(0,K.jsx)(a$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/inventory`,element:(0,K.jsx)(y$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/settings`,element:(0,K.jsx)(t$e,{})}),(0,K.jsx)(Ar,{path:`spoolbuddy/calibration`,element:(0,K.jsx)(r$e,{})})]}),(0,K.jsxs)(Ar,{element:(0,K.jsx)(E$e,{children:(0,K.jsx)(T$e,{children:(0,K.jsx)(Dp,{})})}),children:[(0,K.jsx)(Ar,{index:!0,element:(0,K.jsx)(Wke,{})}),(0,K.jsx)(Ar,{path:`archives`,element:(0,K.jsx)(hze,{})}),(0,K.jsx)(Ar,{path:`queue`,element:(0,K.jsx)(mVe,{})}),(0,K.jsx)(Ar,{path:`stats`,element:(0,K.jsx)(NVe,{})}),(0,K.jsx)(Ar,{path:`profiles`,element:(0,K.jsx)(wUe,{})}),(0,K.jsx)(Ar,{path:`maintenance`,element:(0,K.jsx)(kUe,{})}),(0,K.jsx)(Ar,{path:`projects`,element:(0,K.jsx)(MUe,{})}),(0,K.jsx)(Ar,{path:`projects/:id`,element:(0,K.jsx)(RUe,{})}),(0,K.jsx)(Ar,{path:`inventory`,element:(0,K.jsx)(CZe,{})}),(0,K.jsx)(Ar,{path:`files`,element:(0,K.jsx)(bXe,{})}),(0,K.jsx)(Ar,{path:`files/trash`,element:(0,K.jsx)(SXe,{})}),(0,K.jsx)(Ar,{path:`makerworld`,element:(0,K.jsx)($9,{permission:`makerworld:view`,children:(0,K.jsx)(FZe,{})})}),(0,K.jsx)(Ar,{path:`settings`,element:(0,K.jsx)($9,{permission:`settings:read`,children:(0,K.jsx)(tUe,{})})}),(0,K.jsx)(Ar,{path:`groups/new`,element:(0,K.jsx)($9,{permission:`groups:create`,children:(0,K.jsx)(a9,{})})}),(0,K.jsx)(Ar,{path:`groups/:id/edit`,element:(0,K.jsx)($9,{permission:`groups:update`,children:(0,K.jsx)(a9,{})})}),(0,K.jsx)(Ar,{path:`users`,element:(0,K.jsx)(Or,{to:`/settings?tab=users`,replace:!0})}),(0,K.jsx)(Ar,{path:`groups`,element:(0,K.jsx)(Or,{to:`/settings?tab=users`,replace:!0})}),(0,K.jsx)(Ar,{path:`system`,element:(0,K.jsx)(VZe,{})}),(0,K.jsx)(Ar,{path:`notifications`,element:(0,K.jsx)(JZe,{})}),(0,K.jsx)(Ar,{path:`gcode-viewer`,element:(0,K.jsx)(YZe,{})}),(0,K.jsx)(Ar,{path:`external/:id`,element:(0,K.jsx)(NXe,{})}),(0,K.jsx)(Ar,{path:`camera-tokens`,element:(0,K.jsx)(Or,{to:`/settings?tab=apikeys#card-camera-tokens`,replace:!0})})]})]})})]})})})})})})})}(0,b.createRoot)(document.getElementById(`root`)).render((0,K.jsx)(y.StrictMode,{children:(0,K.jsx)(O$e,{})})); \ No newline at end of file diff --git a/static/assets/index-CfaUjcJN.css b/static/assets/index-CfaUjcJN.css new file mode 100644 index 000000000..f185bbd18 --- /dev/null +++ b/static/assets/index-CfaUjcJN.css @@ -0,0 +1,2 @@ +/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-100:oklch(95.4% .038 75.164);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-400:oklch(84.1% .238 128.85);--color-lime-500:oklch(76.8% .233 130.85);--color-green-50:oklch(98.2% .018 155.826);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-200:oklch(91.7% .08 205.041);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-indigo-300:oklch(78.5% .115 274.713);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-600:oklch(55.8% .288 302.321);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-300:oklch(83.3% .145 321.434);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-pink-400:oklch(71.8% .202 349.761);--color-pink-500:oklch(65.6% .241 354.308);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-400:oklch(70.4% .04 256.788);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--breakpoint-2xl:96rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height:calc(1.5/1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25/1.875);--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.inset-2{inset:calc(var(--spacing)*2)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-0\.5{right:calc(var(--spacing)*.5)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-20{right:calc(var(--spacing)*20)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-0\.5{bottom:calc(var(--spacing)*-.5)}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-4{bottom:calc(var(--spacing)*-4)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-0\.5{bottom:calc(var(--spacing)*.5)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-5{bottom:calc(var(--spacing)*5)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.-left-1{left:calc(var(--spacing)*-1)}.-left-2{left:calc(var(--spacing)*-2)}.-left-\[9999px\]{left:-9999px}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60{z-index:60}.z-\[1\]{z-index:1}.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.z-\[101\]{z-index:101}.z-\[110\]{z-index:110}.z-\[120\]{z-index:120}.z-\[1000\]{z-index:1000}.z-\[1001\]{z-index:1001}.z-\[9998\]{z-index:9998}.z-\[9999\]{z-index:9999}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.-m-1{margin:calc(var(--spacing)*-1)}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-1\.5{margin-inline:calc(var(--spacing)*1.5)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-5{margin-inline:calc(var(--spacing)*5)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-2{margin-block:calc(var(--spacing)*2)}.my-8{margin-block:calc(var(--spacing)*8)}.my-auto{margin-block:auto}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0{margin-bottom:calc(var(--spacing)*0)}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-\[3\.25rem\]{margin-left:3.25rem}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.table-row{display:table-row}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.\!h-8{height:calc(var(--spacing)*8)!important}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-4\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-44{height:calc(var(--spacing)*44)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-96{height:calc(var(--spacing)*96)}.h-\[2px\]{height:2px}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[40px\]{height:40px}.h-\[48px\]{height:48px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-56{max-height:calc(var(--spacing)*56)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-72{max-height:calc(var(--spacing)*72)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[3\.75rem\]{max-height:3.75rem}.max-h-\[24rem\]{max-height:24rem}.max-h-\[28rem\]{max-height:28rem}.max-h-\[50vh\]{max-height:50vh}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-2rem\)\]{max-height:calc(100vh - 2rem)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.\!min-h-8{min-height:calc(var(--spacing)*8)!important}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-7{min-height:calc(var(--spacing)*7)}.min-h-\[8rem\]{min-height:8rem}.min-h-\[16px\]{min-height:16px}.min-h-\[18px\]{min-height:18px}.min-h-\[36px\]{min-height:36px}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-screen{min-height:100vh}.\!w-8{width:calc(var(--spacing)*8)!important}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-5\/12{width:41.6667%}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-7\/12{width:58.3333%}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[18px\]{width:18px}.w-\[216px\]{width:216px}.w-\[240px\]{width:240px}.w-\[300px\]{width:300px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-max{width:max-content}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[220px\]{max-width:220px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-screen-2xl{max-width:var(--breakpoint-2xl)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-14{min-width:calc(var(--spacing)*14)}.min-w-28{min-width:calc(var(--spacing)*28)}.min-w-40{min-width:calc(var(--spacing)*40)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[130px\]{min-width:130px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.01\]{scale:1.01}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.\[appearance\:textfield\]{appearance:textfield}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_minmax\(0\,200px\)_220px\]{grid-template-columns:auto 1fr 100px 100px 100px minmax(0,200px) 220px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_minmax\(0\,200px\)_220px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px minmax(0,200px) 220px}.grid-cols-\[minmax\(3\.5rem\,1fr\)\]{grid-template-columns:minmax(3.5rem,1fr)}.grid-cols-\[repeat\(2\,minmax\(3\.5rem\,1fr\)\)\]{grid-template-columns:repeat(2,minmax(3.5rem,1fr))}.grid-cols-\[repeat\(4\,minmax\(3\.5rem\,1fr\)\)\]{grid-template-columns:repeat(4,minmax(3.5rem,1fr))}.grid-cols-\[repeat\(auto-fill\,minmax\(130px\,1fr\)\)\]{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-nowrap{flex-wrap:nowrap}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-items-center{justify-items:center}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing)*2)}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-dark-tertiary\/40>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-dark-tertiary\/40>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}:where(.divide-gray-100>:not(:last-child)){border-color:var(--color-gray-100)}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[10px\]{border-radius:10px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-b-2xl{border-bottom-right-radius:var(--radius-2xl);border-bottom-left-radius:var(--radius-2xl)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[3px\]{border-left-style:var(--tw-border-style);border-left-width:3px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab, red, red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-700{border-color:var(--color-amber-700)}.border-amber-700\/40{border-color:#b7500066}@supports (color:color-mix(in lab, red, red)){.border-amber-700\/40{border-color:color-mix(in oklab,var(--color-amber-700)40%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-dark-tertiary\/60{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/60{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)60%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-black\/20{border-color:#0003}@supports (color:color-mix(in lab, red, red)){.border-black\/20{border-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.border-blue-400{border-color:var(--color-blue-400)}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-400\/60{border-color:#54a2ff99}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/60{border-color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-current{border-color:currentColor}.border-cyan-400{border-color:var(--color-cyan-400)}.border-cyan-400\/50{border-color:#00d2ef80}@supports (color:color-mix(in lab, red, red)){.border-cyan-400\/50{border-color:color-mix(in oklab,var(--color-cyan-400)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab, red, red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-emerald-500\/20{border-color:#00bb7f33}@supports (color:color-mix(in lab, red, red)){.border-emerald-500\/20{border-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab, red, red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/30{border-color:#6a72824d}@supports (color:color-mix(in lab, red, red)){.border-gray-500\/30{border-color:color-mix(in oklab,var(--color-gray-500)30%,transparent)}}.border-gray-500\/40{border-color:#6a728266}@supports (color:color-mix(in lab, red, red)){.border-gray-500\/40{border-color:color-mix(in oklab,var(--color-gray-500)40%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-800{border-color:var(--color-gray-800)}.border-green-200{border-color:var(--color-green-200)}.border-green-300{border-color:var(--color-green-300)}.border-green-400{border-color:var(--color-green-400)}.border-green-400\/60{border-color:#05df7299}@supports (color:color-mix(in lab, red, red)){.border-green-400\/60{border-color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab, red, red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab, red, red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab, red, red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-green-800{border-color:var(--color-green-800)}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-400\/60{border-color:#ff8b1a99}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/60{border-color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab, red, red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-400\/60{border-color:#c07eff99}@supports (color:color-mix(in lab, red, red)){.border-purple-400\/60{border-color:color-mix(in oklab,var(--color-purple-400)60%,transparent)}}.border-purple-500{border-color:var(--color-purple-500)}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab, red, red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab, red, red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-400{border-color:var(--color-red-400)}.border-red-400\/60{border-color:#ff656899}@supports (color:color-mix(in lab, red, red)){.border-red-400\/60{border-color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab, red, red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800{border-color:var(--color-red-800)}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab, red, red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-red-900\/40{border-color:#82181a66}@supports (color:color-mix(in lab, red, red)){.border-red-900\/40{border-color:color-mix(in oklab,var(--color-red-900)40%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-teal-400\/60{border-color:#00d3bd99}@supports (color:color-mix(in lab, red, red)){.border-teal-400\/60{border-color:color-mix(in oklab,var(--color-teal-400)60%,transparent)}}.border-transparent{border-color:#0000}.border-white{border-color:var(--color-white)}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/15{border-color:#ffffff26}@supports (color:color-mix(in lab, red, red)){.border-white\/15{border-color:color-mix(in oklab,var(--color-white)15%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab, red, red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400{border-color:var(--color-yellow-400)}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/40{border-color:#fac80066}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/40{border-color:color-mix(in oklab,var(--color-yellow-400)40%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-zinc-700\/50{border-color:#3f3f4680}@supports (color:color-mix(in lab, red, red)){.border-zinc-700\/50{border-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.border-zinc-800{border-color:var(--color-zinc-800)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-blue-500{border-left-color:var(--color-blue-500)}.border-l-cyan-400{border-left-color:var(--color-cyan-400)}.border-l-emerald-500{border-left-color:var(--color-emerald-500)}.border-l-gray-500{border-left-color:var(--color-gray-500)}.border-l-red-500{border-left-color:var(--color-red-500)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.\!bg-bambu-green{background-color:var(--color-bambu-green)!important}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100\/60{background-color:#fef3c699}@supports (color:color-mix(in lab, red, red)){.bg-amber-100\/60{background-color:color-mix(in oklab,var(--color-amber-100)60%,transparent)}}.bg-amber-400\/10{background-color:#fcbb001a}@supports (color:color-mix(in lab, red, red)){.bg-amber-400\/10{background-color:color-mix(in oklab,var(--color-amber-400)10%,transparent)}}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/15{background-color:#f99c0026}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/15{background-color:color-mix(in oklab,var(--color-amber-500)15%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600{background-color:var(--color-amber-600)}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab, red, red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-amber-900\/20{background-color:#7b330633}@supports (color:color-mix(in lab, red, red)){.bg-amber-900\/20{background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.bg-amber-900\/30{background-color:#7b33064d}@supports (color:color-mix(in lab, red, red)){.bg-amber-900\/30{background-color:color-mix(in oklab,var(--color-amber-900)30%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/10{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/10{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)10%,transparent)}}.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/40{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/40{background-color:color-mix(in oklab,var(--color-bambu-dark)40%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/40{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/40{background-color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/15{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/15{background-color:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab, red, red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab, red, red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab, red, red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab, red, red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab, red, red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab, red, red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab, red, red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-400\/15{background-color:#54a2ff26}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/15{background-color:color-mix(in oklab,var(--color-blue-400)15%,transparent)}}.bg-blue-400\/20{background-color:#54a2ff33}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/20{background-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/15{background-color:#3080ff26}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/15{background-color:color-mix(in oklab,var(--color-blue-500)15%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab, red, red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-blue-700{background-color:var(--color-blue-700)}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/15{background-color:#00b7d726}@supports (color:color-mix(in lab, red, red)){.bg-cyan-500\/15{background-color:color-mix(in oklab,var(--color-cyan-500)15%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab, red, red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab, red, red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab, red, red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500)10%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab, red, red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-600\/20{background-color:#00976733}@supports (color:color-mix(in lab, red, red)){.bg-emerald-600\/20{background-color:color-mix(in oklab,var(--color-emerald-600)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-fuchsia-500\/20{background-color:#e12afb33}@supports (color:color-mix(in lab, red, red)){.bg-fuchsia-500\/20{background-color:color-mix(in oklab,var(--color-fuchsia-500)20%,transparent)}}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab, red, red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/15{background-color:#6a728226}@supports (color:color-mix(in lab, red, red)){.bg-gray-500\/15{background-color:color-mix(in oklab,var(--color-gray-500)15%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab, red, red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-50{background-color:var(--color-green-50)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab, red, red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab, red, red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-600\/40{background-color:#00a54466}@supports (color:color-mix(in lab, red, red)){.bg-green-600\/40{background-color:color-mix(in oklab,var(--color-green-600)40%,transparent)}}.bg-green-700{background-color:var(--color-green-700)}.bg-green-900\/30{background-color:#0d542b4d}@supports (color:color-mix(in lab, red, red)){.bg-green-900\/30{background-color:color-mix(in oklab,var(--color-green-900)30%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab, red, red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/10{background-color:#625fff1a}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/10{background-color:color-mix(in oklab,var(--color-indigo-500)10%,transparent)}}.bg-indigo-500\/15{background-color:#625fff26}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/15{background-color:color-mix(in oklab,var(--color-indigo-500)15%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-lime-500\/20{background-color:#80cd0033}@supports (color:color-mix(in lab, red, red)){.bg-lime-500\/20{background-color:color-mix(in oklab,var(--color-lime-500)20%,transparent)}}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab, red, red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab, red, red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab, red, red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-pink-500\/20{background-color:#f6339a33}@supports (color:color-mix(in lab, red, red)){.bg-pink-500\/20{background-color:color-mix(in oklab,var(--color-pink-500)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab, red, red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-600\/20{background-color:#e4001433}@supports (color:color-mix(in lab, red, red)){.bg-red-600\/20{background-color:color-mix(in oklab,var(--color-red-600)20%,transparent)}}.bg-red-900\/20{background-color:#82181a33}@supports (color:color-mix(in lab, red, red)){.bg-red-900\/20{background-color:color-mix(in oklab,var(--color-red-900)20%,transparent)}}.bg-red-900\/30{background-color:#82181a4d}@supports (color:color-mix(in lab, red, red)){.bg-red-900\/30{background-color:color-mix(in oklab,var(--color-red-900)30%,transparent)}}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab, red, red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab, red, red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab, red, red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/10{background-color:#00a5ef1a}@supports (color:color-mix(in lab, red, red)){.bg-sky-500\/10{background-color:color-mix(in oklab,var(--color-sky-500)10%,transparent)}}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab, red, red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning,.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab, red, red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab, red, red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab, red, red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab, red, red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab, red, red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/15{background-color:#edb20026}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/15{background-color:color-mix(in oklab,var(--color-yellow-500)15%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-yellow-700{background-color:var(--color-yellow-700)}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-800\/50{background-color:#27272a80}@supports (color:color-mix(in lab, red, red)){.bg-zinc-800\/50{background-color:color-mix(in oklab,var(--color-zinc-800)50%,transparent)}}.bg-zinc-800\/60{background-color:#27272a99}@supports (color:color-mix(in lab, red, red)){.bg-zinc-800\/60{background-color:color-mix(in oklab,var(--color-zinc-800)60%,transparent)}}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-zinc-900\/50{background-color:#18181b80}@supports (color:color-mix(in lab, red, red)){.bg-zinc-900\/50{background-color:color-mix(in oklab,var(--color-zinc-900)50%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/15{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.from-bambu-green\/15{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.from-bambu-green\/15{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab, red, red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab, red, red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-bambu-green\/5{--tw-gradient-via:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.via-bambu-green\/5{--tw-gradient-via:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.via-bambu-green\/5{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab, red, red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-0{padding-inline:calc(var(--spacing)*0)!important}.\!px-2{padding-inline:calc(var(--spacing)*2)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.\!py-0{padding-block:calc(var(--spacing)*0)!important}.py-0{padding-block:calc(var(--spacing)*0)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.py-px{padding-block:1px}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-0\.5{padding-top:calc(var(--spacing)*.5)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-2\.5{padding-top:calc(var(--spacing)*2.5)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-9{padding-right:calc(var(--spacing)*9)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-1{padding-left:calc(var(--spacing)*1)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-3{padding-left:calc(var(--spacing)*3)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-5{padding-left:calc(var(--spacing)*5)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.pl-20{padding-left:calc(var(--spacing)*20)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[6px\]{font-size:6px}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing)*5);line-height:calc(var(--spacing)*5)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-white{color:var(--color-white)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/60{color:#fee68599}@supports (color:color-mix(in lab, red, red)){.text-amber-200\/60{color:color-mix(in oklab,var(--color-amber-200)60%,transparent)}}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab, red, red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab, red, red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-400\/80{color:#fcbb00cc}@supports (color:color-mix(in lab, red, red)){.text-amber-400\/80{color:color-mix(in oklab,var(--color-amber-400)80%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab, red, red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-bambu-dark{color:var(--color-bambu-dark)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/50{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/50{color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.text-bambu-green\/60{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/60{color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab, red, red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-100{color:var(--color-blue-100)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab, red, red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab, red, red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/50{color:#54a2ff80}@supports (color:color-mix(in lab, red, red)){.text-blue-400\/50{color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab, red, red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-100{color:var(--color-emerald-100)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-600{color:var(--color-emerald-600)}.text-emerald-700{color:var(--color-emerald-700)}.text-fuchsia-300{color:var(--color-fuchsia-300)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab, red, red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.text-green-400\/70{color:#05df72b3}@supports (color:color-mix(in lab, red, red)){.text-green-400\/70{color:color-mix(in oklab,var(--color-green-400)70%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab, red, red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-green-700{color:var(--color-green-700)}.text-green-800{color:var(--color-green-800)}.text-indigo-300{color:var(--color-indigo-300)}.text-indigo-400{color:var(--color-indigo-400)}.text-lime-400{color:var(--color-lime-400)}.text-orange-100{color:var(--color-orange-100)}.text-orange-200{color:var(--color-orange-200)}.text-orange-200\/70{color:#ffd7a8b3}@supports (color:color-mix(in lab, red, red)){.text-orange-200\/70{color:color-mix(in oklab,var(--color-orange-200)70%,transparent)}}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-pink-400{color:var(--color-pink-400)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab, red, red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab, red, red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab, red, red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab, red, red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab, red, red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab, red, red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-slate-400{color:var(--color-slate-400)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab, red, red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab, red, red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab, red, red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab, red, red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-100{color:var(--color-yellow-100)}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab, red, red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab, red, red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-500\/80{color:#edb200cc}@supports (color:color-mix(in lab, red, red)){.text-yellow-500\/80{color:color-mix(in oklab,var(--color-yellow-500)80%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.placeholder-gray-400::placeholder{color:var(--color-gray-400)}.placeholder-white\/30::placeholder{color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.placeholder-white\/30::placeholder{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.accent-red-500{accent-color:var(--color-red-500)}.\[color-scheme\:dark\]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-90{opacity:.9}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_8px_rgba\(248\,113\,113\,0\.6\)\]{--tw-shadow:0 0 8px var(--tw-shadow-color,#f8717199);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab, red, red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.\!filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)!important}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-all{-webkit-user-select:all;user-select:all}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:bg-bambu-green\/30:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.group-hover\:bg-bambu-green\/30:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.group-hover\:break-all:is(:where(.group):hover *){word-break:break-all}.group-hover\:whitespace-normal:is(:where(.group):hover *){white-space:normal}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-amber-500:is(:where(.peer):checked~*){background-color:var(--color-amber-500)}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:ring-2:is(:where(.peer):focus~*){--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.peer-focus\:ring-bambu-green\/50:is(:where(.peer):focus~*){--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.peer-focus\:ring-bambu-green\/50:is(:where(.peer):focus~*){--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder\:text-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-3:before{content:var(--tw-content);right:calc(var(--spacing)*3)}.before\:left-3:before{content:var(--tw-content);left:calc(var(--spacing)*3)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0\.5:after{content:var(--tw-content);top:calc(var(--spacing)*.5)}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-0\.5:after{content:var(--tw-content);left:calc(var(--spacing)*.5)}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:transition-transform:after{content:var(--tw-content);transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus-within\:border-bambu-green:focus-within{border-color:var(--color-bambu-green)}@media (hover:hover){.hover\:z-10:hover{z-index:10}.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-amber-500:hover{border-color:var(--color-amber-500)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/40:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-green\/40:hover{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-gray-400:hover{border-color:var(--color-gray-400)}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab, red, red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab, red, red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)!important}@supports (color:color-mix(in lab, red, red)){.hover\:\!bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)!important}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-amber-700:hover{background-color:var(--color-amber-700)}.hover\:bg-amber-900\/50:hover{background-color:#7b330680}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-900\/50:hover{background-color:color-mix(in oklab,var(--color-amber-900)50%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-secondary\/80:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-secondary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)80%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/40:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/40:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/30:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.hover\:bg-bambu-dark\/40:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/40:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)40%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-bambu-green\/90:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/90:hover{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.hover\:bg-black\/10:hover{background-color:#0000001a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/10:hover{background-color:color-mix(in oklab,var(--color-black)10%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-400:hover{background-color:var(--color-blue-400)}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-blue-700:hover{background-color:var(--color-blue-700)}.hover\:bg-cyan-500\/10:hover{background-color:#00b7d71a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-cyan-500\/10:hover{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.hover\:bg-emerald-600:hover{background-color:var(--color-emerald-600)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-400:hover{background-color:var(--color-green-400)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab, red, red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-600:hover{background-color:var(--color-green-600)}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-indigo-500\/20:hover{background-color:#625fff33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-indigo-500\/20:hover{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.hover\:bg-indigo-500\/30:hover{background-color:#625fff4d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-indigo-500\/30:hover{background-color:color-mix(in oklab,var(--color-indigo-500)30%,transparent)}}.hover\:bg-orange-400:hover{background-color:var(--color-orange-400)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-500\/30:hover{background-color:#fe6e004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-500\/30:hover{background-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.hover\:bg-purple-400:hover{background-color:var(--color-purple-400)}.hover\:bg-purple-600\/90:hover{background-color:#9810fae6}@supports (color:color-mix(in lab, red, red)){.hover\:bg-purple-600\/90:hover{background-color:color-mix(in oklab,var(--color-purple-600)90%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400:hover{background-color:var(--color-red-400)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/25:hover{background-color:#fb2c3640}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/25:hover{background-color:color-mix(in oklab,var(--color-red-500)25%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-600\/30:hover{background-color:#e400144d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-600\/30:hover{background-color:color-mix(in oklab,var(--color-red-600)30%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-900\/50:hover{background-color:#82181a80}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-900\/50:hover{background-color:color-mix(in oklab,var(--color-red-900)50%,transparent)}}.hover\:bg-sky-500\/20:hover{background-color:#00a5ef33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-sky-500\/20:hover{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.hover\:bg-teal-400:hover{background-color:var(--color-teal-400)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/25:hover{background-color:#edb20040}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/25:hover{background-color:color-mix(in oklab,var(--color-yellow-500)25%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab, red, red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:bg-zinc-700\/60:hover{background-color:#3f3f4699}@supports (color:color-mix(in lab, red, red)){.hover\:bg-zinc-700\/60:hover{background-color:color-mix(in oklab,var(--color-zinc-700)60%,transparent)}}.hover\:bg-zinc-800:hover{background-color:var(--color-zinc-800)}.hover\:from-bambu-green\/20:hover{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:from-bambu-green\/20:hover{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:from-bambu-green\/20:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.hover\:text-amber-100:hover{color:var(--color-amber-100)}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-800:hover{color:var(--color-amber-800)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-blue-600:hover{color:var(--color-blue-600)}.hover\:text-blue-800:hover{color:var(--color-blue-800)}.hover\:text-cyan-200:hover{color:var(--color-cyan-200)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:text-gray-700:hover{color:var(--color-gray-700)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-red-800:hover{color:var(--color-red-800)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/60:hover{color:#fff9}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/60:hover{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-200:hover{color:var(--color-zinc-200)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-90:hover{opacity:.9}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}}.focus\:border-amber-500\/50:focus{border-color:#f99c0080}@supports (color:color-mix(in lab, red, red)){.focus\:border-amber-500\/50:focus{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.focus\:border-bambu-gray:focus{border-color:var(--color-bambu-gray)}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x)var(--tw-scale-y)}.active\:cursor-grabbing:active{cursor:grabbing}.active\:bg-amber-500\/30:active{background-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.active\:bg-amber-500\/30:active{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.active\:opacity-50:active{opacity:.5}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:bg-gray-600:disabled{background-color:var(--color-gray-600)}.disabled\:bg-zinc-700:disabled{background-color:var(--color-zinc-700)}.disabled\:no-underline:disabled{text-decoration-line:none}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}@media (hover:hover){.disabled\:hover\:border-bambu-dark-tertiary:disabled:hover{border-color:var(--color-bambu-dark-tertiary)}.disabled\:hover\:bg-bambu-dark:disabled:hover{background-color:var(--color-bambu-dark)}.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}.disabled\:hover\:bg-transparent:disabled:hover{background-color:#0000}.disabled\:hover\:text-bambu-gray:disabled:hover{color:var(--color-bambu-gray)}}@media not all and (width>=640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (width>=550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}}@media not all and (width>=520px){.max-\[520px\]\:h-20{height:calc(var(--spacing)*20)}.max-\[520px\]\:w-20{width:calc(var(--spacing)*20)}}@media (width>=40rem){.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-12{height:calc(var(--spacing)*12)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-12{width:calc(var(--spacing)*12)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-72{width:calc(var(--spacing)*72)}.sm\:w-auto{width:auto}.sm\:max-w-\[140px\]{max-width:140px}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-5{gap:calc(var(--spacing)*5)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media (width>=48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:col-span-2{grid-column:span 2/span 2}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1fr_140px_auto\]{grid-template-columns:1fr 140px auto}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:self-auto{align-self:auto}.md\:p-5{padding:calc(var(--spacing)*5)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media (width>=64rem){.lg\:static{position:static}.lg\:sticky{position:sticky}.lg\:top-4{top:calc(var(--spacing)*4)}.lg\:top-6{top:calc(var(--spacing)*6)}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:mb-0{margin-bottom:calc(var(--spacing)*0)}.lg\:mb-6{margin-bottom:calc(var(--spacing)*6)}.lg\:-ml-px{margin-left:-1px}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/2{width:50%}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-48{width:calc(var(--spacing)*48)}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:grid-cols-\[1fr_20rem\]{grid-template-columns:1fr 20rem}.lg\:flex-col{flex-direction:column}.lg\:flex-row{flex-direction:row}.lg\:flex-nowrap{flex-wrap:nowrap}.lg\:justify-start{justify-content:flex-start}.lg\:gap-0{gap:calc(var(--spacing)*0)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:self-start{align-self:flex-start}.lg\:overflow-y-auto{overflow-y:auto}.lg\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.lg\:border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.lg\:border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}}@media (width>=80rem){.xl\:col-span-3{grid-column:span 3/span 3}.xl\:inline{display:inline}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media (width>=96rem){.\32 xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}:where(.dark\:divide-gray-800:where(.dark,.dark *)>:not(:last-child)){border-color:var(--color-gray-800)}.dark\:border-amber-700:where(.dark,.dark *){border-color:var(--color-amber-700)}.dark\:border-amber-800:where(.dark,.dark *){border-color:var(--color-amber-800)}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-gray-700:where(.dark,.dark *){border-color:var(--color-gray-700)}.dark\:border-green-800:where(.dark,.dark *){border-color:var(--color-green-800)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:#7b330633}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.dark\:bg-amber-900\/30:where(.dark,.dark *){background-color:#7b33064d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-900\/30:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)30%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab, red, red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:#1c398e33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-900)20%,transparent)}}.dark\:bg-gray-700:where(.dark,.dark *){background-color:var(--color-gray-700)}.dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--color-gray-800)}.dark\:bg-gray-800\/30:where(.dark,.dark *){background-color:#1e29394d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/30:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)30%,transparent)}}.dark\:bg-gray-800\/40:where(.dark,.dark *){background-color:#1e293966}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/40:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)40%,transparent)}}.dark\:bg-gray-800\/50:where(.dark,.dark *){background-color:#1e293980}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/50:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)50%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-green-900\/20:where(.dark,.dark *){background-color:#0d542b33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-green-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-green-900)20%,transparent)}}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-100:where(.dark,.dark *){color:var(--color-amber-100)}.dark\:text-amber-200:where(.dark,.dark *){color:var(--color-amber-200)}.dark\:text-amber-300:where(.dark,.dark *){color:var(--color-amber-300)}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab, red, red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab, red, red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-emerald-300:where(.dark,.dark *){color:var(--color-emerald-300)}.dark\:text-emerald-400:where(.dark,.dark *){color:var(--color-emerald-400)}.dark\:text-gray-100:where(.dark,.dark *){color:var(--color-gray-100)}.dark\:text-gray-300:where(.dark,.dark *){color:var(--color-gray-300)}.dark\:text-gray-400:where(.dark,.dark *){color:var(--color-gray-400)}.dark\:text-gray-500:where(.dark,.dark *){color:var(--color-gray-500)}.dark\:text-gray-600:where(.dark,.dark *){color:var(--color-gray-600)}.dark\:text-green-200:where(.dark,.dark *){color:var(--color-green-200)}.dark\:text-green-400:where(.dark,.dark *){color:var(--color-green-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media (hover:hover){.dark\:hover\:border-gray-500:where(.dark,.dark *):hover{border-color:var(--color-gray-500)}.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--color-gray-600)}.dark\:hover\:bg-gray-800\/50:where(.dark,.dark *):hover{background-color:#1e293980}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-gray-800\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-gray-800)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-amber-200:where(.dark,.dark *):hover{color:var(--color-amber-200)}.dark\:hover\:text-blue-300:where(.dark,.dark *):hover{color:var(--color-blue-300)}.dark\:hover\:text-gray-200:where(.dark,.dark *):hover{color:var(--color-gray-200)}.dark\:hover\:text-gray-300:where(.dark,.dark *):hover{color:var(--color-gray-300)}.dark\:hover\:text-red-300:where(.dark,.dark *):hover{color:var(--color-red-300)}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-inner-spin-button\]\:appearance-none::-webkit-inner-spin-button{appearance:none}.\[\&\:\:-webkit-outer-spin-button\]\:appearance-none::-webkit-outer-spin-button{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}.\[\&\>\*\]\:shrink-0>*{flex-shrink:0}}@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/inter-latin.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/inter-latin-ext.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}html{font-size:14.4px}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (width<=220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab, red, red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab, red, red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}@keyframes spoolbuddy-optimized-ping{0%{opacity:.8;transform:scale(.8)}80%,to{opacity:0;transform:scale(2.2)}}.spoolbuddy-optimized-ping{will-change:auto;contain:layout;animation:3.5s cubic-bezier(0,0,.2,1) infinite spoolbuddy-optimized-ping}.spoolbuddy-spool-glow{will-change:auto;transform:scale(2)}@media (prefers-reduced-motion:reduce){.spoolbuddy-optimized-ping{opacity:.25;animation:none;transform:scale(1.2)}.spoolbuddy-spool-glow{transition:none}}@keyframes slide-down{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.animate-slide-down{animation:.25s ease-out slide-down}.card-shadow{box-shadow:var(--card-shadow)}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl{flex-direction:column;height:90vh;max-height:90vh;display:flex}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:first-child,[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:last-child{flex-shrink:0}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:nth-child(2){flex:auto;min-height:0;overflow-y:auto}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl .max-h-96{max-height:none}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab, red, red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@media (hover:hover) and (pointer:fine){.history-thumb-hover:hover .history-thumb-preview{opacity:1}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}.hg-theme-default{box-sizing:border-box;touch-action:manipulation;-webkit-user-select:none;user-select:none;background-color:#ececec;border-radius:5px;width:100%;padding:5px;font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;overflow:hidden}.hg-theme-default .hg-button span,.hg-theme-default .hg-button span svg{pointer-events:none}.hg-theme-default button.hg-button{font-size:inherit;border-width:0}.hg-theme-default .hg-button{flex-grow:1;display:inline-block}.hg-theme-default .hg-row{display:flex}.hg-theme-default .hg-row:not(:last-child){margin-bottom:5px}.hg-theme-default .hg-row .hg-button-container,.hg-theme-default .hg-row .hg-button:not(:last-child){margin-right:5px}.hg-theme-default .hg-row>div:last-child{margin-right:0}.hg-theme-default .hg-row .hg-button-container{display:flex}.hg-theme-default .hg-button{box-sizing:border-box;cursor:pointer;-webkit-tap-highlight-color:#0000;background:#fff;border-bottom:1px solid #b5b5b5;border-radius:5px;justify-content:center;align-items:center;height:40px;padding:5px;display:flex;box-shadow:0 0 3px -1px #0000004d}.hg-theme-default .hg-button.hg-standardBtn{width:20px}.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.hg-theme-default.hg-layout-numeric .hg-button{justify-content:center;align-items:center;width:33.3%;height:60px;display:flex}.hg-theme-default .hg-button.hg-button-numpadadd,.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.hg-theme-default .hg-button.hg-button-com{max-width:85px}.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.hg-theme-default .hg-button.hg-selectedButton{color:#fff;background:#05194687}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\.com]{max-width:82px}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\@]{max-width:60px}.hg-candidate-box{-webkit-user-select:none;user-select:none;background:#ececec;border-bottom:2px solid #b5b5b5;border-radius:5px;margin-top:-10px;display:inline-flex;position:absolute;transform:translateY(-100%)}ul.hg-candidate-box-list{flex:1;margin:0;padding:0;list-style:none;display:flex}li.hg-candidate-box-list-item{justify-content:center;align-items:center;width:40px;height:40px;display:flex}li.hg-candidate-box-list-item:hover{cursor:pointer;background:#00000008}li.hg-candidate-box-list-item:active{background:#0000001a}.hg-candidate-box-prev:before{content:"◄"}.hg-candidate-box-next:before{content:"►"}.hg-candidate-box-next,.hg-candidate-box-prev{color:#969696;cursor:pointer;align-items:center;padding:0 10px;display:flex}.hg-candidate-box-next{border-top-right-radius:5px;border-bottom-right-radius:5px}.hg-candidate-box-prev{border-top-left-radius:5px;border-bottom-left-radius:5px}.hg-candidate-box-btn-active{color:#444}.simple-keyboard.vkb-theme{background:#1a1a1a;border-top:1px solid #333;padding:8px 4px;font-family:inherit}.simple-keyboard.vkb-theme .hg-row{gap:4px;margin-bottom:4px;flex-flow:row!important;display:flex!important}.simple-keyboard.vkb-theme .hg-row:last-child{margin-bottom:0}.simple-keyboard.vkb-theme .hg-button{color:#e0e0e0;cursor:pointer;background:#2d2d2d;border:none;border-radius:6px;flex:auto;justify-content:center;align-items:center;min-width:0;height:44px;padding:0 2px;font-size:16px;font-weight:500;transition:background .1s;box-shadow:0 1px 2px #0000004d;display:inline-flex!important}.simple-keyboard.vkb-theme .hg-button:active{color:#fff;background:#00ae42}.simple-keyboard.vkb-theme .hg-button-bksp,.simple-keyboard.vkb-theme .hg-button-shift,.simple-keyboard.vkb-theme .hg-button-lock{color:#aaa;background:#3a3a3a;flex-grow:1.5}.simple-keyboard.vkb-theme .hg-button-close{color:#aaa;background:#3a3a3a;flex-grow:2;font-weight:600}.simple-keyboard.vkb-theme .hg-button-close:active{background:#555}.simple-keyboard.vkb-theme .hg-button-space{flex-grow:7}.simple-keyboard.vkb-theme .hg-activeButton{color:#fff;background:#00ae42} diff --git a/static/assets/index-DNsDLric.css b/static/assets/index-DNsDLric.css deleted file mode 100644 index e8ed9039d..000000000 --- a/static/assets/index-DNsDLric.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-100:oklch(95.4% .038 75.164);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-lime-400:oklch(84.1% .238 128.85);--color-lime-500:oklch(76.8% .233 130.85);--color-green-50:oklch(98.2% .018 155.826);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-teal-400:oklch(77.7% .152 181.912);--color-teal-500:oklch(70.4% .14 182.503);--color-cyan-200:oklch(91.7% .08 205.041);--color-cyan-300:oklch(86.5% .127 207.078);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-cyan-600:oklch(60.9% .126 221.723);--color-sky-400:oklch(74.6% .16 232.661);--color-sky-500:oklch(68.5% .169 237.323);--color-blue-50:oklch(97% .014 254.604);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-200:oklch(88.2% .059 254.128);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-blue-800:oklch(42.4% .199 265.638);--color-blue-900:oklch(37.9% .146 265.522);--color-indigo-300:oklch(78.5% .115 274.713);--color-indigo-400:oklch(67.3% .182 276.935);--color-indigo-500:oklch(58.5% .233 277.117);--color-violet-500:oklch(60.6% .25 292.717);--color-purple-300:oklch(82.7% .119 306.383);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-purple-600:oklch(55.8% .288 302.321);--color-purple-700:oklch(49.6% .265 301.924);--color-fuchsia-300:oklch(83.3% .145 321.434);--color-fuchsia-500:oklch(66.7% .295 322.15);--color-pink-400:oklch(71.8% .202 349.761);--color-pink-500:oklch(65.6% .241 354.308);--color-rose-300:oklch(81% .117 11.638);--color-rose-400:oklch(71.2% .194 13.428);--color-rose-500:oklch(64.5% .246 16.439);--color-rose-600:oklch(58.6% .253 17.585);--color-slate-300:oklch(86.9% .022 252.894);--color-slate-500:oklch(55.4% .046 257.417);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-zinc-100:oklch(96.7% .001 286.375);--color-zinc-200:oklch(92% .004 286.32);--color-zinc-300:oklch(87.1% .006 286.286);--color-zinc-400:oklch(70.5% .015 286.067);--color-zinc-500:oklch(55.2% .016 285.938);--color-zinc-600:oklch(44.2% .017 285.786);--color-zinc-700:oklch(37% .013 285.805);--color-zinc-800:oklch(27.4% .006 286.033);--color-zinc-900:oklch(21% .006 285.885);--color-black:#000;--color-white:#fff;--spacing:.25rem;--breakpoint-2xl:96rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--container-5xl:64rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height:calc(1.5/1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25/1.875);--text-5xl:3rem;--text-5xl--line-height:1;--font-weight-light:300;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--tracking-widest:.1em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--drop-shadow-md:0 3px 3px #0000001f;--drop-shadow-lg:0 4px 4px #00000026;--ease-out:cubic-bezier(0,0,.2,1);--ease-in-out:cubic-bezier(.4,0,.2,1);--animate-spin:spin 1s linear infinite;--animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--blur-sm:8px;--blur-2xl:40px;--aspect-video:16/9;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-bambu-green:var(--accent);--color-bambu-green-light:var(--accent-light);--color-bambu-green-dark:var(--accent-dark);--color-status-ok:var(--status-ok);--color-status-error:var(--status-error);--color-status-warning:var(--status-warning);--color-bambu-dark:var(--bg-primary);--color-bambu-dark-secondary:var(--bg-secondary);--color-bambu-dark-tertiary:var(--bg-tertiary);--color-bambu-gray:var(--text-muted);--color-bambu-gray-light:var(--text-secondary);--color-bambu-gray-dark:var(--text-tertiary)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.inset-2{inset:calc(var(--spacing)*2)}.inset-x-0{inset-inline:calc(var(--spacing)*0)}.inset-y-0{inset-block:calc(var(--spacing)*0)}.-top-0\.5{top:calc(var(--spacing)*-.5)}.-top-1{top:calc(var(--spacing)*-1)}.-top-1\.5{top:calc(var(--spacing)*-1.5)}.top-0{top:calc(var(--spacing)*0)}.top-0\.5{top:calc(var(--spacing)*.5)}.top-1{top:calc(var(--spacing)*1)}.top-1\.5{top:calc(var(--spacing)*1.5)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing)*2)}.top-2\.5{top:calc(var(--spacing)*2.5)}.top-3{top:calc(var(--spacing)*3)}.top-4{top:calc(var(--spacing)*4)}.top-8{top:calc(var(--spacing)*8)}.top-\[3px\]{top:3px}.top-\[52px\]{top:52px}.top-full{top:100%}.-right-0\.5{right:calc(var(--spacing)*-.5)}.-right-1{right:calc(var(--spacing)*-1)}.-right-1\.5{right:calc(var(--spacing)*-1.5)}.-right-2{right:calc(var(--spacing)*-2)}.right-0{right:calc(var(--spacing)*0)}.right-0\.5{right:calc(var(--spacing)*.5)}.right-1{right:calc(var(--spacing)*1)}.right-1\.5{right:calc(var(--spacing)*1.5)}.right-2{right:calc(var(--spacing)*2)}.right-3{right:calc(var(--spacing)*3)}.right-4{right:calc(var(--spacing)*4)}.right-6{right:calc(var(--spacing)*6)}.right-12{right:calc(var(--spacing)*12)}.right-20{right:calc(var(--spacing)*20)}.right-\[5\.5rem\]{right:5.5rem}.right-full{right:100%}.-bottom-0\.5{bottom:calc(var(--spacing)*-.5)}.-bottom-1{bottom:calc(var(--spacing)*-1)}.-bottom-2{bottom:calc(var(--spacing)*-2)}.-bottom-4{bottom:calc(var(--spacing)*-4)}.-bottom-7{bottom:calc(var(--spacing)*-7)}.bottom-0{bottom:calc(var(--spacing)*0)}.bottom-0\.5{bottom:calc(var(--spacing)*.5)}.bottom-1{bottom:calc(var(--spacing)*1)}.bottom-2{bottom:calc(var(--spacing)*2)}.bottom-3{bottom:calc(var(--spacing)*3)}.bottom-4{bottom:calc(var(--spacing)*4)}.bottom-5{bottom:calc(var(--spacing)*5)}.bottom-6{bottom:calc(var(--spacing)*6)}.bottom-8{bottom:calc(var(--spacing)*8)}.bottom-20{bottom:calc(var(--spacing)*20)}.bottom-full{bottom:100%}.-left-1{left:calc(var(--spacing)*-1)}.-left-2{left:calc(var(--spacing)*-2)}.-left-\[9999px\]{left:-9999px}.left-0{left:calc(var(--spacing)*0)}.left-0\.5{left:calc(var(--spacing)*.5)}.left-1{left:calc(var(--spacing)*1)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing)*2)}.left-2\.5{left:calc(var(--spacing)*2.5)}.left-3{left:calc(var(--spacing)*3)}.left-4{left:calc(var(--spacing)*4)}.left-10{left:calc(var(--spacing)*10)}.left-12{left:calc(var(--spacing)*12)}.left-\[3px\]{left:3px}.left-full{left:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-60{z-index:60}.z-\[1\]{z-index:1}.z-\[60\]{z-index:60}.z-\[100\]{z-index:100}.z-\[101\]{z-index:101}.z-\[110\]{z-index:110}.z-\[120\]{z-index:120}.z-\[1000\]{z-index:1000}.z-\[1001\]{z-index:1001}.z-\[9998\]{z-index:9998}.z-\[9999\]{z-index:9999}.col-span-1{grid-column:span 1/span 1}.col-span-2{grid-column:span 2/span 2}.col-span-3{grid-column:span 3/span 3}.col-span-4{grid-column:span 4/span 4}.col-span-full{grid-column:1/-1}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.-m-1{margin:calc(var(--spacing)*-1)}.-m-4{margin:calc(var(--spacing)*-4)}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-4{margin-inline:calc(var(--spacing)*-4)}.mx-1{margin-inline:calc(var(--spacing)*1)}.mx-1\.5{margin-inline:calc(var(--spacing)*1.5)}.mx-2{margin-inline:calc(var(--spacing)*2)}.mx-4{margin-inline:calc(var(--spacing)*4)}.mx-5{margin-inline:calc(var(--spacing)*5)}.mx-auto{margin-inline:auto}.my-1{margin-block:calc(var(--spacing)*1)}.my-2{margin-block:calc(var(--spacing)*2)}.my-8{margin-block:calc(var(--spacing)*8)}.my-auto{margin-block:auto}.-mt-0\.5{margin-top:calc(var(--spacing)*-.5)}.-mt-2{margin-top:calc(var(--spacing)*-2)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mt-8{margin-top:calc(var(--spacing)*8)}.mt-14{margin-top:calc(var(--spacing)*14)}.mt-auto{margin-top:auto}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-1\.5{margin-right:calc(var(--spacing)*1.5)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-4{margin-right:calc(var(--spacing)*4)}.mr-auto{margin-right:auto}.-mb-px{margin-bottom:-1px}.mb-0{margin-bottom:calc(var(--spacing)*0)}.mb-0\.5{margin-bottom:calc(var(--spacing)*.5)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-2\.5{margin-bottom:calc(var(--spacing)*2.5)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.-ml-2{margin-left:calc(var(--spacing)*-2)}.ml-0\.5{margin-left:calc(var(--spacing)*.5)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-1\.5{margin-left:calc(var(--spacing)*1.5)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-3{margin-left:calc(var(--spacing)*3)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-7{margin-left:calc(var(--spacing)*7)}.ml-16{margin-left:calc(var(--spacing)*16)}.ml-64{margin-left:calc(var(--spacing)*64)}.ml-\[3\.25rem\]{margin-left:3.25rem}.ml-auto{margin-left:auto}.line-clamp-1{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.table-row{display:table-row}.aspect-square{aspect-ratio:1}.aspect-video{aspect-ratio:var(--aspect-video)}.\!h-8{height:calc(var(--spacing)*8)!important}.h-0{height:calc(var(--spacing)*0)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1{height:calc(var(--spacing)*1)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-2\.5{height:calc(var(--spacing)*2.5)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-4\.5{height:calc(var(--spacing)*4.5)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-14{height:calc(var(--spacing)*14)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-32{height:calc(var(--spacing)*32)}.h-44{height:calc(var(--spacing)*44)}.h-48{height:calc(var(--spacing)*48)}.h-64{height:calc(var(--spacing)*64)}.h-80{height:calc(var(--spacing)*80)}.h-96{height:calc(var(--spacing)*96)}.h-\[2px\]{height:2px}.h-\[18px\]{height:18px}.h-\[38px\]{height:38px}.h-\[40px\]{height:40px}.h-\[48px\]{height:48px}.h-\[80vh\]{height:80vh}.h-\[160px\]{height:160px}.h-\[300px\]{height:300px}.h-\[calc\(100\%-40px\)\]{height:calc(100% - 40px)}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-40{max-height:calc(var(--spacing)*40)}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-56{max-height:calc(var(--spacing)*56)}.max-h-60{max-height:calc(var(--spacing)*60)}.max-h-64{max-height:calc(var(--spacing)*64)}.max-h-72{max-height:calc(var(--spacing)*72)}.max-h-80{max-height:calc(var(--spacing)*80)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[3\.75rem\]{max-height:3.75rem}.max-h-\[24rem\]{max-height:24rem}.max-h-\[28rem\]{max-height:28rem}.max-h-\[50vh\]{max-height:50vh}.max-h-\[60vh\]{max-height:60vh}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.max-h-\[500px\]{max-height:500px}.max-h-\[600px\]{max-height:600px}.max-h-\[calc\(90vh-80px\)\]{max-height:calc(90vh - 80px)}.max-h-\[calc\(100vh-2rem\)\]{max-height:calc(100vh - 2rem)}.max-h-\[calc\(100vh-320px\)\]{max-height:calc(100vh - 320px)}.max-h-full{max-height:100%}.\!min-h-8{min-height:calc(var(--spacing)*8)!important}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-7{min-height:calc(var(--spacing)*7)}.min-h-\[8rem\]{min-height:8rem}.min-h-\[16px\]{min-height:16px}.min-h-\[18px\]{min-height:18px}.min-h-\[36px\]{min-height:36px}.min-h-\[40px\]{min-height:40px}.min-h-\[44px\]{min-height:44px}.min-h-\[48px\]{min-height:48px}.min-h-\[60px\]{min-height:60px}.min-h-\[80px\]{min-height:80px}.min-h-\[120px\]{min-height:120px}.min-h-\[300px\]{min-height:300px}.min-h-\[400px\]{min-height:400px}.min-h-\[calc\(100vh-64px\)\]{min-height:calc(100vh - 64px)}.min-h-screen{min-height:100vh}.\!w-8{width:calc(var(--spacing)*8)!important}.w-0{width:calc(var(--spacing)*0)}.w-0\.5{width:calc(var(--spacing)*.5)}.w-1{width:calc(var(--spacing)*1)}.w-1\.5{width:calc(var(--spacing)*1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing)*2)}.w-2\.5{width:calc(var(--spacing)*2.5)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-4\.5{width:calc(var(--spacing)*4.5)}.w-5{width:calc(var(--spacing)*5)}.w-5\/12{width:41.6667%}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-7\/12{width:58.3333%}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-11{width:calc(var(--spacing)*11)}.w-12{width:calc(var(--spacing)*12)}.w-14{width:calc(var(--spacing)*14)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-72{width:calc(var(--spacing)*72)}.w-96{width:calc(var(--spacing)*96)}.w-\[18px\]{width:18px}.w-\[216px\]{width:216px}.w-\[240px\]{width:240px}.w-\[300px\]{width:300px}.w-\[340px\]{width:340px}.w-\[420px\]{width:420px}.w-\[560px\]{width:560px}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.w-max{width:max-content}.w-px{width:1px}.w-screen{width:100vw}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-5xl{max-width:var(--container-5xl)}.max-w-6xl{max-width:var(--container-6xl)}.max-w-32{max-width:calc(var(--spacing)*32)}.max-w-\[40\%\]{max-width:40%}.max-w-\[80px\]{max-width:80px}.max-w-\[90vw\]{max-width:90vw}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[160px\]{max-width:160px}.max-w-\[200px\]{max-width:200px}.max-w-\[220px\]{max-width:220px}.max-w-\[280px\]{max-width:280px}.max-w-\[600px\]{max-width:600px}.max-w-full{max-width:100%}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-screen-2xl{max-width:var(--breakpoint-2xl)}.max-w-sm{max-width:var(--container-sm)}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-14{min-width:calc(var(--spacing)*14)}.min-w-28{min-width:calc(var(--spacing)*28)}.min-w-40{min-width:calc(var(--spacing)*40)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[16px\]{min-width:16px}.min-w-\[18px\]{min-width:18px}.min-w-\[32px\]{min-width:32px}.min-w-\[40px\]{min-width:40px}.min-w-\[48px\]{min-width:48px}.min-w-\[50px\]{min-width:50px}.min-w-\[80px\]{min-width:80px}.min-w-\[100px\]{min-width:100px}.min-w-\[120px\]{min-width:120px}.min-w-\[130px\]{min-width:130px}.min-w-\[140px\]{min-width:140px}.min-w-\[150px\]{min-width:150px}.min-w-\[160px\]{min-width:160px}.min-w-\[180px\]{min-width:180px}.min-w-\[200px\]{min-width:200px}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-\[2_1_190px\]{flex:2 190px}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-0\.5{--tw-translate-x:calc(var(--spacing)*.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1{--tw-translate-x:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-3\.5{--tw-translate-x:calc(var(--spacing)*3.5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-4{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-5{--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-6{--tw-translate-x:calc(var(--spacing)*6);translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1/2*100%)*-1);translate:var(--tw-translate-x)var(--tw-translate-y)}.scale-105{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.scale-\[1\.01\]{scale:1.01}.scale-\[1\.02\]{scale:1.02}.-rotate-90{rotate:-90deg}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-ping{animation:var(--animate-ping)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-ew-resize{cursor:ew-resize}.cursor-grab{cursor:grab}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.cursor-row-resize{cursor:row-resize}.cursor-se-resize{cursor:se-resize}.touch-manipulation{touch-action:manipulation}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.list-none{list-style-type:none}.\[appearance\:textfield\]{appearance:textfield}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}.grid-cols-12{grid-template-columns:repeat(12,minmax(0,1fr))}.grid-cols-\[auto_1fr_100px_100px_100px_minmax\(0\,200px\)_220px\]{grid-template-columns:auto 1fr 100px 100px 100px minmax(0,200px) 220px}.grid-cols-\[auto_1fr_120px_100px_100px_100px_minmax\(0\,200px\)_220px\]{grid-template-columns:auto 1fr 120px 100px 100px 100px minmax(0,200px) 220px}.grid-cols-\[minmax\(3\.5rem\,1fr\)\]{grid-template-columns:minmax(3.5rem,1fr)}.grid-cols-\[repeat\(2\,minmax\(3\.5rem\,1fr\)\)\]{grid-template-columns:repeat(2,minmax(3.5rem,1fr))}.grid-cols-\[repeat\(4\,minmax\(3\.5rem\,1fr\)\)\]{grid-template-columns:repeat(4,minmax(3.5rem,1fr))}.grid-cols-\[repeat\(auto-fill\,minmax\(130px\,1fr\)\)\]{grid-template-columns:repeat(auto-fill,minmax(130px,1fr))}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-nowrap{flex-wrap:nowrap}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-items-center{justify-items:center}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-2\.5{gap:calc(var(--spacing)*2.5)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.gap-\[3px\]{gap:3px}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.gap-x-2{column-gap:calc(var(--spacing)*2)}.gap-x-3{column-gap:calc(var(--spacing)*3)}.gap-x-4{column-gap:calc(var(--spacing)*4)}.gap-x-6{column-gap:calc(var(--spacing)*6)}.gap-y-1{row-gap:calc(var(--spacing)*1)}.gap-y-2{row-gap:calc(var(--spacing)*2)}.gap-y-3{row-gap:calc(var(--spacing)*3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-bambu-dark-tertiary>:not(:last-child)),:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-dark-tertiary\/30>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}:where(.divide-bambu-dark-tertiary\/40>:not(:last-child)){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-dark-tertiary\/40>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){:where(.divide-bambu-gray\/20>:not(:last-child)){border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}:where(.divide-gray-100>:not(:last-child)){border-color:var(--color-gray-100)}.self-start{align-self:flex-start}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-\[10px\]{border-radius:10px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-none{border-radius:0}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-lg{border-top-left-radius:var(--radius-lg);border-top-right-radius:var(--radius-lg)}.rounded-t-xl{border-top-left-radius:var(--radius-xl);border-top-right-radius:var(--radius-xl)}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-l-lg{border-top-left-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-lg{border-top-right-radius:var(--radius-lg);border-bottom-right-radius:var(--radius-lg)}.rounded-r-none{border-top-right-radius:0;border-bottom-right-radius:0}.rounded-b-2xl{border-bottom-right-radius:var(--radius-2xl);border-bottom-left-radius:var(--radius-2xl)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-4{border-style:var(--tw-border-style);border-width:4px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.border-t-2{border-top-style:var(--tw-border-style);border-top-width:2px}.border-t-\[5px\]{border-top-style:var(--tw-border-style);border-top-width:5px}.border-t-\[6px\]{border-top-style:var(--tw-border-style);border-top-width:6px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-r-\[5px\]{border-right-style:var(--tw-border-style);border-right-width:5px}.border-r-\[6px\]{border-right-style:var(--tw-border-style);border-right-width:6px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-b-\[6px\]{border-bottom-style:var(--tw-border-style);border-bottom-width:6px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-l-4{border-left-style:var(--tw-border-style);border-left-width:4px}.border-l-\[3px\]{border-left-style:var(--tw-border-style);border-left-width:3px}.border-l-\[5px\]{border-left-style:var(--tw-border-style);border-left-width:5px}.border-l-\[6px\]{border-left-style:var(--tw-border-style);border-left-width:6px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-amber-200{border-color:var(--color-amber-200)}.border-amber-300{border-color:var(--color-amber-300)}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab, red, red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500{border-color:var(--color-amber-500)}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab, red, red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-700{border-color:var(--color-amber-700)}.border-amber-700\/40{border-color:#b7500066}@supports (color:color-mix(in lab, red, red)){.border-amber-700\/40{border-color:color-mix(in oklab,var(--color-amber-700)40%,transparent)}}.border-bambu-dark-secondary{border-color:var(--color-bambu-dark-secondary)}.border-bambu-dark-tertiary,.border-bambu-dark-tertiary\/20{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/20{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.border-bambu-dark-tertiary\/30{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/30{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.border-bambu-dark-tertiary\/40{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/40{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.border-bambu-dark-tertiary\/50{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/50{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.border-bambu-dark-tertiary\/60{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.border-bambu-dark-tertiary\/60{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)60%,transparent)}}.border-bambu-gray,.border-bambu-gray\/20{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/20{border-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.border-bambu-gray\/30{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/30{border-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.border-bambu-gray\/50{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.border-bambu-gray\/50{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.border-bambu-green,.border-bambu-green\/20{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/20{border-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.border-bambu-green\/30{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/30{border-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.border-bambu-green\/40{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/40{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.border-bambu-green\/50{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.border-bambu-green\/50{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.border-black\/20{border-color:#0003}@supports (color:color-mix(in lab, red, red)){.border-black\/20{border-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.border-blue-400{border-color:var(--color-blue-400)}.border-blue-400\/20{border-color:#54a2ff33}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/20{border-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.border-blue-400\/50{border-color:#54a2ff80}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/50{border-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.border-blue-400\/60{border-color:#54a2ff99}@supports (color:color-mix(in lab, red, red)){.border-blue-400\/60{border-color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.border-blue-500{border-color:var(--color-blue-500)}.border-blue-500\/20{border-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/20{border-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab, red, red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-current{border-color:currentColor}.border-cyan-400{border-color:var(--color-cyan-400)}.border-cyan-400\/50{border-color:#00d2ef80}@supports (color:color-mix(in lab, red, red)){.border-cyan-400\/50{border-color:color-mix(in oklab,var(--color-cyan-400)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab, red, red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-emerald-500\/20{border-color:#00bb7f33}@supports (color:color-mix(in lab, red, red)){.border-emerald-500\/20{border-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-gray-400\/20{border-color:#99a1af33}@supports (color:color-mix(in lab, red, red)){.border-gray-400\/20{border-color:color-mix(in oklab,var(--color-gray-400)20%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-500\/30{border-color:#6a72824d}@supports (color:color-mix(in lab, red, red)){.border-gray-500\/30{border-color:color-mix(in oklab,var(--color-gray-500)30%,transparent)}}.border-gray-500\/40{border-color:#6a728266}@supports (color:color-mix(in lab, red, red)){.border-gray-500\/40{border-color:color-mix(in oklab,var(--color-gray-500)40%,transparent)}}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-800{border-color:var(--color-gray-800)}.border-green-200{border-color:var(--color-green-200)}.border-green-300{border-color:var(--color-green-300)}.border-green-400{border-color:var(--color-green-400)}.border-green-400\/60{border-color:#05df7299}@supports (color:color-mix(in lab, red, red)){.border-green-400\/60{border-color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.border-green-500{border-color:var(--color-green-500)}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab, red, red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab, red, red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-green-500\/50{border-color:#00c75880}@supports (color:color-mix(in lab, red, red)){.border-green-500\/50{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.border-green-800{border-color:var(--color-green-800)}.border-orange-400\/20{border-color:#ff8b1a33}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/20{border-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.border-orange-400\/50{border-color:#ff8b1a80}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/50{border-color:color-mix(in oklab,var(--color-orange-400)50%,transparent)}}.border-orange-400\/60{border-color:#ff8b1a99}@supports (color:color-mix(in lab, red, red)){.border-orange-400\/60{border-color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab, red, red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-purple-400\/20{border-color:#c07eff33}@supports (color:color-mix(in lab, red, red)){.border-purple-400\/20{border-color:color-mix(in oklab,var(--color-purple-400)20%,transparent)}}.border-purple-400\/60{border-color:#c07eff99}@supports (color:color-mix(in lab, red, red)){.border-purple-400\/60{border-color:color-mix(in oklab,var(--color-purple-400)60%,transparent)}}.border-purple-500{border-color:var(--color-purple-500)}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab, red, red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab, red, red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-red-300{border-color:var(--color-red-300)}.border-red-400{border-color:var(--color-red-400)}.border-red-400\/60{border-color:#ff656899}@supports (color:color-mix(in lab, red, red)){.border-red-400\/60{border-color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/40{border-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.border-red-500\/40{border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab, red, red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-red-800{border-color:var(--color-red-800)}.border-red-800\/70{border-color:#9f0712b3}@supports (color:color-mix(in lab, red, red)){.border-red-800\/70{border-color:color-mix(in oklab,var(--color-red-800)70%,transparent)}}.border-red-900\/40{border-color:#82181a66}@supports (color:color-mix(in lab, red, red)){.border-red-900\/40{border-color:color-mix(in oklab,var(--color-red-900)40%,transparent)}}.border-slate-500{border-color:var(--color-slate-500)}.border-status-error\/20{border-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.border-status-error\/20{border-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.border-status-ok,.border-status-ok\/20{border-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.border-status-ok\/20{border-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.border-status-warning\/20{border-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.border-status-warning\/20{border-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.border-teal-400\/60{border-color:#00d3bd99}@supports (color:color-mix(in lab, red, red)){.border-teal-400\/60{border-color:color-mix(in oklab,var(--color-teal-400)60%,transparent)}}.border-transparent{border-color:#0000}.border-white{border-color:var(--color-white)}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/15{border-color:#ffffff26}@supports (color:color-mix(in lab, red, red)){.border-white\/15{border-color:color-mix(in oklab,var(--color-white)15%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab, red, red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-white\/30{border-color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.border-white\/30{border-color:color-mix(in oklab,var(--color-white)30%,transparent)}}.border-yellow-400{border-color:var(--color-yellow-400)}.border-yellow-400\/20{border-color:#fac80033}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/20{border-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.border-yellow-400\/40{border-color:#fac80066}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/40{border-color:color-mix(in oklab,var(--color-yellow-400)40%,transparent)}}.border-yellow-400\/50{border-color:#fac80080}@supports (color:color-mix(in lab, red, red)){.border-yellow-400\/50{border-color:color-mix(in oklab,var(--color-yellow-400)50%,transparent)}}.border-yellow-500{border-color:var(--color-yellow-500)}.border-yellow-500\/20{border-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/20{border-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/50{border-color:#edb20080}@supports (color:color-mix(in lab, red, red)){.border-yellow-500\/50{border-color:color-mix(in oklab,var(--color-yellow-500)50%,transparent)}}.border-zinc-500{border-color:var(--color-zinc-500)}.border-zinc-600{border-color:var(--color-zinc-600)}.border-zinc-700{border-color:var(--color-zinc-700)}.border-zinc-700\/50{border-color:#3f3f4680}@supports (color:color-mix(in lab, red, red)){.border-zinc-700\/50{border-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.border-zinc-800{border-color:var(--color-zinc-800)}.border-t-bambu-dark-tertiary{border-top-color:var(--color-bambu-dark-tertiary)}.border-t-transparent{border-top-color:#0000}.border-r-transparent{border-right-color:#0000}.border-b-bambu-dark-tertiary{border-bottom-color:var(--color-bambu-dark-tertiary)}.border-l-blue-500{border-left-color:var(--color-blue-500)}.border-l-cyan-400{border-left-color:var(--color-cyan-400)}.border-l-emerald-500{border-left-color:var(--color-emerald-500)}.border-l-gray-500{border-left-color:var(--color-gray-500)}.border-l-red-500{border-left-color:var(--color-red-500)}.border-l-transparent{border-left-color:#0000}.border-l-yellow-500{border-left-color:var(--color-yellow-500)}.\!bg-bambu-green{background-color:var(--color-bambu-green)!important}.bg-amber-50{background-color:var(--color-amber-50)}.bg-amber-100\/60{background-color:#fef3c699}@supports (color:color-mix(in lab, red, red)){.bg-amber-100\/60{background-color:color-mix(in oklab,var(--color-amber-100)60%,transparent)}}.bg-amber-400\/10{background-color:#fcbb001a}@supports (color:color-mix(in lab, red, red)){.bg-amber-400\/10{background-color:color-mix(in oklab,var(--color-amber-400)10%,transparent)}}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/15{background-color:#f99c0026}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/15{background-color:color-mix(in oklab,var(--color-amber-500)15%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-amber-600{background-color:var(--color-amber-600)}.bg-amber-600\/20{background-color:#dd740033}@supports (color:color-mix(in lab, red, red)){.bg-amber-600\/20{background-color:color-mix(in oklab,var(--color-amber-600)20%,transparent)}}.bg-amber-900\/20{background-color:#7b330633}@supports (color:color-mix(in lab, red, red)){.bg-amber-900\/20{background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.bg-amber-900\/30{background-color:#7b33064d}@supports (color:color-mix(in lab, red, red)){.bg-amber-900\/30{background-color:color-mix(in oklab,var(--color-amber-900)30%,transparent)}}.bg-bambu-dark{background-color:var(--color-bambu-dark)}.bg-bambu-dark-secondary,.bg-bambu-dark-secondary\/30{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)30%,transparent)}}.bg-bambu-dark-secondary\/50{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.bg-bambu-dark-secondary\/60{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/60{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)60%,transparent)}}.bg-bambu-dark-secondary\/90{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/90{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)90%,transparent)}}.bg-bambu-dark-secondary\/95{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-secondary\/95{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)95%,transparent)}}.bg-bambu-dark-tertiary,.bg-bambu-dark-tertiary\/10{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/10{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)10%,transparent)}}.bg-bambu-dark-tertiary\/20{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/20{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)20%,transparent)}}.bg-bambu-dark-tertiary\/30{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/30{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.bg-bambu-dark-tertiary\/40{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/40{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.bg-bambu-dark-tertiary\/50{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/50{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.bg-bambu-dark-tertiary\/70{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/70{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.bg-bambu-dark-tertiary\/80{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark-tertiary\/80{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.bg-bambu-dark\/20{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/20{background-color:color-mix(in oklab,var(--color-bambu-dark)20%,transparent)}}.bg-bambu-dark\/30{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/30{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.bg-bambu-dark\/40{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/40{background-color:color-mix(in oklab,var(--color-bambu-dark)40%,transparent)}}.bg-bambu-dark\/50{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/50{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.bg-bambu-dark\/80{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/80{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.bg-bambu-dark\/90{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-dark\/90{background-color:color-mix(in oklab,var(--color-bambu-dark)90%,transparent)}}.bg-bambu-gray,.bg-bambu-gray\/10{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/10{background-color:color-mix(in oklab,var(--color-bambu-gray)10%,transparent)}}.bg-bambu-gray\/20{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/20{background-color:color-mix(in oklab,var(--color-bambu-gray)20%,transparent)}}.bg-bambu-gray\/30{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/30{background-color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.bg-bambu-gray\/40{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/40{background-color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.bg-bambu-gray\/50{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/50{background-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.bg-bambu-gray\/60{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/60{background-color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.bg-bambu-gray\/90{background-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-gray\/90{background-color:color-mix(in oklab,var(--color-bambu-gray)90%,transparent)}}.bg-bambu-green,.bg-bambu-green\/5{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/5{background-color:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.bg-bambu-green\/10{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/10{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.bg-bambu-green\/15{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/15{background-color:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.bg-bambu-green\/20{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/20{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.bg-bambu-green\/30{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/30{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.bg-bambu-green\/50{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/50{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.bg-bambu-green\/75{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/75{background-color:color-mix(in oklab,var(--color-bambu-green)75%,transparent)}}.bg-bambu-green\/90{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.bg-bambu-green\/90{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/15{background-color:#00000026}@supports (color:color-mix(in lab, red, red)){.bg-black\/15{background-color:color-mix(in oklab,var(--color-black)15%,transparent)}}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab, red, red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.bg-black\/30{background-color:#0000004d}@supports (color:color-mix(in lab, red, red)){.bg-black\/30{background-color:color-mix(in oklab,var(--color-black)30%,transparent)}}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab, red, red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/70{background-color:#000000b3}@supports (color:color-mix(in lab, red, red)){.bg-black\/70{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.bg-black\/80{background-color:#000c}@supports (color:color-mix(in lab, red, red)){.bg-black\/80{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab, red, red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-100{background-color:var(--color-blue-100)}.bg-blue-300{background-color:var(--color-blue-300)}.bg-blue-400{background-color:var(--color-blue-400)}.bg-blue-400\/10{background-color:#54a2ff1a}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/10{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.bg-blue-400\/15{background-color:#54a2ff26}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/15{background-color:color-mix(in oklab,var(--color-blue-400)15%,transparent)}}.bg-blue-400\/20{background-color:#54a2ff33}@supports (color:color-mix(in lab, red, red)){.bg-blue-400\/20{background-color:color-mix(in oklab,var(--color-blue-400)20%,transparent)}}.bg-blue-500{background-color:var(--color-blue-500)}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/15{background-color:#3080ff26}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/15{background-color:color-mix(in oklab,var(--color-blue-500)15%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-500\/30{background-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/30{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.bg-blue-500\/90{background-color:#3080ffe6}@supports (color:color-mix(in lab, red, red)){.bg-blue-500\/90{background-color:color-mix(in oklab,var(--color-blue-500)90%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-blue-600\/20{background-color:#155dfc33}@supports (color:color-mix(in lab, red, red)){.bg-blue-600\/20{background-color:color-mix(in oklab,var(--color-blue-600)20%,transparent)}}.bg-blue-700{background-color:var(--color-blue-700)}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/15{background-color:#00b7d726}@supports (color:color-mix(in lab, red, red)){.bg-cyan-500\/15{background-color:color-mix(in oklab,var(--color-cyan-500)15%,transparent)}}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab, red, red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-cyan-600\/20{background-color:#0092b533}@supports (color:color-mix(in lab, red, red)){.bg-cyan-600\/20{background-color:color-mix(in oklab,var(--color-cyan-600)20%,transparent)}}.bg-emerald-500\/10{background-color:#00bb7f1a}@supports (color:color-mix(in lab, red, red)){.bg-emerald-500\/10{background-color:color-mix(in oklab,var(--color-emerald-500)10%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab, red, red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-emerald-600\/20{background-color:#00976733}@supports (color:color-mix(in lab, red, red)){.bg-emerald-600\/20{background-color:color-mix(in oklab,var(--color-emerald-600)20%,transparent)}}.bg-emerald-700{background-color:var(--color-emerald-700)}.bg-fuchsia-500{background-color:var(--color-fuchsia-500)}.bg-fuchsia-500\/20{background-color:#e12afb33}@supports (color:color-mix(in lab, red, red)){.bg-fuchsia-500\/20{background-color:color-mix(in oklab,var(--color-fuchsia-500)20%,transparent)}}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-400\/10{background-color:#99a1af1a}@supports (color:color-mix(in lab, red, red)){.bg-gray-400\/10{background-color:color-mix(in oklab,var(--color-gray-400)10%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/15{background-color:#6a728226}@supports (color:color-mix(in lab, red, red)){.bg-gray-500\/15{background-color:color-mix(in oklab,var(--color-gray-500)15%,transparent)}}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab, red, red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-50{background-color:var(--color-green-50)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-400{background-color:var(--color-green-400)}.bg-green-400\/10{background-color:#05df721a}@supports (color:color-mix(in lab, red, red)){.bg-green-400\/10{background-color:color-mix(in oklab,var(--color-green-400)10%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/10{background-color:#00c7581a}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/10{background-color:color-mix(in oklab,var(--color-green-500)10%,transparent)}}.bg-green-500\/15{background-color:#00c75826}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/15{background-color:color-mix(in oklab,var(--color-green-500)15%,transparent)}}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab, red, red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-green-600\/20{background-color:#00a54433}@supports (color:color-mix(in lab, red, red)){.bg-green-600\/20{background-color:color-mix(in oklab,var(--color-green-600)20%,transparent)}}.bg-green-600\/40{background-color:#00a54466}@supports (color:color-mix(in lab, red, red)){.bg-green-600\/40{background-color:color-mix(in oklab,var(--color-green-600)40%,transparent)}}.bg-green-700{background-color:var(--color-green-700)}.bg-green-900\/30{background-color:#0d542b4d}@supports (color:color-mix(in lab, red, red)){.bg-green-900\/30{background-color:color-mix(in oklab,var(--color-green-900)30%,transparent)}}.bg-green-900\/50{background-color:#0d542b80}@supports (color:color-mix(in lab, red, red)){.bg-green-900\/50{background-color:color-mix(in oklab,var(--color-green-900)50%,transparent)}}.bg-indigo-500\/10{background-color:#625fff1a}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/10{background-color:color-mix(in oklab,var(--color-indigo-500)10%,transparent)}}.bg-indigo-500\/15{background-color:#625fff26}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/15{background-color:color-mix(in oklab,var(--color-indigo-500)15%,transparent)}}.bg-indigo-500\/20{background-color:#625fff33}@supports (color:color-mix(in lab, red, red)){.bg-indigo-500\/20{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.bg-lime-500{background-color:var(--color-lime-500)}.bg-lime-500\/20{background-color:#80cd0033}@supports (color:color-mix(in lab, red, red)){.bg-lime-500\/20{background-color:color-mix(in oklab,var(--color-lime-500)20%,transparent)}}.bg-orange-400\/10{background-color:#ff8b1a1a}@supports (color:color-mix(in lab, red, red)){.bg-orange-400\/10{background-color:color-mix(in oklab,var(--color-orange-400)10%,transparent)}}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab, red, red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-orange-600{background-color:var(--color-orange-600)}.bg-orange-600\/20{background-color:#f0510033}@supports (color:color-mix(in lab, red, red)){.bg-orange-600\/20{background-color:color-mix(in oklab,var(--color-orange-600)20%,transparent)}}.bg-pink-500\/20{background-color:#f6339a33}@supports (color:color-mix(in lab, red, red)){.bg-pink-500\/20{background-color:color-mix(in oklab,var(--color-pink-500)20%,transparent)}}.bg-purple-400\/10{background-color:#c07eff1a}@supports (color:color-mix(in lab, red, red)){.bg-purple-400\/10{background-color:color-mix(in oklab,var(--color-purple-400)10%,transparent)}}.bg-purple-500{background-color:var(--color-purple-500)}.bg-purple-500\/10{background-color:#ac4bff1a}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/10{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-purple-500\/80{background-color:#ac4bffcc}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/80{background-color:color-mix(in oklab,var(--color-purple-500)80%,transparent)}}.bg-purple-500\/90{background-color:#ac4bffe6}@supports (color:color-mix(in lab, red, red)){.bg-purple-500\/90{background-color:color-mix(in oklab,var(--color-purple-500)90%,transparent)}}.bg-purple-700{background-color:var(--color-purple-700)}.bg-red-50{background-color:var(--color-red-50)}.bg-red-100{background-color:var(--color-red-100)}.bg-red-400{background-color:var(--color-red-400)}.bg-red-500{background-color:var(--color-red-500)}.bg-red-500\/5{background-color:#fb2c360d}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/5{background-color:color-mix(in oklab,var(--color-red-500)5%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/15{background-color:#fb2c3626}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/15{background-color:color-mix(in oklab,var(--color-red-500)15%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-500\/30{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/30{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.bg-red-500\/40{background-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/40{background-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.bg-red-500\/80{background-color:#fb2c36cc}@supports (color:color-mix(in lab, red, red)){.bg-red-500\/80{background-color:color-mix(in oklab,var(--color-red-500)80%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-red-600\/20{background-color:#e4001433}@supports (color:color-mix(in lab, red, red)){.bg-red-600\/20{background-color:color-mix(in oklab,var(--color-red-600)20%,transparent)}}.bg-red-900\/20{background-color:#82181a33}@supports (color:color-mix(in lab, red, red)){.bg-red-900\/20{background-color:color-mix(in oklab,var(--color-red-900)20%,transparent)}}.bg-red-900\/30{background-color:#82181a4d}@supports (color:color-mix(in lab, red, red)){.bg-red-900\/30{background-color:color-mix(in oklab,var(--color-red-900)30%,transparent)}}.bg-red-950\/70{background-color:#460809b3}@supports (color:color-mix(in lab, red, red)){.bg-red-950\/70{background-color:color-mix(in oklab,var(--color-red-950)70%,transparent)}}.bg-rose-500\/20{background-color:#ff235733}@supports (color:color-mix(in lab, red, red)){.bg-rose-500\/20{background-color:color-mix(in oklab,var(--color-rose-500)20%,transparent)}}.bg-rose-600\/20{background-color:#e7004433}@supports (color:color-mix(in lab, red, red)){.bg-rose-600\/20{background-color:color-mix(in oklab,var(--color-rose-600)20%,transparent)}}.bg-sky-500{background-color:var(--color-sky-500)}.bg-sky-500\/10{background-color:#00a5ef1a}@supports (color:color-mix(in lab, red, red)){.bg-sky-500\/10{background-color:color-mix(in oklab,var(--color-sky-500)10%,transparent)}}.bg-sky-500\/20{background-color:#00a5ef33}@supports (color:color-mix(in lab, red, red)){.bg-sky-500\/20{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.bg-status-error,.bg-status-error\/10{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/10{background-color:color-mix(in oklab,var(--color-status-error)10%,transparent)}}.bg-status-error\/20{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/20{background-color:color-mix(in oklab,var(--color-status-error)20%,transparent)}}.bg-status-error\/80{background-color:var(--color-status-error)}@supports (color:color-mix(in lab, red, red)){.bg-status-error\/80{background-color:color-mix(in oklab,var(--color-status-error)80%,transparent)}}.bg-status-ok,.bg-status-ok\/10{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.bg-status-ok\/10{background-color:color-mix(in oklab,var(--color-status-ok)10%,transparent)}}.bg-status-ok\/20{background-color:var(--color-status-ok)}@supports (color:color-mix(in lab, red, red)){.bg-status-ok\/20{background-color:color-mix(in oklab,var(--color-status-ok)20%,transparent)}}.bg-status-warning,.bg-status-warning\/10{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.bg-status-warning\/10{background-color:color-mix(in oklab,var(--color-status-warning)10%,transparent)}}.bg-status-warning\/20{background-color:var(--color-status-warning)}@supports (color:color-mix(in lab, red, red)){.bg-status-warning\/20{background-color:color-mix(in oklab,var(--color-status-warning)20%,transparent)}}.bg-teal-500{background-color:var(--color-teal-500)}.bg-teal-500\/20{background-color:#00baa733}@supports (color:color-mix(in lab, red, red)){.bg-teal-500\/20{background-color:color-mix(in oklab,var(--color-teal-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-violet-500{background-color:var(--color-violet-500)}.bg-white{background-color:var(--color-white)}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab, red, red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-white\/50{background-color:#ffffff80}@supports (color:color-mix(in lab, red, red)){.bg-white\/50{background-color:color-mix(in oklab,var(--color-white)50%,transparent)}}.bg-white\/70{background-color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.bg-white\/70{background-color:color-mix(in oklab,var(--color-white)70%,transparent)}}.bg-white\/90{background-color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.bg-white\/90{background-color:color-mix(in oklab,var(--color-white)90%,transparent)}}.bg-yellow-400{background-color:var(--color-yellow-400)}.bg-yellow-400\/10{background-color:#fac8001a}@supports (color:color-mix(in lab, red, red)){.bg-yellow-400\/10{background-color:color-mix(in oklab,var(--color-yellow-400)10%,transparent)}}.bg-yellow-400\/20{background-color:#fac80033}@supports (color:color-mix(in lab, red, red)){.bg-yellow-400\/20{background-color:color-mix(in oklab,var(--color-yellow-400)20%,transparent)}}.bg-yellow-500{background-color:var(--color-yellow-500)}.bg-yellow-500\/5{background-color:#edb2000d}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/5{background-color:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.bg-yellow-500\/10{background-color:#edb2001a}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/10{background-color:color-mix(in oklab,var(--color-yellow-500)10%,transparent)}}.bg-yellow-500\/15{background-color:#edb20026}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/15{background-color:color-mix(in oklab,var(--color-yellow-500)15%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-yellow-700{background-color:var(--color-yellow-700)}.bg-zinc-600{background-color:var(--color-zinc-600)}.bg-zinc-700{background-color:var(--color-zinc-700)}.bg-zinc-800{background-color:var(--color-zinc-800)}.bg-zinc-800\/50{background-color:#27272a80}@supports (color:color-mix(in lab, red, red)){.bg-zinc-800\/50{background-color:color-mix(in oklab,var(--color-zinc-800)50%,transparent)}}.bg-zinc-800\/60{background-color:#27272a99}@supports (color:color-mix(in lab, red, red)){.bg-zinc-800\/60{background-color:color-mix(in oklab,var(--color-zinc-800)60%,transparent)}}.bg-zinc-900{background-color:var(--color-zinc-900)}.bg-zinc-900\/50{background-color:#18181b80}@supports (color:color-mix(in lab, red, red)){.bg-zinc-900\/50{background-color:color-mix(in oklab,var(--color-zinc-900)50%,transparent)}}.bg-gradient-to-b{--tw-gradient-position:to bottom in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-t{--tw-gradient-position:to top in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-bambu-dark-secondary{--tw-gradient-from:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-bambu-green\/15{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.from-bambu-green\/15{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)15%,transparent)}}.from-bambu-green\/15{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-black\/80{--tw-gradient-from:#000c}@supports (color:color-mix(in lab, red, red)){.from-black\/80{--tw-gradient-from:color-mix(in oklab,var(--color-black)80%,transparent)}}.from-black\/80{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/5{--tw-gradient-from:#3080ff0d}@supports (color:color-mix(in lab, red, red)){.from-blue-500\/5{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.from-blue-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-white\/10{--tw-gradient-from:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.from-white\/10{--tw-gradient-from:color-mix(in oklab,var(--color-white)10%,transparent)}}.from-white\/10{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-bambu-green\/5{--tw-gradient-via:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.via-bambu-green\/5{--tw-gradient-via:color-mix(in oklab,var(--color-bambu-green)5%,transparent)}}.via-bambu-green\/5{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.via-black\/60{--tw-gradient-via:#0009}@supports (color:color-mix(in lab, red, red)){.via-black\/60{--tw-gradient-via:color-mix(in oklab,var(--color-black)60%,transparent)}}.via-black\/60{--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-bambu-dark-secondary{--tw-gradient-to:var(--color-bambu-dark-secondary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-bambu-dark-tertiary{--tw-gradient-to:var(--color-bambu-dark-tertiary);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-transparent{--tw-gradient-to:transparent;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-cover{background-size:cover}.bg-center{background-position:50%}.fill-yellow-400{fill:var(--color-yellow-400)}.object-contain{object-fit:contain}.object-cover{object-fit:cover}.object-left{object-position:left}.p-0{padding:calc(var(--spacing)*0)}.p-0\.5{padding:calc(var(--spacing)*.5)}.p-1{padding:calc(var(--spacing)*1)}.p-1\.5{padding:calc(var(--spacing)*1.5)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.p-12{padding:calc(var(--spacing)*12)}.\!px-0{padding-inline:calc(var(--spacing)*0)!important}.\!px-2{padding-inline:calc(var(--spacing)*2)!important}.\!px-3{padding-inline:calc(var(--spacing)*3)!important}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-2\.5{padding-inline:calc(var(--spacing)*2.5)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.\!py-0{padding-block:calc(var(--spacing)*0)!important}.py-0{padding-block:calc(var(--spacing)*0)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.py-24{padding-block:calc(var(--spacing)*24)}.py-px{padding-block:1px}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-0\.5{padding-top:calc(var(--spacing)*.5)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-2\.5{padding-top:calc(var(--spacing)*2.5)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-3{padding-right:calc(var(--spacing)*3)}.pr-4{padding-right:calc(var(--spacing)*4)}.pr-6{padding-right:calc(var(--spacing)*6)}.pr-7{padding-right:calc(var(--spacing)*7)}.pr-8{padding-right:calc(var(--spacing)*8)}.pr-9{padding-right:calc(var(--spacing)*9)}.pr-10{padding-right:calc(var(--spacing)*10)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-1{padding-left:calc(var(--spacing)*1)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-3{padding-left:calc(var(--spacing)*3)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-5{padding-left:calc(var(--spacing)*5)}.pl-6{padding-left:calc(var(--spacing)*6)}.pl-7{padding-left:calc(var(--spacing)*7)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-9{padding-left:calc(var(--spacing)*9)}.pl-10{padding-left:calc(var(--spacing)*10)}.pl-20{padding-left:calc(var(--spacing)*20)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-5xl{font-size:var(--text-5xl);line-height:var(--tw-leading,var(--text-5xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[6px\]{font-size:6px}.text-\[7px\]{font-size:7px}.text-\[8px\]{font-size:8px}.text-\[9px\]{font-size:9px}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing)*5);line-height:calc(var(--spacing)*5)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-light{--tw-font-weight:var(--font-weight-light);font-weight:var(--font-weight-light)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.\!text-white{color:var(--color-white)!important}.text-amber-200{color:var(--color-amber-200)}.text-amber-200\/60{color:#fee68599}@supports (color:color-mix(in lab, red, red)){.text-amber-200\/60{color:color-mix(in oklab,var(--color-amber-200)60%,transparent)}}.text-amber-200\/80{color:#fee685cc}@supports (color:color-mix(in lab, red, red)){.text-amber-200\/80{color:color-mix(in oklab,var(--color-amber-200)80%,transparent)}}.text-amber-300{color:var(--color-amber-300)}.text-amber-300\/60{color:#ffd23699}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/60{color:color-mix(in oklab,var(--color-amber-300)60%,transparent)}}.text-amber-300\/70{color:#ffd236b3}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/70{color:color-mix(in oklab,var(--color-amber-300)70%,transparent)}}.text-amber-300\/80{color:#ffd236cc}@supports (color:color-mix(in lab, red, red)){.text-amber-300\/80{color:color-mix(in oklab,var(--color-amber-300)80%,transparent)}}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/70{color:#fcbb00b3}@supports (color:color-mix(in lab, red, red)){.text-amber-400\/70{color:color-mix(in oklab,var(--color-amber-400)70%,transparent)}}.text-amber-500{color:var(--color-amber-500)}.text-amber-500\/80{color:#f99c00cc}@supports (color:color-mix(in lab, red, red)){.text-amber-500\/80{color:color-mix(in oklab,var(--color-amber-500)80%,transparent)}}.text-amber-600{color:var(--color-amber-600)}.text-amber-700{color:var(--color-amber-700)}.text-amber-800{color:var(--color-amber-800)}.text-amber-900{color:var(--color-amber-900)}.text-bambu-dark{color:var(--color-bambu-dark)}.text-bambu-dark-tertiary{color:var(--color-bambu-dark-tertiary)}.text-bambu-gray{color:var(--color-bambu-gray)}.text-bambu-gray-dark{color:var(--color-bambu-gray-dark)}.text-bambu-gray-light{color:var(--color-bambu-gray-light)}.text-bambu-gray\/30{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/30{color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.text-bambu-gray\/40{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/40{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.text-bambu-gray\/50{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/50{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.text-bambu-gray\/60{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/60{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.text-bambu-gray\/70{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/70{color:color-mix(in oklab,var(--color-bambu-gray)70%,transparent)}}.text-bambu-gray\/80{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.text-bambu-gray\/80{color:color-mix(in oklab,var(--color-bambu-gray)80%,transparent)}}.text-bambu-green,.text-bambu-green\/50{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/50{color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.text-bambu-green\/60{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/60{color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.text-bambu-green\/70{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.text-bambu-green\/70{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.text-black{color:var(--color-black)}.text-black\/80{color:#000c}@supports (color:color-mix(in lab, red, red)){.text-black\/80{color:color-mix(in oklab,var(--color-black)80%,transparent)}}.text-blue-100{color:var(--color-blue-100)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/70{color:#90c5ffb3}@supports (color:color-mix(in lab, red, red)){.text-blue-300\/70{color:color-mix(in oklab,var(--color-blue-300)70%,transparent)}}.text-blue-300\/80{color:#90c5ffcc}@supports (color:color-mix(in lab, red, red)){.text-blue-300\/80{color:color-mix(in oklab,var(--color-blue-300)80%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-500\/70{color:#3080ffb3}@supports (color:color-mix(in lab, red, red)){.text-blue-500\/70{color:color-mix(in oklab,var(--color-blue-500)70%,transparent)}}.text-blue-600{color:var(--color-blue-600)}.text-blue-700{color:var(--color-blue-700)}.text-cyan-300{color:var(--color-cyan-300)}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-100{color:var(--color-emerald-100)}.text-emerald-300{color:var(--color-emerald-300)}.text-emerald-400{color:var(--color-emerald-400)}.text-emerald-600{color:var(--color-emerald-600)}.text-emerald-700{color:var(--color-emerald-700)}.text-fuchsia-300{color:var(--color-fuchsia-300)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-gray-800{color:var(--color-gray-800)}.text-gray-900{color:var(--color-gray-900)}.text-green-200{color:var(--color-green-200)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-400\/60{color:#05df7299}@supports (color:color-mix(in lab, red, red)){.text-green-400\/60{color:color-mix(in oklab,var(--color-green-400)60%,transparent)}}.text-green-400\/70{color:#05df72b3}@supports (color:color-mix(in lab, red, red)){.text-green-400\/70{color:color-mix(in oklab,var(--color-green-400)70%,transparent)}}.text-green-500{color:var(--color-green-500)}.text-green-500\/60{color:#00c75899}@supports (color:color-mix(in lab, red, red)){.text-green-500\/60{color:color-mix(in oklab,var(--color-green-500)60%,transparent)}}.text-green-600{color:var(--color-green-600)}.text-green-700{color:var(--color-green-700)}.text-green-800{color:var(--color-green-800)}.text-indigo-300{color:var(--color-indigo-300)}.text-indigo-400{color:var(--color-indigo-400)}.text-lime-400{color:var(--color-lime-400)}.text-orange-100{color:var(--color-orange-100)}.text-orange-200{color:var(--color-orange-200)}.text-orange-200\/70{color:#ffd7a8b3}@supports (color:color-mix(in lab, red, red)){.text-orange-200\/70{color:color-mix(in oklab,var(--color-orange-200)70%,transparent)}}.text-orange-300{color:var(--color-orange-300)}.text-orange-400{color:var(--color-orange-400)}.text-orange-500{color:var(--color-orange-500)}.text-orange-600{color:var(--color-orange-600)}.text-orange-700{color:var(--color-orange-700)}.text-pink-400{color:var(--color-pink-400)}.text-purple-300{color:var(--color-purple-300)}.text-purple-300\/70{color:#d9b3ffb3}@supports (color:color-mix(in lab, red, red)){.text-purple-300\/70{color:color-mix(in oklab,var(--color-purple-300)70%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-purple-400\/80{color:#c07effcc}@supports (color:color-mix(in lab, red, red)){.text-purple-400\/80{color:color-mix(in oklab,var(--color-purple-400)80%,transparent)}}.text-red-200{color:var(--color-red-200)}.text-red-300{color:var(--color-red-300)}.text-red-300\/80{color:#ffa3a3cc}@supports (color:color-mix(in lab, red, red)){.text-red-300\/80{color:color-mix(in oklab,var(--color-red-300)80%,transparent)}}.text-red-400{color:var(--color-red-400)}.text-red-400\/50{color:#ff656880}@supports (color:color-mix(in lab, red, red)){.text-red-400\/50{color:color-mix(in oklab,var(--color-red-400)50%,transparent)}}.text-red-400\/60{color:#ff656899}@supports (color:color-mix(in lab, red, red)){.text-red-400\/60{color:color-mix(in oklab,var(--color-red-400)60%,transparent)}}.text-red-400\/70{color:#ff6568b3}@supports (color:color-mix(in lab, red, red)){.text-red-400\/70{color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.text-red-500{color:var(--color-red-500)}.text-red-600{color:var(--color-red-600)}.text-rose-300{color:var(--color-rose-300)}.text-rose-400{color:var(--color-rose-400)}.text-sky-400{color:var(--color-sky-400)}.text-slate-300{color:var(--color-slate-300)}.text-status-error{color:var(--color-status-error)}.text-status-ok{color:var(--color-status-ok)}.text-status-warning{color:var(--color-status-warning)}.text-teal-400{color:var(--color-teal-400)}.text-white{color:var(--color-white)}.text-white\/30{color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.text-white\/30{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab, red, red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab, red, red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab, red, red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab, red, red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-white\/90{color:#ffffffe6}@supports (color:color-mix(in lab, red, red)){.text-white\/90{color:color-mix(in oklab,var(--color-white)90%,transparent)}}.text-yellow-100{color:var(--color-yellow-100)}.text-yellow-200{color:var(--color-yellow-200)}.text-yellow-200\/70{color:#fff085b3}@supports (color:color-mix(in lab, red, red)){.text-yellow-200\/70{color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}.text-yellow-300{color:var(--color-yellow-300)}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-500{color:var(--color-yellow-500)}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab, red, red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.text-yellow-500\/80{color:#edb200cc}@supports (color:color-mix(in lab, red, red)){.text-yellow-500\/80{color:color-mix(in oklab,var(--color-yellow-500)80%,transparent)}}.text-yellow-600{color:var(--color-yellow-600)}.text-yellow-700{color:var(--color-yellow-700)}.text-zinc-100{color:var(--color-zinc-100)}.text-zinc-200{color:var(--color-zinc-200)}.text-zinc-300{color:var(--color-zinc-300)}.text-zinc-400{color:var(--color-zinc-400)}.text-zinc-500{color:var(--color-zinc-500)}.text-zinc-600{color:var(--color-zinc-600)}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.line-through{text-decoration-line:line-through}.underline{text-decoration-line:underline}.placeholder-bambu-gray::placeholder{color:var(--color-bambu-gray)}.placeholder-bambu-gray-dark::placeholder{color:var(--color-bambu-gray-dark)}.placeholder-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.placeholder-gray-400::placeholder{color:var(--color-gray-400)}.placeholder-white\/30::placeholder{color:#ffffff4d}@supports (color:color-mix(in lab, red, red)){.placeholder-white\/30::placeholder{color:color-mix(in oklab,var(--color-white)30%,transparent)}}.placeholder-zinc-500::placeholder{color:var(--color-zinc-500)}.accent-bambu-green{accent-color:var(--color-bambu-green)}.accent-green-500{accent-color:var(--color-green-500)}.accent-red-500{accent-color:var(--color-red-500)}.\[color-scheme\:dark\]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}.opacity-0{opacity:0}.opacity-20{opacity:.2}.opacity-25{opacity:.25}.opacity-30{opacity:.3}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.opacity-75{opacity:.75}.opacity-80{opacity:.8}.opacity-90{opacity:.9}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_6px_rgba\(34\,197\,94\,0\.5\)\]{--tw-shadow:0 0 6px var(--tw-shadow-color,#22c55e80);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[0_0_8px_rgba\(248\,113\,113\,0\.6\)\]{--tw-shadow:0 0 8px var(--tw-shadow-color,#f8717199);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow\/depth{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-bambu-green\/20{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.shadow-bambu-green\/20{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)20%,transparent)var(--tw-shadow-alpha),transparent)}}.shadow-bambu-green\/25{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.shadow-bambu-green\/25{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)25%,transparent)var(--tw-shadow-alpha),transparent)}}.ring-bambu-green,.ring-bambu-green\/30{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.ring-bambu-green\/30{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.ring-blue-400\/50{--tw-ring-color:#54a2ff80}@supports (color:color-mix(in lab, red, red)){.ring-blue-400\/50{--tw-ring-color:color-mix(in oklab,var(--color-blue-400)50%,transparent)}}.ring-green-500{--tw-ring-color:var(--color-green-500)}.ring-white{--tw-ring-color:var(--color-white)}.ring-offset-1{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-2{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.ring-offset-bambu-dark{--tw-ring-offset-color:var(--color-bambu-dark)}.ring-offset-bambu-dark-secondary{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-2xl{--tw-blur:blur(var(--blur-2xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-lg{--tw-drop-shadow-size:drop-shadow(0 4px 4px var(--tw-drop-shadow-color,#00000026));--tw-drop-shadow:drop-shadow(var(--drop-shadow-lg));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow-md{--tw-drop-shadow-size:drop-shadow(0 3px 3px var(--tw-drop-shadow-color,#0000001f));--tw-drop-shadow:drop-shadow(var(--drop-shadow-md));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.\!filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)!important}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.backdrop-blur-sm{--tw-backdrop-blur:blur(var(--blur-sm));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.duration-500{--tw-duration:.5s;transition-duration:.5s}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-all{-webkit-user-select:all;user-select:all}.select-none{-webkit-user-select:none;user-select:none}@media (hover:hover){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.group-hover\:bg-bambu-green\/20:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.group-hover\:bg-bambu-green\/30:is(:where(.group):hover *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.group-hover\:bg-bambu-green\/30:is(:where(.group):hover *){background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.group-hover\:break-all:is(:where(.group):hover *){word-break:break-all}.group-hover\:whitespace-normal:is(:where(.group):hover *){white-space:normal}.group-hover\:text-bambu-gray:is(:where(.group):hover *){color:var(--color-bambu-gray)}.group-hover\:text-bambu-green:is(:where(.group):hover *){color:var(--color-bambu-green)}.group-hover\:opacity-100:is(:where(.group):hover *),.group-hover\/resize\:opacity-100:is(:where(.group\/resize):hover *){opacity:1}.group-hover\/thumb\:block:is(:where(.group\/thumb):hover *){display:block}}.peer-checked\:bg-amber-500:is(:where(.peer):checked~*){background-color:var(--color-amber-500)}.peer-checked\:bg-bambu-green:is(:where(.peer):checked~*){background-color:var(--color-bambu-green)}.peer-focus\:ring-2:is(:where(.peer):focus~*){--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.peer-focus\:ring-bambu-green\/50:is(:where(.peer):focus~*){--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.peer-focus\:ring-bambu-green\/50:is(:where(.peer):focus~*){--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.peer-focus\:outline-none:is(:where(.peer):focus~*){--tw-outline-style:none;outline-style:none}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.placeholder\:text-bambu-gray::placeholder,.placeholder\:text-bambu-gray\/40::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/40::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)40%,transparent)}}.placeholder\:text-bambu-gray\/50::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/50::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.placeholder\:text-bambu-gray\/60::placeholder{color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.placeholder\:text-bambu-gray\/60::placeholder{color:color-mix(in oklab,var(--color-bambu-gray)60%,transparent)}}.before\:absolute:before{content:var(--tw-content);position:absolute}.before\:top-0:before{content:var(--tw-content);top:calc(var(--spacing)*0)}.before\:right-3:before{content:var(--tw-content);right:calc(var(--spacing)*3)}.before\:left-3:before{content:var(--tw-content);left:calc(var(--spacing)*3)}.before\:h-0\.5:before{content:var(--tw-content);height:calc(var(--spacing)*.5)}.before\:bg-bambu-green:before{content:var(--tw-content);background-color:var(--color-bambu-green)}.after\:absolute:after{content:var(--tw-content);position:absolute}.after\:top-0\.5:after{content:var(--tw-content);top:calc(var(--spacing)*.5)}.after\:top-\[2px\]:after{content:var(--tw-content);top:2px}.after\:left-0\.5:after{content:var(--tw-content);left:calc(var(--spacing)*.5)}.after\:left-\[2px\]:after{content:var(--tw-content);left:2px}.after\:h-4:after{content:var(--tw-content);height:calc(var(--spacing)*4)}.after\:h-5:after{content:var(--tw-content);height:calc(var(--spacing)*5)}.after\:w-4:after{content:var(--tw-content);width:calc(var(--spacing)*4)}.after\:w-5:after{content:var(--tw-content);width:calc(var(--spacing)*5)}.after\:rounded-full:after{content:var(--tw-content);border-radius:3.40282e38px}.after\:border:after{content:var(--tw-content);border-style:var(--tw-border-style);border-width:1px}.after\:border-gray-300:after{content:var(--tw-content);border-color:var(--color-gray-300)}.after\:bg-white:after{content:var(--tw-content);background-color:var(--color-white)}.after\:transition-all:after{content:var(--tw-content);transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:transition-transform:after{content:var(--tw-content);transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.after\:content-\[\'\'\]:after{--tw-content:"";content:var(--tw-content)}.peer-checked\:after\:translate-x-5:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:calc(var(--spacing)*5);translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:translate-x-full:is(:where(.peer):checked~*):after{content:var(--tw-content);--tw-translate-x:100%;translate:var(--tw-translate-x)var(--tw-translate-y)}.peer-checked\:after\:border-white:is(:where(.peer):checked~*):after{content:var(--tw-content);border-color:var(--color-white)}.last\:border-0:last-child{border-style:var(--tw-border-style);border-width:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.focus-within\:border-bambu-green:focus-within{border-color:var(--color-bambu-green)}@media (hover:hover){.hover\:z-10:hover{z-index:10}.hover\:z-20:hover{z-index:20}.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:scale-110:hover{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x)var(--tw-scale-y)}.hover\:border-amber-500:hover{border-color:var(--color-amber-500)}.hover\:border-bambu-dark-tertiary\/80:hover{border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-dark-tertiary\/80:hover{border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:border-bambu-gray:hover{border-color:var(--color-bambu-gray)}.hover\:border-bambu-gray-dark:hover{border-color:var(--color-bambu-gray-dark)}.hover\:border-bambu-gray\/50:hover{border-color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-gray\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.hover\:border-bambu-green:hover,.hover\:border-bambu-green\/40:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-green\/40:hover{border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.hover\:border-bambu-green\/50:hover{border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:border-bambu-green\/50:hover{border-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:border-gray-400:hover{border-color:var(--color-gray-400)}.hover\:border-green-500\/50:hover{border-color:#00c75880}@supports (color:color-mix(in lab, red, red)){.hover\:border-green-500\/50:hover{border-color:color-mix(in oklab,var(--color-green-500)50%,transparent)}}.hover\:border-white:hover{border-color:var(--color-white)}.hover\:border-white\/40:hover{border-color:#fff6}@supports (color:color-mix(in lab, red, red)){.hover\:border-white\/40:hover{border-color:color-mix(in oklab,var(--color-white)40%,transparent)}}.hover\:\!bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)!important}@supports (color:color-mix(in lab, red, red)){.hover\:\!bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)!important}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-amber-700:hover{background-color:var(--color-amber-700)}.hover\:bg-amber-900\/50:hover{background-color:#7b330680}@supports (color:color-mix(in lab, red, red)){.hover\:bg-amber-900\/50:hover{background-color:color-mix(in oklab,var(--color-amber-900)50%,transparent)}}.hover\:bg-bambu-dark:hover{background-color:var(--color-bambu-dark)}.hover\:bg-bambu-dark-secondary:hover,.hover\:bg-bambu-dark-secondary\/50:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-secondary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)50%,transparent)}}.hover\:bg-bambu-dark-secondary\/80:hover{background-color:var(--color-bambu-dark-secondary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-secondary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-secondary)80%,transparent)}}.hover\:bg-bambu-dark-tertiary:hover,.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)30%,transparent)}}.hover\:bg-bambu-dark-tertiary\/40:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/40:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)40%,transparent)}}.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/70:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)70%,transparent)}}.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark-tertiary\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)80%,transparent)}}.hover\:bg-bambu-dark\/30:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)30%,transparent)}}.hover\:bg-bambu-dark\/40:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/40:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)40%,transparent)}}.hover\:bg-bambu-dark\/50:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.hover\:bg-bambu-dark\/80:hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-dark\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-dark)80%,transparent)}}.hover\:bg-bambu-gray-dark:hover{background-color:var(--color-bambu-gray-dark)}.hover\:bg-bambu-green:hover{background-color:var(--color-bambu-green)}.hover\:bg-bambu-green-dark:hover{background-color:var(--color-bambu-green-dark)}.hover\:bg-bambu-green-light:hover{background-color:var(--color-bambu-green-light)}.hover\:bg-bambu-green\/10:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/10:hover{background-color:color-mix(in oklab,var(--color-bambu-green)10%,transparent)}}.hover\:bg-bambu-green\/20:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/20:hover{background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:bg-bambu-green\/30:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/30:hover{background-color:color-mix(in oklab,var(--color-bambu-green)30%,transparent)}}.hover\:bg-bambu-green\/50:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/50:hover{background-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.hover\:bg-bambu-green\/80:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/80:hover{background-color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:bg-bambu-green\/90:hover{background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:bg-bambu-green\/90:hover{background-color:color-mix(in oklab,var(--color-bambu-green)90%,transparent)}}.hover\:bg-black\/10:hover{background-color:#0000001a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/10:hover{background-color:color-mix(in oklab,var(--color-black)10%,transparent)}}.hover\:bg-black\/40:hover{background-color:#0006}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/40:hover{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.hover\:bg-black\/70:hover{background-color:#000000b3}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/70:hover{background-color:color-mix(in oklab,var(--color-black)70%,transparent)}}.hover\:bg-black\/80:hover{background-color:#000c}@supports (color:color-mix(in lab, red, red)){.hover\:bg-black\/80:hover{background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.hover\:bg-blue-400:hover{background-color:var(--color-blue-400)}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-blue-500\/30:hover{background-color:#3080ff4d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-blue-500\/30:hover{background-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.hover\:bg-blue-600:hover{background-color:var(--color-blue-600)}.hover\:bg-blue-700:hover{background-color:var(--color-blue-700)}.hover\:bg-cyan-500\/10:hover{background-color:#00b7d71a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-cyan-500\/10:hover{background-color:color-mix(in oklab,var(--color-cyan-500)10%,transparent)}}.hover\:bg-emerald-600:hover{background-color:var(--color-emerald-600)}.hover\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\:bg-gray-100:hover{background-color:var(--color-gray-100)}.hover\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\:bg-green-400:hover{background-color:var(--color-green-400)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab, red, red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-600:hover{background-color:var(--color-green-600)}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-indigo-500\/20:hover{background-color:#625fff33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-indigo-500\/20:hover{background-color:color-mix(in oklab,var(--color-indigo-500)20%,transparent)}}.hover\:bg-indigo-500\/30:hover{background-color:#625fff4d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-indigo-500\/30:hover{background-color:color-mix(in oklab,var(--color-indigo-500)30%,transparent)}}.hover\:bg-orange-400:hover{background-color:var(--color-orange-400)}.hover\:bg-orange-400\/20:hover{background-color:#ff8b1a33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-400\/20:hover{background-color:color-mix(in oklab,var(--color-orange-400)20%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-500\/30:hover{background-color:#fe6e004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-orange-500\/30:hover{background-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.hover\:bg-purple-400:hover{background-color:var(--color-purple-400)}.hover\:bg-purple-600\/90:hover{background-color:#9810fae6}@supports (color:color-mix(in lab, red, red)){.hover\:bg-purple-600\/90:hover{background-color:color-mix(in oklab,var(--color-purple-600)90%,transparent)}}.hover\:bg-red-200:hover{background-color:var(--color-red-200)}.hover\:bg-red-400:hover{background-color:var(--color-red-400)}.hover\:bg-red-400\/10:hover{background-color:#ff65681a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-400\/10:hover{background-color:color-mix(in oklab,var(--color-red-400)10%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-500\/25:hover{background-color:#fb2c3640}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/25:hover{background-color:color-mix(in oklab,var(--color-red-500)25%,transparent)}}.hover\:bg-red-500\/30:hover{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-500\/30:hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.hover\:bg-red-600:hover{background-color:var(--color-red-600)}.hover\:bg-red-600\/30:hover{background-color:#e400144d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-600\/30:hover{background-color:color-mix(in oklab,var(--color-red-600)30%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-red-900\/50:hover{background-color:#82181a80}@supports (color:color-mix(in lab, red, red)){.hover\:bg-red-900\/50:hover{background-color:color-mix(in oklab,var(--color-red-900)50%,transparent)}}.hover\:bg-sky-500\/20:hover{background-color:#00a5ef33}@supports (color:color-mix(in lab, red, red)){.hover\:bg-sky-500\/20:hover{background-color:color-mix(in oklab,var(--color-sky-500)20%,transparent)}}.hover\:bg-teal-400:hover{background-color:var(--color-teal-400)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/10:hover{background-color:#ffffff1a}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/10:hover{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-white\/80:hover{background-color:#fffc}@supports (color:color-mix(in lab, red, red)){.hover\:bg-white\/80:hover{background-color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/25:hover{background-color:#edb20040}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/25:hover{background-color:color-mix(in oklab,var(--color-yellow-500)25%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab, red, red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:bg-yellow-600:hover{background-color:var(--color-yellow-600)}.hover\:bg-zinc-600:hover{background-color:var(--color-zinc-600)}.hover\:bg-zinc-700:hover{background-color:var(--color-zinc-700)}.hover\:bg-zinc-700\/50:hover{background-color:#3f3f4680}@supports (color:color-mix(in lab, red, red)){.hover\:bg-zinc-700\/50:hover{background-color:color-mix(in oklab,var(--color-zinc-700)50%,transparent)}}.hover\:bg-zinc-700\/60:hover{background-color:#3f3f4699}@supports (color:color-mix(in lab, red, red)){.hover\:bg-zinc-700\/60:hover{background-color:color-mix(in oklab,var(--color-zinc-700)60%,transparent)}}.hover\:bg-zinc-800:hover{background-color:var(--color-zinc-800)}.hover\:from-bambu-green\/20:hover{--tw-gradient-from:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:from-bambu-green\/20:hover{--tw-gradient-from:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.hover\:from-bambu-green\/20:hover{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.hover\:text-amber-100:hover{color:var(--color-amber-100)}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-800:hover{color:var(--color-amber-800)}.hover\:text-bambu-gray:hover{color:var(--color-bambu-gray)}.hover\:text-bambu-green:hover{color:var(--color-bambu-green)}.hover\:text-bambu-green-light:hover{color:var(--color-bambu-green-light)}.hover\:text-bambu-green\/70:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:text-bambu-green\/70:hover{color:color-mix(in oklab,var(--color-bambu-green)70%,transparent)}}.hover\:text-bambu-green\/80:hover{color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:text-bambu-green\/80:hover{color:color-mix(in oklab,var(--color-bambu-green)80%,transparent)}}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-blue-600:hover{color:var(--color-blue-600)}.hover\:text-blue-800:hover{color:var(--color-blue-800)}.hover\:text-cyan-200:hover{color:var(--color-cyan-200)}.hover\:text-gray-600:hover{color:var(--color-gray-600)}.hover\:text-gray-700:hover{color:var(--color-gray-700)}.hover\:text-gray-900:hover{color:var(--color-gray-900)}.hover\:text-orange-300:hover{color:var(--color-orange-300)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-200:hover{color:var(--color-red-200)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-red-800:hover{color:var(--color-red-800)}.hover\:text-white:hover{color:var(--color-white)}.hover\:text-white\/60:hover{color:#fff9}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/60:hover{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.hover\:text-white\/70:hover{color:#ffffffb3}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/70:hover{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.hover\:text-white\/80:hover{color:#fffc}@supports (color:color-mix(in lab, red, red)){.hover\:text-white\/80:hover{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.hover\:text-yellow-400:hover{color:var(--color-yellow-400)}.hover\:text-zinc-200:hover{color:var(--color-zinc-200)}.hover\:text-zinc-300:hover{color:var(--color-zinc-300)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-70:hover{opacity:.7}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-90:hover{opacity:.9}.hover\:opacity-100:hover{opacity:1}.hover\:shadow-lg:hover{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-xl:hover{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:shadow-bambu-green\/5:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)5%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.hover\:shadow-bambu-green\/30:hover{--tw-shadow-color:color-mix(in oklab,color-mix(in oklab,var(--color-bambu-green)30%,transparent)var(--tw-shadow-alpha),transparent)}}.hover\:brightness-110:hover{--tw-brightness:brightness(110%);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}}.focus\:border-amber-500\/50:focus{border-color:#f99c0080}@supports (color:color-mix(in lab, red, red)){.focus\:border-amber-500\/50:focus{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.focus\:border-bambu-gray:focus{border-color:var(--color-bambu-gray)}.focus\:border-bambu-green:focus{border-color:var(--color-bambu-green)}.focus\:border-red-500:focus{border-color:var(--color-red-500)}.focus\:border-transparent:focus{border-color:#0000}.focus\:ring-0:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-bambu-gray:focus{--tw-ring-color:var(--color-bambu-gray)}.focus\:ring-bambu-green:focus,.focus\:ring-bambu-green\/50:focus{--tw-ring-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.focus\:ring-bambu-green\/50:focus{--tw-ring-color:color-mix(in oklab,var(--color-bambu-green)50%,transparent)}}.focus\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\:ring-red-500:focus{--tw-ring-color:var(--color-red-500)}.focus\:ring-offset-0:focus{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:ring-offset-bambu-dark:focus{--tw-ring-offset-color:var(--color-bambu-dark)}.focus\:ring-offset-bambu-dark-secondary:focus{--tw-ring-offset-color:var(--color-bambu-dark-secondary)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:scale-95:active{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x)var(--tw-scale-y)}.active\:cursor-grabbing:active{cursor:grabbing}.active\:bg-amber-500\/30:active{background-color:#f99c004d}@supports (color:color-mix(in lab, red, red)){.active\:bg-amber-500\/30:active{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.active\:opacity-50:active{opacity:.5}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:cursor-wait:disabled{cursor:wait}.disabled\:bg-gray-600:disabled{background-color:var(--color-gray-600)}.disabled\:bg-zinc-700:disabled{background-color:var(--color-zinc-700)}.disabled\:no-underline:disabled{text-decoration-line:none}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:opacity-60:disabled{opacity:.6}@media (hover:hover){.disabled\:hover\:border-bambu-dark-tertiary:disabled:hover{border-color:var(--color-bambu-dark-tertiary)}.disabled\:hover\:bg-bambu-dark:disabled:hover{background-color:var(--color-bambu-dark)}.disabled\:hover\:bg-bambu-green:disabled:hover{background-color:var(--color-bambu-green)}.disabled\:hover\:bg-transparent:disabled:hover{background-color:#0000}.disabled\:hover\:text-bambu-gray:disabled:hover{color:var(--color-bambu-gray)}}@media not all and (width>=640px){.max-\[640px\]\:hidden{display:none}.max-\[640px\]\:w-full{width:100%}.max-\[640px\]\:grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.max-\[640px\]\:flex-col{flex-direction:column}.max-\[640px\]\:flex-wrap{flex-wrap:wrap}.max-\[640px\]\:items-center{align-items:center}.max-\[640px\]\:items-start{align-items:flex-start}}@media not all and (width>=550px){.max-\[550px\]\:order-1{order:1}.max-\[550px\]\:order-2{order:2}.max-\[550px\]\:order-3{order:3}.max-\[550px\]\:order-4{order:4}.max-\[550px\]\:mt-1{margin-top:calc(var(--spacing)*1)}.max-\[550px\]\:w-full{width:100%}.max-\[550px\]\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.max-\[550px\]\:flex-col{flex-direction:column}.max-\[550px\]\:flex-wrap{flex-wrap:wrap}.max-\[550px\]\:items-center{align-items:center}.max-\[550px\]\:items-start{align-items:flex-start}.max-\[550px\]\:justify-end{justify-content:flex-end}.max-\[550px\]\:gap-3{gap:calc(var(--spacing)*3)}}@media not all and (width>=520px){.max-\[520px\]\:h-20{height:calc(var(--spacing)*20)}.max-\[520px\]\:w-20{width:calc(var(--spacing)*20)}}@media (width>=40rem){.sm\:mt-0{margin-top:calc(var(--spacing)*0)}.sm\:mt-2{margin-top:calc(var(--spacing)*2)}.sm\:mt-3{margin-top:calc(var(--spacing)*3)}.sm\:mr-1{margin-right:calc(var(--spacing)*1)}.sm\:mb-4{margin-bottom:calc(var(--spacing)*4)}.sm\:ml-auto{margin-left:auto}.sm\:block{display:block}.sm\:flex{display:flex}.sm\:grid{display:grid}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:h-2{height:calc(var(--spacing)*2)}.sm\:h-3{height:calc(var(--spacing)*3)}.sm\:h-3\.5{height:calc(var(--spacing)*3.5)}.sm\:h-4{height:calc(var(--spacing)*4)}.sm\:h-5{height:calc(var(--spacing)*5)}.sm\:h-6{height:calc(var(--spacing)*6)}.sm\:h-12{height:calc(var(--spacing)*12)}.sm\:h-14{height:calc(var(--spacing)*14)}.sm\:w-3{width:calc(var(--spacing)*3)}.sm\:w-3\.5{width:calc(var(--spacing)*3.5)}.sm\:w-4{width:calc(var(--spacing)*4)}.sm\:w-5{width:calc(var(--spacing)*5)}.sm\:w-6{width:calc(var(--spacing)*6)}.sm\:w-12{width:calc(var(--spacing)*12)}.sm\:w-14{width:calc(var(--spacing)*14)}.sm\:w-16{width:calc(var(--spacing)*16)}.sm\:w-40{width:calc(var(--spacing)*40)}.sm\:w-72{width:calc(var(--spacing)*72)}.sm\:w-auto{width:auto}.sm\:max-w-\[140px\]{max-width:140px}.sm\:max-w-none{max-width:none}.sm\:max-w-xs{max-width:var(--container-xs)}.sm\:flex-1{flex:1}.sm\:flex-none{flex:none}.sm\:cursor-default{cursor:default}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:justify-between{justify-content:space-between}.sm\:gap-1{gap:calc(var(--spacing)*1)}.sm\:gap-1\.5{gap:calc(var(--spacing)*1.5)}.sm\:gap-2{gap:calc(var(--spacing)*2)}.sm\:gap-3{gap:calc(var(--spacing)*3)}.sm\:gap-4{gap:calc(var(--spacing)*4)}.sm\:gap-5{gap:calc(var(--spacing)*5)}.sm\:gap-6{gap:calc(var(--spacing)*6)}:where(.sm\:space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.sm\:space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}.sm\:border-bambu-dark-tertiary{border-color:var(--color-bambu-dark-tertiary)}.sm\:p-1\.5{padding:calc(var(--spacing)*1.5)}.sm\:p-2{padding:calc(var(--spacing)*2)}.sm\:p-3{padding:calc(var(--spacing)*3)}.sm\:p-4{padding:calc(var(--spacing)*4)}.sm\:px-2{padding-inline:calc(var(--spacing)*2)}.sm\:px-3{padding-inline:calc(var(--spacing)*3)}.sm\:text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.sm\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media (width>=48rem){.md\:top-\[2px\]{top:2px}.md\:left-\[2px\]{left:2px}.md\:col-span-2{grid-column:span 2/span 2}.md\:mx-0{margin-inline:calc(var(--spacing)*0)}.md\:block{display:block}.md\:inline{display:inline}.md\:h-4{height:calc(var(--spacing)*4)}.md\:h-5{height:calc(var(--spacing)*5)}.md\:min-h-0{min-height:calc(var(--spacing)*0)}.md\:w-4{width:calc(var(--spacing)*4)}.md\:w-9{width:calc(var(--spacing)*9)}.md\:min-w-\[200px\]{min-width:200px}.md\:flex-1{flex:1}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.md\:grid-cols-\[1fr_140px_auto\]{grid-template-columns:1fr 140px auto}.md\:flex-row{flex-direction:row}.md\:flex-wrap{flex-wrap:wrap}.md\:items-center{align-items:center}.md\:gap-4{gap:calc(var(--spacing)*4)}.md\:self-auto{align-self:auto}.md\:p-5{padding:calc(var(--spacing)*5)}.md\:p-6{padding:calc(var(--spacing)*6)}.md\:p-8{padding:calc(var(--spacing)*8)}.md\:px-0{padding-inline:calc(var(--spacing)*0)}.md\:py-2{padding-block:calc(var(--spacing)*2)}.md\:pb-0{padding-bottom:calc(var(--spacing)*0)}}@media (width>=64rem){.lg\:static{position:static}.lg\:sticky{position:sticky}.lg\:top-4{top:calc(var(--spacing)*4)}.lg\:top-6{top:calc(var(--spacing)*6)}.lg\:col-span-2{grid-column:span 2/span 2}.lg\:mb-0{margin-bottom:calc(var(--spacing)*0)}.lg\:mb-6{margin-bottom:calc(var(--spacing)*6)}.lg\:-ml-px{margin-left:-1px}.lg\:flex{display:flex}.lg\:hidden{display:none}.lg\:h-\[calc\(100vh-64px\)\]{height:calc(100vh - 64px)}.lg\:w-1\/2{width:50%}.lg\:w-1\/3{width:33.3333%}.lg\:w-2\/3{width:66.6667%}.lg\:w-48{width:calc(var(--spacing)*48)}.lg\:w-80{width:calc(var(--spacing)*80)}.lg\:w-\[480px\]{width:480px}.lg\:max-w-md{max-width:var(--container-md)}.lg\:max-w-sm{max-width:var(--container-sm)}.lg\:max-w-xl{max-width:var(--container-xl)}.lg\:flex-shrink-0{flex-shrink:0}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.lg\:grid-cols-\[1fr_20rem\]{grid-template-columns:1fr 20rem}.lg\:flex-col{flex-direction:column}.lg\:flex-row{flex-direction:row}.lg\:flex-nowrap{flex-wrap:nowrap}.lg\:justify-start{justify-content:flex-start}.lg\:gap-0{gap:calc(var(--spacing)*0)}.lg\:gap-6{gap:calc(var(--spacing)*6)}.lg\:gap-8{gap:calc(var(--spacing)*8)}.lg\:self-start{align-self:flex-start}.lg\:overflow-y-auto{overflow-y:auto}.lg\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.lg\:border-b-0{border-bottom-style:var(--tw-border-style);border-bottom-width:0}.lg\:border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}}@media (width>=80rem){.xl\:col-span-3{grid-column:span 3/span 3}.xl\:inline{display:inline}.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.xl\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}@media (width>=96rem){.\32 xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}:where(.dark\:divide-gray-800:where(.dark,.dark *)>:not(:last-child)){border-color:var(--color-gray-800)}.dark\:border-amber-700:where(.dark,.dark *){border-color:var(--color-amber-700)}.dark\:border-amber-800:where(.dark,.dark *){border-color:var(--color-amber-800)}.dark\:border-bambu-dark-tertiary:where(.dark,.dark *),.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:var(--color-bambu-dark-tertiary)}@supports (color:color-mix(in lab, red, red)){.dark\:border-bambu-dark-tertiary\/50:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-dark-tertiary)50%,transparent)}}.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:border-bambu-green\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-bambu-green)40%,transparent)}}.dark\:border-gray-600:where(.dark,.dark *){border-color:var(--color-gray-600)}.dark\:border-gray-700:where(.dark,.dark *){border-color:var(--color-gray-700)}.dark\:border-green-800:where(.dark,.dark *){border-color:var(--color-green-800)}.dark\:border-red-500\/30:where(.dark,.dark *){border-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.dark\:border-red-500\/30:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:border-red-500\/40:where(.dark,.dark *){border-color:#fb2c3666}@supports (color:color-mix(in lab, red, red)){.dark\:border-red-500\/40:where(.dark,.dark *){border-color:color-mix(in oklab,var(--color-red-500)40%,transparent)}}.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:#f99c001a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:#7b330633}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)20%,transparent)}}.dark\:bg-amber-900\/30:where(.dark,.dark *){background-color:#7b33064d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-amber-900\/30:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-amber-900)30%,transparent)}}.dark\:bg-bambu-dark:where(.dark,.dark *){background-color:var(--color-bambu-dark)}.dark\:bg-bambu-dark-secondary:where(.dark,.dark *){background-color:var(--color-bambu-dark-secondary)}.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:bg-bambu-green\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-bambu-green)20%,transparent)}}.dark\:bg-black\/80:where(.dark,.dark *){background-color:#000c}@supports (color:color-mix(in lab, red, red)){.dark\:bg-black\/80:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-black)80%,transparent)}}.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:#3080ff1a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:#3080ff33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:#1c398e33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-blue-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-blue-900)20%,transparent)}}.dark\:bg-gray-700:where(.dark,.dark *){background-color:var(--color-gray-700)}.dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--color-gray-800)}.dark\:bg-gray-800\/30:where(.dark,.dark *){background-color:#1e29394d}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/30:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)30%,transparent)}}.dark\:bg-gray-800\/40:where(.dark,.dark *){background-color:#1e293966}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/40:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)40%,transparent)}}.dark\:bg-gray-800\/50:where(.dark,.dark *){background-color:#1e293980}@supports (color:color-mix(in lab, red, red)){.dark\:bg-gray-800\/50:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-gray-800)50%,transparent)}}.dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--color-gray-900)}.dark\:bg-green-900\/20:where(.dark,.dark *){background-color:#0d542b33}@supports (color:color-mix(in lab, red, red)){.dark\:bg-green-900\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-green-900)20%,transparent)}}.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:#fb2c361a}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-500\/10:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:#fb2c3633}@supports (color:color-mix(in lab, red, red)){.dark\:bg-red-500\/20:where(.dark,.dark *){background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.dark\:text-amber-100:where(.dark,.dark *){color:var(--color-amber-100)}.dark\:text-amber-200:where(.dark,.dark *){color:var(--color-amber-200)}.dark\:text-amber-300:where(.dark,.dark *){color:var(--color-amber-300)}.dark\:text-amber-400:where(.dark,.dark *){color:var(--color-amber-400)}.dark\:text-bambu-gray:where(.dark,.dark *),.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-gray\/30:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)30%,transparent)}}.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:var(--color-bambu-gray)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-gray\/50:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-gray)50%,transparent)}}.dark\:text-bambu-green:where(.dark,.dark *),.dark\:text-bambu-green\/60:where(.dark,.dark *){color:var(--color-bambu-green)}@supports (color:color-mix(in lab, red, red)){.dark\:text-bambu-green\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-bambu-green)60%,transparent)}}.dark\:text-blue-200:where(.dark,.dark *){color:var(--color-blue-200)}.dark\:text-blue-200\/80:where(.dark,.dark *){color:#bedbffcc}@supports (color:color-mix(in lab, red, red)){.dark\:text-blue-200\/80:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-200)80%,transparent)}}.dark\:text-blue-300:where(.dark,.dark *){color:var(--color-blue-300)}.dark\:text-blue-300\/60:where(.dark,.dark *){color:#90c5ff99}@supports (color:color-mix(in lab, red, red)){.dark\:text-blue-300\/60:where(.dark,.dark *){color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.dark\:text-blue-400:where(.dark,.dark *){color:var(--color-blue-400)}.dark\:text-emerald-300:where(.dark,.dark *){color:var(--color-emerald-300)}.dark\:text-emerald-400:where(.dark,.dark *){color:var(--color-emerald-400)}.dark\:text-gray-100:where(.dark,.dark *){color:var(--color-gray-100)}.dark\:text-gray-300:where(.dark,.dark *){color:var(--color-gray-300)}.dark\:text-gray-400:where(.dark,.dark *){color:var(--color-gray-400)}.dark\:text-gray-500:where(.dark,.dark *){color:var(--color-gray-500)}.dark\:text-gray-600:where(.dark,.dark *){color:var(--color-gray-600)}.dark\:text-green-200:where(.dark,.dark *){color:var(--color-green-200)}.dark\:text-green-400:where(.dark,.dark *){color:var(--color-green-400)}.dark\:text-orange-200:where(.dark,.dark *){color:var(--color-orange-200)}.dark\:text-orange-400:where(.dark,.dark *){color:var(--color-orange-400)}.dark\:text-red-400:where(.dark,.dark *){color:var(--color-red-400)}.dark\:text-red-400\/70:where(.dark,.dark *){color:#ff6568b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-red-400\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-red-400)70%,transparent)}}.dark\:text-white:where(.dark,.dark *){color:var(--color-white)}.dark\:text-yellow-200:where(.dark,.dark *){color:var(--color-yellow-200)}.dark\:text-yellow-200\/70:where(.dark,.dark *){color:#fff085b3}@supports (color:color-mix(in lab, red, red)){.dark\:text-yellow-200\/70:where(.dark,.dark *){color:color-mix(in oklab,var(--color-yellow-200)70%,transparent)}}@media (hover:hover){.dark\:hover\:border-gray-500:where(.dark,.dark *):hover{border-color:var(--color-gray-500)}.dark\:hover\:bg-bambu-dark-tertiary:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark-tertiary)}.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:var(--color-bambu-dark)}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-bambu-dark\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-bambu-dark)50%,transparent)}}.dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--color-gray-600)}.dark\:hover\:bg-gray-800\/50:where(.dark,.dark *):hover{background-color:#1e293980}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-gray-800\/50:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-gray-800)50%,transparent)}}.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:#fb2c364d}@supports (color:color-mix(in lab, red, red)){.dark\:hover\:bg-red-500\/30:where(.dark,.dark *):hover{background-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.dark\:hover\:text-amber-200:where(.dark,.dark *):hover{color:var(--color-amber-200)}.dark\:hover\:text-blue-300:where(.dark,.dark *):hover{color:var(--color-blue-300)}.dark\:hover\:text-gray-200:where(.dark,.dark *):hover{color:var(--color-gray-200)}.dark\:hover\:text-gray-300:where(.dark,.dark *):hover{color:var(--color-gray-300)}.dark\:hover\:text-red-300:where(.dark,.dark *):hover{color:var(--color-red-300)}.dark\:hover\:text-white:where(.dark,.dark *):hover{color:var(--color-white)}}.\[\&\:\:-webkit-inner-spin-button\]\:appearance-none::-webkit-inner-spin-button{appearance:none}.\[\&\:\:-webkit-outer-spin-button\]\:appearance-none::-webkit-outer-spin-button{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:h-3::-webkit-slider-thumb{height:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:w-3::-webkit-slider-thumb{width:calc(var(--spacing)*3)}.\[\&\:\:-webkit-slider-thumb\]\:cursor-pointer::-webkit-slider-thumb{cursor:pointer}.\[\&\:\:-webkit-slider-thumb\]\:appearance-none::-webkit-slider-thumb{appearance:none}.\[\&\:\:-webkit-slider-thumb\]\:rounded-full::-webkit-slider-thumb{border-radius:3.40282e38px}.\[\&\:\:-webkit-slider-thumb\]\:bg-bambu-green::-webkit-slider-thumb{background-color:var(--color-bambu-green)}.\[\&\>\*\]\:shrink-0>*{flex-shrink:0}}@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/inter-latin.woff2)format("woff2");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/fonts/inter-latin-ext.woff2)format("woff2");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}html{font-size:14.4px}:root{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438;--status-ok:#22c55e;--status-error:#ef4444;--status-warning:#f59e0b;--bg-primary:#f5f5f5;--bg-secondary:#fff;--bg-tertiary:#e5e5e5;--text-primary:#1a1a1a;--text-secondary:#4a4a4a;--text-muted:#6b6b6b;--text-tertiary:gray;--border-color:#d4d4d4;--card-shadow:0 2px 8px #00000014;--glow-color:transparent;font-synthesis:none;text-rendering:optimizelegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Inter,system-ui,sans-serif;font-weight:400;line-height:1.5}.dark{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d;--card-shadow:0 4px 16px #0006}.bg-warm{--bg-primary:#faf8f5;--bg-secondary:#fffefa;--bg-tertiary:#e8e4dd;--text-primary:#2d2a26;--text-secondary:#5c5750;--text-muted:#7a756c;--text-tertiary:#9a9590;--border-color:#d8d4cc}.bg-cool{--bg-primary:#f0f4f8;--bg-secondary:#fff;--bg-tertiary:#dce4ec;--text-primary:#1a2530;--text-secondary:#4a5568;--text-muted:#6b7a8a;--text-tertiary:#8a9aaa;--border-color:#c8d4e0}.dark.bg-neutral{--bg-primary:#1a1a1a;--bg-secondary:#2d2d2d;--bg-tertiary:#3d3d3d;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:gray;--text-tertiary:#4a4a4a;--border-color:#3d3d3d}.dark.bg-warm{--bg-primary:#1c1a18;--bg-secondary:#2e2a26;--bg-tertiary:#3e3a36;--text-primary:#f5f0ea;--text-secondary:#b0a898;--text-muted:#8a8278;--text-tertiary:#5a5248;--border-color:#3e3a36}.dark.bg-cool{--bg-primary:#181c20;--bg-secondary:#262c32;--bg-tertiary:#363e46;--text-primary:#f0f4f8;--text-secondary:#98a8b8;--text-muted:#788898;--text-tertiary:#4a5a6a;--border-color:#363e46}.dark.bg-oled{--bg-primary:#000;--bg-secondary:#141414;--bg-tertiary:#1f1f1f;--text-primary:#fff;--text-secondary:#a0a0a0;--text-muted:#707070;--text-tertiary:#404040;--border-color:#2a2a2a}.dark.bg-slate{--bg-primary:#0f172a;--bg-secondary:#1e293b;--bg-tertiary:#334155;--text-primary:#f1f5f9;--text-secondary:#94a3b8;--text-muted:#64748b;--text-tertiary:#475569;--border-color:#334155}.dark.bg-forest{--bg-primary:#121a16;--bg-secondary:#1c2a22;--bg-tertiary:#2a3d30;--text-primary:#e8f5ec;--text-secondary:#8aa894;--text-muted:#6a8874;--text-tertiary:#4a6854;--border-color:#2a3d30}.printer-control-buttons-container{container-type:inline-size}@container (width<=220px){.printer-control-buttons{flex-direction:column;align-items:stretch}.printer-control-buttons>button{width:100%}}.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px var(--accent)}@supports (color:color-mix(in lab, red, red)){.style-glow{--card-shadow:0 2px 8px #00000014,0 0 25px color-mix(in srgb,var(--accent)12%,transparent)}}.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px var(--accent)}@supports (color:color-mix(in lab, red, red)){.dark.style-glow{--card-shadow:0 4px 20px #00000080,0 0 40px color-mix(in srgb,var(--accent)15%,transparent)}}.style-vibrant{--card-shadow:0 8px 30px #00000026,0 2px 8px #0000001a}.dark.style-vibrant{--card-shadow:0 10px 40px #0009,0 4px 12px #0006}.accent-green{--accent:#00ae42;--accent-light:#00c64d;--accent-dark:#009438}.accent-teal{--accent:#14b8a6;--accent-light:#2dd4bf;--accent-dark:#0d9488}.accent-blue{--accent:#3b82f6;--accent-light:#60a5fa;--accent-dark:#2563eb}.accent-orange{--accent:#f97316;--accent-light:#fb923c;--accent-dark:#ea580c}.accent-purple{--accent:#8b5cf6;--accent-light:#a78bfa;--accent-dark:#7c3aed}.accent-red{--accent:#ef4444;--accent-light:#f87171;--accent-dark:#dc2626}body{background-color:var(--bg-primary);color:var(--text-primary);min-height:100vh;margin:0;transition:background-color .2s,color .2s}#root{min-height:100vh}.text-white{color:var(--text-primary)}.bg-bambu-dark,.bg-bambu-dark-secondary,.bg-bambu-dark-tertiary,.border-bambu-dark-tertiary{transition:background-color .2s,border-color .2s}@keyframes slide-in{0%{opacity:0;transform:translate(100%)}to{opacity:1;transform:translate(0)}}.animate-slide-in{animation:.2s ease-out slide-in}.icon-theme{opacity:.5}.dark .icon-theme{filter:invert();opacity:.4}.icon-green{filter:invert(48%)sepia(89%)saturate(459%)hue-rotate(93deg)brightness(95%)contrast(92%);opacity:1}.icon-heating{filter:invert(50%)sepia()saturate(1000%)hue-rotate(360deg)brightness()contrast();opacity:1}.dark .jogpad-theme{filter:brightness(.35)contrast(1.2)}.ams-empty-slot{background:repeating-linear-gradient(45deg,#444,#444 2px,#222 2px 4px)}.dark .ams-empty-slot{background:repeating-linear-gradient(45deg,#555,#555 2px,#333 2px 4px)}.touch-manipulation{touch-action:manipulation}.safe-area-bottom{padding-bottom:env(safe-area-inset-bottom,0)}.safe-area-top{padding-top:env(safe-area-inset-top,0)}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}@keyframes slide-in-left{0%{transform:translate(-100%)}to{transform:translate(0)}}.animate-slide-in-left{animation:.3s ease-out slide-in-left}@keyframes spoolbuddy-optimized-ping{0%{opacity:.8;transform:scale(.8)}80%,to{opacity:0;transform:scale(2.2)}}.spoolbuddy-optimized-ping{will-change:auto;contain:layout;animation:3.5s cubic-bezier(0,0,.2,1) infinite spoolbuddy-optimized-ping}.spoolbuddy-spool-glow{will-change:auto;transform:scale(2)}@media (prefers-reduced-motion:reduce){.spoolbuddy-optimized-ping{opacity:.25;animation:none;transform:scale(1.2)}.spoolbuddy-spool-glow{transition:none}}@keyframes slide-down{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.animate-slide-down{animation:.25s ease-out slide-down}.card-shadow{box-shadow:var(--card-shadow)}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl{flex-direction:column;height:90vh;max-height:90vh;display:flex}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:first-child,[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:last-child{flex-shrink:0}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl>div:nth-child(2){flex:auto;min-height:0;overflow-y:auto}[data-spoolbuddy-kiosk] .fixed .relative.max-w-2xl .max-h-96{max-height:none}.calendar-scroll{scrollbar-width:thin;scrollbar-color:var(--text-muted)transparent}@supports (color:color-mix(in lab, red, red)){.calendar-scroll{scrollbar-color:color-mix(in srgb,var(--text-muted)60%,transparent)transparent}}.calendar-scroll::-webkit-scrollbar{width:8px}.calendar-scroll::-webkit-scrollbar-track{background:0 0}.calendar-scroll::-webkit-scrollbar-thumb{background-color:var(--text-muted)}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb{background-color:color-mix(in srgb,var(--text-muted)60%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid var(--bg-secondary);border-radius:999px}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb{border:2px solid color-mix(in srgb,var(--bg-secondary)70%,transparent)}}.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted)}@supports (color:color-mix(in lab, red, red)){.calendar-scroll::-webkit-scrollbar-thumb:hover{background-color:color-mix(in srgb,var(--text-muted)80%,transparent)}}@media (hover:hover) and (pointer:fine){.history-thumb-hover:hover .history-thumb-preview{opacity:1}}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}.hg-theme-default{box-sizing:border-box;touch-action:manipulation;-webkit-user-select:none;user-select:none;background-color:#ececec;border-radius:5px;width:100%;padding:5px;font-family:HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif;overflow:hidden}.hg-theme-default .hg-button span,.hg-theme-default .hg-button span svg{pointer-events:none}.hg-theme-default button.hg-button{font-size:inherit;border-width:0}.hg-theme-default .hg-button{flex-grow:1;display:inline-block}.hg-theme-default .hg-row{display:flex}.hg-theme-default .hg-row:not(:last-child){margin-bottom:5px}.hg-theme-default .hg-row .hg-button-container,.hg-theme-default .hg-row .hg-button:not(:last-child){margin-right:5px}.hg-theme-default .hg-row>div:last-child{margin-right:0}.hg-theme-default .hg-row .hg-button-container{display:flex}.hg-theme-default .hg-button{box-sizing:border-box;cursor:pointer;-webkit-tap-highlight-color:#0000;background:#fff;border-bottom:1px solid #b5b5b5;border-radius:5px;justify-content:center;align-items:center;height:40px;padding:5px;display:flex;box-shadow:0 0 3px -1px #0000004d}.hg-theme-default .hg-button.hg-standardBtn{width:20px}.hg-theme-default .hg-button.hg-activeButton{background:#efefef}.hg-theme-default.hg-layout-numeric .hg-button{justify-content:center;align-items:center;width:33.3%;height:60px;display:flex}.hg-theme-default .hg-button.hg-button-numpadadd,.hg-theme-default .hg-button.hg-button-numpadenter{height:85px}.hg-theme-default .hg-button.hg-button-numpad0{width:105px}.hg-theme-default .hg-button.hg-button-com{max-width:85px}.hg-theme-default .hg-button.hg-standardBtn.hg-button-at{max-width:45px}.hg-theme-default .hg-button.hg-selectedButton{color:#fff;background:#05194687}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\.com]{max-width:82px}.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=\@]{max-width:60px}.hg-candidate-box{-webkit-user-select:none;user-select:none;background:#ececec;border-bottom:2px solid #b5b5b5;border-radius:5px;margin-top:-10px;display:inline-flex;position:absolute;transform:translateY(-100%)}ul.hg-candidate-box-list{flex:1;margin:0;padding:0;list-style:none;display:flex}li.hg-candidate-box-list-item{justify-content:center;align-items:center;width:40px;height:40px;display:flex}li.hg-candidate-box-list-item:hover{cursor:pointer;background:#00000008}li.hg-candidate-box-list-item:active{background:#0000001a}.hg-candidate-box-prev:before{content:"◄"}.hg-candidate-box-next:before{content:"►"}.hg-candidate-box-next,.hg-candidate-box-prev{color:#969696;cursor:pointer;align-items:center;padding:0 10px;display:flex}.hg-candidate-box-next{border-top-right-radius:5px;border-bottom-right-radius:5px}.hg-candidate-box-prev{border-top-left-radius:5px;border-bottom-left-radius:5px}.hg-candidate-box-btn-active{color:#444}.simple-keyboard.vkb-theme{background:#1a1a1a;border-top:1px solid #333;padding:8px 4px;font-family:inherit}.simple-keyboard.vkb-theme .hg-row{gap:4px;margin-bottom:4px;flex-flow:row!important;display:flex!important}.simple-keyboard.vkb-theme .hg-row:last-child{margin-bottom:0}.simple-keyboard.vkb-theme .hg-button{color:#e0e0e0;cursor:pointer;background:#2d2d2d;border:none;border-radius:6px;flex:auto;justify-content:center;align-items:center;min-width:0;height:44px;padding:0 2px;font-size:16px;font-weight:500;transition:background .1s;box-shadow:0 1px 2px #0000004d;display:inline-flex!important}.simple-keyboard.vkb-theme .hg-button:active{color:#fff;background:#00ae42}.simple-keyboard.vkb-theme .hg-button-bksp,.simple-keyboard.vkb-theme .hg-button-shift,.simple-keyboard.vkb-theme .hg-button-lock{color:#aaa;background:#3a3a3a;flex-grow:1.5}.simple-keyboard.vkb-theme .hg-button-close{color:#aaa;background:#3a3a3a;flex-grow:2;font-weight:600}.simple-keyboard.vkb-theme .hg-button-close:active{background:#555}.simple-keyboard.vkb-theme .hg-button-space{flex-grow:7}.simple-keyboard.vkb-theme .hg-activeButton{color:#fff;background:#00ae42} diff --git a/static/index.html b/static/index.html index 55406fe82..a8becb5cf 100644 --- a/static/index.html +++ b/static/index.html @@ -26,8 +26,8 @@ - - + +